mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-30 12:36:23 +02:00
lnwallet: move nonce generation into generateRevocation
Before this commit, we would conditionally generate nonces in RevokeCurrentCommitment. We move this to generateRevocation as this is called when doing channel sync, and we want to make sure we send the correct set of nonces.
This commit is contained in:
parent
76f0f67b7c
commit
911becb431
@ -5209,17 +5209,6 @@ func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck,
|
||||
&lc.channelState.FundingOutpoint,
|
||||
)
|
||||
|
||||
// If this is a taproot channel, We've now accepted+revoked a new
|
||||
// commitment, so we'll send the remote party another verification
|
||||
// nonce they can use to generate new commitments.
|
||||
if lc.channelState.ChanType.IsTaproot() {
|
||||
localSession := lc.musigSessions.LocalSession
|
||||
nextVerificationNonce := localSession.VerificationNonce()
|
||||
revocationMsg.LocalNonce = (*lnwire.Musig2Nonce)(
|
||||
&nextVerificationNonce.PubNonce,
|
||||
)
|
||||
}
|
||||
|
||||
return revocationMsg, newCommitment.Htlcs, finalHtlcs, nil
|
||||
}
|
||||
|
||||
@ -7759,8 +7748,9 @@ func (lc *LightningChannel) generateRevocation(height uint64) (*lnwire.RevokeAnd
|
||||
// revocation.
|
||||
//
|
||||
// Put simply in the window slides to the left by one.
|
||||
revHeight := height + 2
|
||||
nextCommitSecret, err := lc.channelState.RevocationProducer.AtIndex(
|
||||
height + 2,
|
||||
revHeight,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -7771,6 +7761,21 @@ func (lc *LightningChannel) generateRevocation(height uint64) (*lnwire.RevokeAnd
|
||||
&lc.channelState.FundingOutpoint,
|
||||
)
|
||||
|
||||
// If this is a taproot channel, then we also need to generate the
|
||||
// verification nonce for this target state.
|
||||
if lc.channelState.ChanType.IsTaproot() {
|
||||
nextVerificationNonce, err := channeldb.NewMusigVerificationNonce( //nolint:lll
|
||||
lc.channelState.LocalChanCfg.MultiSigKey.PubKey,
|
||||
revHeight, lc.taprootNonceProducer,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
revocationMsg.LocalNonce = (*lnwire.Musig2Nonce)(
|
||||
&nextVerificationNonce.PubNonce,
|
||||
)
|
||||
}
|
||||
|
||||
return revocationMsg, nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user