Skip to content

Commit a9dd0f4

Browse files
committed
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.
1 parent fd13d8f commit a9dd0f4

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

contractcourt/chain_watcher.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,32 @@ func (c *chainWatcher) Start() error {
287287
}
288288
}
289289

290-
localKey := chanState.LocalChanCfg.MultiSigKey.PubKey.SerializeCompressed()
291-
remoteKey := chanState.RemoteChanCfg.MultiSigKey.PubKey.SerializeCompressed()
292-
multiSigScript, err := input.GenMultiSigScript(
293-
localKey, remoteKey,
290+
localKey := chanState.LocalChanCfg.MultiSigKey.PubKey
291+
remoteKey := chanState.RemoteChanCfg.MultiSigKey.PubKey
292+
293+
var (
294+
pkScript []byte
295+
err error
294296
)
295-
if err != nil {
296-
return err
297-
}
298-
pkScript, err := input.WitnessScriptHash(multiSigScript)
299-
if err != nil {
300-
return err
297+
if chanState.ChanType.IsTaproot() {
298+
pkScript, _, err = input.GenTaprootFundingScript(
299+
localKey, remoteKey, 0,
300+
)
301+
if err != nil {
302+
return err
303+
}
304+
} else {
305+
multiSigScript, err := input.GenMultiSigScript(
306+
localKey.SerializeCompressed(),
307+
remoteKey.SerializeCompressed(),
308+
)
309+
if err != nil {
310+
return err
311+
}
312+
pkScript, err = input.WitnessScriptHash(multiSigScript)
313+
if err != nil {
314+
return err
315+
}
301316
}
302317

303318
spendNtfn, err := c.cfg.notifier.RegisterSpendNtfn(
@@ -834,6 +849,9 @@ func (c *chainWatcher) handlePossibleBreach(commitSpend *chainntnfs.SpendDetail,
834849
}
835850

836851
// Create an AnchorResolution for the breached state.
852+
//
853+
// TODO(roasbeef): make keyring for taproot chans to pass in instead of
854+
// nil
837855
anchorRes, err := lnwallet.NewAnchorResolution(
838856
c.cfg.chanState, commitSpend.SpendingTx, nil,
839857
)

0 commit comments

Comments
 (0)