From 05e836424ab1326b090efde9144bf1fad34cc521 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 30 Oct 2014 16:38:08 -0300 Subject: [PATCH 1/2] correctly assign sentTxid when proposal is broadcasted --- js/controllers/history.js | 1 + js/models/Wallet.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/controllers/history.js b/js/controllers/history.js index f5f0e465b..00fb3689c 100644 --- a/js/controllers/history.js +++ b/js/controllers/history.js @@ -72,6 +72,7 @@ angular.module('copayApp.controllers').controller('HistoryController', } $scope.getShortNetworkName = function() { + var w = $rootScope.wallet; return w.getNetworkName().substring(0, 4); }; $scope.amountAlternative = function(amount, txIndex, cb) { diff --git a/js/models/Wallet.js b/js/models/Wallet.js index 0b6fe5b1f..e19823c32 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -442,7 +442,7 @@ Wallet.prototype._checkSentTx = function(ntxid, cb) { this.blockchain.getTransaction(txid, function(err, tx) { if (err) return cb(false); - return cb(ret); + return cb(txid); }); }; @@ -477,10 +477,10 @@ Wallet.prototype._onTxProposal = function(senderId, data) { var tx = m.txp.builder.build(); if (tx.isComplete()) { - this._checkSentTx(m.ntxid, function(ret) { - if (ret) { + this._checkSentTx(m.ntxid, function(txid) { + if (txid) { if (!m.txp.getSent()) { - m.txp.setSent(m.ntxid); + m.txp.setSent(txid); self.emitAndKeepAlive('txProposalsUpdated'); } } From dbf1ae2f6452d77105d53dded9eec507b92c7d59 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 30 Oct 2014 16:43:12 -0300 Subject: [PATCH 2/2] fixed test --- test/Wallet.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Wallet.js b/test/Wallet.js index e64202d89..7090943ac 100644 --- a/test/Wallet.js +++ b/test/Wallet.js @@ -1609,10 +1609,11 @@ describe('Wallet model', function() { new: false, hasChanged: true, }); - w._checkSentTx = sinon.stub().yields(true); + w._checkSentTx = sinon.stub().yields('123'); w._onTxProposal('senderID', data); txp.setSent.calledOnce.should.be.true; + txp.setSent.calledWith('123').should.be.true; w.sendTxProposal.called.should.be.false; done(); });