Merge pull request #5643 from jmacxx/prevent_negative_mining_display

Prevent negative suggested mining fee when burning BSQ for fees
This commit is contained in:
sqrrm 2021-08-06 12:25:11 +02:00 committed by GitHub
commit 374e76a4fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -611,10 +611,14 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
}
public Coin getTxFee() {
if (isCurrencyForMakerFeeBtc())
if (isCurrencyForMakerFeeBtc()) {
return txFeeFromFeeService;
else
return txFeeFromFeeService.subtract(getMakerFee());
} else {
// when BSQ is burnt to pay the Bisq maker fee, it has the benefit of those sats also going to the miners.
// so that reduces the explicit mining fee for the maker transaction
Coin makerFee = getMakerFee() != null ? getMakerFee() : Coin.ZERO;
return txFeeFromFeeService.isGreaterThan(makerFee) ? txFeeFromFeeService.subtract(makerFee) : Coin.ZERO;
}
}
void swapTradeToSavings() {

View File

@ -621,10 +621,14 @@ class TakeOfferDataModel extends OfferDataModel {
public Coin getTotalTxFee() {
Coin totalTxFees = txFeeFromFeeService.add(getTxFeeForDepositTx()).add(getTxFeeForPayoutTx());
if (isCurrencyForTakerFeeBtc())
if (isCurrencyForTakerFeeBtc()) {
return totalTxFees;
else
return totalTxFees.subtract(getTakerFee() != null ? getTakerFee() : Coin.ZERO);
} else {
// when BSQ is burnt to pay the Bisq taker fee, it has the benefit of those sats also going to the miners.
// so that reduces the explicit mining fee for the taker transaction
Coin takerFee = getTakerFee() != null ? getTakerFee() : Coin.ZERO;
return totalTxFees.subtract(Coin.valueOf(Math.min(takerFee.longValue(), txFeeFromFeeService.longValue())));
}
}
@NotNull