Skip to content

Commit

Permalink
notify user that hotkey is not registered (#1030)
Browse files Browse the repository at this point in the history
* notify user that hotkey is not registered

* Revert "notify user that hotkey is not registered"

This reverts commit 9e103aa.

* notify if not registered
  • Loading branch information
camfairchild authored Jan 23, 2023
1 parent b35b8f8 commit 878b5bb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bittensor/_cli/commands/stake.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ def run( cli ):
final_amounts: List[Union[float, Balance]] = []
for hotkey in tqdm(hotkeys_to_stake_to):
hotkey: Tuple[Optional[str], str] # (hotkey_name (or None), hotkey_ss58)
if not subtensor.is_hotkey_registered_any( hotkey_ss58 = hotkey ):
# Hotkey is not registered.
if (len(hotkeys_to_stake_to) == 1):
# Only one hotkey, error
bittensor.__console__.print(f"[red]Hotkey [bold]{hotkey}[/bold] is not registered. Aborting.[/red]")
return None
else:
# Otherwise, print warning and skip
bittensor.__console__.print(f"[yellow]Hotkey [bold]{hotkey}[/bold] is not registered. Skipping.[/yellow]")
continue


stake_amount_tao: float = config.get('amount')
if config.get('max_stake'):
# Get the current stake of the hotkey from this coldkey.
Expand Down
11 changes: 11 additions & 0 deletions bittensor/_cli/commands/unstake.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ def run( cli ):
final_amounts: List[Union[float, Balance]] = []
for hotkey in tqdm(hotkeys_to_unstake_from):
hotkey: Tuple[Optional[str], str] # (hotkey_name (or None), hotkey_ss58)
if not subtensor.is_hotkey_registered_any( hotkey_ss58 = hotkey ):
# Hotkey is not registered.
if (len(hotkeys_to_unstake_from) == 1):
# Only one hotkey, error
bittensor.__console__.print(f"[red]Hotkey [bold]{hotkey}[/bold] is not registered. Aborting.[/red]")
return None
else:
# Otherwise, print warning and skip
bittensor.__console__.print(f"[yellow]Hotkey [bold]{hotkey}[/bold] is not registered. Skipping.[/yellow]")
continue

unstake_amount_tao: float = cli.config.get('amount') # The amount specified to unstake.
hotkey_stake: Balance = subtensor.get_stake_for_coldkey_and_hotkey( hotkey_ss58 = hotkey[1], coldkey_ss58 = wallet.coldkey.ss58_address )
if unstake_amount_tao == None:
Expand Down

0 comments on commit 878b5bb

Please sign in to comment.