Skip to content

Conversation

@achow101
Copy link
Member

We've been moving in the direction that all wallets must have a name. Therefore, we shouldn't allow creating new unnamed wallets. createwallet, restorewallet, and the wallet tool's create and createfromdump all now require the user to provide a non-empty wallet name when creating/restoring a wallet.

The GUI is already enforcing this, but we were not enforcing it for RPCs or in the underlying CreateWallet and RestoreWallet functions.

Wallet migration does still need to be able to restore unnamed wallets, so there is a new argument to RestoreWallet to explicitly allow that behavior for migration only.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 12, 2026

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34269.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK polespinasa, Sjors, w0xlt, rogersala21

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34176 (wallet: improve error msg when db directory is not writable by furszy)
  • #25722 (refactor: Use util::Result class for wallet loading by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

Mostly happy with 5e3d561. The missing newline issue needs fixing, the rest is more cosmetic.

Copy link
Member

@polespinasa polespinasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concept ACK

reviewed first commit d65c0da will review the second one later.

Left some questions.


self.log.info('New default wallet should load by default when there are no other wallets')
self.nodes[0].createwallet(wallet_name='', load_on_startup=False)
self.nodes[0].create_unnamed_wallet(load_on_startup=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why no just add a name to the wallet?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is specifically regarding the unnamed wallet (referred to as the default wallet) and loading it automatically on startup if it's there by itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth a comment to make it easy to understand if you lack context?

Copy link
Member

@Sjors Sjors Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's enough context if you hover over the create_unnamed_wallet helper? Or is there something else about this test that needs clarifying?

Scherm­afbeelding 2026-01-14 om 11 21 23

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes what create_unnamed_wallet does is clear, what is not clear is that the test needs an unnamed wallet. Because without context it is not clear that default wallet means unnamed.

That lack of context is what made me ask why not just add a name to the wallet.

Something like this might be enough:

self.log.info('New default (unnamed) wallet should load by default when there are no other wallets')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because without context it is not clear that default wallet means unnamed.

Default wallet has always meant the unnamed wallet.

@achow101 achow101 force-pushed the dont-create-default-wallets branch from 5e3d561 to 1261089 Compare January 13, 2026 21:22
Copy link
Member

@polespinasa polespinasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm tested ACK 1261089

Prior to this PR you could create or restore a wallet using an empty name "", now you cannot and it fails returning an error code.

$ ./build/bin/bitcoin-cli createwallet ""
error code: -8
error message:
Wallet name cannot be empty
$ ./build/bin/bitcoin-wallet -wallet='' create
Wallet name cannot be empty


self.log.info('New default wallet should load by default when there are no other wallets')
self.nodes[0].createwallet(wallet_name='', load_on_startup=False)
self.nodes[0].create_unnamed_wallet(load_on_startup=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth a comment to make it easy to understand if you lack context?

@Sjors
Copy link
Member

Sjors commented Jan 14, 2026

utACK 1261089

const fs::path path = fsbridge::AbsPathJoin(GetWalletDir(), fs::PathFromString(name));

if (command == "create") {
if (name.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code reachable considering the condition already being checked above if ((command == "create" || command == "createfromdump") && !args.IsArgSet("-wallet")) { ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, -wallet= is a valid way to set -wallet

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm ACK 1261089 with the above minor nit

Copy link

@rogersala21 rogersala21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 1261089

Tested and reviewed the code lgtm.

Now restorewallet does not work with empty name "".

$ /bitcoin-cli restorewallet "" walletbackup.dat 
error code: -8
error message:
Wallet name cannot be empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants