MCPcopy Index your code
hub / github.com/jimmysong/programmingbitcoin / is_p2pkh_script_pubkey

Method is_p2pkh_script_pubkey

code-ch13/script.py:246–255  ·  view source on GitHub ↗

Returns whether this follows the OP_DUP OP_HASH160 <20 byte hash> OP_EQUALVERIFY OP_CHECKSIG pattern.

(self)

Source from the content-addressed store, hash-verified

244 return True
245
246 def is_p2pkh_script_pubkey(self):
247 ''&#x27;Returns whether this follows the
248 OP_DUP OP_HASH160 <20 byte hash> OP_EQUALVERIFY OP_CHECKSIG pattern.''&#x27;
249 # there should be exactly 5 cmds
250 # OP_DUP (0x76), OP_HASH160 (0xa9), 20-byte hash, OP_EQUALVERIFY (0x88),
251 # OP_CHECKSIG (0xac)
252 return len(self.cmds) == 5 and self.cmds[0] == 0x76 \
253 and self.cmds[1] == 0xa9 \
254 and type(self.cmds[2]) == bytes and len(self.cmds[2]) == 20 \
255 and self.cmds[3] == 0x88 and self.cmds[4] == 0xac
256
257 def is_p2sh_script_pubkey(self):
258 ''&#x27;Returns whether this follows the

Callers 1

addressMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected