diff --git a/aliasmgr/aliasmgr.go b/aliasmgr/aliasmgr.go index a3227b18b..258d2054b 100644 --- a/aliasmgr/aliasmgr.go +++ b/aliasmgr/aliasmgr.go @@ -3,13 +3,14 @@ package aliasmgr import ( "encoding/binary" "fmt" + "maps" + "slices" "sync" "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnwire" - "golang.org/x/exp/maps" ) // UpdateLinkAliases is a function type for a function that locates the active @@ -515,7 +516,7 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) { // channel in the baseToSet map. haveAlias := func(maybeNextAlias lnwire.ShortChannelID) bool { return fn.Any( - maps.Values(m.baseToSet), + slices.Collect(maps.Values(m.baseToSet)), func(aliasList []lnwire.ShortChannelID) bool { return fn.Any( aliasList, diff --git a/docs/release-notes/release-notes-0.19.0.md b/docs/release-notes/release-notes-0.19.0.md index f4d055d2e..fb927da4e 100644 --- a/docs/release-notes/release-notes-0.19.0.md +++ b/docs/release-notes/release-notes-0.19.0.md @@ -242,6 +242,8 @@ close transaction. * [The bitcoin `testnet4` test network is now also supported](https://github.com/lightningnetwork/lnd/pull/9620). +* [remove x/exp/maps dependency](https://github.com/lightningnetwork/lnd/pull/9621) + ## RPC Updates * Some RPCs that previously just returned an empty response message now at least diff --git a/fn/map.go b/fn/map.go index 071da9872..60cc3c0aa 100644 --- a/fn/map.go +++ b/fn/map.go @@ -2,13 +2,13 @@ package fn import ( "fmt" - - "golang.org/x/exp/maps" + "maps" + "slices" ) // KeySet converts a map into a Set containing the keys of the map. func KeySet[K comparable, V any](m map[K]V) Set[K] { - return NewSet(maps.Keys(m)...) + return NewSet(slices.Collect(maps.Keys(m))...) } // NewSubMapIntersect returns a sub-map of `m` containing only the keys found in diff --git a/fn/set.go b/fn/set.go index faeb9d7df..de54884ee 100644 --- a/fn/set.go +++ b/fn/set.go @@ -1,6 +1,9 @@ package fn -import "golang.org/x/exp/maps" +import ( + "maps" + "slices" +) // Set is a generic set using type params that supports the following // operations: diff, union, intersection, and subset. @@ -92,7 +95,7 @@ func (s Set[T]) Equal(other Set[T]) bool { // ToSlice returns the set as a slice. func (s Set[T]) ToSlice() []T { - return maps.Keys(s) + return slices.Collect(maps.Keys(s)) } // Copy copies s and returns the result. diff --git a/lnrpc/marshall_utils.go b/lnrpc/marshall_utils.go index 96d3342d8..05a9e9a90 100644 --- a/lnrpc/marshall_utils.go +++ b/lnrpc/marshall_utils.go @@ -4,6 +4,8 @@ import ( "encoding/hex" "errors" "fmt" + "maps" + "slices" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" @@ -14,7 +16,6 @@ import ( "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" - "golang.org/x/exp/maps" ) var ( @@ -222,7 +223,7 @@ func UnmarshallCoinSelectionStrategy(strategy CoinSelectionStrategy, // used in various RPCs that handle scid alias mappings. func MarshalAliasMap(scidMap aliasmgr.ScidAliasMap) []*AliasMap { return fn.Map( - maps.Keys(scidMap), + slices.Collect(maps.Keys(scidMap)), func(base lnwire.ShortChannelID) *AliasMap { return &AliasMap{ BaseScid: base.ToUint64(), diff --git a/lnrpc/walletrpc/walletkit_server.go b/lnrpc/walletrpc/walletkit_server.go index ebc04ce35..c8eaccc1d 100644 --- a/lnrpc/walletrpc/walletkit_server.go +++ b/lnrpc/walletrpc/walletkit_server.go @@ -10,9 +10,11 @@ import ( "encoding/binary" "errors" "fmt" + "maps" "math" "os" "path/filepath" + "slices" "sort" "time" @@ -43,7 +45,6 @@ import ( "github.com/lightningnetwork/lnd/lnwallet/chanfunding" "github.com/lightningnetwork/lnd/macaroons" "github.com/lightningnetwork/lnd/sweep" - "golang.org/x/exp/maps" "google.golang.org/grpc" "gopkg.in/macaroon-bakery.v2/bakery" ) @@ -1269,7 +1270,7 @@ func (w *WalletKit) BumpForceCloseFee(_ context.Context, err) } - pendingSweeps := maps.Values(inputsMap) + pendingSweeps := slices.Collect(maps.Values(inputsMap)) // Discard everything except for the anchor sweeps. anchors := fn.Filter( diff --git a/sweep/walletsweep.go b/sweep/walletsweep.go index 3f790dc66..d814d3b3b 100644 --- a/sweep/walletsweep.go +++ b/sweep/walletsweep.go @@ -3,7 +3,9 @@ package sweep import ( "errors" "fmt" + "maps" "math" + "slices" "time" "github.com/btcsuite/btcd/btcutil" @@ -15,7 +17,6 @@ import ( "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chanfunding" - "golang.org/x/exp/maps" ) var ( @@ -425,7 +426,7 @@ func fetchUtxosFromOutpoints(utxos []*lnwallet.Utxo, return nil, fmt.Errorf("%w: %v", ErrUnknownUTXO, err.Error()) } - fetchedUtxos := maps.Values(subMap) + fetchedUtxos := slices.Collect(maps.Values(subMap)) return fetchedUtxos, nil }