Skip to content

Conversation

achow101
Copy link
Member

#29109 (comment) reports that a wallet with noncritical errors cannot be dumped with bitcoin-wallet dump. This was caused by an erroneous reset of the wallet pointer when the loading the wallet returns something other than LOAD_OK. Not all errors are errors that require aborting, so unilaterally resetting the pointer at that time is incorrect. The first commit resolves this issue.

Furthermore, if a wallet has loading errors, that should not prevent the wallet tool from dumping the wallet. The wallet application logic should not get in the way of performing such a low level database operation, especially when it's primary usage is for debugging potentially corrupted wallets. The 2nd commit is taken from #28710 and changes the dump to stop at making a WalletDatabase rather than making a CWallet only to retrieve the underlying WalletDatabase.

achow101 and others added 2 commits December 19, 2023 16:54
When there is a wallet loading error, it could be a noncritical one so
it is not necessary to make wallet_instance a nullptr. The wallet can
still go on with normal operation in that case, as we do for loading in
bitcoind and bitcoin-qt.
It's not necessary to set up an entire CWallet just so we can get access
to the WalletDatabase and read the records. Instead we can go one level
lower and make just a WalletDatabase.
@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 19, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK furszy, BrandonOdiwuor

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26606 (wallet: Implement independent BDB parser by achow101)
  • #26596 (wallet: Migrate legacy wallets to descriptor wallets without requiring BDB by achow101)

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.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK d83bea4

Comment on lines +24 to 27
bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& error)
{
// Get the dumpfile
std::string dump_filename = args.GetArg("-dumpfile", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR but could also provide the -dumpfile path arg instead of the entire ArgsManager and remove <common/args.h> dependency.

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review ACK d83bea4

@fanquake fanquake merged commit 04978c2 into bitcoin:master Jan 5, 2024
Retropex pushed a commit to Retropex/bitcoin that referenced this pull request Mar 28, 2024
It's not necessary to set up an entire CWallet just so we can get access
to the WalletDatabase and read the records. Instead we can go one level
lower and make just a WalletDatabase.

Github-Pull: bitcoin#29117
Rebased-From: d83bea4
@bitcoin bitcoin locked and limited conversation to collaborators Jan 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants