Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsNo conflicts as of last run. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
a530752 to
203efb1
Compare
|
What is the benefit here? Seems highly risky, because it could mean that a pre-existing wallet name that is nested in whitespace could possibly not be loaded/restored/dumped/etc. So ~0 for a risky change without any benefits. |
Thanks for the feedback. My motivation was to prevent wallet names that consist solely of whitespace, since they can be confusing to users and difficult to distinguish in the UI or when passed through the RPC interface. For instance, a user creates a wallet with 2 spaces Please note that the PR is not trimming the user inputs ratedg@0xratedg:~/Desktop/bitcoin/build/bin$ ./bitcoin-cli createwallet " testallet "
{
"name": " testallet "
}the above is totally valid, and it is saved as such. The one below is, however, rejected because it contains only spaces ratedg@0xratedg:~/Desktop/bitcoin/build/bin$ ./bitcoin-cli createwallet " "
error code: -8
error message:
Wallet name cannot be empty
ratedg@0xratedg:~/Desktop/bitcoin/build/bin$
|
|
IMO, I do not see the difference between |
I don't know if a user exists with a space-only wallet, but breaking the UX for them for no reason seems pointless? |
Does it break the UX? The check was there already |
|
It's reasonable to disallow such names when creating a new wallet, but still allow existing wallets to be loaded. |
This PR trims wallet names using util::TrimStringView before the empty check, across all call sites that currently guard against empty wallet names
203efb1 to
8464a0e
Compare
I have restored the |
frankomosh
left a comment
There was a problem hiding this comment.
Are non-ASCII covered by TrimStringView? Or should they even matter in this case?
|
|
I think if we are doing this we should disable any white-space beginning or ending a wallet name. Valid cases:
Invalid cases:
But this restriction must only be applied in wallet creation to keep backwards compatibility. Also the error message should not be "empty wallet name" as that is not the case. Functional tests should be added for each case. And a release note will be necessary for this, affecting the GUI and the RPC interface. I think the motivation for this should be avoid not being able to load the wallet as you cannot easily identify the number of white-spaces that the name has. |
This is very helpful @polespinasa . Checking before accepting instead of accepting then trimming without users' knowledge, for your last three example cases i.e. I will work on tests and the release notes. |
Sorry for bike-shedding this, but if this was the motivation, what about:
Should they be invalid as well? Again, no objection. I am just curios what the real motivation here is. Also, this currently code-conflicts with #35833. |
|
Will take a look to #35833. About motivation, yeah it is tricky because there can always be weird cases, idk where the line is on what should be able to be done and what not. I only specified white-spaces at the begging and at the end bc they are more likely to be "invisible" in some desktop interfaces. But if we care about > 1 white-spaces in between also, we could just forbid more than one white-spaces together if between other characters. About the "... aaaaaaaaaaaaaaaa ..." I think that is fine as those are "visible" characters, but that is just an opinion, obviously still ugly. I see it more as a "mistake" prevention, in case a user by mistake sets an empty space at the beginning and then he is unable to load the wallet. |
|
My motivation was to prevent space only wallet names by adding more validation. For backward compatibility achow recommended leaving the loading logic for now. I guess it will be done eventually, hahah. IMO I can't seem to find any justification for allowing such names. |
|
There still seems to be no conceptual buy in here and there hasn't been any activity for more than a month. Given the number of pull requests, and limited review resources, maybe this should be closed for now due to lack of interest? |
|
I agree in closing this and opening an issue to discuss if we care about this "weird" names. |
|
Agreed @sedited |

Summary
This PR trims wallet names using util::TrimStringView before the empty check, across all call sites that currently guard against empty wallet names
Motivation: Although there is a check against empty wallet names, it does not reject wallet names consisting solely of whitespace. As a result, the RPC command below succeeds and creates a wallet with a whitespace-only name. Such names are not meaningful and are effectively indistinguishable from nameless directories to users, so they should be rejected in the same way as empty wallet names.
bitcoin-cli createwallet " "util::TrimStringView;has been preferred as opposed toutil::TrimString;to prevent mutating the user input but guarding against space-only names. This means that the wallet name can have leading and trailing white space unless requested otherwise.Testing
Before:
After: