diff --git a/integration_test/src/main.rs b/integration_test/src/main.rs index b183f4ff..4da07828 100644 --- a/integration_test/src/main.rs +++ b/integration_test/src/main.rs @@ -213,6 +213,7 @@ fn main() { test_wait_for_block(&cl); test_get_descriptor_info(&cl); test_derive_addresses(&cl); + test_get_mempool_info(&cl); //TODO import_multi( //TODO verify_message( //TODO encrypt_wallet(&self, passphrase: &str) -> Result<()> { @@ -1360,6 +1361,36 @@ fn test_derive_addresses(cl: &Client) { assert!(cl.derive_addresses(descriptor, None).is_err()); // Range must be specified for a ranged descriptor } +fn test_get_mempool_info(cl: &Client) { + let res = cl.get_mempool_info().unwrap(); + + if version() >= 190000 { + assert!(res.loaded.is_some()); + } else { + assert!(res.loaded.is_none()); + } + + if version() >= 210000 { + assert!(res.unbroadcast_count.is_some()); + } else { + assert!(res.unbroadcast_count.is_none()); + } + + if version() >= 220000 { + assert!(res.total_fee.is_some()); + } else { + assert!(res.total_fee.is_none()); + } + + if version() >= 240000 { + assert!(res.incremental_relay_fee.is_some()); + assert!(res.full_rbf.is_some()); + } else { + assert!(res.incremental_relay_fee.is_none()); + assert!(res.full_rbf.is_none()); + } +} + fn test_get_index_info(cl: &Client) { if version() >= 210000 { let gii = cl.get_index_info().unwrap(); diff --git a/json/src/lib.rs b/json/src/lib.rs index eb4fad9b..f6b13675 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -1059,7 +1059,7 @@ pub enum ImportMultiRequestScriptPubkey<'a> { #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct GetMempoolInfoResult { /// True if the mempool is fully loaded - pub loaded: bool, + pub loaded: Option, /// 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 @@ -1067,8 +1067,8 @@ pub struct GetMempoolInfoResult { /// Total memory usage for the mempool pub usage: usize, /// Total fees for the mempool in BTC, ignoring modified fees through prioritisetransaction - #[serde(with = "bitcoin::amount::serde::as_btc")] - pub total_fee: Amount, + #[serde(default, with = "bitcoin::amount::serde::as_btc::opt")] + pub total_fee: Option, /// Maximum memory usage for the mempool #[serde(rename = "maxmempool")] pub max_mempool: usize, @@ -1079,14 +1079,14 @@ pub struct GetMempoolInfoResult { #[serde(rename = "minrelaytxfee", with = "bitcoin::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::amount::serde::as_btc")] - pub incremental_relay_fee: Amount, + #[serde(rename = "incrementalrelayfee", default, with = "bitcoin::amount::serde::as_btc::opt")] + pub incremental_relay_fee: Option, /// Current number of transactions that haven't passed initial broadcast yet #[serde(rename = "unbroadcastcount")] - pub unbroadcast_count: usize, + pub unbroadcast_count: Option, /// True if the mempool accepts RBF without replaceability signaling inspection #[serde(rename = "fullrbf")] - pub full_rbf: bool, + pub full_rbf: Option, } #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]