Skip to content

Commit

Permalink
contractcourt: update chain watcher to understand the taproot pkscript
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Roasbeef committed May 12, 2023
1 parent fd13d8f commit a9dd0f4
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions contractcourt/chain_watcher.go
Expand Up @@ -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(
Expand Down Expand Up @@ -834,6 +849,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,
)
Expand Down

0 comments on commit a9dd0f4

Please sign in to comment.