Skip to content

Commit

Permalink
Merge pull request bitpay#11 from isocolsky/reject
Browse files Browse the repository at this point in the history
WIP Reject
  • Loading branch information
matiu committed Feb 14, 2015
2 parents b54187a + 3770fad commit 68cc30b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
1 change: 1 addition & 0 deletions bit-wallet/bit
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ program
.command('balance', 'wallet balance')
.command('send <address> <amount> <note>', 'send bitcoins')
.command('sign <txpId>', 'sign a Transaction Proposal')
.command('reject <txpId>', 'reject a Transaction Proposal')
.parse(process.argv);


Expand Down
52 changes: 52 additions & 0 deletions bit-wallet/bit-reject
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node

var _ = require('lodash');
var program = require('commander');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');

program
.version('0.0.1')
.option('-c,--config [file]', 'Wallet config filename')
.option('-v,--verbose', 'be verbose')
.usage('[options] <txpid>')
.parse(process.argv);

var args = program.args;
if (!args[0])
program.help();

var txpid = args[0];

var cli = new ClientLib({
filename: program.config
});

cli.txProposals({}, function(err, x) {
common.die(err);

if (program.verbose)
console.log('* Raw Server Response:\n', x); //TODO

var txps = _.filter(x, function(x) {
return _.endsWith(common.shortID(x.id), txpid);
});

if (!txps.length)
common.die('Could not find TX Proposal:' + txpid);

if (txps.length > 1)
common.die('More than one TX Proposals match:' + txpid + ' : ' + _.map(txps, function(x) {
return x.id;
}).join(' '));;

var txp = txps[0];
cli.reject(txp, function(err, x) {
common.die(err);

if (program.verbose)
console.log('* Raw Server Response:\n', x); //TODO

console.log('Transaction rejected.');
});
});
2 changes: 1 addition & 1 deletion bit-wallet/bit-sign
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cli.txProposals({}, function(err, x) {
common.die('Could not find TX Proposal:' + txpid);

if (txps.length > 1)
common.die('More that one TX Proposals match:' + txpid + ' : ' + _.map(txps, function(x) {
common.die('More than one TX Proposals match:' + txpid + ' : ' + _.map(txps, function(x) {
return x.id;
}).join(' '));;

Expand Down

0 comments on commit 68cc30b

Please sign in to comment.