From 3bef4f30b6cbdc3088d1fde09fada4f8ca1ecb54 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 16 Dec 2015 00:21:58 -0300 Subject: [PATCH] initialize amount field on multiple_output tx proposals --- lib/model/txproposal_legacy.js | 1 + test/integration/server.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/model/txproposal_legacy.js b/lib/model/txproposal_legacy.js index f8316d2..09952ec 100644 --- a/lib/model/txproposal_legacy.js +++ b/lib/model/txproposal_legacy.js @@ -45,6 +45,7 @@ TxProposal._create.multiple_outputs = function(txp, opts) { return _.pick(output, ['amount', 'toAddress', 'message']); }); txp.outputOrder = _.shuffle(_.range(txp.outputs.length + 1)); + txp.amount = txp.getTotalAmount(); try { txp.network = Bitcore.Address(txp.outputs[0].toAddress).toObject().network; } catch (ex) {} diff --git a/test/integration/server.js b/test/integration/server.js index d3ed35d..524cd09 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2467,6 +2467,7 @@ describe('Wallet service', function() { server.createTxLegacy(txOpts, function(err, tx) { should.not.exist(err); should.exist(tx); + tx.amount.should.equal(helpers.toSatoshi(150)); done(); }); }); @@ -4790,12 +4791,14 @@ describe('Wallet service', function() { }); }); it('should handle exceeded limit', function(done) { - server.getTxHistory({limit:1000}, function(err, txs) { + server.getTxHistory({ + limit: 1000 + }, function(err, txs) { err.code.should.equal('HISTORY_LIMIT_EXCEEDED'); done(); }); }); - + }); describe('#scan', function() {