Skip to content

Read walletdir from bitcoin.conf when deleting wallet files#2594

Open
Copilot wants to merge 5 commits into
masterfrom
copilot/detect-remove-wallets-directory
Open

Read walletdir from bitcoin.conf when deleting wallet files#2594
Copilot wants to merge 5 commits into
masterfrom
copilot/detect-remove-wallets-directory

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Specter hardcoded the wallet directory as datadir + /wallets/ (or chain-specific subdir), ignoring the walletdir option in bitcoin.conf. This causes wallet file deletion to silently fail for any node using a custom wallet directory.

Changes

  • rpc.py — New get_walletdir(datadir, chain) helper: calls get_rpcconfig() and returns the configured walletdir, with the network-specific section (e.g. [regtest]) taking precedence over [default]. Returns None if unset.

  • node.pyNode.delete_wallet_file() — Uses get_walletdir() as the wallet base path when set; falls back to existing datadir + chain-subdir logic otherwise.

  • devices/bitcoin_core.pyBitcoinCore.delete() — Same pattern; walletdir replaces the two-candidate path search when configured.

Example bitcoin.conf patterns handled

# Global default
walletdir=/mnt/ssd/wallets

# Or network-specific (takes precedence)
[regtest]
walletdir=/tmp/regtest-wallets

# Or dot-notation equivalent
regtest.walletdir=/tmp/regtest-wallets

All three formats are already parsed by get_rpcconfig(), so no parser changes were needed.

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 8, 2026

Deploy Preview for specter-desktop-docs canceled.

Name Link
🔨 Latest commit 9c9b41e
🔍 Latest deploy log https://app.netlify.com/projects/specter-desktop-docs/deploys/69d7a749ce1972000806a784

Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix wallets directory detection and removal Read walletdir from bitcoin.conf when deleting wallet files Apr 8, 2026
Copilot AI requested a review from k9ert April 8, 2026 19:51
Copilot finished work on behalf of k9ert April 8, 2026 19:51
@k9ert k9ert marked this pull request as ready for review April 8, 2026 20:01
Copilot AI review requested due to automatic review settings April 8, 2026 20:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes wallet file deletion when Bitcoin Core is configured with a custom walletdir in bitcoin.conf, by resolving the effective wallet base directory (network section overrides defaults) and using it during delete operations.

Changes:

  • Add get_walletdir(datadir, chain) helper to read walletdir from parsed bitcoin.conf with network-specific precedence.
  • Update wallet deletion logic to use walletdir when present, falling back to previous datadir-based paths when absent.
  • Add test coverage and fixtures for walletdir in bitcoin.conf.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_rpc.py Adds unit tests for get_walletdir behavior (default vs network override).
tests/misc_testdata/rpc_autodetection/example_walletdir_network/bitcoin.conf New fixture with both global and [regtest] walletdir.
tests/misc_testdata/rpc_autodetection/example_walletdir_default/bitcoin.conf New fixture with only global walletdir.
src/cryptoadvance/specter/rpc.py Introduces get_walletdir() using get_rpcconfig() output.
src/cryptoadvance/specter/node.py Uses get_walletdir() in Node.delete_wallet_file() to locate wallet files correctly.
src/cryptoadvance/specter/devices/bitcoin_core.py Uses get_walletdir() in BitcoinCore.delete() to locate hot-wallet files correctly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_rpc.py
Comment thread src/cryptoadvance/specter/node.py
Comment thread src/cryptoadvance/specter/devices/bitcoin_core.py
Comment thread src/cryptoadvance/specter/rpc.py Outdated
Comment thread tests/test_rpc.py
@k9ert k9ert force-pushed the copilot/detect-remove-wallets-directory branch from cf75983 to 9c9b41e Compare April 9, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wallets directory detection and removal

3 participants