Skip to content

Commit 56ffb4f

Browse files
committed
Add missing fields to getmempoolinfo
v21, v22 and v24 had missing return fields. Redefine the type and into functions with the missing fields. Update model and other into functions.
1 parent 0e97a48 commit 56ffb4f

File tree

18 files changed

+259
-18
lines changed

18 files changed

+259
-18
lines changed

types/src/model/blockchain.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ pub struct GetMempoolInfo {
454454
pub bytes: u32,
455455
/// Total memory usage for the mempool.
456456
pub usage: u32,
457+
/// Total fees for the mempool in BTC, ignoring modified fees through prioritisetransaction. v23
458+
/// and later only.
459+
pub total_fee: Option<f64>,
457460
/// Maximum memory usage for the mempool.
458461
pub max_mempool: u32,
459462
/// Minimum fee rate in BTC/kB for a transaction to be accepted.
@@ -462,6 +465,13 @@ pub struct GetMempoolInfo {
462465
pub mempool_min_fee: Option<FeeRate>,
463466
/// Current minimum relay fee for transactions.
464467
pub min_relay_tx_fee: Option<FeeRate>,
468+
/// Minimum fee rate increment for mempool limiting or replacement in BTC/kvB. v24 and later only.
469+
pub incremental_relay_fee: Option<FeeRate>,
470+
/// Current number of transactions that haven't passed initial broadcast yet. v21 and later only.
471+
pub unbroadcast_count: Option<u32>,
472+
/// True if the mempool accepts RBF without replaceability signaling inspection. v24 and later
473+
/// only.
474+
pub full_rbf: Option<bool>,
465475
}
466476

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

types/src/v17/blockchain/into.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,13 @@ impl GetMempoolInfo {
463463
size,
464464
bytes,
465465
usage,
466+
total_fee: None,
466467
max_mempool,
467468
mempool_min_fee,
468469
min_relay_tx_fee,
470+
incremental_relay_fee: None,
471+
unbroadcast_count: None,
472+
full_rbf: None,
469473
})
470474
}
471475
}

types/src/v19/blockchain/into.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,13 @@ impl GetMempoolInfo {
226226
size,
227227
bytes,
228228
usage,
229+
total_fee: None,
229230
max_mempool,
230231
mempool_min_fee,
231232
min_relay_tx_fee,
233+
incremental_relay_fee: None,
234+
unbroadcast_count: None,
235+
full_rbf: None,
232236
})
233237
}
234238
}

types/src/v21/blockchain/into.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use alloc::collections::BTreeMap;
55
use bitcoin::{BlockHash, Network, Txid, Work, Wtxid};
66

77
use super::{
8-
GetBlockchainInfo, GetBlockchainInfoError, GetMempoolEntry, MempoolEntry, MempoolEntryError,
8+
GetBlockchainInfo, GetBlockchainInfoError, GetMempoolEntry, GetMempoolInfo,
9+
GetMempoolInfoError, MempoolEntry, MempoolEntryError,
910
};
1011
use crate::model;
1112

@@ -104,3 +105,30 @@ impl MempoolEntry {
104105
})
105106
}
106107
}
108+
109+
impl GetMempoolInfo {
110+
/// Converts version specific type to a version nonspecific, more strongly typed type.
111+
pub fn into_model(self) -> Result<model::GetMempoolInfo, GetMempoolInfoError> {
112+
let size = crate::to_u32(self.size, "size")?;
113+
let bytes = crate::to_u32(self.bytes, "bytes")?;
114+
let usage = crate::to_u32(self.usage, "usage")?;
115+
let max_mempool = crate::to_u32(self.max_mempool, "max_mempool")?;
116+
let mempool_min_fee = crate::btc_per_kb(self.mempool_min_fee)?;
117+
let min_relay_tx_fee = crate::btc_per_kb(self.min_relay_tx_fee)?;
118+
let unbroadcast_count = Some(crate::to_u32(self.unbroadcast_count, "unbroadcast_count")?);
119+
120+
Ok(model::GetMempoolInfo {
121+
loaded: Some(self.loaded),
122+
size,
123+
bytes,
124+
usage,
125+
total_fee: None,
126+
max_mempool,
127+
mempool_min_fee,
128+
min_relay_tx_fee,
129+
incremental_relay_fee: None,
130+
unbroadcast_count,
131+
full_rbf: None,
132+
})
133+
}
134+
}

types/src/v21/blockchain/mod.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use alloc::collections::BTreeMap;
1111
use serde::{Deserialize, Serialize};
1212

1313
pub use super::{
14-
Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBlockchainInfoError, MempoolEntryError,
15-
MempoolEntryFees,
14+
Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBlockchainInfoError, GetMempoolInfoError,
15+
MempoolEntryError, MempoolEntryFees,
1616
};
1717

