diff --git a/bittensor/_cli/commands/stake.py b/bittensor/_cli/commands/stake.py index ac9b628ada..96274e4bd3 100644 --- a/bittensor/_cli/commands/stake.py +++ b/bittensor/_cli/commands/stake.py @@ -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. diff --git a/bittensor/_cli/commands/unstake.py b/bittensor/_cli/commands/unstake.py index 0d864563aa..05688434e7 100644 --- a/bittensor/_cli/commands/unstake.py +++ b/bittensor/_cli/commands/unstake.py @@ -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: