File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
ironfish-cli/src/commands/wallet Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments