Don't reopen monero wallet on each subscription monitor run

This commit is contained in:
silverpill 2023-03-28 00:10:49 +00:00
parent 8cfb2318a2
commit 378d94e7b8
2 changed files with 15 additions and 5 deletions

View file

@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fixed error in emoji update SQL query.
- Restart stalled background jobs.
- Order attachments by creation date.
- Don't reopen monero wallet on each subscription monitor run.
## [1.18.0] - 2023-03-21

View file

@ -56,11 +56,20 @@ pub async fn open_monero_wallet(
let wallet_client = RpcClientBuilder::new()
.build(config.wallet_url.clone())?
.wallet();
if let Some(ref wallet_name) = config.wallet_name {
wallet_client.open_wallet(
wallet_name.clone(),
config.wallet_password.clone(),
).await?;
if let Err(error) = wallet_client.refresh(None).await {
if error.to_string() == "Server error: No wallet file" {
// Try to open wallet
if let Some(ref wallet_name) = config.wallet_name {
wallet_client.open_wallet(
wallet_name.clone(),
config.wallet_password.clone(),
).await?;
} else {
return Err(MoneroError::WalletRpcError("wallet file is required"));
};
} else {
return Err(error.into());
};
};
Ok(wallet_client)
}