improve error messages
This commit is contained in:
parent
628dc12d00
commit
15798be382
|
@ -496,25 +496,22 @@ CopayServer.prototype.removePendingTx = function(opts, cb) {
|
|||
|
||||
Utils.runLocked(self.walletId, cb, function(cb) {
|
||||
|
||||
self.storage.fetchTx(self.walletId, opts.id, function(err, txp) {
|
||||
self.getTx({
|
||||
id: 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'));
|
||||
|
||||
|
||||
if (txp.creatorId !== self.copayerId)
|
||||
return cb(new ClientError('Not allowed to erase this TX'));
|
||||
return cb(new ClientError('Only creators can remove pending proposals'));
|
||||
|
||||
var actors = txp.getActors();
|
||||
|
||||
if (actors.length > 1)
|
||||
return cb(new ClientError('Not allowed to erase this TX'));
|
||||
|
||||
if (actors.length == 1 && actors[0] !== self.copayerId)
|
||||
return cb(new ClientError('Not allowed to erase this TX'));
|
||||
if (actors.length > 1 || (actors.length == 1 && actors[0] !== self.copayerId))
|
||||
return cb(new ClientError('Cannot remove a proposal signed/rejected by other copayers'));
|
||||
|
||||
self.storage.removeTx(self.walletId, opts.id, cb);
|
||||
});
|
||||
|
|
|
@ -1310,7 +1310,7 @@ describe('Copay server', function() {
|
|||
server2.removePendingTx({
|
||||
id: txp.id
|
||||
}, function(err) {
|
||||
err.message.should.contain('Not allowed');
|
||||
err.message.should.contain('creators');
|
||||
server2.getPendingTxs({}, function(err, txs) {
|
||||
txs.length.should.equal(1);
|
||||
done();
|
||||
|
@ -1330,7 +1330,7 @@ describe('Copay server', function() {
|
|||
server.removePendingTx({
|
||||
id: txp.id
|
||||
}, function(err) {
|
||||
err.message.should.contain('Not allowed');
|
||||
err.message.should.contain('other copayers');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue