Merge pull request #21 from isocolsky/fix/rejections

fix required rejections
This commit is contained in:
Matias Alejo Garcia 2015-02-09 12:27:57 -03:00
commit 4cf2f7e8ca
3 changed files with 5 additions and 5 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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": []
} }