From 54badbf7d8e5584125cd3e5082cfd9cabfd67f58 Mon Sep 17 00:00:00 2001 From: BANADDA MUBARAKA <83466862+BANADDA@users.noreply.github.com> Date: Thu, 17 Sep 2026 13:53:27 +0300 Subject: [PATCH] identity: accept a bittensor hotkey file that carries only the private key --- validator/identity.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/validator/identity.py b/validator/identity.py index 947fc42..92e65a2 100644 --- a/validator/identity.py +++ b/validator/identity.py @@ -6,7 +6,7 @@ from pathlib import Path from typing import Any -from substrateinterface import Keypair +from substrateinterface import Keypair, KeypairType from protocol.session import HEADER_HOTKEY, HEADER_SIGNATURE, HEADER_TIMESTAMP, signing_bytes from validator.config import Settings @@ -53,7 +53,26 @@ def load_keypair(settings: Settings) -> Keypair: return Keypair.create_from_seed(seed_bytes(seed), ss58_format=SS58_FORMAT) if phrase: return Keypair.create_from_mnemonic(phrase.strip(), ss58_format=SS58_FORMAT) - raise IdentityError("the wallet hotkey file has neither secretSeed nor secretPhrase") + private = str(data.get("privateKey", "") or "") + if private: + raw = bytes.fromhex(private[2:] if private.startswith("0x") else private) + public = str(data.get("publicKey", "") or "") + crypto = ( + KeypairType.SR25519 + if int(data.get("cryptoType", 1) or 1) == 0 + else KeypairType.ED25519 + ) + return Keypair( + public_key=bytes.fromhex(public[2:] if public.startswith("0x") else public) + if public + else None, + private_key=raw, + ss58_format=SS58_FORMAT, + crypto_type=crypto, + ) + raise IdentityError( + "the wallet hotkey file has neither secretSeed, secretPhrase nor privateKey" + ) raise IdentityError("set CV_HOTKEY_SEED, CV_HOTKEY_MNEMONIC or CV_WALLET_HOTKEY_FILE")