Skip to content

Commit 2380612

Browse files
committed
add scanblocks call
1 parent 413da8c commit 2380612

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

client/src/client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,12 +1255,20 @@ pub trait RpcApi: Sized {
12551255
}
12561256
}
12571257

1258+
fn scan_blocks_blocking(
1259+
&self,
1260+
descriptors: &[json::ScanBlocksRequest],
1261+
) -> Result<json::ScanBlocksResult> {
1262+
self.call("scanblocks", &["start".into(), into_json(descriptors)?])
1263+
}
1264+
12581265
fn scan_tx_out_set_blocking(
12591266
&self,
12601267
descriptors: &[json::ScanTxOutRequest],
12611268
) -> Result<json::ScanTxOutResult> {
12621269
self.call("scantxoutset", &["start".into(), into_json(descriptors)?])
12631270
}
1271+
12641272
}
12651273

12661274
/// Client implements a JSON-RPC client for the Bitcoin Core daemon or compatible APIs.

json/src/lib.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use bitcoin::block::Version;
3030
use bitcoin::consensus::encode;
3131
use bitcoin::hashes::hex::FromHex;
3232
use bitcoin::hashes::sha256;
33-
use bitcoin::{Address, Amount, PrivateKey, PublicKey, SignedAmount, Transaction, ScriptBuf, Script, bip158, bip32, Network};
33+
use bitcoin::{Address, Amount, PrivateKey, PublicKey, SignedAmount, Transaction, ScriptBuf, Script, bip158, bip32, Network, BlockHash};
3434
use serde::de::Error as SerdeError;
3535
use serde::{Deserialize, Serialize};
3636
use std::fmt;
@@ -2087,6 +2087,28 @@ pub enum PubKeyOrAddress<'a> {
20872087
PubKey(&'a PublicKey),
20882088
}
20892089

2090+
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
2091+
#[serde(untagged)]
2092+
/// Start a scan of the UTXO set for an [output descriptor](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md).
2093+
pub enum ScanBlocksRequest {
2094+
/// Scan for a single descriptor
2095+
Single(String),
2096+
/// Scan for a descriptor with xpubs
2097+
Extended {
2098+
/// Descriptor
2099+
desc: String,
2100+
/// Range of the xpub derivations to scan
2101+
range: Option<(u64, u64)>,
2102+
},
2103+
}
2104+
2105+
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
2106+
pub struct ScanBlocksResult {
2107+
pub from_height: u64,
2108+
pub to_height: u64,
2109+
pub relevant_blocks: Vec<BlockHash>,
2110+
}
2111+
20902112
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
20912113
#[serde(untagged)]
20922114
/// Start a scan of the UTXO set for an [output descriptor](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md).

0 commit comments

Comments
 (0)