diff --git a/client/src/client_sync/v17/blockchain.rs b/client/src/client_sync/v17/blockchain.rs index 0a5a2c7d..83df4494 100644 --- a/client/src/client_sync/v17/blockchain.rs +++ b/client/src/client_sync/v17/blockchain.rs @@ -318,6 +318,30 @@ macro_rules! impl_client_v17__savemempool { }; } +/// Implements Bitcoin Core JSON-RPC API method `scantxoutset` +#[macro_export] +macro_rules! impl_client_v17__scantxoutset { + () => { + impl Client { + pub fn scan_tx_out_set( + &self, + action: ScanAction, + scan_objects: &[ScanObject], + ) -> Result { + let params = match action { + ScanAction::Start => { + vec![into_json(action)?, into_json(scan_objects)?] + } + ScanAction::Abort | ScanAction::Status => { + vec![into_json(action)?] + } + }; + self.call("scantxoutset", ¶ms) + } + } + }; +} + /// Implements Bitcoin Core JSON-RPC API method `verifychain` #[macro_export] macro_rules! impl_client_v17__verifychain { diff --git a/client/src/client_sync/v17/mod.rs b/client/src/client_sync/v17/mod.rs index 1fc905ab..a4f8e19b 100644 --- a/client/src/client_sync/v17/mod.rs +++ b/client/src/client_sync/v17/mod.rs @@ -48,6 +48,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); @@ -214,3 +215,24 @@ pub struct WalletCreateFundedPsbtInput { txid: Txid, vout: u32, } + +/// Args for the `scantxoutset` +/// +/// Represents the action for the `scantxoutset` RPC call. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum ScanAction { + Start, + Abort, + Status, +} + +/// Represents a scan object for scantxoutset (descriptor string or object). +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[serde(untagged)] +pub enum ScanObject { + /// Plain descriptor string + Descriptor(String), + /// Object containing descriptor and optional range + WithDesc { desc: String }, +} diff --git a/client/src/client_sync/v18/mod.rs b/client/src/client_sync/v18/mod.rs index b944ce45..27142453 100644 --- a/client/src/client_sync/v18/mod.rs +++ b/client/src/client_sync/v18/mod.rs @@ -19,7 +19,10 @@ use crate::types::v18::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{AddressType, Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + AddressType, Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, }; // This publicly re-exports `Client`. @@ -48,6 +51,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v19/mod.rs b/client/src/client_sync/v19/mod.rs index 46296cbf..af0db6a6 100644 --- a/client/src/client_sync/v19/mod.rs +++ b/client/src/client_sync/v19/mod.rs @@ -18,7 +18,10 @@ use crate::types::v19::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{AddressType, Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + AddressType, Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, }; crate::define_jsonrpc_minreq_client!("v19"); @@ -47,6 +50,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v20.rs b/client/src/client_sync/v20.rs index 60d36191..b8cf8479 100644 --- a/client/src/client_sync/v20.rs +++ b/client/src/client_sync/v20.rs @@ -15,7 +15,10 @@ use crate::types::v20::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{AddressType, Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + AddressType, Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, }; crate::define_jsonrpc_minreq_client!("v20"); @@ -44,6 +47,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v21/mod.rs b/client/src/client_sync/v21/mod.rs index bf797687..eb72385c 100644 --- a/client/src/client_sync/v21/mod.rs +++ b/client/src/client_sync/v21/mod.rs @@ -17,7 +17,10 @@ use crate::types::v21::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{AddressType, Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + AddressType, Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, }; crate::define_jsonrpc_minreq_client!("v21"); @@ -46,6 +49,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v22/mod.rs b/client/src/client_sync/v22/mod.rs index 74103a92..fb313373 100644 --- a/client/src/client_sync/v22/mod.rs +++ b/client/src/client_sync/v22/mod.rs @@ -17,7 +17,10 @@ use crate::types::v22::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{AddressType, Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + AddressType, Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, }; crate::define_jsonrpc_minreq_client!("v22"); @@ -46,6 +49,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v17__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v23/mod.rs b/client/src/client_sync/v23/mod.rs index 27729342..01957bed 100644 --- a/client/src/client_sync/v23/mod.rs +++ b/client/src/client_sync/v23/mod.rs @@ -19,7 +19,10 @@ use crate::types::v23::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, }; crate::define_jsonrpc_minreq_client!("v23"); @@ -48,6 +51,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v24.rs b/client/src/client_sync/v24.rs index c18b44d1..de2d2fc8 100644 --- a/client/src/client_sync/v24.rs +++ b/client/src/client_sync/v24.rs @@ -15,7 +15,10 @@ use crate::types::v24::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + Input, Output, ScanAction, ScanObject, TemplateRequest, TemplateRules, + WalletCreateFundedPsbtInput + }, v23::AddressType, }; @@ -45,6 +48,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v25.rs b/client/src/client_sync/v25/mod.rs similarity index 96% rename from client/src/client_sync/v25.rs rename to client/src/client_sync/v25/mod.rs index e80adad1..b5343b7b 100644 --- a/client/src/client_sync/v25.rs +++ b/client/src/client_sync/v25/mod.rs @@ -15,7 +15,10 @@ use crate::types::v25::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + Input, Output, ScanAction, ScanObject, TemplateRequest, TemplateRules, + WalletCreateFundedPsbtInput + }, v23::AddressType, }; @@ -45,6 +48,7 @@ crate::impl_client_v17__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v26/mod.rs b/client/src/client_sync/v26/mod.rs index 9be772f1..b9b8d199 100644 --- a/client/src/client_sync/v26/mod.rs +++ b/client/src/client_sync/v26/mod.rs @@ -19,7 +19,10 @@ use crate::types::v26::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, v23::AddressType, }; @@ -49,6 +52,7 @@ crate::impl_client_v26__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v27.rs b/client/src/client_sync/v27.rs index d2546bb5..64d2d37b 100644 --- a/client/src/client_sync/v27.rs +++ b/client/src/client_sync/v27.rs @@ -15,7 +15,10 @@ use crate::types::v27::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + Input, Output, ScanAction, ScanObject, TemplateRequest, TemplateRules, + WalletCreateFundedPsbtInput + }, v23::AddressType, }; @@ -45,6 +48,7 @@ crate::impl_client_v26__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/client/src/client_sync/v28/mod.rs b/client/src/client_sync/v28/mod.rs index eb3ba176..5873dbad 100644 --- a/client/src/client_sync/v28/mod.rs +++ b/client/src/client_sync/v28/mod.rs @@ -17,7 +17,10 @@ use crate::types::v28::*; #[rustfmt::skip] // Keep public re-exports separate. pub use crate::client_sync::{ - v17::{Input, Output, TemplateRequest, TemplateRules, WalletCreateFundedPsbtInput}, + v17::{ + Input, Output, ScanAction, ScanObject, TemplateRequest, + TemplateRules, WalletCreateFundedPsbtInput + }, v23::AddressType, }; @@ -47,6 +50,7 @@ crate::impl_client_v26__gettxoutsetinfo!(); crate::impl_client_v17__preciousblock!(); crate::impl_client_v17__pruneblockchain!(); crate::impl_client_v23__savemempool!(); +crate::impl_client_v17__scantxoutset!(); crate::impl_client_v17__verifychain!(); crate::impl_client_v17__verifytxoutproof!(); diff --git a/integration_test/tests/blockchain.rs b/integration_test/tests/blockchain.rs index 15ae0f6f..9d4d81ac 100644 --- a/integration_test/tests/blockchain.rs +++ b/integration_test/tests/blockchain.rs @@ -307,6 +307,35 @@ fn blockchain__savemempool() { } } +#[test] +fn blockchain__scan_tx_out_set_modelled() { + #[cfg(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21" + ))] + let node = Node::with_wallet(Wallet::None, &[]); + + #[cfg(not(any( + feature = "v17", + feature = "v18", + feature = "v19", + feature = "v20", + feature = "v21" + )))] + let node = Node::with_wallet(Wallet::None, &["-coinstatsindex=1"]); + + let dummy_pubkey_hex = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; + let scan_desc = format!("pkh({})", dummy_pubkey_hex); + + let scan_objects: node::ScanObject = node::ScanObject::Descriptor(scan_desc); + let action: node::ScanAction = node::ScanAction::Start; + + let _: Result = node.client.scan_tx_out_set(action, &[scan_objects]); +} + #[test] fn blockchain__verify_tx_out_proof__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); diff --git a/types/src/v17/blockchain/mod.rs b/types/src/v17/blockchain/mod.rs index c979a6c3..bdfd33a0 100644 --- a/types/src/v17/blockchain/mod.rs +++ b/types/src/v17/blockchain/mod.rs @@ -650,6 +650,53 @@ 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(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + /// Returns after scan completes + Start(ScanTxOutSetStart), + /// True (scan will be aborted), False (no scan to abort) + Abort(bool), + /// Scan in progress or Completed + Status(Option), +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetStart { + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +pub struct ScanTxOutSetStatus { + /// Approximate percent complete + pub progress: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pubkey: String, + /// The total amount in BTC of 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)] pub struct VerifyChain(pub bool); diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index cbc218f6..6dd06918 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -47,7 +47,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -243,8 +243,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, ScanTxOutSet, ScanTxOutSetStart, + ScanTxOutSetStatus, ScanTxOutSetUnspent, Softfork, SoftforkReject, VerifyChain, + VerifyTxOutProof, }, control::{GetMemoryInfoStats, Locked, Logging}, generating::{Generate, GenerateToAddress}, diff --git a/types/src/v18/blockchain.rs b/types/src/v18/blockchain.rs new file mode 100644 index 00000000..773adc6e --- /dev/null +++ b/types/src/v18/blockchain.rs @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v0.18` - blockchain. +//! +//! Types for methods found under the `== Blockchain ==` section of the API docs. +use serde::{Deserialize, Serialize}; + +/// 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(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + /// Returns after scan completes + Start(ScanTxOutSetStart), + /// True (scan will be aborted), False (no scan to abort) + Abort(bool), + /// Scan in progress or Completed + Status(Option), +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetStart { + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +pub struct ScanTxOutSetStatus { + /// Approximate percent complete + pub progress: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// An output descriptor + pub desc: String, + /// The total amount in BTC of 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 e8e65cdc..5ec17364 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -47,7 +47,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -223,12 +223,14 @@ //! // JSON-RPC types by API section. +mod blockchain; mod control; mod network; mod raw_transactions; #[doc(inline)] pub use self::{ + blockchain::{ScanTxOutSet, ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent}, control::{ActiveCommand, GetRpcInfo}, network::{GetNodeAddresses, NodeAddress}, raw_transactions::{ diff --git a/types/src/v19/blockchain/mod.rs b/types/src/v19/blockchain/mod.rs index 587ee287..44346ad2 100644 --- a/types/src/v19/blockchain/mod.rs +++ b/types/src/v19/blockchain/mod.rs @@ -246,3 +246,60 @@ pub struct MempoolEntryFees { /// Modified fees (see above) of in-mempool descendants (including this one) in BTC. pub descendant: f64, } + +/// 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(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + /// Returns after scan completes + Start(ScanTxOutSetStart), + /// True (scan will be aborted), False (no scan to abort) + Abort(bool), + /// Scan in progress or Completed + Status(Option), +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetStart { + /// Whether the scan is completed + pub success: bool, + /// The number of unspent transaction outputs scanned + pub txouts: u64, + /// The current block height (index) + pub height: u64, + /// The hash of the block at the tip of the chain + pub bestblock: String, + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +pub struct ScanTxOutSetStatus { + /// Approximate percent complete + pub progress: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// An output descriptor + pub desc: String, + /// The total amount in BTC of unspent output + pub amount: f64, + /// Height of the unspent transaction output + pub height: u64, +} diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index a2575db3..3ed493e6 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -235,7 +235,8 @@ pub use self::{ GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, MempoolEntry, MempoolEntryError, MempoolEntryFees, - MempoolEntryFeesError, Softfork, SoftforkType, + MempoolEntryFeesError, ScanTxOutSet, ScanTxOutSetStart, ScanTxOutSetStatus, + ScanTxOutSetUnspent, Softfork, SoftforkType, }, wallet::{GetBalances, GetBalancesMine, GetBalancesWatchOnly}, }; diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 9a4bf72f..1893a573 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -276,7 +276,7 @@ pub use crate::{ GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, - MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, - SoftforkType, + MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSet, + ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent, Softfork, SoftforkType, }, }; diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index 5ff3e581..04079f35 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -282,8 +282,8 @@ pub use crate::{ GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, - MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, - SoftforkType, + MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSet, + ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent, Softfork, SoftforkType, }, v20::Logging, }; diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index 03d1223f..f0dde546 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -48,7 +48,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | returns nothing | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -293,8 +293,8 @@ pub use crate::{ GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, - MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, - SoftforkType, + MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSet, + ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent, Softfork, SoftforkType, }, v21::UnloadWallet, ScriptPubkey, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index ebea75e2..212ad163 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -50,7 +50,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | version | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -292,8 +292,8 @@ pub use crate::{ GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, - MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, - SoftforkType, + MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSet, + ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent, Softfork, SoftforkType, }, v21::UnloadWallet, v22::{Logging, ScriptPubkey}, diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 79f76e5d..e0d865b8 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -51,7 +51,7 @@ //! | preciousblock | returns nothing | | //! | pruneblockchain | returns numeric | | //! | savemempool | version | | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -293,8 +293,8 @@ pub use crate::{ GetBalancesWatchOnly, GetBlockFilter, GetBlockFilterError, GetBlockchainInfo, GetBlockchainInfoError, GetMempoolAncestors, GetMempoolAncestorsVerbose, GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, MapMempoolEntryError, - MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, Softfork, - SoftforkType, + MempoolEntry, MempoolEntryError, MempoolEntryFees, MempoolEntryFeesError, ScanTxOutSet, + ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent, Softfork, SoftforkType, }, v21::UnloadWallet, v22::{Logging, ScriptPubkey}, diff --git a/types/src/v25/blockchain.rs b/types/src/v25/blockchain.rs new file mode 100644 index 00000000..1b108849 --- /dev/null +++ b/types/src/v25/blockchain.rs @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v0.25` - blockchain. +//! +//! Types for methods found under the `== Blockchain ==` section of the API docs. +use serde::{Deserialize, Serialize}; + +/// 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(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + Start(ScanTxOutSetStart), + Abort(bool), + Status(Option), +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetStart { + /// Whether the scan is completed + pub success: bool, + /// The number of unspent transaction outputs scanned + pub txouts: u64, + /// The current block height (index) + pub height: u64, + /// The hash of the block at the tip of the chain + pub bestblock: String, + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +pub struct ScanTxOutSetStatus { + /// Approximate percent complete + pub progress: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// An output descriptor + pub desc: String, + /// The total amount in BTC of 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 f17b6889..465c1a8c 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -52,7 +52,7 @@ //! | pruneblockchain | returns numeric | | //! | savemempool | version | | //! | scanblocks | version + model | TODO | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -240,10 +240,14 @@ //! //! +mod blockchain; mod wallet; #[doc(inline)] -pub use self::wallet::{CreateWallet, LoadWallet, UnloadWallet}; +pub use self::{ + blockchain::{ScanTxOutSet, ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent}, + wallet::{CreateWallet, LoadWallet, UnloadWallet}, +}; #[doc(inline)] pub use crate::{ v17::{ diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index b73d19bb..550811ea 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -56,7 +56,7 @@ //! | pruneblockchain | returns numeric | | //! | savemempool | version | | //! | scanblocks | version + model | TODO | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -318,4 +318,5 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GlobalXpub, Proprietary, PsbtInput, PsbtOutput, TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, + v25::{ScanTxOutSet, ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent}, }; diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 6535e76b..f3e4fb46 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -56,7 +56,7 @@ //! | pruneblockchain | returns numeric | | //! | savemempool | version | | //! | scanblocks | version + model | TODO | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -302,6 +302,7 @@ pub use crate::{ DecodePsbt, DecodePsbtError, GlobalXpub, Proprietary, PsbtInput, PsbtOutput, TaprootBip32Deriv, TaprootLeaf, TaprootScript, TaprootScriptPathSig, }, + v25::{ScanTxOutSet, ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent}, v26::{ CreateWallet, DescriptorProcessPsbt, DescriptorProcessPsbtError, GetPrioritisedTransactions, GetTxOutSetInfo, GetTxOutSetInfoError, LoadWallet, diff --git a/types/src/v28/blockchain.rs b/types/src/v28/blockchain.rs index 9fe59546..9e93cda8 100644 --- a/types/src/v28/blockchain.rs +++ b/types/src/v28/blockchain.rs @@ -95,3 +95,63 @@ 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(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum ScanTxOutSet { + Start(ScanTxOutSetStart), + Abort(bool), + Status(Option), +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] // v28 +pub struct ScanTxOutSetStart { + /// Whether the scan is completed + pub success: bool, + /// The number of unspent transaction outputs scanned + pub txouts: u64, + /// The current block height (index) + pub height: u64, + /// The hash of the block at the tip of the chain + pub bestblock: String, + /// The unspents + pub unspents: Vec, + /// The total amount of all found unspent outputs in BTC + pub total_amount: f64, +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +pub struct ScanTxOutSetStatus { + /// Approximate percent complete + pub progress: f64, +} + +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub struct ScanTxOutSetUnspent { + /// The transaction id + pub txid: String, + /// The vout value + pub vout: u32, + /// The script key + #[serde(rename = "scriptPubKey")] + pub script_pub_key: String, + /// An output descriptor + pub desc: String, + /// The total amount in BTC of 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 + pub blockhash: 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 fd21c3dc..c8fe6c8d 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -56,7 +56,7 @@ //! | pruneblockchain | returns numeric | | //! | savemempool | version | | //! | scanblocks | version + model | TODO | -//! | scantxoutset | omitted | API marked as experimental | +//! | scantxoutset | version + model | API marked as experimental | //! | verifychain | returns boolean | | //! | verifytxoutproof | version + model | | //! @@ -255,7 +255,13 @@ mod mining; mod network; #[doc(inline)] -pub use self::{blockchain::GetBlockchainInfo, mining::GetMiningInfo, network::GetNetworkInfo}; +pub use self::{ + blockchain::{ + GetBlockchainInfo, ScanTxOutSet, ScanTxOutSetStart, ScanTxOutSetStatus, ScanTxOutSetUnspent, + }, + mining::GetMiningInfo, + network::GetNetworkInfo, +}; #[doc(inline)] pub use crate::{ v17::{