-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Bug Description
btcli wallet create unconditionally attempts to create a new coldkey before creating the hotkey, even when the wallet's coldkey already exists. This causes two confusing/problematic behaviors:
1. Misleading mnemonic displayed
When a user runs btcli wallet create --wallet-name <existing-wallet> to add a new hotkey, the command first generates and displays a coldkey mnemonic that the user never asked for:
The mnemonic to the new coldkey is: save dentist casino uniform tube lift renew degree patient siege awake foot
This is confusing because the user intended to create a hotkey, not a coldkey. They see a coldkey mnemonic first, which may lead them to believe the labels are wrong (since they only wanted a hotkey).
2. Unnecessary overwrite prompt for existing coldkey
After displaying the unwanted coldkey mnemonic, the command prompts:
File /Users/user/.bittensor/wallets/my-wallet/coldkey already exists. Overwrite? (y/N)
If the user says N (to protect their existing coldkey), they get an error:
Generic error: Failed to create new coldkey: KeyFileError(Generic("File is not writable..."))
The hotkey creation then proceeds correctly, but the UX is confusing and potentially dangerous (a user might accidentally overwrite their coldkey).
Expected Behavior
When running btcli wallet create with an existing wallet name:
- If the coldkey already exists, skip coldkey creation and inform the user
- Only create the new hotkey
- Don't show a coldkey mnemonic that can't/won't be saved
Root Cause
In bittensor_cli/src/commands/wallets.py, the wallet_create function calls wallet.create_new_coldkey() unconditionally without checking if the coldkey file already exists:
async def wallet_create(...):
# ...
else:
try:
wallet.create_new_coldkey(...) # Always called, even if coldkey exists
except KeyFileError as error:
...
try:
wallet.create_new_hotkey(...)
except KeyFileError as error:
...Steps to Reproduce
- Create a wallet:
btcli wallet create --wallet-name test-wallet - Run the same command again to add a new hotkey:
btcli wallet create --wallet-name test-wallet - Observe: coldkey mnemonic is displayed, followed by overwrite prompt
Environment
- btcli version: 9.18.1 (also affects 9.17.0 and earlier)
- OS: macOS
- bittensor-wallet: 4.0.0