From 0f1c9f86f6e7569348cce697e23e62aed084779a Mon Sep 17 00:00:00 2001 From: dev7ba Date: Thu, 26 Jan 2023 20:10:52 +0100 Subject: [PATCH] Add getmempoolinfo --- client/src/client.rs | 5 +++++ json/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/client/src/client.rs b/client/src/client.rs index fb6f44b8..f132922e 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -917,6 +917,11 @@ pub trait RpcApi: Sized { self.call("reconsiderblock", &[into_json(block_hash)?]) } + /// Returns details on the active state of the TX memory pool + fn get_mempool_info(&self) -> Result { + self.call("getmempoolinfo", &[]) + } + /// Get txids of all transactions in a memory pool fn get_raw_mempool(&self) -> Result> { self.call("getrawmempool", &[]) diff --git a/json/src/lib.rs b/json/src/lib.rs index 6a251eb2..7ad2b23a 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -1045,6 +1045,39 @@ pub enum ImportMultiRequestScriptPubkey<'a> { Script(&'a Script), } +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] +pub struct GetMempoolInfoResult { + /// True if the mempool is fully loaded + pub loaded: bool, + /// Current tx count + pub size: usize, + /// Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted + pub bytes: usize, + /// Total memory usage for the mempool + pub usage: usize, + /// Total fees for the mempool in BTC, ignoring modified fees through prioritisetransaction + #[serde(with = "bitcoin::util::amount::serde::as_btc")] + pub total_fee: Amount, + /// Maximum memory usage for the mempool + #[serde(rename = "maxmempool")] + pub max_mempool: usize, + /// Minimum fee rate in BTC/kvB for tx to be accepted. Is the maximum of minrelaytxfee and minimum mempool fee + #[serde(rename = "mempoolminfee", with = "bitcoin::util::amount::serde::as_btc")] + pub mempool_min_fee: Amount, + /// Current minimum relay fee for transactions + #[serde(rename = "minrelaytxfee", with = "bitcoin::util::amount::serde::as_btc")] + pub min_relay_tx_fee: Amount, + /// Minimum fee rate increment for mempool limiting or replacement in BTC/kvB + #[serde(rename = "incrementalrelayfee", with = "bitcoin::util::amount::serde::as_btc")] + pub incremental_relay_fee: Amount, + /// Current number of transactions that haven't passed initial broadcast yet + #[serde(rename = "unbroadcastcount")] + pub unbroadcast_count: usize, + /// True if the mempool accepts RBF without replaceability signaling inspection + #[serde(rename = "fullrbf")] + pub full_rbf: bool, +} + #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct GetMempoolEntryResult { /// Virtual transaction size as defined in BIP 141. This is different from actual serialized