Neptune-Crypto/neptune-core
Catch Potential Error when Trying to Find Wallet Database
Aberta
#559 aberto em 21 de abr. de 2025
good first issuehelp wantedminor
Métricas do repositório
- Stars
- (110 estrelas)
- Métricas de merge de PR
- (Métricas PR pendentes)
Description
See #556.
In WalletState::new_from_context:
let database_is_new = !tokio::fs::try_exists(&data_dir.wallet_database_dir_path()).await.unwrap();
What if the path cannot be verified to exist or not exist? try_exists will return an Err case and the unwrap() will cause a panic. Let's catch that case gracefully.
I think it's preferable to catch this edge case and log a warning message. "Cannot determine existence of wallet database." Or something like that. And the variable database_is_new should be set to false so as to avoid unnecessary work.
I realize that down the line things will probably fail when the client tries to read data from the wallet database but
a) by the time control flow gets there the problem may have been resolved b) a future refactor might find a way around that problem without affecting scan mode policy.