allow to remove creator, in tx without other signatures

This commit is contained in:
Matias Alejo Garcia 2015-06-11 18:00:52 -03:00
parent 74c8b34188
commit 5d943a4b27
3 changed files with 33 additions and 2 deletions

View File

@ -131,6 +131,18 @@ TxProposal.prototype.getActors = function() {
};
/**
* getApprovers
*
* @return {String[]} copayerIds that approved the tx proposal (accept)
*/
TxProposal.prototype.getApprovers = function() {
return _.pluck(
_.filter(this.actions, {
type: 'accept'
}), 'copayerId');
};
/**
* getActionBy
*

View File

@ -868,11 +868,11 @@ WalletService.prototype.removePendingTx = function(opts, cb) {
var now = Math.floor(Date.now() / 1000);
if (now - txp.createdOn < WalletService.lockTimeoutHours * 3600) {
var actors = txp.getActors();
if (txp.creatorId !== self.copayerId)
return cb(new ClientError('Only creators can remove pending proposals during locktime'));
if (actors.length > 1 || (actors.length == 1 && actors[0] !== self.copayerId))
var approvers = txp.getApprovers();
if (approvers.length > 1 || (approvers.length == 1 && approvers[0] !== self.copayerId))
return cb(new ClientError('TXACTIONED', 'Cannot remove a proposal signed/rejected by other copayers during locktime'));
}

View File

@ -2774,6 +2774,25 @@ describe('Wallet service', function() {
});
});
it('should allow creator copayer to remove a TX rejected by other copayer, in less than 24hrs', function(done) {
helpers.getAuthServer(wallet.copayers[1].id, function(server2) {
var signatures = helpers.clientSign(txp, TestData.copayers[1].xPrivKey);
server2.rejectTx({
txProposalId: txp.id,
signatures: signatures,
}, function(err) {
should.not.exist(err);
server.removePendingTx({
txProposalId: txp.id
}, function(err) {
should.not.exist(err);
done();
});
});
});
});
it('should allow creator copayer to remove a TX signed by other copayer, after 24hrs', function(done) {
helpers.getAuthServer(wallet.copayers[1].id, function(server2) {