Merge #495: lib: on Windows unload the watchonly wallet before deleting it
17d1f847bcf201fb452c7c9d950b0b1ee2f4e22c lib: on Windows unload the watchonly wallet before deleting it (Antoine Poinsot) Pull request description: Fixes #493 ACKs for top commit: darosior: ACK 17d1f847bcf201fb452c7c9d950b0b1ee2f4e22c -- tested on Windows by Kevin Tree-SHA512: 2a92f5ce957ce4bd3a7c4a9b9c5f49ff0262157935c492a562c8a03af45b794db3bc5abd64d38b270d5b86fdc4c5288dcc4ea20c7343bc04b4c6a396c3a27ffc
This commit is contained in:
commit
165fb36196
@ -446,7 +446,7 @@ impl BitcoinD {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn unload_wallet(&self, wallet_path: String) -> Option<String> {
|
||||
pub fn unload_wallet(&self, wallet_path: String) -> Option<String> {
|
||||
self.make_node_request("unloadwallet", ¶ms!(Json::String(wallet_path),))
|
||||
.get("warning")
|
||||
.expect("No 'warning' in 'unloadwallet' response?")
|
||||
|
||||
@ -201,6 +201,7 @@ fn setup_sqlite(
|
||||
// Windows-specific utility to remove a leftover watchonly wallet within bitcoind's datadir.
|
||||
#[cfg(windows)]
|
||||
fn maybe_delete_watchonly_wallet(
|
||||
bitcoind: &BitcoinD,
|
||||
bitcoind_cookie_path: &path::Path,
|
||||
bitcoin_net: miniscript::bitcoin::Network,
|
||||
wallet_name: &str,
|
||||
@ -228,6 +229,12 @@ fn maybe_delete_watchonly_wallet(
|
||||
"Found a leftover watchonly wallet at '{}'. Deleting it.",
|
||||
wallet_path.as_path().to_string_lossy()
|
||||
);
|
||||
if let Some(warning) = bitcoind.unload_wallet(wallet_path.to_string_lossy().to_string()) {
|
||||
log::warn!(
|
||||
"Warning when unloading watchonly wallet on bitcoind: '{}'",
|
||||
warning
|
||||
);
|
||||
}
|
||||
fs::remove_dir_all(&wallet_path)
|
||||
.map_err(|e| StartupError::WindowsBitcoindWatchonlyDeletion(wallet_path, e))?;
|
||||
} else {
|
||||
@ -275,6 +282,7 @@ fn setup_bitcoind(
|
||||
// any leftover Liana watchonly wallet from bitcoind's data dir.
|
||||
#[cfg(windows)]
|
||||
maybe_delete_watchonly_wallet(
|
||||
&bitcoind,
|
||||
&bitcoind_config.cookie_path,
|
||||
config.bitcoin_config.network,
|
||||
wo_name,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user