mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-01-27 02:41: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) {
|
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() {
|
public VsizeFeerate getVsizeFeerate() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class Store {
|
||||||
mempoolEntries.put(txid, null);
|
mempoolEntries.put(txid, null);
|
||||||
}
|
}
|
||||||
entries.removeIf(txe -> txe.height > 0 && txe.tx_hash.equals(listTransaction.txid()));
|
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 {
|
} else {
|
||||||
mempoolEntries.remove(txid);
|
mempoolEntries.remove(txid);
|
||||||
entries.removeIf(txe -> txe.height != listTransaction.blockheight() && txe.tx_hash.equals(listTransaction.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;
|
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 class TxEntry implements Comparable<TxEntry> {
|
||||||
public final int height;
|
public final int height;
|
||||||
private final transient int index;
|
private final transient int index;
|
||||||
public final String tx_hash;
|
public final String tx_hash;
|
||||||
|
public final Long fee;
|
||||||
|
|
||||||
public TxEntry(int height, int index, String tx_hash) {
|
public TxEntry(int height, int index, String tx_hash) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.tx_hash = tx_hash;
|
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
|
@Override
|
||||||
|
@ -16,22 +31,18 @@ public class TxEntry implements Comparable<TxEntry> {
|
||||||
if(this == o) {
|
if(this == o) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(o == null || getClass() != o.getClass()) {
|
if(!(o instanceof TxEntry txEntry)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TxEntry txEntry = (TxEntry) o;
|
return height == txEntry.height && tx_hash.equals(txEntry.tx_hash) && Objects.equals(fee, txEntry.fee);
|
||||||
|
|
||||||
if(height != txEntry.height) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return tx_hash.equals(txEntry.tx_hash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = height;
|
int result = height;
|
||||||
result = 31 * result + tx_hash.hashCode();
|
result = 31 * result + tx_hash.hashCode();
|
||||||
|
result = 31 * result + Objects.hashCode(fee);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +73,7 @@ public class TxEntry implements Comparable<TxEntry> {
|
||||||
"height=" + height +
|
"height=" + height +
|
||||||
", index=" + index +
|
", index=" + index +
|
||||||
", tx_hash='" + tx_hash + '\'' +
|
", tx_hash='" + tx_hash + '\'' +
|
||||||
|
", fee=" + fee +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue