Skip to content

Commit 714cafb

Browse files
committed
New fn to retrieve wallet hotkey ss58
1 parent 1c19e0f commit 714cafb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bittensor_cli/src/bittensor/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,3 +1431,15 @@ def blocks_to_duration(blocks: int) -> str:
14311431
results.append(f"{unit_count}{unit}")
14321432
# Return only the first two non-zero units
14331433
return " ".join(results[:2]) or "0s"
1434+
1435+
1436+
def get_hotkey_pub_ss58(wallet: Wallet) -> str:
1437+
"""
1438+
Helper fn to retrieve the hotkeypub ss58 of a wallet that may have been created before
1439+
bt-wallet 3.1.1 and thus not have a wallet hotkeypub. In this case, it will return the hotkey
1440+
SS58.
1441+
"""
1442+
try:
1443+
return wallet.hotkeypub.ss58_address
1444+
except KeyFileError:
1445+
return wallet.hotkey.ss58_address

0 commit comments

Comments
 (0)