diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/MempoolEntry.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/MempoolEntry.java index 27f42836..a62980ab 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/MempoolEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/MempoolEntry.java @@ -10,7 +10,7 @@ public record MempoolEntry(int vsize, int ancestorsize, boolean bip125_replaceab } public TxEntry getTxEntry(String txid) { - return new TxEntry(hasUnconfirmedParents() ? -1 : 0, 0, txid); + return new TxEntry(hasUnconfirmedParents() ? -1 : 0, 0, txid, fees().base()); } public VsizeFeerate getVsizeFeerate() { diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/Store.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/Store.java index 3f87d0b5..765a003a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/Store.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/Store.java @@ -35,7 +35,7 @@ public class Store { mempoolEntries.put(txid, null); } entries.removeIf(txe -> txe.height > 0 && txe.tx_hash.equals(listTransaction.txid())); - txEntry = new TxEntry(0, 0, listTransaction.txid()); + txEntry = new TxEntry(0, 0, listTransaction.txid(), listTransaction.fee()); } else { mempoolEntries.remove(txid); entries.removeIf(txe -> txe.height != listTransaction.blockheight() && txe.tx_hash.equals(listTransaction.txid())); diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/TxEntry.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/TxEntry.java index 9e16b512..bd5d6a87 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/TxEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/index/TxEntry.java @@ -1,14 +1,29 @@ package com.sparrowwallet.sparrow.net.cormorant.index; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.sparrowwallet.drongo.protocol.Transaction; + +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_NULL) public class TxEntry implements Comparable { public final int height; private final transient int index; public final String tx_hash; + public final Long fee; public TxEntry(int height, int index, String tx_hash) { this.height = height; this.index = index; this.tx_hash = tx_hash; + this.fee = null; + } + + public TxEntry(int height, int index, String tx_hash, double btcFee) { + this.height = height; + this.index = index; + this.tx_hash = tx_hash; + this.fee = btcFee > 0.0 ? (long)(btcFee * Transaction.SATOSHIS_PER_BITCOIN) : null; } @Override @@ -16,22 +31,18 @@ public class TxEntry implements Comparable { if(this == o) { return true; } - if(o == null || getClass() != o.getClass()) { + if(!(o instanceof TxEntry txEntry)) { return false; } - TxEntry txEntry = (TxEntry) o; - - if(height != txEntry.height) { - return false; - } - return tx_hash.equals(txEntry.tx_hash); + return height == txEntry.height && tx_hash.equals(txEntry.tx_hash) && Objects.equals(fee, txEntry.fee); } @Override public int hashCode() { int result = height; result = 31 * result + tx_hash.hashCode(); + result = 31 * result + Objects.hashCode(fee); return result; } @@ -62,6 +73,7 @@ public class TxEntry implements Comparable { "height=" + height + ", index=" + index + ", tx_hash='" + tx_hash + '\'' + + ", fee=" + fee + '}'; } }