diff --git a/types/src/v24/blockchain/into.rs b/types/src/v24/blockchain/into.rs index cab70193..ca2be929 100644 --- a/types/src/v24/blockchain/into.rs +++ b/types/src/v24/blockchain/into.rs @@ -7,8 +7,8 @@ use bitcoin::{hex, OutPoint, Txid, Wtxid}; use super::{ GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, - GetTxSpendingPrevout, GetTxSpendingPrevoutError, GetTxSpendingPrevoutItem, - MapMempoolEntryError, MempoolEntry, MempoolEntryError, + GetRawMempoolVerbose, GetTxSpendingPrevout, GetTxSpendingPrevoutError, + GetTxSpendingPrevoutItem, MapMempoolEntryError, MempoolEntry, MempoolEntryError, }; use crate::model; @@ -114,6 +114,21 @@ impl MempoolEntry { } } +impl GetRawMempoolVerbose { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use MapMempoolEntryError as E; + + let mut map = BTreeMap::new(); + for (k, v) in self.0.into_iter() { + let txid = k.parse::().map_err(E::Txid)?; + let relative = v.into_model().map_err(E::MempoolEntry)?; + map.insert(txid, relative); + } + Ok(model::GetRawMempoolVerbose(map)) + } +} + impl GetMempoolInfo { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v24/blockchain/mod.rs b/types/src/v24/blockchain/mod.rs index 98c88832..0304a998 100644 --- a/types/src/v24/blockchain/mod.rs +++ b/types/src/v24/blockchain/mod.rs @@ -64,6 +64,13 @@ pub struct GetMempoolDescendantsVerbose(pub BTreeMap); #[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] pub struct GetMempoolEntry(pub MempoolEntry); +/// Result of JSON-RPC method `getrawmempool` with verbose set to `true`. +/// +/// Map of txid to [`MempoolEntry`]. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct GetRawMempoolVerbose(pub BTreeMap); + /// Mempool data. Part of `getmempoolentry`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 859e45de..8728519c 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -249,8 +249,8 @@ mod wallet; pub use self::{ blockchain::{ GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, - GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTxSpendingPrevout, - GetTxSpendingPrevoutError, GetTxSpendingPrevoutItem, MempoolEntry, + GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetRawMempoolVerbose, + GetTxSpendingPrevout, GetTxSpendingPrevoutError, GetTxSpendingPrevoutItem, MempoolEntry, }, network::{GetPeerInfo, PeerInfo}, raw_transactions::{ @@ -279,16 +279,15 @@ pub use crate::{ GetChainTips, GetChainTxStatsError, GetConnectionCount, GetDifficulty, GetMemoryInfoStats, GetMempoolInfoError, GetMiningInfo, GetNetTotals, GetNetworkInfoAddress, GetNetworkInfoError, GetNetworkInfoNetwork, GetNewAddress, GetRawChangeAddress, - GetRawMempool, GetRawMempoolVerbose, GetRawTransaction, GetRawTransactionVerbose, - GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, - GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, - GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, - ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, - LoadWallet, LockUnspent, Locked, NumericError, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + GetRawMempool, GetRawTransaction, GetRawTransactionVerbose, GetRawTransactionVerboseError, + GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetTxOutSetInfo, + GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, + ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, + PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, + RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, + SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, diff --git a/types/src/v24/wallet/into.rs b/types/src/v24/wallet/into.rs index 322349e2..b6ada363 100644 --- a/types/src/v24/wallet/into.rs +++ b/types/src/v24/wallet/into.rs @@ -216,6 +216,7 @@ impl ListUnspentItem { let vout = crate::to_u32(self.vout, "vout")?; let address = self.address.parse::>().map_err(E::Address)?; let script_pubkey = ScriptBuf::from_hex(&self.script_pubkey).map_err(E::ScriptPubkey)?; + let label = self.label.unwrap_or_default(); let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?; let confirmations = crate::to_u32(self.confirmations, "confirmations")?; @@ -228,7 +229,7 @@ impl ListUnspentItem { txid, vout, address, - label: self.label, + label, script_pubkey, amount, confirmations, diff --git a/types/src/v24/wallet/mod.rs b/types/src/v24/wallet/mod.rs index a2fc30fb..c615a869 100644 --- a/types/src/v24/wallet/mod.rs +++ b/types/src/v24/wallet/mod.rs @@ -250,7 +250,7 @@ pub struct ListUnspentItem { /// The bitcoin address of the transaction. pub address: String, /// The associated label, or "" for the default label. - pub label: String, + pub label: Option, /// The script key. #[serde(rename = "scriptPubKey")] pub script_pubkey: String, diff --git a/types/src/v28/raw_transactions/into.rs b/types/src/v28/raw_transactions/into.rs index eee80c08..dbab987c 100644 --- a/types/src/v28/raw_transactions/into.rs +++ b/types/src/v28/raw_transactions/into.rs @@ -61,7 +61,8 @@ impl SubmitPackageTxResultFees { .flatten(); let effective_includes = self .effective_includes - .iter() + .unwrap_or_default() + .into_iter() .map(|s| s.parse::().map_err(E::EffectiveIncludes)) .collect::, _>>()?; diff --git a/types/src/v28/raw_transactions/mod.rs b/types/src/v28/raw_transactions/mod.rs index b0ea1756..343915e2 100644 --- a/types/src/v28/raw_transactions/mod.rs +++ b/types/src/v28/raw_transactions/mod.rs @@ -82,5 +82,5 @@ pub struct SubmitPackageTxResultFees { /// If [`Self::effective_fee_rate`] is provided, this holds the wtxid's of the transactions /// whose fees and vsizes are included in effective-feerate. #[serde(rename = "effective-includes")] - pub effective_includes: Vec, + pub effective_includes: Option>, }