Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commands: include unconfirmed change as coin selection candidates #873

Merged
Prev Previous commit
Next Next commit
bitcoin: add ancestor size and fees to mempool entry
jp1ac4 committed Jan 25, 2024

Verified

This commit was signed with the committer’s verified signature.
jp1ac4 Michael Mallan
commit edbf00f17c3796dc326bfbe6ae8833c201bdc045
23 changes: 21 additions & 2 deletions src/bitcoin/d/mod.rs
Original file line number Diff line number Diff line change
@@ -1473,6 +1473,7 @@ impl<'a> CachedTxGetter<'a> {
#[derive(Debug, Clone)]
pub struct MempoolEntry {
pub vsize: u64,
pub ancestor_vsize: u64,
pub fees: MempoolEntryFees,
}

@@ -1482,19 +1483,28 @@ impl From<Json> for MempoolEntry {
.get("vsize")
.and_then(Json::as_u64)
.expect("Must be present in bitcoind response");
let ancestor_vsize = json
.get("ancestorsize")
.and_then(Json::as_u64)
.expect("Must be present in bitcoind response");
let fees = json
.get("fees")
.as_ref()
.expect("Must be present in bitcoind response")
.into();

MempoolEntry { vsize, fees }
MempoolEntry {
vsize,
ancestor_vsize,
fees,
}
}
}

#[derive(Debug, Clone)]
pub struct MempoolEntryFees {
pub base: bitcoin::Amount,
pub ancestor: bitcoin::Amount,
pub descendant: bitcoin::Amount,
}

@@ -1506,11 +1516,20 @@ impl From<&&Json> for MempoolEntryFees {
.and_then(Json::as_f64)
.and_then(|a| bitcoin::Amount::from_btc(a).ok())
.expect("Must be present and a valid amount");
let ancestor = json
.get("ancestor")
.and_then(Json::as_f64)
.and_then(|a| bitcoin::Amount::from_btc(a).ok())
.expect("Must be present and a valid amount");
let descendant = json
.get("descendant")
.and_then(Json::as_f64)
.and_then(|a| bitcoin::Amount::from_btc(a).ok())
.expect("Must be present and a valid amount");
MempoolEntryFees { base, descendant }
MempoolEntryFees {
base,
ancestor,
descendant,
}
}
}