Skip to content

Commit 9c7fea7

Browse files
author
Danny Diekroeger
committed
recoveryInfo takes in a bitgo half-signed tx
1 parent 6a7f0b1 commit 9c7fea7

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

app/admin.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ setVerificationCommand.addArgument(
108108

109109
const recoveryInfoCommand = subparsers.addParser('recoveryInfo', { addHelp: true });
110110
recoveryInfoCommand.addArgument(
111-
['pub'],
111+
['file'],
112112
{
113113
action: 'store',
114-
help: 'the backup pub (wallet key) to be recovered'
114+
help: 'the path to the recovery file that bitgo provided'
115115
}
116116
);
117117

@@ -376,14 +376,17 @@ const handleVerification = co(function *(args) {
376376
});
377377

378378
const handleRecoveryInfo = co(function *(args){
379-
const walletkey = yield WalletKey.findOne({ pub: args.pub });
379+
const json = JSON.parse(fs.readFileSync(args.file));
380+
const pub = json.backupKey;
381+
const walletkey = yield WalletKey.findOne({ pub });
380382
const masterkey = yield MasterKey.findOne({ pub: walletkey.masterKey });
381-
382-
const outfile = { walletkey, masterkey };
383-
const filename = 'recovery-key-info.json';
384-
console.log('Got info... writing file ' + filename);
385-
fs.writeFileSync(filename, JSON.stringify(outfile, null, 2));
386-
console.log('Done');
383+
json.masterkey = masterkey.pub;
384+
json.masterkeypath = masterkey.path;
385+
json.walletkeypath = walletkey.path;
386+
const filename = args.file.substring(0,args.file.length - 5) + '-prepared.json';
387+
console.log('got info... writing file ' + filename);
388+
fs.writeFileSync(filename, JSON.stringify(json, null, 2));
389+
console.log('done.');
387390
});
388391

389392
const requireDB = function() {

bin/admin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Promise = require('bluebird');
44
const admin = require('../app/admin');
55

66
Promise.try(admin.run).catch(function(e) {
7-
console.log('Did not connect to database, proceeding offline...');
7+
console.log('Error connecting to database, proceeding offline...');
88
try {
99
admin.db.connection.close();
1010
} catch(e) {

0 commit comments

Comments
 (0)