Skip to content

Commit

Permalink
lnwallet: generate local nonces if non passed in for taproot chans
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Roasbeef committed Jul 24, 2023
1 parent 0f26e3f commit e47cced
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lnwallet/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e47cced

Please sign in to comment.