Browse Source

Merge pull request #21 from isocolsky/fix/rejections

fix required rejections
activeAddress
Matias Alejo Garcia 10 years ago
parent
commit
4cf2f7e8ca
  1. 6
      lib/model/txproposal.js
  2. 2
      lib/server.js
  3. 2
      test/txproposal.js

6
lib/model/txproposal.js

@ -23,7 +23,7 @@ function TxProposal(opts) {
this.inputs = opts.inputs;
this.inputPaths = opts.inputPaths;
this.requiredSignatures = opts.requiredSignatures;
this.maxRejections = opts.maxRejections;
this.requiredRejections = opts.requiredRejections;
this.status = 'pending';
this.actions = {};
};
@ -41,7 +41,7 @@ TxProposal.fromObj = function(obj) {
x.changeAddress = obj.changeAddress;
x.inputs = obj.inputs;
x.requiredSignatures = obj.requiredSignatures;
x.maxRejections = obj.maxRejections;
x.requiredRejections = obj.requiredRejections;
x.status = obj.status;
x.txid = obj.txid;
x.inputPaths = obj.inputPaths;
@ -157,7 +157,7 @@ TxProposal.prototype.isAccepted = function() {
TxProposal.prototype.isRejected = function() {
var votes = _.countBy(_.values(this.actions), 'type');
return votes['reject'] > this.maxRejections;
return votes['reject'] >= this.requiredRejections;
};
TxProposal.prototype.setBroadcasted = function(txid) {

2
lib/server.js

@ -420,7 +420,7 @@ CopayServer.prototype.createTx = function(opts, cb) {
message: opts.message,
changeAddress: changeAddress.address,
requiredSignatures: wallet.m,
maxRejections: wallet.n - wallet.m,
requiredRejections: Math.min(wallet.m - 1, wallet.n - wallet.m) + 1,
});
txp.inputs = self._selectUtxos(txp, utxos);

2
test/txproposal.js

@ -101,7 +101,7 @@ var aTXP = function() {
}],
"inputPaths": ["m/2147483647/0/1"],
"requiredSignatures": 2,
"maxRejections": 0,
"requiredRejections": 1,
"status": "pending",
"actions": []
}

Loading…
Cancel
Save