add optional height param to clear command for rescan-from-height
Some checks failed
Rust / Build on macOS-latest (push) Has been cancelled
Rust / Build on ubuntu-16.04 (push) Has been cancelled
Rust / Build on windows-latest (push) Has been cancelled
Rust / Linux ARMv7 (push) Has been cancelled
Rust / Linux ARM64 (push) Has been cancelled
Rust / Build on ubuntu-latest (push) Has been cancelled
Some checks failed
Rust / Build on macOS-latest (push) Has been cancelled
Rust / Build on ubuntu-16.04 (push) Has been cancelled
Rust / Build on windows-latest (push) Has been cancelled
Rust / Linux ARMv7 (push) Has been cancelled
Rust / Linux ARM64 (push) Has been cancelled
Rust / Build on ubuntu-latest (push) Has been cancelled
This commit is contained in:
@@ -132,8 +132,16 @@ impl Command for ClearCommand {
|
||||
"Clear the wallet state, rolling back the wallet to an empty state.".to_string()
|
||||
}
|
||||
|
||||
fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String {
|
||||
lightclient.clear_state();
|
||||
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String {
|
||||
if !args.is_empty() {
|
||||
if let Ok(height) = args[0].parse::<u64>() {
|
||||
lightclient.clear_state_from(height);
|
||||
} else {
|
||||
return format!("Error: invalid height '{}'", args[0]);
|
||||
}
|
||||
} else {
|
||||
lightclient.clear_state();
|
||||
}
|
||||
|
||||
let result = object!{ "result" => "success" };
|
||||
|
||||
|
||||
@@ -1274,12 +1274,16 @@ pub fn start_mempool_monitor(lc: Arc<LightClient>) -> Result<(), String> {
|
||||
}
|
||||
|
||||
pub fn clear_state(&self) {
|
||||
self.clear_state_from(self.wallet.read().unwrap().get_birthday());
|
||||
}
|
||||
|
||||
pub fn clear_state_from(&self, height: u64) {
|
||||
// First, clear the state from the wallet
|
||||
self.wallet.read().unwrap().clear_blocks();
|
||||
|
||||
// Then set the initial block
|
||||
self.set_wallet_initial_state(self.wallet.read().unwrap().get_birthday());
|
||||
info!("Cleared wallet state");
|
||||
self.set_wallet_initial_state(height);
|
||||
info!("Cleared wallet state to height {}", height);
|
||||
}
|
||||
|
||||
pub fn do_rescan(&self) -> Result<JsonValue, String> {
|
||||
|
||||
Reference in New Issue
Block a user