From 410baae0c754958edf8f867ab287119f06714a70 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 9096630f5..2e8fb9c1f 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -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)