Skip to content

Commit 3636ffc

Browse files
committed
Add missing getmempoolentry field in v18
There is a missing return field `bip125-replaceable` in v18. Redefinte the type in v18 with the new field and add it to the redefinition in v19. Update the v17 and v19 into functions. Type redefined in v19, therefore no further reexport changes needed.
1 parent f005c0f commit 3636ffc

File tree

7 files changed

+140
-2
lines changed

7 files changed

+140
-2
lines changed

types/src/model/blockchain.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ pub struct MempoolEntry {
414414
pub depends: Vec<Txid>,
415415
/// Unconfirmed transactions spending outputs from this transaction (child transaction id).
416416
pub spent_by: Vec<Txid>,
417+
/// Whether this transaction could be replaced due to BIP125 (replace-by-fee)
418+
pub bip125_replaceable: Option<bool>,
417419
}
418420

419421
/// (No docs in Core v0.17.)

types/src/v17/blockchain/into.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ impl MempoolEntry {
425425
fees,
426426
depends,
427427
spent_by,
428+
bip125_replaceable: None,
428429
})
429430
}
430431
}

types/src/v18/blockchain/into.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+
use bitcoin::{Txid, Wtxid};
4+
5+
use super::{GetMempoolEntry, MempoolEntry, MempoolEntryError};
6+
use crate::model;
7+
8+
impl GetMempoolEntry {
9+
/// Converts version specific type to a version nonspecific, more strongly typed type.
10+
pub fn into_model(self) -> Result<model::GetMempoolEntry, MempoolEntryError> {
11+
Ok(model::GetMempoolEntry(self.0.into_model()?))
12+
}
13+
}
14+
15+
impl MempoolEntry {
16+
/// Converts version specific type to a version nonspecific, more strongly typed type.
17+
pub fn into_model(self) -> Result<model::MempoolEntry, MempoolEntryError> {
18+
use MempoolEntryError as E;
19+
20+
let size = Some(crate::to_u32(self.size, "size")?);
21+
let weight = None;
22+
let time = crate::to_u32(self.time, "time")?;
23+
let height = crate::to_u32(self.height, "height")?;
24+
let descendant_count = crate::to_u32(self.descendant_count, "descendant_count")?;
25+
let descendant_size = crate::to_u32(self.descendant_size, "descendant_size")?;
26+
let ancestor_count = crate::to_u32(self.ancestor_count, "ancestor_count")?;
27+
let ancestor_size = crate::to_u32(self.ancestor_size, "ancestor_size")?;
28+
let wtxid = self.wtxid.parse::<Wtxid>().map_err(E::Wtxid)?;
29+
let fees = self.fees.into_model().map_err(E::Fees)?;
30+
let depends = self
31+
.depends
32+
.iter()
33+
.map(|txid| txid.parse::<Txid>())
34+
.collect::<Result<Vec<_>, _>>()
35+
.map_err(E::Depends)?;
36+
let spent_by = self
37+
.spent_by
38+
.iter()
39+
.map(|txid| txid.parse::<Txid>())
40+
.collect::<Result<Vec<_>, _>>()
41+
.map_err(E::SpentBy)?;
42+
43+
Ok(model::MempoolEntry {
44+
size,
45+
weight,
46+
time,
47+
height,
48+
descendant_count,
49+
descendant_size,
50+
ancestor_count,
51+
ancestor_size,
52+
wtxid,
53+
fees,
54+
depends,
55+
spent_by,
56+
bip125_replaceable: Some(self.bip125_replaceable),
57+
})
58+
}
59+
}

