Skip to content

Commit d1abc67

Browse files
authored
feat(cli,ironfish): Check if the wallet is locked before fetching accounts (#5333)
1 parent a1c7df2 commit d1abc67

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ironfish-cli/src/utils/account.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export async function useAccount(
1414
return account
1515
}
1616

17+
const status = await client.wallet.getAccountsStatus()
18+
if (status.content.locked) {
19+
throw new Error('Wallet is locked. Unlock the wallet to fetch accounts')
20+
}
21+
1722
const defaultAccount = await client.wallet.getAccounts({ default: true })
1823

1924
if (defaultAccount.content.accounts.length) {

ironfish/src/rpc/routes/wallet/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import { serializeRpcWalletNote } from './serializers'
1212
import { RpcWalletNote } from './types'
1313

1414
export function getAccount(wallet: Wallet, name?: string): Account {
15+
if (wallet.locked) {
16+
throw new RpcValidationError('Wallet is locked. Unlock the wallet to fetch accounts')
17+
}
18+
1519
if (name) {
1620
const account = wallet.getAccountByName(name)
1721
if (account) {

0 commit comments

Comments
 (0)