|
|
@ -33,15 +33,15 @@ TxProposal.create = function(opts) { |
|
|
|
x.message = opts.message; |
|
|
|
x.payProUrl = opts.payProUrl; |
|
|
|
x.changeAddress = opts.changeAddress; |
|
|
|
x.inputs = []; |
|
|
|
x.inputPaths = []; |
|
|
|
x.setInputs(opts.inputs); |
|
|
|
x.outputs = _.map(opts.outputs, function(output) { |
|
|
|
return _.pick(output, ['amount', 'toAddress', 'message']); |
|
|
|
}); |
|
|
|
x.outputOrder = _.shuffle(_.range(x.outputs.length + 1)); |
|
|
|
x.requiredSignatures = opts.requiredSignatures; |
|
|
|
x.requiredRejections = opts.requiredRejections; |
|
|
|
x.walletM = opts.walletM; |
|
|
|
x.walletN = opts.walletN; |
|
|
|
x.requiredSignatures = x.walletM; |
|
|
|
x.requiredRejections = Math.min(x.walletM, x.walletN - x.walletM + 1), |
|
|
|
x.status = 'temporary'; |
|
|
|
x.actions = []; |
|
|
|
x.fee = null; |
|
|
@ -80,9 +80,10 @@ TxProposal.fromObj = function(obj) { |
|
|
|
x.payProUrl = obj.payProUrl; |
|
|
|
x.changeAddress = obj.changeAddress; |
|
|
|
x.inputs = obj.inputs; |
|
|
|
x.walletM = obj.walletM; |
|
|
|
x.walletN = obj.walletN; |
|
|
|
x.requiredSignatures = obj.requiredSignatures; |
|
|
|
x.requiredRejections = obj.requiredRejections; |
|
|
|
x.walletN = obj.walletN; |
|
|
|
x.status = obj.status; |
|
|
|
x.txid = obj.txid; |
|
|
|
x.broadcastedOn = obj.broadcastedOn; |
|
|
@ -112,8 +113,8 @@ TxProposal.prototype.toObject = function() { |
|
|
|
}; |
|
|
|
|
|
|
|
TxProposal.prototype.setInputs = function(inputs) { |
|
|
|
this.inputs = inputs; |
|
|
|
this.inputPaths = _.pluck(inputs, 'path'); |
|
|
|
this.inputs = inputs || []; |
|
|
|
this.inputPaths = _.pluck(inputs, 'path') || []; |
|
|
|
}; |
|
|
|
|
|
|
|
TxProposal.prototype._updateStatus = function() { |
|
|
@ -144,9 +145,6 @@ TxProposal.prototype._buildTx = function() { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (self.toAddress && self.amount && !self.outputs) { |
|
|
|
t.to(self.toAddress, self.amount); |
|
|
|
} else if (self.outputs) { |
|
|
|
_.each(self.outputs, function(o) { |
|
|
|
$.checkState(o.script || o.toAddress, 'Output should have either toAddress or script specified'); |
|
|
|
if (o.script) { |
|
|
@ -158,7 +156,6 @@ TxProposal.prototype._buildTx = function() { |
|
|
|
t.to(o.toAddress, o.amount); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
t.fee(self.fee); |
|
|
|
t.change(self.changeAddress.address); |
|
|
|