Skip to content

Commit a1c7df2

Browse files
authored
feat(cli): Add wallet:lock (#5330)
1 parent b463f60 commit a1c7df2

File tree

1 file changed

+40
-0
lines changed
  • ironfish-cli/src/commands/wallet

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4+
import { RpcRequestError } from '@ironfish/sdk'
5+
import { IronfishCommand } from '../../command'
6+
import { RemoteFlags } from '../../flags'
7+
8+
export class LockCommand extends IronfishCommand {
9+
static hidden = true
10+
11+
static description = 'lock accounts in the wallet'
12+
13+
static flags = {
14+
...RemoteFlags,
15+
}
16+
17+
async start(): Promise<void> {
18+
const client = await this.connectRpc()
19+
20+
const response = await client.wallet.getAccountsStatus()
21+
if (!response.content.encrypted) {
22+
this.log('Wallet is decrypted')
23+
this.exit(1)
24+
}
25+
26+
try {
27+
await client.wallet.lock()
28+
} catch (e) {
29+
if (e instanceof RpcRequestError) {
30+
this.log('Wallet lock failed')
31+
this.exit(1)
32+
}
33+
34+
throw e
35+
}
36+
37+
this.log('Locked the wallet')
38+
this.exit(0)
39+
}
40+
}

0 commit comments

Comments
 (0)