diff --git a/bit-wallet/bit b/bit-wallet/bit
index 6b9a031..d1069d5 100755
--- a/bit-wallet/bit
+++ b/bit-wallet/bit
@@ -10,7 +10,7 @@ program
.command('address', 'create a new address from server')
.command('addresses', 'list addresses')
.command('balance', 'wallet balance')
- .command('send
', 'send bitcoins')
+ .command('send [note]', 'send bitcoins')
.command('sign ', 'sign a transaction proposal')
.command('reject [reason]', 'reject a transaction proposal')
.command('broadcast ', 'broadcast a transaction proposal to the Bitcoin network')
diff --git a/bit-wallet/bit-reject b/bit-wallet/bit-reject
index bfd4f13..5f99aea 100755
--- a/bit-wallet/bit-reject
+++ b/bit-wallet/bit-reject
@@ -24,7 +24,7 @@ client.getTxProposals({}, function(err, txps) {
var txp = utils.findOneTxProposal(txps, txpid);
client.rejectTxProposal(txp, reason, function(err, tx) {
utils.die(err);
- if (x.status == 'rejected')
+ if (tx.status == 'rejected')
console.log('Transaction finally rejected.');
else
console.log('Transaction rejected by you.');
diff --git a/bit-wallet/bit-rm b/bit-wallet/bit-rm
index f56356a..5e7e7d5 100755
--- a/bit-wallet/bit-rm
+++ b/bit-wallet/bit-rm
@@ -3,7 +3,7 @@
var _ = require('lodash');
var program = require('commander');
var Client = require('../lib/client');
-var common = require('./common');
+var utils = require('./cli-utils');
program
.version('0.0.1')
@@ -24,15 +24,15 @@ var cli = new Client({
});
cli.getTxProposals({}, function(err, txps) {
- common.die(err);
+ utils.die(err);
if (program.verbose)
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) {
- common.die(err);
+ utils.die(err);
console.log('Transaction removed.');
});
diff --git a/bit-wallet/bit-send b/bit-wallet/bit-send
index 8dc858b..794eea5 100755
--- a/bit-wallet/bit-send
+++ b/bit-wallet/bit-send
@@ -9,11 +9,21 @@ program
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
- .usage('[options] ')
- .parse(process.argv);
+ .usage('[options] [note]')
+ .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;
-if (!args[0] || !args[1] || !args[2])
+if (!args[0] || !args[1])
program.help();
var address = args[0];
@@ -23,14 +33,14 @@ try {
} catch (ex) {
utils.die(ex);
}
-var message = args[2];
+var note = args[2];
var client = utils.getClient(program);
client.sendTxProposal({
toAddress: address,
amount: amount,
- message: message
+ message: note
}, function(err, x) {
utils.die(err);
console.log(' * Tx created: ID %s [%s] RequiredSignatures:',
diff --git a/bit-wallet/bit-sign b/bit-wallet/bit-sign
index 17c0a74..1450484 100755
--- a/bit-wallet/bit-sign
+++ b/bit-wallet/bit-sign
@@ -20,10 +20,10 @@ client.getTxProposals({}, function(err, txps) {
utils.die(err);
var txp = utils.findOneTxProposal(txps, txpid);
- client.signTxProposal(txp, function(err, x) {
+ client.signTxProposal(txp, function(err, tx) {
utils.die(err);
- if (x.status == 'broadcasted')
- console.log('Transaction Broadcasted: TXID: ' + x.txid);
+ if (tx.status == 'broadcasted')
+ console.log('Transaction Broadcasted: TXID: ' + tx.txid);
else
console.log('Transaction signed by you.');
});
diff --git a/bit-wallet/bit-status b/bit-wallet/bit-status
index 5d15a1f..dcbdfa2 100755
--- a/bit-wallet/bit-status
+++ b/bit-wallet/bit-status
@@ -25,19 +25,20 @@ client.getStatus(function(err, res) {
console.log('* Copayers:', _.pluck(x.copayers,'name').join(', '));
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)) {
console.log("* TX Proposals:")
_.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)) {
- console.log('\t\t * Actions');
- console.log('\t\t', _.map(x.actions, function(a) {
- return a.copayerName + ': ' + a.type + ''
+ console.log('\t\tActions: ', _.map(x.actions, function(a) {
+ return a.copayerName + ' ' + (a.type == 'accept' ? '✓' : '✗') + (a.comment ? ' (' + a.comment + ')' : '');
}).join('. '));
}
+ console.log('\t\tMissing signatures: ' + missingSignatures);
});
}
});