Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blockcache/blockcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// BlockCache is an lru cache for blocks.
type BlockCache struct {
Cache *lru.Cache[wire.InvVect, *neutrino.CacheableBlock]
HashMutex *multimutex.HashMutex
HashMutex *multimutex.Mutex[lntypes.Hash]
}

// NewBlockCache creates a new BlockCache with the given maximum capacity.
Expand All @@ -23,7 +23,7 @@ func NewBlockCache(capacity uint64) *BlockCache {
Cache: lru.NewCache[wire.InvVect, *neutrino.CacheableBlock](
capacity,
),
HashMutex: multimutex.NewHashMutex(),
HashMutex: multimutex.NewMutex[lntypes.Hash](),
}
}

Expand Down
8 changes: 5 additions & 3 deletions contractcourt/breacharbiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,7 @@ func createTestArbiter(t *testing.T, contractBreaches chan *ContractBreachEvent,
})

aliceKeyPriv, _ := btcec.PrivKeyFromBytes(channels.AlicesPrivKey)
signer := &mock.SingleSigner{Privkey: aliceKeyPriv}
signer := input.NewMockSigner([]*btcec.PrivateKey{aliceKeyPriv}, nil)

// Assemble our test arbiter.
notifier := mock.MakeMockSpendNotifier()
Expand Down Expand Up @@ -2339,8 +2339,10 @@ func createInitChannels(t *testing.T, revocationWindow int) (
Packager: channeldb.NewChannelPackager(shortChanID),
}

aliceSigner := &mock.SingleSigner{Privkey: aliceKeyPriv}
bobSigner := &mock.SingleSigner{Privkey: bobKeyPriv}
aliceSigner := input.NewMockSigner(
[]*btcec.PrivateKey{aliceKeyPriv}, nil,
)
bobSigner := input.NewMockSigner([]*btcec.PrivateKey{bobKeyPriv}, nil)

