File tree Expand file tree Collapse file tree 4 files changed +32
-8
lines changed Expand file tree Collapse file tree 4 files changed +32
-8
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ export class DecryptCommand extends IronfishCommand {
32
32
33
33
let passphrase = flags . passphrase
34
34
if ( ! passphrase ) {
35
- passphrase = await inputPrompt ( 'Enter a passphrase to decrypt the wallet' , true )
35
+ passphrase = await inputPrompt ( 'Enter a passphrase to decrypt the wallet' , true , {
36
+ password : true ,
37
+ } )
36
38
}
37
39
38
40
try {
Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ export class EncryptCommand extends IronfishCommand {
17
17
passphrase : Flags . string ( {
18
18
description : 'Passphrase to encrypt the wallet with' ,
19
19
} ) ,
20
+ confirm : Flags . boolean ( {
21
+ description : 'Suppress the passphrase confirmation prompt' ,
22
+ } ) ,
20
23
}
21
24
22
25
async start ( ) : Promise < void > {
@@ -32,7 +35,20 @@ export class EncryptCommand extends IronfishCommand {
32
35
33
36
let passphrase = flags . passphrase
34
37
if ( ! passphrase ) {
35
- passphrase = await inputPrompt ( 'Enter a passphrase to encrypt the wallet' , true )
38
+ passphrase = await inputPrompt ( 'Enter a passphrase to encrypt the wallet' , true , {
39
+ password : true ,
40
+ } )
41
+ }
42
+
43
+ if ( ! flags . confirm ) {
44
+ const confirmedPassphrase = await inputPrompt ( 'Confirm your passphrase' , true , {
45
+ password : true ,
46
+ } )
47
+
48
+ if ( confirmedPassphrase !== passphrase ) {
49
+ this . log ( 'Passphrases do not match' )
50
+ this . exit ( 1 )
51
+ }
36
52
}
37
53
38
54
try {
Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ export class UnlockCommand extends IronfishCommand {
36
36
37
37
let passphrase = flags . passphrase
38
38
if ( ! passphrase ) {
39
- passphrase = await inputPrompt ( 'Enter a passphrase to unlock the wallet' , true )
39
+ passphrase = await inputPrompt ( 'Enter a passphrase to unlock the wallet' , true , {
40
+ password : true ,
41
+ } )
40
42
}
41
43
42
44
try {
Original file line number Diff line number Diff line change 5
5
import { ux } from '@oclif/core'
6
6
import inquirer from 'inquirer'
7
7
8
- async function _inputPrompt ( message : string ) : Promise < string > {
8
+ async function _inputPrompt ( message : string , options ?: { password : boolean } ) : Promise < string > {
9
9
const result : { prompt : string } = await inquirer . prompt ( {
10
- type : 'input' ,
10
+ type : options ?. password ? 'password' : 'input' ,
11
11
name : 'prompt' ,
12
12
message : `${ message } :` ,
13
13
} )
14
14
return result . prompt . trim ( )
15
15
}
16
16
17
- export async function inputPrompt ( message : string , required : boolean = false ) : Promise < string > {
17
+ export async function inputPrompt (
18
+ message : string ,
19
+ required : boolean = false ,
20
+ options ?: { password : boolean } ,
21
+ ) : Promise < string > {
18
22
let userInput : string = ''
19
23
20
24
if ( required ) {
21
25
while ( ! userInput ) {
22
- userInput = await _inputPrompt ( message )
26
+ userInput = await _inputPrompt ( message , options )
23
27
}
24
28
} else {
25
- userInput = await _inputPrompt ( message )
29
+ userInput = await _inputPrompt ( message , options )
26
30
}
27
31
28
32
return userInput
You can’t perform that action at this time.
0 commit comments