Skip to content

Commit

Permalink
flesh out scanblocks params
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguida committed Nov 12, 2023
1 parent 1e6ee5f commit 23927f3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
14 changes: 12 additions & 2 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,19 @@ pub trait RpcApi: Sized {

fn scan_blocks_blocking(
&self,
descriptors: &[json::ScanBlocksRequest],
request: json::ScanBlocksRequest,
) -> Result<json::ScanBlocksResult> {
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(
Expand Down
26 changes: 24 additions & 2 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
/// Height at which to stop scanning
pub stop_height: Option<u64>,
/// Filter type. Only "basic" is supported for now.
pub filtertype: Option<String>,
/// Additional scan options. Only "filter_false_positives" is supported for now.
pub options: Option<ScanBlocksOptions>,
}

#[derive(Serialize, Clone, PartialEq, Eq, Debug)]
/// Options struct for `scanblocks` rpc
pub struct ScanBlocksOptions {
/// Scan for a single descriptor
pub filter_false_positives: Option<bool>,
}

#[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
Expand Down

0 comments on commit 23927f3

Please sign in to comment.