mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
improve transaction entry sort and unconfirmed tx tooltip
This commit is contained in:
parent
19551671bd
commit
13a576e871
4 changed files with 35 additions and 15 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit f10688279a7a761c734c80c051237c0a4a90928b
|
Subproject commit b4b2534e7a69c272a4d8b089cd88b3502f6d4b39
|
|
@ -373,11 +373,11 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
|
||||||
private String getTooltip(TransactionEntry transactionEntry) {
|
private String getTooltip(TransactionEntry transactionEntry) {
|
||||||
String tooltip = transactionEntry.getBlockTransaction().getHash().toString();
|
String tooltip = transactionEntry.getBlockTransaction().getHash().toString();
|
||||||
if(transactionEntry.getBlockTransaction().getHeight() <= 0) {
|
if(transactionEntry.getBlockTransaction().getHeight() <= 0) {
|
||||||
if(!AppServices.getMempoolHistogram().isEmpty()) {
|
Double feeRate = transactionEntry.getBlockTransaction().getFeeRate();
|
||||||
Set<MempoolRateSize> rateSizes = AppServices.getMempoolHistogram().get(AppServices.getMempoolHistogram().lastKey());
|
Long vSizefromTip = transactionEntry.getVSizeFromTip();
|
||||||
double vSize = transactionEntry.getBlockTransaction().getTransaction().getVirtualSize();
|
if(feeRate != null && vSizefromTip != null) {
|
||||||
double feeRate = transactionEntry.getBlockTransaction().getFee() / vSize;
|
long blocksFromTip = (long)Math.ceil((double)vSizefromTip / Transaction.MAX_BLOCK_SIZE);
|
||||||
long vSizefromTip = rateSizes.stream().filter(rateSize -> rateSize.getFee() > feeRate).mapToLong(MempoolRateSize::getVSize).sum();
|
|
||||||
String amount = vSizefromTip + " vB";
|
String amount = vSizefromTip + " vB";
|
||||||
if(vSizefromTip > 1000 * 1000) {
|
if(vSizefromTip > 1000 * 1000) {
|
||||||
amount = String.format("%.2f", (double)vSizefromTip / (1000 * 1000)) + " MvB";
|
amount = String.format("%.2f", (double)vSizefromTip / (1000 * 1000)) + " MvB";
|
||||||
|
@ -385,7 +385,11 @@ public class EntryCell extends TreeTableCell<Entry, Entry> {
|
||||||
amount = String.format("%.2f", (double)vSizefromTip / 1000) + " kvB";
|
amount = String.format("%.2f", (double)vSizefromTip / 1000) + " kvB";
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip += "\nFee rate: " + String.format("%.2f", feeRate) + " sats/vB (" + amount + " from tip)";
|
tooltip += "\nConfirms in: ±" + blocksFromTip + " block" + (blocksFromTip > 1 ? "s" : "") + " (" + amount + " from tip)";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(feeRate != null) {
|
||||||
|
tooltip += "\nFee rate: " + String.format("%.2f", feeRate) + " sats/vB";
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip += "\nRBF: " + (transactionEntry.getBlockTransaction().getTransaction().isReplaceByFee() ? "Enabled" : "Disabled");
|
tooltip += "\nRBF: " + (transactionEntry.getBlockTransaction().getTransaction().isReplaceByFee() ? "Enabled" : "Disabled");
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.sparrowwallet.sparrow.WalletTabData;
|
||||||
import com.sparrowwallet.sparrow.event.WalletBlockHeightChangedEvent;
|
import com.sparrowwallet.sparrow.event.WalletBlockHeightChangedEvent;
|
||||||
import com.sparrowwallet.sparrow.event.WalletEntryLabelsChangedEvent;
|
import com.sparrowwallet.sparrow.event.WalletEntryLabelsChangedEvent;
|
||||||
import com.sparrowwallet.sparrow.event.WalletTabsClosedEvent;
|
import com.sparrowwallet.sparrow.event.WalletTabsClosedEvent;
|
||||||
|
import com.sparrowwallet.sparrow.net.MempoolRateSize;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
import javafx.beans.property.IntegerPropertyBase;
|
import javafx.beans.property.IntegerPropertyBase;
|
||||||
import javafx.beans.property.LongProperty;
|
import javafx.beans.property.LongProperty;
|
||||||
|
@ -181,9 +182,12 @@ public class TransactionEntry extends Entry implements Comparable<TransactionEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(TransactionEntry other) {
|
public int compareTo(TransactionEntry other) {
|
||||||
int blockOrder = blockTransaction.compareBlockOrder(other.blockTransaction);
|
//This comparison must be identical to that of WalletTransactionsEntry.WalletTransaction
|
||||||
if(blockOrder != 0) {
|
if(blockTransaction.getHeight() != other.blockTransaction.getHeight()) {
|
||||||
return blockOrder;
|
int blockOrder = blockTransaction.getComparisonHeight() - other.blockTransaction.getComparisonHeight();
|
||||||
|
if(blockOrder != 0) {
|
||||||
|
return blockOrder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int valueOrder = Long.compare(other.getValue(), getValue());
|
int valueOrder = Long.compare(other.getValue(), getValue());
|
||||||
|
@ -191,7 +195,7 @@ public class TransactionEntry extends Entry implements Comparable<TransactionEnt
|
||||||
return valueOrder;
|
return valueOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockTransaction.compareTo(other.blockTransaction);
|
return blockTransaction.getHash().compareTo(other.blockTransaction.getHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,6 +248,16 @@ public class TransactionEntry extends Entry implements Comparable<TransactionEnt
|
||||||
return balance;
|
return balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getVSizeFromTip() {
|
||||||
|
if(!AppServices.getMempoolHistogram().isEmpty()) {
|
||||||
|
Set<MempoolRateSize> rateSizes = AppServices.getMempoolHistogram().get(AppServices.getMempoolHistogram().lastKey());
|
||||||
|
double feeRate = blockTransaction.getFeeRate();
|
||||||
|
return rateSizes.stream().filter(rateSize -> rateSize.getFee() > feeRate).mapToLong(MempoolRateSize::getVSize).sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void blockHeightChanged(WalletBlockHeightChangedEvent event) {
|
public void blockHeightChanged(WalletBlockHeightChangedEvent event) {
|
||||||
if(event.getWallet().equals(getWallet())) {
|
if(event.getWallet().equals(getWallet())) {
|
||||||
|
|
|
@ -246,9 +246,11 @@ public class WalletTransactionsEntry extends Entry {
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(WalletTransactionsEntry.WalletTransaction other) {
|
public int compareTo(WalletTransactionsEntry.WalletTransaction other) {
|
||||||
//This comparison must be identical to that of TransactionEntry so we can avoid a resort calculating balances when creating WalletTransactionsEntry
|
//This comparison must be identical to that of TransactionEntry so we can avoid a resort calculating balances when creating WalletTransactionsEntry
|
||||||
int blockOrder = blockTransaction.compareBlockOrder(other.blockTransaction);
|
if(blockTransaction.getHeight() != other.blockTransaction.getHeight()) {
|
||||||
if(blockOrder != 0) {
|
int blockOrder = blockTransaction.getComparisonHeight() - other.blockTransaction.getComparisonHeight();
|
||||||
return blockOrder;
|
if(blockOrder != 0) {
|
||||||
|
return blockOrder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int valueOrder = Long.compare(other.getValue(), getValue());
|
int valueOrder = Long.compare(other.getValue(), getValue());
|
||||||
|
@ -256,7 +258,7 @@ public class WalletTransactionsEntry extends Entry {
|
||||||
return valueOrder;
|
return valueOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockTransaction.compareTo(other.blockTransaction);
|
return blockTransaction.getHash().compareTo(other.blockTransaction.getHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue