diff --git a/js/config.js b/js/config.js index cf2793f1f..a16d9120f 100644 --- a/js/config.js +++ b/js/config.js @@ -3,12 +3,12 @@ var config = { networkName: 'testnet', network: { - key: 'lwjd5qra8257b9', + // key: 'lwjd5qra8257b9', // This is for running local peerJs with params: ./peerjs -p 10009 -k 'sdfjhwefh' - // key: 'sdfjhwefh', - // host: 'localhost', - // port: 10009, - // path: '/', + key: 'sdfjhwefh', + host: 'localhost', + port: 10009, + path: '/', maxPeers: 3, debug: 3, }, diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index 83b19a245..89476fce5 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -7,11 +7,13 @@ angular.module('copay.transactions').controller('TransactionsController', $scope.oneAtATime = true; var _updateTxs = function() { - var inT = $rootScope.wallet.getTxProposals(); - var ts = []; + var w =$rootScope.wallet; + var inT = w.getTxProposals(); + var ts = []; + inT.forEach(function(i){ - var b =i.txp.builder; - var tx = b.build(); + var b = i.txp.builder; + var tx = b.build(); var one = { valueOutSat: b.valueOutSat, feeSat: b.feeSat, @@ -21,7 +23,8 @@ angular.module('copay.transactions').controller('TransactionsController', tx.outs.forEach(function(o) { var s = o.getScript(); var aStr = bitcore.Address.fromScript(s, config.networkName).toString(); - outs.push({address: aStr, value: bitcore.util.valueToBigInt(o.getValue())}); + if (!w.addressIsOwn(aStr)) + outs.push({address: aStr, value: bitcore.util.valueToBigInt(o.getValue())}); }); one.outs = outs; ts.push(one); @@ -42,7 +45,6 @@ angular.module('copay.transactions').controller('TransactionsController', $scope.sign = function (ntxid) { var w = $rootScope.wallet; var ret = w.sign(ntxid); -console.log('[transactions.js.28:ret:]',ret); //TODO $rootScope.flashMessage = {type:'success', message: 'Transactions SEND! : ' + ret}; _updateTxs(); }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index a2ed268e2..c0f01854b 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -310,6 +310,22 @@ Wallet.prototype.getAddressesStr = function(onlyMain) { return ret; }; + +Wallet.prototype.addressIsOwn = function(addrStr) { + var addrList = this.getAddressesStr(); + var l = addrList.length; + var ret = false; + + for(var i=0; i