File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 37
37
PRICE_ACCOUNT_SIZE ,
38
38
PRODUCT_ACCOUNT_SIZE ,
39
39
compute_transaction_size ,
40
+ get_actual_signers ,
40
41
recent_blockhash ,
41
42
sort_mapping_account_keys ,
42
43
)
@@ -166,7 +167,7 @@ async def send_transaction(
166
167
transaction = Transaction (recent_blockhash = blockhash )
167
168
168
169
transaction .add (instructions [0 ])
169
- transaction .sign (* signers )
170
+ transaction .sign (* get_actual_signers ( signers , transaction ) )
170
171
171
172
ix_index = 1
172
173
@@ -207,7 +208,7 @@ async def send_transaction(
207
208
and instructions [ix_index :]
208
209
):
209
210
transaction .add (instructions [ix_index ])
210
- transaction .sign (* signers )
211
+ transaction .sign (* get_actual_signers ( signers , transaction ) )
211
212
ix_index += 1
212
213
213
214
if not dump_instructions :
Original file line number Diff line number Diff line change 1
1
from typing import Dict , List
2
2
3
3
from solana .blockhash import Blockhash
4
+ from solana .keypair import Keypair
4
5
from solana .publickey import PublicKey
5
6
from solana .rpc .async_api import AsyncClient
6
7
from solana .rpc .commitment import Commitment
@@ -107,3 +108,25 @@ def apply_overrides(
107
108
else :
108
109
overridden_permissions [key ] = value
109
110
return overridden_permissions
111
+
112
+
113
+ def get_actual_signers (
114
+ signers : List [Keypair ], transaction : Transaction
115
+ ) -> List [Keypair ]:
116
+ """
117
+ Given a list of keypairs and a transaction, returns the keypairs that actually need to sign the transaction,
118
+ i.e. those whose pubkey appears in at least one of the instructions as a signer.
119
+ """
120
+ actual_signers = []
121
+ for signer in signers :
122
+ instruction_has_signer = [
123
+ any (
124
+ signer .public_key == account .pubkey and account .is_signer
125
+ for account in instruction .keys
126
+ )
127
+ for instruction in transaction .instructions
128
+ ]
129
+ if any (instruction_has_signer ):
130
+ actual_signers .append (signer )
131
+
132
+ return actual_signers
You can’t perform that action at this time.
0 commit comments