Skip to content

Commit

Permalink
feat(cli,ironfish): Check if the wallet is locked before fetching acc…
Browse files Browse the repository at this point in the history
…ounts (#5333)
  • Loading branch information
rohanjadvani committed Aug 26, 2024
1 parent a1c7df2 commit d1abc67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ironfish-cli/src/utils/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export async function useAccount(
return account
}

const status = await client.wallet.getAccountsStatus()
if (status.content.locked) {
throw new Error('Wallet is locked. Unlock the wallet to fetch accounts')
}

const defaultAccount = await client.wallet.getAccounts({ default: true })

if (defaultAccount.content.accounts.length) {
Expand Down
4 changes: 4 additions & 0 deletions ironfish/src/rpc/routes/wallet/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { serializeRpcWalletNote } from './serializers'
import { RpcWalletNote } from './types'

export function getAccount(wallet: Wallet, name?: string): Account {
if (wallet.locked) {
throw new RpcValidationError('Wallet is locked. Unlock the wallet to fetch accounts')
}

if (name) {
const account = wallet.getAccountByName(name)
if (account) {
Expand Down

0 comments on commit d1abc67

Please sign in to comment.