updated code to work with bitpay bch payments
This commit is contained in:
parent
8d4bf711eb
commit
381a4e9f78
5 changed files with 51 additions and 12 deletions
|
|
@ -23,7 +23,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var isWindowsPhoneApp = platformInfo.isCordova && platformInfo.isWP;
|
||||
|
||||
//custom fee flag
|
||||
var usingCustomFee = null;
|
||||
var usingCustomFee = false;
|
||||
var usingMerchantFee = false;
|
||||
|
||||
function refresh() {
|
||||
$timeout(function() {
|
||||
|
|
@ -177,7 +178,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
txp: {},
|
||||
};
|
||||
|
||||
if (tx.coin && tx.coin == 'bch') tx.feeLevel = 'normal';
|
||||
if (data.stateParams.requiredFeeRate) {
|
||||
usingMerchantFee = true;
|
||||
tx.feeRate = parseInt(data.stateParams.requiredFeeRate);
|
||||
}
|
||||
|
||||
if (tx.coin && tx.coin == 'bch') {
|
||||
tx.feeLevel = 'normal';
|
||||
}
|
||||
|
||||
// Other Scope vars
|
||||
$scope.isCordova = isCordova;
|
||||
|
|
@ -240,7 +248,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
txp.inputs = tx.sendMaxInfo.inputs;
|
||||
txp.fee = tx.sendMaxInfo.fee;
|
||||
} else {
|
||||
if (usingCustomFee) {
|
||||
if (usingCustomFee || usingMerchantFee) {
|
||||
txp.feePerKb = tx.feeRate;
|
||||
} else txp.feeLevel = tx.feeLevel;
|
||||
}
|
||||
|
|
@ -291,14 +299,29 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
return cb();
|
||||
}
|
||||
|
||||
feeService.getFeeRate(wallet.coin, tx.network, tx.feeLevel, function(err, feeRate) {
|
||||
feeService.getFeeRate(wallet.coin, tx.network, usingMerchantFee ? 'urgent' : tx.feeLevel, function(err, feeRate) {
|
||||
if (err) {
|
||||
ongoingProcess.set('calculatingFee', false);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (!usingCustomFee) tx.feeRate = feeRate;
|
||||
tx.feeLevelName = feeService.feeOpts[tx.feeLevel];
|
||||
var msg;
|
||||
if (usingCustomFee) {
|
||||
msg = gettextCatalog.getString('Custom');
|
||||
tx.feeLevelName = msg;
|
||||
} else if (usingMerchantFee) {
|
||||
$log.info('Using Merchant Fee:' + tx.feeRate + ' vs. Urgent level:' + feeRate);
|
||||
if (tx.feeRate > feeRate) {
|
||||
ongoingProcess.set('calculatingFee', false);
|
||||
setNoWallet(gettextCatalog.getString('Merchant fee to high. Payment rejected'), true);
|
||||
return cb('fee_too_high');
|
||||
}
|
||||
msg = gettextCatalog.getString('Suggested by Merchant');
|
||||
tx.feeLevelName = msg;
|
||||
} else {
|
||||
tx.feeLevelName = feeService.feeOpts[tx.feeLevel];
|
||||
tx.feeRate = feeRate;
|
||||
}
|
||||
|
||||
getSendMaxInfo(lodash.clone(tx), wallet, function(err, sendMaxInfo) {
|
||||
if (err) {
|
||||
|
|
@ -337,7 +360,12 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
getTxp(lodash.clone(tx), wallet, opts.dryRun, function(err, txp) {
|
||||
ongoingProcess.set('calculatingFee', false);
|
||||
if (err) {
|
||||
return cb(err);
|
||||
if (err.message == 'Insufficient funds') {
|
||||
setNoWallet(gettextCatalog.getString('Insufficient funds'));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'));
|
||||
return cb('no_funds');
|
||||
} else
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
txp.feeStr = txFormatService.formatAmountStr(wallet.coin, txp.fee);
|
||||
|
|
@ -487,8 +515,11 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
// If select another wallet
|
||||
tx.coin = wallet.coin;
|
||||
tx.feeLevel = wallet.coin == 'bch' ? 'normal' : configFeeLevel;
|
||||
usingCustomFee = null;
|
||||
|
||||
if (usingCustomFee) {
|
||||
} else {
|
||||
tx.feeLevel = wallet.coin == 'bch' ? 'normal' : configFeeLevel;
|
||||
}
|
||||
|
||||
setButtonText(wallet.credentials.m > 1, !!tx.paypro);
|
||||
|
||||
|
|
@ -637,6 +668,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.chooseFeeLevel = function(tx, wallet) {
|
||||
|
||||
if (wallet.coin == 'bch') return;
|
||||
if (usingMerchantFee) return;
|
||||
|
||||
var scope = $rootScope.$new(true);
|
||||
scope.network = tx.network;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue