From c9c830a667b742ba59d0496f599c3fb74ab6d3a5 Mon Sep 17 00:00:00 2001 From: Shardul Bansal <33334493+bansal19@users.noreply.github.com> Date: Thu, 19 Mar 2026 11:56:57 -0700 Subject: [PATCH] fix: skip coldkey creation in wallet_create when coldkey already exists When running `btcli wallet create` on an existing wallet, the command unconditionally tried to create a new coldkey, causing a confusing overwrite prompt and displaying an unwanted coldkey mnemonic. Now checks if coldkey file exists before attempting creation, and only creates the hotkey when a coldkey is already present. Fixes #861 Co-Authored-By: Claude Opus 4.6 (1M context) --- bittensor_cli/src/commands/wallets.py | 40 +++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 1b15ff2c8..015dac802 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -506,24 +506,30 @@ async def wallet_create( f"[dark_sea_green]Wallet created from URI: {uri}[/dark_sea_green]" ) else: - try: - wallet.create_new_coldkey( - n_words=n_words, - use_password=use_password, - overwrite=overwrite, + if wallet.coldkey_file.exists_on_device() and not overwrite: + console.print( + "[dark_sea_green]Coldkey already exists, skipping coldkey " + "creation. Use --overwrite to force recreation.[/dark_sea_green]" ) - console.print("[dark_sea_green]Coldkey created[/dark_sea_green]") - output_dict["success"] = True - output_dict["data"] = { - "name": wallet.name, - "path": wallet.path, - "hotkey": wallet.hotkey_str, - "coldkey_ss58": wallet.coldkeypub.ss58_address, - } - except KeyFileError as error: - err = str(error) - print_error(err) - output_dict["error"] = err + else: + try: + wallet.create_new_coldkey( + n_words=n_words, + use_password=use_password, + overwrite=overwrite, + ) + console.print("[dark_sea_green]Coldkey created[/dark_sea_green]") + output_dict["success"] = True + output_dict["data"] = { + "name": wallet.name, + "path": wallet.path, + "hotkey": wallet.hotkey_str, + "coldkey_ss58": wallet.coldkeypub.ss58_address, + } + except KeyFileError as error: + err = str(error) + print_error(err) + output_dict["error"] = err try: wallet.create_new_hotkey( n_words=n_words,