You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make wallet network immutable after creation, or document and validate it explicitly #359
The --network flag is a top-level option on every command, which makes it look like a per-invocation choice. In reality the network is fixed at wallet create and stored in the wallet config. Passing a different value later fails with Error: Generic error: Network mismatch: loaded testnet, expected testnet4, which does not explain why. Either the flag should be ignored on non-creation commands (network read from config), or the mismatch should be caught early with a clear message naming the wallet's stored network and suggesting the fix.
Use case
Descriptors only distinguish mainnet from non-mainnet (xpub vs tpub). Testnet, testnet4, signet, and regtest all share tpub, so the network genuinely cannot be inferred from the descriptor and has to be stored and validated separately so the current check is correct, only the UX is wrong. A user who created a wallet on one network and later types a different --network out of habit, or omits the flag entirely if it has a default, gets an opaque error that reads like a descriptor problem. A specific message for example: This wallet was created for network 'testnet'; remove --network or pass --network testnet turns a confusing failure into a one-line fix. Ignoring the flag on non-creation commands would be cleaner still, since the value is not actually a choice at that point.
Additional context
The flag is defined on CliOpts and flows into every subcommand, so nothing at the definition site signals that it is creation-time-only. At minimum, the --network help text should note that on non-creation commands it must match the wallet's stored network. The generic wrapping in Error::Generic is what hides the cause: the underlying check knows both the stored network and the requested one, but that information never reaches the user.
Remove the top-level --network option. Add it to the commands that use it: wallet config, key, and descriptor, plus the feature-gated silent_payment_code and resolve_dns_recipient commands. Normal wallet commands and the REPL will continue using the network stored in the wallet config.
Add a shared mainnet-warning helper. Call it when configuring a wallet and when loading one for wallet operations, using the wallet’s actual configured network. Commands that don’t use a wallet won’t emit this warning.
Keep --force for overwriting other wallet configuration, but reject attempts to change an existing wallet’s network. The error will identify the wallet and suggest using a new wallet name for a different network. Keep the persisted-wallet network check and make its error actionable for existing mismatches.
Hi @emma31-dev I have a different proposal for this issue.
Keep the top-level --network option for now, but explain in the help text that normal wallet commands use the network saved in the wallet configuration.
Prevent wallet config --force from changing an existing wallet's network while still allowing updates to other settings.
Improve the network mismatch error to show the wallet name, the network in its database, and the network in config.toml with guidance on what to correct.
I think this would address the mismatch without changing how users currently run the commands. Moving--network could then be handled separately.
@muawiya1 I agree that the change will create more friction for users so I think it should rather be documented and a clear error is emitted during the mismatch.
Can I take on this issue using my proposed approach, keeping --network where it is, documenting its behaviour and improving the error message when the networks do not match?
Activity
emma31-dev commentedon Oct 22, 2026
Here is my Proposed approach:
Remove the top-level
--networkoption. Add it to the commands that use it:wallet config,key, anddescriptor, plus the feature-gatedsilent_payment_codeandresolve_dns_recipientcommands. Normal wallet commands and the REPL will continue using the network stored in the wallet config.Add a shared mainnet-warning helper. Call it when configuring a wallet and when loading one for wallet operations, using the wallet’s actual configured network. Commands that don’t use a wallet won’t emit this warning.
Keep
--forcefor overwriting other wallet configuration, but reject attempts to change an existing wallet’s network. The error will identify the wallet and suggest using a new wallet name for a different network. Keep the persisted-wallet network check and make its error actionable for existing mismatches.muawiya1 commentedon Nov 2, 2026
Hi @emma31-dev I have a different proposal for this issue.
--networkoption for now, but explain in the help text that normal wallet commands use the network saved in the wallet configuration.wallet config --forcefrom changing an existing wallet's network while still allowing updates to other settings.config.tomlwith guidance on what to correct.I think this would address the mismatch without changing how users currently run the commands. Moving--network could then be handled separately.
emma31-dev commentedon Nov 2, 2026
@muawiya1 I agree that the change will create more friction for users so I think it should rather be documented and a clear error is emitted during the mismatch.
muawiya1 commentedon Nov 3, 2026
Can I take on this issue using my proposed approach, keeping
--networkwhere it is, documenting its behaviour and improving the error message when the networks do not match?emma31-dev commentedon Nov 3, 2026
@muawiya1 sure you can work on it then tag me to it so I review later.
vadim-anfv commentedon Nov 8, 2026
Thanks @emma31-dev, good catch.
@muawiya1 I see #377, it is in my review queue.