From e47cced26b930a831b149469367b749dd98dd31e Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 24 Jul 2023 21:20:57 +0200 Subject: [PATCH] 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. --- lnwallet/channel.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 4fa9d1b659..a5e7bbf9e8 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1423,10 +1423,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)