Add rescan to daemon client

This commit is contained in:
edouard 2022-11-11 09:36:33 +01:00
parent 182c7560e9
commit 8155516386
3 changed files with 17 additions and 0 deletions

View File

@ -113,6 +113,11 @@ impl<C: Client + Debug> Daemon for Minisafed<C> {
self.call("broadcastspend", Some(vec![txid.to_string()]))?;
Ok(())
}
fn start_rescan(&self, t: u32) -> Result<(), DaemonError> {
let _res: serde_json::value::Value = self.call("startrescan", Some(vec![t]))?;
Ok(())
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]

View File

@ -156,4 +156,15 @@ impl Daemon for EmbeddedDaemon {
.broadcast_spend(txid)
.map_err(|e| DaemonError::Unexpected(e.to_string()))
}
fn start_rescan(&self, t: u32) -> Result<(), DaemonError> {
self.handle
.as_ref()
.ok_or(DaemonError::NoAnswer)?
.lock()
.unwrap()
.control
.start_rescan(t)
.map_err(|e| DaemonError::Unexpected(e.to_string()))
}
}

View File

@ -88,4 +88,5 @@ pub trait Daemon: Debug {
fn update_spend_tx(&self, psbt: &Psbt) -> Result<(), DaemonError>;
fn delete_spend_tx(&self, txid: &Txid) -> Result<(), DaemonError>;
fn broadcast_spend_tx(&self, txid: &Txid) -> Result<(), DaemonError>;
fn start_rescan(&self, t: u32) -> Result<(), DaemonError>;
}