This code added here is more complicated than it needs to be and it is not a refactoring because it would change behavior, and in bad ways for windows and case insensitive filesystems. If the intention is to change behavior, this should be done in separate, smaller PR and accompanied by tests so it can be better understood and discussed. For a clean refactoring in this PR, this entire function should just be:
0WalletLocation::WalletLocation(const std::string& name) : m_name(name), m_path(fs::absolute(name, GetWalletDir()) {}
And the m_filename
and GetFileName()
members should be dropped and all GetFileName()
calls changed to GetName()
.
From: https://github.com/bitcoin/bitcoin/blob/d387507aeca652a5569825af65243536f2ce26ea/src/bitcoin-cli.cpp#L55
The way -rpcwallet
and -wallet
arguments were designed to work is that there is no string or path manipulation done when matching wallet names that would ever cause the wrong wallet to be used or the right wallet not to be found.
So for example, if a user starts bitcoind
with -wallet=c:\wallets\bob\2018\
they should be able to run bitcoin-cli
with the exact same -rpcwallet=c:\wallets\bob\2018\
value, and not have to figure out a different value like bob/2018
or C:\Wallets\Bob\2018
or whatever else the code added in this function might change it to.
I think we could consider changing this behavior, but only if we do it in a clear and deliberate way. I’d definitely want it to be done after this refactoring instead of simultaneously with it.