UNPKG

xud

Version:
60 lines 2.97 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handler = exports.builder = exports.describe = exports.command = void 0; const readline_1 = __importDefault(require("readline")); const xudrpc_pb_1 = require("../../proto/xudrpc_pb"); const command_1 = require("../command"); exports.command = 'changepass'; exports.describe = 'change the password for an existing xud instance'; exports.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.'); }; exports.handler = (argv) => { const rl = readline_1.default.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('', (password2) => __awaiter(void 0, void 0, void 0, function* () { process.stdout.write('\n\n'); rl.close(); if (password1 === password2) { const request = new xudrpc_pb_1.ChangePasswordRequest(); request.setNewPassword(password1); request.setOldPassword(oldPassword); const client = yield command_1.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, command_1.callback(argv, formatOutput)); }); } else { process.exitCode = 1; console.error('Passwords do not match, please try again'); } })); }); }); }; //# sourceMappingURL=changepass.js.map