From 6f0a9499aaf37505495b519b4b242f6509d94093 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Sun, 20 Apr 2014 16:21:33 -0300 Subject: [PATCH 01/10] Removed "sendTest" link. --- index.html | 4 ---- js/controllers/send.js | 6 ------ 2 files changed, 10 deletions(-) diff --git a/index.html b/index.html index b9f10e7ce..6773f7b4b 100644 --- a/index.html +++ b/index.html @@ -347,10 +347,6 @@ missing -
-
- sendTest -
diff --git a/js/controllers/send.js b/js/controllers/send.js index c027ae04c..cd6226bdb 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -38,10 +38,4 @@ angular.module('copay.send').controller('SendController', $rootScope.flashMessage = { message: 'You send a proposal transaction succefully', type: 'success'}; }; - $scope.sendTest = function() { - var w = $rootScope.wallet; - w.createTx( 'mimoZNLcP2rrMRgdeX5PSnR7AjCqQveZZ4', '12345',function() { - $rootScope.$digest(); - }); - }; }); From 9ab4e2e6d8e9c0296e01c630f8bfcd0c8e2f5441 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Sun, 20 Apr 2014 19:08:04 -0300 Subject: [PATCH 02/10] Improve look&feel of tx list. --- css/main.css | 19 ++++++++++++ index.html | 82 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 78 insertions(+), 23 deletions(-) diff --git a/css/main.css b/css/main.css index bedc96ff4..17e58a215 100644 --- a/css/main.css +++ b/css/main.css @@ -92,6 +92,7 @@ body { .transactions .panel { background: #ECECEC; + border: 1px solid #eee; } .transactions .panel.pending { @@ -99,6 +100,24 @@ body { padding: 1rem; } +.pending .txheader { + margin-bottom: 10px; + padding-bottom: 10px; + border-bottom: 1px solid #eee; +} + +.pending .txbottom { + margin-top: 10px; + padding-top: 10px; + border-top: 1px solid #eee; + font-size: 12px; +} + +.pending table { + width: 100%; + border: none; +} + .home .panel:hover { background: #efefef; } diff --git a/index.html b/index.html index 63039e996..2f1c95005 100644 --- a/index.html +++ b/index.html @@ -237,36 +237,72 @@
-

Pending Transactions ({{txs.length}})

+

Pending transactions ({{txs.length}})

- NTXID: {{tx.ntxid}} - CREATOR: {{tx.creator}} - CREATED_TS: {{tx.createdTs}} -
-

{{o.value}} BTC

- -

{{o.address}}

+
+
+
+ ntxid: {{tx.ntxid}} +
+
+ created at {{tx.createdTs | date:'medium'}} +
+
-
- Signed by you already + +
+
+ + + + + + + + + + + + + + + +
CreatorTo address
{{tx.creator}}{{o.value}} BTC{{o.address}}
+
-
-
- - - One signature - {{tx.missingSignatures}} signatures -missing - - + +
+
+
+
+ Signed by you already +
+
+ + +
+
+
+ + TODO: if tx was sent + + + One signature missing + + + {{tx.missingSignatures}} signatures missing +
+
-
-
-
+
-

Last Transactions

+

Last transactions

Address 1 1231 BTC

From cb887ca778bec77b44b68ad36d853e195992a564 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Sun, 20 Apr 2014 19:39:16 -0300 Subject: [PATCH 03/10] Fix navbar menu on small devices --- css/main.css | 9 +++++++++ index.html | 4 ++-- js/controllers/header.js | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/css/main.css b/css/main.css index bedc96ff4..980cc0d13 100644 --- a/css/main.css +++ b/css/main.css @@ -185,6 +185,15 @@ small.has-error { color: #f04124; } +@media (max-width: 641px) { + .hide_menu { + display: none; + } + .show_menu { + display: block; + } +} + hr { margin: 2.25rem 0;} button.primary { background-color: #111; } diff --git a/index.html b/index.html index 6773f7b4b..6544f6617 100644 --- a/index.html +++ b/index.html @@ -27,11 +27,11 @@ -
+
  • {{item.title}} diff --git a/js/controllers/header.js b/js/controllers/header.js index d6680e76b..4236c486f 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -47,4 +47,5 @@ angular.module('copay.header').controller('HeaderController', $rootScope.flashMessage = {}; }; + $rootScope.isCollapsed = true; }); From 5267c2ad48c4efa7e036804a4914d757127ff65c Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Sun, 20 Apr 2014 20:21:54 -0300 Subject: [PATCH 04/10] WIP: reorder main menu. Renamed home for addresses. Fix header titles --- css/main.css | 4 ++-- index.html | 15 +++++++-------- js/app.js | 4 ++-- js/controllers/{home.js => addresses.js} | 2 +- js/controllers/header.js | 8 ++++---- js/routes.js | 4 ++-- 6 files changed, 18 insertions(+), 19 deletions(-) rename js/controllers/{home.js => addresses.js} (93%) diff --git a/css/main.css b/css/main.css index 17e58a215..3a034f86d 100644 --- a/css/main.css +++ b/css/main.css @@ -86,7 +86,7 @@ body { color: #111; }*/ -.home .panel { +.addresses .panel { font-size: 0.9rem; } @@ -118,7 +118,7 @@ body { border: none; } -.home .panel:hover { +.addresses .panel:hover { background: #efefef; } diff --git a/index.html b/index.html index 8f562e44d..7071f272a 100644 --- a/index.html +++ b/index.html @@ -208,9 +208,9 @@ - - - + diff --git a/js/app.js b/js/app.js index e8bbf2fdf..c955f458e 100644 --- a/js/app.js +++ b/js/app.js @@ -5,7 +5,7 @@ angular.module('copay',[ 'mm.foundation', 'monospaced.qrcode', 'copay.header', - 'copay.home', + 'copay.addresses', 'copay.transactions', 'copay.send', 'copay.backup', @@ -18,7 +18,7 @@ angular.module('copay',[ ]); angular.module('copay.header', []); -angular.module('copay.home', []); +angular.module('copay.addresses', []); angular.module('copay.transactions', []); angular.module('copay.send', []); angular.module('copay.backup', []); diff --git a/js/controllers/home.js b/js/controllers/addresses.js similarity index 93% rename from js/controllers/home.js rename to js/controllers/addresses.js index edacdc467..d7955ef80 100644 --- a/js/controllers/home.js +++ b/js/controllers/addresses.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copay.home').controller('HomeController', +angular.module('copay.addresses').controller('AddressesController', function($scope, $rootScope, $location, Socket, controllerUtils) { $scope.title = 'Home'; $scope.oneAtATime = true; diff --git a/js/controllers/header.js b/js/controllers/header.js index d6680e76b..754ab8dfd 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -3,13 +3,13 @@ angular.module('copay.header').controller('HeaderController', function($scope, $rootScope, $location, walletFactory, controllerUtils) { $scope.menu = [{ - 'title': 'Home', - 'icon': 'fi-home', - 'link': '#/home' - }, { 'title': 'Copayers', 'icon': 'fi-torsos-all', 'link': '#/peer' + }, { + 'title': 'Addresses', + 'icon': 'fi-address-book', + 'link': '#/addresses' }, { 'title': 'Transactions', 'icon': 'fi-loop', diff --git a/js/routes.js b/js/routes.js index 5c655b208..9fb2085f5 100644 --- a/js/routes.js +++ b/js/routes.js @@ -15,8 +15,8 @@ angular .when('/setup', { templateUrl: 'setup.html' }) - .when('/home', { - templateUrl: 'home.html' + .when('/addresses', { + templateUrl: 'addresses.html' }) .when('/join/:id', { templateUrl: 'join.html' From a1b00dcd0541abb0b6a027abade34397b728ef32 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 20 Apr 2014 20:24:24 -0300 Subject: [PATCH 05/10] more work on Tx --- js/controllers/transactions.js | 8 +++-- js/models/blockchain/Insight.js | 8 +++++ js/models/core/TxProposals.js | 57 +++++++++++++++++++++++++------ js/models/core/Wallet.js | 59 +++++++++++++++++++++++---------- js/models/core/WalletFactory.js | 5 +-- js/models/network/WebRTC.js | 25 ++++++++------ 6 files changed, 119 insertions(+), 43 deletions(-) diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index e5048401e..c140160b0 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -8,6 +8,7 @@ angular.module('copay.transactions').controller('TransactionsController', $scope.oneAtATime = true; var _updateTxs = function() { +console.log('[transactions.js.10:_updateTxs:]'); //TODO var w =$rootScope.wallet; var inT = w.getTxProposals(); var txs = []; @@ -35,11 +36,14 @@ angular.module('copay.transactions').controller('TransactionsController', one.missingSignatures = tx.countInputMissingSignatures(0); one.signedByUs = i.signedByUs; one.ntxid = i.ntxid; - one.creator = i.txp.creator, + one.creator = i.txp.creator; one.createdTs = i.txp.createdTs; + one.sentTs = i.txp.sentTs; txs.push(one); }); $scope.txs = txs; +console.log('[transactions.js.55] SET HANDL+'); //TODO + w.once('txProposalsUpdated',_updateTxs); }; @@ -49,7 +53,7 @@ angular.module('copay.transactions').controller('TransactionsController', else { _updateTxs(); var w = $rootScope.wallet; - w.on('refresh',_updateTxs); + var socket = Socket($scope); socket.on('connect', controllerUtils.handleTransactionByAddress($scope)); } diff --git a/js/models/blockchain/Insight.js b/js/models/blockchain/Insight.js index 1fcedb37b..fb77b7d73 100644 --- a/js/models/blockchain/Insight.js +++ b/js/models/blockchain/Insight.js @@ -70,7 +70,10 @@ Insight.prototype.sendRawTransaction = function(rawtx, cb) { headers: { 'content-type' : 'application/x-www-form-urlencoded' } }; this._request(options, function(err,res) { +console.log('[Insight.js.73:err:]',err); //TODO if (err) return cb(); + +console.log('[Insight.js.74]', res); //TODO return cb(res.txid); }); }; @@ -95,13 +98,18 @@ Insight.prototype._request = function(options, callback) { request.open(options.method, url, true); request.onreadystatechange = function() { if (request.readyState === 4) { +console.log('[Insight.js.102]', request); //TODO if (request.status === 200) { try { return callback(null, JSON.parse(request.responseText)); } catch (e) { + +console.log('[Insight.js.106]'); //TODO return callback({message: 'Wrong response from insight'}); } } else { + +console.log('[Insight.js.111]'); //TODO return callback({message: 'Error ' + request.status}); } } diff --git a/js/models/core/TxProposals.js b/js/models/core/TxProposals.js index 309047988..e056d9e8f 100644 --- a/js/models/core/TxProposals.js +++ b/js/models/core/TxProposals.js @@ -19,6 +19,7 @@ function TxProposal(opts) { this.seenBy = opts.seenBy || {}; this.signedBy = opts.signedBy || {}; this.builder = opts.builder; + this.sentTs = null; } TxProposal.prototype.toObj = function() { @@ -35,6 +36,14 @@ TxProposal.fromObj = function(o) { return t; }; +TxProposal.setSent = function() { + this.sentTs = Date.now();; +}; + +TxProposal.getSentTs = function() { + return this.sentTs; +}; + module.exports = require('soop')(TxProposal); @@ -54,6 +63,7 @@ TxProposals.fromObj = function(o) { o.txps.forEach(function(o2) { var t = TxProposal.fromObj(o2); var id = t.builder.build().getNormalizedHash().toString('hex'); +console.log('[TxProposals.js.65:id:]',id, o2); //TODO ret.txps[id] = t; }); return ret; @@ -64,7 +74,8 @@ TxProposals.prototype.toObj = function() { var ret = []; for(var id in this.txps){ var t = this.txps[id]; - ret.push(t.toObj()); + if (!t.sent) + ret.push(t.toObj()); } return { txps: ret, @@ -110,43 +121,66 @@ TxProposals.prototype._startMerge = function(myTxps, theirTxps) { TxProposals.prototype._mergeMetadata = function(myTxps, theirTxps, mergeInfo) { var toMerge = mergeInfo.toMerge; + var hasChanged =0; Object.keys(toMerge).forEach(function(hash) { var v0 = myTxps[hash]; var v1 = toMerge[hash]; +console.log('[TxProposals.js.127:v0:]',v0, v1); //TODO Object.keys(v1.seenBy).forEach(function(k) { - v0.seenBy[k] = v1.seenBy[k]; + if (!v0.seenBy[k] || v0.seenBy[k] !== v1.seenBy[k]) { + v0.seenBy[k] = v1.seenBy[k]; + hasChanged++; + } }); Object.keys(v1.signedBy).forEach(function(k) { - v0.signedBy[k] = v1.signedBy[k]; + if (!v0.signedBy[k]) { + v0.signedBy[k] = v1.signedBy[k]; + hasChanged++; + } }); + + if (!v0.sentTs && v1.sentTs) { + v0.sentTs = v1.sentTs; + hasChanged++; + } + }); +console.log('[TxProposals.js.131:hasChanged:]',hasChanged); //TODO + return hasChanged; }; TxProposals.prototype._mergeBuilder = function(myTxps, theirTxps, mergeInfo) { var toMerge = mergeInfo.toMerge; + var hasChanged=0; for(var hash in toMerge){ var v0 = myTxps[hash].builder; var v1 = toMerge[hash].builder; + // TODO: enhance this + var before = JSON.stringify(v0.toObj()); v0.merge(v1); - }; + var after = JSON.stringify(v0.toObj()); + if (after !== before) hasChanged ++; + } +console.log('[TxProposals.js.149:hasChanged:]',hasChanged); //TODO }; TxProposals.prototype.add = function(data) { var id = data.builder.build().getNormalizedHash().toString('hex'); +console.log('[TxProposals.js.175:data: ADD]',data); //TODO this.txps[id] = new TxProposal(data); }; -TxProposals.prototype.remove = function(ntxid) { - -console.log('[TxProposals.js.147] DELETING:', ntxid); //TODO - delete this.txps[ntxid]; +TxProposals.prototype.setSent = function(ntxid) { + //sent TxProposals are local an not broadcasted. +console.log('[TxProposals.js.147] SET SENT:', ntxid); //TODO + this.txps[ntxid].setSent(); }; @@ -155,18 +189,21 @@ TxProposals.prototype.merge = function(t) { throw new Error('network mismatch in:', t); var res = []; + var hasChanged = 0; var myTxps = this.txps; var theirTxps = t.txps; var mergeInfo = this._startMerge(myTxps, theirTxps); - this._mergeMetadata(myTxps, theirTxps, mergeInfo); - this._mergeBuilder(myTxps, theirTxps, mergeInfo); + hasChanged += this._mergeMetadata(myTxps, theirTxps, mergeInfo); + hasChanged += this._mergeBuilder(myTxps, theirTxps, mergeInfo); Object.keys(mergeInfo.toMerge).forEach(function(hash) { mergeInfo.ready[hash] = myTxps[hash]; }); + mergeInfo.stats.hasChanged = hasChanged; + this.txps=mergeInfo.ready; return mergeInfo.stats; }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 7b0efd813..45e62301b 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -34,7 +34,8 @@ function Wallet(opts) { Wallet.parent=EventEmitter; Wallet.prototype.log = function(){ if (!this.verbose) return; - console.log(arguments); + if (console) + console.log.apply(console, arguments); }; Wallet.getRandomId = function() { @@ -76,10 +77,13 @@ Wallet.prototype._handleTxProposals = function(senderId, data, isInbound) { var recipients; var inTxp = copay.TxProposals.fromObj(data.txProposals); var mergeInfo = this.txProposals.merge(inTxp, true); +console.log('[Wallet.js.79:inTxp:]',inTxp); //TODO var addSeen = this.addSeenToTxProposals(); + +console.log('[Wallet.js.81]', addSeen, mergeInfo); //TODO // if ((mergeInfo.merged && !data.isBroadcast) || addSeen) { - if (mergeInfo.merged || addSeen) { + if (mergeInfo.hasChanged || addSeen) { this.log('### BROADCASTING txProposals. ' ); recipients = null; shouldSend = true; @@ -191,6 +195,8 @@ console.log('[Wallet.js.177] NET START: emit CREATED'); //TODO if (otherPeerId !== myPeerId) { net.connectTo(otherPeerId); } + self.sendWalletReady(self.firstPeerId); + self.firstPeerId = null; self.emit('refresh'); } }, startOpts); @@ -203,7 +209,8 @@ Wallet.prototype.store = function(isSync) { if (isSync) { this.log('Wallet stored.'); //TODO - } else { + } + else { this.log('Wallet stored. REFRESH Emitted'); //TODO this.emit('refresh'); } @@ -291,7 +298,7 @@ Wallet.prototype.getTxProposals = function() { var txp = this.txProposals.txps[k]; var i = {txp:txp}; i.ntxid = k; - i.signedByUs = txp.signedBy[this.privateKey.getId()]?true:false; + i.signedByUs = txp.signedBy[this.getMyPeerId()]?true:false; ret.push(i); } return ret; @@ -301,7 +308,7 @@ Wallet.prototype.getTxProposal = function(ntxid) { var txp = this.txProposals.txps[ntxid]; var i = {txp:txp}; i.ntxid = ntxid; - i.signedByUs = txp.signedBy[this.privateKey.getId()]?true:false; + i.signedByUs = txp.signedBy[this.getMyPeerId()]?true:false; return i; }; @@ -319,7 +326,7 @@ Wallet.prototype.sign = function(ntxid) { var ret = false; if (b.signaturesAdded > before) { - txp.signedBy[self.privateKey.getId()] = Date.now(); + txp.signedBy[self.getMyPeerId()] = Date.now(); this.sendTxProposals(); this.store(true); ret = true; @@ -342,8 +349,9 @@ Wallet.prototype.sendTx = function(ntxid) { this.blockchain.sendRawTransaction(txHex, function(txid) { self.log('BITCOND txid:',txid); //TODO if (txid) { - self.txProposals.remove(ntxid); - self.store(true); + self.txProposals.setSent(ntxid); + self.sendTxProposals(); + self.store(); } return (txid); }); @@ -351,12 +359,15 @@ Wallet.prototype.sendTx = function(ntxid) { Wallet.prototype.addSeenToTxProposals = function() { var ret=false; - var self=this; + var myId=this.getMyPeerId(); for(var k in this.txProposals.txps) { var txp = this.txProposals.txps[k]; - if (!txp.seenBy[self.privateKey.getId()]) { - txp.seenBy[self.privateKey.getId()] = Date.now(); +console.log('[Wallet.js.364:txp:] ADD SEEN',txp); //TODO + if (!txp.seenBy[myId]) { + +console.log('[Wallet.js.367] ADDING'); //TODO + txp.seenBy[myId] = Date.now(); ret = true; } } @@ -435,9 +446,12 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) { } self.getUnspent(function(unspentList) { // TODO check enough funds, etc. +console.log('[Wallet.js.452]', self); //TODO self.createTxSync(toAddress, amountSatStr, unspentList, opts); self.sendPublicKeyRing(); // Change Address self.sendTxProposals(); + +console.log('[Wallet.js.452]', self); //TODO self.store(); return cb(); }); @@ -469,15 +483,24 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) { b.sign( priv.getAll(pkr.addressIndex, pkr.changeAddressIndex) ); } var me = {}; - if (priv) me[priv.getId()] = Date.now(); + var myId = this.getMyPeerId(); + var now = Date.now(); - this.txProposals.add({ - signedBy: priv && b.signaturesAdded ? me : {}, - seenBy: priv ? me : {}, - creator: priv.getId(), - createdTs: Date.now(), + if (priv) me[myId] = now; + +console.log('[Wallet.js.485:me:]',myId, me); //TODO + + var data = { + signedBy: (priv && b.signaturesAdded ? me : {}), + seenBy: (priv ? me : {}), + creator: myId, + createdTs: now, builder: b, - }); + }; + +console.log('[Wallet.js.499:data:]',data); //TODO + + this.txProposals.add(data); }; Wallet.prototype.connectTo = function(peerId) { diff --git a/js/models/core/WalletFactory.js b/js/models/core/WalletFactory.js index b6f904128..c6719ba27 100644 --- a/js/models/core/WalletFactory.js +++ b/js/models/core/WalletFactory.js @@ -33,7 +33,8 @@ function WalletFactory(config) { WalletFactory.prototype.log = function(){ if (!this.verbose) return; - console.log(arguments); + if (console) + console.log.apply(console, arguments); }; @@ -152,7 +153,7 @@ WalletFactory.prototype.joinCreateSession = function(peerId, cb) { if (data.type ==='walletId') { data.opts.privateKey = privateKey; var w = self.open(data.walletId, data.opts); - w.sendWalletReady(peerId); + w.firstPeerId = peerId; return cb(w); } }); diff --git a/js/models/network/WebRTC.js b/js/models/network/WebRTC.js index 2a7017535..382f9e536 100644 --- a/js/models/network/WebRTC.js +++ b/js/models/network/WebRTC.js @@ -23,6 +23,7 @@ function Network(opts) { this.debug = opts.debug || 3; this.maxPeers = opts.maxPeers || 10; this.opts = { key: opts.key }; + this.connections = {}; // For using your own peerJs server ['port', 'host', 'path', 'debug'].forEach(function(k) { @@ -69,6 +70,9 @@ Network._arrayRemove = function(el, array) { }; Network.prototype._onClose = function(peerId) { +console.log('[WebRTC.js.72:_onClose:]'); + + delete this.connections[peerId]; this.connectedPeers = Network._arrayRemove(peerId, this.connectedPeers); this._notifyNetworkChange(); }; @@ -138,11 +142,11 @@ Network.prototype._checkAnyPeer = function() { } Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) { - var self=this; dataConn.on('open', function() { if (!Network._inArray(dataConn.peer, self.connectedPeers)) { + self.connections[dataConn.peer] = dataConn; console.log('### DATA CONNECTION READY TO: ADDING PEER: %s (inbound: %s)', dataConn.peer, isInbound); @@ -159,11 +163,14 @@ Network.prototype._setupConnectionHandlers = function(dataConn, isInbound) { dataConn.on('error', function(e) { console.log('### DATA ERROR',e ); //TODO + self._onClose(dataConn.peer); + self._checkAnyPeer(); self.emit('dataError'); }); dataConn.on('close', function() { if (self.closing) return; + console.log('### CLOSE RECV FROM:', dataConn.peer); self._onClose(dataConn.peer); self._checkAnyPeer(); @@ -181,8 +188,6 @@ Network.prototype._setupPeerHandlers = function(openCallback) { p.on('open', function() { self.connectedPeers = [self.peerId]; - -console.log('[WebRTC.js.187] LENGTH', self.connectedPeers.length); //TODO return openCallback(); }); @@ -239,18 +244,16 @@ console.log('[WebRTC.js.237] started TRUE'); //TODO Network.prototype._sendToOne = function(peerId, data, cb) { if (peerId !== this.peerId) { - var conns = this.peer.connections[peerId]; - - if (conns) { + var dataConn = this.connections[peerId]; + if (dataConn) { var str = JSON.stringify({ sender: this.peerId, data: data }); - - for (var i = 0; i < conns.length; i++) { - var conn = conns[i]; - conn.send(str); - } + dataConn.send(str); + } + else { +console.log('[WebRTC.js.255] WARN: NO CONNECTION TO:', peerId); //TODO } } if (typeof cb === 'function') cb(); From 65da9b69c17fce9d67f9fcd829c2ba05bc0d832a Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Sun, 20 Apr 2014 21:19:32 -0300 Subject: [PATCH 06/10] sentTs on transaction proposal --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index b94efc069..551bdcfd4 100644 --- a/index.html +++ b/index.html @@ -287,8 +287,8 @@
- - TODO: if tx was sent + + Sent at {{tx.sentTs | date:'medium'}} One signature missing From 17431e29c510af0e03fbcc114fe71b4ce414a66b Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 20 Apr 2014 21:23:53 -0300 Subject: [PATCH 07/10] fix set sent --- js/models/core/TxProposals.js | 9 +++++---- js/models/core/Wallet.js | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/js/models/core/TxProposals.js b/js/models/core/TxProposals.js index e056d9e8f..26935583b 100644 --- a/js/models/core/TxProposals.js +++ b/js/models/core/TxProposals.js @@ -29,6 +29,11 @@ TxProposal.prototype.toObj = function() { return o; }; + +TxProposal.prototype.setSent = function() { + this.sentTs = Date.now();; +}; + TxProposal.fromObj = function(o) { var t = new TxProposal(o); var b = new Builder.fromObj(o.builderObj); @@ -36,10 +41,6 @@ TxProposal.fromObj = function(o) { return t; }; -TxProposal.setSent = function() { - this.sentTs = Date.now();; -}; - TxProposal.getSentTs = function() { return this.sentTs; }; diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 45e62301b..e368850c3 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -348,8 +348,14 @@ Wallet.prototype.sendTx = function(ntxid) { var self = this; this.blockchain.sendRawTransaction(txHex, function(txid) { self.log('BITCOND txid:',txid); //TODO + +console.log('[Wallet.js.351]'); //TODO if (txid) { +console.log('[Wallet.js.354]',self); //TODO self.txProposals.setSent(ntxid); + +console.log('[Wallet.js.353]', self.txProposals); //TODO + self.sendTxProposals(); self.store(); } From 55f26590bca6a3397fa2b4c2bef1e57114c202e0 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Sun, 20 Apr 2014 21:40:03 -0300 Subject: [PATCH 08/10] use "info" instead of "warning", which is more pleasant ...and update a typo: signning -> signing --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 0aaa11793..ece511429 100644 --- a/index.html +++ b/index.html @@ -55,9 +55,9 @@
-
+
- NOTE: Your wallet is not complete yet. + Note: Your wallet is not complete yet. {{$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers() }} keys are @@ -189,8 +189,8 @@

Online Copayers: {{$root.wallet.network.connectedPeers.length}}

-

- {{$root.wallet.publicKeyRing.requiredCopayers}} copayers needed for signning transactions +

+ {{$root.wallet.publicKeyRing.requiredCopayers}} copayers needed for signing transactions

    From 616429a355de0b60fc2bd844d3fc52d41daad1d8 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sun, 20 Apr 2014 21:53:54 -0300 Subject: [PATCH 09/10] fixes in ux --- index.html | 10 +++++++++- js/controllers/transactions.js | 26 +++++++++++++++++++------- js/models/core/TxProposals.js | 2 +- js/models/core/Wallet.js | 14 ++++---------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index 0aaa11793..f88cd7e19 100644 --- a/index.html +++ b/index.html @@ -286,6 +286,13 @@
+ + Transaction ready. + + + Sent at {{tx.sentTs | date:'medium'}} @@ -299,8 +306,8 @@
-
+
diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index c140160b0..39bf65282 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -43,6 +43,7 @@ console.log('[transactions.js.10:_updateTxs:]'); //TODO }); $scope.txs = txs; console.log('[transactions.js.55] SET HANDL+'); //TODO + w.removeListener('txProposalsUpdated',_updateTxs) w.once('txProposalsUpdated',_updateTxs); }; @@ -58,6 +59,20 @@ console.log('[transactions.js.55] SET HANDL+'); //TODO socket.on('connect', controllerUtils.handleTransactionByAddress($scope)); } + + $scope.send = function (ntxid) { + var w = $rootScope.wallet; + w.sendTx(ntxid, function(txid) { +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'} + ; + _updateTxs(); + $rootScope.$digest(); + }); + }; + $scope.sign = function (ntxid) { var w = $rootScope.wallet; var ret = w.sign(ntxid); @@ -65,19 +80,16 @@ console.log('[transactions.js.55] SET HANDL+'); //TODO var p = w.getTxProposal(ntxid); if (p.txp.builder.isFullySigned()) { - w.sendTx(ntxid, function(txid) { - $rootScope.flashMessage = txid - ? {type:'success', message: 'Transactions SENT! txid:' + txid} - : {type:'error', message: 'There was an error sending the Transaction'} - ; - }); + $scope.send(ntxid); } else { $rootScope.flashMessage = ret ? {type:'success', message: 'Transactions signed'} : {type:'error', message: 'There was an error signing the Transaction'} ; + _updateTxs(); + $rootScope.$digest(); } - _updateTxs(); }; + }); diff --git a/js/models/core/TxProposals.js b/js/models/core/TxProposals.js index 26935583b..28f9dadbe 100644 --- a/js/models/core/TxProposals.js +++ b/js/models/core/TxProposals.js @@ -19,7 +19,7 @@ function TxProposal(opts) { this.seenBy = opts.seenBy || {}; this.signedBy = opts.signedBy || {}; this.builder = opts.builder; - this.sentTs = null; + this.sentTs = opts.sentTs || null; } TxProposal.prototype.toObj = function() { diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index e368850c3..e82bff825 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -334,7 +334,7 @@ Wallet.prototype.sign = function(ntxid) { return ret; }; -Wallet.prototype.sendTx = function(ntxid) { +Wallet.prototype.sendTx = function(ntxid, cb) { var txp = this.txProposals.txps[ntxid]; if (!txp) return; @@ -348,18 +348,12 @@ Wallet.prototype.sendTx = function(ntxid) { var self = this; this.blockchain.sendRawTransaction(txHex, function(txid) { self.log('BITCOND txid:',txid); //TODO - -console.log('[Wallet.js.351]'); //TODO if (txid) { -console.log('[Wallet.js.354]',self); //TODO self.txProposals.setSent(ntxid); - -console.log('[Wallet.js.353]', self.txProposals); //TODO - - self.sendTxProposals(); - self.store(); } - return (txid); + self.sendTxProposals(); + self.store(); + return cb(txid); }); }; From 9d149b8394d45e272d48ce852dbbb349bdf1d6da Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Sun, 20 Apr 2014 22:05:25 -0300 Subject: [PATCH 10/10] another typo --- js/controllers/send.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/controllers/send.js b/js/controllers/send.js index cd6226bdb..91cf5d297 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -35,7 +35,7 @@ angular.module('copay.send').controller('SendController', form.amount.$pristine = true; // TODO: check if createTx has an error. - $rootScope.flashMessage = { message: 'You send a proposal transaction succefully', type: 'success'}; + $rootScope.flashMessage = { message: 'Your transaction proposal has been sent successfully', type: 'success'}; }; });