fix subcribe
This commit is contained in:
parent
87facad839
commit
4c61c74706
4 changed files with 20 additions and 15 deletions
|
|
@ -71,9 +71,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$scope.loadTxs = function() {
|
$scope.loadTxs = function() {
|
||||||
controllerUtils.updateTxs();
|
controllerUtils.updateTxs();
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
|
|
@ -120,6 +120,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
if (msg.match('BIG'))
|
if (msg.match('BIG'))
|
||||||
msg = 'The transaction have too many inputs. Try creating many transactions for smaller amounts.'
|
msg = 'The transaction have too many inputs. Try creating many transactions for smaller amounts.'
|
||||||
|
|
||||||
|
if (msg.match('totalNeededAmount'))
|
||||||
|
msg = 'Not enough funds.'
|
||||||
|
|
||||||
var message = 'The transaction' + (w.isShared() ? ' proposal' : '') + ' could not be created: ' + msg;
|
var message = 'The transaction' + (w.isShared() ? ' proposal' : '') + ' could not be created: ' + msg;
|
||||||
$scope.error = message;
|
$scope.error = message;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
|
|
@ -400,17 +403,8 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getAvailableAmount = function() {
|
$scope.setTopAmount = function() {
|
||||||
if (!$rootScope.safeUnspentCount) return null;
|
$scope.amount = $rootScope.topAmount;
|
||||||
|
|
||||||
var estimatedFee = copay.Wallet.estimatedFee($rootScope.safeUnspentCount);
|
|
||||||
var amount = ((($rootScope.availableBalance * w.settings.unitToSatoshi).toFixed(0) - estimatedFee) / w.settings.unitToSatoshi);
|
|
||||||
|
|
||||||
return amount > 0 ? amount : 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.topAmount = function(form) {
|
|
||||||
$scope.amount = $scope.getAvailableAmount();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -449,6 +443,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
$scope.loadTxs();
|
$scope.loadTxs();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$scope.error = undefined;
|
||||||
|
|
||||||
var p = w.txProposals.getTxProposal(ntxid);
|
var p = w.txProposals.getTxProposal(ntxid);
|
||||||
if (p.builder.isFullySigned()) {
|
if (p.builder.isFullySigned()) {
|
||||||
|
|
|
||||||
|
|
@ -812,6 +812,7 @@ Wallet.prototype._lockIncomming = function() {
|
||||||
Wallet.prototype._setBlockchainListeners = function() {
|
Wallet.prototype._setBlockchainListeners = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.blockchain.removeAllListeners();
|
self.blockchain.removeAllListeners();
|
||||||
|
self.subscribeToAddresses();
|
||||||
|
|
||||||
log.debug('Setting Blockchain listeners for', this.getName());
|
log.debug('Setting Blockchain listeners for', this.getName());
|
||||||
self.blockchain.on('reconnect', function(attempts) {
|
self.blockchain.on('reconnect', function(attempts) {
|
||||||
|
|
@ -2179,6 +2180,7 @@ Wallet.prototype.getAddressesStr = function(opts) {
|
||||||
|
|
||||||
Wallet.prototype.subscribeToAddresses = function() {
|
Wallet.prototype.subscribeToAddresses = function() {
|
||||||
var addrInfo = this.publicKeyRing.getAddressesInfo();
|
var addrInfo = this.publicKeyRing.getAddressesInfo();
|
||||||
|
console.log('[Wallet.js.2181:addrInfo:]',addrInfo); //TODO
|
||||||
this.blockchain.subscribe(_.pluck(addrInfo, 'addressStr'));
|
this.blockchain.subscribe(_.pluck(addrInfo, 'addressStr'));
|
||||||
log.debug('Subscribed to ' + addrInfo.length + ' addresses'); //TODO
|
log.debug('Subscribed to ' + addrInfo.length + ' addresses'); //TODO
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,12 @@ angular.module('copayApp.services')
|
||||||
r.lockedBalance = (balanceSat - safeBalanceSat) * satToUnit;
|
r.lockedBalance = (balanceSat - safeBalanceSat) * satToUnit;
|
||||||
r.lockedBalanceBTC = (balanceSat - safeBalanceSat) / COIN;
|
r.lockedBalanceBTC = (balanceSat - safeBalanceSat) / COIN;
|
||||||
|
|
||||||
|
|
||||||
|
if (r.safeUnspentCount){
|
||||||
|
var estimatedFee = copay.Wallet.estimatedFee(r.safeUnspentCount);
|
||||||
|
r.topAmount = (((r.availableBalance * w.settings.unitToSatoshi).toFixed(0) - estimatedFee) / w.settings.unitToSatoshi);
|
||||||
|
}
|
||||||
|
|
||||||
var balanceByAddr = {};
|
var balanceByAddr = {};
|
||||||
for (var ii in balanceByAddrSat) {
|
for (var ii in balanceByAddrSat) {
|
||||||
balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit;
|
balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit;
|
||||||
|
|
@ -279,6 +285,8 @@ angular.module('copayApp.services')
|
||||||
r.balanceByAddr = balanceByAddr;
|
r.balanceByAddr = balanceByAddr;
|
||||||
root.updateAddressList();
|
root.updateAddressList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (rateService.isAvailable()) {
|
if (rateService.isAvailable()) {
|
||||||
r.totalBalanceAlternative = rateService.toFiat(balanceSat, w.settings.alternativeIsoCode);
|
r.totalBalanceAlternative = rateService.toFiat(balanceSat, w.settings.alternativeIsoCode);
|
||||||
r.alternativeIsoCode = w.settings.alternativeIsoCode;
|
r.alternativeIsoCode = w.settings.alternativeIsoCode;
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,9 @@
|
||||||
<small class="icon-input" ng-show="sendForm.amount.$invalid &&
|
<small class="icon-input" ng-show="sendForm.amount.$invalid &&
|
||||||
!sendForm.amount.$pristine && !notValidAmount"><i class="fi-x"></i></small>
|
!sendForm.amount.$pristine && !notValidAmount"><i class="fi-x"></i></small>
|
||||||
<a class="small input-note" title="{{'Send all funds'|translate}}"
|
<a class="small input-note" title="{{'Send all funds'|translate}}"
|
||||||
ng-show="availableBalance && (!$root.merchant || +$root.merchant.total === 0)"
|
ng-show="topAmount && (!$root.merchant || +$root.merchant.total === 0)"
|
||||||
ng-click="topAmount(sendForm)">
|
ng-click="setTopAmount(sendForm)">
|
||||||
<span translate>Use all funds</span> ({{availableBalance}} {{$root.wallet.settings.unitName}})
|
<span translate>Use all funds</span> {{$root.wallet.settings.unitName}}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-3 columns">
|
<div class="small-3 columns">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue