Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible typos and grammar issues:
2026-11-24 20:36:55 |
|
Concept ACK, thanks for taking over. |
a2b33bc to
f8b9da8
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
|
Concept ACK f8b9da8 because it enforces the handling of database errors, thereby ensuring consistency between in-memory behaviour and databases behaviour. |
f8b9da8 to
c794ae0
Compare
d9a9c92 to
d16ed3e
Compare
| // there will likely be write failures in the future. Better to stop loading the wallet | ||
| // and not let the user use it at this time. | ||
| pwallet->WalletLogPrintf("Error: Unable to update the wallet last client version"); | ||
| return DBErrors::CORRUPT; |
There was a problem hiding this comment.
Frankly, a mild issue like @jeanpablojp's disk full/permissions read-write restrictions reporting BErrors::CORRUPT may misguide the user giving then unnecessary tensions. For the others, this may fly, for loading the database IMHO, a log might probably help instead of locking them out with the error ...Wallet corrupted
| auto address{EncodeDestination(dest)}; | ||
| if (entry.purpose) batch.WritePurpose(address, PurposeToString(*entry.purpose)); | ||
| if (entry.label) batch.WriteName(address, *entry.label); | ||
| if (entry.purpose) { |
There was a problem hiding this comment.
Makes a lot of sense to work with the all-or-nothing logic here. A purpose or name failure (less tragic) means that the more tragic ones (WriteAddressReceiveRequest and WriteAddressPreviouslySpent may also fail.
d16ed3e to
5b35156
Compare
Return values for some writes can be ignored, if they fail, no harm occurred.
RunWithinTxn calls TxnAbort, but if this fails, the WalletBatch will go out of scope anyways, which will call destructors that reach SQLiteBatch::Close, which will also call TxnAbort, and has more handling of abort failures.
Handle write failures for WriteOrderPosNext and WriteTx
Mark WriteBestBlock as [[nodiscard]] and explicitly ignore errors, or handle them.
All WalletBatch operations that interact with the database (read, write, erase, transactions) have bool returns values that callers need to check as database operations may fail.
5b35156 to
c145c2c
Compare
polespinasa
left a comment
There was a problem hiding this comment.
Super concept ACK
reviewed d0ecbdc
| DecIndex(); | ||
| } | ||
| WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor); | ||
| (void)WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor); |
There was a problem hiding this comment.
in 8cc88b5 wallet: Explicitly mark ignored write failures
nit: I would probably add here also a comment saying that write failure is ok.
| if (own_txn && !TxnBegin()) return false; | ||
| if (!WriteIC(encrypted_key, secret, /*fOverwrite=*/false) || !EraseIC(plaintext_key) || (own_txn && !TxnCommit())) { | ||
| if (own_txn) TxnAbort(); | ||
| if (own_txn) (void)TxnAbort(); |
There was a problem hiding this comment.
in 401a4bd wallet: Ignore TxnAbort failure in RunWithinTxn
nit: I would also add the comment added for the other case here too :)
| WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor); | ||
| if (!WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor)) { | ||
| DecIndex(); | ||
| return util::Error{_("Error: Unable to update database with new address")}; |
There was a problem hiding this comment.
in 52841e7 wallet: Handle descriptor update write failures
This needs changes on how the error propagates. RPCs such as getnewaddress would previously succeed and now fail with error code RPC_WALLET_KEYPOOL_RAN_OUT which does not seem accurate.

A common theme in the wallet is that many database write failures are ignored, when they should probably be handled, or at least documented that a failure is being ignored. This PR marks all database functions in
WalletBatchas[[nodiscard]]so that a compiler will tell us if a return value is implicitly ignored. All of the calls to those functions are updated to either deal with failure, or explicitly ignore it with a rationale.Based on #35752 which handles failures for the encryption functions.