#35768 wallet: Reject whitespace-only wallet names

full analysis

https://github.com/bitcoin/bitcoin/pull/35768 · vicjuma · +15/-3 in 5 files, 1 commits · labels: Wallet

Goal

  • Prevent creating wallets whose names consist entirely of whitespace
  • Avoids creating blank-looking directories on disk that are difficult to manage

This pull request checks wallet names using `util::TrimStringView` before empty-string validation in `CreateWallet`, `CreateFromDump`, and `WalletTool::ExecuteWalletToolFunc`. Wallet creation and wallet-tool dump restoration are prevented from using names consisting entirely of whitespace, while existing wallets with such names can still be loaded.

Problem: Bitcoin Core disallows empty wallet names, but still permits wallet names composed solely of whitespace characters. This results in disk directory names that look blank and are difficult to distinguish or manage.

Category: Wallet (#72 of 84)

P4 · cleanup

  • P4 because whitespace-only wallet names are an extreme edge case with no safety implications
  • Provides a minor usability cleanup rather than fixing an active failure mode

P4 because whitespace-only wallet names are an extreme edge case that carries no security, stability, or fund-safety implications. The author notes that 'Such names are not meaningful and are effectively indistinguishable from nameless directories to users', which is a cosmetic and usability cleanup rather than a fix for an active failure mode.

Membership: Modifies wallet creation and dump loading validation in src/wallet/wallet.cpp, src/wallet/dump.cpp, and src/wallet/wallettool.cpp.

Factors: security/stability 0, bug 0, performance 0, user value 1, leverage 0

Reviewability: Ready

  • Ready to review
  • Small, self-contained patch with passing CI

The patch is small, self-contained, clean, and CI is passing; open scope suggestions do not invalidate review of the current implementation.

Author status: active, last engaged on 2026-08-26 explaining motivation and discussing scope

Open concerns:

  • maflcko questioned the real-world benefit and motivation, cautioning against any risk of breaking existing wallet UX.
  • polespinasa suggested extending the restriction to any wallet names with leading or trailing whitespace and using a dedicated error message instead of 'Wallet name cannot be empty'.

Resolved concerns:

  • achow101 noted that whitespace-only names should be disallowed during creation but existing wallets should still load; author restored the original check in RestoreWallet.

Agreement: Positive

  • General support for rejecting blank-like names at creation while preserving loading for existing ones
  • Supports blocking creation while ensuring existing wallets still load (achow101)
  • Skeptical of practical payoff and cautioned about UX risk, but raised no objection (maflcko)
  • Suggested broadening the restriction to leading and trailing whitespace (polespinasa)

Positive on rejecting empty-like names at creation, though reviewers debate the scope and utility

achow101 supported disallowing such names on creation provided existing wallets can still load. maflcko expressed skepticism over the practical payoff but explicitly stated no objection, while polespinasa proposed broadening the rule.

  • achow101: 'It's reasonable to disallow such names when creating a new wallet, but still allow existing wallets to be loaded.'
  • maflcko: '~0 for a risky change without any benefits... Again, no objection. I am just curios what the real motivation here is.'
  • polespinasa: 'I think if we are doing this we should disable any white-space beginning or ending a wallet name.'

Review verdicts (DrahtBot): 0

Files

7 lines under test/bench/ci.

  • test/functional/tool_wallet.py +6/-0
  • src/wallet/dump.cpp +3/-1
  • src/wallet/wallettool.cpp +3/-1
  • src/wallet/wallet.cpp +2/-1
  • test/functional/wallet_createwallet.py +1/-0

Card

This PR checks wallet names with util::TrimStringView before validating against empty strings, rejecting whitespace-only names when creating wallets or restoring from dumps. It addresses an edge case where users could create wallets named solely with spaces, leading to confusing directory listings that look blank. The change has minor usability value and fixes an oversight in the existing empty-name check without affecting existing wallet loading. Concept feedback is generally supportive of disallowing space-only names upon creation, though reviewers question whether the benefit is worth changing validation rules.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T16:20, confidence high, input hash 1bc9e8c7802c3da1