Is there an existing issue for this?
- 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.
0#!/bin/bash
1set -e
2DATADIR="$HOME/.../2024-04-testwallets"
3for WALLET in a.dat b.dat c.dat d.dat ...; do
4 echo $WALLET
5 rm -f /tmp/dump /tmp/dump2
6 src/bitcoin-wallet -datadir="$DATADIR" -withinternalbdb -wallet="$WALLET" -dumpfile=/tmp/dump dump
7 src/bitcoin-wallet -datadir="$DATADIR" -wallet="$WALLET" -dumpfile=/tmp/dump2 dump
8
9 diff -q /tmp/dump /tmp/dump2
10
11 ### Uncomment to following to make it work:
12 # rm -rf $DATADIR/database.
13done
14rm -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