fix: skip coldkey creation in wallet create when coldkey already exists#862
Open
shardi-b wants to merge 1 commit intoopentensor:mainfrom
Open
fix: skip coldkey creation in wallet create when coldkey already exists#862shardi-b wants to merge 1 commit intoopentensor:mainfrom
shardi-b wants to merge 1 commit intoopentensor:mainfrom
Conversation
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 opentensor#861 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #861 -
btcli wallet createunconditionally attempts to create a new coldkey even when one already exists for the wallet, causing confusing behavior.Changes Made
wallet_create()to verify if the coldkey file already exists before attempting creation--overwriteis not set, prints an informational message and skips to hotkey creation--overwriteis explicitly passed, existing behavior is preserved (coldkey gets recreated)Issue Link
Testing
Manual Testing
btcli wallet create --wallet-name test-walletbtcli wallet create --wallet-name test-wallet --wallet-hotkey new-hotkeyTest Results: Fix verified manually - coldkey creation is skipped, only hotkey mnemonic shown, no overwrite prompt.
Automated Testing
Test Command(s):
# Existing e2e tests in tests/e2e_tests/test_wallet_creations.py cover wallet creation flowsRoot Cause
In
bittensor_cli/src/commands/wallets.py, thewallet_createfunction calledwallet.create_new_coldkey()unconditionally without checking if a coldkey already existed:This pattern (
coldkey_file.exists_on_device()) is already used elsewhere in the codebase (e.g., line 604, 873) for the same purpose.Checklist