MCPcopy
hub / github.com/jimmysong/programmingbitcoin / verify_input

Function verify_input

code-ch08/answers.py:192–203  ·  view source on GitHub ↗
(self, input_index)

Source from the content-addressed store, hash-verified

190
191
192def verify_input(self, input_index):
193 tx_in = self.tx_ins[input_index]
194 script_pubkey = tx_in.script_pubkey(testnet=self.testnet)
195 if script_pubkey.is_p2sh_script_pubkey():
196 cmd = tx_in.script_sig.cmds[-1]
197 raw_redeem = encode_varint(len(cmd)) + cmd
198 redeem_script = Script.parse(BytesIO(raw_redeem))
199 else:
200 redeem_script = None
201 z = self.sig_hash(input_index, redeem_script)
202 combined = tx_in.script_sig + script_pubkey
203 return combined.evaluate(z)
204# end::answer5[]
205
206

Callers

nothing calls this directly

Calls 6

encode_varintFunction · 0.90
script_pubkeyMethod · 0.45
is_p2sh_script_pubkeyMethod · 0.45
parseMethod · 0.45
sig_hashMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected