Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
PEP 8 fixes
  • Loading branch information
nerolation authored Mar 5, 2022
commit 51251ec28f5717230ad43d78dc04d693404d17fe
3 changes: 2 additions & 1 deletion blockchain_parser/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def address(self):
"""
if self._address is None:
if self.type == "bech32m":
self._address = from_taproot(b2a_hex(self.hash).decode("ascii"))
tweaked_pubkey = b2a_hex(self.hash).decode("ascii")
self._address = from_taproot(tweaked_pubkey)
elif self.type != "bech32":
version = b'\x00' if self.type == "normal" else b'\x05'
checksum = double_sha256(version + self.hash)
Expand Down
2 changes: 1 addition & 1 deletion blockchain_parser/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def type(self):

if self.is_p2wsh():
return "p2wsh"

if self.is_p2tr():
return "p2tr"

Expand Down
6 changes: 3 additions & 3 deletions blockchain_parser/utils_taproot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# modified, propagated, or distributed except according to the terms contained
# in the LICENSE file.
#
# Encoding/Decoding written by Pieter Wuille (2017)
# Encoding/Decoding written by Pieter Wuille (2017)
# and adapted by Anton Wahrstätter (2022)
# https://github.com/Bytom/python-bytomlib/blob/master/pybtmsdk/segwit_addr.py

Expand Down Expand Up @@ -121,7 +121,7 @@ def decode(hrp, addr):
return (None, None)
if data[0] == 0 and len(decoded) != 20 and len(decoded) != 32:
return (None, None)
if data[0] == 0 and spec != Encoding.BECH32 or data[0] != 0 and spec != Encoding.BECH32M:
if data[0] != 0 and spec != Encoding.BECH32M:
return (None, None)
return (data[0], decoded)

Expand All @@ -137,5 +137,5 @@ def encode(witprog):


def from_taproot(tweaked_pubkey):
tweaked_pubkey = [int(tweaked_pubkey[i:i+2], 16) for i in range(0, len(tweaked_pubkey), 2)]
tweaked_pubkey = [int(tweaked_pubkey[i:i+2], 16) for i in range(len(tweaked_pubkey), 2)]
return encode(tweaked_pubkey)