From 49f4af99a610e3cee65ca5cbf6a5d7f3be2c6c83 Mon Sep 17 00:00:00 2001 From: bdhimes Date: Mon, 8 Sep 2025 14:58:52 +0200 Subject: [PATCH] Better shows hotkeypubs in `w list` --- bittensor_cli/src/bittensor/utils.py | 20 ++++++++++++++++++-- bittensor_cli/src/commands/wallets.py | 13 +++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/bittensor_cli/src/bittensor/utils.py b/bittensor_cli/src/bittensor/utils.py index 8611db3f8..1497470a9 100644 --- a/bittensor_cli/src/bittensor/utils.py +++ b/bittensor_cli/src/bittensor/utils.py @@ -269,10 +269,26 @@ def get_hotkey_wallets_for_wallet( except FileNotFoundError: hotkeys = [] for h_name in hotkeys: - hotkey_for_name = Wallet(path=str(wallet_path), name=wallet.name, hotkey=h_name) + if h_name.endswith("pub.txt"): + if h_name.split("pub.txt")[0] in hotkeys: + continue + else: + hotkey_for_name = Wallet( + path=str(wallet_path), + name=wallet.name, + hotkey=h_name.split("pub.txt")[0], + ) + else: + hotkey_for_name = Wallet( + path=str(wallet_path), name=wallet.name, hotkey=h_name + ) try: + exists = ( + hotkey_for_name.hotkey_file.exists_on_device() + or hotkey_for_name.hotkeypub_file.exists_on_device() + ) if ( - (exists := hotkey_for_name.hotkey_file.exists_on_device()) + exists and not hotkey_for_name.hotkey_file.is_encrypted() # and hotkey_for_name.coldkeypub.ss58_address and get_hotkey_pub_ss58(hotkey_for_name) diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index ff37a50e7..ab002919e 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -846,12 +846,21 @@ async def wallet_list(wallet_path: str, json_output: bool): data = f"[bold red]Hotkey[/bold red][green] {hkey}[/green] (?)" hk_data = {"name": hkey.name, "ss58_address": "?"} if hkey: - hkey_ss58 = get_hotkey_pub_ss58(hkey) + try: + hkey_ss58 = hkey.get_hotkey().ss58_address + pub_only = False + except KeyFileError: + hkey_ss58 = hkey.get_hotkeypub().ss58_address + pub_only = True try: data = ( f"[bold red]Hotkey[/bold red] [green]{hkey.hotkey_str}[/green] " - f"ss58_address [green]{hkey_ss58}[/green]\n" + f"ss58_address [green]{hkey_ss58}[/green]" ) + if pub_only: + data += " [blue](hotkeypub only)[/blue]\n" + else: + data += "\n" hk_data["name"] = hkey.hotkey_str hk_data["ss58_address"] = hkey_ss58 except UnicodeDecodeError: