Skip to content

Commit a5f9033

Browse files
committed
fix(types): v24 GetRawMempoolVerbose should use the same version MempoolEntry
1 parent 3a9c52a commit a5f9033

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

types/src/v24/blockchain/into.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use bitcoin::{hex, OutPoint, Txid, Wtxid};
77
use super::{
88
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
99
GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError,
10-
GetTxSpendingPrevout, GetTxSpendingPrevoutError, GetTxSpendingPrevoutItem,
11-
MapMempoolEntryError, MempoolEntry, MempoolEntryError,
10+
GetRawMempoolVerbose, GetTxSpendingPrevout, GetTxSpendingPrevoutError,
11+
GetTxSpendingPrevoutItem, MapMempoolEntryError, MempoolEntry, MempoolEntryError,
1212
};
1313
use crate::model;
1414

@@ -114,6 +114,21 @@ impl MempoolEntry {
114114
}
115115
}
116116

117+
impl GetRawMempoolVerbose {
118+
/// Converts version specific type to a version nonspecific, more strongly typed type.
119+
pub fn into_model(self) -> Result<model::GetRawMempoolVerbose, MapMempoolEntryError> {
120+
use MapMempoolEntryError as E;
121+
122+
let mut map = BTreeMap::new();
123+
for (k, v) in self.0.into_iter() {
124+
let txid = k.parse::<Txid>().map_err(E::Txid)?;
125+
let relative = v.into_model().map_err(E::MempoolEntry)?;
126+
map.insert(txid, relative);
127+
}
128+
Ok(model::GetRawMempoolVerbose(map))
129+
}
130+
}
131+
117132
impl GetMempoolInfo {
118133
/// Converts version specific type to a version nonspecific, more strongly typed type.
119134
pub fn into_model(self) -> Result<model::GetMempoolInfo, GetMempoolInfoError> {

types/src/v24/blockchain/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ pub struct GetMempoolDescendantsVerbose(pub BTreeMap<String, MempoolEntry>);
6464
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
6565
pub struct GetMempoolEntry(pub MempoolEntry);
6666

67+
/// Result of JSON-RPC method `getrawmempool` with verbose set to `true`.
68+
///
69+
/// Map of txid to [`MempoolEntry`].
70+
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
71+
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]
72+
pub struct GetRawMempoolVerbose(pub BTreeMap<String, MempoolEntry>);
73+
6774
/// Mempool data. Part of `getmempoolentry`.
6875
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
6976
#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))]

types/src/v24/mod.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ mod wallet;
249249
pub use self::{
250250
blockchain::{
251251
GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants,
252-
GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTxSpendingPrevout,
253-
GetTxSpendingPrevoutError, GetTxSpendingPrevoutItem, MempoolEntry,
252+
GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetRawMempoolVerbose,
253+
GetTxSpendingPrevout, GetTxSpendingPrevoutError, GetTxSpendingPrevoutItem, MempoolEntry,
254254
},
255255
network::{GetPeerInfo, PeerInfo},
256256
raw_transactions::{
@@ -279,16 +279,15 @@ pub use crate::{
279279
GetChainTips, GetChainTxStatsError, GetConnectionCount, GetDifficulty, GetMemoryInfoStats,
280280
GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfoAddress,
281281
GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress,
282-
GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose,
283-
GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut,
284-
GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance,
285-
GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError,
286-
ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem,
287-
ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets,
288-
LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError,
289-
RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType,
290-
SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage,
291-
SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
282+
GetRawMempool, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError,
283+
GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetTxOutSetInfo,
284+
GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings,
285+
ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent,
286+
ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError,
287+
ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError,
288+
PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput,
289+
RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive,
290+
SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError,
292291
SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject,
293292
TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain,
294293
VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError,

0 commit comments

Comments
 (0)