Skip to content

Commit 72910f9

Browse files
authored
Merge pull request #325 from opentensor/feat/unstaking-all-hotkeys
Adds unstaking from all hotkeys + tests
2 parents 55215ff + c2d7e7c commit 72910f9

File tree

3 files changed

+521
-103
lines changed

3 files changed

+521
-103
lines changed

bittensor_cli/cli.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,11 +3221,22 @@ def stake_remove(
32213221
else:
32223222
print_error("Invalid hotkey ss58 address.")
32233223
raise typer.Exit()
3224-
else:
3225-
hotkey_or_ss58 = Prompt.ask(
3226-
"Enter the [blue]hotkey[/blue] name or [blue]ss58 address[/blue] to unstake all from",
3227-
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
3224+
elif all_hotkeys:
3225+
wallet = self.wallet_ask(
3226+
wallet_name,
3227+
wallet_path,
3228+
wallet_hotkey,
3229+
ask_for=[WO.NAME, WO.PATH],
32283230
)
3231+
else:
3232+
if not hotkey_ss58_address and not wallet_hotkey:
3233+
hotkey_or_ss58 = Prompt.ask(
3234+
"Enter the [blue]hotkey[/blue] name or [blue]ss58 address[/blue] to unstake all from [dim](or enter 'all' to unstake from all hotkeys)[/dim]",
3235+
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
3236+
)
3237+
else:
3238+
hotkey_or_ss58 = hotkey_ss58_address or wallet_hotkey
3239+
32293240
if is_valid_ss58_address(hotkey_or_ss58):
32303241
hotkey_ss58_address = hotkey_or_ss58
32313242
wallet = self.wallet_ask(
@@ -3234,6 +3245,14 @@ def stake_remove(
32343245
wallet_hotkey,
32353246
ask_for=[WO.NAME, WO.PATH],
32363247
)
3248+
elif hotkey_or_ss58 == "all":
3249+
all_hotkeys = True
3250+
wallet = self.wallet_ask(
3251+
wallet_name,
3252+
wallet_path,
3253+
wallet_hotkey,
3254+
ask_for=[WO.NAME, WO.PATH],
3255+
)
32373256
else:
32383257
wallet_hotkey = hotkey_or_ss58
32393258
wallet = self.wallet_ask(
@@ -3249,6 +3268,9 @@ def stake_remove(
32493268
subtensor=self.initialize_chain(network),
32503269
hotkey_ss58_address=hotkey_ss58_address,
32513270
unstake_all_alpha=unstake_all_alpha,
3271+
all_hotkeys=all_hotkeys,
3272+
include_hotkeys=include_hotkeys,
3273+
exclude_hotkeys=exclude_hotkeys,
32523274
prompt=prompt,
32533275
)
32543276
)

0 commit comments

Comments
 (0)