From 1eed5fc1e9518bdd2f89e4cdbd3499ecd04273dd Mon Sep 17 00:00:00 2001 From: ffranr Date: Thu, 12 Dec 2024 16:30:44 +0000 Subject: [PATCH] asset: copy TapBranchHash from `commitment` package --- asset/asset.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/asset/asset.go b/asset/asset.go index 0cb16cde8..7424552df 100644 --- a/asset/asset.go +++ b/asset/asset.go @@ -729,6 +729,15 @@ func CheckTapLeafSanity(leaf *txscript.TapLeaf) error { return nil } +// TapBranchHash takes the tap hashes of the left and right nodes and hashes +// them into a branch. +func TapBranchHash(l, r chainhash.Hash) chainhash.Hash { + if bytes.Compare(l[:], r[:]) > 0 { + l, r = r, l + } + return *chainhash.TaggedHash(chainhash.TagTapBranch, l[:], r[:]) +} + // TapLeafNodes represents an ordered list of TapLeaf objects, that have been // checked for their script version and size. These leaves can be stored to and // loaded from the DB.