Fix fee levels for btc and bch
This commit is contained in:
parent
491aef0acf
commit
70fa50177c
12 changed files with 20 additions and 23 deletions
|
|
@ -70,7 +70,7 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
|
||||
|
||||
|
||||
feeService.getFeeLevels(function(err, levels){
|
||||
feeService.getFeeLevels($scope.wallet.coin, function(err, levels){
|
||||
walletService.getLowUtxos($scope.wallet, levels, function(err, resp) {
|
||||
if (err) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
// no min amount? (sendMax) => look for no empty wallets
|
||||
minAmount = minAmount || 1;
|
||||
|
||||
console.log('[confirm.js.76]', network, coin); //TODO
|
||||
$scope.wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: network,
|
||||
|
|
@ -256,7 +255,7 @@ console.log('[confirm.js.76]', network, coin); //TODO
|
|||
// End of quick refresh, before wallet is selected.
|
||||
if (!wallet) return cb();
|
||||
|
||||
feeService.getFeeRate(tx.network, tx.feeLevel, function(err, feeRate) {
|
||||
feeService.getFeeRate(wallet.coin, tx.network, tx.feeLevel, function(err, feeRate) {
|
||||
if (err) return cb(err);
|
||||
|
||||
if (!usingCustomFee) tx.feeRate = feeRate;
|
||||
|
|
@ -573,6 +572,7 @@ console.log('[confirm.js.76]', network, coin); //TODO
|
|||
scope.network = tx.network;
|
||||
scope.feeLevel = tx.feeLevel;
|
||||
scope.noSave = true;
|
||||
scope.coin = wallet.coin;
|
||||
|
||||
if (usingCustomFee) {
|
||||
scope.customFeePerKB = tx.feeRate;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ angular.module('copayApp.controllers').controller('feeLevelsController', functio
|
|||
|
||||
$scope.feeOpts = feeService.feeOpts;
|
||||
$scope.loadingFee = true;
|
||||
feeService.getFeeLevels(function(err, levels) {
|
||||
feeService.getFeeLevels($scope.coin, function(err, levels) {
|
||||
$scope.loadingFee = false;
|
||||
if (err || lodash.isEmpty(levels)) {
|
||||
showErrorAndClose(null, err);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
|
|||
$scope.wallet.buildTxFromPrivateKey($scope.privateKey, destinationAddress, null, function(err, testTx) {
|
||||
if (err) return cb(err);
|
||||
var rawTxLength = testTx.serialize().length;
|
||||
feeService.getCurrentFeeRate('livenet', function(err, feePerKb) {
|
||||
feeService.getCurrentFeeRate('btc', 'livenet', function(err, feePerKb) {
|
||||
var opts = {};
|
||||
opts.fee = Math.round((feePerKb * rawTxLength) / 2000);
|
||||
$scope.wallet.buildTxFromPrivateKey($scope.privateKey, destinationAddress, opts, function(err, tx) {
|
||||
|
|
|
|||
|
|
@ -32,11 +32,12 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu
|
|||
});
|
||||
|
||||
$scope.init = function() {
|
||||
var coin = 'btc'; // TODO: only BTC in preferences
|
||||
$scope.network = $scope.network || 'livenet';
|
||||
$scope.feeOpts = feeService.feeOpts;
|
||||
$scope.currentFeeLevel = $scope.feeLevel || feeService.getCurrentFeeLevel();
|
||||
$scope.loadingFee = true;
|
||||
feeService.getFeeLevels(function(err, levels) {
|
||||
feeService.getFeeLevels(coin, function(err, levels) {
|
||||
$scope.loadingFee = false;
|
||||
if (err) {
|
||||
//Error is already formatted
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
|||
$scope.$digest();
|
||||
});
|
||||
|
||||
feeService.getFeeLevels(function(err, levels) {
|
||||
feeService.getFeeLevels($scope.wallet.coin, function(err, levels) {
|
||||
if (err) return;
|
||||
walletService.getLowAmount($scope.wallet, levels, function(err, amount) {
|
||||
if (err) return;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
var analyzeUtxos = function() {
|
||||
if (analyzeUtxosDone) return;
|
||||
|
||||
feeService.getFeeLevels(function(err, levels) {
|
||||
feeService.getFeeLevels($scope.wallet.coin, function(err, levels) {
|
||||
if (err) return;
|
||||
walletService.getLowUtxos($scope.wallet, levels, function(err, resp) {
|
||||
if (err || !resp) return;
|
||||
|
|
@ -169,7 +169,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
});
|
||||
};
|
||||
|
||||
feeService.getFeeLevels(function(err, levels) {
|
||||
feeService.getFeeLevels($scope.wallet.coin, function(err, levels) {
|
||||
walletService.getTxHistory($scope.wallet, {
|
||||
progressFn: progressFn,
|
||||
feeLevels: levels,
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
var _getNetAmount = function(amount, cb) {
|
||||
// Fee Normal for a single transaction (450 bytes)
|
||||
var txNormalFeeKB = 450 / 1000;
|
||||
feeService.getFeeRate(null, 'normal', function(err, feePerKb) {
|
||||
feeService.getFeeRate('btc', 'livenet', 'normal', function(err, feePerKb) {
|
||||
if (err) return cb(err);
|
||||
var feeBTC = (feePerKb * txNormalFeeKB / 100000000).toFixed(8);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ angular.module('copayApp.services').factory('feeService', function($log, $timeou
|
|||
};
|
||||
|
||||
|
||||
root.getFeeRate = function(network, feeLevel, cb) {
|
||||
root.getFeeRate = function(coin, network, feeLevel, cb) {
|
||||
|
||||
if (feeLevel == 'custom') return cb();
|
||||
|
||||
network = network || 'livenet';
|
||||
|
||||
root.getFeeLevels(function(err, levels, fromCache) {
|
||||
root.getFeeLevels(coin, function(err, levels, fromCache) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var feeLevelRate = lodash.find(levels[network], {
|
||||
|
|
@ -53,11 +53,12 @@ angular.module('copayApp.services').factory('feeService', function($log, $timeou
|
|||
});
|
||||
};
|
||||
|
||||
root.getCurrentFeeRate = function(network, cb) {
|
||||
return root.getFeeRate(network, root.getCurrentFeeLevel(), cb);
|
||||
root.getCurrentFeeRate = function(coin, network, cb) {
|
||||
return root.getFeeRate(coin, network, root.getCurrentFeeLevel(), cb);
|
||||
};
|
||||
|
||||
root.getFeeLevels = function(cb) {
|
||||
root.getFeeLevels = function(coin, cb) {
|
||||
coin = coin || 'btc';
|
||||
|
||||
if (cache.updateTs > Date.now() - CACHE_TIME_TS * 1000) {
|
||||
return cb(null, cache.data, true);
|
||||
|
|
@ -65,7 +66,7 @@ angular.module('copayApp.services').factory('feeService', function($log, $timeou
|
|||
|
||||
var walletClient = bwcService.getClient();
|
||||
|
||||
walletClient.getFeeLevels('btc', 'livenet', function(errLivenet, levelsLivenet) {
|
||||
walletClient.getFeeLevels(coin, 'livenet', function(errLivenet, levelsLivenet) {
|
||||
walletClient.getFeeLevels('btc', 'testnet', function(errTestnet, levelsTestnet) {
|
||||
if (errLivenet || errTestnet) {
|
||||
return cb(gettextCatalog.getString('Could not get dynamic fee'));
|
||||
|
|
|
|||
|
|
@ -89,10 +89,7 @@ angular.module('copayApp.services')
|
|||
wallet.copayerId = wallet.credentials.copayerId;
|
||||
wallet.m = wallet.credentials.m;
|
||||
wallet.n = wallet.credentials.n;
|
||||
wallet.coin = wallet.credentials.coin ? wallet.credentials.coin : 'btc';
|
||||
|
||||
// TODO
|
||||
if (wallet.id == 'bf338d5b-6b2e-4118-adb0-6208c2d22a81') wallet.credentials.coin = wallet.coin = 'bch';
|
||||
wallet.coin = wallet.credentials.coin;
|
||||
|
||||
root.updateWalletSettings(wallet);
|
||||
root.wallet[walletId] = wallet;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ angular.module('copayApp.services').service('sendMaxService', function(feeServic
|
|||
*
|
||||
*/
|
||||
this.getInfo = function(wallet, cb) {
|
||||
feeService.getCurrentFeeRate(wallet.credentials.network, function(err, feePerKb) {
|
||||
feeService.getCurrentFeeRate(wallet.coin, wallet.credentials.network, function(err, feePerKb) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var config = configService.getSync().wallet;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@
|
|||
</a>
|
||||
<div class="item item-icon-right" ng-if="wallet" ng-click="chooseFeeLevel(tx, wallet)">
|
||||
<span class="label">{{'Fee:' | translate}} {{tx.feeLevelName | translate}}</span>
|
||||
<span ng-if="wallet.coin == 'btc'">
|
||||
<span class="m10l">{{tx.txp[wallet.id].feeStr || '...'}}</span>
|
||||
<span class="item-note m10l">
|
||||
<span>{{tx.txp[wallet.id].alternativeFeeStr || '...'}}
|
||||
|
|
@ -90,7 +89,6 @@
|
|||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<i ng-if="wallet.coin == 'btc'" class="icon bp-arrow-right"></i>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue