From ed2989ae33e230188aaaf8a6052440db7e39810a Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Tue, 3 Dec 2024 15:51:05 -0700 Subject: [PATCH] multi: update to fn v2 --- aliasmgr/aliasmgr.go | 22 +++-- chainntnfs/bitcoindnotify/bitcoind.go | 2 +- chainntnfs/btcdnotify/btcd.go | 2 +- chainntnfs/interface.go | 2 +- chainntnfs/mocks.go | 2 +- chainreg/chainregistry.go | 2 +- chanbackup/backup.go | 2 +- chanbackup/single.go | 2 +- chanbackup/single_test.go | 2 +- channeldb/channel.go | 2 +- channeldb/channel_test.go | 2 +- .../migration/lnwire21/custom_records.go | 15 +-- .../migration32/mission_control_store.go | 4 +- channeldb/revocation_log.go | 2 +- channeldb/revocation_log_test.go | 2 +- cmd/commands/cmd_macaroon.go | 17 ++-- config_builder.go | 2 +- contractcourt/anchor_resolver.go | 2 +- contractcourt/breach_arbitrator.go | 10 +- contractcourt/breach_arbitrator_test.go | 2 +- contractcourt/briefcase.go | 2 +- contractcourt/briefcase_test.go | 2 +- contractcourt/chain_arbitrator.go | 2 +- contractcourt/chain_watcher.go | 12 +-- contractcourt/channel_arbitrator.go | 6 +- contractcourt/channel_arbitrator_test.go | 2 +- contractcourt/commit_sweep_resolver.go | 2 +- contractcourt/contract_resolver.go | 2 +- .../htlc_incoming_contest_resolver.go | 2 +- contractcourt/htlc_lease_resolver.go | 2 +- .../htlc_outgoing_contest_resolver.go | 2 +- contractcourt/htlc_success_resolver.go | 2 +- contractcourt/htlc_success_resolver_test.go | 2 +- contractcourt/htlc_timeout_resolver.go | 2 +- contractcourt/htlc_timeout_resolver_test.go | 2 +- contractcourt/utxonursery.go | 2 +- contractcourt/utxonursery_test.go | 2 +- discovery/gossiper.go | 2 +- discovery/gossiper_test.go | 2 +- funding/aux_funding.go | 2 +- funding/manager.go | 2 +- funding/manager_test.go | 2 +- go.mod | 4 +- go.sum | 8 +- graph/builder.go | 2 +- graph/db/models/channel_edge_info.go | 2 +- htlcswitch/interceptable_switch.go | 2 +- htlcswitch/interfaces.go | 2 +- htlcswitch/link.go | 2 +- htlcswitch/link_test.go | 2 +- htlcswitch/mock.go | 2 +- htlcswitch/quiescer.go | 2 +- htlcswitch/quiescer_test.go | 2 +- htlcswitch/switch.go | 2 +- htlcswitch/switch_test.go | 2 +- input/input.go | 2 +- input/mocks.go | 2 +- input/script_utils.go | 2 +- input/taproot.go | 2 +- input/taproot_test.go | 2 +- intercepted_forward.go | 2 +- invoices/modification_interceptor.go | 2 +- itest/lnd_funding_test.go | 2 +- itest/lnd_sweep_test.go | 6 +- lnrpc/devrpc/dev_server.go | 2 +- lnrpc/marshall_utils.go | 24 +++-- lnrpc/routerrpc/forward_interceptor.go | 2 +- lnrpc/routerrpc/router_backend.go | 2 +- lnrpc/routerrpc/router_server.go | 2 +- lnrpc/walletrpc/walletkit_server.go | 35 ++++--- lntest/harness.go | 2 +- lntest/harness_assertion.go | 4 +- lntest/miner/miner.go | 7 +- lntest/mock/walletcontroller.go | 2 +- lntest/node/state.go | 6 +- lnwallet/aux_leaf_store.go | 2 +- lnwallet/aux_resolutions.go | 2 +- lnwallet/aux_signer.go | 2 +- lnwallet/btcwallet/btcwallet.go | 2 +- lnwallet/chainfee/filtermanager.go | 2 +- lnwallet/chancloser/aux_closer.go | 2 +- lnwallet/chancloser/chancloser.go | 2 +- lnwallet/chancloser/chancloser_test.go | 2 +- lnwallet/chancloser/interface.go | 2 +- lnwallet/chanfunding/canned_assembler.go | 2 +- lnwallet/chanfunding/interface.go | 2 +- lnwallet/chanfunding/psbt_assembler.go | 2 +- lnwallet/channel.go | 93 ++++++++++--------- lnwallet/channel_test.go | 11 ++- lnwallet/commitment.go | 10 +- lnwallet/commitment_chain.go | 2 +- lnwallet/config.go | 2 +- lnwallet/interface.go | 2 +- lnwallet/mock.go | 2 +- lnwallet/musig_session.go | 2 +- lnwallet/reservation.go | 2 +- lnwallet/rpcwallet/rpcwallet.go | 2 +- lnwallet/test/test_interface.go | 2 +- lnwallet/test_utils.go | 2 +- lnwallet/transactions_test.go | 2 +- lnwallet/update_log.go | 2 +- lnwallet/wallet.go | 2 +- lnwire/channel_reestablish.go | 2 +- lnwire/custom_records.go | 15 +-- lnwire/custom_records_test.go | 11 ++- lnwire/dyn_ack.go | 2 +- lnwire/dyn_propose.go | 2 +- lnwire/extra_bytes.go | 2 +- lnwire/lnwire_test.go | 2 +- lnwire/onion_error.go | 2 +- lnwire/onion_error_test.go | 2 +- msgmux/msg_router.go | 4 +- peer/brontide.go | 2 +- peer/brontide_test.go | 2 +- peer/musig_chan_closer.go | 2 +- peer/test_utils.go | 2 +- protofsm/daemon_events.go | 2 +- protofsm/msg_mapper.go | 2 +- protofsm/state_machine.go | 44 +++++++-- protofsm/state_machine_test.go | 2 +- routing/bandwidth.go | 2 +- routing/bandwidth_test.go | 2 +- routing/blinding.go | 2 +- routing/blinding_test.go | 2 +- routing/integrated_routing_context_test.go | 2 +- routing/localchans/manager.go | 2 +- routing/missioncontrol.go | 2 +- routing/mock_test.go | 2 +- routing/pathfind.go | 2 +- routing/pathfind_test.go | 2 +- routing/payment_lifecycle.go | 2 +- routing/payment_lifecycle_test.go | 2 +- routing/payment_session_source.go | 2 +- routing/result_interpretation.go | 4 +- routing/result_interpretation_test.go | 2 +- routing/router.go | 2 +- routing/router_test.go | 2 +- rpcserver.go | 6 +- rpcserver_test.go | 2 +- server.go | 2 +- subrpcserver_config.go | 2 +- sweep/aggregator.go | 2 +- sweep/aggregator_test.go | 2 +- sweep/fee_bumper.go | 8 +- sweep/fee_bumper_test.go | 2 +- sweep/fee_function.go | 2 +- sweep/fee_function_test.go | 2 +- sweep/interface.go | 2 +- sweep/mock_test.go | 2 +- sweep/sweeper.go | 2 +- sweep/sweeper_test.go | 2 +- sweep/tx_input_set.go | 6 +- sweep/tx_input_set_test.go | 2 +- sweep/walletsweep.go | 2 +- sweep/walletsweep_test.go | 2 +- watchtower/blob/justice_kit.go | 2 +- watchtower/blob/justice_kit_test.go | 2 +- watchtower/lookout/justice_descriptor_test.go | 2 +- .../wtclient/backup_task_internal_test.go | 2 +- watchtower/wtclient/client_test.go | 2 +- watchtower/wtclient/manager.go | 2 +- watchtower/wtdb/client_chan_summary.go | 2 +- watchtower/wtdb/client_db.go | 2 +- zpay32/decode.go | 2 +- zpay32/encode.go | 2 +- zpay32/invoice.go | 2 +- zpay32/invoice_test.go | 2 +- 167 files changed, 372 insertions(+), 302 deletions(-) diff --git a/aliasmgr/aliasmgr.go b/aliasmgr/aliasmgr.go index f06cb53d79..a3227b18b8 100644 --- a/aliasmgr/aliasmgr.go +++ b/aliasmgr/aliasmgr.go @@ -5,7 +5,7 @@ import ( "fmt" "sync" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnwire" @@ -432,9 +432,9 @@ func (m *Manager) DeleteLocalAlias(alias, } // We'll filter the alias set and remove the alias from it. - aliasSet = fn.Filter(func(a lnwire.ShortChannelID) bool { + aliasSet = fn.Filter(aliasSet, func(a lnwire.ShortChannelID) bool { return a.ToUint64() != alias.ToUint64() - }, aliasSet) + }) // If the alias set is empty, we'll delete the base SCID from the // baseToSet map. @@ -514,11 +514,17 @@ func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error) { // haveAlias returns true if the passed alias is already assigned to a // channel in the baseToSet map. haveAlias := func(maybeNextAlias lnwire.ShortChannelID) bool { - return fn.Any(func(aliasList []lnwire.ShortChannelID) bool { - return fn.Any(func(alias lnwire.ShortChannelID) bool { - return alias == maybeNextAlias - }, aliasList) - }, maps.Values(m.baseToSet)) + return fn.Any( + maps.Values(m.baseToSet), + func(aliasList []lnwire.ShortChannelID) bool { + return fn.Any( + aliasList, + func(alias lnwire.ShortChannelID) bool { + return alias == maybeNextAlias + }, + ) + }, + ) } err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error { diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index fc20fbb857..59c03d5171 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -15,7 +15,7 @@ import ( "github.com/btcsuite/btcwallet/chain" "github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/queue" ) diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index c3a40a00bf..e3bff289cf 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -17,7 +17,7 @@ import ( "github.com/btcsuite/btcwallet/chain" "github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/queue" ) diff --git a/chainntnfs/interface.go b/chainntnfs/interface.go index b2383636aa..1b8a5acb50 100644 --- a/chainntnfs/interface.go +++ b/chainntnfs/interface.go @@ -13,7 +13,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) var ( diff --git a/chainntnfs/mocks.go b/chainntnfs/mocks.go index d9ab9928d0..4a888b162e 100644 --- a/chainntnfs/mocks.go +++ b/chainntnfs/mocks.go @@ -3,7 +3,7 @@ package chainntnfs import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/stretchr/testify/mock" ) diff --git a/chainreg/chainregistry.go b/chainreg/chainregistry.go index edc422482e..a9a9ede704 100644 --- a/chainreg/chainregistry.go +++ b/chainreg/chainregistry.go @@ -23,7 +23,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs/btcdnotify" "github.com/lightningnetwork/lnd/chainntnfs/neutrinonotify" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/keychain" diff --git a/chanbackup/backup.go b/chanbackup/backup.go index 5853b37e45..afffe5a2e8 100644 --- a/chanbackup/backup.go +++ b/chanbackup/backup.go @@ -5,7 +5,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) // LiveChannelSource is an interface that allows us to query for the set of diff --git a/chanbackup/single.go b/chanbackup/single.go index b741320b07..01d14f6c07 100644 --- a/chanbackup/single.go +++ b/chanbackup/single.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnencrypt" "github.com/lightningnetwork/lnd/lnwire" diff --git a/chanbackup/single_test.go b/chanbackup/single_test.go index d2212bd859..0fe402926d 100644 --- a/chanbackup/single_test.go +++ b/chanbackup/single_test.go @@ -13,7 +13,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnencrypt" "github.com/lightningnetwork/lnd/lnwire" diff --git a/channeldb/channel.go b/channeldb/channel.go index 9ca57312aa..f4e99a6f8c 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -19,7 +19,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/walletdb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hop" diff --git a/channeldb/channel_test.go b/channeldb/channel_test.go index 2cac0baced..b1ca100eb3 100644 --- a/channeldb/channel_test.go +++ b/channeldb/channel_test.go @@ -18,7 +18,7 @@ import ( _ "github.com/btcsuite/btcwallet/walletdb/bdb" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/clock" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/kvdb" diff --git a/channeldb/migration/lnwire21/custom_records.go b/channeldb/migration/lnwire21/custom_records.go index f0f59185e9..7771c8ec8b 100644 --- a/channeldb/migration/lnwire21/custom_records.go +++ b/channeldb/migration/lnwire21/custom_records.go @@ -6,7 +6,7 @@ import ( "io" "sort" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" ) @@ -163,9 +163,12 @@ func (c CustomRecords) SerializeTo(w io.Writer) error { // ProduceRecordsSorted converts a slice of record producers into a slice of // records and then sorts it by type. func ProduceRecordsSorted(recordProducers ...tlv.RecordProducer) []tlv.Record { - records := fn.Map(func(producer tlv.RecordProducer) tlv.Record { - return producer.Record() - }, recordProducers) + records := fn.Map( + recordProducers, + func(producer tlv.RecordProducer) tlv.Record { + return producer.Record() + }, + ) // Ensure that the set of records are sorted before we attempt to // decode from the stream, to ensure they're canonical. @@ -196,9 +199,9 @@ func TlvMapToRecords(tlvMap tlv.TypeMap) []tlv.Record { // RecordsAsProducers converts a slice of records into a slice of record // producers. func RecordsAsProducers(records []tlv.Record) []tlv.RecordProducer { - return fn.Map(func(record tlv.Record) tlv.RecordProducer { + return fn.Map(records, func(record tlv.Record) tlv.RecordProducer { return &record - }, records) + }) } // EncodeRecords encodes the given records into a byte slice. diff --git a/channeldb/migration32/mission_control_store.go b/channeldb/migration32/mission_control_store.go index 3ac9d6114c..76463eb6ca 100644 --- a/channeldb/migration32/mission_control_store.go +++ b/channeldb/migration32/mission_control_store.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/wire" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" ) @@ -371,7 +371,7 @@ func extractMCRoute(r *Route) *mcRoute { // extractMCHops extracts the Hop fields that MC actually uses from a slice of // Hops. func extractMCHops(hops []*Hop) mcHops { - return fn.Map(extractMCHop, hops) + return fn.Map(hops, extractMCHop) } // extractMCHop extracts the Hop fields that MC actually uses from a Hop. diff --git a/channeldb/revocation_log.go b/channeldb/revocation_log.go index 3abc73f81e..ea6eaf13f2 100644 --- a/channeldb/revocation_log.go +++ b/channeldb/revocation_log.go @@ -7,7 +7,7 @@ import ( "math" "github.com/btcsuite/btcd/btcutil" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" diff --git a/channeldb/revocation_log_test.go b/channeldb/revocation_log_test.go index 4290552eee..2df6627e2c 100644 --- a/channeldb/revocation_log_test.go +++ b/channeldb/revocation_log_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/btcsuite/btcd/btcutil" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lntest/channels" "github.com/lightningnetwork/lnd/lnwire" diff --git a/cmd/commands/cmd_macaroon.go b/cmd/commands/cmd_macaroon.go index 15c29380a7..d7d6d5f9dc 100644 --- a/cmd/commands/cmd_macaroon.go +++ b/cmd/commands/cmd_macaroon.go @@ -10,7 +10,7 @@ import ( "strings" "unicode" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/macaroons" @@ -177,12 +177,15 @@ func bakeMacaroon(ctx *cli.Context) error { "%w", err) } - ops := fn.Map(func(p *lnrpc.MacaroonPermission) bakery.Op { - return bakery.Op{ - Entity: p.Entity, - Action: p.Action, - } - }, parsedPermissions) + ops := fn.Map( + parsedPermissions, + func(p *lnrpc.MacaroonPermission) bakery.Op { + return bakery.Op{ + Entity: p.Entity, + Action: p.Action, + } + }, + ) rawMacaroon, err = macaroons.BakeFromRootKey(macRootKey, ops) if err != nil { diff --git a/config_builder.go b/config_builder.go index 42650bb68b..42790a50c6 100644 --- a/config_builder.go +++ b/config_builder.go @@ -33,7 +33,7 @@ import ( "github.com/lightningnetwork/lnd/chainreg" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/funding" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/invoices" diff --git a/contractcourt/anchor_resolver.go b/contractcourt/anchor_resolver.go index b4d6877202..e482c4c713 100644 --- a/contractcourt/anchor_resolver.go +++ b/contractcourt/anchor_resolver.go @@ -9,7 +9,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/sweep" ) diff --git a/contractcourt/breach_arbitrator.go b/contractcourt/breach_arbitrator.go index d59829b5e5..33bc7f7e33 100644 --- a/contractcourt/breach_arbitrator.go +++ b/contractcourt/breach_arbitrator.go @@ -15,7 +15,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/kvdb" @@ -1537,9 +1537,9 @@ func (b *BreachArbitrator) createSweepTx( // outputs from the regular, BTC only outputs. So we only need one such // output, which'll carry the custom channel "valuables" from both the // breached commitment and HTLC outputs. - hasBlobs := fn.Any(func(i input.Input) bool { + hasBlobs := fn.Any(inputs, func(i input.Input) bool { return i.ResolutionBlob().IsSome() - }, inputs) + }) if hasBlobs { weightEstimate.AddP2TROutput() } @@ -1624,7 +1624,7 @@ func (b *BreachArbitrator) sweepSpendableOutputsTxn(txWeight lntypes.WeightUnit, // First, we'll add the extra sweep output if it exists, subtracting the // amount from the sweep amt. if b.cfg.AuxSweeper.IsSome() { - extraChangeOut.WhenResult(func(o sweep.SweepOutput) { + extraChangeOut.WhenOk(func(o sweep.SweepOutput) { sweepAmt -= o.Value txn.AddTxOut(&o.TxOut) @@ -1697,7 +1697,7 @@ func (b *BreachArbitrator) sweepSpendableOutputsTxn(txWeight lntypes.WeightUnit, return &justiceTxCtx{ justiceTx: txn, sweepAddr: pkScript, - extraTxOut: extraChangeOut.Option(), + extraTxOut: extraChangeOut.OkToSome(), fee: txFee, inputs: inputs, }, nil diff --git a/contractcourt/breach_arbitrator_test.go b/contractcourt/breach_arbitrator_test.go index 576009eda4..c387c21797 100644 --- a/contractcourt/breach_arbitrator_test.go +++ b/contractcourt/breach_arbitrator_test.go @@ -22,7 +22,7 @@ import ( "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "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/lntest/channels" diff --git a/contractcourt/briefcase.go b/contractcourt/briefcase.go index a0908ea3fa..7d199c5c28 100644 --- a/contractcourt/briefcase.go +++ b/contractcourt/briefcase.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnwallet" diff --git a/contractcourt/briefcase_test.go b/contractcourt/briefcase_test.go index 0f44db2abb..533d0eff78 100644 --- a/contractcourt/briefcase_test.go +++ b/contractcourt/briefcase_test.go @@ -14,7 +14,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnmock" diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index 6d9b30d208..646d68b869 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -14,7 +14,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/kvdb" diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go index e79c8d546b..e29f21e7f4 100644 --- a/contractcourt/chain_watcher.go +++ b/contractcourt/chain_watcher.go @@ -18,7 +18,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnutils" @@ -451,7 +451,7 @@ func (c *chainWatcher) handleUnknownLocalState( leaseExpiry = c.cfg.chanState.ThawHeight } - remoteAuxLeaf := fn.ChainOption( + remoteAuxLeaf := fn.FlatMapOption( func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf { return l.RemoteAuxLeaf }, @@ -468,7 +468,7 @@ func (c *chainWatcher) handleUnknownLocalState( // Next, we'll derive our script that includes the revocation base for // the remote party allowing them to claim this output before the CSV // delay if we breach. - localAuxLeaf := fn.ChainOption( + localAuxLeaf := fn.FlatMapOption( func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf { return l.LocalAuxLeaf }, @@ -1062,15 +1062,15 @@ func (c *chainWatcher) toSelfAmount(tx *wire.MsgTx) btcutil.Amount { return false } - return fn.Any(c.cfg.isOurAddr, addrs) + return fn.Any(addrs, c.cfg.isOurAddr) } // Grab all of the outputs that correspond with our delivery address // or our wallet is aware of. - outs := fn.Filter(fn.PredOr(isDeliveryOutput, isWalletOutput), tx.TxOut) + outs := fn.Filter(tx.TxOut, fn.PredOr(isDeliveryOutput, isWalletOutput)) // Grab the values for those outputs. - vals := fn.Map(func(o *wire.TxOut) int64 { return o.Value }, outs) + vals := fn.Map(outs, func(o *wire.TxOut) int64 { return o.Value }) // Return the sum. return btcutil.Amount(fn.Sum(vals)) diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index 319b437e4e..0be157d971 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -15,7 +15,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/input" @@ -997,7 +997,7 @@ func (c *ChannelArbitrator) stateStep( getIdx := func(htlc channeldb.HTLC) uint64 { return htlc.HtlcIndex } - dustHTLCSet := fn.NewSet(fn.Map(getIdx, dustHTLCs)...) + dustHTLCSet := fn.NewSet(fn.Map(dustHTLCs, getIdx)...) err = c.abandonForwards(dustHTLCSet) if err != nil { return StateError, closeTx, err @@ -1306,7 +1306,7 @@ func (c *ChannelArbitrator) stateStep( return htlc.HtlcIndex } remoteDangling := fn.NewSet(fn.Map( - getIdx, htlcActions[HtlcFailDanglingAction], + htlcActions[HtlcFailDanglingAction], getIdx, )...) err := c.abandonForwards(remoteDangling) if err != nil { diff --git a/contractcourt/channel_arbitrator_test.go b/contractcourt/channel_arbitrator_test.go index 92ad608eb9..02e4b347c2 100644 --- a/contractcourt/channel_arbitrator_test.go +++ b/contractcourt/channel_arbitrator_test.go @@ -16,7 +16,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/kvdb" diff --git a/contractcourt/commit_sweep_resolver.go b/contractcourt/commit_sweep_resolver.go index 4b47a34294..6019a0dbc6 100644 --- a/contractcourt/commit_sweep_resolver.go +++ b/contractcourt/commit_sweep_resolver.go @@ -13,7 +13,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/sweep" diff --git a/contractcourt/contract_resolver.go b/contractcourt/contract_resolver.go index 53f4f680d0..f5a88f24e6 100644 --- a/contractcourt/contract_resolver.go +++ b/contractcourt/contract_resolver.go @@ -9,7 +9,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btclog/v2" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) var ( diff --git a/contractcourt/htlc_incoming_contest_resolver.go b/contractcourt/htlc_incoming_contest_resolver.go index 73841eb88c..e5be63cbf7 100644 --- a/contractcourt/htlc_incoming_contest_resolver.go +++ b/contractcourt/htlc_incoming_contest_resolver.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/txscript" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/invoices" diff --git a/contractcourt/htlc_lease_resolver.go b/contractcourt/htlc_lease_resolver.go index 53fa893553..9c5da6ee49 100644 --- a/contractcourt/htlc_lease_resolver.go +++ b/contractcourt/htlc_lease_resolver.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/tlv" ) diff --git a/contractcourt/htlc_outgoing_contest_resolver.go b/contractcourt/htlc_outgoing_contest_resolver.go index 2466544c98..1303d0af60 100644 --- a/contractcourt/htlc_outgoing_contest_resolver.go +++ b/contractcourt/htlc_outgoing_contest_resolver.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet" ) diff --git a/contractcourt/htlc_success_resolver.go b/contractcourt/htlc_success_resolver.go index b2716ad305..9d09f844dc 100644 --- a/contractcourt/htlc_success_resolver.go +++ b/contractcourt/htlc_success_resolver.go @@ -12,7 +12,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/labels" diff --git a/contractcourt/htlc_success_resolver_test.go b/contractcourt/htlc_success_resolver_test.go index 23023729fa..c0206d8f14 100644 --- a/contractcourt/htlc_success_resolver_test.go +++ b/contractcourt/htlc_success_resolver_test.go @@ -12,7 +12,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/kvdb" diff --git a/contractcourt/htlc_timeout_resolver.go b/contractcourt/htlc_timeout_resolver.go index 9954c3c0db..545e7c6135 100644 --- a/contractcourt/htlc_timeout_resolver.go +++ b/contractcourt/htlc_timeout_resolver.go @@ -12,7 +12,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnutils" diff --git a/contractcourt/htlc_timeout_resolver_test.go b/contractcourt/htlc_timeout_resolver_test.go index f3f23c385c..0e4f1336c2 100644 --- a/contractcourt/htlc_timeout_resolver_test.go +++ b/contractcourt/htlc_timeout_resolver_test.go @@ -14,7 +14,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/input" diff --git a/contractcourt/utxonursery.go b/contractcourt/utxonursery.go index aef906a0ad..a870683746 100644 --- a/contractcourt/utxonursery.go +++ b/contractcourt/utxonursery.go @@ -15,7 +15,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/labels" diff --git a/contractcourt/utxonursery_test.go b/contractcourt/utxonursery_test.go index 796d1ed239..f1b47cc2ca 100644 --- a/contractcourt/utxonursery_test.go +++ b/contractcourt/utxonursery_test.go @@ -18,7 +18,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntest/mock" "github.com/lightningnetwork/lnd/lnwallet" diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 41e58c404e..7db67c39ea 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -19,7 +19,7 @@ import ( "github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" diff --git a/discovery/gossiper_test.go b/discovery/gossiper_test.go index 85a4e0657e..b74f69bf0a 100644 --- a/discovery/gossiper_test.go +++ b/discovery/gossiper_test.go @@ -24,7 +24,7 @@ import ( "github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" diff --git a/funding/aux_funding.go b/funding/aux_funding.go index 492612145a..c7ef653f47 100644 --- a/funding/aux_funding.go +++ b/funding/aux_funding.go @@ -2,7 +2,7 @@ package funding import ( "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/msgmux" diff --git a/funding/manager.go b/funding/manager.go index c8a54d9588..395cccb2a6 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -23,7 +23,7 @@ import ( "github.com/lightningnetwork/lnd/chanacceptor" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/discovery" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" diff --git a/funding/manager_test.go b/funding/manager_test.go index 525f69f9a5..b6130176d1 100644 --- a/funding/manager_test.go +++ b/funding/manager_test.go @@ -27,7 +27,7 @@ import ( "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channelnotifier" "github.com/lightningnetwork/lnd/discovery" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/keychain" diff --git a/go.mod b/go.mod index 1330f9a84a..bbb421de40 100644 --- a/go.mod +++ b/go.mod @@ -36,13 +36,13 @@ require ( github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb github.com/lightningnetwork/lnd/cert v1.2.2 github.com/lightningnetwork/lnd/clock v1.1.1 - github.com/lightningnetwork/lnd/fn v1.2.5 + github.com/lightningnetwork/lnd/fn/v2 v2.0.2 github.com/lightningnetwork/lnd/healthcheck v1.2.6 github.com/lightningnetwork/lnd/kvdb v1.4.11 github.com/lightningnetwork/lnd/queue v1.1.1 github.com/lightningnetwork/lnd/sqldb v1.0.5 github.com/lightningnetwork/lnd/ticker v1.1.1 - github.com/lightningnetwork/lnd/tlv v1.2.6 + github.com/lightningnetwork/lnd/tlv v1.3.0 github.com/lightningnetwork/lnd/tor v1.1.4 github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 github.com/miekg/dns v1.1.43 diff --git a/go.sum b/go.sum index aa04dc5fce..4c452df735 100644 --- a/go.sum +++ b/go.sum @@ -456,8 +456,8 @@ github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U= github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0= github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ= -github.com/lightningnetwork/lnd/fn v1.2.5 h1:pGMz0BDUxrhvOtShD4FIysdVy+ulfFAnFvTKjZO5Pp8= -github.com/lightningnetwork/lnd/fn v1.2.5/go.mod h1:SyFohpVrARPKH3XVAJZlXdVe+IwMYc4OMAvrDY32kw0= +github.com/lightningnetwork/lnd/fn/v2 v2.0.2 h1:M7o2lYrh/zCp+lntPB3WP/rWTu5U+4ssyHW+kqNJ0fs= +github.com/lightningnetwork/lnd/fn/v2 v2.0.2/go.mod h1:TOzwrhjB/Azw1V7aa8t21ufcQmdsQOQMDtxVOQWNl8s= github.com/lightningnetwork/lnd/healthcheck v1.2.6 h1:1sWhqr93GdkWy4+6U7JxBfcyZIE78MhIHTJZfPx7qqI= github.com/lightningnetwork/lnd/healthcheck v1.2.6/go.mod h1:Mu02um4CWY/zdTOvFje7WJgJcHyX2zq/FG3MhOAiGaQ= github.com/lightningnetwork/lnd/kvdb v1.4.11 h1:fk1HMVFrsVK3xqU7q+JWHRgBltw/a2qIg1E3zazMb/8= @@ -468,8 +468,8 @@ github.com/lightningnetwork/lnd/sqldb v1.0.5 h1:ax5vBPf44tN/uD6C5+hBPBjOJ7cRMrUL github.com/lightningnetwork/lnd/sqldb v1.0.5/go.mod h1:OG09zL/PHPaBJefp4HsPz2YLUJ+zIQHbpgCtLnOx8I4= github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM= github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA= -github.com/lightningnetwork/lnd/tlv v1.2.6 h1:icvQG2yDr6k3ZuZzfRdG3EJp6pHurcuh3R6dg0gv/Mw= -github.com/lightningnetwork/lnd/tlv v1.2.6/go.mod h1:/CmY4VbItpOldksocmGT4lxiJqRP9oLxwSZOda2kzNQ= +github.com/lightningnetwork/lnd/tlv v1.3.0 h1:exS/KCPEgpOgviIttfiXAPaUqw2rHQrnUOpP7HPBPiY= +github.com/lightningnetwork/lnd/tlv v1.3.0/go.mod h1:pJuiBj1ecr1WWLOtcZ+2+hu9Ey25aJWFIsjmAoPPnmc= github.com/lightningnetwork/lnd/tor v1.1.4 h1:TUW27EXqoZCcCAQPlD4aaDfh8jMbBS9CghNz50qqwtA= github.com/lightningnetwork/lnd/tor v1.1.4/go.mod h1:qSRB8llhAK+a6kaTPWOLLXSZc6Hg8ZC0mq1sUQ/8JfI= github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw= diff --git a/graph/builder.go b/graph/builder.go index c0133e02ec..d6984af709 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -16,7 +16,7 @@ import ( "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" diff --git a/graph/db/models/channel_edge_info.go b/graph/db/models/channel_edge_info.go index 0f91e2bbec..6aa67acc6a 100644 --- a/graph/db/models/channel_edge_info.go +++ b/graph/db/models/channel_edge_info.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) // ChannelEdgeInfo represents a fully authenticated channel along with all its diff --git a/htlcswitch/interceptable_switch.go b/htlcswitch/interceptable_switch.go index c48436173f..6414c9f802 100644 --- a/htlcswitch/interceptable_switch.go +++ b/htlcswitch/interceptable_switch.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/lntypes" diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index d8f55afc69..7763a4a751 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/lntypes" diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 60062862ef..214144ac19 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -16,7 +16,7 @@ import ( "github.com/btcsuite/btclog/v2" "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/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hodl" "github.com/lightningnetwork/lnd/htlcswitch/hop" diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 80632b07e9..4e5c9478a1 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -26,7 +26,7 @@ import ( "github.com/lightningnetwork/lnd/build" "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/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hodl" "github.com/lightningnetwork/lnd/htlcswitch/hop" diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index ce791bef32..1d149fb0bf 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -24,7 +24,7 @@ import ( "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/contractcourt" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/invoices" diff --git a/htlcswitch/quiescer.go b/htlcswitch/quiescer.go index 27d0deb8c6..468ad5e708 100644 --- a/htlcswitch/quiescer.go +++ b/htlcswitch/quiescer.go @@ -6,7 +6,7 @@ import ( "time" "github.com/btcsuite/btclog/v2" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/htlcswitch/quiescer_test.go b/htlcswitch/quiescer_test.go index da08909d57..6ce9563e45 100644 --- a/htlcswitch/quiescer_test.go +++ b/htlcswitch/quiescer_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" "github.com/stretchr/testify/require" diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 1a08275ec9..3e2e9a52dd 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -17,7 +17,7 @@ import ( "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/contractcourt" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/kvdb" diff --git a/htlcswitch/switch_test.go b/htlcswitch/switch_test.go index abfb8e4d5b..8809321460 100644 --- a/htlcswitch/switch_test.go +++ b/htlcswitch/switch_test.go @@ -17,7 +17,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "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/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch/hodl" "github.com/lightningnetwork/lnd/htlcswitch/hop" diff --git a/input/input.go b/input/input.go index 088b20401f..4a9a4b55c0 100644 --- a/input/input.go +++ b/input/input.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/tlv" ) diff --git a/input/mocks.go b/input/mocks.go index bbd4550c5f..6d90bc28df 100644 --- a/input/mocks.go +++ b/input/mocks.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2/schnorr/musig2" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/tlv" diff --git a/input/script_utils.go b/input/script_utils.go index 91ca55292f..000efe9585 100644 --- a/input/script_utils.go +++ b/input/script_utils.go @@ -14,7 +14,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnutils" "golang.org/x/crypto/ripemd160" diff --git a/input/taproot.go b/input/taproot.go index 2ca6e97236..5ca4dd0c66 100644 --- a/input/taproot.go +++ b/input/taproot.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/waddrmgr" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) const ( diff --git a/input/taproot_test.go b/input/taproot_test.go index a1259be196..3a1e000374 100644 --- a/input/taproot_test.go +++ b/input/taproot_test.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lntypes" "github.com/stretchr/testify/require" diff --git a/intercepted_forward.go b/intercepted_forward.go index 791d4bd583..5cb1ca192b 100644 --- a/intercepted_forward.go +++ b/intercepted_forward.go @@ -3,7 +3,7 @@ package lnd import ( "errors" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" diff --git a/invoices/modification_interceptor.go b/invoices/modification_interceptor.go index 97e75e8cc5..58f5b63d07 100644 --- a/invoices/modification_interceptor.go +++ b/invoices/modification_interceptor.go @@ -5,7 +5,7 @@ import ( "fmt" "sync/atomic" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) var ( diff --git a/itest/lnd_funding_test.go b/itest/lnd_funding_test.go index 54180abf57..0b08da32b3 100644 --- a/itest/lnd_funding_test.go +++ b/itest/lnd_funding_test.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainreg" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/funding" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/labels" diff --git a/itest/lnd_sweep_test.go b/itest/lnd_sweep_test.go index 099014aff0..158e8768f9 100644 --- a/itest/lnd_sweep_test.go +++ b/itest/lnd_sweep_test.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/contractcourt" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" @@ -1119,9 +1119,9 @@ func testSweepHTLCs(ht *lntest.HarnessTest) { // The sweeping tx has two inputs, one from wallet, the other // from the force close tx. We now check whether the first tx // spends from the force close tx of Alice->Bob. - found := fn.Any(func(inp *wire.TxIn) bool { + found := fn.Any(txns[0].TxIn, func(inp *wire.TxIn) bool { return inp.PreviousOutPoint.Hash == abCloseTxid - }, txns[0].TxIn) + }) // If the first tx spends an outpoint from the force close tx // of Alice->Bob, then it must be the incoming HTLC sweeping diff --git a/lnrpc/devrpc/dev_server.go b/lnrpc/devrpc/dev_server.go index 60f30dd7ed..b26b144c81 100644 --- a/lnrpc/devrpc/dev_server.go +++ b/lnrpc/devrpc/dev_server.go @@ -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" diff --git a/lnrpc/marshall_utils.go b/lnrpc/marshall_utils.go index 230fea35b6..96d3342d83 100644 --- a/lnrpc/marshall_utils.go +++ b/lnrpc/marshall_utils.go @@ -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() + }, + ), + } + }, + ) } diff --git a/lnrpc/routerrpc/forward_interceptor.go b/lnrpc/routerrpc/forward_interceptor.go index 9da831ac04..72df3d0199 100644 --- a/lnrpc/routerrpc/forward_interceptor.go +++ b/lnrpc/routerrpc/forward_interceptor.go @@ -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" diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index 9421e991b6..7d73681094 100644 --- a/lnrpc/routerrpc/router_backend.go +++ b/lnrpc/routerrpc/router_backend.go @@ -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" diff --git a/lnrpc/routerrpc/router_server.go b/lnrpc/routerrpc/router_server.go index 7f1a7edf07..9499fa25a3 100644 --- a/lnrpc/routerrpc/router_server.go +++ b/lnrpc/routerrpc/router_server.go @@ -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" diff --git a/lnrpc/walletrpc/walletkit_server.go b/lnrpc/walletrpc/walletkit_server.go index c6dec6fbd5..4f477cdbd4 100644 --- a/lnrpc/walletrpc/walletkit_server.go +++ b/lnrpc/walletrpc/walletkit_server.go @@ -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 { - - return false - } + 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 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. diff --git a/lntest/harness.go b/lntest/harness.go index f96a3aadd7..8e8fcd3936 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -13,7 +13,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/go-errors/errors" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/kvdb/etcd" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" diff --git a/lntest/harness_assertion.go b/lntest/harness_assertion.go index 1b079fea16..11cbefdd5c 100644 --- a/lntest/harness_assertion.go +++ b/lntest/harness_assertion.go @@ -19,7 +19,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "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/lnrpc/routerrpc" @@ -270,7 +270,7 @@ func (h *HarnessTest) AssertNumActiveEdges(hn *node.HarnessNode, IncludeUnannounced: includeUnannounced, } resp := hn.RPC.DescribeGraph(req) - activeEdges := fn.Filter(filterDisabled, resp.Edges) + activeEdges := fn.Filter(resp.Edges, filterDisabled) total := len(activeEdges) if total-old == expected { diff --git a/lntest/miner/miner.go b/lntest/miner/miner.go index e9e380bbb3..0229d6a47f 100644 --- a/lntest/miner/miner.go +++ b/lntest/miner/miner.go @@ -17,7 +17,7 @@ import ( "github.com/btcsuite/btcd/integration/rpctest" "github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntest/node" "github.com/lightningnetwork/lnd/lntest/wait" "github.com/stretchr/testify/require" @@ -296,10 +296,7 @@ func (h *HarnessMiner) AssertTxInMempool(txid chainhash.Hash) *wire.MsgTx { return fmt.Errorf("empty mempool") } - isEqual := func(memTx chainhash.Hash) bool { - return memTx == txid - } - result := fn.Find(isEqual, mempool) + result := fn.Find(mempool, fn.Eq(txid)) if result.IsNone() { return fmt.Errorf("txid %v not found in "+ diff --git a/lntest/mock/walletcontroller.go b/lntest/mock/walletcontroller.go index 8b7ef55380..fa623bf84d 100644 --- a/lntest/mock/walletcontroller.go +++ b/lntest/mock/walletcontroller.go @@ -16,7 +16,7 @@ import ( base "github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wallet/txauthor" "github.com/btcsuite/btcwallet/wtxmgr" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" ) diff --git a/lntest/node/state.go b/lntest/node/state.go index a89ab7d2cc..38f02f3a4c 100644 --- a/lntest/node/state.go +++ b/lntest/node/state.go @@ -7,7 +7,7 @@ import ( "time" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc/walletrpc" "github.com/lightningnetwork/lnd/lntest/rpc" @@ -324,11 +324,11 @@ func (s *State) updateEdgeStats() { req := &lnrpc.ChannelGraphRequest{IncludeUnannounced: true} resp := s.rpc.DescribeGraph(req) - s.Edge.Total = len(fn.Filter(filterDisabled, resp.Edges)) + s.Edge.Total = len(fn.Filter(resp.Edges, filterDisabled)) req = &lnrpc.ChannelGraphRequest{IncludeUnannounced: false} resp = s.rpc.DescribeGraph(req) - s.Edge.Public = len(fn.Filter(filterDisabled, resp.Edges)) + s.Edge.Public = len(fn.Filter(resp.Edges, filterDisabled)) } // updateWalletBalance creates stats for the node's wallet balance. diff --git a/lnwallet/aux_leaf_store.go b/lnwallet/aux_leaf_store.go index c457a92509..28a78e09db 100644 --- a/lnwallet/aux_leaf_store.go +++ b/lnwallet/aux_leaf_store.go @@ -5,7 +5,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" diff --git a/lnwallet/aux_resolutions.go b/lnwallet/aux_resolutions.go index 382232640d..b36e2d6368 100644 --- a/lnwallet/aux_resolutions.go +++ b/lnwallet/aux_resolutions.go @@ -4,7 +4,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/tlv" diff --git a/lnwallet/aux_signer.go b/lnwallet/aux_signer.go index 01abe1aae3..510b64b5d1 100644 --- a/lnwallet/aux_signer.go +++ b/lnwallet/aux_signer.go @@ -2,7 +2,7 @@ package lnwallet import ( "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwire" diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 5d28574cbe..b9a909fbd3 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -27,7 +27,7 @@ import ( "github.com/btcsuite/btcwallet/wtxmgr" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/blockcache" - "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/kvdb" diff --git a/lnwallet/chainfee/filtermanager.go b/lnwallet/chainfee/filtermanager.go index 26fa56aef1..2d6fd0a2e1 100644 --- a/lnwallet/chainfee/filtermanager.go +++ b/lnwallet/chainfee/filtermanager.go @@ -9,7 +9,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/rpcclient" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) const ( diff --git a/lnwallet/chancloser/aux_closer.go b/lnwallet/chancloser/aux_closer.go index 8b1c445ca3..62f475dd43 100644 --- a/lnwallet/chancloser/aux_closer.go +++ b/lnwallet/chancloser/aux_closer.go @@ -4,7 +4,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/tlv" diff --git a/lnwallet/chancloser/chancloser.go b/lnwallet/chancloser/chancloser.go index 17112b29e0..398a8a9f3e 100644 --- a/lnwallet/chancloser/chancloser.go +++ b/lnwallet/chancloser/chancloser.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/labels" diff --git a/lnwallet/chancloser/chancloser_test.go b/lnwallet/chancloser/chancloser_test.go index 28709fd5f8..fe71fe5e3b 100644 --- a/lnwallet/chancloser/chancloser_test.go +++ b/lnwallet/chancloser/chancloser_test.go @@ -14,7 +14,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "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/lntypes" diff --git a/lnwallet/chancloser/interface.go b/lnwallet/chancloser/interface.go index 729cdc545b..f774c81039 100644 --- a/lnwallet/chancloser/interface.go +++ b/lnwallet/chancloser/interface.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwallet" diff --git a/lnwallet/chanfunding/canned_assembler.go b/lnwallet/chanfunding/canned_assembler.go index b3457f21bf..e28cbb96d1 100644 --- a/lnwallet/chanfunding/canned_assembler.go +++ b/lnwallet/chanfunding/canned_assembler.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/keychain" ) diff --git a/lnwallet/chanfunding/interface.go b/lnwallet/chanfunding/interface.go index 3512b32ff9..e40c4a1157 100644 --- a/lnwallet/chanfunding/interface.go +++ b/lnwallet/chanfunding/interface.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wtxmgr" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet/chainfee" ) diff --git a/lnwallet/chanfunding/psbt_assembler.go b/lnwallet/chanfunding/psbt_assembler.go index f678f520fc..dd1bedd05a 100644 --- a/lnwallet/chanfunding/psbt_assembler.go +++ b/lnwallet/chanfunding/psbt_assembler.go @@ -13,7 +13,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/keychain" ) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 7f70e600c6..d190acdf5e 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -25,7 +25,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/keychain" @@ -600,7 +600,7 @@ func (lc *LightningChannel) extractPayDescs(feeRate chainfee.SatPerKWeight, htlc := htlc - auxLeaf := fn.ChainOption( + auxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.OutgoingHtlcLeaves if htlc.Incoming { @@ -1106,7 +1106,7 @@ func (lc *LightningChannel) logUpdateToPayDesc(logUpdate *channeldb.LogUpdate, feeRate, wireMsg.Amount.ToSatoshis(), remoteDustLimit, ) if !isDustRemote { - auxLeaf := fn.ChainOption( + auxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.OutgoingHtlcLeaves return leaves[pd.HtlcIndex].AuxTapLeaf @@ -2088,7 +2088,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64, // Since it is the remote breach we are reconstructing, the output // going to us will be a to-remote script with our local params. - remoteAuxLeaf := fn.ChainOption( + remoteAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { return l.RemoteAuxLeaf }, @@ -2102,7 +2102,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64, return nil, err } - localAuxLeaf := fn.ChainOption( + localAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { return l.LocalAuxLeaf }, @@ -2229,7 +2229,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64, return nil, fmt.Errorf("unable to aux resolve: %w", err) } - br.LocalResolutionBlob = resolveBlob.Option() + br.LocalResolutionBlob = resolveBlob.OkToSome() } // Similarly, if their balance exceeds the remote party's dust limit, @@ -2308,7 +2308,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64, return nil, fmt.Errorf("unable to aux resolve: %w", err) } - br.RemoteResolutionBlob = resolveBlob.Option() + br.RemoteResolutionBlob = resolveBlob.OkToSome() } // Finally, with all the necessary data constructed, we can pad the @@ -2338,7 +2338,7 @@ func createHtlcRetribution(chanState *channeldb.OpenChannel, // We'll generate the original second level witness script now, as // we'll need it if we're revoking an HTLC output on the remote // commitment transaction, and *they* go to the second level. - secondLevelAuxLeaf := fn.ChainOption( + secondLevelAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) fn.Option[input.AuxTapLeaf] { return fn.MapOption(func(val uint16) input.AuxTapLeaf { idx := input.HtlcIndex(val) @@ -2366,7 +2366,7 @@ func createHtlcRetribution(chanState *channeldb.OpenChannel, // HTLC script. Otherwise, is this was an outgoing HTLC that we sent, // then from the PoV of the remote commitment state, they're the // receiver of this HTLC. - htlcLeaf := fn.ChainOption( + htlcLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) fn.Option[input.AuxTapLeaf] { return fn.MapOption(func(val uint16) input.AuxTapLeaf { idx := input.HtlcIndex(val) @@ -2693,13 +2693,13 @@ type HtlcView struct { // AuxOurUpdates returns the outgoing HTLCs as a read-only copy of // AuxHtlcDescriptors. func (v *HtlcView) AuxOurUpdates() []AuxHtlcDescriptor { - return fn.Map(newAuxHtlcDescriptor, v.Updates.Local) + return fn.Map(v.Updates.Local, newAuxHtlcDescriptor) } // AuxTheirUpdates returns the incoming HTLCs as a read-only copy of // AuxHtlcDescriptors. func (v *HtlcView) AuxTheirUpdates() []AuxHtlcDescriptor { - return fn.Map(newAuxHtlcDescriptor, v.Updates.Remote) + return fn.Map(v.Updates.Remote, newAuxHtlcDescriptor) } // fetchHTLCView returns all the candidate HTLC updates which should be @@ -2917,9 +2917,9 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, // The fee rate of our view is always the last UpdateFee message from // the channel's OpeningParty. openerUpdates := view.Updates.GetForParty(lc.channelState.Initiator()) - feeUpdates := fn.Filter(func(u *paymentDescriptor) bool { + feeUpdates := fn.Filter(openerUpdates, func(u *paymentDescriptor) bool { return u.EntryType == FeeUpdate - }, openerUpdates) + }) lastFeeUpdate := fn.Last(feeUpdates) lastFeeUpdate.WhenSome(func(pd *paymentDescriptor) { newView.FeePerKw = chainfee.SatPerKWeight( @@ -2942,14 +2942,17 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, for _, party := range parties { // First we run through non-add entries in both logs, // populating the skip sets. - resolutions := fn.Filter(func(pd *paymentDescriptor) bool { - switch pd.EntryType { - case Settle, Fail, MalformedFail: - return true - default: - return false - } - }, view.Updates.GetForParty(party)) + resolutions := fn.Filter( + view.Updates.GetForParty(party), + func(pd *paymentDescriptor) bool { + switch pd.EntryType { + case Settle, Fail, MalformedFail: + return true + default: + return false + } + }, + ) for _, entry := range resolutions { addEntry, err := lc.fetchParent( @@ -3002,10 +3005,16 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, // settled HTLCs, and debiting the chain state balance due to any newly // added HTLCs. for _, party := range parties { - liveAdds := fn.Filter(func(pd *paymentDescriptor) bool { - return pd.EntryType == Add && - !skip.GetForParty(party).Contains(pd.HtlcIndex) - }, view.Updates.GetForParty(party)) + liveAdds := fn.Filter( + view.Updates.GetForParty(party), + func(pd *paymentDescriptor) bool { + isAdd := pd.EntryType == Add + shouldSkip := skip.GetForParty(party). + Contains(pd.HtlcIndex) + + return isAdd && !shouldSkip + }, + ) for _, entry := range liveAdds { // Skip the entries that have already had their add @@ -3063,7 +3072,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView, uncommittedUpdates := lntypes.MapDual( view.Updates, func(us []*paymentDescriptor) []*paymentDescriptor { - return fn.Filter(isUncommitted, us) + return fn.Filter(us, isUncommitted) }, ) @@ -3189,7 +3198,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, htlcFee := HtlcTimeoutFee(chanType, feePerKw) outputAmt := htlc.Amount.ToSatoshis() - htlcFee - auxLeaf := fn.ChainOption( + auxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.IncomingHtlcLeaves return leaves[htlc.HtlcIndex].SecondLevelLeaf @@ -3270,7 +3279,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, htlcFee := HtlcSuccessFee(chanType, feePerKw) outputAmt := htlc.Amount.ToSatoshis() - htlcFee - auxLeaf := fn.ChainOption( + auxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.OutgoingHtlcLeaves return leaves[htlc.HtlcIndex].SecondLevelLeaf @@ -4802,7 +4811,7 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel, htlcFee := HtlcSuccessFee(chanType, feePerKw) outputAmt := htlc.Amount.ToSatoshis() - htlcFee - auxLeaf := fn.ChainOption(func( + auxLeaf := fn.FlatMapOption(func( l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.IncomingHtlcLeaves @@ -4895,7 +4904,7 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel, htlcFee := HtlcTimeoutFee(chanType, feePerKw) outputAmt := htlc.Amount.ToSatoshis() - htlcFee - auxLeaf := fn.ChainOption(func( + auxLeaf := fn.FlatMapOption(func( l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.OutgoingHtlcLeaves @@ -6766,7 +6775,7 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, //nolint:funlen // Before we can generate the proper sign descriptor, we'll need to // locate the output index of our non-delayed output on the commitment // transaction. - remoteAuxLeaf := fn.ChainOption( + remoteAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { return l.RemoteAuxLeaf }, @@ -6870,7 +6879,7 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, //nolint:funlen return nil, fmt.Errorf("unable to aux resolve: %w", err) } - commitResolution.ResolutionBlob = resolveBlob.Option() + commitResolution.ResolutionBlob = resolveBlob.OkToSome() } closeSummary := channeldb.ChannelCloseSummary{ @@ -7059,7 +7068,7 @@ func newOutgoingHtlcResolution(signer input.Signer, // First, we'll re-generate the script used to send the HTLC to the // remote party within their commitment transaction. - auxLeaf := fn.ChainOption(func(l CommitAuxLeaves) input.AuxTapLeaf { + auxLeaf := fn.FlatMapOption(func(l CommitAuxLeaves) input.AuxTapLeaf { return l.OutgoingHtlcLeaves[htlc.HtlcIndex].AuxTapLeaf })(auxLeaves) htlcScriptInfo, err := genHtlcScript( @@ -7149,7 +7158,7 @@ func newOutgoingHtlcResolution(signer input.Signer, return nil, fmt.Errorf("unable to aux resolve: %w", err) } - resolutionBlob := resolveRes.Option() + resolutionBlob := resolveRes.OkToSome() return &OutgoingHtlcResolution{ Expiry: htlc.RefundTimeout, @@ -7171,7 +7180,7 @@ func newOutgoingHtlcResolution(signer input.Signer, // With the fee calculated, re-construct the second level timeout // transaction. - secondLevelAuxLeaf := fn.ChainOption( + secondLevelAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.OutgoingHtlcLeaves return leaves[htlc.HtlcIndex].SecondLevelLeaf @@ -7366,7 +7375,7 @@ func newOutgoingHtlcResolution(signer input.Signer, if err := resolveRes.Err(); err != nil { return nil, fmt.Errorf("unable to aux resolve: %w", err) } - resolutionBlob := resolveRes.Option() + resolutionBlob := resolveRes.OkToSome() return &OutgoingHtlcResolution{ Expiry: htlc.RefundTimeout, @@ -7406,7 +7415,7 @@ func newIncomingHtlcResolution(signer input.Signer, // First, we'll re-generate the script the remote party used to // send the HTLC to us in their commitment transaction. - auxLeaf := fn.ChainOption(func(l CommitAuxLeaves) input.AuxTapLeaf { + auxLeaf := fn.FlatMapOption(func(l CommitAuxLeaves) input.AuxTapLeaf { return l.IncomingHtlcLeaves[htlc.HtlcIndex].AuxTapLeaf })(auxLeaves) scriptInfo, err := genHtlcScript( @@ -7497,7 +7506,7 @@ func newIncomingHtlcResolution(signer input.Signer, return nil, fmt.Errorf("unable to aux resolve: %w", err) } - resolutionBlob := resolveRes.Option() + resolutionBlob := resolveRes.OkToSome() return &IncomingHtlcResolution{ ClaimOutpoint: op, @@ -7507,7 +7516,7 @@ func newIncomingHtlcResolution(signer input.Signer, }, nil } - secondLevelAuxLeaf := fn.ChainOption( + secondLevelAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { leaves := l.IncomingHtlcLeaves return leaves[htlc.HtlcIndex].SecondLevelLeaf @@ -7707,7 +7716,7 @@ func newIncomingHtlcResolution(signer input.Signer, return nil, fmt.Errorf("unable to aux resolve: %w", err) } - resolutionBlob := resolveRes.Option() + resolutionBlob := resolveRes.OkToSome() return &IncomingHtlcResolution{ SignedSuccessTx: successTx, @@ -8011,7 +8020,7 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel, leaseExpiry = chanState.ThawHeight } - localAuxLeaf := fn.ChainOption( + localAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { return l.LocalAuxLeaf }, @@ -8126,7 +8135,7 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel, return nil, fmt.Errorf("unable to aux resolve: %w", err) } - commitResolution.ResolutionBlob = resolveBlob.Option() + commitResolution.ResolutionBlob = resolveBlob.OkToSome() } // Once the delay output has been found (if it exists), then we'll also diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index f7ecd32277..d0caa97812 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -25,7 +25,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" @@ -730,9 +730,12 @@ func TestCommitHTLCSigCustomRecordSize(t *testing.T) { // Replace the default PackSigs implementation to return a // large custom records blob. - mockSigner.ExpectedCalls = fn.Filter(func(c *mock.Call) bool { - return c.Method != "PackSigs" - }, mockSigner.ExpectedCalls) + mockSigner.ExpectedCalls = fn.Filter( + mockSigner.ExpectedCalls, + func(c *mock.Call) bool { + return c.Method != "PackSigs" + }, + ) mockSigner.On("PackSigs", mock.Anything). Return(fn.Ok(fn.Some(largeBlob))) }) diff --git a/lnwallet/commitment.go b/lnwallet/commitment.go index 8b364a01df..787e8a71e1 100644 --- a/lnwallet/commitment.go +++ b/lnwallet/commitment.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwallet/chainfee" @@ -836,7 +836,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance, continue } - auxLeaf := fn.ChainOption( + auxLeaf := fn.FlatMapOption( func(leaves input.HtlcAuxLeaves) input.AuxTapLeaf { return leaves[htlc.HtlcIndex].AuxTapLeaf }, @@ -864,7 +864,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance, continue } - auxLeaf := fn.ChainOption( + auxLeaf := fn.FlatMapOption( func(leaves input.HtlcAuxLeaves) input.AuxTapLeaf { return leaves[htlc.HtlcIndex].AuxTapLeaf }, @@ -1323,7 +1323,7 @@ func findOutputIndexesFromRemote(revocationPreimage *chainhash.Hash, // Compute the to_local script. From our PoV, when facing a remote // commitment, the to_local output belongs to them. - localAuxLeaf := fn.ChainOption( + localAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { return l.LocalAuxLeaf }, @@ -1338,7 +1338,7 @@ func findOutputIndexesFromRemote(revocationPreimage *chainhash.Hash, // Compute the to_remote script. From our PoV, when facing a remote // commitment, the to_remote output belongs to us. - remoteAuxLeaf := fn.ChainOption( + remoteAuxLeaf := fn.FlatMapOption( func(l CommitAuxLeaves) input.AuxTapLeaf { return l.RemoteAuxLeaf }, diff --git a/lnwallet/commitment_chain.go b/lnwallet/commitment_chain.go index fa2abe0aa2..871a139c5c 100644 --- a/lnwallet/commitment_chain.go +++ b/lnwallet/commitment_chain.go @@ -1,7 +1,7 @@ package lnwallet import ( - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) // commitmentChain represents a chain of unrevoked commitments. The tail of the diff --git a/lnwallet/config.go b/lnwallet/config.go index 425fe15dad..c60974be6d 100644 --- a/lnwallet/config.go +++ b/lnwallet/config.go @@ -5,7 +5,7 @@ import ( "github.com/btcsuite/btcwallet/wallet" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "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/lnwallet/chainfee" diff --git a/lnwallet/interface.go b/lnwallet/interface.go index c9dee9202a..64f8546310 100644 --- a/lnwallet/interface.go +++ b/lnwallet/interface.go @@ -19,7 +19,7 @@ import ( base "github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wallet/txauthor" "github.com/btcsuite/btcwallet/wtxmgr" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chanvalidate" diff --git a/lnwallet/mock.go b/lnwallet/mock.go index a8610dc779..39e520d276 100644 --- a/lnwallet/mock.go +++ b/lnwallet/mock.go @@ -18,7 +18,7 @@ import ( "github.com/btcsuite/btcwallet/wtxmgr" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/tlv" diff --git a/lnwallet/musig_session.go b/lnwallet/musig_session.go index 822aa48a14..748e5fa958 100644 --- a/lnwallet/musig_session.go +++ b/lnwallet/musig_session.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "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/lnwire" diff --git a/lnwallet/reservation.go b/lnwallet/reservation.go index fd35d95076..a8a0cacd4b 100644 --- a/lnwallet/reservation.go +++ b/lnwallet/reservation.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "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/lntypes" diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index bf6aa61df3..426712b597 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -22,7 +22,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/waddrmgr" basewallet "github.com/btcsuite/btcwallet/wallet" - "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/lncfg" diff --git a/lnwallet/test/test_interface.go b/lnwallet/test/test_interface.go index c006aa2e50..27de51708c 100644 --- a/lnwallet/test/test_interface.go +++ b/lnwallet/test/test_interface.go @@ -34,7 +34,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs/btcdnotify" "github.com/lightningnetwork/lnd/channeldb" - "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/kvdb" diff --git a/lnwallet/test_utils.go b/lnwallet/test_utils.go index ff9adfbd79..738558e224 100644 --- a/lnwallet/test_utils.go +++ b/lnwallet/test_utils.go @@ -16,7 +16,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "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/lntypes" diff --git a/lnwallet/transactions_test.go b/lnwallet/transactions_test.go index 135d1866bc..38131eaa72 100644 --- a/lnwallet/transactions_test.go +++ b/lnwallet/transactions_test.go @@ -21,7 +21,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "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/lntypes" diff --git a/lnwallet/update_log.go b/lnwallet/update_log.go index 2d1f65c9fa..b2b8af58d1 100644 --- a/lnwallet/update_log.go +++ b/lnwallet/update_log.go @@ -1,7 +1,7 @@ package lnwallet import ( - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" ) // updateLog is an append-only log that stores updates to a node's commitment diff --git a/lnwallet/wallet.go b/lnwallet/wallet.go index ad6354e2e8..96ea85cf9e 100644 --- a/lnwallet/wallet.go +++ b/lnwallet/wallet.go @@ -23,7 +23,7 @@ import ( "github.com/btcsuite/btcwallet/wallet" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/channeldb" - "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/lntypes" diff --git a/lnwire/channel_reestablish.go b/lnwire/channel_reestablish.go index e523279498..577379623f 100644 --- a/lnwire/channel_reestablish.go +++ b/lnwire/channel_reestablish.go @@ -5,7 +5,7 @@ import ( "io" "github.com/btcsuite/btcd/btcec/v2" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" ) diff --git a/lnwire/custom_records.go b/lnwire/custom_records.go index 8177cbe821..a63aa5dfb0 100644 --- a/lnwire/custom_records.go +++ b/lnwire/custom_records.go @@ -6,7 +6,7 @@ import ( "io" "sort" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" ) @@ -179,9 +179,12 @@ func (c CustomRecords) SerializeTo(w io.Writer) error { // ProduceRecordsSorted converts a slice of record producers into a slice of // records and then sorts it by type. func ProduceRecordsSorted(recordProducers ...tlv.RecordProducer) []tlv.Record { - records := fn.Map(func(producer tlv.RecordProducer) tlv.Record { - return producer.Record() - }, recordProducers) + records := fn.Map( + recordProducers, + func(producer tlv.RecordProducer) tlv.Record { + return producer.Record() + }, + ) // Ensure that the set of records are sorted before we attempt to // decode from the stream, to ensure they're canonical. @@ -212,9 +215,9 @@ func TlvMapToRecords(tlvMap tlv.TypeMap) []tlv.Record { // RecordsAsProducers converts a slice of records into a slice of record // producers. func RecordsAsProducers(records []tlv.Record) []tlv.RecordProducer { - return fn.Map(func(record tlv.Record) tlv.RecordProducer { + return fn.Map(records, func(record tlv.Record) tlv.RecordProducer { return &record - }, records) + }) } // EncodeRecords encodes the given records into a byte slice. diff --git a/lnwire/custom_records_test.go b/lnwire/custom_records_test.go index 8ff6af10ba..d4aad2e546 100644 --- a/lnwire/custom_records_test.go +++ b/lnwire/custom_records_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -182,9 +182,12 @@ func TestCustomRecordsExtendRecordProducers(t *testing.T) { func serializeRecordProducers(t *testing.T, producers []tlv.RecordProducer) []byte { - tlvRecords := fn.Map(func(p tlv.RecordProducer) tlv.Record { - return p.Record() - }, producers) + tlvRecords := fn.Map( + producers, + func(p tlv.RecordProducer) tlv.Record { + return p.Record() + }, + ) stream, err := tlv.NewStream(tlvRecords...) require.NoError(t, err) diff --git a/lnwire/dyn_ack.go b/lnwire/dyn_ack.go index 24f23a228d..d477461e7b 100644 --- a/lnwire/dyn_ack.go +++ b/lnwire/dyn_ack.go @@ -5,7 +5,7 @@ import ( "io" "github.com/btcsuite/btcd/btcec/v2/schnorr/musig2" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" ) diff --git a/lnwire/dyn_propose.go b/lnwire/dyn_propose.go index b0cc1198e9..394fff6f37 100644 --- a/lnwire/dyn_propose.go +++ b/lnwire/dyn_propose.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/tlv" ) diff --git a/lnwire/extra_bytes.go b/lnwire/extra_bytes.go index c4ca260e1e..4681426cbb 100644 --- a/lnwire/extra_bytes.go +++ b/lnwire/extra_bytes.go @@ -5,7 +5,7 @@ import ( "fmt" "io" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" ) diff --git a/lnwire/lnwire_test.go b/lnwire/lnwire_test.go index 952e90a7e6..6bfbb465ec 100644 --- a/lnwire/lnwire_test.go +++ b/lnwire/lnwire_test.go @@ -22,7 +22,7 @@ import ( "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tor" diff --git a/lnwire/onion_error.go b/lnwire/onion_error.go index 5f05e1ef9f..7b65a85f4e 100644 --- a/lnwire/onion_error.go +++ b/lnwire/onion_error.go @@ -10,7 +10,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/go-errors/errors" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/tlv" ) diff --git a/lnwire/onion_error_test.go b/lnwire/onion_error_test.go index 9c39be6d5c..5c3d0291a5 100644 --- a/lnwire/onion_error_test.go +++ b/lnwire/onion_error_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/davecgh/go-spew/spew" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/stretchr/testify/require" ) diff --git a/msgmux/msg_router.go b/msgmux/msg_router.go index db9e783990..736c085a95 100644 --- a/msgmux/msg_router.go +++ b/msgmux/msg_router.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/btcsuite/btcd/btcec/v2" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" ) @@ -91,8 +91,8 @@ func sendQueryErr[Q any](sendChan chan fn.Req[Q, error], queryArg Q, quitChan chan struct{}) error { return fn.ElimEither( - fn.Iden, fn.Iden, sendQuery(sendChan, queryArg, quitChan).Either, + fn.Iden, fn.Iden, ) } diff --git a/peer/brontide.go b/peer/brontide.go index 6bc49445ee..f8ac00aa20 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -26,7 +26,7 @@ import ( "github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/feature" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/funding" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" diff --git a/peer/brontide_test.go b/peer/brontide_test.go index c3d1bee48b..eded658887 100644 --- a/peer/brontide_test.go +++ b/peer/brontide_test.go @@ -13,7 +13,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "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/htlcswitch" "github.com/lightningnetwork/lnd/lntest/wait" "github.com/lightningnetwork/lnd/lnwallet" diff --git a/peer/musig_chan_closer.go b/peer/musig_chan_closer.go index 6f69a8c5b8..149ebcfa0c 100644 --- a/peer/musig_chan_closer.go +++ b/peer/musig_chan_closer.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/btcsuite/btcd/btcec/v2/schnorr/musig2" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chancloser" diff --git a/peer/test_utils.go b/peer/test_utils.go index eb510a53b1..34c42e2f7c 100644 --- a/peer/test_utils.go +++ b/peer/test_utils.go @@ -18,7 +18,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channelnotifier" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/input" diff --git a/protofsm/daemon_events.go b/protofsm/daemon_events.go index e5de0b6951..bca7283d39 100644 --- a/protofsm/daemon_events.go +++ b/protofsm/daemon_events.go @@ -5,7 +5,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/protofsm/msg_mapper.go b/protofsm/msg_mapper.go index b96d677e6b..5e24255fa3 100644 --- a/protofsm/msg_mapper.go +++ b/protofsm/msg_mapper.go @@ -1,7 +1,7 @@ package protofsm import ( - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/protofsm/state_machine.go b/protofsm/state_machine.go index b71d5efe42..a81f5746b2 100644 --- a/protofsm/state_machine.go +++ b/protofsm/state_machine.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnwire" ) @@ -21,6 +21,12 @@ const ( pollInterval = time.Millisecond * 100 ) +var ( + // ErrStateMachineShutdown occurs when trying to feed an event to a + // StateMachine that has been asked to Stop. + ErrStateMachineShutdown = fmt.Errorf("StateMachine is shutting down") +) + // EmittedEvent is a special type that can be emitted by a state transition. // This can container internal events which are to be routed back to the state, // or external events which are to be sent to the daemon. @@ -287,7 +293,7 @@ func (s *StateMachine[Event, Env]) CurrentState() (State[Event, Env], error) { } if !fn.SendOrQuit(s.stateQuery, query, s.quit) { - return nil, fmt.Errorf("state machine is shutting down") + return nil, ErrStateMachineShutdown } return fn.RecvOrTimeout(query.CurrentState, time.Second) @@ -322,6 +328,8 @@ func (s *StateMachine[Event, Env]) RemoveStateSub(sub StateSubscriber[ // executeDaemonEvent executes a daemon event, which is a special type of event // that can be emitted as part of the state transition function of the state // machine. An error is returned if the type of event is unknown. +// +//nolint:funlen func (s *StateMachine[Event, Env]) executeDaemonEvent( event DaemonEvent) error { @@ -347,7 +355,7 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( // If a post-send event was specified, then we'll funnel // that back into the main state machine now as well. return fn.MapOptionZ(daemonEvent.PostSendEvent, func(event Event) error { //nolint:ll - return s.wg.Go(func(ctx context.Context) { + launched := s.wg.Go(func(ctx context.Context) { log.Debugf("FSM(%v): sending "+ "post-send event: %v", s.cfg.Env.Name(), @@ -356,6 +364,12 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( s.SendEvent(event) }) + + if !launched { + return ErrStateMachineShutdown + } + + return nil }) } @@ -368,7 +382,7 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( // Otherwise, this has a SendWhen predicate, so we'll need // launch a goroutine to poll the SendWhen, then send only once // the predicate is true. - return s.wg.Go(func(ctx context.Context) { + launched := s.wg.Go(func(ctx context.Context) { predicateTicker := time.NewTicker( s.cfg.CustomPollInterval.UnwrapOr(pollInterval), ) @@ -407,6 +421,12 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( } }) + if !launched { + return ErrStateMachineShutdown + } + + return nil + // If this is a broadcast transaction event, then we'll broadcast with // the label attached. case *BroadcastTxn: @@ -436,7 +456,7 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( return fmt.Errorf("unable to register spend: %w", err) } - return s.wg.Go(func(ctx context.Context) { + launched := s.wg.Go(func(ctx context.Context) { for { select { case spend, ok := <-spendEvent.Spend: @@ -461,6 +481,12 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( } }) + if !launched { + return ErrStateMachineShutdown + } + + return nil + // The state machine has requested a new event to be sent once a // specified txid+pkScript pair has confirmed. case *RegisterConf[Event]: @@ -476,7 +502,7 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( return fmt.Errorf("unable to register conf: %w", err) } - return s.wg.Go(func(ctx context.Context) { + launched := s.wg.Go(func(ctx context.Context) { for { select { case <-confEvent.Confirmed: @@ -498,6 +524,12 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( } } }) + + if !launched { + return ErrStateMachineShutdown + } + + return nil } return fmt.Errorf("unknown daemon event: %T", event) diff --git a/protofsm/state_machine_test.go b/protofsm/state_machine_test.go index fc30fcefc3..fc7a4ccfdc 100644 --- a/protofsm/state_machine_test.go +++ b/protofsm/state_machine_test.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" diff --git a/routing/bandwidth.go b/routing/bandwidth.go index 12e82131dc..c816ed3410 100644 --- a/routing/bandwidth.go +++ b/routing/bandwidth.go @@ -3,7 +3,7 @@ package routing import ( "fmt" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/lnwire" diff --git a/routing/bandwidth_test.go b/routing/bandwidth_test.go index 4872b5a7ec..7469bc84c6 100644 --- a/routing/bandwidth_test.go +++ b/routing/bandwidth_test.go @@ -5,7 +5,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/go-errors/errors" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/tlv" diff --git a/routing/blinding.go b/routing/blinding.go index 7c84063469..0c27e87439 100644 --- a/routing/blinding.go +++ b/routing/blinding.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" sphinx "github.com/lightningnetwork/lightning-onion" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" diff --git a/routing/blinding_test.go b/routing/blinding_test.go index 410dfaf643..8f83f7fd82 100644 --- a/routing/blinding_test.go +++ b/routing/blinding_test.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" sphinx "github.com/lightningnetwork/lightning-onion" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" diff --git a/routing/integrated_routing_context_test.go b/routing/integrated_routing_context_test.go index 315b0dff22..e4241dac53 100644 --- a/routing/integrated_routing_context_test.go +++ b/routing/integrated_routing_context_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnwire" diff --git a/routing/localchans/manager.go b/routing/localchans/manager.go index d7380439ac..cd9e58fcaa 100644 --- a/routing/localchans/manager.go +++ b/routing/localchans/manager.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/discovery" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnwire" diff --git a/routing/missioncontrol.go b/routing/missioncontrol.go index de892392e7..3bc9be7aba 100644 --- a/routing/missioncontrol.go +++ b/routing/missioncontrol.go @@ -13,7 +13,7 @@ import ( "github.com/btcsuite/btcwallet/walletdb" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" diff --git a/routing/mock_test.go b/routing/mock_test.go index 3cdb5ebaf2..2575514102 100644 --- a/routing/mock_test.go +++ b/routing/mock_test.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/channeldb" - "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/lntypes" diff --git a/routing/pathfind.go b/routing/pathfind.go index 8e40c5bc4b..80f4b1e68f 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/btcutil" sphinx "github.com/lightningnetwork/lightning-onion" "github.com/lightningnetwork/lnd/feature" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/lnutils" diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index da29c79a25..c463b8135b 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -21,7 +21,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" sphinx "github.com/lightningnetwork/lightning-onion" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/htlcswitch" diff --git a/routing/payment_lifecycle.go b/routing/payment_lifecycle.go index 267ce3965d..292397d9df 100644 --- a/routing/payment_lifecycle.go +++ b/routing/payment_lifecycle.go @@ -10,7 +10,7 @@ import ( "github.com/davecgh/go-spew/spew" sphinx "github.com/lightningnetwork/lightning-onion" "github.com/lightningnetwork/lnd/channeldb" - "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/lntypes" diff --git a/routing/payment_lifecycle_test.go b/routing/payment_lifecycle_test.go index 315c1bad58..98fe7ffd21 100644 --- a/routing/payment_lifecycle_test.go +++ b/routing/payment_lifecycle_test.go @@ -9,7 +9,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/go-errors/errors" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/lnmock" "github.com/lightningnetwork/lnd/lntest/wait" diff --git a/routing/payment_session_source.go b/routing/payment_session_source.go index d5f1a6af41..240f801e78 100644 --- a/routing/payment_session_source.go +++ b/routing/payment_session_source.go @@ -2,7 +2,7 @@ package routing import ( "github.com/btcsuite/btcd/btcec/v2" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" diff --git a/routing/result_interpretation.go b/routing/result_interpretation.go index 089213d65e..bc1749dfb1 100644 --- a/routing/result_interpretation.go +++ b/routing/result_interpretation.go @@ -6,7 +6,7 @@ import ( "io" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/tlv" @@ -578,7 +578,7 @@ func extractMCRoute(r *route.Route) *mcRoute { // extractMCHops extracts the Hop fields that MC actually uses from a slice of // Hops. func extractMCHops(hops []*route.Hop) mcHops { - return fn.Map(extractMCHop, hops) + return fn.Map(hops, extractMCHop) } // extractMCHop extracts the Hop fields that MC actually uses from a Hop. diff --git a/routing/result_interpretation_test.go b/routing/result_interpretation_test.go index b213eb1835..8c67bdeea9 100644 --- a/routing/result_interpretation_test.go +++ b/routing/result_interpretation_test.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/davecgh/go-spew/spew" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/route" ) diff --git a/routing/router.go b/routing/router.go index 9eabe0b2ae..0b3c90c321 100644 --- a/routing/router.go +++ b/routing/router.go @@ -19,7 +19,7 @@ import ( "github.com/lightningnetwork/lnd/amp" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" - "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/lntypes" diff --git a/routing/router_test.go b/routing/router_test.go index 2923f1fb90..0824146d1e 100644 --- a/routing/router_test.go +++ b/routing/router_test.go @@ -23,7 +23,7 @@ import ( sphinx "github.com/lightningnetwork/lightning-onion" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/clock" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/graph" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/graph/db/models" diff --git a/rpcserver.go b/rpcserver.go index d7d2e0186c..72e2fa4afd 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -46,7 +46,7 @@ import ( "github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/feature" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/funding" "github.com/lightningnetwork/lnd/graph" graphdb "github.com/lightningnetwork/lnd/graph/db" @@ -8068,9 +8068,9 @@ func (r *rpcServer) VerifyChanBackup(ctx context.Context, } return &lnrpc.VerifyChanBackupResponse{ - ChanPoints: fn.Map(func(c chanbackup.Single) string { + ChanPoints: fn.Map(channels, func(c chanbackup.Single) string { return c.FundingOutpoint.String() - }, channels), + }), }, nil } diff --git a/rpcserver_test.go b/rpcserver_test.go index b4b66e719c..b686c9020a 100644 --- a/rpcserver_test.go +++ b/rpcserver_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnrpc" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/server.go b/server.go index f8f8239ed6..abf898ca31 100644 --- a/server.go +++ b/server.go @@ -39,7 +39,7 @@ import ( "github.com/lightningnetwork/lnd/contractcourt" "github.com/lightningnetwork/lnd/discovery" "github.com/lightningnetwork/lnd/feature" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/funding" "github.com/lightningnetwork/lnd/graph" graphdb "github.com/lightningnetwork/lnd/graph/db" diff --git a/subrpcserver_config.go b/subrpcserver_config.go index 30755c05e4..102e211187 100644 --- a/subrpcserver_config.go +++ b/subrpcserver_config.go @@ -11,7 +11,7 @@ import ( "github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/chainreg" "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" graphdb "github.com/lightningnetwork/lnd/graph/db" "github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/invoices" diff --git a/sweep/aggregator.go b/sweep/aggregator.go index a0a1b0a540..e97ccb9a21 100644 --- a/sweep/aggregator.go +++ b/sweep/aggregator.go @@ -5,7 +5,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwallet" diff --git a/sweep/aggregator_test.go b/sweep/aggregator_test.go index 6df0d73fa2..2cb89bdc38 100644 --- a/sweep/aggregator_test.go +++ b/sweep/aggregator_test.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lnwallet/chainfee" diff --git a/sweep/fee_bumper.go b/sweep/fee_bumper.go index adb4db65ed..7bb58ae29e 100644 --- a/sweep/fee_bumper.go +++ b/sweep/fee_bumper.go @@ -13,7 +13,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/chain" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/labels" "github.com/lightningnetwork/lnd/lntypes" @@ -145,13 +145,13 @@ type BumpRequest struct { func (r *BumpRequest) MaxFeeRateAllowed() (chainfee.SatPerKWeight, error) { // We'll want to know if we have any blobs, as we need to factor this // into the max fee rate for this bump request. - hasBlobs := fn.Any(func(i input.Input) bool { + hasBlobs := fn.Any(r.Inputs, func(i input.Input) bool { return fn.MapOptionZ( i.ResolutionBlob(), func(b tlv.Blob) bool { return len(b) > 0 }, ) - }, r.Inputs) + }) sweepAddrs := [][]byte{ r.DeliveryAddress.DeliveryAddress, @@ -1382,7 +1382,7 @@ func prepareSweepTx(inputs []input.Input, changePkScript lnwallet.AddrWithKey, return err } - extraChangeOut = extraOut.LeftToOption() + extraChangeOut = extraOut.LeftToSome() return nil }, diff --git a/sweep/fee_bumper_test.go b/sweep/fee_bumper_test.go index 5030dee227..c9196aee5a 100644 --- a/sweep/fee_bumper_test.go +++ b/sweep/fee_bumper_test.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/chain" "github.com/lightningnetwork/lnd/chainntnfs" - "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/lnwallet" diff --git a/sweep/fee_function.go b/sweep/fee_function.go index cbf283e37d..bff44000be 100644 --- a/sweep/fee_function.go +++ b/sweep/fee_function.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/btcsuite/btcd/btcutil" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/sweep/fee_function_test.go b/sweep/fee_function_test.go index c278bb7f06..a55ce79a78 100644 --- a/sweep/fee_function_test.go +++ b/sweep/fee_function_test.go @@ -3,7 +3,7 @@ package sweep import ( "testing" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/stretchr/testify/require" ) diff --git a/sweep/interface.go b/sweep/interface.go index f2fff84b08..6c8c2cfad2 100644 --- a/sweep/interface.go +++ b/sweep/interface.go @@ -4,7 +4,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "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/lnwallet" diff --git a/sweep/mock_test.go b/sweep/mock_test.go index 34202b1453..eeeb283969 100644 --- a/sweep/mock_test.go +++ b/sweep/mock_test.go @@ -4,7 +4,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "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/lnwallet" diff --git a/sweep/sweeper.go b/sweep/sweeper.go index 6257faac1f..9eeefc94b8 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnwallet" diff --git a/sweep/sweeper_test.go b/sweep/sweeper_test.go index 2b61f67933..7d99ba93b9 100644 --- a/sweep/sweeper_test.go +++ b/sweep/sweeper_test.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" diff --git a/sweep/tx_input_set.go b/sweep/tx_input_set.go index ce144a8eb3..adae7cf131 100644 --- a/sweep/tx_input_set.go +++ b/sweep/tx_input_set.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" @@ -141,7 +141,7 @@ func validateInputs(inputs []SweeperInput, deadlineHeight int32) error { // dedupInputs is a set used to track unique outpoints of the inputs. dedupInputs := fn.NewSet( // Iterate all the inputs and map the function. - fn.Map(func(inp SweeperInput) wire.OutPoint { + fn.Map(inputs, func(inp SweeperInput) wire.OutPoint { // If the input has a deadline height, we'll check if // it's the same as the specified. inp.params.DeadlineHeight.WhenSome(func(h int32) { @@ -156,7 +156,7 @@ func validateInputs(inputs []SweeperInput, deadlineHeight int32) error { }) return inp.OutPoint() - }, inputs)..., + })..., ) // Make sure the inputs share the same deadline height when there is diff --git a/sweep/tx_input_set_test.go b/sweep/tx_input_set_test.go index 8d0850b20d..73f056a964 100644 --- a/sweep/tx_input_set_test.go +++ b/sweep/tx_input_set_test.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/stretchr/testify/require" diff --git a/sweep/walletsweep.go b/sweep/walletsweep.go index 81458fbfb0..3f790dc66f 100644 --- a/sweep/walletsweep.go +++ b/sweep/walletsweep.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/wtxmgr" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" diff --git a/sweep/walletsweep_test.go b/sweep/walletsweep_test.go index 968d9cb4fb..c7a5dfc221 100644 --- a/sweep/walletsweep_test.go +++ b/sweep/walletsweep_test.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcwallet/wtxmgr" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lntest/mock" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet/chainfee" diff --git a/watchtower/blob/justice_kit.go b/watchtower/blob/justice_kit.go index 7780239f07..9dc1af6258 100644 --- a/watchtower/blob/justice_kit.go +++ b/watchtower/blob/justice_kit.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" secp "github.com/decred/dcrd/dcrec/secp256k1/v4" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" diff --git a/watchtower/blob/justice_kit_test.go b/watchtower/blob/justice_kit_test.go index a1d6ec9f2c..0d23e2e0fc 100644 --- a/watchtower/blob/justice_kit_test.go +++ b/watchtower/blob/justice_kit_test.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" diff --git a/watchtower/lookout/justice_descriptor_test.go b/watchtower/lookout/justice_descriptor_test.go index 5045b4a0f4..ded2cd6031 100644 --- a/watchtower/lookout/justice_descriptor_test.go +++ b/watchtower/lookout/justice_descriptor_test.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" secp "github.com/decred/dcrd/dcrec/secp256k1/v4" - "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/lnwallet" diff --git a/watchtower/wtclient/backup_task_internal_test.go b/watchtower/wtclient/backup_task_internal_test.go index 7eb34f6e37..62d7609469 100644 --- a/watchtower/wtclient/backup_task_internal_test.go +++ b/watchtower/wtclient/backup_task_internal_test.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightningnetwork/lnd/channeldb" - "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/lnwallet" diff --git a/watchtower/wtclient/client_test.go b/watchtower/wtclient/client_test.go index f3a4d5bf4e..e842876b65 100644 --- a/watchtower/wtclient/client_test.go +++ b/watchtower/wtclient/client_test.go @@ -19,7 +19,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channelnotifier" - "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/kvdb" diff --git a/watchtower/wtclient/manager.go b/watchtower/wtclient/manager.go index 01a9fa01ef..7a39c8ff73 100644 --- a/watchtower/wtclient/manager.go +++ b/watchtower/wtclient/manager.go @@ -12,7 +12,7 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channelnotifier" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/subscribe" diff --git a/watchtower/wtdb/client_chan_summary.go b/watchtower/wtdb/client_chan_summary.go index 6fec34c842..9ab77377b4 100644 --- a/watchtower/wtdb/client_chan_summary.go +++ b/watchtower/wtdb/client_chan_summary.go @@ -3,7 +3,7 @@ package wtdb import ( "io" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/watchtower/wtdb/client_db.go b/watchtower/wtdb/client_db.go index b6f6affce6..6e6adacc02 100644 --- a/watchtower/wtdb/client_db.go +++ b/watchtower/wtdb/client_db.go @@ -9,7 +9,7 @@ import ( "sync" "github.com/btcsuite/btcd/btcec/v2" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/tlv" diff --git a/zpay32/decode.go b/zpay32/decode.go index 61099cf2f0..76c2c1ecf4 100644 --- a/zpay32/decode.go +++ b/zpay32/decode.go @@ -14,7 +14,7 @@ import ( "github.com/btcsuite/btcd/btcutil/bech32" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/zpay32/encode.go b/zpay32/encode.go index 3e2d799776..43ccd5ecb1 100644 --- a/zpay32/encode.go +++ b/zpay32/encode.go @@ -9,7 +9,7 @@ import ( "github.com/btcsuite/btcd/btcutil/bech32" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/zpay32/invoice.go b/zpay32/invoice.go index 7c18253eb0..9c5d86ce2f 100644 --- a/zpay32/invoice.go +++ b/zpay32/invoice.go @@ -8,7 +8,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" ) diff --git a/zpay32/invoice_test.go b/zpay32/invoice_test.go index a4753431e7..55718007db 100644 --- a/zpay32/invoice_test.go +++ b/zpay32/invoice_test.go @@ -17,7 +17,7 @@ import ( "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" sphinx "github.com/lightningnetwork/lightning-onion" - "github.com/lightningnetwork/lnd/fn" + "github.com/lightningnetwork/lnd/fn/v2" "github.com/lightningnetwork/lnd/lnwire" "github.com/stretchr/testify/require" )