Skip to content

Commit 2f8579f

Browse files
committed
review changes
1 parent a457f0a commit 2f8579f

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

hathor/transaction/scripts/execute.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,15 @@ def evaluate_final_stack(stack: Stack, log: list[str]) -> None:
107107
raise FinalStackInvalid('\n'.join(log))
108108

109109

110-
def script_eval(tx: Transaction, spent_tx: BaseTransaction, *, input_index: int) -> 'ScriptContext':
111-
"""Evaluates the output script and input data according to
112-
a very limited subset of Bitcoin's scripting language.
113-
114-
:param tx: the transaction being validated, the 'owner' of the input data
115-
:type tx: :py:class:`hathor.transaction.Transaction`
116-
117-
:param txin: transaction input being evaluated
118-
:type txin: :py:class:`hathor.transaction.TxInput`
119-
120-
:param spent_tx: the transaction referenced by the input
121-
:type spent_tx: :py:class:`hathor.transaction.BaseTransaction`
110+
def script_eval(*, tx: Transaction, spent_tx: BaseTransaction, input_index: int) -> 'ScriptContext':
111+
"""
112+
Evaluates the output script and input data according to a very limited subset of Bitcoin's scripting language.
113+
Raises ScriptError if script verification fails
122114
123-
:raises ScriptError: if script verification fails
115+
Args:
116+
tx: the transaction being validated, the 'owner' of the input data
117+
spent_tx: the transaction referenced by the input
118+
input_index: index of the transaction input being evaluated
124119
"""
125120
extras = ScriptExtras(tx=tx, input_index=input_index, spent_tx=spent_tx)
126121
input_data = extras.txin.data

hathor/verification/transaction_verifier.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ def verify_script(
150150
) -> ScriptContext:
151151
"""
152152
:type tx: Transaction
153-
:type input_tx: TxInput
154153
:type spent_tx: Transaction
154+
:type input_index: int
155155
"""
156156
from hathor.transaction.scripts import script_eval
157157
try:
158-
return script_eval(tx, spent_tx, input_index=input_index)
158+
return script_eval(tx=tx, spent_tx=spent_tx, input_index=input_index)
159159
except ScriptError as e:
160160
raise InvalidInputData(e) from e
161161

tests/tx/test_multisig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_spend_multisig(self):
134134
expected_dict = {'type': 'MultiSig', 'address': self.multisig_address_b58, 'timelock': None}
135135
self.assertEqual(cls_script.to_human_readable(), expected_dict)
136136

137-
script_eval(tx, tx1, input_index=0)
137+
script_eval(tx=tx, spent_tx=tx1, input_index=0)
138138

139139
# Script error
140140
with self.assertRaises(ScriptError):

tests/tx/test_nano_contracts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ def test_match_values(self):
3838
txin = TxInput(b'aa', 0, input_data)
3939
spent_tx = Transaction(hash=b'aa', outputs=[TxOutput(20, script)])
4040
tx = Transaction(inputs=[txin], outputs=[TxOutput(20, P2PKH.create_output_script(address))])
41-
script_eval(tx, spent_tx, input_index=0)
41+
script_eval(tx=tx, spent_tx=spent_tx, input_index=0)

0 commit comments

Comments
 (0)