Skip to content

Commit 8e4fb85

Browse files
committed
add struct and RPC method to check scantxoutset status
1 parent 7fb8aae commit 8e4fb85

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

client/src/client.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,22 @@ pub trait RpcApi: Sized {
12571257
}
12581258
}
12591259

1260+
// Return the status of a UTXO set scan
1261+
fn scan_tx_out_set_status(&self) -> Result<Option<json::ScanTxOutStatusResult>> {
1262+
match self.call("scantxoutset", &["status".into()]) {
1263+
Ok(response) => {
1264+
let response: serde_json::Value = response;
1265+
if response.is_null() {
1266+
Ok(None)
1267+
} else {
1268+
let result: json::ScanTxOutStatusResult = serde_json::from_value(response)?;
1269+
Ok(Some(result))
1270+
}
1271+
}
1272+
Err(e) => Err(e),
1273+
}
1274+
}
1275+
12601276
fn scan_tx_out_set_blocking(
12611277
&self,
12621278
descriptors: &[json::ScanTxOutRequest],

json/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,12 @@ pub enum PubKeyOrAddress<'a> {
20972097
PubKey(&'a PublicKey),
20982098
}
20992099

2100+
/// Used to represent the status of a UTXO set scan.
2101+
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
2102+
pub struct ScanTxOutStatusResult {
2103+
pub progress: u8,
2104+
}
2105+
21002106
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Debug)]
21012107
#[serde(untagged)]
21022108
/// 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)