Skip to content

Commit a1ffb2f

Browse files
committed
Add check for scriptSig in ConsensusVerifyScript
scriptSig is redundant there, but is retained for compatibilty with VerifyScript(). But it cannot be ignored, and therefore it is now checked to be the same as the scriptSig in the input.
1 parent 87b967d commit a1ffb2f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

bitcointx/core/bitcoinconsensus.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ def ConsensusVerifyScript(
194194
The arguments are compatible with `VerifyScript()` from
195195
`bitcointx.core.scripteval`
196196
197-
scriptSig - Signature
197+
scriptSig - Signature. Must be present in the transaction input at
198+
inIdx. Redundant, but is there for compatibility of
199+
arguments with VerifyScript() that allow to supply
200+
different scriptSig than the one in the input
198201
scriptPubKey - PubKey
199202
txTo - Spending transaction
200203
inIdx - Index of the transaction input containing scriptSig
@@ -223,6 +226,16 @@ def ConsensusVerifyScript(
223226
if not MoneyRange(amount):
224227
raise ValueError('amount out of MoneyRange')
225228

229+
ensure_isinstance(scriptSig, CScript, 'scriptSig')
230+
if not type(scriptSig) == type(scriptPubKey):
231+
raise TypeError(
232+
"scriptSig and scriptPubKey must be of the same script class")
233+
234+
if txTo.vin[inIdx].scriptSig != scriptSig:
235+
raise ValueError(
236+
f'supplied scriptSig is not present in input {inIdx} of '
237+
f'the supplied transaction')
238+
226239
if witness is not None:
227240
ensure_isinstance(witness, CScriptWitness, 'witness')
228241
if not txTo.wit.vtxinwit[inIdx].scriptWitness.is_null() \

0 commit comments

Comments
 (0)