Skip to content

Commit bbc6f53

Browse files
committed
Allow using a different signing key than hotkey
1 parent 8e7bdda commit bbc6f53

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

bittensor/core/extrinsics/asyncex/staking.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ async def add_stake_extrinsic(
121121
wait_for_inclusion,
122122
wait_for_finalization,
123123
nonce_key="coldkeypub",
124+
signing_key="coldkey",
124125
)
125126
if staking_response is True: # If we successfully staked.
126127
# We only wait here if we expect finalization.
@@ -310,6 +311,7 @@ async def add_stake_multiple_extrinsic(
310311
wait_for_inclusion,
311312
wait_for_finalization,
312313
nonce_key="coldkeypub",
314+
signing_key="coldkey",
313315
)
314316

315317
if staking_response is True: # If we successfully staked.

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ async def unstake_extrinsic(
107107
wait_for_inclusion,
108108
wait_for_finalization,
109109
nonce_key="coldkeypub",
110+
signing_key="coldkey",
110111
)
111112

112113
if staking_response is True: # If we successfully unstaked.
@@ -277,6 +278,7 @@ async def unstake_multiple_extrinsic(
277278
wait_for_inclusion,
278279
wait_for_finalization,
279280
nonce_key="coldkeypub",
281+
signing_key="coldkey",
280282
)
281283

282284
if staking_response is True: # If we successfully unstaked.

bittensor/core/extrinsics/staking.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def add_stake_extrinsic(
113113
wait_for_inclusion,
114114
wait_for_finalization,
115115
nonce_key="coldkeypub",
116+
signing_key="coldkey",
116117
)
117118
if staking_response is True: # If we successfully staked.
118119
# We only wait here if we expect finalization.
@@ -291,6 +292,7 @@ def add_stake_multiple_extrinsic(
291292
wait_for_inclusion,
292293
wait_for_finalization,
293294
nonce_key="coldkeypub",
295+
signing_key="coldkey",
294296
)
295297

296298
if staking_response is True: # If we successfully staked.

bittensor/core/extrinsics/unstaking.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def unstake_extrinsic(
100100
wait_for_inclusion,
101101
wait_for_finalization,
102102
nonce_key="coldkeypub",
103+
signing_key="coldkey",
103104
)
104105

105106
if staking_response is True: # If we successfully unstaked.
@@ -260,6 +261,7 @@ def unstake_multiple_extrinsic(
260261
wait_for_inclusion,
261262
wait_for_finalization,
262263
nonce_key="coldkeypub",
264+
signing_key="coldkey",
263265
)
264266

265267
if staking_response is True: # If we successfully unstaked.

bittensor/core/extrinsics/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ async def async_sign_and_send_with_nonce(
2828
wait_for_finalization: bool,
2929
period: Optional[int] = None,
3030
nonce_key: str = "hotkey",
31+
signing_key: str = "hotkey",
3132
):
3233
"""
3334
Signs an extrinsic call with the wallet keypair (default hotkey), adding an optional era for period
3435
"""
3536
keypair = getattr(wallet, nonce_key)
3637
next_nonce = await subtensor.substrate.get_account_next_index(keypair.ss58_address)
37-
38-
extrinsic_data = {"call": call, "keypair": wallet.hotkey, "nonce": next_nonce}
38+
signing_keypair = getattr(wallet, signing_key)
39+
extrinsic_data = {"call": call, "keypair": signing_keypair, "nonce": next_nonce}
3940
if period is not None:
4041
extrinsic_data["era"] = {"period": period}
4142

@@ -66,12 +67,14 @@ def sign_and_send_with_nonce(
6667
wait_for_inclusion,
6768
wait_for_finalization,
6869
nonce_key: str = "hotkey",
70+
signing_key: str = "hotkey",
6971
):
7072
keypair = getattr(wallet, nonce_key)
7173
next_nonce = subtensor.substrate.get_account_next_index(keypair.ss58_address)
74+
signing_keypair = getattr(wallet, signing_key)
7275
extrinsic = subtensor.substrate.create_signed_extrinsic(
7376
call=call,
74-
keypair=wallet.hotkey,
77+
keypair=signing_keypair,
7578
nonce=next_nonce,
7679
)
7780
response = subtensor.substrate.submit_extrinsic(

0 commit comments

Comments
 (0)