-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This prompts the user for a password without displaying it on the screen or saving it to the command history for the `CreateNode` and `UnlockNode` calls via the cli.
- Loading branch information
Showing
2 changed files
with
40 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
import { Arguments } from 'yargs'; | ||
import { callback, loadXudInitClient } from '../command'; | ||
import { CreateNodeRequest } from '../../proto/xudrpc_pb'; | ||
import readline from 'readline'; | ||
|
||
export const command = 'create <password>'; | ||
export const command = 'create'; | ||
|
||
export const describe = 'create an xud node'; | ||
|
||
export const builder = { | ||
password: { | ||
description: 'password to encrypt xud key and wallets', | ||
type: 'string', | ||
}, | ||
}; | ||
export const builder = {}; | ||
|
||
export const handler = (argv: Arguments) => { | ||
const request = new CreateNodeRequest(); | ||
request.setPassword(argv.password); | ||
loadXudInitClient(argv).createNode(request, callback(argv)); | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
terminal: true, | ||
}); | ||
|
||
process.stdout.write('Enter master xud password: '); | ||
rl.question('', (password1) => { | ||
process.stdout.write('\n'); | ||
process.stdout.write('Re-enter password: '); | ||
rl.question('', (password2) => { | ||
process.stdout.write('\n'); | ||
rl.close(); | ||
if (password1 === password2) { | ||
const request = new CreateNodeRequest(); | ||
request.setPassword(argv.password); | ||
loadXudInitClient(argv).createNode(request, callback(argv)); | ||
} else { | ||
console.log('Passwords do not match, please try again'); | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
import { Arguments } from 'yargs'; | ||
import { callback, loadXudInitClient } from '../command'; | ||
import { UnlockNodeRequest } from '../../proto/xudrpc_pb'; | ||
import readline from 'readline'; | ||
|
||
export const command = 'unlock <password>'; | ||
export const command = 'unlock'; | ||
|
||
export const describe = 'unlock an xud node'; | ||
|
||
export const builder = { | ||
password: { | ||
description: 'password to decrypt xud key and wallets', | ||
type: 'string', | ||
}, | ||
}; | ||
export const builder = {}; | ||
|
||
export const handler = (argv: Arguments) => { | ||
const request = new UnlockNodeRequest(); | ||
request.setPassword(argv.password); | ||
loadXudInitClient(argv).unlockNode(request, callback(argv)); | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
terminal: true, | ||
}); | ||
|
||
process.stdout.write('Enter master xud password: '); | ||
rl.question('', (password) => { | ||
process.stdout.write('\n'); | ||
rl.close(); | ||
const request = new UnlockNodeRequest(); | ||
request.setPassword(password); | ||
loadXudInitClient(argv).unlockNode(request, callback(argv)); | ||
}); | ||
}; |