Skip to content

Commit d61029b

Browse files
committed
Add getmempoolinfo v30 support
Redefine the type in v30 for the changes and remove TODO from table. Update the export, into function and test feature gate.
1 parent 8812817 commit d61029b

File tree

10 files changed

+113
-3
lines changed

10 files changed

+113
-3
lines changed

integration_test/tests/blockchain.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ fn blockchain__get_mempool_entry__modelled() {
331331
}
332332

333333
#[test]
334-
#[cfg(feature = "v29_and_below")]
335334
fn blockchain__get_mempool_info__modelled() {
336335
let node = Node::with_wallet(Wallet::Default, &[]);
337336
node.fund_wallet();

types/src/model/blockchain.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ pub struct GetMempoolInfo {
646646
/// True if the mempool accepts RBF without replaceability signaling inspection. v24 and later
647647
/// only.
648648
pub full_rbf: Option<bool>,
649+
/// True if the mempool accepts transactions with bare multisig outputs.
650+
pub permit_bare_multisig: Option<bool>,
651+
/// Maximum number of bytes that can be used by OP_RETURN outputs in the mempool.
652+
pub max_data_carrier_size: Option<u64>,
649653
}
650654

651655
/// Models the result of JSON-RPC method `getrawmempool` with verbose set to false.

types/src/v17/blockchain/into.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ impl GetMempoolInfo {
472472
incremental_relay_fee: None,
473473
unbroadcast_count: None,
474474
full_rbf: None,
475+
permit_bare_multisig: None,
476+
max_data_carrier_size: None,
475477
})
476478
}
477479
}

types/src/v19/blockchain/into.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ impl GetMempoolInfo {
234234
incremental_relay_fee: None,
235235
unbroadcast_count: None,
236236
full_rbf: None,
237+
permit_bare_multisig: None,
238+
max_data_carrier_size: None,
237239
})
238240
}
239241
}

types/src/v21/blockchain/into.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ impl GetMempoolInfo {
177177
incremental_relay_fee: None,
178178
unbroadcast_count,
179179
full_rbf: None,
180+
permit_bare_multisig: None,
181+
max_data_carrier_size: None,
180182
})
181183
}
182184
}

types/src/v22/blockchain/into.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ impl GetMempoolInfo {
2626
incremental_relay_fee: None,
2727
unbroadcast_count,
2828
full_rbf: None,
29+
permit_bare_multisig: None,
30+
max_data_carrier_size: None,
2931
})
3032
}
3133
}

types/src/v24/blockchain/into.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ impl GetMempoolInfo {
153153
incremental_relay_fee,
154154
unbroadcast_count,
155155
full_rbf: Some(self.full_rbf),
156+
permit_bare_multisig: None,
157+
max_data_carrier_size: None,
156158
})
157159
}
158160
}

types/src/v30/blockchain/into.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
use super::{GetMempoolInfo, GetMempoolInfoError};
4+
use crate::model;
5+
6+
impl GetMempoolInfo {
7+
/// Converts version specific type to a version nonspecific, more strongly typed type.
8+
pub fn into_model(self) -> Result<model::GetMempoolInfo, GetMempoolInfoError> {
9+
let size = crate::to_u32(self.size, "size")?;
10+
let bytes = crate::to_u32(self.bytes, "bytes")?;
11+
let usage = crate::to_u32(self.usage, "usage")?;
12+
let max_mempool = crate::to_u32(self.max_mempool, "max_mempool")?;
13+
let mempool_min_fee = crate::btc_per_kb(self.mempool_min_fee)?;
14+
let min_relay_tx_fee = crate::btc_per_kb(self.min_relay_tx_fee)?;
15+
let incremental_relay_fee = crate::btc_per_kb(self.incremental_relay_fee)?;
16+
let unbroadcast_count = Some(crate::to_u32(self.unbroadcast_count, "unbroadcast_count")?);
17+
18+
Ok(model::GetMempoolInfo {
19+
loaded: Some(self.loaded),
20+
size,
21+
bytes,
22+
usage,
23+
total_fee: Some(self.total_fee),
24+
max_mempool,
25+
mempool_min_fee,
26+
min_relay_tx_fee,
27+
incremental_relay_fee,
28+
unbroadcast_count,
29+
full_rbf: Some(self.full_rbf),
30+
permit_bare_multisig: Some(self.permit_bare_multisig),
31+
max_data_carrier_size: Some(self.max_data_carrier_size),
32+
})
33+
}
34+
}

