Skip to content

Commit

Permalink
asset: change all-zero hash to empty leaf
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Dec 19, 2024
1 parent c1badfa commit ed0f363
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,8 @@ func NewGKRCustomSubtreeRootRecord(root *chainhash.Hash) tlv.Record {
// 1. It cannot be misinterpreted as a genesis asset ID leaf.
// 2. It optionally includes user-defined script spending leaves.
// - <custom_root_hash> is the root hash of the custom tapscript subtree.
// If not specified, it defaults to a 32-byte zero-filled array.
// If not specified, it defaults to the same [OP_RETURN] that's on the left
// side.
// - [OP_RETURN] is a non-spendable script leaf containing the script
// `OP_RETURN`. Its presence ensures that [tweaked_custom_branch] remains
// a branch node and cannot be a valid genesis asset ID leaf.
Expand Down Expand Up @@ -1108,7 +1109,7 @@ func NewGroupKeyTapscriptRoot(genesisAssetID ID,
// hash of the custom tapscript subtree.
//
// If a custom tapscript subtree root hash is provided, we use it.
// Otherwise, we default to an empty hash (a zero-filled byte array).
// Otherwise, we default to an empty non-spendable leaf hash as well.
emptyNonSpendLeaf, err := NewNonSpendableScriptLeaf(nil)
if err != nil {
return GroupKeyRevealTapscript{}, err
Expand All @@ -1117,7 +1118,7 @@ func NewGroupKeyTapscriptRoot(genesisAssetID ID,
// Compute the tweaked custom branch hash.
tweakedCustomBranchHash := TapBranchHash(
emptyNonSpendLeaf.TapHash(),
customRoot.UnwrapOr(chainhash.Hash{}),
customRoot.UnwrapOr(emptyNonSpendLeaf.TapHash()),
)

// Next, we'll combine the tweaked custom branch hash with the genesis
Expand Down

0 comments on commit ed0f363

Please sign in to comment.