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 7ad22305..cadc8234 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 cb3d9e47..196ee356 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 dfc00400..8c9a1e88 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 40c2eed6..d743e9b1 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 f532abdb..5f6d8b21 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 1e0b542b..8ea05da7 100644 --- a/client/src/client_sync/v22/mod.rs +++ b/client/src/client_sync/v22/mod.rs @@ -52,6 +52,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 aba9cd2b..923fd2b5 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 617dba69..34c17249 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 b17d955d..8050468a 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 b1f021a3..85352002 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 385a122a..414c4c05 100644 --- a/client/src/client_sync/v27/mod.rs +++ b/client/src/client_sync/v27/mod.rs @@ -58,6 +58,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 422ad4e0..7be2fb84 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 851c2c2a..4574b314 100644 --- a/client/src/client_sync/v29/mod.rs +++ b/client/src/client_sync/v29/mod.rs @@ -60,6 +60,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 7acb8cbd..bbda9242 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__estimate_raw_fee!(); diff --git a/integration_test/tests/blockchain.rs b/integration_test/tests/blockchain.rs index eac27c39..baaf80cf 100644 --- a/integration_test/tests/blockchain.rs +++ b/integration_test/tests/blockchain.rs @@ -507,6 +507,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 42602db9..720d4f0b 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 tx_outs: 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 best_block: 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 descriptor: 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 block_hash: 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 70c8ddfd..3437ffea 100644 --- a/types/src/model/mod.rs +++ b/types/src/model/mod.rs @@ -35,8 +35,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}, hidden::{ diff --git a/types/src/v17/blockchain/error.rs b/types/src/v17/blockchain/error.rs index 1edcd08d..5e483566 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 `best_block` field failed. + BestBlockHash(hex::HexToArrayError), + /// Conversion of the `block_hash` field failed. + BlockHash(hex::HexToArrayError), + /// Conversion of the `txid` field failed. + Txid(hex::HexToArrayError), + /// Conversion of the `script_pubkey` 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 `best_block` field failed"; e), + BlockHash(e) => write_err!(f, "conversion of the `block_hash` field failed"; e), + Txid(e) => write_err!(f, "conversion of the `txid` field failed"; e), + ScriptPubKey(e) => write_err!(f, "conversion of the `script_pubkey` 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 0bad48c8..16399441 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::*; @@ -551,6 +551,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, + tx_outs: None, + height: None, + best_block: 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, + descriptor: None, + amount, + coinbase: None, + height: self.height, + block_hash: 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 cb50a7cb..443e81db 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 7f96e791..0ef6aa0a 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..2f6e77ba 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, + tx_outs: None, + height: None, + best_block: 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, + descriptor: Some(self.descriptor), + amount, + coinbase: None, + height: self.height, + block_hash: 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 cbc8c5e9..142ea608 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}, @@ -283,8 +283,9 @@ pub use crate::v17::{ MempoolEntryFeesError, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, PsbtScript, RawFeeDetail, RawFeeRange, RawTransaction, 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, Softfork, SoftforkReject, TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, diff --git a/types/src/v19/blockchain/into.rs b/types/src/v19/blockchain/into.rs index 092fceb5..fd60814d 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; @@ -261,3 +261,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 best_block = 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, + tx_outs: Some(self.tx_outs), + height: Some(self.height), + best_block: Some(best_block), + unspents, + total_amount, + }) + } +} diff --git a/types/src/v19/blockchain/mod.rs b/types/src/v19/blockchain/mod.rs index 2418911a..d2cffe6e 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,29 @@ 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. + #[serde(rename = "txouts")] + pub tx_outs: 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 7ea527ef..4d05bdd1 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}, @@ -276,15 +276,15 @@ pub use crate::v17::{ ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, Logging, MempoolAcceptance, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawFeeDetail, RawFeeRange, RawTransactionError, RawTransactionInput, - RawTransactionOutput, RescanBlockchain, ScriptType, SendMany, SendRawTransaction, - SendToAddress, SetNetworkActive, SetTxFee, SignFail, SignFailError, SignMessage, - SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, - SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory, - TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, - VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, - WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, - WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, - WitnessUtxoError, + RawTransactionOutput, 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, + VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WalletProcessPsbt, WitnessUtxo, WitnessUtxoError, }; #[doc(inline)] pub use crate::v18::{ @@ -293,5 +293,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 f7e9ac20..7124547f 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,15 @@ pub use crate::{ LoadWallet, LockUnspent, Locked, MempoolAcceptance, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawFeeDetail, RawFeeRange, 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, + RescanBlockchain, 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 +297,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 b5c05f4d..21ba6e25 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 | | //! @@ -288,14 +288,14 @@ pub use crate::{ LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawFeeDetail, RawFeeRange, 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, + 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, @@ -309,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 625eb65e..cf0b2544 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 | | //! @@ -294,14 +294,14 @@ pub use crate::{ LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, PsbtInput, PsbtInputError, PsbtOutput, PsbtOutputError, RawFeeDetail, RawFeeRange, 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, + 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, @@ -320,7 +320,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 8751859c..37e9f09c 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 | | //! @@ -290,14 +290,14 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawFeeDetail, RawFeeRange, 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, + 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, @@ -312,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 4e232980..774d312b 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 | | //! @@ -290,14 +290,14 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LoadWallet, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawFeeDetail, RawFeeRange, 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, + 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, @@ -312,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..dd7046d6 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 best_block = 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, + tx_outs: Some(self.tx_outs), + height: Some(self.height), + best_block: Some(best_block), + 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, + descriptor: Some(self.descriptor), + amount, + coinbase: Some(self.coinbase), + height: self.height, + block_hash: None, + confirmations: None, + }) + } +} diff --git a/types/src/v25/blockchain/mod.rs b/types/src/v25/blockchain/mod.rs index 978842cb..8bd48359 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,51 @@ 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. + #[serde(rename = "txouts")] + pub tx_outs: 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 899c3947..69f11bb5 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, RawFeeDetail, RawFeeRange, 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, diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index 9886bc97..5a66571f 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, RawFeeDetail, RawFeeRange, 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, + 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, 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 a79980fe..911d107c 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, RawFeeDetail, RawFeeRange, 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, + 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, 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..063c2cbd --- /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 best_block = 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, + tx_outs: Some(self.tx_outs), + height: Some(self.height), + best_block: Some(best_block), + 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 block_hash = self.block_hash.parse::().map_err(E::BlockHash)?; + + Ok(model::ScanTxOutSetUnspent { + txid, + vout: self.vout, + script_pubkey, + descriptor: Some(self.descriptor), + amount, + coinbase: Some(self.coinbase), + height: self.height, + block_hash: Some(block_hash), + confirmations: Some(self.confirmations), + }) + } +} diff --git a/types/src/v28/blockchain.rs b/types/src/v28/blockchain/mod.rs similarity index 67% rename from types/src/v28/blockchain.rs rename to types/src/v28/blockchain/mod.rs index 31dff9a8..38e331fb 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,56 @@ 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. + #[serde(rename = "txouts")] + pub tx_outs: 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 c904851a..e88573eb 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, RawFeeDetail, RawFeeRange, 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, + 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, WitnessUtxo, WitnessUtxoError, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index 9912fda1..a228b0dd 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 | | //! @@ -297,13 +297,14 @@ pub use crate::{ ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawFeeDetail, RawFeeRange, 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, + 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, @@ -361,8 +362,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 70103202..15ddab2e 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 | | @@ -290,14 +290,15 @@ pub use crate::{ ListLockUnspent, ListLockUnspentItem, ListLockUnspentItemError, ListReceivedByAddressError, ListUnspentItemError, ListWallets, LockUnspent, Locked, NumericError, PartialSignatureError, PruneBlockchain, RawFeeDetail, RawFeeRange, 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, + RawTransactionInput, 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, @@ -349,9 +350,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"),