alicePool := lnwallet.NewSigPool(1, aliceSigner)
channelAlice, err := lnwallet.NewLightningChannel(
Expand Down
4 changes: 2 additions & 2 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ type AuthenticatedGossiper struct {
// goroutine per channel ID. This is done to ensure that when
// the gossiper is handling an announcement, the db state stays
// consistent between when the DB is first read until it's written.
channelMtx *multimutex.Mutex
channelMtx *multimutex.Mutex[uint64]

recentRejects *lru.Cache[rejectCacheKey, *cachedReject]

Expand Down Expand Up @@ -493,7 +493,7 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper
prematureChannelUpdates: lru.NewCache[uint64, *cachedNetworkMsg]( //nolint: lll
maxPrematureUpdates,
),
channelMtx: multimutex.NewMutex(),
channelMtx: multimutex.NewMutex[uint64](),
recentRejects: lru.NewCache[rejectCacheKey, *cachedReject](
maxRejectedUpdates,
),
Expand Down
4 changes: 2 additions & 2 deletions htlcswitch/payment_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ type networkResultStore struct {
// paymentIDMtx is a multimutex used to make sure the database and
// result subscribers map is consistent for each payment ID in case of
// concurrent callers.
paymentIDMtx *multimutex.Mutex
paymentIDMtx *multimutex.Mutex[uint64]
}

func newNetworkResultStore(db kvdb.Backend) *networkResultStore {
return &networkResultStore{
backend: db,
results: make(map[uint64][]chan *networkResult),
paymentIDMtx: multimutex.NewMutex(),
paymentIDMtx: multimutex.NewMutex[uint64](),
}
}

Expand Down
9 changes: 6 additions & 3 deletions htlcswitch/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnpeer"
"github.com/lightningnetwork/lnd/lntest/channels"
"github.com/lightningnetwork/lnd/lntest/mock"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
Expand Down Expand Up @@ -336,8 +335,12 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
return nil, nil, err
}

aliceSigner := &mock.SingleSigner{Privkey: aliceKeyPriv}
bobSigner := &mock.SingleSigner{Privkey: bobKeyPriv}
aliceSigner := input.NewMockSigner(
[]*btcec.PrivateKey{aliceKeyPriv}, nil,
)
bobSigner := input.NewMockSigner(
[]*btcec.PrivateKey{bobKeyPriv}, nil,
)

alicePool := lnwallet.NewSigPool(runtime.NumCPU(), aliceSigner)
channelAlice, err := lnwallet.NewLightningChannel(
Expand Down
34 changes: 22 additions & 12 deletions input/musig2.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ type MuSig2Signer interface {
// public key of the local signing key. If nonces of other parties are
// already known, they can be submitted as well to reduce the number of
// method calls necessary later on.
//
// The set of sessionOpts are _optional_ and allow a caller to modify
// the generated sessions. As an example the local nonce might already
// be generated ahead of time.
MuSig2CreateSession(MuSig2Version, keychain.KeyLocator,
[]*btcec.PublicKey, *MuSig2Tweaks,
[][musig2.PubNonceSize]byte) (*MuSig2SessionInfo, error)
[]*btcec.PublicKey, *MuSig2Tweaks, [][musig2.PubNonceSize]byte,
...musig2.SessionOption) (*MuSig2SessionInfo, error)

// MuSig2RegisterNonces registers one or more public nonces of other
// signing participants for a session identified by its ID. This method
Expand Down Expand Up @@ -374,15 +378,20 @@ func combineKeysV040(allSignerPubKeys []*btcec.PublicKey, sortKeys bool,

// MuSig2CreateContext creates a new MuSig2 signing context.
func MuSig2CreateContext(bipVersion MuSig2Version, privKey *btcec.PrivateKey,
allSignerPubKeys []*btcec.PublicKey,
tweaks *MuSig2Tweaks) (MuSig2Context, MuSig2Session, error) {
allSignerPubKeys []*btcec.PublicKey, tweaks *MuSig2Tweaks,
sessionOpts ...musig2.SessionOption,
) (MuSig2Context, MuSig2Session, error) {

switch bipVersion {
case MuSig2Version040:
return createContextV040(privKey, allSignerPubKeys, tweaks)
return createContextV040(
privKey, allSignerPubKeys, tweaks, sessionOpts...,
)

case MuSig2Version100RC2:
return createContextV100RC2(privKey, allSignerPubKeys, tweaks)
return createContextV100RC2(
privKey, allSignerPubKeys, tweaks, sessionOpts...,
)

default:
return nil, nil, fmt.Errorf("unknown MuSig2 version: <%d>",
Expand All @@ -393,8 +402,9 @@ func MuSig2CreateContext(bipVersion MuSig2Version, privKey *btcec.PrivateKey,
// createContextV100RC2 implements the MuSig2CreateContext logic for the MuSig2
// BIP draft version 1.0.0rc2.
func createContextV100RC2(privKey *btcec.PrivateKey,
allSignerPubKeys []*btcec.PublicKey,
tweaks *MuSig2Tweaks) (*musig2.Context, *musig2.Session, error) {
allSignerPubKeys []*btcec.PublicKey, tweaks *MuSig2Tweaks,
sessionOpts ...musig2.SessionOption,
) (*musig2.Context, *musig2.Session, error) {

// The context keeps track of all signing keys and our local key.
allOpts := append(
Expand All @@ -409,7 +419,7 @@ func createContextV100RC2(privKey *btcec.PrivateKey,
"context: %v", err)
}

muSigSession, err := muSigContext.NewSession()
muSigSession, err := muSigContext.NewSession(sessionOpts...)
if err != nil {
return nil, nil, fmt.Errorf("error creating MuSig2 signing "+
"session: %v", err)
Expand All @@ -421,9 +431,9 @@ func createContextV100RC2(privKey *btcec.PrivateKey,
// createContextV040 implements the MuSig2CreateContext logic for the MuSig2 BIP
// draft version 0.4.0.
func createContextV040(privKey *btcec.PrivateKey,
allSignerPubKeys []*btcec.PublicKey,
tweaks *MuSig2Tweaks) (*musig2v040.Context, *musig2v040.Session,
error) {
allSignerPubKeys []*btcec.PublicKey, tweaks *MuSig2Tweaks,
sessionOpts ...musig2.SessionOption,
) (*musig2v040.Context, *musig2v040.Session, error) {

// The context keeps track of all signing keys and our local key.
allOpts := append(
Expand Down
Loading