1818
/// Result of JSON-RPC method `getblockchaininfo`.
@@ -173,3 +173,36 @@ pub struct MempoolEntry {
173173
/// any peers)
174174
pub unbroadcast: bool,
175175
}
176+
177+
/// Result of JSON-RPC method `getmempoolinfo` with verbose set to `true`.
178+
///
179+
/// > getmempoolinfo
180+
/// >
181+
/// > Returns details on the active state of the TX memory pool.
182+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
183+
pub struct GetMempoolInfo {
184+
/// True if the mempool is fully loaded. v0.19 and later only.
185+
pub loaded: bool,
186+
/// Current transaction count.
187+
pub size: i64,
188+
/// Sum of all virtual transaction sizes as defined in BIP 141.
189+
///
190+
/// Differs from actual serialized size because witness data is discounted.
191+
pub bytes: i64,
192+
/// Total memory usage for the mempool.
193+
pub usage: i64,
194+
/// Maximum memory usage for the mempool.
195+
#[serde(rename = "maxmempool")]
196+
pub max_mempool: i64,
197+
/// Minimum fee rate in BTC/kB for a transaction to be accepted.
198+
///
199+
/// This is the maximum of `minrelaytxfee` and the minimum mempool fee.
200+
#[serde(rename = "mempoolminfee")]
201+
pub mempool_min_fee: f64,
202+
/// Current minimum relay fee for transactions.
203+
#[serde(rename = "minrelaytxfee")]
204+
pub min_relay_tx_fee: f64,
205+
/// Current number of transactions that haven't passed initial broadcast yet. v21 and later only.
206+
#[serde(rename = "unbroadcastcount")]
207+
pub unbroadcast_count: i64,
208+
}

types/src/v21/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ mod wallet;
237237

238238
#[doc(inline)]
239239
pub use self::{
240-
blockchain::{Bip9SoftforkInfo, GetBlockchainInfo, GetMempoolEntry, Softfork, SoftforkType},
240+
blockchain::{
241+
Bip9SoftforkInfo, GetBlockchainInfo, GetMempoolEntry, GetMempoolInfo, Softfork,
242+
SoftforkType,
243+
},
241244
wallet::UnloadWallet,
242245
};
243246
#[doc(inline)]
@@ -286,7 +289,7 @@ pub use crate::{
286289
GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError,
287290
GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors,
288291
GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose,
289-
GetMempoolInfo, GetNetworkInfo, GetPeerInfo, GetRpcInfo, MapMempoolEntryError,
292+
GetNetworkInfo, GetPeerInfo, GetRpcInfo, MapMempoolEntryError,
290293
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
291294
},
292295
v20::{Banned, CreateMultisig, ListBanned, Logging},

types/src/v22/blockchain/into.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 unbroadcast_count = Some(crate::to_u32(self.unbroadcast_count, "unbroadcast_count")?);
16+
17+
Ok(model::GetMempoolInfo {
18+
loaded: Some(self.loaded),
19+
size,
20+
bytes,
21+
usage,
22+
total_fee: Some(self.total_fee),
23+
max_mempool,
24+
mempool_min_fee,
25+
min_relay_tx_fee,
26+
incremental_relay_fee: None,
27+
unbroadcast_count,
28+
full_rbf: None,
29+
})
30+
}
31+
}

types/src/v22/blockchain/mod.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! The JSON-RPC API for Bitcoin Core `v22` - 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+
pub struct GetMempoolInfo {
20+
/// True if the mempool is fully loaded. v0.19 and later only.
21+
pub loaded: bool,
22+
/// Current transaction count.
23+
pub size: i64,
24+
/// Sum of all virtual transaction sizes as defined in BIP 141.
25+
///
26+
/// Differs from actual serialized size because witness data is discounted.
27+
pub bytes: i64,
28+
/// Total memory usage for the mempool.
29+
pub usage: i64,
30+
/// Total fees for the mempool in BTC, ignoring modified fees through prioritisetransaction. v23
31+
/// and later only.
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+
/// Current number of transactions that haven't passed initial broadcast yet. v21 and later only.
45+
#[serde(rename = "unbroadcastcount")]
46+
pub unbroadcast_count: i64,
47+
}

types/src/v22/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,13 @@
243243
//! </details>
244244
245245
// JSON-RPC types by API section.
246+
mod blockchain;
246247
mod control;
247248
mod network;
248249

249250
#[doc(inline)]
250251
pub use self::{
252+
blockchain::GetMempoolInfo,
251253
control::Logging,
252254
network::{Banned, ListBanned},
253255
};
@@ -297,12 +299,13 @@ pub use crate::{
297299
GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError,
298300
GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors,
299301
GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose,
300-
GetMempoolInfo, GetNetworkInfo, GetPeerInfo, GetRpcInfo, MapMempoolEntryError,
302+
GetNetworkInfo, GetPeerInfo, GetRpcInfo, MapMempoolEntryError,
301303
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
302304
},
303305
v20::CreateMultisig,
304306
v21::{
305-
Bip9SoftforkInfo, GetBlockchainInfo, GetMempoolEntry, Softfork, SoftforkType, UnloadWallet,
307+
Bip9SoftforkInfo, GetBlockchainInfo, GetMempoolEntry, Softfork, SoftforkType,
308+
UnloadWallet,
306309
},
307310
ScriptPubkey,
308311
};

types/src/v23/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ pub use crate::{
294294
GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError,
295295
GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo, GetMempoolAncestors,
296296
GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose,
297-
GetMempoolInfo, GetNetworkInfo, GetPeerInfo, GetRpcInfo, MapMempoolEntryError,
297+
GetNetworkInfo, GetPeerInfo, GetRpcInfo, MapMempoolEntryError,
298298
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
299299
Softfork, SoftforkType,
300300
},
301301
v21::UnloadWallet,
302-
v22::{Banned, ListBanned, Logging, ScriptPubkey},
302+
v22::{Banned, GetMempoolInfo, ListBanned, Logging, ScriptPubkey},
303303
};

0 commit comments

Comments
 (0)