When the default wallet is migrated, we do not rename the wallet so we end up having a descriptor wallet with the empty string as its name and the wallet.dat file in the root of the walletdir. This is supposed to be an unsupported configuration and there is no other way to achieve this (other than file copying), but the wallet loading code does not disallow loading such wallets. However listwalletdir
does not currently list the default wallet if it is sqlite. This is confusing to users, so change listwalletdir
to include these wallets.
Additionally, the migration of the default wallet, and of any plain wallet files in the walletdir, produces a backup file in the walletdir itself. Since these backups are a BDB file, listwalletdir
will detect them as being another wallet that we could open, but this is erroneous and could lead to confusion and potentially funds loss if both the backup and the migrated wallet are in use simultaneously. To reduce the likelihood of this issue, don’t list these wallets in listwalletdir
.
Possibly we could have more stringent checks on loading to resolve these issues, but I’m concerned that that will just confuse users and gratuitously break things that already worked.
Since the original intent was to disallow default wallets for sqlite/descriptors, a possible alternative would be to prevent people from loading such wallets and change migration to rename those wallets. However, given that this behavior with migrating default wallets has existed since default wallet migration was fixed, I think that making such a change would be confusing and break things for no good reason. Although perhaps we should still do the renaming.
For the backups, we could also change loading to refuse to load any wallet named with .bak
(or .legacy.bak
) as such wallets can still be loaded by giving the path to them directly, which some users may do to “restore” the backup. However restricting what can be loaded based on filename seems a little heavyhanded. It wouldn’t be funds loss though since the correct way to restore the backup is with restorewallet
.