types/src/v30/blockchain/mod.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! The JSON-RPC API for Bitcoin Core `v30` - blockchain.
4+
//!
5+
//! Types for methods found under the `== Blockchain ==` section of the API docs.
6+
7+
mod into;
8+
9+
use serde::{Deserialize, Serialize};
10+
11+
pub use super::GetMempoolInfoError;
12+
13+
/// Result of JSON-RPC method `getmempoolinfo` with verbose set to `true`.
14+
///
15+
/// > getmempoolinfo
16+
/// >
17+
/// > Returns details on the active state of the TX memory pool.
18+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
19+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
20+
pub struct GetMempoolInfo {
21+
/// True if the initial load attempt of the persisted mempool finished.
22+
pub loaded: bool,
23+
/// Current tx count.
24+
pub size: i64,
25+
/// Sum of all virtual transaction sizes as defined in BIP 141.
26+
///
27+
/// Differs from actual serialized size because witness data is discounted.
28+
pub bytes: i64,
29+
/// Total memory usage for the mempool.
30+
pub usage: i64,
31+
/// Total fees for the mempool in BTC, ignoring modified fees through prioritisetransaction.
32+
pub total_fee: f64,
33+
/// Maximum memory usage for the mempool.
34+
#[serde(rename = "maxmempool")]
35+
pub max_mempool: i64,
36+
/// Minimum fee rate in BTC/kB for a transaction to be accepted.
37+
///
38+
/// This is the maximum of `minrelaytxfee` and the minimum mempool fee.
39+
#[serde(rename = "mempoolminfee")]
40+
pub mempool_min_fee: f64,
41+
/// Current minimum relay fee for transactions.
42+
#[serde(rename = "minrelaytxfee")]
43+
pub min_relay_tx_fee: f64,
44+
/// Minimum fee rate increment for mempool limiting or replacement in BTC/kvB.
45+
#[serde(rename = "incrementalrelayfee")]
46+
pub incremental_relay_fee: f64,
47+
/// Current number of transactions that haven't passed initial broadcast yet.
48+
#[serde(rename = "unbroadcastcount")]
49+
pub unbroadcast_count: i64,
50+
/// True if the mempool accepts RBF without replaceability signaling inspection.
51+
#[serde(rename = "fullrbf")]
52+
pub full_rbf: bool,
53+
/// True if the mempool accepts transactions with bare multisig outputs.
54+
#[serde(rename = "permitbaremultisig")]
55+
pub permit_bare_multisig: bool,
56+
/// Maximum number of bytes that can be used by OP_RETURN outputs in the mempool.
57+
#[serde(rename = "maxdatacarriersize")]
58+
pub max_data_carrier_size: u64,
59+
}

types/src/v30/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
//! | getmempoolancestors | version + model | |
4646
//! | getmempooldescendants | version + model | |
4747
//! | getmempoolentry | version + model | |
48-
//! | getmempoolinfo | version + model | TODO |
48+
//! | getmempoolinfo | version + model | |
4949
//! | getrawmempool | version + model | Includes additional 'verbose' type |
5050
//! | gettxout | version + model | |
5151
//! | gettxoutproof | returns string | |
@@ -242,6 +242,10 @@
242242
//!
243243
//! </details>
244244
245+
mod blockchain;
246+
247+
#[doc(inline)]
248+
pub use self::{blockchain::GetMempoolInfo};
245249
#[doc(inline)]
246250
pub use crate::{
247251
v17::{
@@ -297,7 +301,7 @@ pub use crate::{
297301
},
298302
v24::{
299303
DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose,
300-
GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo,
304+
GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry,
301305
GetRawMempoolVerbose, GetTransactionDetail, GetTxSpendingPrevout,
302306
GetTxSpendingPrevoutError, GlobalXpub, ListUnspent, ListUnspentItem, MempoolEntry,
303307
MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError,

0 commit comments

Comments
 (0)