commit
d4aeff3c44
|
@ -10,7 +10,7 @@ program
|
||||||
.command('address', 'create a new address from server')
|
.command('address', 'create a new address from server')
|
||||||
.command('addresses', 'list addresses')
|
.command('addresses', 'list addresses')
|
||||||
.command('balance', 'wallet balance')
|
.command('balance', 'wallet balance')
|
||||||
.command('send <address> <amount> <note>', 'send bitcoins')
|
.command('send <address> <amount> [note]', 'send bitcoins')
|
||||||
.command('sign <txpId>', 'sign a transaction proposal')
|
.command('sign <txpId>', 'sign a transaction proposal')
|
||||||
.command('reject <txpId> [reason]', 'reject a transaction proposal')
|
.command('reject <txpId> [reason]', 'reject a transaction proposal')
|
||||||
.command('broadcast <txpId>', 'broadcast a transaction proposal to the Bitcoin network')
|
.command('broadcast <txpId>', 'broadcast a transaction proposal to the Bitcoin network')
|
||||||
|
|
|
@ -24,7 +24,7 @@ client.getTxProposals({}, function(err, txps) {
|
||||||
var txp = utils.findOneTxProposal(txps, txpid);
|
var txp = utils.findOneTxProposal(txps, txpid);
|
||||||
client.rejectTxProposal(txp, reason, function(err, tx) {
|
client.rejectTxProposal(txp, reason, function(err, tx) {
|
||||||
utils.die(err);
|
utils.die(err);
|
||||||
if (x.status == 'rejected')
|
if (tx.status == 'rejected')
|
||||||
console.log('Transaction finally rejected.');
|
console.log('Transaction finally rejected.');
|
||||||
else
|
else
|
||||||
console.log('Transaction rejected by you.');
|
console.log('Transaction rejected by you.');
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var program = require('commander');
|
var program = require('commander');
|
||||||
var Client = require('../lib/client');
|
var Client = require('../lib/client');
|
||||||
var common = require('./common');
|
var utils = require('./cli-utils');
|
||||||
|
|
||||||
program
|
program
|
||||||
.version('0.0.1')
|
.version('0.0.1')
|
||||||
|
@ -24,15 +24,15 @@ var cli = new Client({
|
||||||
});
|
});
|
||||||
|
|
||||||
cli.getTxProposals({}, function(err, txps) {
|
cli.getTxProposals({}, function(err, txps) {
|
||||||
common.die(err);
|
utils.die(err);
|
||||||
|
|
||||||
if (program.verbose)
|
if (program.verbose)
|
||||||
console.log('* Raw Server Response:\n', txps); //TODO
|
console.log('* Raw Server Response:\n', txps); //TODO
|
||||||
|
|
||||||
var txp = common.findOneTxProposal(txps, txpid);
|
var txp = utils.findOneTxProposal(txps, txpid);
|
||||||
|
|
||||||
cli.removeTxProposal(txp, function(err) {
|
cli.removeTxProposal(txp, function(err) {
|
||||||
common.die(err);
|
utils.die(err);
|
||||||
|
|
||||||
console.log('Transaction removed.');
|
console.log('Transaction removed.');
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,11 +9,21 @@ program
|
||||||
.option('-c, --config [file]', 'Wallet config filename')
|
.option('-c, --config [file]', 'Wallet config filename')
|
||||||
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
|
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
|
||||||
.option('-v, --verbose', 'be verbose')
|
.option('-v, --verbose', 'be verbose')
|
||||||
.usage('[options] <address> <amount> <message>')
|
.usage('[options] <address> <amount> [note]')
|
||||||
.parse(process.argv);
|
.description('Create a proposal for sending bitcoins to a destination address.\n The amount can be specified in bit, btc or sat (the default).');
|
||||||
|
|
||||||
|
program.on('--help', function(){
|
||||||
|
console.log(' Examples:');
|
||||||
|
console.log('');
|
||||||
|
console.log(' $ bit-send n2HRFgtoihgAhx1qAEXcdBMjoMvAx7AcDc 500bit');
|
||||||
|
console.log(' $ bit-send mgWeRvUC6d1LRPKtdDbvYEpaUEmApS4XrY 0.2btc "dinner with friends"');
|
||||||
|
console.log('');
|
||||||
|
});
|
||||||
|
|
||||||
|
program.parse(process.argv);
|
||||||
|
|
||||||
var args = program.args;
|
var args = program.args;
|
||||||
if (!args[0] || !args[1] || !args[2])
|
if (!args[0] || !args[1])
|
||||||
program.help();
|
program.help();
|
||||||
|
|
||||||
var address = args[0];
|
var address = args[0];
|
||||||
|
@ -23,14 +33,14 @@ try {
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
utils.die(ex);
|
utils.die(ex);
|
||||||
}
|
}
|
||||||
var message = args[2];
|
var note = args[2];
|
||||||
|
|
||||||
var client = utils.getClient(program);
|
var client = utils.getClient(program);
|
||||||
|
|
||||||
client.sendTxProposal({
|
client.sendTxProposal({
|
||||||
toAddress: address,
|
toAddress: address,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
message: message
|
message: note
|
||||||
}, function(err, x) {
|
}, function(err, x) {
|
||||||
utils.die(err);
|
utils.die(err);
|
||||||
console.log(' * Tx created: ID %s [%s] RequiredSignatures:',
|
console.log(' * Tx created: ID %s [%s] RequiredSignatures:',
|
||||||
|
|
|
@ -20,10 +20,10 @@ client.getTxProposals({}, function(err, txps) {
|
||||||
utils.die(err);
|
utils.die(err);
|
||||||
|
|
||||||
var txp = utils.findOneTxProposal(txps, txpid);
|
var txp = utils.findOneTxProposal(txps, txpid);
|
||||||
client.signTxProposal(txp, function(err, x) {
|
client.signTxProposal(txp, function(err, tx) {
|
||||||
utils.die(err);
|
utils.die(err);
|
||||||
if (x.status == 'broadcasted')
|
if (tx.status == 'broadcasted')
|
||||||
console.log('Transaction Broadcasted: TXID: ' + x.txid);
|
console.log('Transaction Broadcasted: TXID: ' + tx.txid);
|
||||||
else
|
else
|
||||||
console.log('Transaction signed by you.');
|
console.log('Transaction signed by you.');
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,19 +25,20 @@ client.getStatus(function(err, res) {
|
||||||
console.log('* Copayers:', _.pluck(x.copayers,'name').join(', '));
|
console.log('* Copayers:', _.pluck(x.copayers,'name').join(', '));
|
||||||
|
|
||||||
var x = res.balance;
|
var x = res.balance;
|
||||||
console.log('* Balance %d (Locked: %d)', x.totalAmount, x.lockedAmount);
|
console.log('* Balance %dSAT (Locked: %dSAT)', x.totalAmount, x.lockedAmount);
|
||||||
|
|
||||||
if (!_.isEmpty(res.pendingTxps)) {
|
if (!_.isEmpty(res.pendingTxps)) {
|
||||||
console.log("* TX Proposals:")
|
console.log("* TX Proposals:")
|
||||||
_.each(res.pendingTxps, function(x) {
|
_.each(res.pendingTxps, function(x) {
|
||||||
console.log("\t%s [%s by %s] %dSAT => %s", utils.shortID(x.id), x.message, x.creatorName, x.amount, x.toAddress);
|
missingSignatures = x.requiredSignatures - _.filter(_.values(x.actions), function (a) { return a.type == 'accept'; }).length;
|
||||||
|
console.log("\t%s [\"%s\" by %s] %dSAT => %s", utils.shortID(x.id), x.message, x.creatorName, x.amount, x.toAddress);
|
||||||
|
|
||||||
if (!_.isEmpty(x.actions)) {
|
if (!_.isEmpty(x.actions)) {
|
||||||
console.log('\t\t * Actions');
|
console.log('\t\tActions: ', _.map(x.actions, function(a) {
|
||||||
console.log('\t\t', _.map(x.actions, function(a) {
|
return a.copayerName + ' ' + (a.type == 'accept' ? '✓' : '✗') + (a.comment ? ' (' + a.comment + ')' : '');
|
||||||
return a.copayerName + ': ' + a.type + ''
|
|
||||||
}).join('. '));
|
}).join('. '));
|
||||||
}
|
}
|
||||||
|
console.log('\t\tMissing signatures: ' + missingSignatures);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue