remove pending tx
This commit is contained in:
parent
11a7a65bc5
commit
7975bb2499
|
@ -93,6 +93,10 @@ TxProposal.prototype.getRawTx = function() {
|
|||
};
|
||||
|
||||
|
||||
TxProposal.prototype.getActors = function() {
|
||||
return _.keys(this.actions);
|
||||
};
|
||||
|
||||
TxProposal.prototype.addAction = function(copayerId, type, signatures) {
|
||||
var action = new TxProposalAction({
|
||||
copayerId: copayerId,
|
||||
|
|
|
@ -482,6 +482,39 @@ CopayServer.prototype.removeWallet = function(opts, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* removePendingTx
|
||||
*
|
||||
* @param opts
|
||||
* @param {string} opts.id - The tx id.
|
||||
* @return {undefined}
|
||||
*/
|
||||
CopayServer.prototype.removePendingTx = function(opts, cb) {
|
||||
var self = this;
|
||||
|
||||
if (!Utils.checkRequired(opts, ['id']))
|
||||
return cb(new ClientError('Required argument missing'));
|
||||
|
||||
Utils.runLocked(self.id, cb, function(cb) {
|
||||
|
||||
self.storage.fetchTx(self.walletId, opts.id, function(err, txp) {
|
||||
if (err) return cb(err);
|
||||
if (!txp)
|
||||
return cb(new ClientError('Transaction proposal not found'));
|
||||
|
||||
if (!txp.isPending())
|
||||
return cb(new ClientError('Transaction proposal not pending'));
|
||||
|
||||
var actors = txp.getActors();
|
||||
|
||||
if (actors.length > 1 || actors[0] !== self.copayerId)
|
||||
return cb(new ClientError('No allowed to erase this TX'));
|
||||
|
||||
self.storage.removeTx(opts.id, cb);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
CopayServer.prototype._broadcastTx = function(txp, cb) {
|
||||
var raw = txp.getRawTx();
|
||||
|
@ -510,8 +543,9 @@ CopayServer.prototype.signTx = function(opts, cb) {
|
|||
}, function(err, txp) {
|
||||
if (err) return cb(err);
|
||||
if (!txp) return cb(new ClientError('Transaction proposal not found'));
|
||||
|
||||
var action = _.find(txp.actions, {
|
||||
copayerId: opts.copayerId
|
||||
copayerId: self.copayerId
|
||||
});
|
||||
if (action)
|
||||
return cb(new ClientError('CVOTED', 'Copayer already voted on this transaction proposal'));
|
||||
|
|
Loading…
Reference in New Issue