From ba8a0e83d2df060a6211e3a5c8bd78e07741a30d Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 18 Apr 2014 11:19:39 -0300 Subject: [PATCH 1/3] fix p2p connecting --- js/config.js | 10 +++++----- js/controllers/transactions.js | 14 ++++++++------ js/models/core/Wallet.js | 16 ++++++++++++++++ js/models/core/WalletFactory.js | 6 +++--- test/test.Wallet.js | 9 ++++++++- test/test.Walletfactory.js | 6 ++++++ 6 files changed, 46 insertions(+), 15 deletions(-) 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 Date: Fri, 18 Apr 2014 11:23:07 -0300 Subject: [PATCH 2/3] remote server --- js/config.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/config.js b/js/config.js index a16d9120f..c5dde3556 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, }, From 40ef2bc23e0ac9051555dbd3534cb52fe41beed3 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 18 Apr 2014 11:23:45 -0300 Subject: [PATCH 3/3] . --- test/test.Walletfactory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.Walletfactory.js b/test/test.Walletfactory.js index 21160a0dd..98157d952 100644 --- a/test/test.Walletfactory.js +++ b/test/test.Walletfactory.js @@ -39,7 +39,7 @@ describe('WalletFactory model', function() { var wf = new WalletFactory(config); should.exist(wf); }); - it('#_checkRead should return fail', function() { + it('#_checkRead should return false', function() { var wf = new WalletFactory(config); wf._checkRead('dummy').should.equal(false); wf.read('dummy').should.equal(false);