lnwallet: export MusigCommitType enum

We need to export the enum as it'll now be used in areas such as the
chan closer.
This commit is contained in:
Olaoluwa Osuntokun
2023-06-23 17:34:18 -07:00
parent a5d8f69516
commit 72d41ae408

View File

@ -19,17 +19,18 @@ import (
"github.com/lightningnetwork/lnd/shachain" "github.com/lightningnetwork/lnd/shachain"
) )
// commitType is an enum that denotes if this is the local or remote // MusigCommitType is an enum that denotes if this is the local or remote
// commitment. // commitment.
type commitType uint8 type MusigCommitType uint8
const ( const (
// localCommit denotes that this a session for the local commitment. // LocalMusigCommit denotes that this a session for the local
localCommit commitType = iota
// remoteCommit denotes that this is a session for the remote
// commitment. // commitment.
remoteCommit LocalMusigCommit MusigCommitType = iota
// RemoteMusigCommit denotes that this is a session for the remote
// commitment.
RemoteMusigCommit
) )
var ( var (
@ -198,7 +199,7 @@ type MusigSession struct {
// commitType tracks if this is the session for the local or remote // commitType tracks if this is the session for the local or remote
// commitment. // commitment.
commitType commitType commitType MusigCommitType
} }
// NewPartialMusigSession creates a new musig2 session given only the // NewPartialMusigSession creates a new musig2 session given only the
@ -207,7 +208,7 @@ type MusigSession struct {
func NewPartialMusigSession(verificationNonce musig2.Nonces, func NewPartialMusigSession(verificationNonce musig2.Nonces,
localKey, remoteKey keychain.KeyDescriptor, localKey, remoteKey keychain.KeyDescriptor,
signer input.MuSig2Signer, inputTxOut *wire.TxOut, signer input.MuSig2Signer, inputTxOut *wire.TxOut,
commitType commitType) *MusigSession { commitType MusigCommitType) *MusigSession {
signerKeys := []*btcec.PublicKey{localKey.PubKey, remoteKey.PubKey} signerKeys := []*btcec.PublicKey{localKey.PubKey, remoteKey.PubKey}
@ -243,7 +244,7 @@ func (m *MusigSession) FinalizeSession(signingNonce musig2.Nonces) error {
// If we're making a session for the remote commitment, then the nonce // If we're making a session for the remote commitment, then the nonce
// we use to sign is actually will be the signing nonce for the // we use to sign is actually will be the signing nonce for the
// session, and their nonce the verification nonce. // session, and their nonce the verification nonce.
case remoteCommit: case RemoteMusigCommit:
localNonce = m.nonces.SigningNonce localNonce = m.nonces.SigningNonce
remoteNonce = m.nonces.VerificationNonce remoteNonce = m.nonces.VerificationNonce
@ -251,7 +252,7 @@ func (m *MusigSession) FinalizeSession(signingNonce musig2.Nonces) error {
// commitment (to broadcast), so now our verification nonce is the one // commitment (to broadcast), so now our verification nonce is the one
// we've already generated, and we want to bind their new signing // we've already generated, and we want to bind their new signing
// nonce. // nonce.
case localCommit: case LocalMusigCommit:
localNonce = m.nonces.VerificationNonce localNonce = m.nonces.VerificationNonce
remoteNonce = m.nonces.SigningNonce remoteNonce = m.nonces.SigningNonce
} }
@ -307,7 +308,7 @@ func (m *MusigSession) SignCommit(tx *wire.MsgTx) (*MusigPartialSig, error) {
switch { switch {
// If we already have a session, then we don't need to finalize as this // If we already have a session, then we don't need to finalize as this
// was done up front (symmetric nonce case, like for co-op close). // was done up front (symmetric nonce case, like for co-op close).
case m.session == nil && m.commitType == remoteCommit: case m.session == nil && m.commitType == RemoteMusigCommit:
// Before we can sign a new commitment, we'll need to generate // Before we can sign a new commitment, we'll need to generate
// a fresh nonce that'll be sent along side our signature. With // a fresh nonce that'll be sent along side our signature. With
// the nonce in hand, we can finalize the session. // the nonce in hand, we can finalize the session.
@ -535,11 +536,11 @@ func NewMusigPairSession(cfg *MusigSessionCfg) *MusigPairSession {
// the local+remote party. // the local+remote party.
localSession := NewPartialMusigSession( localSession := NewPartialMusigSession(
cfg.LocalNonce, cfg.LocalKey, cfg.RemoteKey, cfg.LocalNonce, cfg.LocalKey, cfg.RemoteKey,
cfg.Signer, cfg.InputTxOut, localCommit, cfg.Signer, cfg.InputTxOut, LocalMusigCommit,
) )
remoteSession := NewPartialMusigSession( remoteSession := NewPartialMusigSession(
cfg.RemoteNonce, cfg.LocalKey, cfg.RemoteKey, cfg.RemoteNonce, cfg.LocalKey, cfg.RemoteKey,
cfg.Signer, cfg.InputTxOut, remoteCommit, cfg.Signer, cfg.InputTxOut, RemoteMusigCommit,
) )
return &MusigPairSession{ return &MusigPairSession{