1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ from __future__ import annotations
16+
1517import struct
1618from dataclasses import dataclass
17- from typing import NamedTuple , Optional , Union
19+ from typing import TYPE_CHECKING , NamedTuple , Optional , Union
1820
1921from hathor .transaction import BaseTransaction , Transaction , TxInput
2022from hathor .transaction .exceptions import DataIndexError , FinalStackInvalid , InvalidScriptError , OutOfData
2123
24+ if TYPE_CHECKING :
25+ from hathor .transaction .scripts .opcode import OpcodesVersion
26+
2227
2328@dataclass (slots = True , frozen = True , kw_only = True )
2429class ScriptExtras :
2530 tx : Transaction
31+ version : OpcodesVersion
2632
2733
2834@dataclass (slots = True , frozen = True , kw_only = True )
@@ -72,7 +78,7 @@ def execute_eval(data: bytes, log: list[str], extras: ScriptExtras) -> None:
7278 continue
7379
7480 # this is an opcode manipulating the stack
75- execute_op_code (Opcode (opcode ), context )
81+ execute_op_code (Opcode (opcode ), context , extras . version )
7682
7783 evaluate_final_stack (stack , log )
7884
@@ -94,7 +100,7 @@ def evaluate_final_stack(stack: Stack, log: list[str]) -> None:
94100 raise FinalStackInvalid ('\n ' .join (log ))
95101
96102
97- def script_eval (tx : Transaction , txin : TxInput , spent_tx : BaseTransaction ) -> None :
103+ def script_eval (tx : Transaction , txin : TxInput , spent_tx : BaseTransaction , version : OpcodesVersion ) -> None :
98104 """Evaluates the output script and input data according to
99105 a very limited subset of Bitcoin's scripting language.
100106
@@ -112,7 +118,7 @@ def script_eval(tx: Transaction, txin: TxInput, spent_tx: BaseTransaction) -> No
112118 raw_script_eval (
113119 input_data = txin .data ,
114120 output_script = spent_tx .outputs [txin .index ].script ,
115- extras = UtxoScriptExtras (tx = tx , txin = txin , spent_tx = spent_tx ),
121+ extras = UtxoScriptExtras (tx = tx , txin = txin , spent_tx = spent_tx , version = version ),
116122 )
117123
118124
0 commit comments