bitcoind: don't try to match bitcoind's error string when loading wallet

The functional tests uncovered another error. And trying to pattern match any error is brittle. Just explicitly let anything through.
This commit is contained in:
Antoine Poinsot 2022-07-25 16:01:04 +02:00
parent 096ad68c4b
commit cea72d8a63
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 6 additions and 19 deletions

View File

@ -418,27 +418,14 @@ impl BitcoinD {
Ok(())
}
pub fn maybe_load_watchonly_wallet(&self) -> Result<(), BitcoindError> {
match self.make_fallible_node_request(
/// Try to load the watchonly wallet in bitcoind. It will continue on error (since it's
/// likely the wallet is just already loaded) and log it as info instead.
pub fn try_load_watchonly_wallet(&self) {
if let Err(e) = self.make_fallible_node_request(
"loadwallet",
&params!(Json::String(self.watchonly_wallet_path.clone()),),
) {
Err(e) => {
if e.to_string().contains("is already loaded") {
Ok(())
} else {
Err(e)
}
}
Ok(res) => {
if let Some(warning) = res.get("warning").map(Json::as_str).flatten() {
Err(BitcoindError::WalletLoading(warning.to_string()))
} else if res.get("name").is_none() {
Err(BitcoindError::WalletLoading(res.to_string()))
} else {
Ok(())
}
}
log::info!("Got error '{}' while trying to load watchonly on bitcoind. It is possibly already loaded.", e);
}
}

View File

@ -171,7 +171,7 @@ impl DaemonHandle {
bitcoind.create_watchonly_wallet(&config.main_descriptor)?;
log::info!("Created a new watchonly wallet on bitcoind.");
}
bitcoind.maybe_load_watchonly_wallet()?;
bitcoind.try_load_watchonly_wallet();
bitcoind.sanity_check(&config.main_descriptor, config.bitcoind_config.network)?;
bitcoind.with_retry_limit(None);
log::info!("Connection to bitcoind established and checked.");