fix(watch-only): make AddressCache::new fallible#931
fix(watch-only): make AddressCache::new fallible#931Sandipmandal25 wants to merge 1 commit intogetfloresta:masterfrom
Conversation
1938768 to
d3b758a
Compare
d3b758a to
ac22dcc
Compare
ac22dcc to
ad12323
Compare
Just to be clear that was my mistake, a competency test ideally should not be a PR. Thats what i wrote on our discord channel: https://discord.com/channels/1185232004506198056/1488947854612365353/1489335077769838685 |
|
When i started reading the code here i noticed that this is partially addressed on #804 but i have the intuition that it will be discarded, AFAIK the approach there was already reviewed and validated, maybe you could steal the code there and implement it here ? (That is, the error handling for the watch only interface) |
hey @jaoleal when you say "it will be discarded" do you mean pr #804 ? also by "steal the code from #804" and should i just take the full lib.rs error handling changes from there? |
i missed this acknowledging my mistake. |
Yes, Im not certain what will be discarded but for sure the error handling for the AddressCache is desirable.
Yes, but only if you think its proper. |
i willl expand this with the full lib.rs error handling changes. |
Description and Notes
Closes part of #463 and Competency Test for sob 2026 to be submitted along with proposal

AddressCache::newandAddressCacheInner::newpreviously panicked on database failures at startup.This change makes both return
Result<Self, WatchOnlyError<D::Error>>, allowing callers to handle errors instead of crashing.changes
Replaced three production panics:
database.load().expect("Could not load database")?database.save_stats(...).expect("Could not save stats")?self.database.get_stats().unwrap()(inmaybe_derive_addresses)let Ok(...) else { return }Updated
florestad.rs::load_walletto propagate viaFlorestadError::CouldNotInitializeWallet.verification
cargo test -p floresta-watch-onlyAll 10 tests pass
Includes
new_returns_err_when_database_load_fails:FailingDatabasestubload()returnsErrAddressCache::newreturnsErr(WatchOnlyError::DatabaseError(_))checklist
unwrap,expectandpanicoutside test code #463