-
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 adds the ability to change the master password of an existing xud node. Changing the password re-encrypts the node key on disk and queues password changes for all lnd wallets. Lnd does not currently offer the ability to change the password of an unlocked, running instance. Instead lnd can only change its password right after being started while it is still locked. Xud therefore saves the old password for each lnd wallet to the xud database and encrypts the old password using the new passwords. On subsequent unlocks of xud, when we go to unlock lnd wallets we first check whether we have any old passwords in the database corresponding to any lnd wallets. If we do, we decrypt the old password and change the password for lnd, which in turn will unlock lnd. Closes #1981.
- Loading branch information
Showing
21 changed files
with
1,142 additions
and
416 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import readline from 'readline'; | ||
import { Arguments } from 'yargs'; | ||
import { ChangePasswordRequest } from '../../proto/xudrpc_pb'; | ||
import { callback, loadXudClient } from '../command'; | ||
|
||
export const command = 'changepass'; | ||
|
||
export const describe = 'change the password for an existing xud instance'; | ||
|
||
export const builder = {}; | ||
|
||
const formatOutput = () => { | ||
console.log('The master xud password was succesfully changed.'); | ||
console.log('Passwords for lnd wallets will be changed the next time xud is restarted and unlocked.'); | ||
}; | ||
|
||
export const handler = (argv: Arguments<any>) => { | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
terminal: true, | ||
}); | ||
|
||
console.log(`\ | ||
You are changing the master password for xud and underlying wallets.\ | ||
`); | ||
process.stdout.write('Enter old password: '); | ||
rl.question('', (oldPassword) => { | ||
process.stdout.write('\nEnter new password: '); | ||
rl.question('', (password1) => { | ||
process.stdout.write('\nRe-enter password: '); | ||
rl.question('', async (password2) => { | ||
process.stdout.write('\n\n'); | ||
rl.close(); | ||
if (password1 === password2) { | ||
const request = new ChangePasswordRequest(); | ||
request.setNewPassword(password1); | ||
request.setOldPassword(oldPassword); | ||
|
||
const client = await loadXudClient(argv); | ||
// wait up to 3 seconds for rpc server to listen before call in case xud was just started | ||
client.waitForReady(Date.now() + 3000, () => { | ||
client.changePassword(request, callback(argv, formatOutput)); | ||
}); | ||
} else { | ||
process.exitCode = 1; | ||
console.error('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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.