mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-18 21:35:24 +01:00
input: add PayToTaprootScript helper func
In this commit, we add a helper function to take a taproot output key and turn it into a v1 witness program.
This commit is contained in:
parent
9851a6147b
commit
92868cfaa5
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
@ -135,3 +136,15 @@ func TapscriptFullKeyOnly(taprootKey *btcec.PublicKey) *waddrmgr.Tapscript {
|
||||
FullOutputKey: taprootKey,
|
||||
}
|
||||
}
|
||||
|
||||
// PayToTaprootScript creates a new script to pay to a version 1 (taproot)
|
||||
// witness program. The passed public key will be serialized as an x-only key
|
||||
// to create the witness program.
|
||||
func PayToTaprootScript(taprootKey *btcec.PublicKey) ([]byte, error) {
|
||||
builder := txscript.NewScriptBuilder()
|
||||
|
||||
builder.AddOp(txscript.OP_1)
|
||||
builder.AddData(schnorr.SerializePubKey(taprootKey))
|
||||
|
||||
return builder.Script()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user