mirror of
https://github.com/bitcoin/bips.git
synced 2026-07-27 18:13:38 +00:00
bip360: make consistent use of h2b
This commit is contained in:
@@ -79,9 +79,7 @@ def tapleaf_hash(script: str, tapleaf_ver: str = "c0") -> str:
|
|||||||
"""Hash function for tree leaves"""
|
"""Hash function for tree leaves"""
|
||||||
if not script:
|
if not script:
|
||||||
raise ValueError("tapleaf_hash: script is required")
|
raise ValueError("tapleaf_hash: script is required")
|
||||||
leaf = b"".join(
|
leaf = h2b(tapleaf_ver) + serialize_varbytes(h2b(script))
|
||||||
(bytes.fromhex(tapleaf_ver), serialize_varbytes(bytes.fromhex(script)))
|
|
||||||
)
|
|
||||||
return tagged_hash("TapLeaf", leaf).hex()
|
return tagged_hash("TapLeaf", leaf).hex()
|
||||||
|
|
||||||
|
|
||||||
@@ -147,7 +145,7 @@ def compute_control_block(path: int, tree: ScriptTree) -> bytes:
|
|||||||
assert len(tree) == 2
|
assert len(tree) == 2
|
||||||
sibling = tree[(path & 1) ^ 1]
|
sibling = tree[(path & 1) ^ 1]
|
||||||
tree = tree[(path & 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
|
path >>= 1
|
||||||
|
|
||||||
assert isinstance(tree, dict)
|
assert isinstance(tree, dict)
|
||||||
|
|||||||
Reference in New Issue
Block a user