bitcore-wallet-service/bit-wallet/bit-reject

33 lines
920 B
Plaintext
Raw Normal View History

2015-02-13 17:51:40 -08:00
#!/usr/bin/env node
var _ = require('lodash');
var program = require('commander');
2015-02-15 06:33:04 -08:00
var Client = require('../lib/client');
2015-02-15 08:14:36 -08:00
var utils = require('./cli-utils');
2015-02-13 17:51:40 -08:00
program
.version('0.0.1')
.option('-c,--config [file]', 'Wallet config filename')
.option('-v,--verbose', 'be verbose')
2015-02-17 15:31:03 -08:00
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
2015-02-14 07:54:00 -08:00
.usage('[options] <txpid> [reason]')
2015-02-13 17:51:40 -08:00
.parse(process.argv);
var args = program.args;
var txpid = args[0] || '';
2015-02-14 07:54:00 -08:00
var reason = args[1] || '';
2015-02-15 08:14:36 -08:00
var client = utils.getClient(program);
2015-02-13 17:51:40 -08:00
2015-02-15 08:14:36 -08:00
client.getTxProposals({}, function(err, txps) {
utils.die(err);
2015-02-13 17:51:40 -08:00
2015-02-15 08:14:36 -08:00
var txp = utils.findOneTxProposal(txps, txpid);
client.rejectTxProposal(txp, reason, function(err, tx) {
utils.die(err);
2015-02-15 14:12:45 -08:00
if (x.status == 'rejected')
console.log('Transaction finally rejected.');
else
console.log('Transaction rejected by you.');
2015-02-13 17:51:40 -08:00
});
});