Skip to content

Commit 49f4af9

Browse files
committed
Better shows hotkeypubs in w list
1 parent db8a45e commit 49f4af9

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

bittensor_cli/src/bittensor/utils.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,26 @@ def get_hotkey_wallets_for_wallet(
269269
except FileNotFoundError:
270270
hotkeys = []
271271
for h_name in hotkeys:
272-
hotkey_for_name = Wallet(path=str(wallet_path), name=wallet.name, hotkey=h_name)
272+
if h_name.endswith("pub.txt"):
273+
if h_name.split("pub.txt")[0] in hotkeys:
274+
continue
275+
else:
276+
hotkey_for_name = Wallet(
277+
path=str(wallet_path),
278+
name=wallet.name,
279+
hotkey=h_name.split("pub.txt")[0],
280+
)
281+
else:
282+
hotkey_for_name = Wallet(
283+
path=str(wallet_path), name=wallet.name, hotkey=h_name
284+
)
273285
try:
286+
exists = (
287+
hotkey_for_name.hotkey_file.exists_on_device()
288+
or hotkey_for_name.hotkeypub_file.exists_on_device()
289+
)
274290
if (
275-
(exists := hotkey_for_name.hotkey_file.exists_on_device())
291+
exists
276292
and not hotkey_for_name.hotkey_file.is_encrypted()
277293
# and hotkey_for_name.coldkeypub.ss58_address
278294
and get_hotkey_pub_ss58(hotkey_for_name)

bittensor_cli/src/commands/wallets.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,12 +846,21 @@ async def wallet_list(wallet_path: str, json_output: bool):
846846
data = f"[bold red]Hotkey[/bold red][green] {hkey}[/green] (?)"
847847
hk_data = {"name": hkey.name, "ss58_address": "?"}
848848
if hkey:
849-
hkey_ss58 = get_hotkey_pub_ss58(hkey)
849+
try:
850+
hkey_ss58 = hkey.get_hotkey().ss58_address
851+
pub_only = False
852+
except KeyFileError:
853+
hkey_ss58 = hkey.get_hotkeypub().ss58_address
854+
pub_only = True
850855
try:
851856
data = (
852857
f"[bold red]Hotkey[/bold red] [green]{hkey.hotkey_str}[/green] "
853-
f"ss58_address [green]{hkey_ss58}[/green]\n"
858+
f"ss58_address [green]{hkey_ss58}[/green]"
854859
)
860+
if pub_only:
861+
data += " [blue](hotkeypub only)[/blue]\n"
862+
else:
863+
data += "\n"
855864
hk_data["name"] = hkey.hotkey_str
856865
hk_data["ss58_address"] = hkey_ss58
857866
except UnicodeDecodeError:

0 commit comments

Comments
 (0)