|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
var _ = require('lodash'); |
|
|
|
var Guid = require('guid'); |
|
|
|
var Bitcore = require('bitcore'); |
|
|
|
|
|
|
|
var TxProposalAction = require('./txproposalaction'); |
|
|
|
|
|
|
@ -38,7 +39,6 @@ TxProposal.fromObj = function (obj) { |
|
|
|
x.message = obj.message; |
|
|
|
x.changeAddress = obj.changeAddress; |
|
|
|
x.inputs = obj.inputs; |
|
|
|
x.rawTx = obj.rawTx; |
|
|
|
x.requiredSignatures = obj.requiredSignatures; |
|
|
|
x.maxRejections = obj.maxRejections; |
|
|
|
x.status = obj.status; |
|
|
@ -51,6 +51,7 @@ TxProposal.fromObj = function (obj) { |
|
|
|
return x; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
TxProposal.prototype._updateStatus = function () { |
|
|
|
if (this.status != 'pending') return; |
|
|
|
|
|
|
@ -61,6 +62,16 @@ TxProposal.prototype._updateStatus = function () { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
TxProposal.prototype._getBitcoreTx = function () { |
|
|
|
return new Bitcore.Transaction() |
|
|
|
.from(this.inputs) |
|
|
|
.to(this.toAddress, this.amount) |
|
|
|
.change(this.changeAddress); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
TxProposal.prototype.addAction = function (copayerId, type, signature) { |
|
|
|
var action = new TxProposalAction({ |
|
|
|
copayerId: copayerId, |
|
|
@ -71,7 +82,15 @@ TxProposal.prototype.addAction = function (copayerId, type, signature) { |
|
|
|
this._updateStatus(); |
|
|
|
}; |
|
|
|
|
|
|
|
TxProposal.prototype.sign = function (copayerId, signature) { |
|
|
|
|
|
|
|
TxProposal.prototype._checkSignature = function (signatures) { |
|
|
|
var t = this._getBitcoreTx(); |
|
|
|
t.applyS |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
TxProposal.prototype.sign = function (copayerId, signatures) { |
|
|
|
this._checkSignature(signature); |
|
|
|
this.addAction(copayerId, 'accept', signature); |
|
|
|
}; |
|
|
|
|
|
|
|