lnwallet: generate local nonces if non passed in for taproot chans

This ensures that when loading the channel again after a normal chan
reest, we generate the local nonces, which ensures we can then process
nonces the remote party sends us in their chan reest message.
This commit is contained in:
Olaoluwa Osuntokun 2023-07-24 21:20:57 +02:00
parent 9ce817511d
commit 410baae0c7
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306

@ -1421,10 +1421,20 @@ func NewLightningChannel(signer input.Signer,
log: build.NewPrefixLog(logPrefix, walletLog),
}
switch {
// At this point, we may already have nonces that were passed in, so
// we'll check that now as this lets us skip some steps later.
if opts.localNonce != nil {
case state.ChanType.IsTaproot() && opts.localNonce != nil:
lc.pendingVerificationNonce = opts.localNonce
// Otherwise, we'll generate the nonces here ourselves. This ensures
// we'll be ablve to process the chan syncmessag efrom the remote
// party.
case state.ChanType.IsTaproot() && opts.localNonce == nil:
_, err := lc.GenMusigNonces()
if err != nil {
return nil, err
}
}
if lc.pendingVerificationNonce != nil && opts.remoteNonce != nil {
err := lc.InitRemoteMusigNonces(opts.remoteNonce)