Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,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 @@ -100,11 +108,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 @@ -127,13 +140,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