Merge pull request #274 from greggzigler/bug/simpleProposalHash
proposals with explicit type = simple need legacy header
This commit is contained in:
commit
6e9630e0df
|
@ -157,7 +157,8 @@ TxProposal.prototype.getBitcoreTx = function() {
|
|||
};
|
||||
|
||||
TxProposal.prototype.getNetworkName = function() {
|
||||
return Bitcore.Address(this.toAddress).toObject().network;
|
||||
var someAddress = this.toAddress || this.outputs[0].toAddress;
|
||||
return Bitcore.Address(someAddress).toObject().network;
|
||||
};
|
||||
|
||||
TxProposal.prototype.getRawTx = function() {
|
||||
|
|
|
@ -903,9 +903,10 @@ WalletService.prototype.createTx = function(opts, cb) {
|
|||
|
||||
var copayer = wallet.getCopayer(self.copayerId);
|
||||
var hash;
|
||||
if (!opts.type) {
|
||||
if (!opts.type || opts.type == Model.TxProposal.Types.SIMPLE) {
|
||||
hash = WalletUtils.getProposalHash(opts.toAddress, opts.amount, opts.message, opts.payProUrl);
|
||||
} else {
|
||||
// should match bwc api _computeProposalSignature
|
||||
var header = {
|
||||
outputs: _.map(opts.outputs, function(output) {
|
||||
return _.pick(output, ['toAddress', 'amount', 'message']);
|
||||
|
|
|
@ -221,22 +221,22 @@ helpers.createProposalOpts = function(type, outputs, message, signingKey, feePer
|
|||
};
|
||||
if (feePerKb) opts.feePerKb = feePerKb;
|
||||
|
||||
switch (type) {
|
||||
case Model.TxProposal.Types.SIMPLE:
|
||||
opts.toAddress = outputs[0].toAddress;
|
||||
opts.amount = outputs[0].amount;
|
||||
break;
|
||||
case Model.TxProposal.Types.MULTIPLEOUTPUTS:
|
||||
opts.outputs = outputs;
|
||||
break;
|
||||
var hash;
|
||||
if (type == Model.TxProposal.Types.SIMPLE) {
|
||||
opts.toAddress = outputs[0].toAddress;
|
||||
opts.amount = outputs[0].amount;
|
||||
hash = WalletUtils.getProposalHash(opts.toAddress, opts.amount,
|
||||
opts.message, opts.payProUrl);
|
||||
}
|
||||
else if (type == Model.TxProposal.Types.MULTIPLEOUTPUTS) {
|
||||
opts.outputs = outputs;
|
||||
var header = {
|
||||
outputs: outputs,
|
||||
message: opts.message,
|
||||
payProUrl: opts.payProUrl
|
||||
};
|
||||
hash = WalletUtils.getProposalHash(header);
|
||||
}
|
||||
|
||||
var header = {
|
||||
outputs: outputs,
|
||||
message: opts.message,
|
||||
payProUrl: opts.payProUrl
|
||||
};
|
||||
var hash = WalletUtils.getProposalHash(header);
|
||||
|
||||
try {
|
||||
opts.proposalSignature = WalletUtils.signMessage(hash, signingKey);
|
||||
|
|
Loading…
Reference in New Issue