mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 17:55:36 +01:00
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.
This commit is contained in:
parent
e8b6e0ca45
commit
9ce817511d
1 changed files with 28 additions and 10 deletions
|
@ -287,17 +287,32 @@ func (c *chainWatcher) Start() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localKey := chanState.LocalChanCfg.MultiSigKey.PubKey.SerializeCompressed()
|
localKey := chanState.LocalChanCfg.MultiSigKey.PubKey
|
||||||
remoteKey := chanState.RemoteChanCfg.MultiSigKey.PubKey.SerializeCompressed()
|
remoteKey := chanState.RemoteChanCfg.MultiSigKey.PubKey
|
||||||
multiSigScript, err := input.GenMultiSigScript(
|
|
||||||
localKey, remoteKey,
|
var (
|
||||||
|
pkScript []byte
|
||||||
|
err error
|
||||||
)
|
)
|
||||||
if err != nil {
|
if chanState.ChanType.IsTaproot() {
|
||||||
return err
|
pkScript, _, err = input.GenTaprootFundingScript(
|
||||||
}
|
localKey, remoteKey, 0,
|
||||||
pkScript, err := input.WitnessScriptHash(multiSigScript)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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(
|
spendNtfn, err := c.cfg.notifier.RegisterSpendNtfn(
|
||||||
|
@ -833,6 +848,9 @@ func (c *chainWatcher) handlePossibleBreach(commitSpend *chainntnfs.SpendDetail,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an AnchorResolution for the breached state.
|
// Create an AnchorResolution for the breached state.
|
||||||
|
//
|
||||||
|
// TODO(roasbeef): make keyring for taproot chans to pass in instead of
|
||||||
|
// nil
|
||||||
anchorRes, err := lnwallet.NewAnchorResolution(
|
anchorRes, err := lnwallet.NewAnchorResolution(
|
||||||
c.cfg.chanState, commitSpend.SpendingTx, nil,
|
c.cfg.chanState, commitSpend.SpendingTx, nil,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue