qml: Validate wallet name during wallet creation #686

Closed
pseudoramdom wants to merge 3 commits from duplicate-wallet-name into qt6 AGit
pseudoramdom commented 2026-05-06 16:26:52 +00:00 (Migrated from github.com)

Fixes https://github.com/bitcoin-core/gui-qml/issues/571

When creating a wallet, the name is checked for

  • invalid/empty names
  • discovered wallet names in wallet dir
  • existing loaded wallets

The same checks are performed for external-signer wallets.

Review notes

This PR is stacked on top of #547. Now rebased on top of qt6

Screenshots

Screenshot 2026-05-06 at 8 50 36 AM
Fixes https://github.com/bitcoin-core/gui-qml/issues/571 When creating a wallet, the name is checked for - invalid/empty names - discovered wallet names in wallet dir - existing loaded wallets The same checks are performed for external-signer wallets. ### Review notes ~~This PR is stacked on top of #547.~~ Now rebased on top of `qt6` ## Screenshots <img width="1210" height="836" alt="Screenshot 2026-05-06 at 8 50 36 AM" src="https://git.fish.foo/attachments/7cabda7b-1668-4eef-9151-40175963f962" />
pseudoramdom commented 2026-05-06 16:42:27 +00:00 (Migrated from github.com)

I could've written unit test, but the scaffolding for test_walletcontroller is all in #551 already.
Felt it's easier to add later rather than picking that commit and dropping it later when #551 is merged. Thoughts @johnny9 ?

I could've written unit test, but the scaffolding for test_walletcontroller is all in #551 already. Felt it's easier to add later rather than picking that commit and dropping it later when #551 is merged. Thoughts @johnny9 ?
johnny9 commented 2026-05-06 16:52:48 +00:00 (Migrated from github.com)

I could've written unit test, but the scaffolding for test_walletcontroller is all in #551 already.
Felt it's easier to add later rather than picking that commit and dropping it later when #551 is merged. Thoughts @johnny9 ?

I'm fine with that.

> I could've written unit test, but the scaffolding for test_walletcontroller is all in #551 already. > Felt it's easier to add later rather than picking that commit and dropping it later when #551 is merged. Thoughts @johnny9 ? I'm fine with that.
pseudoramdom commented 2026-05-10 19:52:45 +00:00 (Migrated from github.com)

558cf9c1b722adbbf294a6c9901a3cc0d57caadd
Rebased on top of qt6 now

558cf9c1b722adbbf294a6c9901a3cc0d57caadd Rebased on top of `qt6` now
MarnixCroes (Migrated from github.com) reviewed 2026-05-12 18:06:41 +00:00
MarnixCroes (Migrated from github.com) left a comment

558cf9c1b722adbbf294a6c9901a3cc0d57caadd

tested a bit, works as expected ✅

558cf9c1b722adbbf294a6c9901a3cc0d57caadd tested a bit, works as expected ✅
MarnixCroes (Migrated from github.com) commented 2026-05-12 17:45:10 +00:00

IMO this makes sense.

Note that bitcoin-qt, allows special characters, more than 20 characters and does not trim.
IDK if this was a purposeful decision (back then).

IMO this makes sense. Note that bitcoin-qt, allows special characters, more than 20 characters and does not trim. IDK if this was a purposeful decision (back then).
MarnixCroes (Migrated from github.com) commented 2026-05-12 17:48:45 +00:00
        return tr("Wallet names can use up to 20 characters (letters, numbers and underscores).");
```suggestion return tr("Wallet names can use up to 20 characters (letters, numbers and underscores)."); ```
MarnixCroes (Migrated from github.com) commented 2026-05-12 17:48:56 +00:00

nit

nit
davidgumberg (Migrated from github.com) reviewed 2026-05-12 20:59:18 +00:00
davidgumberg (Migrated from github.com) commented 2026-05-12 20:59:18 +00:00

in bitcoin-qt and bitcoin core wallet names are not distinct from paths, so whatever characters are permitted in a path are permitted in a wallet name..

This validation rule disallows wallet names that use utf-8 I am not sure if that's intentional?

I wonder if wallet name rules belong to the wallet itself rather than the gui controller. Related is that users with existing wallets that violate these rules won't be able to load them in the gui.

in bitcoin-qt and bitcoin core wallet names are not distinct from paths, so whatever characters are permitted in a path are permitted in a wallet name.. This validation rule disallows wallet names that use utf-8 I am not sure if that's intentional? I wonder if wallet name rules belong to the wallet itself rather than the gui controller. Related is that users with existing wallets that violate these rules won't be able to load them in the gui.
johnny9 (Migrated from github.com) reviewed 2026-05-14 03:07:07 +00:00
johnny9 (Migrated from github.com) commented 2026-05-14 03:07:07 +00:00

validation rules in the gui can give faster feedback to the user so they are useful but the current validation rules are too restrictive. it shouldn't prevent the user from loading their 🚀🚀🚀🚀🚀🚀 wallet but we should allow utf-8 wallet names since it is valid

image
validation rules in the gui can give faster feedback to the user so they are useful but the current validation rules are too restrictive. it shouldn't prevent the user from loading their 🚀🚀🚀🚀🚀🚀 wallet but we should allow utf-8 wallet names since it is valid <img width="833" height="755" alt="image" src="https://git.fish.foo/attachments/50a32c68-6c1b-43dd-8db9-587104372e4a" />
pseudoramdom (Migrated from github.com) reviewed 2026-05-14 04:43:50 +00:00
pseudoramdom (Migrated from github.com) commented 2026-05-14 04:43:50 +00:00

Agree. I'll relax the regex to allow utf-8.
Additionally, David suggested moving the wallet name validation to wallet and exposing a wallet interface for it. (as a follow-up, not required for this PR)

Agree. I'll relax the regex to allow utf-8. Additionally, David suggested moving the wallet name validation to wallet and exposing a wallet interface for it. (as a follow-up, not required for this PR)
jarolrod (Migrated from github.com) reviewed 2026-05-14 04:54:44 +00:00
jarolrod (Migrated from github.com) commented 2026-05-14 04:54:44 +00:00

here's an interesting nit I noticed, should I placeholder test represent valid names, as in should the placeholder test instead be: "my_bitcoin_wallet"

here's an interesting nit I noticed, should I placeholder test represent valid names, as in should the placeholder test instead be: "my_bitcoin_wallet"
pseudoramdom commented 2026-05-14 18:23:31 +00:00 (Migrated from github.com)

Hi @GBKS - is there a design spec to show validation errors? Would it be toast?

Hi @GBKS - is there a design spec to show validation errors? Would it be toast?
pseudoramdom commented 2026-05-26 19:27:45 +00:00 (Migrated from github.com)

Pulled this into https://github.com/bitcoin-core/gui-qml/pull/727. Closing this PR.

Pulled this into https://github.com/bitcoin-core/gui-qml/pull/727. Closing this PR.
Sign in to join this conversation.
No description provided.