bitcoin-cli needlessly creates empty ~/.bitcoin/wallets directory #20070

issue Kixunil openend this issue on October 3, 2020
  1. Kixunil commented at 1:32 pm on October 3, 2020: none

    When bitcoin-cli is run, it, not bitcoind creates an empty ~/.bitcoin/wallets direcctory with ~ bring home of currently running user. This is weird and leads to user confusion because it happens even in cases when bitcoin-cli connects to a bitcoind running under a different user or probably on other machine.

    Expected behavior

    bitcoin-cli never modifies filesystem, especially not things that the daemon should take care of.

    Actual behavior

    bitcoin-cli creates empty directory

    To reproduce

    1. make sure ~/.bitcoin does not exist under user A
    2. install bitcoind and run it under a user B
    3. run bitcoin-cli getblockchaininfo under user A
    4. ls ~/.bitcoin under user A

    For quick setup, you can try to use my project in a Debian VM or using provided Docker file. Just apt install bitcoin-regtest bitcoin-cli, it’s already pre-configured to run under a different user, so then just running sudo bitcoin-cli getblockchaininfo && sudo ls /root/.bitcoin should reproduce the issue.

    System information

    0.20 official release downloaded from https://bitcoin.org/bin/bitcoin-core-..., verified GPG signature from Wladimir.

    OS: Linux Debian Buster CPU: Intel x86_64 Disk: NVMe SSD FS: ext4

    I don’t think configuration is relevant since bitcoin-cli is not informed where to find it (via parameters or otherwise) and thus it can not access it. I also added -rpcport and -rpccookiefile parameters explicitly but I don’t think it’s relevant.

    Loosely related to #16220, but not a duplicate.

  2. Kixunil added the label Bug on Oct 3, 2020
  3. n-thumann commented at 6:21 pm on October 3, 2020: contributor
  4. Kixunil commented at 7:29 pm on October 3, 2020: none
    Good find. My understanding is that the function is shared between daemon and client, that’s why it happens. Not surprised, if the function is called GetDatadir but it doesn’t just get the datadir, but also creates it. :)
  5. maflcko commented at 7:20 am on October 4, 2020: member

    I also added -rpcport and -rpccookiefile parameters explicitly but I don’t think it’s relevant.

    As a temporary workaround, you can skip passing them and instead pass in the datadir to bitcoin-cli. It will then read those values from the conf file (or cookie file), but also skip creating the wallet dir (because it already exists).

  6. Kixunil commented at 8:38 am on October 4, 2020: none
    Good idea. I can’t skip them because of other reasons but adding -datadir=/tmp/ disables creating the directory.
  7. Kixunil referenced this in commit 7ddad7f5df on Oct 4, 2020
  8. achow101 closed this on Feb 23, 2023

  9. bitcoin locked this on Feb 23, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-05 19:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me