|
|
@ -7,28 +7,32 @@ var Address = Bitcore.Address; |
|
|
|
|
|
|
|
var TxProposalAction = require('./txproposalaction'); |
|
|
|
|
|
|
|
var VERSION = '1.0.0'; |
|
|
|
function TxProposal() { |
|
|
|
this.version = '1.0.0'; |
|
|
|
}; |
|
|
|
|
|
|
|
function TxProposal(opts) { |
|
|
|
TxProposal.create = function(opts) { |
|
|
|
opts = opts || {}; |
|
|
|
|
|
|
|
this.version = VERSION; |
|
|
|
var x = new TxProposal(); |
|
|
|
|
|
|
|
var now = Date.now(); |
|
|
|
this.createdOn = Math.floor(now / 1000); |
|
|
|
this.id = ('00000000000000' + now).slice(-14) + Uuid.v4(); |
|
|
|
this.creatorId = opts.creatorId; |
|
|
|
this.toAddress = opts.toAddress; |
|
|
|
this.amount = opts.amount; |
|
|
|
this.message = opts.message; |
|
|
|
this.proposalSignature = opts.proposalSignature; |
|
|
|
this.changeAddress = opts.changeAddress; |
|
|
|
this.inputs = opts.inputs; |
|
|
|
this.inputPaths = opts.inputPaths; |
|
|
|
this.requiredSignatures = opts.requiredSignatures; |
|
|
|
this.requiredRejections = opts.requiredRejections; |
|
|
|
this.status = 'pending'; |
|
|
|
this.actions = {}; |
|
|
|
x.createdOn = Math.floor(now / 1000); |
|
|
|
x.id = ('00000000000000' + now).slice(-14) + Uuid.v4(); |
|
|
|
x.creatorId = opts.creatorId; |
|
|
|
x.toAddress = opts.toAddress; |
|
|
|
x.amount = opts.amount; |
|
|
|
x.message = opts.message; |
|
|
|
x.proposalSignature = opts.proposalSignature; |
|
|
|
x.changeAddress = opts.changeAddress; |
|
|
|
x.inputs = []; |
|
|
|
x.inputPaths = []; |
|
|
|
x.requiredSignatures = opts.requiredSignatures; |
|
|
|
x.requiredRejections = opts.requiredRejections; |
|
|
|
x.status = 'pending'; |
|
|
|
x.actions = {}; |
|
|
|
|
|
|
|
return x; |
|
|
|
}; |
|
|
|
|
|
|
|
TxProposal.fromObj = function(obj) { |
|
|
@ -51,7 +55,7 @@ TxProposal.fromObj = function(obj) { |
|
|
|
x.inputPaths = obj.inputPaths; |
|
|
|
x.actions = obj.actions; |
|
|
|
_.each(x.actions, function(action, copayerId) { |
|
|
|
x.actions[copayerId] = new TxProposalAction(action); |
|
|
|
x.actions[copayerId] = TxProposalAction.fromObj(action); |
|
|
|
}); |
|
|
|
|
|
|
|
return x; |
|
|
@ -136,7 +140,7 @@ TxProposal.prototype.getActionBy = function(copayerId) { |
|
|
|
}; |
|
|
|
|
|
|
|
TxProposal.prototype.addAction = function(copayerId, type, comment, signatures, xpub) { |
|
|
|
var action = new TxProposalAction({ |
|
|
|
var action = TxProposalAction.create({ |
|
|
|
copayerId: copayerId, |
|
|
|
type: type, |
|
|
|
signatures: signatures, |
|
|
|