types/src/v18/blockchain/mod.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! The JSON-RPC API for Bitcoin Core `v0.18` - 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+
use super::{MempoolEntryError, MempoolEntryFees};
12+
13+
/// Result of JSON-RPC method `getmempoolentry`.
14+
///
15+
/// > getmempoolentry txid
16+
/// >
17+
/// > Returns mempool data for given transaction
18+
/// >
19+
/// > Arguments:
20+
/// > 1. "txid" (string, required) The transaction id (must be in mempool)
21+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
22+
pub struct GetMempoolEntry(pub MempoolEntry);
23+
24+
/// A relative (ancestor or descendant) transaction of a transaction in the mempool.
25+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
26+
pub struct MempoolEntry {
27+
/// Virtual transaction size as defined in BIP 141.
28+
///
29+
/// This is different from actual serialized size for witness transactions as witness data is discounted.
30+
pub size: i64,
31+
/// DEPRECATED: Transaction fee in BTC.
32+
pub fee: f64,
33+
/// DEPRECATED: Transaction fee with fee deltas used for mining priority.
34+
#[serde(rename = "modifiedfee")]
35+
pub modified_fee: f64,
36+
/// Local time transaction entered pool in seconds since 1 Jan 1970 GMT.
37+
pub time: i64,
38+
/// Block height when transaction entered pool.
39+
pub height: i64,
40+
/// Number of in-mempool descendant transactions (including this one).
41+
#[serde(rename = "descendantcount")]
42+
pub descendant_count: i64,
43+
/// Virtual transaction size of in-mempool descendants (including this one).
44+
#[serde(rename = "descendantsize")]
45+
pub descendant_size: i64,
46+
/// DEPRECATED: Modified fees (see above) of in-mempool descendants (including this one).
47+
#[serde(rename = "descendantfees")]
48+
pub descendant_fees: f64,
49+
/// Number of in-mempool ancestor transactions (including this one).
50+
#[serde(rename = "ancestorcount")]
51+
pub ancestor_count: i64,
52+
/// Virtual transaction size of in-mempool ancestors (including this one).
53+
#[serde(rename = "ancestorsize")]
54+
pub ancestor_size: i64,
55+
/// DEPRECATED: Modified fees (see above) of in-mempool ancestors (including this one).
56+
#[serde(rename = "ancestorfees")]
57+
pub ancestor_fees: f64,
58+
/// Hash of serialized transaction, including witness data.
59+
pub wtxid: String,
60+
/// (No docs in Core v0.17.)
61+
pub fees: MempoolEntryFees,
62+
/// Unconfirmed transactions used as inputs for this transaction (parent transaction id).
63+
pub depends: Vec<String>,
64+
/// Unconfirmed transactions spending outputs from this transaction (child transaction id).
65+
#[serde(rename = "spentby")]
66+
pub spent_by: Vec<String>,
67+
/// Whether this transaction could be replaced due to BIP125 (replace-by-fee)
68+
#[serde(rename = "bip125-replaceable")]
69+
pub bip125_replaceable: bool,
70+
}

types/src/v18/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
//! </details>
224224
225225
// JSON-RPC types by API section.
226+
mod blockchain;
226227
mod control;
227228
mod network;
228229
mod raw_transactions;
@@ -231,6 +232,7 @@ mod wallet;
231232

232233
#[doc(inline)]
233234
pub use self::{
235+
blockchain::{GetMempoolEntry, MempoolEntry},
234236
control::{ActiveCommand, GetRpcInfo},
235237
network::{GetNodeAddresses, NodeAddress},
236238
raw_transactions::{
@@ -260,7 +262,7 @@ pub use crate::v17::{
260262
GetBlockchainInfo, GetBlockchainInfoError, GetChainTips, GetChainTxStats, GetChainTxStatsError,
261263
GetConnectionCount, GetDifficulty, GetMemoryInfoStats, GetMempoolAncestors,
262264
GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose,
263-
GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals,
265+
GetMempoolInfo, GetMempoolInfoError, GetMiningInfo, GetNetTotals,
264266
GetNetworkInfo, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork,
265267
GetNewAddress, GetPeerInfo, GetRawChangeAddress, GetRawMempool, GetRawMempoolVerbose,
266268
GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError,
@@ -273,7 +275,7 @@ pub use crate::v17::{
273275
ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError,
274276
ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError,
275277
ListWallets, LoadWallet, Locked, Logging, MapMempoolEntryError, MempoolAcceptance,
276-
MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
278+
MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PeerInfo,
277279
PruneBlockchain, PsbtInput, PsbtOutput, PsbtScript, RawTransaction, RawTransactionError,
278280
RawTransactionInput, RawTransactionOutput, RescanBlockchain, SendMany, SendRawTransaction,
279281
SendToAddress, SetNetworkActive, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey,

types/src/v19/blockchain/into.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ impl MempoolEntry {
160160
fees,
161161
depends,
162162
spent_by,
163+
bip125_replaceable: Some(self.bip125_replaceable),
163164
})
164165
}
165166
}

types/src/v19/blockchain/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ pub struct MempoolEntry {
232232
/// Unconfirmed transactions spending outputs from this transaction (child transaction id).
233233
#[serde(rename = "spentby")]
234234
pub spent_by: Vec<String>,
235+
/// Whether this transaction could be replaced due to BIP125 (replace-by-fee)
236+
#[serde(rename = "bip125-replaceable")]
237+
pub bip125_replaceable: bool,
235238
}
236239

237240
/// (No docs in Core v0.19.)

0 commit comments

Comments
 (0)