Transactions counter in navbar. Moved updateTx from controller to service.
This commit is contained in:
parent
1b545ea444
commit
cb00a5b629
4 changed files with 51 additions and 54 deletions
|
|
@ -82,6 +82,10 @@ angular.module('copay.controllerUtils')
|
|||
root.updateBalance();
|
||||
$rootScope.$digest();
|
||||
});
|
||||
w.on('txProposalsUpdated', function() {
|
||||
console.log('[ txProposalsUpdated ]'); //TODO
|
||||
root.updateTxs();
|
||||
});
|
||||
w.on('openError', root.onErrorDigest);
|
||||
w.on('connect', function(peerID) {
|
||||
if (peerID) {
|
||||
|
|
@ -116,10 +120,46 @@ angular.module('copay.controllerUtils')
|
|||
console.log('New available balance:', balance);
|
||||
$rootScope.availableBalance = balance;
|
||||
$rootScope.loading = false;
|
||||
$rootScope.$digest();
|
||||
if (cb) cb();
|
||||
});
|
||||
};
|
||||
|
||||
root.updateTxs = function() {
|
||||
var bitcore = require('bitcore');
|
||||
var w = $rootScope.wallet;
|
||||
if (!w) return;
|
||||
|
||||
var inT = w.getTxProposals();
|
||||
var txs = [];
|
||||
|
||||
inT.forEach(function(i){
|
||||
var tx = i.builder.build();
|
||||
var outs = [];
|
||||
|
||||
tx.outs.forEach(function(o) {
|
||||
var addr = bitcore.Address.fromScriptPubKey(o.getScript(), config.networkName)[0].toString();
|
||||
if (!w.addressIsOwn(addr, {excludeMain:true})) {
|
||||
outs.push({
|
||||
address: addr,
|
||||
value: bitcore.util.valueToBigInt(o.getValue())/bitcore.util.COIN,
|
||||
});
|
||||
}
|
||||
});
|
||||
// extra fields
|
||||
i.outs = outs;
|
||||
i.fee = i.builder.feeSat/bitcore.util.COIN;
|
||||
i.missingSignatures = tx.countInputMissingSignatures(0);
|
||||
txs.push(i);
|
||||
});
|
||||
$rootScope.txs = txs;
|
||||
console.log('[controllerUtils.js:155]',txs); //TODO
|
||||
$rootScope.txslength = txs.length;
|
||||
w.removeListener('txProposalsUpdated',root.updateTxs)
|
||||
w.once('txProposalsUpdated',root.updateTxs);
|
||||
$rootScope.loading = false;
|
||||
};
|
||||
|
||||
root.setSocketHandlers = function() {
|
||||
// TODO: optimize this?
|
||||
Socket.removeAllListeners();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue