WIP send max fixes
This commit is contained in:
parent
8189d571bf
commit
48d6b78667
4 changed files with 39 additions and 16 deletions
|
|
@ -431,7 +431,7 @@
|
|||
<h4 class="title m0" translate>Fee policy for this transaction</h4>
|
||||
<ul class="no-bullet m0 size-14">
|
||||
<li ng-repeat="fee in (index.network == 'livenet' ? index.feeLevels.livenet : index.feeLevels.testnet)"
|
||||
ng-click="home.currentSendFeeLevel = fee.level" class="line-b p20">
|
||||
ng-click="home.setFee(fee.level)" class="line-b p20">
|
||||
{{index.feeOpts[fee.level]|translate}}
|
||||
<i class="fi-check size-16 right"
|
||||
ng-show="(home.currentSendFeeLevel || index.currentFeeLevel) == fee.level"></i>
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
}
|
||||
$log.debug('Wallet Status:', walletStatus);
|
||||
self.setPendingTxps(walletStatus.pendingTxps);
|
||||
self.setFees();
|
||||
self.setFeesOpts();
|
||||
self.setSpendUnconfirmed();
|
||||
|
||||
// Status Shortcuts
|
||||
|
|
@ -311,17 +311,40 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.spendUnconfirmed = configService.getSync().wallet.spendUnconfirmed;
|
||||
};
|
||||
|
||||
self.setCurrentFeeLevel = function(level) {
|
||||
self.currentFeeLevel = level || configService.getSync().wallet.settings.feeLevel || 'priority';
|
||||
self.setSendMax = function() {
|
||||
|
||||
// Set Send max
|
||||
if (self.currentFeeLevel && self.totalBytesToSendMax) {
|
||||
feeService.getCurrentFeeValue(self.currentFeeLevel, function(err, feePerKb) {
|
||||
|
||||
// KB to send max
|
||||
if (self.totalBytesToSendMax) {
|
||||
var feeToSendMaxSat = parseInt(((self.totalBytesToSendMax * feePerKb ) / 1000.).toFixed(0));
|
||||
self.availableMaxBalance = strip((self.availableBalanceSat - feeToSendMaxSat) * self.satToUnit);
|
||||
self.feeToSendMaxStr = profileService.formatAmount(feeToSendMaxSat) + ' ' + self.unitName;
|
||||
|
||||
console.log('[index.js.595]', self.currentFeeLevel, feePerKb, self.totalBytesToSendMax, feeToSendMaxSat, self.feeToSendMaxStr, "AVAIL", self.availableBalanceSat,self.availableMaxBalance); //TODO
|
||||
|
||||
} else {
|
||||
self.feeToSendMaxStr = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
self.setFees = function() {
|
||||
self.setCurrentFeeLevel = function(level) {
|
||||
self.currentFeeLevel = level || configService.getSync().wallet.settings.feeLevel || 'priority';
|
||||
self.setSendMax();
|
||||
};
|
||||
|
||||
|
||||
self.setFeesOpts = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
if (!fc) return;
|
||||
$timeout(function() {
|
||||
feeService.getFeeLevels(function(levels) {
|
||||
self.feeLevels = levels;
|
||||
self.setCurrentFeeLevel();
|
||||
$rootScope.$apply();
|
||||
});
|
||||
});
|
||||
|
|
@ -550,6 +573,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
var config = configService.getSync().wallet.settings;
|
||||
var COIN = 1e8;
|
||||
|
||||
|
||||
// Address with Balance
|
||||
self.balanceByAddress = balance.byAddress;
|
||||
|
||||
|
|
@ -572,17 +596,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.lockedBalanceBTC = strip(self.lockedBalanceSat / COIN);
|
||||
self.availableBalanceBTC = strip(self.availableBalanceBTC / COIN);
|
||||
|
||||
// KB to send max
|
||||
self.feePerKbSat = config.feeValue || 10000;
|
||||
if (balance.totalKbToSendMax) {
|
||||
var feeToSendMaxSat = balance.totalKbToSendMax * self.feePerKbSat;
|
||||
|
||||
self.availableMaxBalance = strip((self.availableBalanceSat - feeToSendMaxSat) * self.satToUnit);
|
||||
self.feeToSendMaxStr = profileService.formatAmount(feeToSendMaxSat) + ' ' + self.unitName;
|
||||
} else {
|
||||
self.feeToSendMaxStr = null;
|
||||
}
|
||||
|
||||
//STR
|
||||
self.totalBalanceStr = profileService.formatAmount(self.totalBalanceSat) + ' ' + self.unitName;
|
||||
self.lockedBalanceStr = profileService.formatAmount(self.lockedBalanceSat) + ' ' + self.unitName;
|
||||
|
|
@ -591,6 +604,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.alternativeName = config.alternativeName;
|
||||
self.alternativeIsoCode = config.alternativeIsoCode;
|
||||
|
||||
// Other
|
||||
self.totalBytesToSendMax = balance.totalBytesToSendMax;
|
||||
|
||||
self.setCurrentFeeLevel();
|
||||
|
||||
// Check address
|
||||
addressService.isUsed(self.walletId, balance.byAddress, function(err, used) {
|
||||
if (used) {
|
||||
|
|
|
|||
|
|
@ -714,6 +714,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
};
|
||||
};
|
||||
|
||||
this.setFee = function(level) {
|
||||
this.currentSendFeeLevel = level;
|
||||
};
|
||||
|
||||
this.submitForm = function() {
|
||||
var fc = profileService.focusedClient;
|
||||
var unitToSat = this.unitToSatoshi;
|
||||
|
|
@ -748,6 +752,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
feeService.getCurrentFeeValue(self.currentSendFeeLevel, function(err, feePerKb) {
|
||||
if (err) $log.debug(err);
|
||||
console.log('[walletHome.js.757:amount:]',amount, feePerKb); //TODO
|
||||
fc.sendTxProposal({
|
||||
toAddress: address,
|
||||
amount: amount,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ angular.module('copayApp.services').factory('feeService', function($log, profile
|
|||
}
|
||||
else {
|
||||
fee = lodash.find(levels, { level: feeLevel }).feePerKB;
|
||||
$log.debug('Dynamic fee for ' + feeLevel + ': ' + fee);
|
||||
$log.debug('Dynamic fee for:' + feeLevel + ': ' + fee + ' SAT');
|
||||
return cb(null, fee);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue