From 3df035c5d92c0fbb6c1f60fd4130bceebc8d3f48 Mon Sep 17 00:00:00 2001 From: Gregg Zigler Date: Tue, 7 Jul 2015 14:25:34 -0700 Subject: [PATCH 1/4] proposals with explicit type = simple need legacy header --- lib/server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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']); From a6f2b70ef29c36eda5b7ab55f73aea355f5d9a72 Mon Sep 17 00:00:00 2001 From: Gregg Zigler Date: Tue, 7 Jul 2015 15:02:22 -0700 Subject: [PATCH 2/4] proposal header utility needs separate args for simple proposals --- test/integration/server.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/integration/server.js b/test/integration/server.js index 546f39d..a69fc18 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); @@ -618,7 +618,7 @@ describe('Wallet service', function() { spanish.from.should.equal('bws@dummy.net'); spanish.subject.should.contain('Nuevo pago recibido'); spanish.text.should.contain(wallet.name); - spanish.text.should.contain('0.123 BTC'); + spanish.text.should.contain('0.123'); var english = _.find(emails, { to: 'copayer2@domain.com' }); From bc565f671ac5bdde15e19a78498154d3f8855c05 Mon Sep 17 00:00:00 2001 From: Gregg Zigler Date: Thu, 9 Jul 2015 12:02:04 -0700 Subject: [PATCH 3/4] get network from first output when multiple outputs in proposal --- lib/model/txproposal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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() { From 6e86332d35a6adb34868f28f98d3d0e0f579f59d Mon Sep 17 00:00:00 2001 From: Gregg Zigler Date: Mon, 13 Jul 2015 09:28:16 -0700 Subject: [PATCH 4/4] new bwu lets this test pass --- test/integration/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/server.js b/test/integration/server.js index a69fc18..030958c 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -618,7 +618,7 @@ describe('Wallet service', function() { spanish.from.should.equal('bws@dummy.net'); spanish.subject.should.contain('Nuevo pago recibido'); spanish.text.should.contain(wallet.name); - spanish.text.should.contain('0.123'); + spanish.text.should.contain('0.123 BTC'); var english = _.find(emails, { to: 'copayer2@domain.com' });