bug fixes
This commit is contained in:
parent
eca7d55afb
commit
5d6c89599a
2
app.js
2
app.js
|
@ -217,7 +217,7 @@ router.post('/v1/txproposals/:id/rejections', function(req, res) {
|
||||||
router.delete('/v1/txproposals/:id/', function(req, res) {
|
router.delete('/v1/txproposals/:id/', function(req, res) {
|
||||||
getServerWithAuth(req, res, function(server) {
|
getServerWithAuth(req, res, function(server) {
|
||||||
req.body.txProposalId = req.params['id'];
|
req.body.txProposalId = req.params['id'];
|
||||||
server.removePendingTx(req.body, function(err, txp) {
|
server.removePendingTx(req.body, function(err) {
|
||||||
if (err) return returnError(err, res, req);
|
if (err) return returnError(err, res, req);
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,30 +22,19 @@ var cli = new Client({
|
||||||
filename: program.config
|
filename: program.config
|
||||||
});
|
});
|
||||||
|
|
||||||
cli.getTxProposals({}, function(err, x) {
|
cli.getTxProposals({}, function(err, txps) {
|
||||||
common.die(err);
|
common.die(err);
|
||||||
|
|
||||||
if (program.verbose)
|
if (program.verbose)
|
||||||
console.log('* Raw Server Response:\n', x); //TODO
|
console.log('* Raw Server Response:\n', txps); //TODO
|
||||||
|
|
||||||
var txps = _.filter(x, function(x) {
|
var txp = common.findOneTxProposal(txps, txpid);
|
||||||
return _.endsWith(common.shortID(x.id), txpid);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!txps.length)
|
cli.rejectTxProposal(txp, reason, function(err, tx) {
|
||||||
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.rejectTxProposal(txp, reason, function(err, x) {
|
|
||||||
common.die(err);
|
common.die(err);
|
||||||
|
|
||||||
if (program.verbose)
|
if (program.verbose)
|
||||||
console.log('* Raw Server Response:\n', x); //TODO
|
console.log('* Raw Server Response:\n', tx); //TODO
|
||||||
|
|
||||||
console.log('Transaction rejected.');
|
console.log('Transaction rejected.');
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,31 +22,17 @@ var cli = new Client({
|
||||||
filename: program.config
|
filename: program.config
|
||||||
});
|
});
|
||||||
|
|
||||||
cli.getTxProposals({}, function(err, x) {
|
cli.getTxProposals({}, function(err, txps) {
|
||||||
common.die(err);
|
common.die(err);
|
||||||
|
|
||||||
if (program.verbose)
|
if (program.verbose)
|
||||||
console.log('* Raw Server Response:\n', x); //TODO
|
console.log('* Raw Server Response:\n', txps); //TODO
|
||||||
|
|
||||||
var txps = _.filter(x, function(x) {
|
var txp = common.findOneTxProposal(txps, txpid);
|
||||||
return _.endsWith(common.shortID(x.id), txpid);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!txps.length)
|
cli.removeTxProposal(txp, function(err) {
|
||||||
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.removeTxProposal(txp, function(err, x) {
|
|
||||||
common.die(err);
|
common.die(err);
|
||||||
|
|
||||||
if (program.verbose)
|
console.log('Transaction removed.');
|
||||||
console.log('* Raw Server Response:\n', x); //TODO
|
|
||||||
|
|
||||||
console.log('Transaction rejected.');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,30 +22,19 @@ var cli = new ClientLib({
|
||||||
filename: program.config
|
filename: program.config
|
||||||
});
|
});
|
||||||
|
|
||||||
cli.getTxProposals({}, function(err, x) {
|
cli.getTxProposals({}, function(err, txps) {
|
||||||
common.die(err);
|
common.die(err);
|
||||||
|
|
||||||
if (program.verbose)
|
if (program.verbose)
|
||||||
console.log('* Raw Server Response:\n', x); //TODO
|
console.log('* Raw Server Response:\n', txps); //TODO
|
||||||
|
|
||||||
var txps = _.filter(x, function(x) {
|
var txp = common.findOneTxProposal(txps, txpid);
|
||||||
return _.endsWith(common.shortID(x.id), txpid);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!txps.length)
|
cli.signTxProposal(txp, function(err, tx) {
|
||||||
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.signTxProposal(txp, function(err, x) {
|
|
||||||
common.die(err);
|
common.die(err);
|
||||||
|
|
||||||
if (program.verbose)
|
if (program.verbose)
|
||||||
console.log('* Raw Server Response:\n', x); //TODO
|
console.log('* Raw Server Response:\n', tx); //TODO
|
||||||
|
|
||||||
console.log('Transaction signed.');
|
console.log('Transaction signed.');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
var common = function() {};
|
var common = function() {};
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +20,7 @@ common.parseMN = function(MN) {
|
||||||
var m = parseInt(mn[0]);
|
var m = parseInt(mn[0]);
|
||||||
var n = parseInt(mn[1]);
|
var n = parseInt(mn[1]);
|
||||||
|
|
||||||
if (!m || ! n) {
|
if (!m || !n) {
|
||||||
die('Bad m-n parameter');
|
die('Bad m-n parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,4 +32,20 @@ common.shortID = function(id) {
|
||||||
return id.substr(id.length - 4);
|
return id.substr(id.length - 4);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
common.findOneTxProposal = function(txps, id) {
|
||||||
|
var matches = _.filter(txps, function(tx) {
|
||||||
|
return _.endsWith(common.shortID(tx.id), id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!matches.length)
|
||||||
|
common.die('Could not find TX Proposal:' + id);
|
||||||
|
|
||||||
|
if (matches.length > 1)
|
||||||
|
common.die('More than one TX Proposals match:' + id + ' : ' + _.map(matches, function(tx) {
|
||||||
|
return tx.id;
|
||||||
|
}).join(' '));;
|
||||||
|
|
||||||
|
return matches[0];
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = common;
|
module.exports = common;
|
||||||
|
|
|
@ -84,7 +84,7 @@ API.prototype._loadAndCheck = function() {
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientLib.prototype._doRequest = function(method, url, args, data, cb) {
|
API.prototype._doRequest = function(method, url, args, data, cb) {
|
||||||
var reqSignature = _signRequest(method, url, args, data.signingPrivKey);
|
var reqSignature = _signRequest(method, url, args, data.signingPrivKey);
|
||||||
var absUrl = _getUrl(url);
|
var absUrl = _getUrl(url);
|
||||||
request({
|
request({
|
||||||
|
@ -359,7 +359,7 @@ API.prototype.rejectTxProposal = function(txp, reason, cb) {
|
||||||
this._doPostRequest(url, args, data, cb);
|
this._doPostRequest(url, args, data, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientLib.prototype.removeTxProposal = function(txp, cb) {
|
API.prototype.removeTxProposal = function(txp, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var data = this._loadAndCheck();
|
var data = this._loadAndCheck();
|
||||||
|
|
||||||
|
|
|
@ -547,19 +547,19 @@ CopayServer.prototype.removeWallet = function(opts, cb) {
|
||||||
* removePendingTx
|
* removePendingTx
|
||||||
*
|
*
|
||||||
* @param opts
|
* @param opts
|
||||||
* @param {string} opts.id - The tx id.
|
* @param {string} opts.txProposalId - The tx id.
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
CopayServer.prototype.removePendingTx = function(opts, cb) {
|
CopayServer.prototype.removePendingTx = function(opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!Utils.checkRequired(opts, ['id']))
|
if (!Utils.checkRequired(opts, ['txProposalId']))
|
||||||
return cb(new ClientError('Required argument missing'));
|
return cb(new ClientError('Required argument missing'));
|
||||||
|
|
||||||
Utils.runLocked(self.walletId, cb, function(cb) {
|
Utils.runLocked(self.walletId, cb, function(cb) {
|
||||||
|
|
||||||
self.getTx({
|
self.getTx({
|
||||||
id: opts.id
|
id: opts.txProposalId,
|
||||||
}, function(err, txp) {
|
}, function(err, txp) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ CopayServer.prototype.removePendingTx = function(opts, cb) {
|
||||||
return cb(new ClientError('Cannot remove a proposal signed/rejected by other copayers'));
|
return cb(new ClientError('Cannot remove a proposal signed/rejected by other copayers'));
|
||||||
|
|
||||||
self._notify('transactionProposalRemoved');
|
self._notify('transactionProposalRemoved');
|
||||||
self.storage.removeTx(self.walletId, opts.id, cb);
|
self.storage.removeTx(self.walletId, txp.id, cb);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue