Skip to content

fix(cli): warn for the effective command network - #400

Open
h55n wants to merge 1 commit into
bitcoindevkit:masterfrom
h55n:fix/effective-mainnet-warning-395
Open

h55n wants to merge 1 commit into
bitcoindevkit:masterfrom
h55n:fix/effective-mainnet-warning-395

Conversation

@h55n

@h55n h55n commented Dec 5, 2026

Copy link
Copy Markdown

Fixes #395

The mainnet warning fires whenever --network bitcoin is passed, even for commands that never touch the network (wallets list, completions, entering the REPL), and it goes by the CLI flag rather than the network a saved wallet actually runs on. So a saved signet wallet warns just because the flag says bitcoin, and a saved mainnet wallet stays silent when the flag says testnet.

This moves the warning to the network that is effective for each command:

  • wallet config warns on the CLI network, since that is what gets saved
  • online, offline and HWI wallet commands warn on the saved wallet's network from the WalletRuntime, so the warning follows the wallet, not the flag
  • the REPL warns on entry using the saved wallet's network
  • network-independent commands (wallets, completions) don't warn
  • anything else (for example key and descriptor) keeps warning on the CLI network as a conservative default

Only where the warning is emitted changes; no command's operations are affected.

Tests: new tests/integration/mainnet_warning.rs covers the false positives (wallets list, completions, a testnet wallet under --network bitcoin), the false negatives (a mainnet wallet under --network testnet, wallet config on mainnet) and RUST_LOG suppression, on both the direct and REPL paths. The two existing init tests that asserted wallets list warns now assert against key generate, which keeps the conservative warning.

Use saved wallet networks for wallet commands and REPL sessions instead of the global default. Skip the mainnet warning for wallet listing and shell completions, and keep log-level filtering.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Emit the mainnet warning only for commands that actually use the network

1 participant