mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 03:01:52 +01:00
lnwallet: extract initMusigNonce from initRevocationWindows
This'll be useful later to make some enhancements to the existing unit tests.
This commit is contained in:
parent
c7300f452c
commit
d13908881c
@ -419,6 +419,28 @@ func CreateTestChannels(t *testing.T, chanType channeldb.ChannelType,
|
|||||||
return channelAlice, channelBob, nil
|
return channelAlice, channelBob, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initMusigNonce is used to manually setup musig2 nonces for a new channel,
|
||||||
|
// outside the normal chan-reest flow.
|
||||||
|
func initMusigNonce(chanA, chanB *LightningChannel) error {
|
||||||
|
chanANonces, err := chanA.GenMusigNonces()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
chanBNonces, err := chanB.GenMusigNonces()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := chanA.InitRemoteMusigNonces(chanBNonces); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := chanB.InitRemoteMusigNonces(chanANonces); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// initRevocationWindows simulates a new channel being opened within the p2p
|
// initRevocationWindows simulates a new channel being opened within the p2p
|
||||||
// network by populating the initial revocation windows of the passed
|
// network by populating the initial revocation windows of the passed
|
||||||
// commitment state machines.
|
// commitment state machines.
|
||||||
@ -427,19 +449,7 @@ func initRevocationWindows(chanA, chanB *LightningChannel) error {
|
|||||||
// either FundingLocked or ChannelReestablish by calling
|
// either FundingLocked or ChannelReestablish by calling
|
||||||
// InitRemoteMusigNonces for both sides.
|
// InitRemoteMusigNonces for both sides.
|
||||||
if chanA.channelState.ChanType.IsTaproot() {
|
if chanA.channelState.ChanType.IsTaproot() {
|
||||||
chanANonces, err := chanA.GenMusigNonces()
|
if err := initMusigNonce(chanA, chanB); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
chanBNonces, err := chanB.GenMusigNonces()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := chanA.InitRemoteMusigNonces(chanBNonces); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := chanB.InitRemoteMusigNonces(chanANonces); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user