Skip to content

Commit

Permalink
Merge pull request #187 from opentensor/fix/thewhaleking/better-handl…
Browse files Browse the repository at this point in the history
…e-incorrect-pw

Better handle incorrect password
  • Loading branch information
thewhaleking authored Oct 15, 2024
2 parents a9cd8f8 + 1fcee62 commit 885d1fd
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bittensor_cli/src/bittensor/async_substrate_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,9 +682,9 @@ async def shutdown(self):
try:
self._receiving_task.cancel()
await self._receiving_task
await self.ws.close()
except (AttributeError, asyncio.CancelledError):
pass
await self.ws.close()
self.ws = None
self._initialized = False
self._receiving_task = None
Expand Down
1 change: 1 addition & 0 deletions bittensor_cli/src/bittensor/extrinsics/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,7 @@ async def swap_hotkey_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

if prompt:
Expand Down
2 changes: 2 additions & 0 deletions bittensor_cli/src/bittensor/extrinsics/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ async def root_register_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

print_verbose(f"Checking if hotkey ({wallet.hotkey_str}) is registered on root")
Expand Down Expand Up @@ -429,6 +430,7 @@ async def _do_set_weights():
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

# First convert types.
Expand Down
1 change: 1 addition & 0 deletions bittensor_cli/src/bittensor/extrinsics/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ async def do_transfer() -> tuple[bool, str, str]:
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

# Check balance.
Expand Down
5 changes: 5 additions & 0 deletions bittensor_cli/src/commands/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ async def burned_register_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

with console.status(
Expand Down Expand Up @@ -539,6 +540,7 @@ async def get_stake_for_coldkey_and_hotkey(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

print_verbose("Checking if hotkey is a delegate")
Expand Down Expand Up @@ -1100,6 +1102,7 @@ async def senate_vote(
wallet.unlock_hotkey()
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

console.print(f"Fetching proposals in [dark_orange]network: {subtensor.network}")
Expand Down Expand Up @@ -1323,6 +1326,7 @@ async def _do_set_take() -> bool:
wallet.unlock_hotkey()
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

result_ = await _do_set_take()
Expand Down Expand Up @@ -1724,6 +1728,7 @@ async def nominate(wallet: Wallet, subtensor: SubtensorInterface, prompt: bool):
wallet.unlock_hotkey()
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

print_verbose(f"Checking hotkey ({wallet.hotkey_str}) is a delegate")
Expand Down
4 changes: 4 additions & 0 deletions bittensor_cli/src/commands/stake/stake.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ async def add_stake_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

# Default to wallet's own hotkey if the value is not passed.
Expand Down Expand Up @@ -312,6 +313,7 @@ async def add_stake_multiple_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

with console.status(
Expand Down Expand Up @@ -493,6 +495,7 @@ async def unstake_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

if hotkey_ss58 is None:
Expand Down Expand Up @@ -663,6 +666,7 @@ async def unstake_multiple_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

with console.status(
Expand Down
1 change: 1 addition & 0 deletions bittensor_cli/src/commands/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async def _find_event_attributes_in_extrinsic_receipt(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

with console.status(":satellite: Registering subnet...", spinner="earth"):
Expand Down
1 change: 1 addition & 0 deletions bittensor_cli/src/commands/sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async def set_hyperparameter_extrinsic(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

extrinsic = HYPERPARAMS.get(parameter)
Expand Down
1 change: 1 addition & 0 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,7 @@ async def set_id(
try:
wallet.unlock_coldkey()
except KeyFileError:
err_console.print("Error decrypting coldkey (possibly incorrect password)")
return False

with console.status(
Expand Down

0 comments on commit 885d1fd

Please sign in to comment.