Skip to content

Feature request: bitcoin-wallet tool: don't modify files unless requested #15608

@harding

Description

@harding

When only getting info for a wallet with the bitcoin-wallet tool, I was surprised to find it changing the file modification time (but happy that it didn't also seem to modify the file contents):

$ stat --format=%Y /tmp/test.dat ; sha256sum /tmp/test.dat
1552658778
8d932caabee0dc8d42c7ea362fb685325bd23f217557135282279f5b14233eec  /tmp/test.dat

$ bitcoin/src/bitcoin-wallet -wallet=/tmp/test.dat info
Wallet info
[...]

$ stat --format=%Y /tmp/test.dat ; sha256sum /tmp/test.dat
1552658867
8d932caabee0dc8d42c7ea362fb685325bd23f217557135282279f5b14233eec  /tmp/test.dat

Setting the file permissions to read-only also surprisingly causes the tool to fail:

$ chmod 400 /tmp/test.dat 
$ bitcoin/src/bitcoin-wallet -wallet=/tmp/test.dat info
Error loading /tmp/test.dat. Is wallet being used by another process?

It also fails on a read-only filesystem even if the permission bits are set to writable:

$ chmod 600 /tmp/test.dat 
$ sudo mount -t tmpfs -o size=10000000 tmpfs /mnt
$ sudo cp -a /tmp/test.dat /mnt
$ sudo mount -o remount,ro /mnt
$ bitcoin/src/bitcoin-wallet -wallet=/mnt/test.dat info
Error loading /mnt/test.dat. Is wallet being used by other process?
$ ls -lh /mnt/test.dat 
-rw------- 1 user user 1.4M Mar 15 10:07 /mnt/test.dat

I'd expect the tool to open files read-only when it doesn't need to make any modifications in order to ensure it doesn't make any modifications. Additionally, I'd expect the tool to be able to examine backup files that have been safeguarded by making them read-only in some way.

See also IRC discussion, including @laanwj mentioning a DB_RDONLY flag.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions