Skip to content
Closed
6 changes: 5 additions & 1 deletion contractcourt/chain_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnwallet"
)
Expand Down Expand Up @@ -301,8 +302,11 @@ func (c *chainWatcher) Start() error {
err error
)
if chanState.ChanType.IsTaproot() {
fundingOpts := fn.MapOptionZ(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick 😎

chanState.TapscriptRoot, lnwallet.TapscriptRootToOpt,
)
c.fundingPkScript, _, err = input.GenTaprootFundingScript(
localKey, remoteKey, 0,
localKey, remoteKey, 0, fundingOpts...,
)
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions funding/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/discovery"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/labels"
Expand Down Expand Up @@ -2853,8 +2854,12 @@ func makeFundingScript(channel *channeldb.OpenChannel) ([]byte, error) {
remoteKey := channel.RemoteChanCfg.MultiSigKey.PubKey

if channel.ChanType.IsTaproot() {
fundingOpts := fn.MapOptionZ(
channel.TapscriptRoot, lnwallet.TapscriptRootToOpt,
)
pkScript, _, err := input.GenTaprootFundingScript(
localKey, remoteKey, int64(channel.Capacity),
fundingOpts...,
)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions lnwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,12 @@ func initStateHints(commit1, commit2 *wire.MsgTx,
return nil
}

// TapscriptRootToOpt is a helper function that converts a tapscript root into
// the functional option we can use to pass into GenTaprootFundingScript.
func TapscriptRootToOpt(root chainhash.Hash) []input.FundingScriptOpt {
return []input.FundingScriptOpt{input.WithTapscriptRoot(root)}
}

// ValidateChannel will attempt to fully validate a newly mined channel, given
// its funding transaction and existing channel state. If this method returns
// an error, then the mined channel is invalid, and shouldn't be used.
Expand Down
2 changes: 2 additions & 0 deletions routing/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,8 @@ func makeFundingScript(bitcoinKey1, bitcoinKey2 []byte,
return nil, err
}

// TODO(roasbeef): add tapscript root to gossip v1.5

return fundingScript, nil
}

Expand Down