Skip to content

Commit

Permalink
support Wallet names with hyphens when passing password through ENV vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed May 30, 2024
1 parent 119bc8d commit 5ff7584
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bittensor/keyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def get_coldkey_password_from_environment(coldkey_name: str) -> Optional[str]:
for env_name, env_value in os.environ.items()
if (normalized_env_name := env_name.upper()).startswith("BT_COLD_PW_")
}
return envs.get(f"BT_COLD_PW_{coldkey_name.upper()}")
return envs.get(f"BT_COLD_PW_{coldkey_name.replace('-', '_').upper()}")


def decrypt_keyfile_data(
Expand Down
3 changes: 2 additions & 1 deletion tests/unit_tests/test_keyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ def test_deserialize_keypair_from_keyfile_data(keyfile_setup_teardown):
def test_get_coldkey_password_from_environment(monkeypatch):
password_by_wallet = {
"WALLET": "password",
"my_wallet": "password",
"my_wallet": "password2",
"my-wallet": "password2",
}

monkeypatch.setenv("bt_cold_pw_wallet", password_by_wallet["WALLET"])
Expand Down

0 comments on commit 5ff7584

Please sign in to comment.