Skip to content

Commit

Permalink
Adds confirmation after each successful regen
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheem-opentensor committed Oct 31, 2024
1 parent f958ec8 commit 662eeb2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,21 @@ async def regen_coldkey(
with open(json_path, "r") as f:
json_str = f.read()
try:
wallet.regenerate_coldkey(
new_wallet = wallet.regenerate_coldkey(
mnemonic=mnemonic,
seed=seed,
json=(json_str, json_password) if all([json_str, json_password]) else None,
use_password=use_password,
overwrite=False,
)

if isinstance(new_wallet, Wallet):
console.print(
"\n✅ [dark_sea_green]Regenerated coldkey successfully!\n",
f"[dark_sea_green]Wallet name: ({new_wallet.name}), path: ({new_wallet.path}), coldkey ss58: ({new_wallet.coldkeypub.ss58_address})",
)
except ValueError:
print_error("Mnemonic phrase is invalid")
except KeyFileError:
print_error("KeyFileError: File is not writable")

Expand All @@ -93,11 +101,16 @@ async def regen_coldkey_pub(
):
"""Creates a new coldkeypub under this wallet."""
try:
wallet.regenerate_coldkeypub(
new_coldkeypub = wallet.regenerate_coldkeypub(
ss58_address=ss58_address,
public_key=public_key_hex,
overwrite=False,
)
if isinstance(new_coldkeypub, Wallet):
console.print(
"\n✅ [dark_sea_green]Regenerated coldkeypub successfully!\n",
f"[dark_sea_green]Wallet name: ({new_coldkeypub.name}), path: ({new_coldkeypub.path}), coldkey ss58: ({new_coldkeypub.coldkeypub.ss58_address})",
)
except KeyFileError:
print_error("KeyFileError: File is not writable")

Expand All @@ -120,13 +133,20 @@ async def regen_hotkey(
json_str = f.read()

try:
wallet.regenerate_hotkey(
new_hotkey = wallet.regenerate_hotkey(
mnemonic=mnemonic,
seed=seed,
json=(json_str, json_password) if all([json_str, json_password]) else None,
use_password=use_password,
overwrite=False,
)
if isinstance(new_hotkey, Wallet):
console.print(
"\n✅ [dark_sea_green]Regenerated hotkey successfully!\n",
f"[dark_sea_green]Wallet name: ({new_hotkey.name}), path: ({new_hotkey.path}), hotkey ss58: ({new_hotkey.hotkey.ss58_address})",
)
except ValueError:
print_error("Mnemonic phrase is invalid")
except KeyFileError:
print_error("KeyFileError: File is not writable")

Expand Down

0 comments on commit 662eeb2

Please sign in to comment.