From 4092f0cb9de29a437abe1ca529456674cadbbf49 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 21 Apr 2014 20:28:57 -0300 Subject: [PATCH 1/3] works sometimes --- js/controllers/transactions.js | 13 +++--- js/models/core/PrivateKey.js | 2 + js/models/core/PublicKeyRing.js | 1 + js/models/core/Wallet.js | 7 ++-- js/services/controllerUtils.js | 2 +- test/test.TxProposals.js | 70 +++++++++++++++++++++++++++++---- 6 files changed, 78 insertions(+), 17 deletions(-) diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index d4356a62a..6f29bdd40 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -51,17 +51,20 @@ console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO $scope.sign = function (ntxid) { var w = $rootScope.wallet; var ret = w.sign(ntxid); - _updateTxs(); + if (!ret) { + $rootScope.flashMessage = {type:'error', message: 'There was an error signing the Transaction'}; + _updateTxs(); + $rootScope.$digest(); + return; + } var p = w.getTxProposal(ntxid); if (p.txp.builder.isFullySigned()) { $scope.send(ntxid); + _updateTxs(); + $rootScope.$digest(); } else { - $rootScope.flashMessage = ret - ? {type:'success', message: 'Transactions signed'} - : {type:'error', message: 'There was an error signing the Transaction'} - ; _updateTxs(); $rootScope.$digest(); } diff --git a/js/models/core/PrivateKey.js b/js/models/core/PrivateKey.js index 2002a14b6..5e7ab06cf 100644 --- a/js/models/core/PrivateKey.js +++ b/js/models/core/PrivateKey.js @@ -71,6 +71,8 @@ PrivateKey.prototype.get = function(index,isChange) { PrivateKey.prototype.getAll = function(addressIndex, changeAddressIndex) { var ret = []; +console.log('[PrivateKey.js.75:addressIndex:]',addressIndex); //TODO +console.log('[PrivateKey.js.79:changeAddressIndex:]',changeAddressIndex); //TODO for(var i=0;i Date: Tue, 22 Apr 2014 22:07:18 -0300 Subject: [PATCH 2/3] small fixes --- js/models/core/PrivateKey.js | 3 --- js/models/core/PublicKeyRing.js | 20 +++++++++++++------- js/models/core/Wallet.js | 17 ++++++----------- js/models/network/WebRTC.js | 1 - test/test.TxProposals.js | 19 +++++++++---------- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/js/models/core/PrivateKey.js b/js/models/core/PrivateKey.js index 5e7ab06cf..0e2d87631 100644 --- a/js/models/core/PrivateKey.js +++ b/js/models/core/PrivateKey.js @@ -71,9 +71,6 @@ PrivateKey.prototype.get = function(index,isChange) { PrivateKey.prototype.getAll = function(addressIndex, changeAddressIndex) { var ret = []; -console.log('[PrivateKey.js.75:addressIndex:]',addressIndex); //TODO -console.log('[PrivateKey.js.79:changeAddressIndex:]',changeAddressIndex); //TODO - for(var i=0;i Date: Tue, 22 Apr 2014 23:07:20 -0300 Subject: [PATCH 3/3] fix ux issues. tx sending working --- index.html | 15 ++++++++++----- js/controllers/transactions.js | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 15af8e066..a88a9fb03 100644 --- a/index.html +++ b/index.html @@ -249,11 +249,13 @@
- - {{o.value}} - - {{o.address}} + + + + + +
{{out.value}} {{out.address}}
created at {{tx.createdTs | date:'medium'}}
@@ -266,7 +268,10 @@ - Proposal ID: {{tx.ntxid}} + + Fee: {{tx.fee}} + Proposal ID: {{tx.ntxid}} +
diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index 6f29bdd40..7cc47598e 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -5,8 +5,9 @@ angular.module('copay.transactions').controller('TransactionsController', function($scope, $rootScope, $location) { $scope.title = 'Transactions'; var _updateTxs = function() { -console.log('[transactions.js.10:_updateTxs:]'); //TODO var w =$rootScope.wallet; + if (!w) return; + var inT = w.getTxProposals(); var txs = []; @@ -25,11 +26,10 @@ console.log('[transactions.js.10:_updateTxs:]'); //TODO }); // extra fields i.outs = outs; - i.fee = i.feeSat/bitcore.util.COIN; + i.fee = i.builder.feeSat/bitcore.util.COIN; i.missingSignatures = tx.countInputMissingSignatures(0); txs.push(i); }); -console.log('[transactions.js.35:txs:]',txs); //TODO $scope.txs = txs; w.removeListener('txProposalsUpdated',_updateTxs) w.once('txProposalsUpdated',_updateTxs); @@ -38,7 +38,7 @@ console.log('[transactions.js.35:txs:]',txs); //TODO $scope.send = function (ntxid) { var w = $rootScope.wallet; w.sendTx(ntxid, function(txid) { -console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO + console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO $rootScope.flashMessage = txid ? {type:'success', message: 'Transactions SENT! txid:' + txid} : {type:'error', message: 'There was an error sending the Transaction'}