diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index 8fdf320..d822ca1 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -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() { diff --git a/lib/server.js b/lib/server.js index b2e7fb9..95d2a4d 100644 --- a/lib/server.js +++ b/lib/server.js @@ -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']); diff --git a/test/integration/server.js b/test/integration/server.js index 3d8a92d..0fbce2a 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -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);