mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-01-26 02:11:10 +00:00
only show cpfp rate if child fee increases effective fee rate
This commit is contained in:
parent
25f441a6a8
commit
947013e088
1 changed files with 12 additions and 7 deletions
|
@ -877,18 +877,23 @@ public class SendController extends WalletFormController implements Initializabl
|
|||
walletTransaction.getSelectedUtxos().keySet().stream().filter(ref -> ref.getHeight() <= 0)
|
||||
.map(ref -> getWalletForm().getWallet().getWalletTransaction(ref.getHash()))
|
||||
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if(!unconfirmedUtxoTxs.isEmpty()) {
|
||||
if(!unconfirmedUtxoTxs.isEmpty() && unconfirmedUtxoTxs.stream().allMatch(blkTx -> blkTx.getFee() != null && blkTx.getFee() > 0)) {
|
||||
long utxoTxFee = unconfirmedUtxoTxs.stream().mapToLong(BlockTransaction::getFee).sum();
|
||||
double utxoTxSize = unconfirmedUtxoTxs.stream().mapToDouble(blkTx -> blkTx.getTransaction().getVirtualSize()).sum();
|
||||
long thisFee = walletTransaction.getFee();
|
||||
double thisSize = walletTransaction.getTransaction().getVirtualSize();
|
||||
double thisRate = thisFee / thisSize;
|
||||
double effectiveRate = (utxoTxFee + thisFee) / (utxoTxSize + thisSize);
|
||||
UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat();
|
||||
String strEffectiveRate = format.getCurrencyFormat().format(effectiveRate);
|
||||
Tooltip tooltip = new Tooltip("CPFP (Child Pays For Parent)\n" + strEffectiveRate + " sats/vB effective rate");
|
||||
cpfpFeeRate.setTooltip(tooltip);
|
||||
cpfpFeeRate.setVisible(true);
|
||||
cpfpFeeRate.setText(strEffectiveRate + " sats/vB (CPFP)");
|
||||
if(thisRate > effectiveRate) {
|
||||
UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat();
|
||||
String strEffectiveRate = format.getCurrencyFormat().format(effectiveRate);
|
||||
Tooltip tooltip = new Tooltip("CPFP (Child Pays For Parent)\n" + strEffectiveRate + " sats/vB effective rate");
|
||||
cpfpFeeRate.setTooltip(tooltip);
|
||||
cpfpFeeRate.setVisible(true);
|
||||
cpfpFeeRate.setText(strEffectiveRate + " sats/vB (CPFP)");
|
||||
} else {
|
||||
cpfpFeeRate.setVisible(false);
|
||||
}
|
||||
} else {
|
||||
cpfpFeeRate.setVisible(false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue