diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index ff0f91fa..76e9b2a6 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -112,7 +112,7 @@ public class AppServices { private static Map targetBlockFeeRates; - private static final Map> mempoolHistogram = new TreeMap<>(); + private static final TreeMap> mempoolHistogram = new TreeMap<>(); private static Double minimumRelayFeeRate; @@ -604,7 +604,7 @@ public class AppServices { return targetBlockFeeRates; } - public static Map> getMempoolHistogram() { + public static TreeMap> getMempoolHistogram() { return mempoolHistogram; } diff --git a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java index 61c7615e..3281f75d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java @@ -12,6 +12,7 @@ import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.EventManager; import com.sparrowwallet.sparrow.event.*; import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; +import com.sparrowwallet.sparrow.net.MempoolRateSize; import com.sparrowwallet.sparrow.wallet.*; import javafx.application.Platform; import javafx.geometry.Pos; @@ -69,9 +70,15 @@ public class EntryCell extends TreeTableCell { } Tooltip tooltip = new Tooltip(); - tooltip.setText(transactionEntry.getBlockTransaction().getHash().toString()); + tooltip.setText(getTooltip(transactionEntry)); setTooltip(tooltip); + if(transactionEntry.getBlockTransaction().getHeight() <= 0) { + tooltip.setOnShowing(event -> { + tooltip.setText(getTooltip(transactionEntry)); + }); + } + HBox actionBox = new HBox(); Button viewTransactionButton = new Button(""); viewTransactionButton.setGraphic(getViewTransactionGlyph()); @@ -326,6 +333,30 @@ public class EntryCell extends TreeTableCell { EventManager.get().post(new WalletUtxoStatusChangedEvent(hashIndexEntry.getWallet(), utxos)); } + private String getTooltip(TransactionEntry transactionEntry) { + String tooltip = transactionEntry.getBlockTransaction().getHash().toString(); + if(transactionEntry.getBlockTransaction().getHeight() <= 0) { + if(!AppServices.getMempoolHistogram().isEmpty()) { + Set rateSizes = AppServices.getMempoolHistogram().get(AppServices.getMempoolHistogram().lastKey()); + double vSize = transactionEntry.getBlockTransaction().getTransaction().getVirtualSize(); + double feeRate = transactionEntry.getBlockTransaction().getFee() / vSize; + long vSizefromTip = rateSizes.stream().filter(rateSize -> rateSize.getFee() > feeRate).mapToLong(MempoolRateSize::getVSize).sum(); + String amount = vSizefromTip + " vB"; + if(vSizefromTip > 1000 * 1000) { + amount = String.format("%.2f", (double)vSizefromTip / (1000 * 1000)) + " MvB"; + } else if(vSizefromTip > 1000) { + amount = String.format("%.2f", (double)vSizefromTip / 1000) + " kvB"; + } + + tooltip += "\nFee rate: " + String.format("%.2f", feeRate) + " sats/vB (" + amount + " from tip)"; + } + + tooltip += "\nRBF: " + (transactionEntry.getBlockTransaction().getTransaction().isReplaceByFee() ? "Enabled" : "Disabled"); + } + + return tooltip; + } + private static Glyph getViewTransactionGlyph() { Glyph searchGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SEARCH); searchGlyph.setFontSize(12);