mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-26 04:42:35 +02:00
input: add tapscript root hash helper function
This commit is contained in:
@@ -105,3 +105,24 @@ func TapscriptPartialReveal(internalKey *btcec.PublicKey,
|
|||||||
RevealedScript: revealedLeaf.Script,
|
RevealedScript: revealedLeaf.Script,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TapscriptRootHashOnly creates a waddrmgr.Tapscript for the given internal key
|
||||||
|
// and root hash.
|
||||||
|
func TapscriptRootHashOnly(internalKey *btcec.PublicKey,
|
||||||
|
rootHash []byte) *waddrmgr.Tapscript {
|
||||||
|
|
||||||
|
controlBlock := &txscript.ControlBlock{
|
||||||
|
InternalKey: internalKey,
|
||||||
|
}
|
||||||
|
|
||||||
|
tapKey := txscript.ComputeTaprootOutputKey(internalKey, rootHash)
|
||||||
|
if tapKey.SerializeCompressed()[0] == PubKeyFormatCompressedOdd {
|
||||||
|
controlBlock.OutputKeyYIsOdd = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return &waddrmgr.Tapscript{
|
||||||
|
Type: waddrmgr.TaprootKeySpendRootHash,
|
||||||
|
ControlBlock: controlBlock,
|
||||||
|
RootHash: rootHash,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user