Skip to content

Commit 6fc52fd

Browse files
committed
display effective fee rate next to transaction fee rate when constructing a cpfp tx
1 parent 1d2081d commit 6fc52fd

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ public Double fromString(String string) {
382382
});
383383

384384
walletTransactionProperty.addListener((observable, oldValue, walletTransaction) -> {
385+
setEffectiveFeeRate(walletTransaction);
385386
if(walletTransaction != null) {
386387
setPayments(walletTransaction.getPayments().stream().filter(payment -> payment.getType() != Payment.Type.FAKE_MIX).collect(Collectors.toList()));
387388

@@ -395,7 +396,6 @@ public Double fromString(String string) {
395396
}
396397

397398
setFeeRate(feeRate);
398-
setEffectiveFeeRate(walletTransaction);
399399
}
400400

401401
transactionDiagram.update(walletTransaction);
@@ -881,22 +881,27 @@ public boolean isInsufficientFeeRate() {
881881

882882
private void setFeeRate(Double feeRateAmt) {
883883
UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat();
884-
feeRate.setText(format.getCurrencyFormat().format(feeRateAmt) + " sats/vB");
884+
feeRate.setText(format.getCurrencyFormat().format(feeRateAmt) + (cpfpFeeRate.isVisible() ? "" : " sats/vB"));
885885
setFeeRatePriority(feeRateAmt);
886886
}
887887

888888
private void setEffectiveFeeRate(WalletTransaction walletTransaction) {
889-
List<BlockTransaction> unconfirmedUtxoTxs = walletTransaction.getSelectedUtxos().keySet().stream().filter(ref -> ref.getHeight() <= 0)
890-
.map(ref -> getWalletForm().getWallet().getWalletTransaction(ref.getHash())).filter(Objects::nonNull).distinct().collect(Collectors.toList());
889+
List<BlockTransaction> unconfirmedUtxoTxs = walletTransaction == null ? Collections.emptyList() :
890+
walletTransaction.getSelectedUtxos().keySet().stream().filter(ref -> ref.getHeight() <= 0)
891+
.map(ref -> getWalletForm().getWallet().getWalletTransaction(ref.getHash()))
892+
.filter(Objects::nonNull).distinct().collect(Collectors.toList());
891893
if(!unconfirmedUtxoTxs.isEmpty()) {
892894
long utxoTxFee = unconfirmedUtxoTxs.stream().mapToLong(BlockTransaction::getFee).sum();
893895
double utxoTxSize = unconfirmedUtxoTxs.stream().mapToDouble(blkTx -> blkTx.getTransaction().getVirtualSize()).sum();
894896
long thisFee = walletTransaction.getFee();
895897
double thisSize = walletTransaction.getTransaction().getVirtualSize();
896898
double effectiveRate = (utxoTxFee + thisFee) / (utxoTxSize + thisSize);
897-
Tooltip tooltip = new Tooltip("Child Pays For Parent\n" + String.format("%.2f", effectiveRate) + " sats/vB effective rate");
899+
UnitFormat format = Config.get().getUnitFormat() == null ? UnitFormat.DOT : Config.get().getUnitFormat();
900+
String strEffectiveRate = format.getCurrencyFormat().format(effectiveRate);
901+
Tooltip tooltip = new Tooltip("CPFP (Child Pays For Parent)\n" + strEffectiveRate + " sats/vB effective rate");
898902
cpfpFeeRate.setTooltip(tooltip);
899903
cpfpFeeRate.setVisible(true);
904+
cpfpFeeRate.setText(strEffectiveRate + " sats/vB (CPFP)");
900905
} else {
901906
cpfpFeeRate.setVisible(false);
902907
}
@@ -1548,6 +1553,7 @@ public void bitcoinUnitChanged(BitcoinUnitChangedEvent event) {
15481553

15491554
@Subscribe
15501555
public void unitFormatChanged(UnitFormatChangedEvent event) {
1556+
setEffectiveFeeRate(getWalletTransaction());
15511557
setFeeRate(getFeeRate());
15521558
if(fee.getTextFormatter() instanceof CoinTextFormatter coinTextFormatter && coinTextFormatter.getUnitFormat() != event.getUnitFormat()) {
15531559
Long value = getFeeValueSats(coinTextFormatter.getUnitFormat(), feeAmountUnit.getSelectionModel().getSelectedItem());

src/main/resources/com/sparrowwallet/sparrow/wallet/send.fxml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="12" icon="SIGN_OUT_ALT" />
9999
</graphic>
100100
<padding>
101-
<Insets left="10"/>
101+
<Insets left="4"/>
102102
</padding>
103103
</Label>
104104
<Region HBox.hgrow="ALWAYS" />

0 commit comments

Comments
 (0)