From 1954978202ab1e3f7546fcf1e3c6210fe847a754 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 17 Apr 2014 18:06:09 -0300 Subject: [PATCH] parse output TX to show before signing (WIP) --- index.html | 4 +-- js/controllers/send.js | 2 +- js/controllers/transactions.js | 43 +++++++++++++++++++++------------ js/models/blockchain/Insight.js | 2 -- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 8b8f6d6f4..e896e0805 100644 --- a/index.html +++ b/index.html @@ -237,8 +237,8 @@ missing. Ask your copayers to join your session: {{$root.wallet.network.peerI
-

Pending Transactions ({{txsoutput.length}})

-
+

Pending Transactions ({{txs.length}})

+
{{txp}}

Address 1

diff --git a/js/controllers/send.js b/js/controllers/send.js index 1584c6a76..8e28185bf 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -15,7 +15,7 @@ angular.module('copay.send').controller('SendController', $scope.sendTest = function() { var w = $rootScope.wallet; - w.createTx( '15q6HKjWHAksHcH91JW23BJEuzZgFwydBt', '12345',function() { + w.createTx( 'mimoZNLcP2rrMRgdeX5PSnR7AjCqQveZZ4', '12345',function() { $rootScope.$digest(); }); }; diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index 5e1e3c835..83b19a245 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -6,25 +6,35 @@ angular.module('copay.transactions').controller('TransactionsController', $scope.oneAtATime = true; + var _updateTxs = function() { + var inT = $rootScope.wallet.getTxProposals(); + var ts = []; + inT.forEach(function(i){ + var b =i.txp.builder; + var tx = b.build(); + var one = { + valueOutSat: b.valueOutSat, + feeSat: b.feeSat, + }; + var outs = []; + var bitcore = require('bitcore'); + 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())}); + }); + one.outs = outs; + ts.push(one); + }); + $scope.txs = ts; + }; + + if (!$rootScope.wallet || !$rootScope.wallet.id) { $location.path('signin'); } else { - $scope.txsinput = [ - { - fromAddr: "n3zUqNR7Bbbc4zJhPVj1vG2Lx66K3Xhzvb", - toAddr: "msvv2mDfE298s7boXwALq4Dqv77K3TWRZ1", - amount: 23.9982 - }, - { - fromAddr: "my9wnLwwUrwpNfEgSrWY62ymEGf1edKf4J", - toAddr: "monCusNiDuptf68rtr58hEjKpJt6cW6zwS", - amount: 2.22 - } - ]; - - $scope.txsoutput = $rootScope.wallet.getTxProposals(); - + _updateTxs(); var socket = Socket($scope); socket.on('connect', controllerUtils.handleTransactionByAddress($scope)); } @@ -33,6 +43,7 @@ angular.module('copay.transactions').controller('TransactionsController', var w = $rootScope.wallet; var ret = w.sign(ntxid); console.log('[transactions.js.28:ret:]',ret); //TODO - $scope.txsoutput = $rootScope.wallet.getTxProposals(); + $rootScope.flashMessage = {type:'success', message: 'Transactions SEND! : ' + ret}; + _updateTxs(); }; }); diff --git a/js/models/blockchain/Insight.js b/js/models/blockchain/Insight.js index e2fe60c72..ab86fd6e9 100644 --- a/js/models/blockchain/Insight.js +++ b/js/models/blockchain/Insight.js @@ -109,8 +109,6 @@ Insight.prototype._request = function(options, callback) { if (options.method === 'POST') { request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - request.setRequestHeader('Content-length', options.data.length); - request.setRequestHeader('Connection', 'close'); request.send(options.data); } else { request.send(null);