From edbf00f17c3796dc326bfbe6ae8833c201bdc045 Mon Sep 17 00:00:00 2001 From: jp1ac4 <121959000+jp1ac4@users.noreply.github.com> Date: Wed, 3 Jan 2024 23:14:28 +0000 Subject: [PATCH] bitcoin: add ancestor size and fees to mempool entry --- src/bitcoin/d/mod.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/bitcoin/d/mod.rs b/src/bitcoin/d/mod.rs index a1b1317c..faaaf371 100644 --- a/src/bitcoin/d/mod.rs +++ b/src/bitcoin/d/mod.rs @@ -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 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, + } } }