fix bit cmds: address, addresses, balance, broadcast, confirm, history, reject, rm, send, sign, status & txproposals
This commit is contained in:
parent
f486ecacd3
commit
f89c863419
|
@ -9,8 +9,9 @@ program
|
|||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
var client = utils.getClient(program);
|
||||
client.createAddress(function(err, x) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.createAddress(function(err, x) {
|
||||
utils.die(err);
|
||||
console.log('* New Address %s ', x.address);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,14 +10,20 @@ program
|
|||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
var client = utils.getClient(program);
|
||||
client.getMainAddresses({
|
||||
|
||||
utils.getClient(program, function (client) {
|
||||
client.getMainAddresses({
|
||||
doNotVerify: true
|
||||
}, function(err, x) {
|
||||
}, function(err, x) {
|
||||
utils.die(err);
|
||||
|
||||
if (x.length > 0) {
|
||||
console.log('* Addresses:');
|
||||
_.each(x, function(a) {
|
||||
console.log(' ', a.address);
|
||||
});
|
||||
} else {
|
||||
console.log('* No addresses.');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,9 +9,10 @@ program
|
|||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
var client = utils.getClient(program);
|
||||
|
||||
client.getBalance(function(err, x) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.getBalance(function(err, x) {
|
||||
utils.die(err);
|
||||
console.log('* Wallet balance %s (Locked %s)', utils.renderAmount(x.totalAmount), utils.renderAmount(x.lockedAmount) );
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,19 +11,16 @@ program
|
|||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
if (!args[0])
|
||||
program.help();
|
||||
var txpid = args[0] || '';
|
||||
|
||||
var txpid = args[0];
|
||||
var client = utils.getClient(program);
|
||||
|
||||
client.getTxProposals({}, function(err, txps) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.getTxProposals({}, function(err, txps) {
|
||||
utils.die(err);
|
||||
|
||||
var txp = utils.findOneTxProposal(txps, txpid);
|
||||
client.broadcastTxProposal(txp, function(err, txid) {
|
||||
client.broadcastTxProposal(txp, function(err, txp) {
|
||||
utils.die(err);
|
||||
console.log('Transaction Broadcasted: TXID: ' + x.txid);
|
||||
|
||||
console.log('Transaction Broadcasted: TXID: ' + txp.txid);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,24 +9,27 @@ program = utils.configureCommander(program);
|
|||
program
|
||||
.parse(process.argv);
|
||||
|
||||
var client = utils.getClient(program);
|
||||
|
||||
client.getStatus(function(err, x, myCopayerId) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.getStatus(function(err, x) {
|
||||
utils.die(err);
|
||||
console.log('\n To be sure that none Copayer has joined more that once to this wallet, you can asked them their confirmation number. They can grab them using this (bit confirm) command.');
|
||||
|
||||
console.log('\n * Copayer confirmations ids:');
|
||||
if (x.wallet.n == 1) {
|
||||
console.log('Confirmations only work on shared wallets');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('\n To be sure that no copayer has joined this wallet more than once, you can asked them for their confirmation number. They can get theirs by running the bit-confirm command.');
|
||||
console.log('\n * Copayer confirmation IDs:');
|
||||
|
||||
var myConfirmationId;
|
||||
_.each(x.wallet.copayers, function(x) {
|
||||
var confirmationId = utils.confirmationId(x);
|
||||
if (x.id != myCopayerId)
|
||||
if (x.id != client.credentials.copayerId)
|
||||
console.log('\t\t* %s : %s', x.name, confirmationId);
|
||||
else
|
||||
myConfirmationId = confirmationId;
|
||||
});
|
||||
|
||||
|
||||
console.log('\t\t---');
|
||||
console.log('\t\tYour confirmation ID: %s', myConfirmationId);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,18 +4,16 @@ var _ = require('lodash');
|
|||
var fs = require('fs');
|
||||
var moment = require('moment');
|
||||
var program = require('commander');
|
||||
var Utils = require('./cli-utils');
|
||||
program = Utils.configureCommander(program);
|
||||
var utils = require('./cli-utils');
|
||||
program = utils.configureCommander(program);
|
||||
|
||||
program
|
||||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
var client = Utils.getClient(program);
|
||||
|
||||
var txData;
|
||||
|
||||
client.getTxHistory({}, function (err, txs) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.getTxHistory({}, function (err, txs) {
|
||||
if (_.isEmpty(txs))
|
||||
return;
|
||||
|
||||
|
@ -23,7 +21,7 @@ client.getTxHistory({}, function (err, txs) {
|
|||
|
||||
_.each(txs, function(tx) {
|
||||
var time = moment(tx.time * 1000).fromNow();
|
||||
var amount = Utils.renderAmount(tx.amount);
|
||||
var amount = utils.renderAmount(tx.amount);
|
||||
var confirmations = tx.confirmations || 0;
|
||||
var proposal = tx.proposalId ? '["' + tx.message + '" by ' + tx.creatorName + '] ' : '';
|
||||
switch (tx.action) {
|
||||
|
@ -40,4 +38,5 @@ client.getTxHistory({}, function (err, txs) {
|
|||
|
||||
console.log("\t%s: %s %s %s %s(%s confirmations)", time, direction, tx.action, amount, proposal, confirmations);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,9 +13,9 @@ program
|
|||
var args = program.args;
|
||||
var txpid = args[0] || '';
|
||||
var reason = args[1] || '';
|
||||
var client = utils.getClient(program);
|
||||
|
||||
client.getTxProposals({}, function(err, txps) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.getTxProposals({}, function(err, txps) {
|
||||
utils.die(err);
|
||||
|
||||
var txp = utils.findOneTxProposal(txps, txpid);
|
||||
|
@ -26,4 +26,5 @@ client.getTxProposals({}, function(err, txps) {
|
|||
else
|
||||
console.log('Transaction rejected by you.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,26 +12,20 @@ program
|
|||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
if (!args[0])
|
||||
program.help();
|
||||
var txpid = args[0] || '';
|
||||
|
||||
var txpid = args[0];
|
||||
|
||||
var cli = new Client({
|
||||
filename: program.config
|
||||
});
|
||||
|
||||
cli.getTxProposals({}, function(err, txps) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.getTxProposals({}, function(err, txps) {
|
||||
utils.die(err);
|
||||
|
||||
if (program.verbose)
|
||||
console.log('* Raw Server Response:\n', txps); //TODO
|
||||
|
||||
var txp = utils.findOneTxProposal(txps, txpid);
|
||||
|
||||
cli.removeTxProposal(txp, function(err) {
|
||||
client.removeTxProposal(txp, function(err) {
|
||||
utils.die(err);
|
||||
|
||||
console.log('Transaction removed.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,14 +31,14 @@ try {
|
|||
}
|
||||
var note = args[2];
|
||||
|
||||
var client = utils.getClient(program);
|
||||
|
||||
client.sendTxProposal({
|
||||
utils.getClient(program, function (client) {
|
||||
client.sendTxProposal({
|
||||
toAddress: address,
|
||||
amount: amount,
|
||||
message: note
|
||||
}, function(err, x) {
|
||||
}, function(err, x) {
|
||||
utils.die(err);
|
||||
console.log(' * Tx created: ID %s [%s] RequiredSignatures:',
|
||||
x.id, x.status, x.requiredSignatures);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,9 +15,7 @@ program
|
|||
var args = program.args;
|
||||
var txpid = args[0] || '';
|
||||
|
||||
var client = utils.getClient(program);
|
||||
|
||||
function end(txp) {
|
||||
function end(client, txp) {
|
||||
if (program.output) {
|
||||
client.getSignatures(txp, function(err, signatures) {
|
||||
utils.die(err);
|
||||
|
@ -50,14 +48,16 @@ function end(txp) {
|
|||
|
||||
};
|
||||
|
||||
if (program.input && program.output) {
|
||||
utils.getClient(program, function (client) {
|
||||
if (program.input && program.output) {
|
||||
var inFile = JSON.parse(fs.readFileSync(program.input));
|
||||
end(inFile.txps[0]);
|
||||
} else {
|
||||
end(client, inFile.txps[0]);
|
||||
} else {
|
||||
client.getTxProposals({}, function(err, txps) {
|
||||
utils.die(err);
|
||||
var txp = utils.findOneTxProposal(txps, txpid);
|
||||
utils.die(err);
|
||||
end(txp);
|
||||
end(client, txp);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ utils.getClient(program, function (client) {
|
|||
utils.die(err);
|
||||
|
||||
var x = res.wallet;
|
||||
console.log('* Wallet %s [%s]: %d-%d %s ', x.name, x.network, x.m, x.n, x.status);
|
||||
console.log('* Wallet %s [%s]: %d-of-%d %s ', x.name, x.network, x.m, x.n, x.status);
|
||||
|
||||
if (x.status != 'complete')
|
||||
console.log(' Missing copayers:', x.n - x.copayers.length);
|
||||
|
|
|
@ -7,39 +7,20 @@ var utils = require('./cli-utils');
|
|||
program = utils.configureCommander(program);
|
||||
|
||||
program
|
||||
.option('-i, --input [filename]', 'use input file instead of server\'s')
|
||||
.option('-o, --output [filename]', 'write tx to output file')
|
||||
.option('-o, --output [filename]', 'write tx to output file for offline signing')
|
||||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
var client = utils.getClient(program);
|
||||
|
||||
var txData;
|
||||
|
||||
function end(err, txps, rawtxps) {
|
||||
utils.getClient(program, function (client) {
|
||||
client.getTxProposals({forAirGapped: !!program.output}, function (err, res) {
|
||||
utils.die(err);
|
||||
if (program.input) {
|
||||
console.log('\n* From File : %s\n', program.input);
|
||||
}
|
||||
utils.renderTxProposals(txps);
|
||||
|
||||
if (program.output) {
|
||||
|
||||
client.getEncryptedWalletData(function (err, toComplete) {
|
||||
var txData = {
|
||||
toComplete: toComplete,
|
||||
txps: txps,
|
||||
};
|
||||
fs.writeFileSync(program.output, JSON.stringify(txData));
|
||||
console.log(' * Proposals Saved to: %s\n', program.output);
|
||||
});
|
||||
fs.writeFileSync(program.output, JSON.stringify(res));
|
||||
console.log(' * Tx proposals saved to: %s\n', program.output);
|
||||
} else {
|
||||
utils.renderTxProposals(res);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (program.input) {
|
||||
var txData = fs.readFileSync(program.input);
|
||||
txData = JSON.parse(txData);
|
||||
client.parseTxProposals(txData, end);
|
||||
} else {
|
||||
client.getTxProposals({getRawTxps: !!program.output}, end);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -195,7 +195,11 @@ Utils.renderTxProposals = function(txps) {
|
|||
return a.copayerName + ' ' + (a.type == 'accept' ? '✓' : '✗') + (a.comment ? ' (' + a.comment + ')' : '');
|
||||
}).join('. '));
|
||||
}
|
||||
if (missingSignatures > 0) {
|
||||
console.log('\t\tMissing signatures: ' + missingSignatures);
|
||||
} else {
|
||||
console.log('\t\tReady to broadcast');
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
@ -344,7 +344,7 @@ API.prototype.getStatus = function(cb) {
|
|||
|
||||
self._doGetRequest('/v1/wallets/', function(err, result) {
|
||||
_processTxps(result.pendingTxps, self.credentials.sharedEncryptingKey);
|
||||
return cb(err, result, self.credentials.copayerId);
|
||||
return cb(err, result);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ var FIELDS = [
|
|||
'm',
|
||||
'n',
|
||||
'walletPrivKey',
|
||||
'personalEncryptingKey',
|
||||
'sharedEncryptingKey',
|
||||
'copayerName',
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue