Browse Source

fix required rejections

activeAddress
Ivan Socolsky 10 years ago
parent
commit
674e3a5b77
  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.inputs = opts.inputs;
this.inputPaths = opts.inputPaths; this.inputPaths = opts.inputPaths;
this.requiredSignatures = opts.requiredSignatures; this.requiredSignatures = opts.requiredSignatures;
this.maxRejections = opts.maxRejections; this.requiredRejections = opts.requiredRejections;
this.status = 'pending'; this.status = 'pending';
this.actions = {}; this.actions = {};
}; };
@ -41,7 +41,7 @@ TxProposal.fromObj = function(obj) {
x.changeAddress = obj.changeAddress; x.changeAddress = obj.changeAddress;
x.inputs = obj.inputs; x.inputs = obj.inputs;
x.requiredSignatures = obj.requiredSignatures; x.requiredSignatures = obj.requiredSignatures;
x.maxRejections = obj.maxRejections; x.requiredRejections = obj.requiredRejections;
x.status = obj.status; x.status = obj.status;
x.txid = obj.txid; x.txid = obj.txid;
x.inputPaths = obj.inputPaths; x.inputPaths = obj.inputPaths;
@ -157,7 +157,7 @@ TxProposal.prototype.isAccepted = function() {
TxProposal.prototype.isRejected = function() { TxProposal.prototype.isRejected = function() {
var votes = _.countBy(_.values(this.actions), 'type'); var votes = _.countBy(_.values(this.actions), 'type');
return votes['reject'] > this.maxRejections; return votes['reject'] >= this.requiredRejections;
}; };
TxProposal.prototype.setBroadcasted = function(txid) { TxProposal.prototype.setBroadcasted = function(txid) {

2
lib/server.js

@ -420,7 +420,7 @@ CopayServer.prototype.createTx = function(opts, cb) {
message: opts.message, message: opts.message,
changeAddress: changeAddress.address, changeAddress: changeAddress.address,
requiredSignatures: wallet.m, 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); txp.inputs = self._selectUtxos(txp, utxos);

2
test/txproposal.js

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

Loading…
Cancel
Save