diff --git a/client/src/client_sync/v17/blockchain.rs b/client/src/client_sync/v17/blockchain.rs index 810fa19b..5ab8c26b 100644 --- a/client/src/client_sync/v17/blockchain.rs +++ b/client/src/client_sync/v17/blockchain.rs @@ -318,7 +318,33 @@ macro_rules! impl_client_v17__save_mempool { }; } -/// Implements Bitcoin Core JSON-RPC API method `verifychain`. +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v17__scan_tx_out_set { + () => { + impl Client { + /// Aborts an ongoing `scantxoutset` scan. + pub fn scan_tx_out_set_abort(&self) -> Result { + self.call("scantxoutset", &[into_json("abort")?]) + } + + /// Starts a scan of the UTXO set for specified descriptors. + pub fn scan_tx_out_set_start( + &self, + scan_objects: &[&str], + ) -> Result { + self.call("scantxoutset", &[into_json("start")?, into_json(scan_objects)?]) + } + + /// Checks the status of an ongoing `scantxoutset` scan. + pub fn scan_tx_out_set_status(&self) -> Result> { + self.call("scantxoutset", &[into_json("status")?]) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `verifychain` #[macro_export] macro_rules! impl_client_v17__verify_chain { () => { diff --git a/client/src/client_sync/v17/mod.rs b/client/src/client_sync/v17/mod.rs index 7921840d..a88a39fc 100644 --- a/client/src/client_sync/v17/mod.rs +++ b/client/src/client_sync/v17/mod.rs @@ -50,6 +50,7 @@ crate::impl_client_v17__get_tx_out_set_info!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v17__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v18/mod.rs b/client/src/client_sync/v18/mod.rs index 73a4f048..da52e102 100644 --- a/client/src/client_sync/v18/mod.rs +++ b/client/src/client_sync/v18/mod.rs @@ -54,6 +54,7 @@ crate::impl_client_v17__get_tx_out_set_info!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v17__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v19/mod.rs b/client/src/client_sync/v19/mod.rs index 8bed0e35..bd157996 100644 --- a/client/src/client_sync/v19/mod.rs +++ b/client/src/client_sync/v19/mod.rs @@ -50,6 +50,7 @@ crate::impl_client_v17__get_tx_out_set_info!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v17__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v20/mod.rs b/client/src/client_sync/v20/mod.rs index 067caf4c..85c2823a 100644 --- a/client/src/client_sync/v20/mod.rs +++ b/client/src/client_sync/v20/mod.rs @@ -49,6 +49,7 @@ crate::impl_client_v17__get_tx_out_set_info!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v17__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v21/mod.rs b/client/src/client_sync/v21/mod.rs index 029a1c94..b42c1a0c 100644 --- a/client/src/client_sync/v21/mod.rs +++ b/client/src/client_sync/v21/mod.rs @@ -53,6 +53,7 @@ crate::impl_client_v17__get_tx_out_set_info!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v17__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v22/mod.rs b/client/src/client_sync/v22/mod.rs index 75658cb4..232c6020 100644 --- a/client/src/client_sync/v22/mod.rs +++ b/client/src/client_sync/v22/mod.rs @@ -51,6 +51,7 @@ crate::impl_client_v17__get_tx_out_set_info!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v17__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v23/mod.rs b/client/src/client_sync/v23/mod.rs index f6bed4b9..2c732756 100644 --- a/client/src/client_sync/v23/mod.rs +++ b/client/src/client_sync/v23/mod.rs @@ -54,6 +54,7 @@ crate::impl_client_v17__get_tx_out_set_info!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v24/mod.rs b/client/src/client_sync/v24/mod.rs index 427250df..3e3e162a 100644 --- a/client/src/client_sync/v24/mod.rs +++ b/client/src/client_sync/v24/mod.rs @@ -55,6 +55,7 @@ crate::impl_client_v24__get_tx_spending_prevout!(); crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v25/mod.rs b/client/src/client_sync/v25/mod.rs index d4fa9aca..ed78e40d 100644 --- a/client/src/client_sync/v25/mod.rs +++ b/client/src/client_sync/v25/mod.rs @@ -56,6 +56,7 @@ crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); crate::impl_client_v25__scan_blocks!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v26/mod.rs b/client/src/client_sync/v26/mod.rs index d06fefc7..45612d3d 100644 --- a/client/src/client_sync/v26/mod.rs +++ b/client/src/client_sync/v26/mod.rs @@ -62,6 +62,7 @@ crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); crate::impl_client_v25__scan_blocks!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v27/mod.rs b/client/src/client_sync/v27/mod.rs index c924ab49..f5598365 100644 --- a/client/src/client_sync/v27/mod.rs +++ b/client/src/client_sync/v27/mod.rs @@ -56,6 +56,7 @@ crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); crate::impl_client_v25__scan_blocks!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v28/mod.rs b/client/src/client_sync/v28/mod.rs index 881758d9..9c9f3dfa 100644 --- a/client/src/client_sync/v28/mod.rs +++ b/client/src/client_sync/v28/mod.rs @@ -59,6 +59,7 @@ crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); crate::impl_client_v25__scan_blocks!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v29/mod.rs b/client/src/client_sync/v29/mod.rs index 16160bbb..d523e217 100644 --- a/client/src/client_sync/v29/mod.rs +++ b/client/src/client_sync/v29/mod.rs @@ -59,6 +59,7 @@ crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); crate::impl_client_v25__scan_blocks!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); diff --git a/client/src/client_sync/v30/mod.rs b/client/src/client_sync/v30/mod.rs index 3446ae0e..54e5c899 100644 --- a/client/src/client_sync/v30/mod.rs +++ b/client/src/client_sync/v30/mod.rs @@ -56,6 +56,7 @@ crate::impl_client_v17__precious_block!(); crate::impl_client_v17__prune_blockchain!(); crate::impl_client_v23__save_mempool!(); crate::impl_client_v25__scan_blocks!(); +crate::impl_client_v17__scan_tx_out_set!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); crate::impl_client_v17__wait_for_block!(); diff --git a/integration_test/tests/blockchain.rs b/integration_test/tests/blockchain.rs index cfe97f85..fb1274de 100644 --- a/integration_test/tests/blockchain.rs +++ b/integration_test/tests/blockchain.rs @@ -503,6 +503,29 @@ fn blockchain__scan_blocks_modelled() { let _: ScanBlocksAbort = node.client.scan_blocks_abort().expect("scanblocks abort"); } +#[test] +fn blockchain__scan_tx_out_set_modelled() { + let node = match () { + #[cfg(feature = "v21_and_below")] + () => Node::with_wallet(Wallet::None, &[]), + #[cfg(not(feature = "v21_and_below"))] + () => Node::with_wallet(Wallet::None, &["-coinstatsindex=1"]), + }; + + let dummy_pubkey_hex = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; + let scan_desc = format!("pkh({})", dummy_pubkey_hex); + + let json: ScanTxOutSetStart = + node.client.scan_tx_out_set_start(&[&scan_desc]).expect("scantxoutset start"); + let model: Result = json.into_model(); + model.unwrap(); + + let _: Option = + node.client.scan_tx_out_set_status().expect("scantxoutset status"); + + let _: ScanTxOutSetAbort = node.client.scan_tx_out_set_abort().expect("scantxoutset abort"); +} + #[test] fn blockchain__verify_chain() { let node = Node::with_wallet(Wallet::None, &[]); diff --git a/types/src/model/blockchain.rs b/types/src/model/blockchain.rs index 852dab49..5891dde2 100644 --- a/types/src/model/blockchain.rs +++ b/types/src/model/blockchain.rs @@ -770,3 +770,43 @@ pub struct WaitForNewBlock { /// Block height. pub height: u32, } + +/// Models the result of the JSON-RPC method `scantxoutset` start. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetStart { + /// Whether the scan was completed. + pub success: bool, + /// The number of unspent transaction outputs scanned. For v19 onwards. + pub txouts: Option, + /// The block height at which the scan was done. For v19 onwards. + pub height: Option, + /// The hash of the block at the tip of the chain. For v19 onwards. + pub bestblock: Option, + /// The unspents. + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC. + pub total_amount: Amount, +} + +/// Unspent outputs. Part of `scantxoutset`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id. + pub txid: Txid, + /// The vout value. + pub vout: u32, + /// The output script. + pub script_pubkey: ScriptBuf, + /// A specialized descriptor for the matched output script. For v18 onwards. + pub desc: Option, + /// The total amount in BTC of the unspent output. + pub amount: Amount, + /// Whether this is a coinbase output. For v25 onwards. + pub coinbase: Option, + /// Height of the unspent transaction output. + pub height: u64, + /// Blockhash of the unspent transaction output. For v28 onwards. + pub blockhash: Option, + /// Number of confirmations of the unspent transaction output when the scan was done. For v28 onwards. + pub confirmations: Option, +} diff --git a/types/src/model/mod.rs b/types/src/model/mod.rs index 189b4ca2..d9cf9f9a 100644 --- a/types/src/model/mod.rs +++ b/types/src/model/mod.rs @@ -34,8 +34,8 @@ pub use self::{ GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetRawMempool, GetRawMempoolVerbose, GetTxOut, GetTxOutSetInfo, GetTxSpendingPrevout, GetTxSpendingPrevoutItem, LoadTxOutSet, MempoolEntry, MempoolEntryFees, ReceiveActivity, - ScanBlocksStart, Softfork, SoftforkType, SpendActivity, VerifyTxOutProof, WaitForBlock, - WaitForBlockHeight, WaitForNewBlock, + ScanBlocksStart, ScanTxOutSetStart, ScanTxOutSetUnspent, Softfork, SoftforkType, + SpendActivity, VerifyTxOutProof, WaitForBlock, WaitForBlockHeight, WaitForNewBlock, }, generating::{Generate, GenerateBlock, GenerateToAddress, GenerateToDescriptor}, mining::{ diff --git a/types/src/v17/blockchain/error.rs b/types/src/v17/blockchain/error.rs index 1edcd08d..14bd8825 100644 --- a/types/src/v17/blockchain/error.rs +++ b/types/src/v17/blockchain/error.rs @@ -522,3 +522,59 @@ impl std::error::Error for GetTxOutSetInfoError { impl From for GetTxOutSetInfoError { fn from(e: NumericError) -> Self { Self::Numeric(e) } } + +/// Error when converting a `ScanTxOutSetError` into the model type. +#[derive(Debug)] +pub enum ScanTxOutSetError { + /// Conversion of the `bestblock` field failed. + BestBlockHash(hex::HexToArrayError), + /// Conversion of the `blockhash` field failed. + BlockHash(hex::HexToArrayError), + /// Conversion of the `txid` field failed. + Txid(hex::HexToArrayError), + /// Conversion of the `scriptPubKey` field failed. + ScriptPubKey(hex::HexToBytesError), + /// Conversion of the `total_amount` field failed. + TotalAmount(amount::ParseAmountError), + /// Conversion of the `amount` field failed. + Amount(amount::ParseAmountError), + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), +} + +impl fmt::Display for ScanTxOutSetError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use ScanTxOutSetError::*; + + match self { + BestBlockHash(e) => write_err!(f, "conversion of the `bestblock` field failed"; e), + BlockHash(e) => write_err!(f, "conversion of the `blockhash` field failed"; e), + Txid(e) => write_err!(f, "conversion of the `txid` field failed"; e), + ScriptPubKey(e) => write_err!(f, "conversion of the `scriptPubKey` field failed"; e), + TotalAmount(e) => write_err!(f, "conversion of the `total_amount` field failed"; e), + Amount(e) => write_err!(f, "conversion of the `amount` field failed"; e), + Numeric(e) => write_err!(f, "numeric"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for ScanTxOutSetError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + use ScanTxOutSetError::*; + + match self { + BestBlockHash(e) => Some(e), + BlockHash(e) => Some(e), + Txid(e) => Some(e), + ScriptPubKey(e) => Some(e), + TotalAmount(e) => Some(e), + Amount(e) => Some(e), + Numeric(e) => Some(e), + } + } +} + +impl From for ScanTxOutSetError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} diff --git a/types/src/v17/blockchain/into.rs b/types/src/v17/blockchain/into.rs index c9bdf839..3a8eac84 100644 --- a/types/src/v17/blockchain/into.rs +++ b/types/src/v17/blockchain/into.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: CC0-1.0 use bitcoin::consensus::encode; -use bitcoin::{block, hex, Block, BlockHash, CompactTarget, Txid, Weight, Work}; +use bitcoin::{block, hex, Block, BlockHash, CompactTarget, ScriptBuf, Txid, Weight, Work}; // TODO: Use explicit imports? use super::*; @@ -552,6 +552,50 @@ impl GetTxOutSetInfo { } } +impl ScanTxOutSetStart { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let unspents = + self.unspents.into_iter().map(|u| u.into_model()).collect::, _>>()?; + + let total_amount = Amount::from_btc(self.total_amount).map_err(E::TotalAmount)?; + + Ok(model::ScanTxOutSetStart { + success: self.success, + txouts: None, + height: None, + bestblock: None, + unspents, + total_amount, + }) + } +} + +impl ScanTxOutSetUnspent { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let txid = self.txid.parse::().map_err(E::Txid)?; + let amount = Amount::from_btc(self.amount).map_err(E::Amount)?; + let script_pubkey = ScriptBuf::from_hex(&self.script_pubkey).map_err(E::ScriptPubKey)?; + + Ok(model::ScanTxOutSetUnspent { + txid, + vout: self.vout, + script_pubkey, + desc: None, + amount, + coinbase: None, + height: self.height, + blockhash: None, + confirmations: None, + }) + } +} + impl VerifyTxOutProof { /// Converts version specific type to a version nonspecific, more strongly typed type. pub fn into_model(self) -> Result { diff --git a/types/src/v17/blockchain/mod.rs b/types/src/v17/blockchain/mod.rs index cdebb87d..f4e37ced 100644 --- a/types/src/v17/blockchain/mod.rs +++ b/types/src/v17/blockchain/mod.rs @@ -679,6 +679,56 @@ pub struct PruneBlockchain( pub i64, ); +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. "action" (string, required) The action to execute +/// > 2. "scanobjects" (array, required) Array of scan objects +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetStart { + /// Whether the scan is completed. + pub success: bool, + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, + /// Undocumented searched_items field. + pub searched_items: u64, +} + +/// Result of JSON-RPC method `scantxoutset` when action is `abort`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetAbort(pub bool); + +/// Result of JSON-RPC method `scantxoutset` when action is `status`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetStatus { + /// Approximate percent complete. + pub progress: f64, +} + +/// Unspent output item. Part of `scantxoutset`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetUnspent { + /// The transaction id. + pub txid: String, + /// The vout value. + pub vout: u32, + /// The output script. + #[serde(rename = "scriptPubKey")] + pub script_pubkey: String, + /// The total amount in BTC of the unspent output. + pub amount: f64, + /// Height of the unspent transaction output. + pub height: u64, +} + /// Result of JSON-RPC method `verifychain`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index bd6ab153..2932815d 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -47,7 +47,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -244,8 +244,9 @@ pub use self::{ GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, GetRawMempool, GetRawMempoolVerbose, GetTxOut, GetTxOutError, GetTxOutSetInfo, GetTxOutSetInfoError, MapMempoolEntryError, MempoolEntry, MempoolEntryError, - MempoolEntryFees, MempoolEntryFeesError, PruneBlockchain, Softfork, SoftforkReject, - VerifyChain, VerifyTxOutProof, + MempoolEntryFees, MempoolEntryFeesError, PruneBlockchain, ScanTxOutSetAbort, + ScanTxOutSetError, ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent, Softfork, + SoftforkReject, VerifyChain, VerifyTxOutProof, }, control::{GetMemoryInfoStats, Locked, Logging}, generating::{Generate, GenerateToAddress}, diff --git a/types/src/v18/blockchain/into.rs b/types/src/v18/blockchain/into.rs index 2fb6d06d..935c3047 100644 --- a/types/src/v18/blockchain/into.rs +++ b/types/src/v18/blockchain/into.rs @@ -2,12 +2,13 @@ use alloc::collections::BTreeMap; -use bitcoin::{hex, Txid, Wtxid}; +use bitcoin::{hex, Amount, ScriptBuf, Txid, Wtxid}; use super::{ GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetRawMempool, GetRawMempoolVerbose, - MapMempoolEntryError, MempoolEntry, MempoolEntryError, + MapMempoolEntryError, MempoolEntry, MempoolEntryError, ScanTxOutSetError, ScanTxOutSetStart, + ScanTxOutSetUnspent, }; use crate::model; @@ -134,3 +135,47 @@ impl GetRawMempoolVerbose { Ok(model::GetRawMempoolVerbose(map)) } } + +impl ScanTxOutSetStart { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let unspents = + self.unspents.into_iter().map(|u| u.into_model()).collect::, _>>()?; + + let total_amount = Amount::from_btc(self.total_amount).map_err(E::TotalAmount)?; + + Ok(model::ScanTxOutSetStart { + success: self.success, + txouts: None, + height: None, + bestblock: None, + unspents, + total_amount, + }) + } +} + +impl ScanTxOutSetUnspent { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let txid = self.txid.parse::().map_err(E::Txid)?; + let amount = Amount::from_btc(self.amount).map_err(E::Amount)?; + let script_pubkey = ScriptBuf::from_hex(&self.script_pubkey).map_err(E::ScriptPubKey)?; + + Ok(model::ScanTxOutSetUnspent { + txid, + vout: self.vout, + script_pubkey, + desc: Some(self.descriptor), + amount, + coinbase: None, + height: self.height, + blockhash: None, + confirmations: None, + }) + } +} diff --git a/types/src/v18/blockchain/mod.rs b/types/src/v18/blockchain/mod.rs index f288164c..625d38b3 100644 --- a/types/src/v18/blockchain/mod.rs +++ b/types/src/v18/blockchain/mod.rs @@ -10,7 +10,7 @@ use alloc::collections::BTreeMap; use serde::{Deserialize, Serialize}; -use super::{MapMempoolEntryError, MempoolEntryError, MempoolEntryFees}; +use super::{MapMempoolEntryError, MempoolEntryError, MempoolEntryFees, ScanTxOutSetError}; /// Result of JSON-RPC method `getmempoolancestors` with verbose set to `false`. /// @@ -127,3 +127,43 @@ pub struct GetRawMempool(pub Vec); #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] pub struct GetRawMempoolVerbose(pub BTreeMap); + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. "action" (string, required) The action to execute +/// > 2. "scanobjects" (array, required) Array of scan objects +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetStart { + /// Whether the scan is completed. + pub success: bool, + /// The unspents. + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC. + pub total_amount: f64, + /// Undocumented searched_items field. + pub searched_items: u64, +} + +/// Unspent outputs. Part of `scantxoutset`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetUnspent { + /// The transaction id. + pub txid: String, + /// The vout value. + pub vout: u32, + /// The output script. + #[serde(rename = "scriptPubKey")] + pub script_pubkey: String, + /// A specialized descriptor for the matched output script. + #[serde(rename = "desc")] + pub descriptor: String, + /// The total amount in BTC of the unspent output. + pub amount: f64, + /// Height of the unspent transaction output. + pub height: u64, +} diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index 45c60d87..8a220daa 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -47,7 +47,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -236,7 +236,7 @@ pub use self::{ blockchain::{ GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetRawMempool, GetRawMempoolVerbose, - MempoolEntry, + MempoolEntry, ScanTxOutSetStart, ScanTxOutSetUnspent, }, control::{ActiveCommand, GetRpcInfo}, network::{GetNodeAddresses, GetPeerInfo, NodeAddress, PeerInfo}, @@ -282,13 +282,14 @@ pub use crate::v17::{ MapMempoolEntryError, MempoolAcceptance, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, PsbtScript, RawTransaction, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, - SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, Softfork, SoftforkReject, - TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, - ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, - WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, WitnessUtxoError, + RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScanTxOutSetAbort, + ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendMany, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, + SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, + SignRawTransactionWithWallet, Softfork, SoftforkReject, TestMempoolAccept, TransactionCategory, + TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }; diff --git a/types/src/v19/blockchain/into.rs b/types/src/v19/blockchain/into.rs index 6dca9877..8481107f 100644 --- a/types/src/v19/blockchain/into.rs +++ b/types/src/v19/blockchain/into.rs @@ -13,7 +13,7 @@ use super::{ GetBlockFilter, GetBlockchainInfo, GetChainTxStats, GetChainTxStatsError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetMempoolInfoError, GetRawMempool, GetRawMempoolVerbose, - MempoolEntry, MempoolEntryFees, + MempoolEntry, MempoolEntryFees, ScanTxOutSetError, ScanTxOutSetStart, }; use crate::model; @@ -262,3 +262,26 @@ impl GetRawMempoolVerbose { Ok(model::GetRawMempoolVerbose(map)) } } + +impl ScanTxOutSetStart { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let bestblock = self.best_block.parse::().map_err(E::BestBlockHash)?; + + let unspents = + self.unspents.into_iter().map(|u| u.into_model()).collect::, _>>()?; + + let total_amount = Amount::from_btc(self.total_amount).map_err(E::TotalAmount)?; + + Ok(model::ScanTxOutSetStart { + success: self.success, + txouts: Some(self.txouts), + height: Some(self.height), + bestblock: Some(bestblock), + unspents, + total_amount, + }) + } +} diff --git a/types/src/v19/blockchain/mod.rs b/types/src/v19/blockchain/mod.rs index ac757941..bd4679a7 100644 --- a/types/src/v19/blockchain/mod.rs +++ b/types/src/v19/blockchain/mod.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; // TODO: Remove wildcard, use explicit types. pub use self::error::*; -use super::{GetChainTxStatsError, GetMempoolInfoError}; +use super::{GetChainTxStatsError, GetMempoolInfoError, ScanTxOutSetError, ScanTxOutSetUnspent}; /// Result of JSON-RPC method `getblockchaininfo`. /// @@ -358,3 +358,28 @@ pub struct GetRawMempool(pub Vec); #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] pub struct GetRawMempoolVerbose(pub BTreeMap); + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. action (string, required) The action to execute +/// > 2. scanobjects (json array, required) Array of scan objects +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetStart { + /// Whether the scan was completed. + pub success: bool, + /// The number of unspent transaction outputs scanned. + pub txouts: u64, + /// The block height at which the scan was done. + pub height: u64, + /// The hash of the block at the tip of the chain. + #[serde(rename = "bestblock")] + pub best_block: String, + /// The unspents. + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC. + pub total_amount: f64, +} diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index e481cbf2..77d7a5ce 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -239,7 +239,7 @@ pub use self::{ GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetRawMempool, GetRawMempoolVerbose, MapMempoolEntryError, MempoolEntry, MempoolEntryError, - MempoolEntryFees, MempoolEntryFeesError, Softfork, SoftforkType, + MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSetStart, Softfork, SoftforkType, }, control::GetRpcInfo, network::{GetNetworkInfo, GetPeerInfo, PeerInfo}, @@ -275,8 +275,9 @@ pub use crate::v17::{ ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging, MempoolAcceptance, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawTransactionError, RawTransactionInput, RawTransactionOutput, - RescanBlockchain, ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, - SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + RescanBlockchain, ScanTxOutSetAbort, ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, + SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, + SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, @@ -291,5 +292,6 @@ pub use crate::v18::{ GetAddressInfoError, GetNodeAddresses, GetReceivedByLabel, GetZmqNotifications, ImportMulti, ImportMultiEntry, JoinPsbts, JsonRpcError, ListReceivedByAddress, ListReceivedByAddressItem, ListReceivedByLabel, ListReceivedByLabelError, ListReceivedByLabelItem, ListUnspent, - ListUnspentItem, ListWalletDir, ListWalletDirWallet, NodeAddress, UtxoUpdatePsbt, + ListUnspentItem, ListWalletDir, ListWalletDirWallet, NodeAddress, ScanTxOutSetUnspent, + UtxoUpdatePsbt, }; diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 2d29314f..e91ea7db 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -271,14 +271,14 @@ pub use crate::{ LoadWallet, LockUnspent, Locked, MempoolAcceptance, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, - ScriptType, SendMany, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, - SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, - SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, - SoftforkReject, TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, - ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, - WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, - WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, + ScanTxOutSetAbort, ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendMany, + SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, + SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, + TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -296,6 +296,7 @@ pub use crate::{ GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetNetworkInfo, GetPeerInfo, GetRawMempool, GetRawMempoolVerbose, GetRpcInfo, GetWalletInfo, GetWalletInfoScanning, MapMempoolEntryError, MempoolEntry, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, PeerInfo, SetWalletFlag, Softfork, SoftforkType, + MempoolEntryFeesError, PeerInfo, ScanTxOutSetStart, ScanTxOutSetUnspent, SetWalletFlag, + Softfork, SoftforkType, }, }; diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index fb83edc8..d3c631cf 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -287,14 +287,15 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, - SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, - TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, - WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, + RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScanTxOutSetAbort, + ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, + SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, + SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -308,7 +309,8 @@ pub use crate::{ Bip9SoftforkStatistics, Bip9SoftforkStatus, GetBalances, GetBalancesError, GetBalancesMine, GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo, GetRpcInfo, MapMempoolEntryError, MempoolEntryError, - MempoolEntryFees, MempoolEntryFeesError, SetWalletFlag, + MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSetStart, ScanTxOutSetUnspent, + SetWalletFlag, }, v20::{ AddMultisigAddress, Banned, CreateMultisig, GenerateToDescriptor, GetAddressInfo, diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index efe44a15..dad45348 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -290,14 +290,15 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawTransactionError, - RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScriptType, - SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, - SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, - SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, - TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, - WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, + RawTransactionInput, RawTransactionOutput, RescanBlockchain, ScanTxOutSetAbort, + ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendRawTransaction, SendToAddress, + SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, + SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, + SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -316,7 +317,7 @@ pub use crate::{ v20::{ AddMultisigAddress, CreateMultisig, GenerateToDescriptor, GetTransaction, GetTransactionDetail, ListSinceBlock, ListSinceBlockError, ListTransactions, - TransactionItem, TransactionItemError, + ScanTxOutSetStart, ScanTxOutSetUnspent, TransactionItem, TransactionItemError, }, v21::{ AddPeerAddress, Bip9SoftforkInfo, GenerateBlock, GetBlockchainInfo, GetIndexInfo, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index ff562eef..75b49713 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -50,7 +50,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | version | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -289,14 +289,15 @@ pub use crate::{ ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, - SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, - WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, + RawTransactionOutput, RescanBlockchain, ScanTxOutSetAbort, ScanTxOutSetError, + ScanTxOutSetStatus, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, + SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -311,7 +312,8 @@ pub use crate::{ GetBalancesError, GetBalancesMine, GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo, GetRpcInfo, MapMempoolEntryError, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, SetWalletFlag, Softfork, SoftforkType, + MempoolEntryFeesError, ScanTxOutSetStart, ScanTxOutSetUnspent, SetWalletFlag, Softfork, + SoftforkType, }, v20::{GenerateToDescriptor, GetTransactionDetail}, v21::{ diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index d9b9904a..52f63bcc 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -51,7 +51,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | version | | //! | savemempool | version | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -289,14 +289,15 @@ pub use crate::{ ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, - SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, - WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, + RawTransactionOutput, RescanBlockchain, ScanTxOutSetAbort, ScanTxOutSetError, + ScanTxOutSetStatus, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, + SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -311,7 +312,8 @@ pub use crate::{ GetBalancesError, GetBalancesMine, GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfoError, GetChainTxStats, GetDescriptorInfo, GetRpcInfo, MapMempoolEntryError, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, SetWalletFlag, Softfork, SoftforkType, + MempoolEntryFeesError, ScanTxOutSetStart, ScanTxOutSetUnspent, SetWalletFlag, Softfork, + SoftforkType, }, v20::GenerateToDescriptor, v21::{ diff --git a/types/src/v25/blockchain/into.rs b/types/src/v25/blockchain/into.rs index 595970eb..db01a9c5 100644 --- a/types/src/v25/blockchain/into.rs +++ b/types/src/v25/blockchain/into.rs @@ -1,9 +1,12 @@ // SPDX-License-Identifier: CC0-1.0 -use bitcoin::{Amount, BlockHash, FeeRate, Weight}; +use bitcoin::{Amount, BlockHash, FeeRate, ScriptBuf, Txid, Weight}; use super::error::ScanBlocksStartError; -use super::{GetBlockStats, GetBlockStatsError, ScanBlocksStart}; +use super::{ + GetBlockStats, GetBlockStatsError, ScanBlocksStart, ScanTxOutSetError, ScanTxOutSetStart, + ScanTxOutSetUnspent, +}; use crate::model; impl GetBlockStats { @@ -78,3 +81,49 @@ impl ScanBlocksStart { }) } } + +impl ScanTxOutSetStart { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let bestblock = self.best_block.parse::().map_err(E::BestBlockHash)?; + + let unspents = + self.unspents.into_iter().map(|u| u.into_model()).collect::, _>>()?; + + let total_amount = Amount::from_btc(self.total_amount).map_err(E::TotalAmount)?; + + Ok(model::ScanTxOutSetStart { + success: self.success, + txouts: Some(self.txouts), + height: Some(self.height), + bestblock: Some(bestblock), + unspents, + total_amount, + }) + } +} + +impl ScanTxOutSetUnspent { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let txid = self.txid.parse::().map_err(E::Txid)?; + let amount = Amount::from_btc(self.amount).map_err(E::Amount)?; + let script_pubkey = ScriptBuf::from_hex(&self.script_pubkey).map_err(E::ScriptPubKey)?; + + Ok(model::ScanTxOutSetUnspent { + txid, + vout: self.vout, + script_pubkey, + desc: Some(self.descriptor), + amount, + coinbase: Some(self.coinbase), + height: self.height, + blockhash: None, + confirmations: None, + }) + } +} diff --git a/types/src/v25/blockchain/mod.rs b/types/src/v25/blockchain/mod.rs index 978842cb..dcbe9c27 100644 --- a/types/src/v25/blockchain/mod.rs +++ b/types/src/v25/blockchain/mod.rs @@ -10,7 +10,7 @@ mod into; use serde::{Deserialize, Serialize}; pub use self::error::ScanBlocksStartError; -pub use super::GetBlockStatsError; +pub use super::{GetBlockStatsError, ScanTxOutSetError}; /// Result of JSON-RPC method `getblockstats`. /// @@ -154,3 +154,50 @@ pub struct ScanBlocksStatus { /// Height of the block currently being scanned pub current_height: i64, } + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. action (string, required) The action to execute +/// > 2. scanobjects (json array, required) Array of scan objects +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetStart { + /// Whether the scan was completed. + pub success: bool, + /// The number of unspent transaction outputs scanned. + pub txouts: u64, + /// The block height at which the scan was done. + pub height: u64, + /// The hash of the block at the tip of the chain. + #[serde(rename = "bestblock")] + pub best_block: String, + /// The unspents. + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC. + pub total_amount: f64, +} + +/// Unspent outputs. Part of `scantxoutset`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetUnspent { + /// The transaction id. + pub txid: String, + /// The vout value. + pub vout: u32, + /// The output script. + #[serde(rename = "scriptPubKey")] + pub script_pubkey: String, + /// A specialized descriptor for the matched output script. + #[serde(rename = "desc")] + pub descriptor: String, + /// The total amount in BTC of the unspent output. + pub amount: f64, + /// Whether this is a coinbase output. + pub coinbase: bool, + /// Height of the unspent transaction output. + pub height: u64, +} diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index 7a31ef90..277bf8a3 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -52,7 +52,7 @@ //! | pruneblockchain | version | | //! | savemempool | version | | //! | scanblocks | version + model | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -250,6 +250,7 @@ mod wallet; pub use self::{ blockchain::{ GetBlockStats, ScanBlocksAbort, ScanBlocksStart, ScanBlocksStartError, ScanBlocksStatus, + ScanTxOutSetStart, ScanTxOutSetUnspent, }, control::Logging, generating::{GenerateBlock, GenerateBlockError}, @@ -283,14 +284,15 @@ pub use crate::{ ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, - SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, - SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, - ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, - WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, + RawTransactionOutput, RescanBlockchain, ScanTxOutSetAbort, ScanTxOutSetError, + ScanTxOutSetStatus, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, + SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, + VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, + WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, + WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index 482fa991..ee760691 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -56,7 +56,7 @@ //! | pruneblockchain | version | | //! | savemempool | version | | //! | scanblocks | version + model | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -300,13 +300,14 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, - ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, - SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, - SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, - SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, - VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, - WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, - WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, + ScanTxOutSetAbort, ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, + TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -352,7 +353,7 @@ pub use crate::{ v25::{ DescriptorInfo, GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, MempoolAcceptanceError, MempoolAcceptanceFees, ScanBlocksAbort, - ScanBlocksStart, ScanBlocksStartError, ScanBlocksStatus, TestMempoolAccept, - TestMempoolAcceptError, + ScanBlocksStart, ScanBlocksStartError, ScanBlocksStatus, ScanTxOutSetStart, + ScanTxOutSetUnspent, TestMempoolAccept, TestMempoolAcceptError, }, }; diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 63c4bf47..12293c13 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -56,7 +56,7 @@ //! | pruneblockchain | version | | //! | savemempool | version | | //! | scanblocks | version + model | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -276,13 +276,14 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, - ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, - SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, - SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, - SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, - VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, - WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, - WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, + ScanTxOutSetAbort, ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, + TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -328,8 +329,8 @@ pub use crate::{ v25::{ DescriptorInfo, GenerateBlock, GenerateBlockError, GetBlockStats, ListDescriptors, MempoolAcceptance, MempoolAcceptanceError, MempoolAcceptanceFees, ScanBlocksAbort, - ScanBlocksStart, ScanBlocksStartError, ScanBlocksStatus, TestMempoolAccept, - TestMempoolAcceptError, + ScanBlocksStart, ScanBlocksStartError, ScanBlocksStatus, ScanTxOutSetStart, + ScanTxOutSetUnspent, TestMempoolAccept, TestMempoolAcceptError, }, v26::{ AddrManInfoNetwork, ChainState, CreateWallet, DescriptorProcessPsbt, diff --git a/types/src/v28/blockchain/into.rs b/types/src/v28/blockchain/into.rs new file mode 100644 index 00000000..6a11d007 --- /dev/null +++ b/types/src/v28/blockchain/into.rs @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: CC0-1.0 + +use bitcoin::{Amount, BlockHash, ScriptBuf, Txid}; + +use super::{ScanTxOutSetError, ScanTxOutSetStart, ScanTxOutSetUnspent}; +use crate::model; + +impl ScanTxOutSetStart { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let bestblock = self.best_block.parse::().map_err(E::BestBlockHash)?; + + let unspents = + self.unspents.into_iter().map(|u| u.into_model()).collect::, _>>()?; + + let total_amount = Amount::from_btc(self.total_amount).map_err(E::TotalAmount)?; + + Ok(model::ScanTxOutSetStart { + success: self.success, + txouts: Some(self.txouts), + height: Some(self.height), + bestblock: Some(bestblock), + unspents, + total_amount, + }) + } +} + +impl ScanTxOutSetUnspent { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use ScanTxOutSetError as E; + + let txid = self.txid.parse::().map_err(E::Txid)?; + let amount = Amount::from_btc(self.amount).map_err(E::Amount)?; + let script_pubkey = ScriptBuf::from_hex(&self.script_pubkey).map_err(E::ScriptPubKey)?; + let blockhash = self.block_hash.parse::().map_err(E::BlockHash)?; + + Ok(model::ScanTxOutSetUnspent { + txid, + vout: self.vout, + script_pubkey, + desc: Some(self.descriptor), + amount, + coinbase: Some(self.coinbase), + height: self.height, + blockhash: Some(blockhash), + confirmations: Some(self.confirmations), + }) + } +} diff --git a/types/src/v28/blockchain.rs b/types/src/v28/blockchain/mod.rs similarity index 68% rename from types/src/v28/blockchain.rs rename to types/src/v28/blockchain/mod.rs index 31dff9a8..4b53cdef 100644 --- a/types/src/v28/blockchain.rs +++ b/types/src/v28/blockchain/mod.rs @@ -4,12 +4,14 @@ //! //! Types for methods found under the `== Blockchain ==` section of the API docs. +mod into; + use alloc::collections::BTreeMap; use bitcoin::{BlockHash, Network, Work}; use serde::{Deserialize, Serialize}; -use super::{GetBlockchainInfoError, Softfork}; +use super::{GetBlockchainInfoError, ScanTxOutSetError, Softfork}; use crate::model; /// Result of JSON-RPC method `getblockchaininfo`. @@ -103,3 +105,55 @@ impl GetBlockchainInfo { }) } } + +/// Result of JSON-RPC method `scantxoutset`. +/// +/// > scantxoutset "action" ( [scanobjects,...] ) +/// > +/// > Arguments: +/// > 1. action (string, required) The action to execute +/// > 2. scanobjects (json array, required) Array of scan objects +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetStart { + /// Whether the scan was completed. + pub success: bool, + /// The number of unspent transaction outputs scanned. + pub txouts: u64, + /// The block height at which the scan was done. + pub height: u64, + /// The hash of the block at the tip of the chain. + #[serde(rename = "bestblock")] + pub best_block: String, + /// The unspents. + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC. + pub total_amount: f64, +} + +/// Unspent outputs. Part of `scantxoutset`. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct ScanTxOutSetUnspent { + /// The transaction id. + pub txid: String, + /// The vout value. + pub vout: u32, + /// The output script. + #[serde(rename = "scriptPubKey")] + pub script_pubkey: String, + /// A specialized descriptor for the matched output script. + #[serde(rename = "desc")] + pub descriptor: String, + /// The total amount in BTC of the unspent output. + pub amount: f64, + /// Whether this is a coinbase output. + pub coinbase: bool, + /// Height of the unspent transaction output. + pub height: u64, + /// Blockhash of the unspent transaction output. + #[serde(rename = "blockhash")] + pub block_hash: String, + /// Number of confirmations of the unspent transaction output when the scan was done. + pub confirmations: u64, +} diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 66fbc130..c1bead38 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -56,7 +56,7 @@ //! | pruneblockchain | version | | //! | savemempool | version | | //! | scanblocks | version + model | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -259,7 +259,7 @@ mod wallet; #[doc(inline)] pub use self::{ - blockchain::GetBlockchainInfo, + blockchain::{GetBlockchainInfo, ScanTxOutSetStart, ScanTxOutSetUnspent}, control::Logging, mining::GetMiningInfo, network::GetNetworkInfo, @@ -297,13 +297,14 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, - ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, - SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, - SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, - SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, - VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, - WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, - WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, + ScanTxOutSetAbort, ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, + TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index bd683ca9..9ff225d6 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -57,7 +57,7 @@ //! | pruneblockchain | version | | //! | savemempool | version | | //! | scanblocks | version + model | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! @@ -290,13 +290,14 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, RawTransactionOutput, RescanBlockchain, - ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, SetTxFee, SignFail, - SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, - SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, - TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, - WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, + ScanTxOutSetAbort, ScanTxOutSetError, ScanTxOutSetStatus, ScriptType, SendRawTransaction, + SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, + SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, + SignRawTransactionWithKey, SignRawTransactionWithWallet, TransactionCategory, UploadTarget, + ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, + WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -354,8 +355,9 @@ pub use crate::{ v28::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, GetNetworkInfo, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, - ListSinceBlockError, ListTransactions, Logging, SubmitPackage, SubmitPackageError, - SubmitPackageTxResult, SubmitPackageTxResultError, SubmitPackageTxResultFees, - SubmitPackageTxResultFeesError, TransactionItem, TransactionItemError, + ListSinceBlockError, ListTransactions, Logging, ScanTxOutSetStart, ScanTxOutSetUnspent, + SubmitPackage, SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, + SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, TransactionItem, + TransactionItemError, }, }; diff --git a/types/src/v30/mod.rs b/types/src/v30/mod.rs index 9fd6453f..936a1a66 100644 --- a/types/src/v30/mod.rs +++ b/types/src/v30/mod.rs @@ -57,7 +57,7 @@ //! | pruneblockchain | version | | //! | savemempool | version | | //! | scanblocks | version + model | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | //! | waitforblock | version + model | | @@ -284,14 +284,14 @@ pub use crate::{ ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendRawTransaction, SendToAddress, - SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, - SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, - SignRawTransactionWithWallet, TransactionCategory, UploadTarget, ValidateAddress, - ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, - WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, - WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, - WitnessUtxoError, + RawTransactionOutput, RescanBlockchain, ScanTxOutSetAbort, ScanTxOutSetError, + ScanTxOutSetStatus, ScriptType, SendRawTransaction, SendToAddress, SetNetworkActive, + SetTxFee, SignFail, SignFailError, SignMessage, SignMessageWithPrivKey, SignRawTransaction, + SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, + TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, @@ -343,9 +343,10 @@ pub use crate::{ v28::{ CreateWalletDescriptor, GetAddressInfo, GetAddressInfoEmbedded, GetHdKeys, GetHdKeysError, GetNetworkInfo, GetTransaction, HdKey, HdKeyDescriptor, ListSinceBlock, - ListSinceBlockError, ListTransactions, Logging, SubmitPackage, SubmitPackageError, - SubmitPackageTxResult, SubmitPackageTxResultError, SubmitPackageTxResultFees, - SubmitPackageTxResultFeesError, TransactionItem, TransactionItemError, + ListSinceBlockError, ListTransactions, Logging, ScanTxOutSetStart, ScanTxOutSetUnspent, + SubmitPackage, SubmitPackageError, SubmitPackageTxResult, SubmitPackageTxResultError, + SubmitPackageTxResultFees, SubmitPackageTxResultFeesError, TransactionItem, + TransactionItemError, }, v29::{ ActivityEntry, ChainState, DeriveAddressesMultipath, GetBlockHeader, GetBlockHeaderError, diff --git a/verify/src/method/v17.rs b/verify/src/method/v17.rs index 794bbef1..e14f70e0 100644 --- a/verify/src/method/v17.rs +++ b/verify/src/method/v17.rs @@ -32,7 +32,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_nothing("savemempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v18.rs b/verify/src/method/v18.rs index 0e58b075..c32df830 100644 --- a/verify/src/method/v18.rs +++ b/verify/src/method/v18.rs @@ -32,7 +32,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_nothing("savemempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v19.rs b/verify/src/method/v19.rs index a2127ab4..f4f18693 100644 --- a/verify/src/method/v19.rs +++ b/verify/src/method/v19.rs @@ -33,7 +33,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_nothing("savemempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), diff --git a/verify/src/method/v20.rs b/verify/src/method/v20.rs index b6dd89aa..0bc05ae9 100644 --- a/verify/src/method/v20.rs +++ b/verify/src/method/v20.rs @@ -33,7 +33,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_nothing("savemempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), diff --git a/verify/src/method/v21.rs b/verify/src/method/v21.rs index 4bf08f1a..8f736608 100644 --- a/verify/src/method/v21.rs +++ b/verify/src/method/v21.rs @@ -33,7 +33,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_nothing("savemempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v22.rs b/verify/src/method/v22.rs index 6b7ef498..7bd79055 100644 --- a/verify/src/method/v22.rs +++ b/verify/src/method/v22.rs @@ -33,7 +33,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_nothing("savemempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v23.rs b/verify/src/method/v23.rs index 290d5daa..1f7ba624 100644 --- a/verify/src/method/v23.rs +++ b/verify/src/method/v23.rs @@ -35,7 +35,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v24.rs b/verify/src/method/v24.rs index 22bc17ef..66055981 100644 --- a/verify/src/method/v24.rs +++ b/verify/src/method/v24.rs @@ -36,7 +36,7 @@ pub const METHODS: &[Method] = &[ Method::new_nothing("preciousblock", "precious_block"), Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v25.rs b/verify/src/method/v25.rs index 4a5603ee..2566594a 100644 --- a/verify/src/method/v25.rs +++ b/verify/src/method/v25.rs @@ -37,7 +37,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocksStart", "scan_blocks"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v26.rs b/verify/src/method/v26.rs index a8329fe2..771c6972 100644 --- a/verify/src/method/v26.rs +++ b/verify/src/method/v26.rs @@ -41,7 +41,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocksStart", "scan_blocks"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v27.rs b/verify/src/method/v27.rs index 6a05663c..5497566b 100644 --- a/verify/src/method/v27.rs +++ b/verify/src/method/v27.rs @@ -41,7 +41,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocksStart", "scan_blocks"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), diff --git a/verify/src/method/v28.rs b/verify/src/method/v28.rs index eebcb626..51174e1e 100644 --- a/verify/src/method/v28.rs +++ b/verify/src/method/v28.rs @@ -41,7 +41,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocksStart", "scan_blocks"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_no_model("getrpcinfo", "GetRpcInfo", "get_rpc_info"), diff --git a/verify/src/method/v29.rs b/verify/src/method/v29.rs index 926f641e..79343d99 100644 --- a/verify/src/method/v29.rs +++ b/verify/src/method/v29.rs @@ -46,7 +46,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocksStart", "scan_blocks"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), // control diff --git a/verify/src/method/v30.rs b/verify/src/method/v30.rs index 74b9a0e1..92a36a7d 100644 --- a/verify/src/method/v30.rs +++ b/verify/src/method/v30.rs @@ -46,7 +46,7 @@ pub const METHODS: &[Method] = &[ Method::new_no_model("pruneblockchain", "PruneBlockchain", "prune_blockchain"), Method::new_no_model("savemempool", "SaveMempool", "save_mempool"), Method::new_modelled("scanblocks", "ScanBlocksStart", "scan_blocks"), - Method::new_modelled("scantxoutset", "ScanTxOutSet", "scan_tx_out_set"), + Method::new_modelled("scantxoutset", "ScanTxOutSetStart", "scan_tx_out_set"), Method::new_no_model("verifychain", "VerifyChain", "verify_chain"), Method::new_modelled("verifytxoutproof", "VerifyTxOutProof", "verify_tx_out_proof"), Method::new_modelled("waitforblock", "WaitForBlock", "wait_for_block"),