Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions blockchain_parser/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def operations(self):
"""
if self._operations is None:
# Some coinbase scripts are garbage, they could not be valid
self._operations = list(self.script)

try:
self._operations = list(self.script)
except CScriptTruncatedPushDataError:
self._operations = "[INVALID]"
except CScriptInvalidError:
self._operations = "[INVALID]"
return self._operations

@property
Expand Down Expand Up @@ -132,4 +136,24 @@ def is_multisig(self):
def is_unknown(self):
return not self.is_pubkeyhash() and not self.is_pubkey() \
and not self.is_p2sh() and not self.is_multisig() \
and not self.is_return()
and not self.is_return() and not self.is_p2wpkh()\
and not self.is_p2wsh()

# add by hzx
def is_p2wpkh(self):
if len(self.operations) == 2:
a = bytes(self.operations[0])
b = bytes(self.operations[1])
return len(a)==0 and len(b) == 20

return False

# add by hzx
def is_p2wsh(self):
if len(self.operations) == 2:
a = bytes(self.operations[0])
b = bytes(self.operations[1])
return len(a)==0 and len(b) == 32

return False