mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-01-26 02:11:10 +00:00
cormorant: add fee to mempool tx entries returned from get history
This commit is contained in:
parent
947013e088
commit
d07a5f0a01
3 changed files with 21 additions and 9 deletions
|
@ -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() {
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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<TxEntry> {
|
||||
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<TxEntry> {
|
|||
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<TxEntry> {
|
|||
"height=" + height +
|
||||
", index=" + index +
|
||||
", tx_hash='" + tx_hash + '\'' +
|
||||
", fee=" + fee +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue