Merge #651: lib: windows: don't unload the wo wallet if not loaded
34f3946fc814bf5c915be131dd3092b21f4f48e1 lib: windows: don't unload the wo wallet if not loaded (Antoine Poinsot)
Pull request description:
ACKs for top commit:
darosior:
self-ACK 34f3946fc814bf5c915be131dd3092b21f4f48e1
Tree-SHA512: ef7b5a15ecc18b7ee2ecb286569742f6adf10e0487f94787cc8fc1842516b5d9e969f8cda76ac51897c3c934ed3357c89ac1eae2bc03512a69e832e998ef99ea
This commit is contained in:
commit
85d470dd8d
@ -508,7 +508,7 @@ impl BitcoinD {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn unload_wallet(&self, wallet_path: String) -> Option<String> {
|
||||
fn unload_wallet(&self, wallet_path: String) -> Option<String> {
|
||||
let res = self.make_node_request("unloadwallet", ¶ms!(Json::String(wallet_path),));
|
||||
self.warning_from_res(&res)
|
||||
}
|
||||
@ -607,16 +607,10 @@ impl BitcoinD {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Create the watchonly wallet on bitcoind, and import it the main descriptor.
|
||||
pub fn create_watchonly_wallet(
|
||||
&self,
|
||||
main_descriptor: &LianaDescriptor,
|
||||
) -> Result<(), BitcoindError> {
|
||||
// Remove any leftover. This can happen if we delete the watchonly wallet but don't restart
|
||||
// bitcoind.
|
||||
while self.list_wallets().contains(&self.watchonly_wallet_path) {
|
||||
pub fn maybe_unload_watchonly_wallet(&self, watchonly_wallet_path: String) {
|
||||
while self.list_wallets().contains(&watchonly_wallet_path) {
|
||||
log::info!("Found a leftover watchonly wallet loaded on bitcoind. Removing it.");
|
||||
if let Some(e) = self.unload_wallet(self.watchonly_wallet_path.clone()) {
|
||||
if let Some(e) = self.unload_wallet(watchonly_wallet_path.clone()) {
|
||||
log::error!(
|
||||
"Unloading wallet '{}': '{}'",
|
||||
&self.watchonly_wallet_path,
|
||||
@ -624,6 +618,16 @@ impl BitcoinD {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create the watchonly wallet on bitcoind, and import it the main descriptor.
|
||||
pub fn create_watchonly_wallet(
|
||||
&self,
|
||||
main_descriptor: &LianaDescriptor,
|
||||
) -> Result<(), BitcoindError> {
|
||||
// Remove any leftover. This can happen if we delete the watchonly wallet but don't restart
|
||||
// bitcoind.
|
||||
self.maybe_unload_watchonly_wallet(self.watchonly_wallet_path.clone());
|
||||
|
||||
// Now create the wallet and import the main descriptor.
|
||||
self.create_wallet(self.watchonly_wallet_path.clone())
|
||||
|
||||
@ -229,16 +229,11 @@ fn maybe_delete_watchonly_wallet(
|
||||
};
|
||||
|
||||
if wallet_path.exists() {
|
||||
bitcoind.maybe_unload_watchonly_wallet(wallet_path.to_string_lossy().to_string());
|
||||
log::info!(
|
||||
"Found a leftover watchonly wallet at '{}'. Deleting it.",
|
||||
"Deleting the leftover watchonly wallet at '{}'.",
|
||||
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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user