From 23927f3e8b3bd413e0bf8b7c42b9531345bdd1a3 Mon Sep 17 00:00:00 2001 From: Chris Guida Date: Sun, 12 Nov 2023 16:52:28 -0600 Subject: [PATCH] flesh out scanblocks params --- client/src/client.rs | 14 ++++++++++++-- json/src/lib.rs | 26 ++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/client/src/client.rs b/client/src/client.rs index 4eb32e04..34f8b31a 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -1258,9 +1258,19 @@ pub trait RpcApi: Sized { fn scan_blocks_blocking( &self, - descriptors: &[json::ScanBlocksRequest], + request: json::ScanBlocksRequest, ) -> Result { - self.call("scanblocks", &["start".into(), into_json(descriptors)?]) + self.call( + "scanblocks", + &[ + "start".into(), + into_json(request.scanobjects)?, + into_json(request.start_height)?, + into_json(request.stop_height)?, + into_json(request.filtertype)?, + into_json(request.options)?, + ], + ) } fn scan_tx_out_set_blocking( diff --git a/json/src/lib.rs b/json/src/lib.rs index 041c4e53..5c0832dd 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -2087,10 +2087,32 @@ pub enum PubKeyOrAddress<'a> { PubKey(&'a PublicKey), } +#[derive(Serialize, Clone, PartialEq, Eq, Debug)] +/// Start a scan of the block filter index for an [output descriptor](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md). +pub struct ScanBlocksRequest<'a> { + /// List of descriptors to scan + pub scanobjects: &'a [ScanBlocksRequestDescriptor], + /// Height at which to start scanning + pub start_height: Option, + /// Height at which to stop scanning + pub stop_height: Option, + /// Filter type. Only "basic" is supported for now. + pub filtertype: Option, + /// Additional scan options. Only "filter_false_positives" is supported for now. + pub options: Option, +} + +#[derive(Serialize, Clone, PartialEq, Eq, Debug)] +/// Options struct for `scanblocks` rpc +pub struct ScanBlocksOptions { + /// Scan for a single descriptor + pub filter_false_positives: Option, +} + #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)] #[serde(untagged)] -/// Start a scan of the UTXO set for an [output descriptor](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md). -pub enum ScanBlocksRequest { +/// Descriptors to scan in `scanblocks` rpc +pub enum ScanBlocksRequestDescriptor { /// Scan for a single descriptor Single(String), /// Scan for a descriptor with xpubs