From 0f26e3f2d4fde1a50eb0601aa447ed57c17b5ba2 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 19 Jan 2023 20:31:31 -0800 Subject: [PATCH] contractcourt: update chain watcher to understand the taproot pkscript In this commit, we update the chain watcher to be able to generate the correct pkScript so it can register for confirmation and spend notifications for taproot channels. --- contractcourt/chain_watcher.go | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go index 7fd45e1c24..39d160538c 100644 --- a/contractcourt/chain_watcher.go +++ b/contractcourt/chain_watcher.go @@ -287,17 +287,32 @@ func (c *chainWatcher) Start() error { } } - localKey := chanState.LocalChanCfg.MultiSigKey.PubKey.SerializeCompressed() - remoteKey := chanState.RemoteChanCfg.MultiSigKey.PubKey.SerializeCompressed() - multiSigScript, err := input.GenMultiSigScript( - localKey, remoteKey, + localKey := chanState.LocalChanCfg.MultiSigKey.PubKey + remoteKey := chanState.RemoteChanCfg.MultiSigKey.PubKey + + var ( + pkScript []byte + err error ) - if err != nil { - return err - } - pkScript, err := input.WitnessScriptHash(multiSigScript) - if err != nil { - return err + if chanState.ChanType.IsTaproot() { + pkScript, _, err = input.GenTaprootFundingScript( + localKey, remoteKey, 0, + ) + if err != nil { + return err + } + } else { + multiSigScript, err := input.GenMultiSigScript( + localKey.SerializeCompressed(), + remoteKey.SerializeCompressed(), + ) + if err != nil { + return err + } + pkScript, err = input.WitnessScriptHash(multiSigScript) + if err != nil { + return err + } } spendNtfn, err := c.cfg.notifier.RegisterSpendNtfn( @@ -833,6 +848,9 @@ func (c *chainWatcher) handlePossibleBreach(commitSpend *chainntnfs.SpendDetail, } // Create an AnchorResolution for the breached state. + // + // TODO(roasbeef): make keyring for taproot chans to pass in instead of + // nil anchorRes, err := lnwallet.NewAnchorResolution( c.cfg.chanState, commitSpend.SpendingTx, nil, )