2014-03-26 09:18:42 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2014-03-28 14:08:14 -04:00
|
|
|
angular.module('copay.transactions').controller('TransactionsController',
|
2014-04-17 13:25:36 -03:00
|
|
|
function($scope, $rootScope, $location, Socket, controllerUtils) {
|
2014-03-26 09:18:42 -03:00
|
|
|
$scope.title = 'Transactions';
|
2014-03-26 17:56:11 -03:00
|
|
|
|
2014-03-26 18:07:28 -03:00
|
|
|
$scope.oneAtATime = true;
|
|
|
|
|
|
2014-04-17 18:06:09 -03:00
|
|
|
var _updateTxs = function() {
|
2014-04-18 11:19:39 -03:00
|
|
|
var w =$rootScope.wallet;
|
|
|
|
|
var inT = w.getTxProposals();
|
|
|
|
|
var ts = [];
|
|
|
|
|
|
2014-04-17 18:06:09 -03:00
|
|
|
inT.forEach(function(i){
|
2014-04-18 11:19:39 -03:00
|
|
|
var b = i.txp.builder;
|
|
|
|
|
var tx = b.build();
|
2014-04-17 18:06:09 -03:00
|
|
|
var one = {
|
|
|
|
|
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();
|
2014-04-18 11:19:39 -03:00
|
|
|
if (!w.addressIsOwn(aStr))
|
2014-04-18 11:33:49 -03:00
|
|
|
outs.push({
|
|
|
|
|
address: aStr,
|
|
|
|
|
value: bitcore.util.valueToBigInt(o.getValue())/bitcore.util.COIN,
|
|
|
|
|
});
|
2014-04-17 18:06:09 -03:00
|
|
|
});
|
|
|
|
|
one.outs = outs;
|
|
|
|
|
ts.push(one);
|
|
|
|
|
});
|
|
|
|
|
$scope.txs = ts;
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-18 15:22:02 -03:00
|
|
|
_updateTxs();
|
|
|
|
|
var socket = Socket($scope);
|
|
|
|
|
socket.on('connect', controllerUtils.handleTransactionByAddress($scope));
|
2014-04-16 17:50:10 -03:00
|
|
|
|
|
|
|
|
$scope.sign = function (ntxid) {
|
|
|
|
|
var w = $rootScope.wallet;
|
|
|
|
|
var ret = w.sign(ntxid);
|
2014-04-17 18:06:09 -03:00
|
|
|
$rootScope.flashMessage = {type:'success', message: 'Transactions SEND! : ' + ret};
|
|
|
|
|
_updateTxs();
|
2014-04-16 17:50:10 -03:00
|
|
|
};
|
2014-03-26 09:18:42 -03:00
|
|
|
});
|