Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3321,9 +3321,9 @@ def stake_remove(
def stake_move(
self,
network: Optional[list[str]] = Options.network,
wallet_name=Options.wallet_name,
wallet_path=Options.wallet_path,
wallet_hotkey=Options.wallet_hotkey,
wallet_name: Optional[str] = Options.wallet_name,
wallet_path: Optional[str] = Options.wallet_path,
wallet_hotkey: Optional[str] = Options.wallet_hotkey,
origin_netuid: Optional[int] = typer.Option(
None, "--origin-netuid", help="Origin netuid"
),
Expand Down Expand Up @@ -3533,14 +3533,45 @@ def stake_transfer(
)
self.verbosity_handler(quiet, verbose)

if not wallet_name:
wallet_name = Prompt.ask(
"Enter the [blue]origin wallet name[/blue]",
default=self.config.get("wallet_name") or defaults.wallet.name,
)
wallet = self.wallet_ask(
wallet_name,
wallet_path,
wallet_hotkey,
ask_for=[WO.NAME, WO.PATH, WO.HOTKEY],
validate=WV.WALLET_AND_HOTKEY,
wallet_name, wallet_path, wallet_hotkey, ask_for=[WO.NAME]
)

if not wallet_hotkey:
origin_hotkey = Prompt.ask(
"Enter the [blue]origin hotkey[/blue] name or "
"[blue]ss58 address[/blue] where the stake will be moved from",
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
)
if is_valid_ss58_address(origin_hotkey):
origin_hotkey = origin_hotkey
else:
wallet = self.wallet_ask(
wallet_name,
wallet_path,
origin_hotkey,
ask_for=[WO.NAME, WO.PATH, WO.HOTKEY],
validate=WV.WALLET_AND_HOTKEY,
)
origin_hotkey = wallet.hotkey.ss58_address
else:
if is_valid_ss58_address(wallet_hotkey):
origin_hotkey = wallet_hotkey
else:
wallet = self.wallet_ask(
wallet_name,
wallet_path,
wallet_hotkey,
ask_for=[],
validate=WV.WALLET_AND_HOTKEY,
)
origin_hotkey = wallet.hotkey.ss58_address

if not dest_ss58:
dest_ss58 = Prompt.ask(
"Enter the [blue]destination wallet name[/blue] or [blue]coldkey SS58 address[/blue]"
Expand Down Expand Up @@ -3578,6 +3609,7 @@ def stake_transfer(
move_stake.transfer_stake(
wallet=wallet,
subtensor=self.initialize_chain(network),
origin_hotkey=origin_hotkey,
origin_netuid=origin_netuid,
dest_netuid=dest_netuid,
dest_coldkey_ss58=dest_ss58,
Expand Down
17 changes: 9 additions & 8 deletions bittensor_cli/src/commands/stake/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ async def transfer_stake(
wallet: Wallet,
subtensor: "SubtensorInterface",
amount: float,
origin_hotkey: str,
origin_netuid: int,
dest_netuid: int,
dest_coldkey_ss58: str,
Expand All @@ -707,6 +708,7 @@ async def transfer_stake(
wallet (Wallet): Bittensor wallet object.
subtensor (SubtensorInterface): Subtensor interface instance.
amount (float): Amount to transfer.
origin_hotkey (str): The hotkey SS58 to transfer the stake from.
origin_netuid (int): The netuid to transfer stake from.
dest_netuid (int): The netuid to transfer stake to.
dest_coldkey_ss58 (str): The destination coldkey to transfer stake to.
Expand Down Expand Up @@ -737,16 +739,15 @@ async def transfer_stake(
return False

# Get current stake balances
hotkey_ss58 = wallet.hotkey.ss58_address
with console.status(f"Retrieving stake data from {subtensor.network}..."):
current_stake = await subtensor.get_stake(
coldkey_ss58=wallet.coldkeypub.ss58_address,
hotkey_ss58=hotkey_ss58,
hotkey_ss58=origin_hotkey,
netuid=origin_netuid,
)
current_dest_stake = await subtensor.get_stake(
coldkey_ss58=dest_coldkey_ss58,
hotkey_ss58=hotkey_ss58,
hotkey_ss58=origin_hotkey,
netuid=dest_netuid,
)
amount_to_transfer = Balance.from_tao(amount).set_unit(origin_netuid)
Expand All @@ -766,8 +767,8 @@ async def transfer_stake(
subtensor=subtensor,
origin_netuid=origin_netuid,
destination_netuid=dest_netuid,
origin_hotkey=hotkey_ss58,
destination_hotkey=hotkey_ss58,
origin_hotkey=origin_hotkey,
destination_hotkey=origin_hotkey,
amount_to_move=amount_to_transfer,
)

Expand All @@ -784,7 +785,7 @@ async def transfer_stake(
call_function="transfer_stake",
call_params={
"destination_coldkey": dest_coldkey_ss58,
"hotkey": hotkey_ss58,
"hotkey": origin_hotkey,
"origin_netuid": origin_netuid,
"destination_netuid": dest_netuid,
"alpha_amount": amount_to_transfer.rao,
Expand Down Expand Up @@ -815,12 +816,12 @@ async def transfer_stake(
new_stake, new_dest_stake = await asyncio.gather(
subtensor.get_stake(
coldkey_ss58=wallet.coldkeypub.ss58_address,
hotkey_ss58=hotkey_ss58,
hotkey_ss58=origin_hotkey,
netuid=origin_netuid,
),
subtensor.get_stake(
coldkey_ss58=dest_coldkey_ss58,
hotkey_ss58=hotkey_ss58,
hotkey_ss58=origin_hotkey,
netuid=dest_netuid,
),
)
Expand Down
Loading