add rm
This commit is contained in:
parent
f4b01c1925
commit
f439f23b61
12
app.js
12
app.js
|
@ -207,7 +207,17 @@ router.post('/v1/txproposals/:id/signatures/', function(req, res) {
|
|||
router.post('/v1/txproposals/:id/rejections', function(req, res) {
|
||||
getServerWithAuth(req, res, function(server) {
|
||||
req.body.txProposalId = req.params['id'];
|
||||
server.signTx(req.body, function(err, txp) {
|
||||
server.rejectTx(req.body, function(err, txp) {
|
||||
if (err) return returnError(err, res, req);
|
||||
res.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
router.delete('/v1/txproposals/:id/', function(req, res) {
|
||||
getServerWithAuth(req, res, function(server) {
|
||||
req.body.txProposalId = req.params['id'];
|
||||
server.removePendingTx(req.body, function(err, txp) {
|
||||
if (err) return returnError(err, res, req);
|
||||
res.end();
|
||||
});
|
||||
|
|
|
@ -11,8 +11,9 @@ program
|
|||
.command('addresses', 'list addresses')
|
||||
.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')
|
||||
.command('sign <txpId>', 'sign a transaction proposal')
|
||||
.command('reject <txpId> [reason]', 'reject a transaction proposal')
|
||||
.command('rm <txpId>', 'remove a transaction proposal')
|
||||
.parse(process.argv);
|
||||
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ program
|
|||
.version('0.0.1')
|
||||
.option('-c,--config [file]', 'Wallet config filename')
|
||||
.option('-v,--verbose', 'be verbose')
|
||||
.usage('[options] <txpid>')
|
||||
.usage('[options] <txpid> [reason]')
|
||||
.parse(process.argv);
|
||||
|
||||
var args = program.args;
|
||||
if (!args[0])
|
||||
program.help();
|
||||
|
||||
var txpid = args[0];
|
||||
var reason = args[1] || '';
|
||||
|
||||
var cli = new Client({
|
||||
filename: program.config
|
||||
|
@ -41,7 +41,7 @@ cli.getTxProposals({}, function(err, x) {
|
|||
}).join(' '));;
|
||||
|
||||
var txp = txps[0];
|
||||
cli.rejectTxProposal(txp, function(err, x) {
|
||||
cli.rejectTxProposal(txp, reason, function(err, x) {
|
||||
common.die(err);
|
||||
|
||||
if (program.verbose)
|
||||
|
|
|
@ -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.rm(txp, function(err, x) {
|
||||
common.die(err);
|
||||
|
||||
if (program.verbose)
|
||||
console.log('* Raw Server Response:\n', x); //TODO
|
||||
|
||||
console.log('Transaction rejected.');
|
||||
});
|
||||
});
|
|
@ -359,4 +359,29 @@ API.prototype.rejectTxProposal = function(txp, reason, cb) {
|
|||
this._doPostRequest(url, args, data, cb);
|
||||
};
|
||||
|
||||
ClientLib.prototype.rm = function(txp, cb) {
|
||||
var self = this;
|
||||
var data = this._loadAndCheck();
|
||||
|
||||
var url = '/v1/txproposals/' + txp.id;
|
||||
var reqSignature = _signRequest(url, {}, data.signingPrivKey);
|
||||
|
||||
request({
|
||||
headers: {
|
||||
'x-identity': data.copayerId,
|
||||
'x-signature': reqSignature,
|
||||
},
|
||||
method: 'delete',
|
||||
url: _getUrl(url),
|
||||
json: true,
|
||||
}, function(err, res, body) {
|
||||
if (err) return cb(err);
|
||||
if (res.statusCode != 200) {
|
||||
_parseError(body);
|
||||
return cb('Request error');
|
||||
}
|
||||
return cb(null, body);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = API;
|
||||
|
|
Loading…
Reference in New Issue