multi: add simple taproot channel type to order

This commit is contained in:
Oliver Gugger 2023-09-22 17:13:33 +02:00
parent d000a6b7b1
commit 52cdb3d5f9
No known key found for this signature in database
GPG key ID: 8E4256593F177720
11 changed files with 160 additions and 27 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/lightninglabs/lndclient"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnrpc"
)
// Version represents the type of Pool account script that is used for either
@ -824,3 +825,44 @@ func IncludesPreviousOutPoint(tx *wire.MsgTx, output wire.OutPoint) bool {
}
return false
}
// FundingOutput returns the channel funding output for the given commitment
// type, funding keys and channel size.
func FundingOutput(commitmentType lnrpc.CommitmentType, ourKey,
theirKey []byte, chanSize int64) (*wire.TxOut, error) {
switch commitmentType {
case lnrpc.CommitmentType_SIMPLE_TAPROOT:
ourPubKey, err := btcec.ParsePubKey(ourKey)
if err != nil {
return nil, err
}
theirPubKey, err := btcec.ParsePubKey(theirKey)
if err != nil {
return nil, err
}
log.Debugf("Creating P2TR funding script for local key %x and "+
"remote key %x", ourKey, theirKey)
_, fundingOutput, err := input.GenTaprootFundingScript(
ourPubKey, theirPubKey, chanSize,
)
if err != nil {
return nil, err
}
return fundingOutput, nil
default:
log.Debugf("Creating P2WSH funding script for local key %x "+
"and remote key %x", ourKey, theirKey)
_, fundingOutput, err := input.GenFundingPkScript(
ourKey, theirKey, chanSize,
)
if err != nil {
return nil, err
}
return fundingOutput, nil
}
}