Repository navigation
Wallet: add consistency check on wallet transactions stored on wallet database when loading the wallet. - #35163
Luquitasjeffrey wants to merge 2 commits into
Conversation
…donTransaction call due to corruption on the wallet database file
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. 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 places where named args for integral literals may be used (e.g.
2026-04-27 04:17:21 |
| if (it != pwallet->mapWallet.end()) { | ||
| const CWalletTx& ptx = it->second; | ||
| if (wtx.isConfirmed() && !ptx.isConfirmed()) { | ||
| result = DBErrors::NEED_RESCAN; |
There was a problem hiding this comment.
Question: Should these assignments preserve any more severe load error already stored in result?
Since DBErrors is severity-ordered, and this function already tracks the worst result via std::max, a plain assignment to DBErrors::NEED_RESCAN could silently overwrite a more severe error already stored in result. Would result = std::max(result, DBErrors::NEED_RESCAN) be safer here?
|
This PR looks LLM generated, without real understanding from the author. LLM generated unit tests are not great for proving the existence of bugs, as LLMs can abuse the access to internal state to produce the wanted results. Please write a functional test that demonstrates the bug, as that would at least increase the confidence in the LLMs analysis. |
|
I'm closing this PR as it is clearly LLM generated and there is no evidence that the author understands the mechanism of the issue. |
Fixes: #34599
When loading a corrupted wallet database there exists the chance where the transaction state is inconsistent. For example, in the wallet database a parent transaction could appear to be inactive while the child transaction was confirmed (of course that makes no sense, in the blockchain both transactions are confirmed). As a result, when the wallet attempts to abandon inactive transactions, it raises an assertion error.
To fix the problem, if when loading the wallet it encounters an inconsistent transaction state, it will return NEED_RESCAN as db errors, because, it is not usable a wallet that has inconsistent transaction state.