From dfc6b46aa295c758fe4c8fe8553875cb2cafab7f Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Thu, 28 Aug 2025 13:43:43 +0100 Subject: [PATCH 1/5] Move v25 wallet to subdirectory Move wallet.rs to ./wallet/mod.rs Split out the into_model() into an into module. Code move only. --- types/src/v25/wallet/into.rs | 35 ++++++++++++++++++++++ types/src/v25/{wallet.rs => wallet/mod.rs} | 34 ++------------------- 2 files changed, 37 insertions(+), 32 deletions(-) rename types/src/v25/{wallet.rs => wallet/mod.rs} (83%) diff --git a/types/src/v25/wallet/into.rs b/types/src/v25/wallet/into.rs index e69de29b..20205029 100644 --- a/types/src/v25/wallet/into.rs +++ b/types/src/v25/wallet/into.rs @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: CC0-1.0 + +use super::{CreateWallet, LoadWallet, UnloadWallet}; +use crate::model; + +impl CreateWallet { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> model::CreateWallet { + // As the content of the deprecated `warning` field would be the same as `warnings`, we + // simply ignore the field, even in case it's set. + model::CreateWallet { name: self.name, warnings: self.warnings.unwrap_or_default() } + } + + /// Returns the created wallet name. + pub fn name(self) -> String { self.into_model().name } +} + +impl LoadWallet { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> model::LoadWallet { + // As the content of the deprecated `warning` field would be the same as `warnings`, we + // simply ignore the field, even in case it's set. + model::LoadWallet { name: self.name, warnings: self.warnings.unwrap_or_default() } + } + + /// Returns the loaded wallet name. + pub fn name(self) -> String { self.into_model().name } +} + +impl UnloadWallet { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> model::UnloadWallet { + model::UnloadWallet { warnings: self.warnings.unwrap_or_default() } + } +} diff --git a/types/src/v25/wallet.rs b/types/src/v25/wallet/mod.rs similarity index 83% rename from types/src/v25/wallet.rs rename to types/src/v25/wallet/mod.rs index 36a2df49..148f6c2d 100644 --- a/types/src/v25/wallet.rs +++ b/types/src/v25/wallet/mod.rs @@ -4,9 +4,9 @@ //! //! Types for methods found under the `== Wallet ==` section of the API docs. -use serde::{Deserialize, Serialize}; +mod into; -use crate::model; +use serde::{Deserialize, Serialize}; /// Result of the JSON-RPC method `createwallet`. /// @@ -39,17 +39,6 @@ pub struct CreateWallet { pub warnings: Option>, } -impl CreateWallet { - /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> model::CreateWallet { - // As the content of the deprecated `warning` field would be the same as `warnings`, we - // simply ignore the field, even in case it's set. - model::CreateWallet { name: self.name, warnings: self.warnings.unwrap_or_default() } - } - - /// Returns the created wallet name. - pub fn name(self) -> String { self.into_model().name } -} /// Result of JSON-RPC method `listdescriptors`. /// /// > List descriptors imported into a descriptor-enabled wallet. @@ -108,18 +97,6 @@ pub struct LoadWallet { pub warnings: Option>, } -impl LoadWallet { - /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> model::LoadWallet { - // As the content of the deprecated `warning` field would be the same as `warnings`, we - // simply ignore the field, even in case it's set. - model::LoadWallet { name: self.name, warnings: self.warnings.unwrap_or_default() } - } - - /// Returns the loaded wallet name. - pub fn name(self) -> String { self.into_model().name } -} - /// Result of the JSON-RPC method `unloadwallet`. /// /// > unloadwallet ( "wallet_name" load_on_startup ) @@ -141,10 +118,3 @@ pub struct UnloadWallet { /// Warning messages, if any, related to loading the wallet. pub warnings: Option>, } - -impl UnloadWallet { - /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> model::UnloadWallet { - model::UnloadWallet { warnings: self.warnings.unwrap_or_default() } - } -} From 70eba76f44671d6cae908b05197973b72edd9394 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Thu, 28 Aug 2025 12:18:56 +0100 Subject: [PATCH 2/5] Test and update listsinceblock The RPC was implemented for v17 and untested. Some fields are optional or undocumented. Fix the struct for v17. Update the struct, model, into_model, and error for changes in v20, v23, v24 and v28. Add a test and update the types tables. --- integration_test/tests/wallet.rs | 17 +++++ types/src/model/wallet.rs | 35 ++++++++-- types/src/v17/mod.rs | 2 +- types/src/v17/wallet/into.rs | 22 +++++-- types/src/v17/wallet/mod.rs | 9 ++- types/src/v18/mod.rs | 2 +- types/src/v19/mod.rs | 2 +- types/src/v20/mod.rs | 8 +-- types/src/v20/wallet/error.rs | 109 +++++++++++++++++++++++++++++++ types/src/v20/wallet/into.rs | 87 +++++++++++++++++++++++- types/src/v20/wallet/mod.rs | 93 ++++++++++++++++++++++++++ types/src/v21/mod.rs | 8 +-- types/src/v22/mod.rs | 8 +-- types/src/v23/mod.rs | 8 +-- types/src/v23/wallet/error.rs | 100 ++++++++++++++++++++++++++++ types/src/v23/wallet/into.rs | 92 +++++++++++++++++++++++++- types/src/v23/wallet/mod.rs | 91 +++++++++++++++++++++++++- types/src/v24/mod.rs | 10 +-- types/src/v24/wallet/error.rs | 104 +++++++++++++++++++++++++++++ types/src/v24/wallet/into.rs | 91 ++++++++++++++++++++++++++ types/src/v24/wallet/mod.rs | 98 ++++++++++++++++++++++++++- types/src/v25/mod.rs | 14 ++-- types/src/v26/mod.rs | 12 ++-- types/src/v27/mod.rs | 12 ++-- types/src/v28/mod.rs | 8 +-- types/src/v28/wallet/error.rs | 107 +++++++++++++++++++++++++++++- types/src/v28/wallet/into.rs | 96 ++++++++++++++++++++++++++- types/src/v28/wallet/mod.rs | 99 +++++++++++++++++++++++++++- types/src/v29/mod.rs | 10 +-- 29 files changed, 1280 insertions(+), 74 deletions(-) create mode 100644 types/src/v20/wallet/error.rs diff --git a/integration_test/tests/wallet.rs b/integration_test/tests/wallet.rs index 4ab9920c..f6572522 100644 --- a/integration_test/tests/wallet.rs +++ b/integration_test/tests/wallet.rs @@ -593,6 +593,23 @@ fn wallet__list_received_by_address__modelled() { assert!(model.0.iter().any(|item| &item.address == unchecked_addr)); } +#[test] +fn wallet__list_since_block__modelled() { + let node = Node::with_wallet(Wallet::Default, &[]); + node.fund_wallet(); + let addr = node.client.new_address().expect("newaddress"); + let amount = Amount::from_sat(5_000); + node.client.send_to_address(&addr, amount).expect("sendtoaddress"); + node.mine_a_block(); + + let json: ListSinceBlock = node.client.list_since_block().expect("listsinceblock"); + let model: Result = json.into_model(); + let model = model.unwrap(); + + let first_tx: mtype::ListSinceBlockTransaction = model.transactions[0].clone(); + assert_eq!(first_tx.txid.unwrap().to_string().len(), 64); +} + #[test] fn wallet__import_multi() { let node = match () { diff --git a/types/src/model/wallet.rs b/types/src/model/wallet.rs index 889d4895..7ea51128 100644 --- a/types/src/model/wallet.rs +++ b/types/src/model/wallet.rs @@ -609,6 +609,8 @@ pub struct ListSinceBlock { #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] pub struct ListSinceBlockTransaction { + /// Only returns true if imported addresses were involved in transaction. + pub involves_watch_only: Option, /// The bitcoin address of the transaction. pub address: Option>, /// The transaction category. @@ -631,39 +633,58 @@ pub struct ListSinceBlockTransaction { /// Available for 'send' and 'receive' category of transactions. When it's < 0, it means the /// transaction conflicted that many blocks ago. pub confirmations: i64, + /// Only present if the transaction's only input is a coinbase one. Only documented from v0.20 and later. + pub generated: Option, + /// Whether we consider the transaction to be trusted and safe to spend from. Only present + /// when the transaction has 0 confirmations (or negative confirmations, if conflicted). v0.20 and later only. + pub trusted: Option, /// The block hash containing the transaction. /// /// Available for 'send' and 'receive' category of transactions. - pub block_hash: BlockHash, + pub block_hash: Option, + /// The block height containing the transaction. v20 and later only. + pub block_height: Option, /// The index of the transaction in the block that includes it. /// /// Available for 'send' and 'receive' category of transactions. - pub block_index: u32, + pub block_index: Option, /// The block time in seconds since epoch (1 Jan 1970 GMT). - pub block_time: u32, + pub block_time: Option, /// The transaction id. /// /// Available for 'send' and 'receive' category of transactions. pub txid: Option, + /// The hash of serialized transaction, including witness data. v24 and later only. + pub wtxid: Option, + /// Conflicting transaction ids. Only documented from v0.20 and later. + pub wallet_conflicts: Option>, + /// The txid if this tx was replaced. v23 and later only. + pub replaced_by_txid: Option, + /// The txid if this tx replaces one. v23 and later only. + pub replaces_txid: Option, + /// Transactions in the mempool that directly conflict with either this transaction or an ancestor transaction. v28 and later only. + pub mempool_conflicts: Option>, + /// If a comment to is associated with the transaction. + pub to: Option, /// The transaction time in seconds since epoch (Jan 1 1970 GMT). pub time: u32, /// The time received in seconds since epoch (Jan 1 1970 GMT). /// /// Available for 'send' and 'receive' category of transactions. pub time_received: u32, + /// If a comment is associated with the transaction. + pub comment: Option, /// Whether this transaction could be replaced due to BIP125 (replace-by-fee); /// may be unknown for unconfirmed transactions not in the mempool pub bip125_replaceable: Bip125Replaceable, + /// Only if 'category' is 'received'. List of parent descriptors for the scriptPubKey of this coin. v24 and later only. + pub parent_descriptors: Option>, /// If the transaction has been abandoned (inputs are respendable). /// /// Only available for the 'send' category of transactions. pub abandoned: Option, - /// If a comment is associated with the transaction. - pub comment: Option, /// A comment for the address/transaction, if any. pub label: Option, - /// If a comment to is associated with the transaction. - pub to: Option, } /// Models the result of JSON-RPC method `listtransactions`. diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index b8eae11b..ac2571a4 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -185,7 +185,7 @@ //! | listlockunspent | version + model | | //! | listreceivedbyaccount | returns nothing | | //! | listreceivedbyaddress | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwallets | version + model | | diff --git a/types/src/v17/wallet/into.rs b/types/src/v17/wallet/into.rs index 87fe6615..b5f98b35 100644 --- a/types/src/v17/wallet/into.rs +++ b/types/src/v17/wallet/into.rs @@ -589,30 +589,44 @@ impl ListSinceBlockTransaction { let category = self.category.into_model(); let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?; let vout = crate::to_u32(self.vout, "vout")?; - let fee = SignedAmount::from_btc(self.fee).map_err(E::Fee)?; + let fee = self + .fee + .map(|f| SignedAmount::from_btc(f).map_err(E::Fee)) + .transpose()? // optional historically + .unwrap_or_else(|| SignedAmount::from_sat(0)); let block_hash = self.block_hash.parse::().map_err(E::BlockHash)?; let block_index = crate::to_u32(self.block_index, "block_index")?; let txid = self.txid.map(|s| s.parse::().map_err(E::Txid)).transpose()?; let bip125_replaceable = self.bip125_replaceable.into_model(); Ok(model::ListSinceBlockTransaction { + involves_watch_only: None, address: Some(address), category, amount, vout, fee, confirmations: self.confirmations, - block_hash, - block_index, - block_time: self.block_time, + block_hash: Some(block_hash), + block_index: Some(block_index), + block_time: Some(self.block_time), txid, + wtxid: None, time: self.time, time_received: self.time_received, bip125_replaceable, + generated: None, + trusted: None, abandoned: self.abandoned, comment: self.comment, label: self.label, to: self.to, + block_height: None, + wallet_conflicts: None, + replaced_by_txid: None, + replaces_txid: None, + mempool_conflicts: None, + parent_descriptors: None, }) } } diff --git a/types/src/v17/wallet/mod.rs b/types/src/v17/wallet/mod.rs index a06200e7..b79cbbbf 100644 --- a/types/src/v17/wallet/mod.rs +++ b/types/src/v17/wallet/mod.rs @@ -716,7 +716,7 @@ pub struct ListSinceBlock { #[serde(deny_unknown_fields)] pub struct ListSinceBlockTransaction { /// DEPRECATED. The account name associated with the transaction. Will be "" for the default account. - pub account: String, + pub account: Option, /// The bitcoin address of the transaction. /// /// Not present for move transactions (category = move). @@ -734,12 +734,14 @@ pub struct ListSinceBlockTransaction { /// The amount of the fee in BTC. /// /// This is negative and only available for the 'send' category of transactions. - pub fee: f64, + pub fee: Option, /// The number of confirmations for the transaction. /// /// Available for 'send' and 'receive' category of transactions. When it's < 0, it means the /// transaction conflicted that many blocks ago. pub confirmations: i64, + /// Only present if transaction only input is a coinbase one. + pub generated: Option, /// The block hash containing the transaction. /// /// Available for 'send' and 'receive' category of transactions. @@ -757,6 +759,9 @@ pub struct ListSinceBlockTransaction { /// /// Available for 'send' and 'receive' category of transactions. pub txid: Option, + /// Conflicting transaction ids. + #[serde(rename = "walletconflicts")] + pub wallet_conflicts: Vec, /// The transaction time in seconds since epoch (Jan 1 1970 GMT). pub time: u32, /// The time received in seconds since epoch (Jan 1 1970 GMT). diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index 3c1dbaac..b99893fc 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -188,7 +188,7 @@ //! | listlockunspent | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index 14773787..99908f45 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -189,7 +189,7 @@ //! | listlockunspent | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 44d295d1..65fb814a 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -190,7 +190,7 @@ //! | listlockunspent | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -240,7 +240,8 @@ pub use self::{ util::CreateMultisig, wallet::{ AddMultisigAddress, GetAddressInfo, GetAddressInfoEmbedded, GetTransaction, - GetTransactionDetail, + GetTransactionDetail, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, + ListSinceBlockTransactionError, }, }; #[doc(inline)] @@ -264,8 +265,7 @@ pub use crate::{ GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, - ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, diff --git a/types/src/v20/wallet/error.rs b/types/src/v20/wallet/error.rs new file mode 100644 index 00000000..3e4deeec --- /dev/null +++ b/types/src/v20/wallet/error.rs @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Errors for wallet types newly (re)defined in v20. + +use core::fmt; + +use bitcoin::amount::ParseAmountError; +use bitcoin::{address, hex}; + +use crate::error::write_err; +use crate::NumericError; + +/// Error when converting a `ListSinceBlock` type into the model type. +#[derive(Debug)] +pub enum ListSinceBlockError { + /// Conversion of item in `transactions` list failed. + Transactions(ListSinceBlockTransactionError), + /// Conversion of item in `removed` list failed. + Removed(ListSinceBlockTransactionError), + /// Conversion of the `last_block` field failed. + LastBlock(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockError::*; + + match *self { + Transactions(ref e) => + write_err!(f, "conversion of the `transactions` field failed"; e), + Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockError::*; + + match *self { + Transactions(ref e) => Some(e), + Removed(ref e) => Some(e), + LastBlock(ref e) => Some(e), + } + } +} + +/// Error when converting a `ListSinceBlockTransaction` type into the model type. +/// +/// Note: Additional fields introduced in v20 (e.g. `generated`, `trusted`, `block_height`, +/// `wallet_conflicts`, `involvesWatchonly`) are currently not modelled and therefore are +/// intentionally ignored during conversion; as such they have no dedicated error variants. +#[derive(Debug)] +pub enum ListSinceBlockTransactionError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `address` field failed. + Address(address::ParseError), + /// Conversion of the `amount` field failed. + Amount(ParseAmountError), + /// Conversion of the `fee` field failed. + Fee(ParseAmountError), + /// Conversion of the `block_hash` field failed. + BlockHash(hex::HexToArrayError), + /// Conversion of the `txid` field failed. + Txid(hex::HexToArrayError), + /// Conversion of an item in the `wallet_conflicts` list failed. + WalletConflicts(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockTransactionError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockTransactionError as E; + + match *self { + E::Numeric(ref e) => write_err!(f, "numeric"; e), + E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), + E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + E::WalletConflicts(ref e) => + write_err!(f, "conversion of an item in the `wallet_conflicts` list failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockTransactionError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockTransactionError as E; + + match *self { + E::Numeric(ref e) => Some(e), + E::Address(ref e) => Some(e), + E::Amount(ref e) => Some(e), + E::Fee(ref e) => Some(e), + E::BlockHash(ref e) => Some(e), + E::Txid(ref e) => Some(e), + E::WalletConflicts(ref e) => Some(e), + } + } +} + +impl From for ListSinceBlockTransactionError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} diff --git a/types/src/v20/wallet/into.rs b/types/src/v20/wallet/into.rs index 198cd93b..605ac1db 100644 --- a/types/src/v20/wallet/into.rs +++ b/types/src/v20/wallet/into.rs @@ -11,7 +11,8 @@ use bitcoin::{ use super::{ AddMultisigAddress, AddMultisigAddressError, GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetTransaction, GetTransactionDetail, - GetTransactionDetailError, GetTransactionError, + GetTransactionDetailError, GetTransactionError, ListSinceBlock, ListSinceBlockError, + ListSinceBlockTransaction, ListSinceBlockTransactionError, }; use crate::model; @@ -200,7 +201,7 @@ impl GetTransaction { Ok(model::GetTransaction { amount, - fee, + fee, // Option in model confirmations: self.confirmations, generated: self.generated, trusted: self.trusted, @@ -251,3 +252,85 @@ impl GetTransactionDetail { }) } } + +impl ListSinceBlock { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ListSinceBlockError as E; + + let transactions = self + .transactions + .into_iter() + .map(|tx| tx.into_model()) + .collect::, _>>() + .map_err(E::Transactions)?; + let removed = self + .removed + .into_iter() + .map(|tx| tx.into_model()) + .collect::, _>>() + .map_err(E::Removed)?; + let last_block = self.last_block.parse::().map_err(E::LastBlock)?; + + Ok(model::ListSinceBlock { transactions, removed, last_block }) + } +} + +impl ListSinceBlockTransaction { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model( + self, + ) -> Result { + use ListSinceBlockTransactionError as E; + + let address = self.address.parse::>().map_err(E::Address)?; + let category = self.category.into_model(); + let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?; + let vout = crate::to_u32(self.vout, "vout")?; + let fee = self + .fee + .map(|f| SignedAmount::from_btc(f).map_err(E::Fee)) + .transpose()? // optional historically + .unwrap_or_else(|| SignedAmount::from_sat(0)); + let block_hash = self.block_hash.parse::().map_err(E::BlockHash)?; + let block_height = crate::to_u32(self.block_height, "block_height")?; + let block_index = crate::to_u32(self.block_index, "block_index")?; + let txid = Some(self.txid.parse::().map_err(E::Txid)?); + let wallet_conflicts = self + .wallet_conflicts + .into_iter() + .map(|s| s.parse::().map_err(E::WalletConflicts)) + .collect::, _>>()?; + let bip125_replaceable = self.bip125_replaceable.into_model(); + + Ok(model::ListSinceBlockTransaction { + involves_watch_only: self.involves_watch_only, + address: Some(address), + category, + amount, + vout, + fee, + confirmations: self.confirmations, + generated: self.generated, + trusted: self.trusted, + block_hash: Some(block_hash), + block_height: Some(block_height), + block_index: Some(block_index), + block_time: Some(self.block_time), + txid, + wtxid: None, + wallet_conflicts: Some(wallet_conflicts), + replaced_by_txid: None, + replaces_txid: None, + mempool_conflicts: None, + to: self.to, + time: self.time, + time_received: self.time_received, + comment: self.comment, + bip125_replaceable, + parent_descriptors: None, + abandoned: self.abandoned, + label: self.label, + }) + } +} diff --git a/types/src/v20/wallet/mod.rs b/types/src/v20/wallet/mod.rs index ff15b8f8..7983cdbb 100644 --- a/types/src/v20/wallet/mod.rs +++ b/types/src/v20/wallet/mod.rs @@ -4,11 +4,13 @@ //! //! Types for methods found under the `== Wallet ==` section of the API docs. +mod error; mod into; use bitcoin::Transaction; use serde::{Deserialize, Serialize}; +pub use self::error::{ListSinceBlockError, ListSinceBlockTransactionError}; pub use super::{ AddMultisigAddressError, Bip125Replaceable, GetAddressInfoEmbeddedError, GetAddressInfoError, GetTransactionDetailError, GetTransactionError, ScriptType, TransactionCategory, @@ -249,3 +251,94 @@ pub struct GetTransactionDetail { /// Only available for the 'send' category of transactions. pub abandoned: Option, } + +/// Result of the JSON-RPC method `listsinceblock`. +/// +/// > listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed ) +/// > +/// > Get all transactions in blocks since block `blockhash`, or all transactions if omitted. +/// > If "blockhash" is no longer a part of the main chain, transactions from the fork point onward are included. +/// > Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the "removed" array. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlock { + /// All the transactions. + pub transactions: Vec, + /// Only present if `include_removed=true`. + /// + /// Note: transactions that were re-added in the active chain will appear as-is in this array, + /// and may thus have a positive confirmation count. + pub removed: Vec, + /// The hash of the block (target_confirmations-1) from the best block on the main chain. + /// + /// This is typically used to feed back into listsinceblock the next time you call it. So you + /// would generally use a target_confirmations of say 6, so you will be continually + /// re-notified of transactions until they've reached 6 confirmations plus any new ones. + #[serde(rename = "lastblock")] + pub last_block: String, +} + +/// Transaction item returned as part of `listsinceblock`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlockTransaction { + /// Only returns true if imported addresses were involved in transaction. + #[serde(rename = "involvesWatchonly")] + pub involves_watch_only: Option, + /// The bitcoin address of the transaction. + pub address: String, + /// The transaction category. + pub category: TransactionCategory, + /// The amount in BTC. + /// + /// This is negative for the 'send' category, and is positive for all other categories. + pub amount: f64, + /// The vout value. + pub vout: i64, + /// The amount of the fee in BTC. + /// + /// This is negative and only available for the 'send' category of transactions. + pub fee: Option, + /// The number of confirmations for the transaction. Negative confirmations means the + /// transaction conflicted that many blocks ago. + pub confirmations: i64, + /// Only present if transaction only input is a coinbase one. + pub generated: Option, + /// Only present if we consider transaction to be trusted and so safe to spend from. + pub trusted: Option, + /// The block hash containing the transaction. + #[serde(rename = "blockhash")] + pub block_hash: String, + /// The block height containing the transaction. + #[serde(rename = "blockheight")] + pub block_height: i64, + /// The index of the transaction in the block that includes it. + #[serde(rename = "blockindex")] + pub block_index: i64, + /// The block time expressed in UNIX epoch time. + #[serde(rename = "blocktime")] + pub block_time: u32, + /// The transaction id. + pub txid: String, + /// Conflicting transaction ids. + #[serde(rename = "walletconflicts")] + pub wallet_conflicts: Vec, + /// The transaction time expressed in UNIX epoch time. + pub time: u32, + /// The time received expressed in UNIX epoch time. + #[serde(rename = "timereceived")] + pub time_received: u32, + /// If a comment is associated with the transaction, only present if not empty. + pub comment: Option, + /// ("yes|no|unknown") Whether this transaction could be replaced due to BIP125 (replace-by-fee); + /// may be unknown for unconfirmed transactions not in the mempool + #[serde(rename = "bip125-replaceable")] + pub bip125_replaceable: Bip125Replaceable, + /// 'true' if the transaction has been abandoned (inputs are respendable). Only available for the + /// 'send' category of transactions. + pub abandoned: Option, + /// A comment for the address/transaction, if any. + pub label: Option, + /// If a comment to is associated with the transaction. + pub to: Option, +} diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index 5bbba1d4..ad1cd081 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -194,7 +194,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -281,8 +281,7 @@ pub use crate::{ GetTransactionDetailError, GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, - ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, @@ -308,6 +307,7 @@ pub use crate::{ }, v20::{ AddMultisigAddress, Banned, CreateMultisig, GenerateToDescriptor, GetAddressInfo, - GetAddressInfoEmbedded, GetTransaction, GetTransactionDetail, ListBanned, Logging, + GetAddressInfoEmbedded, GetTransaction, GetTransactionDetail, ListBanned, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, Logging, }, }; diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 21fbee1e..700104a5 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -204,7 +204,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -283,8 +283,7 @@ pub use crate::{ GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -309,7 +308,8 @@ pub use crate::{ }, v20::{ AddMultisigAddress, CreateMultisig, GenerateToDescriptor, GetTransaction, - GetTransactionDetail, + GetTransactionDetail, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, + ListSinceBlockTransactionError, }, v21::{ AddPeerAddress, Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index c2a90387..8bdc9f0a 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -196,7 +196,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -260,7 +260,8 @@ pub use self::{ util::CreateMultisig, wallet::{ AddMultisigAddress, GetTransaction, GetTransactionError, GetWalletInfo, - GetWalletInfoScanning, RestoreWallet, + GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, + ListSinceBlockTransactionError, RestoreWallet, }, }; #[doc(inline)] @@ -284,8 +285,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, diff --git a/types/src/v23/wallet/error.rs b/types/src/v23/wallet/error.rs index 3feae06c..019dcef1 100644 --- a/types/src/v23/wallet/error.rs +++ b/types/src/v23/wallet/error.rs @@ -35,6 +35,106 @@ pub enum GetTransactionError { Details(GetTransactionDetailError), } +/// Error when converting a `ListSinceBlock` type into the model type. +#[derive(Debug)] +pub enum ListSinceBlockError { + /// Conversion of the `transactions` field failed. + Transactions(ListSinceBlockTransactionError), + /// Conversion of the `removed` field failed. + Removed(ListSinceBlockTransactionError), + /// Conversion of the `last_block` field failed. + LastBlock(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockError::*; + match *self { + Transactions(ref e) => + write_err!(f, "conversion of the `transactions` field failed"; e), + Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockError::*; + match *self { + Transactions(ref e) => Some(e), + Removed(ref e) => Some(e), + LastBlock(ref e) => Some(e), + } + } +} + +/// Error when converting a `ListSinceBlockTransaction` type into the model type. +#[derive(Debug)] +pub enum ListSinceBlockTransactionError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `address` field failed. + Address(bitcoin::address::ParseError), + /// Conversion of the `amount` field failed. + Amount(ParseAmountError), + /// Conversion of the `fee` field failed. + Fee(ParseAmountError), + /// Conversion of the `block_hash` field failed. + BlockHash(hex::HexToArrayError), + /// Conversion of the `txid` field failed. + Txid(hex::HexToArrayError), + /// Conversion of the `wallet_conflicts` field failed. + WalletConflicts(hex::HexToArrayError), + /// Conversion of the `replaced_by_txid` field failed. + ReplacedByTxid(hex::HexToArrayError), + /// Conversion of the `replaces_txid` field failed. + ReplacesTxid(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockTransactionError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockTransactionError as E; + match *self { + E::Numeric(ref e) => write_err!(f, "numeric"; e), + E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), + E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + E::WalletConflicts(ref e) => + write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), + E::ReplacedByTxid(ref e) => + write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), + E::ReplacesTxid(ref e) => + write_err!(f, "conversion of the `replaces_txid` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockTransactionError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockTransactionError as E; + match *self { + E::Numeric(ref e) => Some(e), + E::Address(ref e) => Some(e), + E::Amount(ref e) => Some(e), + E::Fee(ref e) => Some(e), + E::BlockHash(ref e) => Some(e), + E::Txid(ref e) => Some(e), + E::WalletConflicts(ref e) => Some(e), + E::ReplacedByTxid(ref e) => Some(e), + E::ReplacesTxid(ref e) => Some(e), + } + } +} + +impl From for ListSinceBlockTransactionError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} + impl fmt::Display for GetTransactionError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use GetTransactionError as E; diff --git a/types/src/v23/wallet/into.rs b/types/src/v23/wallet/into.rs index 899f9365..c6b29f61 100644 --- a/types/src/v23/wallet/into.rs +++ b/types/src/v23/wallet/into.rs @@ -5,7 +5,8 @@ use bitcoin::{Address, BlockHash, ScriptBuf, SignedAmount, Transaction, Txid}; use super::{ AddMultisigAddress, AddMultisigAddressError, GetTransaction, GetTransactionError, - GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, + GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, + ListSinceBlockTransaction, ListSinceBlockTransactionError, }; use crate::model; @@ -60,7 +61,7 @@ impl GetTransaction { Ok(model::GetTransaction { amount, - fee, + fee, // Option in model confirmations: self.confirmations, generated: self.generated, trusted: self.trusted, @@ -142,3 +143,90 @@ impl GetWalletInfo { }) } } + +impl ListSinceBlock { + pub fn into_model(self) -> Result { + use ListSinceBlockError as E; + + let transactions = self + .transactions + .into_iter() + .map(|t| t.into_model()) + .collect::, _>>() + .map_err(E::Transactions)?; + let removed = self + .removed + .into_iter() + .map(|t| t.into_model()) + .collect::, _>>() + .map_err(E::Removed)?; + let last_block = self.last_block.parse::().map_err(E::LastBlock)?; + + Ok(model::ListSinceBlock { transactions, removed, last_block }) + } +} +impl ListSinceBlockTransaction { + pub fn into_model( + self, + ) -> Result { + use ListSinceBlockTransactionError as E; + + let address = self.address.parse::>().map_err(E::Address)?; + let category = self.category.into_model(); + let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?; + let vout = crate::to_u32(self.vout, "vout")?; + let fee = self + .fee + .map(|f| SignedAmount::from_btc(f).map_err(E::Fee)) + .transpose()? // optional historically + .unwrap_or_else(|| SignedAmount::from_sat(0)); + let block_hash = + self.block_hash.map(|h| h.parse::().map_err(E::BlockHash)).transpose()?; + let block_height = + self.block_height.map(|h| crate::to_u32(h, "block_height")).transpose()?; + let block_index = self.block_index.map(|h| crate::to_u32(h, "block_index")).transpose()?; + let txid = self.txid.parse::().map_err(E::Txid)?; + let wallet_conflicts = self + .wallet_conflicts + .into_iter() + .map(|s| s.parse::().map_err(E::WalletConflicts)) + .collect::, _>>()?; + let replaced_by_txid = self + .replaced_by_txid + .map(|s| s.parse::().map_err(E::ReplacedByTxid)) + .transpose()?; + let replaces_txid = + self.replaces_txid.map(|s| s.parse::().map_err(E::ReplacesTxid)).transpose()?; + let bip125_replaceable = self.bip125_replaceable.into_model(); + + Ok(model::ListSinceBlockTransaction { + involves_watch_only: self.involves_watch_only, + address: Some(address), + category, + amount, + vout, + fee, + confirmations: self.confirmations, + generated: self.generated, + trusted: self.trusted, + block_hash, + block_height, + block_index, + block_time: self.block_time, + txid: Some(txid), + wtxid: None, + wallet_conflicts: Some(wallet_conflicts), + replaced_by_txid, + replaces_txid, + mempool_conflicts: None, + to: self.to, + time: self.time, + time_received: self.time_received, + comment: self.comment, + bip125_replaceable, + parent_descriptors: None, + abandoned: self.abandoned, + label: self.label, + }) + } +} diff --git a/types/src/v23/wallet/mod.rs b/types/src/v23/wallet/mod.rs index f25d6fcc..2209e720 100644 --- a/types/src/v23/wallet/mod.rs +++ b/types/src/v23/wallet/mod.rs @@ -10,7 +10,7 @@ mod into; use bitcoin::Transaction; use serde::{Deserialize, Serialize}; -pub use self::error::GetTransactionError; +pub use self::error::{GetTransactionError, ListSinceBlockError, ListSinceBlockTransactionError}; pub use super::{ AddMultisigAddressError, Bip125Replaceable, GetTransactionDetail, GetTransactionDetailError, GetWalletInfoError, @@ -189,3 +189,92 @@ pub enum GetWalletInfoScanning { /// Not scanning (false). NotScanning(bool), } + +/// Result of the JSON-RPC method `listsinceblock`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlock { + /// All the transactions. + pub transactions: Vec, + /// Only present if `include_removed=true`. + /// + /// Note: transactions that were re-added in the active chain will appear as-is in this array, + /// and may thus have a positive confirmation count. + pub removed: Vec, + /// The hash of the block (target_confirmations-1) from the best block on the main chain. + /// + /// This is typically used to feed back into listsinceblock the next time you call it. So you + /// would generally use a target_confirmations of say 6, so you will be continually + /// re-notified of transactions until they've reached 6 confirmations plus any new ones. + #[serde(rename = "lastblock")] + pub last_block: String, +} + +/// Transaction item returned as part of `listsinceblock`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlockTransaction { + /// Only returns true if imported addresses were involved in transaction. + #[serde(rename = "involvesWatchonly")] + pub involves_watch_only: Option, + /// The bitcoin address of the transaction. + pub address: String, + /// The transaction category. + pub category: super::TransactionCategory, + /// The amount in BTC. + /// + /// This is negative for the 'send' category, and is positive for all other categories. + pub amount: f64, + /// The vout value. + pub vout: i64, + /// The amount of the fee in BTC. + /// + /// This is negative and only available for the 'send' category of transactions. + pub fee: Option, + /// The number of confirmations for the transaction. Negative confirmations means the + /// transaction conflicted that many blocks ago. + pub confirmations: i64, + /// Only present if transaction only input is a coinbase one. + pub generated: Option, + /// Only present if we consider transaction to be trusted and so safe to spend from. + pub trusted: Option, + /// The block hash containing the transaction. + #[serde(rename = "blockhash")] + pub block_hash: Option, + /// The block height containing the transaction. + #[serde(rename = "blockheight")] + pub block_height: Option, + /// The index of the transaction in the block that includes it. + #[serde(rename = "blockindex")] + pub block_index: Option, + /// The block time expressed in UNIX epoch time. + #[serde(rename = "blocktime")] + pub block_time: Option, + /// The transaction id. + pub txid: String, + /// Conflicting transaction ids. + #[serde(rename = "walletconflicts")] + pub wallet_conflicts: Vec, + /// The txid if this tx was replaced. + pub replaced_by_txid: Option, + /// The txid if this tx replaces one. + pub replaces_txid: Option, + /// If a comment is associated with the transaction, only present if not empty. + pub comment: Option, + /// If a comment to is associated with the transaction. + pub to: Option, + /// The transaction time expressed in UNIX epoch time. + pub time: u32, + /// The time received expressed in UNIX epoch time. + #[serde(rename = "timereceived")] + pub time_received: u32, + /// ("yes|no|unknown") Whether this transaction could be replaced due to BIP125 (replace-by-fee); + /// may be unknown for unconfirmed transactions not in the mempool + #[serde(rename = "bip125-replaceable")] + pub bip125_replaceable: Bip125Replaceable, + /// 'true' if the transaction has been abandoned (inputs are respendable). Only available for the + /// 'send' category of transactions. + pub abandoned: Option, + /// A comment for the address/transaction, if any. + pub label: Option, +} diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index e5cd611e..bc93b0c9 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -198,7 +198,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -258,8 +258,9 @@ pub use self::{ TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, wallet::{ - GetTransaction, GetTransactionDetail, GetTransactionError, ListUnspent, ListUnspentItem, - MigrateWallet, SendAll, SendAllError, SimulateRawTransaction, + GetTransaction, GetTransactionDetail, GetTransactionError, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListUnspent, ListUnspentItem, MigrateWallet, SendAll, SendAllError, SimulateRawTransaction, }, }; #[doc(inline)] @@ -283,8 +284,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, diff --git a/types/src/v24/wallet/error.rs b/types/src/v24/wallet/error.rs index 668438a5..c57aae96 100644 --- a/types/src/v24/wallet/error.rs +++ b/types/src/v24/wallet/error.rs @@ -91,6 +91,110 @@ impl From for GetTransactionError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } +/// Error when converting a `ListSinceBlock` type into the model type. +#[derive(Debug)] +pub enum ListSinceBlockError { + /// Conversion of the `transactions` field failed. + Transactions(ListSinceBlockTransactionError), + /// Conversion of the `removed` field failed. + Removed(ListSinceBlockTransactionError), + /// Conversion of the `last_block` field failed. + LastBlock(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockError::*; + match *self { + Transactions(ref e) => + write_err!(f, "conversion of the `transactions` field failed"; e), + Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockError::*; + match *self { + Transactions(ref e) => Some(e), + Removed(ref e) => Some(e), + LastBlock(ref e) => Some(e), + } + } +} + +/// Error when converting a `ListSinceBlockTransaction` type into the model type. +#[derive(Debug)] +pub enum ListSinceBlockTransactionError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `address` field failed. + Address(bitcoin::address::ParseError), + /// Conversion of the `amount` field failed. + Amount(ParseAmountError), + /// Conversion of the `fee` field failed. + Fee(ParseAmountError), + /// Conversion of the `block_hash` field failed. + BlockHash(hex::HexToArrayError), + /// Conversion of the `txid` field failed. + Txid(hex::HexToArrayError), + /// Conversion of the `wtxid` field failed. + Wtxid(hex::HexToArrayError), + /// Conversion of the `wallet_conflicts` field failed. + WalletConflicts(hex::HexToArrayError), + /// Conversion of the `replaced_by_txid` field failed. + ReplacedByTxid(hex::HexToArrayError), + /// Conversion of the `replaces_txid` field failed. + ReplacesTxid(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockTransactionError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockTransactionError as E; + match *self { + E::Numeric(ref e) => write_err!(f, "numeric"; e), + E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), + E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + E::WalletConflicts(ref e) => + write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), + E::ReplacedByTxid(ref e) => + write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), + E::ReplacesTxid(ref e) => + write_err!(f, "conversion of the `replaces_txid` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockTransactionError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockTransactionError as E; + match *self { + E::Numeric(ref e) => Some(e), + E::Address(ref e) => Some(e), + E::Amount(ref e) => Some(e), + E::Fee(ref e) => Some(e), + E::BlockHash(ref e) => Some(e), + E::Txid(ref e) => Some(e), + E::Wtxid(ref e) => Some(e), + E::WalletConflicts(ref e) => Some(e), + E::ReplacedByTxid(ref e) => Some(e), + E::ReplacesTxid(ref e) => Some(e), + } + } +} + +impl From for ListSinceBlockTransactionError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} + /// Error when converting a `SendAll` type into the model type. #[derive(Debug)] pub enum SendAllError { diff --git a/types/src/v24/wallet/into.rs b/types/src/v24/wallet/into.rs index bf391156..88600290 100644 --- a/types/src/v24/wallet/into.rs +++ b/types/src/v24/wallet/into.rs @@ -6,6 +6,7 @@ use bitcoin::{Address, BlockHash, ScriptBuf, SignedAmount, Transaction, Txid}; use super::{ GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, + ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, ListUnspent, ListUnspentItem, ListUnspentItemError, SendAll, SendAllError, SimulateRawTransaction, }; @@ -98,6 +99,96 @@ impl GetTransactionDetail { } } +impl ListSinceBlock { + pub fn into_model(self) -> Result { + use ListSinceBlockError as E; + + let transactions = self + .transactions + .into_iter() + .map(|t| t.into_model()) + .collect::, _>>() + .map_err(E::Transactions)?; + let removed = self + .removed + .into_iter() + .map(|t| t.into_model()) + .collect::, _>>() + .map_err(E::Removed)?; + let last_block = self.last_block.parse::().map_err(E::LastBlock)?; + + Ok(model::ListSinceBlock { transactions, removed, last_block }) + } +} + +impl ListSinceBlockTransaction { + pub fn into_model( + self, + ) -> Result { + use ListSinceBlockTransactionError as E; + + let address = + self.address.map(|a| a.parse::>().map_err(E::Address)).transpose()?; + let category = self.category.into_model(); + let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?; + let vout = crate::to_u32(self.vout, "vout")?; + let fee = self + .fee + .map(|f| SignedAmount::from_btc(f).map_err(E::Fee)) + .transpose()? // optional historically + .unwrap_or_else(|| SignedAmount::from_sat(0)); + let block_hash = + self.block_hash.map(|h| h.parse::().map_err(E::BlockHash)).transpose()?; + let block_height = + self.block_height.map(|h| crate::to_u32(h, "block_height")).transpose()?; + let block_index = self.block_index.map(|h| crate::to_u32(h, "block_index")).transpose()?; + let txid = self.txid.parse::().map_err(E::Txid)?; + let wtxid = self.wtxid.parse::().map_err(E::Wtxid)?; + let wallet_conflicts = self + .wallet_conflicts + .into_iter() + .map(|s| s.parse::().map_err(E::WalletConflicts)) + .collect::, _>>()?; + let replaced_by_txid = self + .replaced_by_txid + .map(|s| s.parse::().map_err(E::ReplacedByTxid)) + .transpose()?; + let replaces_txid = + self.replaces_txid.map(|s| s.parse::().map_err(E::ReplacesTxid)).transpose()?; + let bip125_replaceable = self.bip125_replaceable.into_model(); + + Ok(model::ListSinceBlockTransaction { + involves_watch_only: self.involves_watch_only, + address, + category, + amount, + vout, + fee, + confirmations: self.confirmations, + generated: self.generated, + trusted: self.trusted, + block_hash, + block_height, + block_index, + block_time: self.block_time, + txid: Some(txid), + wtxid: Some(wtxid), + wallet_conflicts: Some(wallet_conflicts), + replaced_by_txid, + replaces_txid, + mempool_conflicts: None, + to: self.to, + time: self.time, + time_received: self.time_received, + comment: self.comment, + bip125_replaceable, + parent_descriptors: self.parent_descriptors, + abandoned: self.abandoned, + label: self.label, + }) + } +} + impl ListUnspent { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v24/wallet/mod.rs b/types/src/v24/wallet/mod.rs index da24b7bc..cdaca955 100644 --- a/types/src/v24/wallet/mod.rs +++ b/types/src/v24/wallet/mod.rs @@ -10,7 +10,9 @@ mod into; use bitcoin::Transaction; use serde::{Deserialize, Serialize}; -pub use self::error::{GetTransactionError, SendAllError}; +pub use self::error::{ + GetTransactionError, ListSinceBlockError, ListSinceBlockTransactionError, SendAllError, +}; pub use super::{ Bip125Replaceable, GetTransactionDetailError, ListUnspentItemError, TransactionCategory, }; @@ -118,6 +120,100 @@ pub struct GetTransactionDetail { pub parent_descriptors: Option>, } +/// Result of the JSON-RPC method `listsinceblock`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlock { + /// All the transactions. + pub transactions: Vec, + /// Only present if `include_removed=true`. + /// + /// Note: transactions that were re-added in the active chain will appear as-is in this array, + /// and may thus have a positive confirmation count. + pub removed: Vec, + /// The hash of the block (target_confirmations-1) from the best block on the main chain. + /// + /// This is typically used to feed back into listsinceblock the next time you call it. So you + /// would generally use a target_confirmations of say 6, so you will be continually + /// re-notified of transactions until they've reached 6 confirmations plus any new ones. + #[serde(rename = "lastblock")] + pub last_block: String, +} + +/// Transaction item returned as part of `listsinceblock`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlockTransaction { + /// Only returns true if imported addresses were involved in transaction. + #[serde(rename = "involvesWatchonly")] + pub involves_watch_only: Option, + /// The bitcoin address of the transaction. + pub address: Option, + /// The transaction category. + pub category: super::TransactionCategory, + /// The amount in BTC. + /// + /// This is negative for the 'send' category, and is positive for all other categories. + pub amount: f64, + /// The vout value. + pub vout: i64, + /// The amount of the fee in BTC. + /// + /// This is negative and only available for the 'send' category of transactions. + pub fee: Option, + /// The number of confirmations for the transaction. Negative confirmations means the + /// transaction conflicted that many blocks ago. + pub confirmations: i64, + /// Only present if transaction only input is a coinbase one. + pub generated: Option, + /// Only present if we consider transaction to be trusted and so safe to spend from. + pub trusted: Option, + /// The block hash containing the transaction. + #[serde(rename = "blockhash")] + pub block_hash: Option, + /// The block height containing the transaction. + #[serde(rename = "blockheight")] + pub block_height: Option, + /// The index of the transaction in the block that includes it. + #[serde(rename = "blockindex")] + pub block_index: Option, + /// The block time expressed in UNIX epoch time. + #[serde(rename = "blocktime")] + pub block_time: Option, + /// The transaction id. + pub txid: String, + /// The hash of serialized transaction, including witness data. + pub wtxid: String, + /// Conflicting transaction ids. + #[serde(rename = "walletconflicts")] + pub wallet_conflicts: Vec, + /// The txid if this tx was replaced. + pub replaced_by_txid: Option, + /// The txid if this tx replaces one. + pub replaces_txid: Option, + /// If a comment is associated with the transaction, only present if not empty. + pub comment: Option, + /// If a comment to is associated with the transaction. + pub to: Option, + /// The transaction time expressed in UNIX epoch time. + pub time: u32, + /// The time received expressed in UNIX epoch time. + #[serde(rename = "timereceived")] + pub time_received: u32, + /// ("yes|no|unknown") Whether this transaction could be replaced due to BIP125 (replace-by-fee); + /// may be unknown for unconfirmed transactions not in the mempool + #[serde(rename = "bip125-replaceable")] + pub bip125_replaceable: Bip125Replaceable, + /// Only if 'category' is 'received'. List of parent descriptors for the scriptPubKey of this coin. + #[serde(rename = "parent_descs")] + pub parent_descriptors: Option>, + /// 'true' if the transaction has been abandoned (inputs are respendable). Only available for the + /// 'send' category of transactions. + pub abandoned: Option, + /// A comment for the address/transaction, if any. + pub label: Option, +} + /// Result of the JSON-RPC method `listunspent`. /// /// > listunspent ( minconf maxconf ["addresses",...] `[include_unsafe]` `[query_options]`) diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 4c960b55..08211330 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -199,7 +199,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -279,8 +279,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -322,9 +321,10 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetPeerInfo, GetTransaction, GetTransactionDetail, GetTransactionError, - GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, ListUnspent, ListUnspentItem, - MempoolEntry, MigrateWallet, PeerInfo, Proprietary, PsbtInput, PsbtOutput, SendAll, - SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, - TaprootScriptPathSig, + GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, PeerInfo, Proprietary, + PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, + TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, }; diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index b9d37fc3..edd288b5 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -207,7 +207,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -295,8 +295,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -337,9 +336,10 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTransactionDetail, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, - PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, - TaprootScript, TaprootScriptPathSig, + ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, + ListSinceBlockTransactionError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, + Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, + TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 51321bce..f7b731fa 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -207,7 +207,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -272,8 +272,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -314,9 +313,10 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTransactionDetail, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, - PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, - TaprootScript, TaprootScriptPathSig, + ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, + ListSinceBlockTransactionError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, + Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, + TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 92055cc2..8e1384fb 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -209,7 +209,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -269,7 +269,8 @@ pub use self::{ }, wallet::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, - GetTransaction, HdKey, HdKeyDescriptor, + GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, ListSinceBlockError, + ListSinceBlockTransaction, ListSinceBlockTransactionError, }, }; #[doc(inline)] @@ -292,8 +293,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, diff --git a/types/src/v28/wallet/error.rs b/types/src/v28/wallet/error.rs index 5ad7ddfa..6d5e4e51 100644 --- a/types/src/v28/wallet/error.rs +++ b/types/src/v28/wallet/error.rs @@ -2,7 +2,8 @@ use core::fmt; -use bitcoin::bip32; +use bitcoin::amount::ParseAmountError; +use bitcoin::{bip32, hex}; use crate::error::write_err; use crate::NumericError; @@ -44,3 +45,107 @@ impl std::error::Error for GetHdKeysError { impl From for GetHdKeysError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } + +/// Error when converting a `ListSinceBlock` type into the model type. +#[derive(Debug)] +pub enum ListSinceBlockError { + /// Conversion of the `transactions` field failed. + Transactions(ListSinceBlockTransactionError), + /// Conversion of the `removed` field failed. + Removed(ListSinceBlockTransactionError), + /// Conversion of the `last_block` field failed. + LastBlock(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockError::*; + match *self { + Transactions(ref e) => + write_err!(f, "conversion of the `transactions` field failed"; e), + Removed(ref e) => write_err!(f, "conversion of the `removed` field failed"; e), + LastBlock(ref e) => write_err!(f, "conversion of the `last_block` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockError::*; + match *self { + Transactions(ref e) => Some(e), + Removed(ref e) => Some(e), + LastBlock(ref e) => Some(e), + } + } +} + +/// Error when converting a `ListSinceBlockTransaction` type into the model type. +#[derive(Debug)] +pub enum ListSinceBlockTransactionError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `address` field failed. + Address(bitcoin::address::ParseError), + /// Conversion of the `amount` field failed. + Amount(ParseAmountError), + /// Conversion of the `fee` field failed. + Fee(ParseAmountError), + /// Conversion of the `block_hash` field failed. + BlockHash(hex::HexToArrayError), + /// Conversion of the `txid` field failed. + Txid(hex::HexToArrayError), + /// Conversion of the `wtxid` field failed. + Wtxid(hex::HexToArrayError), + /// Conversion of the `wallet_conflicts` field failed. + WalletConflicts(hex::HexToArrayError), + /// Conversion of the `replaced_by_txid` field failed. + ReplacedByTxid(hex::HexToArrayError), + /// Conversion of the `replaces_txid` field failed. + ReplacesTxid(hex::HexToArrayError), +} + +impl fmt::Display for ListSinceBlockTransactionError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use ListSinceBlockTransactionError as E; + match *self { + E::Numeric(ref e) => write_err!(f, "numeric"; e), + E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), + E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), + E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), + E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), + E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), + E::Wtxid(ref e) => write_err!(f, "conversion of the `wtxid` field failed"; e), + E::WalletConflicts(ref e) => + write_err!(f, "conversion of the `wallet_conflicts` field failed"; e), + E::ReplacedByTxid(ref e) => + write_err!(f, "conversion of the `replaced_by_txid` field failed"; e), + E::ReplacesTxid(ref e) => + write_err!(f, "conversion of the `replaces_txid` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ListSinceBlockTransactionError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ListSinceBlockTransactionError as E; + match *self { + E::Numeric(ref e) => Some(e), + E::Address(ref e) => Some(e), + E::Amount(ref e) => Some(e), + E::Fee(ref e) => Some(e), + E::BlockHash(ref e) => Some(e), + E::Txid(ref e) => Some(e), + E::Wtxid(ref e) => Some(e), + E::WalletConflicts(ref e) => Some(e), + E::ReplacedByTxid(ref e) => Some(e), + E::ReplacesTxid(ref e) => Some(e), + } + } +} + +impl From for ListSinceBlockTransactionError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} diff --git a/types/src/v28/wallet/into.rs b/types/src/v28/wallet/into.rs index 4b0d26bb..9d2d3698 100644 --- a/types/src/v28/wallet/into.rs +++ b/types/src/v28/wallet/into.rs @@ -11,7 +11,8 @@ use bitcoin::{ use super::{ GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, - GetHdKeys, GetHdKeysError, GetTransaction, GetTransactionError, + GetHdKeys, GetHdKeysError, GetTransaction, GetTransactionError, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, }; use crate::model; @@ -249,3 +250,96 @@ impl GetTransaction { }) } } + +impl ListSinceBlock { + pub fn into_model(self) -> Result { + use ListSinceBlockError as E; + + let transactions = self + .transactions + .into_iter() + .map(|t| t.into_model()) + .collect::, _>>() + .map_err(E::Transactions)?; + let removed = self + .removed + .into_iter() + .map(|t| t.into_model()) + .collect::, _>>() + .map_err(E::Removed)?; + let last_block = self.last_block.parse::().map_err(E::LastBlock)?; + + Ok(model::ListSinceBlock { transactions, removed, last_block }) + } +} + +impl ListSinceBlockTransaction { + pub fn into_model( + self, + ) -> Result { + use ListSinceBlockTransactionError as E; + + let address = + self.address.map(|s| s.parse::>().map_err(E::Address)).transpose()?; + let category = self.category.into_model(); + let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?; + let vout = crate::to_u32(self.vout, "vout")?; + let fee = self + .fee + .map(|f| SignedAmount::from_btc(f).map_err(E::Fee)) + .transpose()? // optional historically + .unwrap_or_else(|| SignedAmount::from_sat(0)); + let block_hash = + self.block_hash.map(|s| s.parse::().map_err(E::BlockHash)).transpose()?; + let block_height = + self.block_height.map(|h| crate::to_u32(h, "block_height")).transpose()?; + let block_index = self.block_index.map(|h| crate::to_u32(h, "block_index")).transpose()?; + let txid = self.txid.parse::().map_err(E::Txid)?; + let wtxid = self.wtxid.parse::().map_err(E::Wtxid)?; + let wallet_conflicts = self + .wallet_conflicts + .into_iter() + .map(|s| s.parse::().map_err(E::WalletConflicts)) + .collect::, _>>()?; + let replaced_by_txid = self + .replaced_by_txid + .map(|s| s.parse::().map_err(E::ReplacedByTxid)) + .transpose()?; + let replaces_txid = + self.replaces_txid.map(|s| s.parse::().map_err(E::ReplacesTxid)).transpose()?; + let mempool_conflicts = self + .mempool_conflicts + .map(|v| v.into_iter().filter_map(|s| s.parse::().ok()).collect::>()); + let bip125_replaceable = self.bip125_replaceable.into_model(); + + Ok(model::ListSinceBlockTransaction { + involves_watch_only: self.involves_watch_only, + address, + category, + amount, + vout, + fee, + confirmations: self.confirmations, + generated: self.generated, + trusted: self.trusted, + block_hash, + block_height, + block_index, + block_time: self.block_time, + txid: Some(txid), + wtxid: Some(wtxid), + wallet_conflicts: Some(wallet_conflicts), + replaced_by_txid, + replaces_txid, + mempool_conflicts, + to: self.to, + time: self.time, + time_received: self.time_received, + comment: self.comment, + bip125_replaceable, + parent_descriptors: self.parent_descriptors, + abandoned: self.abandoned, + label: self.label, + }) + } +} diff --git a/types/src/v28/wallet/mod.rs b/types/src/v28/wallet/mod.rs index e8e0f5b9..21e68c8c 100644 --- a/types/src/v28/wallet/mod.rs +++ b/types/src/v28/wallet/mod.rs @@ -8,9 +8,9 @@ mod error; mod into; use bitcoin::Transaction; -pub use error::GetHdKeysError; use serde::{Deserialize, Serialize}; +pub use self::error::{GetHdKeysError, ListSinceBlockError, ListSinceBlockTransactionError}; pub use super::{ Bip125Replaceable, GetAddressInfoEmbeddedError, GetAddressInfoError, GetTransactionDetail, GetTransactionError, LastProcessedBlock, ScriptType, @@ -275,3 +275,100 @@ pub struct GetTransaction { #[serde(rename = "lastprocessedblock")] pub last_processed_block: Option, } + +/// Result of the JSON-RPC method `listsinceblock`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlock { + /// All the transactions. + pub transactions: Vec, + /// Only present if `include_removed=true`. + /// + /// Note: transactions that were re-added in the active chain will appear as-is in this array, + /// and may thus have a positive confirmation count. + pub removed: Vec, + /// The hash of the block (target_confirmations-1) from the best block on the main chain. + /// + /// This is typically used to feed back into listsinceblock the next time you call it. So you + /// would generally use a target_confirmations of say 6, so you will be continually + /// re-notified of transactions until they've reached 6 confirmations plus any new ones. + #[serde(rename = "lastblock")] + pub last_block: String, +} + +/// Transaction item returned as part of `listsinceblock`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListSinceBlockTransaction { + /// Only returns true if imported addresses were involved in transaction. + #[serde(rename = "involvesWatchonly")] + pub involves_watch_only: Option, + /// The bitcoin address of the transaction. + pub address: Option, + /// The transaction category. + pub category: super::TransactionCategory, + /// The amount in BTC. + /// + /// This is negative for the 'send' category, and is positive for all other categories. + pub amount: f64, + /// The vout value. + pub vout: i64, + /// The amount of the fee in BTC. + /// + /// This is negative and only available for the 'send' category of transactions. + pub fee: Option, + /// The number of confirmations for the transaction. Negative confirmations means the + /// transaction conflicted that many blocks ago. + pub confirmations: i64, + /// Only present if transaction only input is a coinbase one. + pub generated: Option, + /// Only present if we consider transaction to be trusted and so safe to spend from. + pub trusted: Option, + /// The block hash containing the transaction. + #[serde(rename = "blockhash")] + pub block_hash: Option, + /// The block height containing the transaction. + #[serde(rename = "blockheight")] + pub block_height: Option, + /// The index of the transaction in the block that includes it. + #[serde(rename = "blockindex")] + pub block_index: Option, + /// The block time expressed in UNIX epoch time. + #[serde(rename = "blocktime")] + pub block_time: Option, + /// The transaction id. + pub txid: String, + /// The hash of serialized transaction, including witness data. + pub wtxid: String, + /// Conflicting transaction ids. + #[serde(rename = "walletconflicts")] + pub wallet_conflicts: Vec, + /// The txid if this tx was replaced. + pub replaced_by_txid: Option, + /// The txid if this tx replaces one. + pub replaces_txid: Option, + /// If a comment is associated with the transaction, only present if not empty. + pub comment: Option, + /// Transactions in the mempool that directly conflict with either this transaction or an ancestor transaction. + #[serde(rename = "mempoolconflicts")] + pub mempool_conflicts: Option>, + /// If a comment to is associated with the transaction. + pub to: Option, + /// The transaction time expressed in UNIX epoch time. + pub time: u32, + /// The time received expressed in UNIX epoch time. + #[serde(rename = "timereceived")] + pub time_received: u32, + /// ("yes|no|unknown") Whether this transaction could be replaced due to BIP125 (replace-by-fee); + /// may be unknown for unconfirmed transactions not in the mempool + #[serde(rename = "bip125-replaceable")] + pub bip125_replaceable: Bip125Replaceable, + /// Only if 'category' is 'received'. List of parent descriptors for the scriptPubKey of this coin. + #[serde(rename = "parent_descs")] + pub parent_descriptors: Option>, + /// 'true' if the transaction has been abandoned (inputs are respendable). Only available for the + /// 'send' category of transactions. + pub abandoned: Option, + /// A comment for the address/transaction, if any. + pub label: Option, +} diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 67683151..741a2cf5 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -210,7 +210,7 @@ //! | psbtbumpfee | version + model | | //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | -//! | listsinceblock | version + model | UNTESTED | +//! | listsinceblock | version + model | | //! | listtransactions | version + model | UNTESTED | //! | listunspent | version + model | | //! | listwalletdir | version | | @@ -289,8 +289,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -349,8 +348,9 @@ pub use crate::{ v27::{GetPrioritisedTransactions, PrioritisedTransaction}, v28::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, - GetNetworkInfo, GetTransaction, HdKey, HdKeyDescriptor, Logging, SubmitPackage, - SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, + GetNetworkInfo, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, + ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, Logging, + SubmitPackage, SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, }, }; From c397fb352765e909c355dc2f18fd52171a1999fd Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Thu, 28 Aug 2025 20:19:42 +0100 Subject: [PATCH 3/5] Unify ListSinceBlock and ListTransactions item Both RPCs return the same shape sub type. Including the changes in versions between 17 and 29. ListSinceBlockTransaction has all the changes implemented up to v29. Use ListSinceBlockTransaction for both RPCs including the error and into functions. Rename it to TransactionItem to be more general. Remove ListTransactionsItem and associated error and into functions. --- integration_test/tests/wallet.rs | 2 +- types/src/model/mod.rs | 10 ++--- types/src/model/wallet.rs | 62 +++------------------------- types/src/v17/mod.rs | 4 +- types/src/v17/wallet/error.rs | 70 ++++---------------------------- types/src/v17/wallet/into.rs | 49 +++------------------- types/src/v17/wallet/mod.rs | 69 ++++--------------------------- types/src/v18/mod.rs | 4 +- types/src/v19/mod.rs | 4 +- types/src/v20/mod.rs | 6 +-- types/src/v20/wallet/error.rs | 18 ++++---- types/src/v20/wallet/into.rs | 12 +++--- types/src/v20/wallet/mod.rs | 8 ++-- types/src/v21/mod.rs | 4 +- types/src/v22/mod.rs | 6 +-- types/src/v23/mod.rs | 6 +-- types/src/v23/wallet/error.rs | 18 ++++---- types/src/v23/wallet/into.rs | 12 +++--- types/src/v23/wallet/mod.rs | 8 ++-- types/src/v24/mod.rs | 4 +- types/src/v24/wallet/error.rs | 18 ++++---- types/src/v24/wallet/into.rs | 15 +++---- types/src/v24/wallet/mod.rs | 8 ++-- types/src/v25/mod.rs | 4 +- types/src/v26/mod.rs | 6 +-- types/src/v27/mod.rs | 6 +-- types/src/v28/mod.rs | 4 +- types/src/v28/wallet/error.rs | 18 ++++---- types/src/v28/wallet/into.rs | 12 +++--- types/src/v28/wallet/mod.rs | 8 ++-- types/src/v29/mod.rs | 4 +- 31 files changed, 136 insertions(+), 343 deletions(-) diff --git a/integration_test/tests/wallet.rs b/integration_test/tests/wallet.rs index f6572522..1007e9bf 100644 --- a/integration_test/tests/wallet.rs +++ b/integration_test/tests/wallet.rs @@ -606,7 +606,7 @@ fn wallet__list_since_block__modelled() { let model: Result = json.into_model(); let model = model.unwrap(); - let first_tx: mtype::ListSinceBlockTransaction = model.transactions[0].clone(); + let first_tx: mtype::TransactionItem = model.transactions[0].clone(); assert_eq!(first_tx.txid.unwrap().to_string().len(), 64); } diff --git a/types/src/model/mod.rs b/types/src/model/mod.rs index 59200227..5f67f899 100644 --- a/types/src/model/mod.rs +++ b/types/src/model/mod.rs @@ -58,10 +58,10 @@ pub use self::{ GetTransactionDetail, GetUnconfirmedBalance, GetWalletInfo, GetWalletInfoScanning, HdKey, HdKeyDescriptor, LastProcessedBlock, ListAddressGroupings, ListAddressGroupingsItem, ListLockUnspent, ListLockUnspentItem, ListReceivedByAddress, ListReceivedByAddressItem, - ListReceivedByLabel, ListReceivedByLabelItem, ListSinceBlock, ListSinceBlockTransaction, - ListTransactions, ListTransactionsItem, ListUnspent, ListUnspentItem, ListWallets, - LoadWallet, PsbtBumpFee, RescanBlockchain, ScriptType, Send, SendAll, SendMany, - SendManyVerbose, SendToAddress, SignMessage, SimulateRawTransaction, TransactionCategory, - UnloadWallet, WalletCreateFundedPsbt, WalletDisplayAddress, WalletProcessPsbt, + ListReceivedByLabel, ListReceivedByLabelItem, ListSinceBlock, ListTransactions, + ListUnspent, ListUnspentItem, ListWallets, LoadWallet, PsbtBumpFee, RescanBlockchain, + ScriptType, Send, SendAll, SendMany, SendManyVerbose, SendToAddress, SignMessage, + SimulateRawTransaction, TransactionCategory, TransactionItem, UnloadWallet, + WalletCreateFundedPsbt, WalletDisplayAddress, WalletProcessPsbt, }, }; diff --git a/types/src/model/wallet.rs b/types/src/model/wallet.rs index 7ea51128..9dfe877b 100644 --- a/types/src/model/wallet.rs +++ b/types/src/model/wallet.rs @@ -590,12 +590,12 @@ pub struct ListReceivedByLabelItem { #[serde(deny_unknown_fields)] pub struct ListSinceBlock { /// All the transactions. - pub transactions: Vec, + pub transactions: Vec, /// Only present if `include_removed=true`. /// /// Note: transactions that were re-added in the active chain will appear as-is in this array, /// and may thus have a positive confirmation count. - pub removed: Vec, + pub removed: Vec, /// The hash of the block (target_confirmations-1) from the best block on the main chain. /// /// This is typically used to feed back into listsinceblock the next time you call it. So you @@ -604,11 +604,10 @@ pub struct ListSinceBlock { pub last_block: BlockHash, } -/// Transaction list item, part of `ListSinceBlock`. -// https://github.com/rust-bitcoin/rust-bitcoin/issues/3516 +/// Transaction item, part of `listsinceblock` and `listtransactions`. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListSinceBlockTransaction { +pub struct TransactionItem { /// Only returns true if imported addresses were involved in transaction. pub involves_watch_only: Option, /// The bitcoin address of the transaction. @@ -690,58 +689,7 @@ pub struct ListSinceBlockTransaction { /// Models the result of JSON-RPC method `listtransactions`. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListTransactions(pub Vec); - -/// Transaction list item, part of `ListTransactions`. -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -pub struct ListTransactionsItem { - /// The bitcoin address of the transaction. - pub address: Address, - /// The transaction category. - pub category: TransactionCategory, - /// The amount. - /// - /// This is negative for the 'send' category, and is positive for the 'receive' category. - #[serde(default, with = "bitcoin::amount::serde::as_btc")] - pub amount: SignedAmount, - /// A comment for the address/transaction, if any. - pub label: Option, - /// The vout value. - pub vout: u32, - /// The amount of the fee in BTC. - /// - /// This is negative and only available for the 'send' category of transactions. - #[serde(default, with = "bitcoin::amount::serde::as_btc")] - pub fee: SignedAmount, - /// The number of confirmations for the transaction. - /// - /// Negative confirmations indicate the transaction conflicts with the block chain. - pub confirmations: i64, - /// Whether we consider the outputs of this unconfirmed transaction safe to spend. - pub trusted: bool, - /// The block hash containing the transaction. - pub block_hash: BlockHash, - /// The index of the transaction in the block that includes it. - pub block_index: u32, - /// The block time in seconds since epoch (1 Jan 1970 GMT). - pub block_time: u32, - /// The transaction id. - pub txid: Txid, - /// The transaction time in seconds since epoch (Jan 1 1970 GMT). - pub time: u32, - /// The time received in seconds since epoch (Jan 1 1970 GMT). - pub time_received: u32, - /// If a comment is associated with the transaction. - pub comment: Option, - /// Whether this transaction could be replaced due to BIP125 (replace-by-fee); - /// may be unknown for unconfirmed transactions not in the mempool - pub bip125_replaceable: Bip125Replaceable, - /// If the transaction has been abandoned (inputs are respendable). - /// - /// Only available for the 'send' category of transactions. - pub abandoned: Option, -} +pub struct ListTransactions(pub Vec); /// Models the result of JSON-RPC method `listunspent`. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index ac2571a4..9a772fbf 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -281,8 +281,8 @@ pub use self::{ ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspent, ListUnspentItem, + ListTransactions, + TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, RescanBlockchain, ScriptType, SendMany, SendToAddress, SetTxFee, SignMessage, TransactionCategory, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, diff --git a/types/src/v17/wallet/error.rs b/types/src/v17/wallet/error.rs index 5cebbff5..b04a8a62 100644 --- a/types/src/v17/wallet/error.rs +++ b/types/src/v17/wallet/error.rs @@ -496,9 +496,9 @@ impl std::error::Error for ListReceivedByAddressError { #[derive(Debug)] pub enum ListSinceBlockError { /// Conversion of item in `transactions` list failed. - Transactions(ListSinceBlockTransactionError), + Transactions(TransactionItemError), /// Conversion of item in `removed` list failed. - Removed(ListSinceBlockTransactionError), + Removed(TransactionItemError), /// Conversion of the `last_block` field failed. LastBlock(hex::HexToArrayError), } @@ -529,9 +529,9 @@ impl std::error::Error for ListSinceBlockError { } } -/// Error when converting a `ListSinceBlockTransaction` type into the model type. +/// Error when converting a `TransactionItem` type into the model type. #[derive(Debug)] -pub enum ListSinceBlockTransactionError { +pub enum TransactionItemError { /// Conversion of numeric type to expected type failed. Numeric(NumericError), /// Conversion of the `address` field failed. @@ -546,9 +546,9 @@ pub enum ListSinceBlockTransactionError { Txid(hex::HexToArrayError), } -impl fmt::Display for ListSinceBlockTransactionError { +impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => write_err!(f, "numeric"; e), @@ -562,9 +562,9 @@ impl fmt::Display for ListSinceBlockTransactionError { } #[cfg(feature = "std")] -impl std::error::Error for ListSinceBlockTransactionError { +impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => Some(e), @@ -577,59 +577,7 @@ impl std::error::Error for ListSinceBlockTransactionError { } } -impl From for ListSinceBlockTransactionError { - fn from(e: NumericError) -> Self { Self::Numeric(e) } -} - -/// Error when converting a `ListTransactionsItem` type into the model type. -#[derive(Debug)] -pub enum ListTransactionsItemError { - /// Conversion of numeric type to expected type failed. - Numeric(NumericError), - /// Conversion of the `address` field failed. - Address(address::ParseError), - /// Conversion of the `amount` field failed. - Amount(ParseAmountError), - /// Conversion of the `fee` field failed. - Fee(ParseAmountError), - /// Conversion of the `block_hash` field failed. - BlockHash(hex::HexToArrayError), - /// Conversion of the `txid` field failed. - Txid(hex::HexToArrayError), -} - -impl fmt::Display for ListTransactionsItemError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListTransactionsItemError as E; - - match *self { - E::Numeric(ref e) => write_err!(f, "numeric"; e), - E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), - E::Amount(ref e) => write_err!(f, "conversion of the `amount` field failed"; e), - E::Fee(ref e) => write_err!(f, "conversion of the `fee` field failed"; e), - E::BlockHash(ref e) => write_err!(f, "conversion of the `block_hash` field failed"; e), - E::Txid(ref e) => write_err!(f, "conversion of the `txid` field failed"; e), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for ListTransactionsItemError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListTransactionsItemError as E; - - match *self { - E::Numeric(ref e) => Some(e), - E::Address(ref e) => Some(e), - E::Amount(ref e) => Some(e), - E::Fee(ref e) => Some(e), - E::BlockHash(ref e) => Some(e), - E::Txid(ref e) => Some(e), - } - } -} - -impl From for ListTransactionsItemError { +impl From for TransactionItemError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } diff --git a/types/src/v17/wallet/into.rs b/types/src/v17/wallet/into.rs index b5f98b35..220cfe47 100644 --- a/types/src/v17/wallet/into.rs +++ b/types/src/v17/wallet/into.rs @@ -578,12 +578,10 @@ impl ListSinceBlock { } } -impl ListSinceBlockTransaction { +impl TransactionItem { /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model( - self, - ) -> Result { - use ListSinceBlockTransactionError as E; + pub fn into_model(self) -> Result { + use TransactionItemError as E; let address = self.address.parse::>().map_err(E::Address)?; let category = self.category.into_model(); @@ -599,7 +597,7 @@ impl ListSinceBlockTransaction { let txid = self.txid.map(|s| s.parse::().map_err(E::Txid)).transpose()?; let bip125_replaceable = self.bip125_replaceable.into_model(); - Ok(model::ListSinceBlockTransaction { + Ok(model::TransactionItem { involves_watch_only: None, address: Some(address), category, @@ -633,50 +631,13 @@ impl ListSinceBlockTransaction { impl ListTransactions { /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> Result { + pub fn into_model(self) -> Result { let transactions = self.0.into_iter().map(|tx| tx.into_model()).collect::, _>>()?; Ok(model::ListTransactions(transactions)) } } -impl ListTransactionsItem { - /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model(self) -> Result { - use ListTransactionsItemError as E; - - let address = self.address.parse::>().map_err(E::Address)?; - let category = self.category.into_model(); - let amount = SignedAmount::from_btc(self.amount).map_err(E::Amount)?; - let vout = crate::to_u32(self.vout, "vout")?; - let fee = SignedAmount::from_btc(self.fee).map_err(E::Fee)?; - let block_hash = self.block_hash.parse::().map_err(E::BlockHash)?; - let block_index = crate::to_u32(self.block_index, "block_index")?; - let txid = self.txid.parse::().map_err(E::Txid)?; - let bip125_replaceable = self.bip125_replaceable.into_model(); - - Ok(model::ListTransactionsItem { - address, - category, - amount, - label: self.label, - vout, - fee, - confirmations: self.confirmations, - trusted: self.trusted, - block_hash, - block_index, - block_time: self.block_time, - txid, - time: self.time, - time_received: self.time_received, - comment: self.comment, - bip125_replaceable, - abandoned: self.abandoned, - }) - } -} - impl ListUnspent { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v17/wallet/mod.rs b/types/src/v17/wallet/mod.rs index b79cbbbf..f23b0596 100644 --- a/types/src/v17/wallet/mod.rs +++ b/types/src/v17/wallet/mod.rs @@ -21,8 +21,8 @@ pub use self::error::*; // // The following structs are very similar but have slightly different fields and docs. // - GetTransaction -// - ListSinceBlockTransaction -// - ListTransactionsItem +// - TransactionItem +// - TransactionItem /// Returned as part of `getaddressesbylabel` and `getaddressinfo`. #[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] @@ -695,12 +695,12 @@ pub struct ListReceivedByAddressItem { #[serde(deny_unknown_fields)] pub struct ListSinceBlock { /// All the transactions. - pub transactions: Vec, + pub transactions: Vec, /// Only present if `include_removed=true`. /// /// Note: transactions that were re-added in the active chain will appear as-is in this array, /// and may thus have a positive confirmation count. - pub removed: Vec, + pub removed: Vec, /// The hash of the block (target_confirmations-1) from the best block on the main chain. /// /// This is typically used to feed back into listsinceblock the next time you call it. So you @@ -710,11 +710,10 @@ pub struct ListSinceBlock { pub last_block: String, } -/// Transaction item returned as part of `listsinceblock`. -// FIXME: These docs from Core seem to buggy, there is only partial mention of 'move' category? +/// Transaction item returned as part of `listsinceblock` and `listtransactions`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListSinceBlockTransaction { +pub struct TransactionItem { /// DEPRECATED. The account name associated with the transaction. Will be "" for the default account. pub account: Option, /// The bitcoin address of the transaction. @@ -796,61 +795,7 @@ pub struct ListSinceBlockTransaction { /// > bitcoind with -deprecatedrpc=accounts #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListTransactions(pub Vec); - -/// Transaction item returned as part of `listtransactions`. -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -pub struct ListTransactionsItem { - /// The bitcoin address of the transaction. - pub address: String, - /// The transaction category. - pub category: TransactionCategory, // FIXME: It appears ok to reuse this? - /// The amount in BTC. - /// - /// This is negative for the 'send' category, and is positive for the 'receive' category. - pub amount: f64, - /// A comment for the address/transaction, if any. - pub label: Option, - /// The vout value. - pub vout: i64, - /// The amount of the fee in BTC. - /// - /// This is negative and only available for the 'send' category of transactions. - pub fee: f64, - /// The number of confirmations for the transaction. - /// - /// Negative confirmations indicate the transaction conflicts with the block chain. - pub confirmations: i64, - /// Whether we consider the outputs of this unconfirmed transaction safe to spend. - pub trusted: bool, - /// The block hash containing the transaction. - #[serde(rename = "blockhash")] - pub block_hash: String, - /// The index of the transaction in the block that includes it. - #[serde(rename = "blockindex")] - pub block_index: i64, - /// The block time in seconds since epoch (1 Jan 1970 GMT). - #[serde(rename = "blocktime")] - pub block_time: u32, - /// The transaction id. - pub txid: String, - /// The transaction time in seconds since epoch (Jan 1 1970 GMT). - pub time: u32, - /// The time received in seconds since epoch (Jan 1 1970 GMT). - #[serde(rename = "timereceived")] - pub time_received: u32, - /// If a comment is associated with the transaction. - pub comment: Option, - /// Whether this transaction could be replaced due to BIP125 (replace-by-fee); - /// may be unknown for unconfirmed transactions not in the mempool - #[serde(rename = "bip125-replaceable")] - pub bip125_replaceable: Bip125Replaceable, - /// If the transaction has been abandoned (inputs are respendable). - /// - /// Only available for the 'send' category of transactions. - pub abandoned: Option, -} +pub struct ListTransactions(pub Vec); /// Result of the JSON-RPC method `listunspent`. /// diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index b99893fc..a91825a3 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -275,8 +275,8 @@ pub use crate::v17::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, - ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListSinceBlockError, + ListTransactions, TransactionItem, TransactionItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging, MapMempoolEntryError, MempoolAcceptance, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PruneBlockchain, PsbtInput, PsbtOutput, PsbtScript, RawTransaction, RawTransactionError, RawTransactionInput, diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index 99908f45..9b7c836c 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -271,8 +271,8 @@ pub use crate::v17::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, - ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListSinceBlockError, + ListTransactions, TransactionItem, TransactionItemError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 65fb814a..14c1eff6 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -240,8 +240,8 @@ pub use self::{ util::CreateMultisig, wallet::{ AddMultisigAddress, GetAddressInfo, GetAddressInfoEmbedded, GetTransaction, - GetTransactionDetail, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, + GetTransactionDetail, ListSinceBlock, ListSinceBlockError, TransactionItem, + TransactionItemError, }, }; #[doc(inline)] @@ -266,7 +266,7 @@ pub use crate::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, diff --git a/types/src/v20/wallet/error.rs b/types/src/v20/wallet/error.rs index 3e4deeec..bda57914 100644 --- a/types/src/v20/wallet/error.rs +++ b/types/src/v20/wallet/error.rs @@ -14,9 +14,9 @@ use crate::NumericError; #[derive(Debug)] pub enum ListSinceBlockError { /// Conversion of item in `transactions` list failed. - Transactions(ListSinceBlockTransactionError), + Transactions(TransactionItemError), /// Conversion of item in `removed` list failed. - Removed(ListSinceBlockTransactionError), + Removed(TransactionItemError), /// Conversion of the `last_block` field failed. LastBlock(hex::HexToArrayError), } @@ -47,13 +47,13 @@ impl std::error::Error for ListSinceBlockError { } } -/// Error when converting a `ListSinceBlockTransaction` type into the model type. +/// Error when converting a `TransactionItem` type into the model type. /// /// Note: Additional fields introduced in v20 (e.g. `generated`, `trusted`, `block_height`, /// `wallet_conflicts`, `involvesWatchonly`) are currently not modelled and therefore are /// intentionally ignored during conversion; as such they have no dedicated error variants. #[derive(Debug)] -pub enum ListSinceBlockTransactionError { +pub enum TransactionItemError { /// Conversion of numeric type to expected type failed. Numeric(NumericError), /// Conversion of the `address` field failed. @@ -70,9 +70,9 @@ pub enum ListSinceBlockTransactionError { WalletConflicts(hex::HexToArrayError), } -impl fmt::Display for ListSinceBlockTransactionError { +impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => write_err!(f, "numeric"; e), @@ -88,9 +88,9 @@ impl fmt::Display for ListSinceBlockTransactionError { } #[cfg(feature = "std")] -impl std::error::Error for ListSinceBlockTransactionError { +impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => Some(e), @@ -104,6 +104,6 @@ impl std::error::Error for ListSinceBlockTransactionError { } } -impl From for ListSinceBlockTransactionError { +impl From for TransactionItemError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } diff --git a/types/src/v20/wallet/into.rs b/types/src/v20/wallet/into.rs index 605ac1db..45cc06b7 100644 --- a/types/src/v20/wallet/into.rs +++ b/types/src/v20/wallet/into.rs @@ -12,7 +12,7 @@ use super::{ AddMultisigAddress, AddMultisigAddressError, GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, + TransactionItem, TransactionItemError, }; use crate::model; @@ -276,12 +276,10 @@ impl ListSinceBlock { } } -impl ListSinceBlockTransaction { +impl TransactionItem { /// Converts version specific type to a version nonspecific, more strongly typed type. - pub fn into_model( - self, - ) -> Result { - use ListSinceBlockTransactionError as E; + pub fn into_model(self) -> Result { + use TransactionItemError as E; let address = self.address.parse::>().map_err(E::Address)?; let category = self.category.into_model(); @@ -303,7 +301,7 @@ impl ListSinceBlockTransaction { .collect::, _>>()?; let bip125_replaceable = self.bip125_replaceable.into_model(); - Ok(model::ListSinceBlockTransaction { + Ok(model::TransactionItem { involves_watch_only: self.involves_watch_only, address: Some(address), category, diff --git a/types/src/v20/wallet/mod.rs b/types/src/v20/wallet/mod.rs index 7983cdbb..2f279528 100644 --- a/types/src/v20/wallet/mod.rs +++ b/types/src/v20/wallet/mod.rs @@ -10,7 +10,7 @@ mod into; use bitcoin::Transaction; use serde::{Deserialize, Serialize}; -pub use self::error::{ListSinceBlockError, ListSinceBlockTransactionError}; +pub use self::error::{ListSinceBlockError, TransactionItemError}; pub use super::{ AddMultisigAddressError, Bip125Replaceable, GetAddressInfoEmbeddedError, GetAddressInfoError, GetTransactionDetailError, GetTransactionError, ScriptType, TransactionCategory, @@ -263,12 +263,12 @@ pub struct GetTransactionDetail { #[serde(deny_unknown_fields)] pub struct ListSinceBlock { /// All the transactions. - pub transactions: Vec, + pub transactions: Vec, /// Only present if `include_removed=true`. /// /// Note: transactions that were re-added in the active chain will appear as-is in this array, /// and may thus have a positive confirmation count. - pub removed: Vec, + pub removed: Vec, /// The hash of the block (target_confirmations-1) from the best block on the main chain. /// /// This is typically used to feed back into listsinceblock the next time you call it. So you @@ -281,7 +281,7 @@ pub struct ListSinceBlock { /// Transaction item returned as part of `listsinceblock`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListSinceBlockTransaction { +pub struct TransactionItem { /// Only returns true if imported addresses were involved in transaction. #[serde(rename = "involvesWatchonly")] pub involves_watch_only: Option, diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index ad1cd081..773adad4 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -282,7 +282,7 @@ pub use crate::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListTransactions, ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, + ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, @@ -308,6 +308,6 @@ pub use crate::{ v20::{ AddMultisigAddress, Banned, CreateMultisig, GenerateToDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetTransaction, GetTransactionDetail, ListBanned, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, Logging, + ListSinceBlockError, TransactionItem, TransactionItemError, Logging, }, }; diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 700104a5..5b44ad04 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -284,7 +284,7 @@ pub use crate::{ GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -308,8 +308,8 @@ pub use crate::{ }, v20::{ AddMultisigAddress, CreateMultisig, GenerateToDescriptor, GetTransaction, - GetTransactionDetail, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, + GetTransactionDetail, ListSinceBlock, ListSinceBlockError, TransactionItem, + TransactionItemError, }, v21::{ AddPeerAddress, Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 8bdc9f0a..01300786 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -260,8 +260,8 @@ pub use self::{ util::CreateMultisig, wallet::{ AddMultisigAddress, GetTransaction, GetTransactionError, GetWalletInfo, - GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, RestoreWallet, + GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, TransactionItem, + TransactionItemError, RestoreWallet, }, }; #[doc(inline)] @@ -286,7 +286,7 @@ pub use crate::{ GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, diff --git a/types/src/v23/wallet/error.rs b/types/src/v23/wallet/error.rs index 019dcef1..583f0a89 100644 --- a/types/src/v23/wallet/error.rs +++ b/types/src/v23/wallet/error.rs @@ -39,9 +39,9 @@ pub enum GetTransactionError { #[derive(Debug)] pub enum ListSinceBlockError { /// Conversion of the `transactions` field failed. - Transactions(ListSinceBlockTransactionError), + Transactions(TransactionItemError), /// Conversion of the `removed` field failed. - Removed(ListSinceBlockTransactionError), + Removed(TransactionItemError), /// Conversion of the `last_block` field failed. LastBlock(hex::HexToArrayError), } @@ -70,9 +70,9 @@ impl std::error::Error for ListSinceBlockError { } } -/// Error when converting a `ListSinceBlockTransaction` type into the model type. +/// Error when converting a `TransactionItem` type into the model type. #[derive(Debug)] -pub enum ListSinceBlockTransactionError { +pub enum TransactionItemError { /// Conversion of numeric type to expected type failed. Numeric(NumericError), /// Conversion of the `address` field failed. @@ -93,9 +93,9 @@ pub enum ListSinceBlockTransactionError { ReplacesTxid(hex::HexToArrayError), } -impl fmt::Display for ListSinceBlockTransactionError { +impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => write_err!(f, "numeric"; e), E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), @@ -114,9 +114,9 @@ impl fmt::Display for ListSinceBlockTransactionError { } #[cfg(feature = "std")] -impl std::error::Error for ListSinceBlockTransactionError { +impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => Some(e), E::Address(ref e) => Some(e), @@ -131,7 +131,7 @@ impl std::error::Error for ListSinceBlockTransactionError { } } -impl From for ListSinceBlockTransactionError { +impl From for TransactionItemError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } diff --git a/types/src/v23/wallet/into.rs b/types/src/v23/wallet/into.rs index c6b29f61..cdb827cb 100644 --- a/types/src/v23/wallet/into.rs +++ b/types/src/v23/wallet/into.rs @@ -6,7 +6,7 @@ use bitcoin::{Address, BlockHash, ScriptBuf, SignedAmount, Transaction, Txid}; use super::{ AddMultisigAddress, AddMultisigAddressError, GetTransaction, GetTransactionError, GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, + TransactionItem, TransactionItemError, }; use crate::model; @@ -165,11 +165,9 @@ impl ListSinceBlock { Ok(model::ListSinceBlock { transactions, removed, last_block }) } } -impl ListSinceBlockTransaction { - pub fn into_model( - self, - ) -> Result { - use ListSinceBlockTransactionError as E; +impl TransactionItem { + pub fn into_model(self) -> Result { + use TransactionItemError as E; let address = self.address.parse::>().map_err(E::Address)?; let category = self.category.into_model(); @@ -199,7 +197,7 @@ impl ListSinceBlockTransaction { self.replaces_txid.map(|s| s.parse::().map_err(E::ReplacesTxid)).transpose()?; let bip125_replaceable = self.bip125_replaceable.into_model(); - Ok(model::ListSinceBlockTransaction { + Ok(model::TransactionItem { involves_watch_only: self.involves_watch_only, address: Some(address), category, diff --git a/types/src/v23/wallet/mod.rs b/types/src/v23/wallet/mod.rs index 2209e720..dc9943ca 100644 --- a/types/src/v23/wallet/mod.rs +++ b/types/src/v23/wallet/mod.rs @@ -10,7 +10,7 @@ mod into; use bitcoin::Transaction; use serde::{Deserialize, Serialize}; -pub use self::error::{GetTransactionError, ListSinceBlockError, ListSinceBlockTransactionError}; +pub use self::error::{GetTransactionError, ListSinceBlockError, TransactionItemError}; pub use super::{ AddMultisigAddressError, Bip125Replaceable, GetTransactionDetail, GetTransactionDetailError, GetWalletInfoError, @@ -195,12 +195,12 @@ pub enum GetWalletInfoScanning { #[serde(deny_unknown_fields)] pub struct ListSinceBlock { /// All the transactions. - pub transactions: Vec, + pub transactions: Vec, /// Only present if `include_removed=true`. /// /// Note: transactions that were re-added in the active chain will appear as-is in this array, /// and may thus have a positive confirmation count. - pub removed: Vec, + pub removed: Vec, /// The hash of the block (target_confirmations-1) from the best block on the main chain. /// /// This is typically used to feed back into listsinceblock the next time you call it. So you @@ -213,7 +213,7 @@ pub struct ListSinceBlock { /// Transaction item returned as part of `listsinceblock`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListSinceBlockTransaction { +pub struct TransactionItem { /// Only returns true if imported addresses were involved in transaction. #[serde(rename = "involvesWatchonly")] pub involves_watch_only: Option, diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index bc93b0c9..5173e041 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -259,7 +259,7 @@ pub use self::{ }, wallet::{ GetTransaction, GetTransactionDetail, GetTransactionError, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListSinceBlockError, TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, MigrateWallet, SendAll, SendAllError, SimulateRawTransaction, }, }; @@ -285,7 +285,7 @@ pub use crate::{ GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, diff --git a/types/src/v24/wallet/error.rs b/types/src/v24/wallet/error.rs index c57aae96..f3821387 100644 --- a/types/src/v24/wallet/error.rs +++ b/types/src/v24/wallet/error.rs @@ -95,9 +95,9 @@ impl From for GetTransactionError { #[derive(Debug)] pub enum ListSinceBlockError { /// Conversion of the `transactions` field failed. - Transactions(ListSinceBlockTransactionError), + Transactions(TransactionItemError), /// Conversion of the `removed` field failed. - Removed(ListSinceBlockTransactionError), + Removed(TransactionItemError), /// Conversion of the `last_block` field failed. LastBlock(hex::HexToArrayError), } @@ -126,9 +126,9 @@ impl std::error::Error for ListSinceBlockError { } } -/// Error when converting a `ListSinceBlockTransaction` type into the model type. +/// Error when converting a `TransactionItem` type into the model type. #[derive(Debug)] -pub enum ListSinceBlockTransactionError { +pub enum TransactionItemError { /// Conversion of numeric type to expected type failed. Numeric(NumericError), /// Conversion of the `address` field failed. @@ -151,9 +151,9 @@ pub enum ListSinceBlockTransactionError { ReplacesTxid(hex::HexToArrayError), } -impl fmt::Display for ListSinceBlockTransactionError { +impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => write_err!(f, "numeric"; e), E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), @@ -173,9 +173,9 @@ impl fmt::Display for ListSinceBlockTransactionError { } #[cfg(feature = "std")] -impl std::error::Error for ListSinceBlockTransactionError { +impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => Some(e), E::Address(ref e) => Some(e), @@ -191,7 +191,7 @@ impl std::error::Error for ListSinceBlockTransactionError { } } -impl From for ListSinceBlockTransactionError { +impl From for TransactionItemError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } diff --git a/types/src/v24/wallet/into.rs b/types/src/v24/wallet/into.rs index 88600290..db7e05ef 100644 --- a/types/src/v24/wallet/into.rs +++ b/types/src/v24/wallet/into.rs @@ -6,9 +6,8 @@ use bitcoin::{Address, BlockHash, ScriptBuf, SignedAmount, Transaction, Txid}; use super::{ GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, - ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, - ListUnspent, ListUnspentItem, ListUnspentItemError, SendAll, SendAllError, - SimulateRawTransaction, + ListSinceBlock, ListSinceBlockError, ListUnspent, ListUnspentItem, ListUnspentItemError, + SendAll, SendAllError, SimulateRawTransaction, TransactionItem, TransactionItemError, }; use crate::model; @@ -121,11 +120,9 @@ impl ListSinceBlock { } } -impl ListSinceBlockTransaction { - pub fn into_model( - self, - ) -> Result { - use ListSinceBlockTransactionError as E; +impl TransactionItem { + pub fn into_model(self) -> Result { + use TransactionItemError as E; let address = self.address.map(|a| a.parse::>().map_err(E::Address)).transpose()?; @@ -157,7 +154,7 @@ impl ListSinceBlockTransaction { self.replaces_txid.map(|s| s.parse::().map_err(E::ReplacesTxid)).transpose()?; let bip125_replaceable = self.bip125_replaceable.into_model(); - Ok(model::ListSinceBlockTransaction { + Ok(model::TransactionItem { involves_watch_only: self.involves_watch_only, address, category, diff --git a/types/src/v24/wallet/mod.rs b/types/src/v24/wallet/mod.rs index cdaca955..4dc963e4 100644 --- a/types/src/v24/wallet/mod.rs +++ b/types/src/v24/wallet/mod.rs @@ -11,7 +11,7 @@ use bitcoin::Transaction; use serde::{Deserialize, Serialize}; pub use self::error::{ - GetTransactionError, ListSinceBlockError, ListSinceBlockTransactionError, SendAllError, + GetTransactionError, ListSinceBlockError, SendAllError, TransactionItemError, }; pub use super::{ Bip125Replaceable, GetTransactionDetailError, ListUnspentItemError, TransactionCategory, @@ -125,12 +125,12 @@ pub struct GetTransactionDetail { #[serde(deny_unknown_fields)] pub struct ListSinceBlock { /// All the transactions. - pub transactions: Vec, + pub transactions: Vec, /// Only present if `include_removed=true`. /// /// Note: transactions that were re-added in the active chain will appear as-is in this array, /// and may thus have a positive confirmation count. - pub removed: Vec, + pub removed: Vec, /// The hash of the block (target_confirmations-1) from the best block on the main chain. /// /// This is typically used to feed back into listsinceblock the next time you call it. So you @@ -143,7 +143,7 @@ pub struct ListSinceBlock { /// Transaction item returned as part of `listsinceblock`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListSinceBlockTransaction { +pub struct TransactionItem { /// Only returns true if imported addresses were involved in transaction. #[serde(rename = "involvesWatchonly")] pub involves_watch_only: Option, diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 08211330..f191ca4a 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -280,7 +280,7 @@ pub use crate::{ GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -322,7 +322,7 @@ pub use crate::{ GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetPeerInfo, GetTransaction, GetTransactionDetail, GetTransactionError, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListSinceBlockError, TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, PeerInfo, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index edd288b5..7453dc95 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -296,7 +296,7 @@ pub use crate::{ GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -336,8 +336,8 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTransactionDetail, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, + ListSinceBlock, ListSinceBlockError, TransactionItem, + TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index f7b731fa..0b7d6445 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -273,7 +273,7 @@ pub use crate::{ GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -313,8 +313,8 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTransactionDetail, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListSinceBlock, ListSinceBlockError, ListSinceBlockTransaction, - ListSinceBlockTransactionError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, + ListSinceBlock, ListSinceBlockError, TransactionItem, + TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 8e1384fb..b7bcf589 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -270,7 +270,7 @@ pub use self::{ wallet::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, ListSinceBlockError, - ListSinceBlockTransaction, ListSinceBlockTransactionError, + TransactionItem, TransactionItemError, }, }; #[doc(inline)] @@ -294,7 +294,7 @@ pub use crate::{ GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, diff --git a/types/src/v28/wallet/error.rs b/types/src/v28/wallet/error.rs index 6d5e4e51..27ff4154 100644 --- a/types/src/v28/wallet/error.rs +++ b/types/src/v28/wallet/error.rs @@ -50,9 +50,9 @@ impl From for GetHdKeysError { #[derive(Debug)] pub enum ListSinceBlockError { /// Conversion of the `transactions` field failed. - Transactions(ListSinceBlockTransactionError), + Transactions(TransactionItemError), /// Conversion of the `removed` field failed. - Removed(ListSinceBlockTransactionError), + Removed(TransactionItemError), /// Conversion of the `last_block` field failed. LastBlock(hex::HexToArrayError), } @@ -81,9 +81,9 @@ impl std::error::Error for ListSinceBlockError { } } -/// Error when converting a `ListSinceBlockTransaction` type into the model type. +/// Error when converting a `TransactionItem` type into the model type. #[derive(Debug)] -pub enum ListSinceBlockTransactionError { +pub enum TransactionItemError { /// Conversion of numeric type to expected type failed. Numeric(NumericError), /// Conversion of the `address` field failed. @@ -106,9 +106,9 @@ pub enum ListSinceBlockTransactionError { ReplacesTxid(hex::HexToArrayError), } -impl fmt::Display for ListSinceBlockTransactionError { +impl fmt::Display for TransactionItemError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => write_err!(f, "numeric"; e), E::Address(ref e) => write_err!(f, "conversion of the `address` field failed"; e), @@ -128,9 +128,9 @@ impl fmt::Display for ListSinceBlockTransactionError { } #[cfg(feature = "std")] -impl std::error::Error for ListSinceBlockTransactionError { +impl std::error::Error for TransactionItemError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ListSinceBlockTransactionError as E; + use TransactionItemError as E; match *self { E::Numeric(ref e) => Some(e), E::Address(ref e) => Some(e), @@ -146,6 +146,6 @@ impl std::error::Error for ListSinceBlockTransactionError { } } -impl From for ListSinceBlockTransactionError { +impl From for TransactionItemError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } diff --git a/types/src/v28/wallet/into.rs b/types/src/v28/wallet/into.rs index 9d2d3698..34ed595e 100644 --- a/types/src/v28/wallet/into.rs +++ b/types/src/v28/wallet/into.rs @@ -12,7 +12,7 @@ use bitcoin::{ use super::{ GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetHdKeys, GetHdKeysError, GetTransaction, GetTransactionError, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, + ListSinceBlockError, TransactionItem, TransactionItemError, }; use crate::model; @@ -273,11 +273,9 @@ impl ListSinceBlock { } } -impl ListSinceBlockTransaction { - pub fn into_model( - self, - ) -> Result { - use ListSinceBlockTransactionError as E; +impl TransactionItem { + pub fn into_model(self) -> Result { + use TransactionItemError as E; let address = self.address.map(|s| s.parse::>().map_err(E::Address)).transpose()?; @@ -312,7 +310,7 @@ impl ListSinceBlockTransaction { .map(|v| v.into_iter().filter_map(|s| s.parse::().ok()).collect::>()); let bip125_replaceable = self.bip125_replaceable.into_model(); - Ok(model::ListSinceBlockTransaction { + Ok(model::TransactionItem { involves_watch_only: self.involves_watch_only, address, category, diff --git a/types/src/v28/wallet/mod.rs b/types/src/v28/wallet/mod.rs index 21e68c8c..35d32c35 100644 --- a/types/src/v28/wallet/mod.rs +++ b/types/src/v28/wallet/mod.rs @@ -10,7 +10,7 @@ mod into; use bitcoin::Transaction; use serde::{Deserialize, Serialize}; -pub use self::error::{GetHdKeysError, ListSinceBlockError, ListSinceBlockTransactionError}; +pub use self::error::{GetHdKeysError, ListSinceBlockError, TransactionItemError}; pub use super::{ Bip125Replaceable, GetAddressInfoEmbeddedError, GetAddressInfoError, GetTransactionDetail, GetTransactionError, LastProcessedBlock, ScriptType, @@ -281,12 +281,12 @@ pub struct GetTransaction { #[serde(deny_unknown_fields)] pub struct ListSinceBlock { /// All the transactions. - pub transactions: Vec, + pub transactions: Vec, /// Only present if `include_removed=true`. /// /// Note: transactions that were re-added in the active chain will appear as-is in this array, /// and may thus have a positive confirmation count. - pub removed: Vec, + pub removed: Vec, /// The hash of the block (target_confirmations-1) from the best block on the main chain. /// /// This is typically used to feed back into listsinceblock the next time you call it. So you @@ -299,7 +299,7 @@ pub struct ListSinceBlock { /// Transaction item returned as part of `listsinceblock`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -pub struct ListSinceBlockTransaction { +pub struct TransactionItem { /// Only returns true if imported addresses were involved in transaction. #[serde(rename = "involvesWatchonly")] pub involves_watch_only: Option, diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 741a2cf5..856d2b09 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -290,7 +290,7 @@ pub use crate::{ GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, - ListTransactionsItem, ListTransactionsItemError, ListUnspentItemError, ListWallets, + ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -349,7 +349,7 @@ pub use crate::{ v28::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, GetNetworkInfo, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, - ListSinceBlockError, ListSinceBlockTransaction, ListSinceBlockTransactionError, Logging, + ListSinceBlockError, TransactionItem, TransactionItemError, Logging, SubmitPackage, SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, }, From ebdbb188b656271412ae0e0f43a0ea6c5b25e3d6 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Thu, 28 Aug 2025 20:39:35 +0100 Subject: [PATCH 4/5] Test and update listtransactions The RPC was implemented for v17 and untested. The struct now uses the fixed `TransactionItem` struct and associated error and into functions. Update all the version types to use the fixed `TransactionItem`. Add a test and update the types tables. --- integration_test/tests/wallet.rs | 18 ++++++++++++++++++ types/src/v17/mod.rs | 2 +- types/src/v18/mod.rs | 2 +- types/src/v19/mod.rs | 2 +- types/src/v20/mod.rs | 6 +++--- types/src/v20/wallet/into.rs | 11 ++++++++++- types/src/v20/wallet/mod.rs | 13 +++++++++++++ types/src/v21/mod.rs | 6 +++--- types/src/v22/mod.rs | 6 +++--- types/src/v23/mod.rs | 6 +++--- types/src/v23/wallet/into.rs | 11 ++++++++++- types/src/v23/wallet/mod.rs | 13 +++++++++++++ types/src/v24/mod.rs | 5 +++-- types/src/v24/wallet/into.rs | 14 ++++++++++++-- types/src/v24/wallet/mod.rs | 13 +++++++++++++ types/src/v25/mod.rs | 6 +++--- types/src/v26/mod.rs | 6 +++--- types/src/v27/mod.rs | 6 +++--- types/src/v28/mod.rs | 6 +++--- types/src/v28/wallet/into.rs | 11 ++++++++++- types/src/v28/wallet/mod.rs | 13 +++++++++++++ types/src/v29/mod.rs | 6 +++--- 22 files changed, 145 insertions(+), 37 deletions(-) diff --git a/integration_test/tests/wallet.rs b/integration_test/tests/wallet.rs index 1007e9bf..6e90f529 100644 --- a/integration_test/tests/wallet.rs +++ b/integration_test/tests/wallet.rs @@ -610,6 +610,24 @@ fn wallet__list_since_block__modelled() { assert_eq!(first_tx.txid.unwrap().to_string().len(), 64); } +#[test] +fn wallet__list_transactions__modelled() { + let node = Node::with_wallet(Wallet::Default, &[]); + + node.fund_wallet(); + let addr = node.client.new_address().expect("newaddress"); + let amount = Amount::from_sat(5_000); + node.client.send_to_address(&addr, amount).expect("sendtoaddress"); + node.mine_a_block(); + + let json: ListTransactions = node.client.list_transactions().expect("listtransactions"); + let model: Result = json.into_model(); + let model = model.unwrap(); + + let first_tx: mtype::TransactionItem = model.0[0].clone(); + assert_eq!(first_tx.txid.unwrap().to_string().len(), 64); +} + #[test] fn wallet__import_multi() { let node = match () { diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index 9a772fbf..ae21bf10 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -186,7 +186,7 @@ //! | listreceivedbyaccount | returns nothing | | //! | listreceivedbyaddress | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwallets | version + model | | //! | loadwallet | version + model | | diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index a91825a3..3a547728 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -189,7 +189,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index 9b7c836c..b62cf68d 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -190,7 +190,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 14c1eff6..a48af984 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -191,7 +191,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -241,7 +241,7 @@ pub use self::{ wallet::{ AddMultisigAddress, GetAddressInfo, GetAddressInfoEmbedded, GetTransaction, GetTransactionDetail, ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, + TransactionItemError, ListTransactions, }, }; #[doc(inline)] @@ -266,7 +266,7 @@ pub use crate::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListTransactions, ListUnspentItemError, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, diff --git a/types/src/v20/wallet/into.rs b/types/src/v20/wallet/into.rs index 45cc06b7..7245350a 100644 --- a/types/src/v20/wallet/into.rs +++ b/types/src/v20/wallet/into.rs @@ -12,7 +12,7 @@ use super::{ AddMultisigAddress, AddMultisigAddressError, GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, ListSinceBlock, ListSinceBlockError, - TransactionItem, TransactionItemError, + ListTransactions, TransactionItem, TransactionItemError, }; use crate::model; @@ -332,3 +332,12 @@ impl TransactionItem { }) } } + +impl ListTransactions { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + let transactions = + self.0.into_iter().map(|tx| tx.into_model()).collect::, _>>()?; + Ok(model::ListTransactions(transactions)) + } +} diff --git a/types/src/v20/wallet/mod.rs b/types/src/v20/wallet/mod.rs index 2f279528..40a85666 100644 --- a/types/src/v20/wallet/mod.rs +++ b/types/src/v20/wallet/mod.rs @@ -342,3 +342,16 @@ pub struct TransactionItem { /// If a comment to is associated with the transaction. pub to: Option, } + +/// Result of the JSON-RPC method `listtransactions`. +/// +/// > listtransactions (label count skip include_watchonly) +/// > +/// > If a label name is provided, this will return only incoming transactions paying to addresses with the specified label. +/// > +/// > Returns up to 'count' most recent transactions skipping the first 'from' transactions. +/// > Note that the "account" argument and "otheraccount" return value have been removed in V0.17. To use this RPC with an "account" argument, restart +/// > bitcoind with -deprecatedrpc=accounts +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListTransactions(pub Vec); diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index 773adad4..e78a3a51 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -195,7 +195,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -282,7 +282,7 @@ pub use crate::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListTransactions, ListUnspentItemError, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, @@ -308,6 +308,6 @@ pub use crate::{ v20::{ AddMultisigAddress, Banned, CreateMultisig, GenerateToDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetTransaction, GetTransactionDetail, ListBanned, ListSinceBlock, - ListSinceBlockError, TransactionItem, TransactionItemError, Logging, + ListSinceBlockError, TransactionItem, TransactionItemError, Logging, ListTransactions, }, }; diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 5b44ad04..975e626a 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -205,7 +205,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -283,7 +283,7 @@ pub use crate::{ GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -309,7 +309,7 @@ pub use crate::{ v20::{ AddMultisigAddress, CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail, ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, + TransactionItemError, ListTransactions, }, v21::{ AddPeerAddress, Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 01300786..bba9747c 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -197,7 +197,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -261,7 +261,7 @@ pub use self::{ wallet::{ AddMultisigAddress, GetTransaction, GetTransactionError, GetWalletInfo, GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, RestoreWallet, + TransactionItemError, RestoreWallet, ListTransactions, }, }; #[doc(inline)] @@ -285,7 +285,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, diff --git a/types/src/v23/wallet/into.rs b/types/src/v23/wallet/into.rs index cdb827cb..f1a0e21f 100644 --- a/types/src/v23/wallet/into.rs +++ b/types/src/v23/wallet/into.rs @@ -6,7 +6,7 @@ use bitcoin::{Address, BlockHash, ScriptBuf, SignedAmount, Transaction, Txid}; use super::{ AddMultisigAddress, AddMultisigAddressError, GetTransaction, GetTransactionError, GetWalletInfo, GetWalletInfoError, GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, - TransactionItem, TransactionItemError, + ListTransactions, TransactionItem, TransactionItemError, }; use crate::model; @@ -228,3 +228,12 @@ impl TransactionItem { }) } } + +impl ListTransactions { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + let transactions = + self.0.into_iter().map(|tx| tx.into_model()).collect::, _>>()?; + Ok(model::ListTransactions(transactions)) + } +} diff --git a/types/src/v23/wallet/mod.rs b/types/src/v23/wallet/mod.rs index dc9943ca..f1cf2a25 100644 --- a/types/src/v23/wallet/mod.rs +++ b/types/src/v23/wallet/mod.rs @@ -278,3 +278,16 @@ pub struct TransactionItem { /// A comment for the address/transaction, if any. pub label: Option, } + +/// Result of the JSON-RPC method `listtransactions`. +/// +/// > listtransactions (label count skip include_watchonly) +/// > +/// > If a label name is provided, this will return only incoming transactions paying to addresses with the specified label. +/// > +/// > Returns up to 'count' most recent transactions skipping the first 'from' transactions. +/// > Note that the "account" argument and "otheraccount" return value have been removed in V0.17. To use this RPC with an "account" argument, restart +/// > bitcoind with -deprecatedrpc=accounts +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListTransactions(pub Vec); diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 5173e041..8a78a017 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -199,7 +199,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -261,6 +261,7 @@ pub use self::{ GetTransaction, GetTransactionDetail, GetTransactionError, ListSinceBlock, ListSinceBlockError, TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, MigrateWallet, SendAll, SendAllError, SimulateRawTransaction, + ListTransactions, }, }; #[doc(inline)] @@ -284,7 +285,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, diff --git a/types/src/v24/wallet/into.rs b/types/src/v24/wallet/into.rs index db7e05ef..322349e2 100644 --- a/types/src/v24/wallet/into.rs +++ b/types/src/v24/wallet/into.rs @@ -6,8 +6,9 @@ use bitcoin::{Address, BlockHash, ScriptBuf, SignedAmount, Transaction, Txid}; use super::{ GetTransaction, GetTransactionDetail, GetTransactionDetailError, GetTransactionError, - ListSinceBlock, ListSinceBlockError, ListUnspent, ListUnspentItem, ListUnspentItemError, - SendAll, SendAllError, SimulateRawTransaction, TransactionItem, TransactionItemError, + ListSinceBlock, ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, + ListUnspentItemError, SendAll, SendAllError, SimulateRawTransaction, TransactionItem, + TransactionItemError, }; use crate::model; @@ -186,6 +187,15 @@ impl TransactionItem { } } +impl ListTransactions { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + let transactions = + self.0.into_iter().map(|tx| tx.into_model()).collect::, _>>()?; + Ok(model::ListTransactions(transactions)) + } +} + impl ListUnspent { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v24/wallet/mod.rs b/types/src/v24/wallet/mod.rs index 4dc963e4..26384d35 100644 --- a/types/src/v24/wallet/mod.rs +++ b/types/src/v24/wallet/mod.rs @@ -214,6 +214,19 @@ pub struct TransactionItem { pub label: Option, } +/// Result of the JSON-RPC method `listtransactions`. +/// +/// > listtransactions (label count skip include_watchonly) +/// > +/// > If a label name is provided, this will return only incoming transactions paying to addresses with the specified label. +/// > +/// > Returns up to 'count' most recent transactions skipping the first 'from' transactions. +/// > Note that the "account" argument and "otheraccount" return value have been removed in V0.17. To use this RPC with an "account" argument, restart +/// > bitcoind with -deprecatedrpc=accounts +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListTransactions(pub Vec); + /// Result of the JSON-RPC method `listunspent`. /// /// > listunspent ( minconf maxconf ["addresses",...] `[include_unsafe]` `[query_options]`) diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index f191ca4a..7e728c02 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -200,7 +200,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -279,7 +279,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -325,6 +325,6 @@ pub use crate::{ ListSinceBlockError, TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, PeerInfo, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, - TaprootLeaf, TaprootScript, TaprootScriptPathSig, + TaprootLeaf, TaprootScript, TaprootScriptPathSig, ListTransactions, }, }; diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index 7453dc95..1686309b 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -208,7 +208,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -295,7 +295,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -339,7 +339,7 @@ pub use crate::{ ListSinceBlock, ListSinceBlockError, TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, - TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, + TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, ListTransactions, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 0b7d6445..a2937c1c 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -208,7 +208,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -272,7 +272,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -316,7 +316,7 @@ pub use crate::{ ListSinceBlock, ListSinceBlockError, TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, - TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, + TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, ListTransactions, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index b7bcf589..8de2fc1d 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -210,7 +210,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -270,7 +270,7 @@ pub use self::{ wallet::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, ListSinceBlockError, - TransactionItem, TransactionItemError, + TransactionItem, TransactionItemError, ListTransactions, }, }; #[doc(inline)] @@ -293,7 +293,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, diff --git a/types/src/v28/wallet/into.rs b/types/src/v28/wallet/into.rs index 34ed595e..afb1e3d8 100644 --- a/types/src/v28/wallet/into.rs +++ b/types/src/v28/wallet/into.rs @@ -12,7 +12,7 @@ use bitcoin::{ use super::{ GetAddressInfo, GetAddressInfoEmbedded, GetAddressInfoEmbeddedError, GetAddressInfoError, GetHdKeys, GetHdKeysError, GetTransaction, GetTransactionError, ListSinceBlock, - ListSinceBlockError, TransactionItem, TransactionItemError, + ListSinceBlockError, ListTransactions, TransactionItem, TransactionItemError, }; use crate::model; @@ -341,3 +341,12 @@ impl TransactionItem { }) } } + +impl ListTransactions { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + let transactions = + self.0.into_iter().map(|tx| tx.into_model()).collect::, _>>()?; + Ok(model::ListTransactions(transactions)) + } +} diff --git a/types/src/v28/wallet/mod.rs b/types/src/v28/wallet/mod.rs index 35d32c35..a5864c55 100644 --- a/types/src/v28/wallet/mod.rs +++ b/types/src/v28/wallet/mod.rs @@ -372,3 +372,16 @@ pub struct TransactionItem { /// A comment for the address/transaction, if any. pub label: Option, } + +/// Result of the JSON-RPC method `listtransactions`. +/// +/// > listtransactions (label count skip include_watchonly) +/// > +/// > If a label name is provided, this will return only incoming transactions paying to addresses with the specified label. +/// > +/// > Returns up to 'count' most recent transactions skipping the first 'from' transactions. +/// > Note that the "account" argument and "otheraccount" return value have been removed in V0.17. To use this RPC with an "account" argument, restart +/// > bitcoind with -deprecatedrpc=accounts +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct ListTransactions(pub Vec); diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 856d2b09..34883dd8 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -211,7 +211,7 @@ //! | listreceivedbyaddress | version + model | | //! | listreceivedbylabel | version + model | | //! | listsinceblock | version + model | | -//! | listtransactions | version + model | UNTESTED | +//! | listtransactions | version + model | | //! | listunspent | version + model | | //! | listwalletdir | version | | //! | listwallets | version + model | | @@ -289,7 +289,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, ListTransactions, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, @@ -351,6 +351,6 @@ pub use crate::{ GetNetworkInfo, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, ListSinceBlockError, TransactionItem, TransactionItemError, Logging, SubmitPackage, SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, - SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, + SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, ListTransactions, }, }; From a07b91c954d8589e2a59486fcf25e760b781a321 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Thu, 28 Aug 2025 20:54:14 +0100 Subject: [PATCH 5/5] Run the formatter Reordering of the reexports only --- types/src/v17/mod.rs | 7 +++---- types/src/v18/mod.rs | 17 ++++++++--------- types/src/v19/mod.rs | 15 +++++++-------- types/src/v20/mod.rs | 15 +++++++-------- types/src/v21/mod.rs | 9 ++++----- types/src/v22/mod.rs | 7 +++---- types/src/v23/mod.rs | 7 +++---- types/src/v24/mod.rs | 8 +++----- types/src/v25/mod.rs | 11 +++++------ types/src/v26/mod.rs | 11 +++++------ types/src/v27/mod.rs | 11 +++++------ types/src/v28/mod.rs | 5 ++--- types/src/v29/mod.rs | 9 ++++----- 13 files changed, 59 insertions(+), 73 deletions(-) diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index ae21bf10..cc1462b6 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -281,10 +281,9 @@ pub use self::{ ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddress, ListReceivedByAddressError, ListReceivedByAddressItem, ListSinceBlock, ListSinceBlockError, - ListTransactions, - TransactionItem, TransactionItemError, ListUnspent, ListUnspentItem, - ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, RescanBlockchain, ScriptType, - SendMany, SendToAddress, SetTxFee, SignMessage, TransactionCategory, + ListTransactions, ListUnspent, ListUnspentItem, ListUnspentItemError, ListWallets, + LoadWallet, LockUnspent, RescanBlockchain, ScriptType, SendMany, SendToAddress, SetTxFee, + SignMessage, TransactionCategory, TransactionItem, TransactionItemError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, }, zmq::GetZmqNotifications, diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index 3a547728..edffdfda 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -275,15 +275,14 @@ pub use crate::v17::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, - ListSinceBlockError, - ListTransactions, TransactionItem, TransactionItemError, ListUnspentItemError, - ListWallets, LoadWallet, LockUnspent, Locked, Logging, MapMempoolEntryError, MempoolAcceptance, - MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, PruneBlockchain, PsbtInput, - PsbtOutput, PsbtScript, RawTransaction, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, Softfork, SoftforkReject, - TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + ListSinceBlockError, ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, + LockUnspent, Locked, Logging, MapMempoolEntryError, MempoolAcceptance, MempoolEntryError, + MempoolEntryFees, MempoolEntryFeesError, PruneBlockchain, PsbtInput, PsbtOutput, PsbtScript, + RawTransaction, RawTransactionError, RawTransactionInput, RawTransactionOutput, + RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, + SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, Softfork, SoftforkReject, TestMempoolAccept, TransactionCategory, + TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }; diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index b62cf68d..b7a018a4 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -271,14 +271,13 @@ pub use crate::v17::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListBanned, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListSinceBlock, - ListSinceBlockError, - ListTransactions, TransactionItem, TransactionItemError, ListUnspentItemError, - ListWallets, LoadWallet, LockUnspent, Locked, Logging, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject, - TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, - VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, + ListSinceBlockError, ListTransactions, ListUnspentItemError, ListWallets, LoadWallet, + LockUnspent, Locked, Logging, PruneBlockchain, RawTransactionError, RawTransactionInput, + RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, + SignRawTransaction, SignRawTransactionError, SoftforkReject, TestMempoolAccept, + TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, + ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }; #[doc(inline)] diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index a48af984..debec268 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -240,8 +240,8 @@ pub use self::{ util::CreateMultisig, wallet::{ AddMultisigAddress, GetAddressInfo, GetAddressInfoEmbedded, GetTransaction, - GetTransactionDetail, ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, ListTransactions, + GetTransactionDetail, ListSinceBlock, ListSinceBlockError, ListTransactions, + TransactionItem, TransactionItemError, }, }; #[doc(inline)] @@ -266,12 +266,11 @@ pub use crate::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, - ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject, - TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, + SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + SoftforkReject, TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index e78a3a51..0b13a32e 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -282,10 +282,9 @@ pub use crate::{ GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, - ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, + ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, + RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, + ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, @@ -308,6 +307,6 @@ pub use crate::{ v20::{ AddMultisigAddress, Banned, CreateMultisig, GenerateToDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetTransaction, GetTransactionDetail, ListBanned, ListSinceBlock, - ListSinceBlockError, TransactionItem, TransactionItemError, Logging, ListTransactions, + ListSinceBlockError, ListTransactions, Logging, TransactionItem, TransactionItemError, }, }; diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 975e626a..1e8fc424 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -283,8 +283,7 @@ pub use crate::{ GetTransactionError, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -308,8 +307,8 @@ pub use crate::{ }, v20::{ AddMultisigAddress, CreateMultisig, GenerateToDescriptor, GetTransaction, - GetTransactionDetail, ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, ListTransactions, + GetTransactionDetail, ListSinceBlock, ListSinceBlockError, ListTransactions, + TransactionItem, TransactionItemError, }, v21::{ AddPeerAddress, Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index bba9747c..f6a090a8 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -260,8 +260,8 @@ pub use self::{ util::CreateMultisig, wallet::{ AddMultisigAddress, GetTransaction, GetTransactionError, GetWalletInfo, - GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, RestoreWallet, ListTransactions, + GetWalletInfoScanning, ListSinceBlock, ListSinceBlockError, ListTransactions, + RestoreWallet, TransactionItem, TransactionItemError, }, }; #[doc(inline)] @@ -285,8 +285,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 8a78a017..7557ecbc 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -259,9 +259,8 @@ pub use self::{ }, wallet::{ GetTransaction, GetTransactionDetail, GetTransactionError, ListSinceBlock, - ListSinceBlockError, TransactionItem, TransactionItemError, - ListUnspent, ListUnspentItem, MigrateWallet, SendAll, SendAllError, SimulateRawTransaction, - ListTransactions, + ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, MigrateWallet, + SendAll, SendAllError, SimulateRawTransaction, TransactionItem, TransactionItemError, }, }; #[doc(inline)] @@ -285,8 +284,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 7e728c02..6536f930 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -279,8 +279,7 @@ pub use crate::{ GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, GetUnconfirmedBalance, GetWalletInfoError, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -322,9 +321,9 @@ pub use crate::{ GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetPeerInfo, GetTransaction, GetTransactionDetail, GetTransactionError, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, ListSinceBlock, - ListSinceBlockError, TransactionItem, TransactionItemError, - ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, PeerInfo, Proprietary, - PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, TaprootBip32Deriv, - TaprootLeaf, TaprootScript, TaprootScriptPathSig, ListTransactions, + ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, MempoolEntry, + MigrateWallet, PeerInfo, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, + SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, + TaprootScriptPathSig, TransactionItem, TransactionItemError, }, }; diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index 1686309b..4a9dddb7 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -295,8 +295,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -336,10 +335,10 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTransactionDetail, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, - Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, - TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, ListTransactions, + ListSinceBlock, ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, + MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, + SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, + TaprootScriptPathSig, TransactionItem, TransactionItemError, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index a2937c1c..0adaaba9 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -272,8 +272,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -313,10 +312,10 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetTransactionDetail, GetTxSpendingPrevout, GetTxSpendingPrevoutError, GlobalXpub, - ListSinceBlock, ListSinceBlockError, TransactionItem, - TransactionItemError, ListUnspent, ListUnspentItem, MempoolEntry, MigrateWallet, - Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, SimulateRawTransaction, - TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, ListTransactions, + ListSinceBlock, ListSinceBlockError, ListTransactions, ListUnspent, ListUnspentItem, + MempoolEntry, MigrateWallet, Proprietary, PsbtInput, PsbtOutput, SendAll, SendAllError, + SimulateRawTransaction, TaprootBip32Deriv, TaprootLeaf, TaprootScript, + TaprootScriptPathSig, TransactionItem, TransactionItemError, }, v25::{ GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 8de2fc1d..4c74f6e7 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -270,7 +270,7 @@ pub use self::{ wallet::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, ListSinceBlockError, - TransactionItem, TransactionItemError, ListTransactions, + ListTransactions, TransactionItem, TransactionItemError, }, }; #[doc(inline)] @@ -293,8 +293,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 34883dd8..60524f1a 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -289,8 +289,7 @@ pub use crate::{ GetRawTransactionVerboseError, GetReceivedByAddress, GetTransactionDetailError, GetTxOut, GetTxOutError, GetUnconfirmedBalance, ListAddressGroupings, ListAddressGroupingsError, ListAddressGroupingsItem, ListLabels, ListLockUnspent, ListLockUnspentItem, - ListLockUnspentItemError, ListReceivedByAddressError, - ListUnspentItemError, ListWallets, + ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, @@ -349,8 +348,8 @@ pub use crate::{ v28::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, GetNetworkInfo, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, - ListSinceBlockError, TransactionItem, TransactionItemError, Logging, - SubmitPackage, SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, - SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, ListTransactions, + ListSinceBlockError, ListTransactions, Logging, SubmitPackage, SubmitPackageError, + SubmitPackageTxResult, SubmitPackageTxResultError, SubmitPackageTxResultFees, + SubmitPackageTxResultFeesError, TransactionItem, TransactionItemError, }, };