From 9bf46b5cfe6a36f16c7c15c1e0aef9c4190fd629 Mon Sep 17 00:00:00 2001 From: notmike Date: Fri, 26 Jun 2026 19:49:28 -0600 Subject: [PATCH] bip360: make consistent use of h2b --- bip-0360/ref-impl/python/p2mr.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bip-0360/ref-impl/python/p2mr.py b/bip-0360/ref-impl/python/p2mr.py index 515ea0b6..3de83412 100644 --- a/bip-0360/ref-impl/python/p2mr.py +++ b/bip-0360/ref-impl/python/p2mr.py @@ -79,9 +79,7 @@ def tapleaf_hash(script: str, tapleaf_ver: str = "c0") -> str: """Hash function for tree leaves""" if not script: raise ValueError("tapleaf_hash: script is required") - leaf = b"".join( - (bytes.fromhex(tapleaf_ver), serialize_varbytes(bytes.fromhex(script))) - ) + leaf = h2b(tapleaf_ver) + serialize_varbytes(h2b(script)) return tagged_hash("TapLeaf", leaf).hex() @@ -147,7 +145,7 @@ def compute_control_block(path: int, tree: ScriptTree) -> bytes: assert len(tree) == 2 sibling = tree[(path & 1) ^ 1] tree = tree[(path & 1)] - control_block = bytes.fromhex(compute_merkle_root(sibling)) + control_block + control_block = h2b(compute_merkle_root(sibling)) + control_block path >>= 1 assert isinstance(tree, dict)