Merge pull request #9330 from ProofOfKeags/update/fn2

multi: update to fn v2
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2024-12-09 12:56:23 +01:00
commit fb429d658b
167 files changed
+372 -302

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc"
+15 -9
View File
@@ -11,7 +11,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/wallet"
"github.com/lightningnetwork/lnd/aliasmgr"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire"
"golang.org/x/exp/maps"
@@ -221,12 +221,18 @@ func UnmarshallCoinSelectionStrategy(strategy CoinSelectionStrategy,
// MarshalAliasMap converts a ScidAliasMap to its proto counterpart. This is
// used in various RPCs that handle scid alias mappings.
func MarshalAliasMap(scidMap aliasmgr.ScidAliasMap) []*AliasMap {
return fn.Map(func(base lnwire.ShortChannelID) *AliasMap {
return &AliasMap{
BaseScid: base.ToUint64(),
Aliases: fn.Map(func(a lnwire.ShortChannelID) uint64 {
return a.ToUint64()
}, scidMap[base]),
}
}, maps.Keys(scidMap))
return fn.Map(
maps.Keys(scidMap),
func(base lnwire.ShortChannelID) *AliasMap {
return &AliasMap{
BaseScid: base.ToUint64(),
Aliases: fn.Map(
scidMap[base],
func(a lnwire.ShortChannelID) uint64 {
return a.ToUint64()
},
),
}
},
)
}
+1 -1
View File
@@ -3,7 +3,7 @@ package routerrpc
import (
"errors"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lnrpc"
+1 -1
View File
@@ -16,7 +16,7 @@ import (
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/feature"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lntypes"
+1 -1
View File
@@ -16,7 +16,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/aliasmgr"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lntypes"
+20 -15
View File
@@ -31,7 +31,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/labels"
@@ -1145,9 +1145,9 @@ func (w *WalletKit) getWaitingCloseChannel(
return nil, err
}
channel := fn.Find(func(c *channeldb.OpenChannel) bool {
channel := fn.Find(chans, func(c *channeldb.OpenChannel) bool {
return c.FundingOutpoint == chanPoint
}, chans)
})
return channel.UnwrapOrErr(errors.New("channel not found"))
}
@@ -1231,18 +1231,23 @@ func (w *WalletKit) BumpForceCloseFee(_ context.Context,
pendingSweeps := maps.Values(inputsMap)
// Discard everything except for the anchor sweeps.
anchors := fn.Filter(func(sweep *sweep.PendingInputResponse) bool {
// Only filter for anchor inputs because these are the only
// inputs which can be used to bump a closed unconfirmed
// commitment transaction.
if sweep.WitnessType != input.CommitmentAnchor &&
sweep.WitnessType != input.TaprootAnchorSweepSpend {
anchors := fn.Filter(
pendingSweeps,
func(sweep *sweep.PendingInputResponse) bool {
// Only filter for anchor inputs because these are the
// only inputs which can be used to bump a closed
// unconfirmed commitment transaction.
isCommitAnchor := sweep.WitnessType ==
input.CommitmentAnchor
isTaprootSweepSpend := sweep.WitnessType ==
input.TaprootAnchorSweepSpend
if !isCommitAnchor && !isTaprootSweepSpend {
return false
}
return false
}
return commitSet.Contains(sweep.OutPoint.Hash)
}, pendingSweeps)
return commitSet.Contains(sweep.OutPoint.Hash)
},
)
if len(anchors) == 0 {
return nil, fmt.Errorf("unable to find pending anchor outputs")
@@ -1754,7 +1759,7 @@ func (w *WalletKit) fundPsbtInternalWallet(account string,
return true
}
eligibleUtxos := fn.Filter(filterFn, utxos)
eligibleUtxos := fn.Filter(utxos, filterFn)
// Validate all inputs against our known list of UTXOs
// now.