Issue Details
- Number
- 29883
- Title
- utils: wallet_dump can create a `database` directory, cross-pollinating records
- Description
- ### Is there an existing issue for this?
- [X] I have searched the existing issues
### Current behaviour
I created a large directory with legacy wallet dat files for testing #26606. Ran into a weird issue where the output mismatches, but after investigating deeper, this was not due to a bug in that PR.
So I created a script that iterates over all wallets, dumps them with the internal bdb and external bdb, diffs the textual output, stopping on the first wallet which mismatches. Mind that the wallets are loose `.dat` files, not themselves subdirectories.
```sh
#!/bin/bash
set -e
DATADIR="$HOME/.../2024-04-testwallets"
for WALLET in a.dat b.dat c.dat d.dat ...; do
echo $WALLET
rm -f /tmp/dump /tmp/dump2
src/bitcoin-wallet -datadir="$DATADIR" -withinternalbdb -wallet="$WALLET" -dumpfile=/tmp/dump dump
src/bitcoin-wallet -datadir="$DATADIR" -wallet="$WALLET" -dumpfile=/tmp/dump2 dump
diff -q /tmp/dump /tmp/dump2
### Uncomment to following to make it work:
# rm -rf $DATADIR/database.
done
rm -f /tmp/dump /tmp/dump2
```
So far so good.
However, I was seeing some huge divergences. Not small differences that could be explained to differences in interpretation, but e.g. the output would have wildly different `blockheight`. A kind of cross-pollination.
What it turned out to be is that the `bitcoin-wallet dump` leaves behind a `database/` subdirectory on close containing log files (`log.0000000001` etc). When opening the next wallet in the same directory, this subdirectory is used, and affects the dumped contents of the new wallet.
Deleting the `database` directory between wallets solves the problem. If this is still worth fixing, the wallet should probably compact after close to incorporate the log files. You wouldn't expect modification on a read-only operation in the first place, but I suppose this is due to an inherent bdb limitation.
### Expected behaviour
Successively dumped wallets don't affect each other.
### Steps to reproduce
See script in "current behavior".
### Relevant log output
_No response_
### How did you obtain Bitcoin Core
Compiled from source
### What version of Bitcoin Core are you using?
7f8d4c963c6a12da0e8df462a3f25ccda4a39a62 (#26606)
### Operating system and version
Ubuntu 24.04
### Machine specifications
_No response_
- URL
-
https://github.com/bitcoin/bitcoin/issue/29883
- Closed by
-
Back to List