Skip to content

Commit df7b792

Browse files
committed
fix BCH paypro fee levels
1 parent b979bf8 commit df7b792

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/js/controllers/confirm.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
158158
description: data.stateParams.description,
159159
paypro: data.stateParams.paypro,
160160

161-
feeLevel: configFeeLevel,
162161
spendUnconfirmed: walletConfig.spendUnconfirmed,
163162

164163
// Vanity tx info (not in the real tx)
@@ -175,11 +174,11 @@ angular.module('copayApp.controllers').controller('confirmController', function(
175174
if (data.stateParams.requiredFeeRate) {
176175
usingMerchantFee = true;
177176
tx.feeRate = parseInt(data.stateParams.requiredFeeRate);
177+
} else {
178+
tx.feeLevel= (tx.coin && tx.coin == 'bch') ? 'normal ' : configFeeLevel;
178179
}
179180

180181
if (tx.coin && tx.coin == 'bch') {
181-
tx.feeLevel = 'normal';
182-
183182
// Use legacy address
184183
tx.toAddress = new bitcoreCash.Address(tx.toAddress).toString();
185184
};
@@ -296,9 +295,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
296295
return cb();
297296
}
298297

299-
// Hack to get 'urgent' fee levels in case of merchantFees, to compare.
300-
feeService.getFeeRate(wallet.coin, tx.network, usingMerchantFee ? 'urgent' : tx.feeLevel, function(err, feeRate) {
298+
var maxAllowedMerchantFee = {
299+
btc: 'urgent',
300+
bch: 'normal',
301+
};
302+
303+
feeService.getFeeRate(wallet.coin, tx.network, usingMerchantFee ? maxAllowedMerchantFee[wallet.coin] : tx.feeLevel, function(err, feeRate) {
301304
if (err) {
305+
$log.warn(err);
302306
ongoingProcess.set('calculatingFee', false);
303307
return cb(err);
304308
}
@@ -309,8 +313,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
309313
tx.feeLevelName = msg;
310314
} else if (usingMerchantFee) {
311315

312-
$log.info('Using Merchant Fee:' + tx.feeRate + ' vs. Urgent level:' + feeRate);
313-
if (tx.feeRate > feeRate) {
316+
var maxAllowedfee = feeRate * 2;
317+
$log.info('Using Merchant Fee:' + tx.feeRate + ' vs. referent level:' + maxAllowedfee);
318+
if (tx.feeRate > maxAllowedfee) {
314319
ongoingProcess.set('calculatingFee', false);
315320
setNoWallet(gettextCatalog.getString('Merchant fee to high. Payment rejected'), true);
316321
return cb('fee_too_high');
@@ -525,11 +530,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
525530
// If select another wallet
526531
tx.coin = wallet.coin;
527532

528-
if (usingCustomFee) {
533+
if (usingCustomFee || usingMerchantFee) {
529534
} else {
530535
tx.feeLevel = wallet.coin == 'bch' ? 'normal' : configFeeLevel;
531536
}
532-
533537
setButtonText(wallet.credentials.m > 1, !!tx.paypro);
534538

535539
if (tx.paypro)

0 commit comments

Comments
 (0)