diff --git a/aliasmgr/aliasmgr.go b/aliasmgr/aliasmgr.go index f06cb53d790..a3227b18b8e 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 fc20fbb8578..59c03d5171b 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 c3a40a00bfb..e3bff289cf0 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 b2383636aa2..1b8a5acb50f 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 d9ab9928d0f..4a888b162ec 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 edc422482ea..a9a9ede7049 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 5853b37e453..afffe5a2e88 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 b741320b078..01d14f6c078 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 d2212bd859c..0fe402926d6 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 9ca57312aa1..f4e99a6f8cd 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 2cac0bacedc..b1ca100eb3b 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 f0f59185e92..7771c8ec8b1 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 3ac9d6114c4..76463eb6ca4 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 3abc73f81e3..ea6eaf13f22 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 4290552eee2..2df6627e2c9 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 15c29380a74..d7d6d5f9dca 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 42650bb68b1..42790a50c63 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 b4d6877202e..e482c4c7132 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 d59829b5e5f..33bc7f7e336 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 576009eda4a..c387c217970 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 a0908ea3fa9..7d199c5c289 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 0f44db2abb9..533d0eff782 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 6d9b30d2086..646d68b869e 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 e79c8d546b7..e29f21e7f45 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 319b437e4e3..0be157d9713 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 92ad608eb96..02e4b347c2b 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 4b47a342948..6019a0dbc6d 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 53f4f680d00..f5a88f24e68 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 73841eb88c5..e5be63cbf79 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 53fa8935534..9c5da6ee496 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 2466544c982..1303d0af600 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 b2716ad3056..9d09f844dcb 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 23023729fac..c0206d8f142 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 9954c3c0dbc..545e7c61353 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 f3f23c385c7..0e4f1336c27 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 aef906a0ad3..a870683746e 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 796d1ed2394..f1b47cc2ca2 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 41e58c404ed..7db67c39ea3 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 85a4e0657ea..b74f69bf0ad 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 492612145a1..c7ef653f47f 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 c8a54d9588d..395cccb2a6b 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 525f69f9a52..b6130176d16 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 1330f9a84a0..bbb421de404 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 aa04dc5fce8..4c452df735a 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 c0133e02ece..d6984af7091 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 0f91e2bbecf..6aa67acc6a1 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 c48436173f6..6414c9f8021 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 d8f55afc69d..7763a4a7513 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 60062862ef5..214144ac19d 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 80632b07e9b..4e5c9478a1d 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 ce791bef328..1d149fb0bf0 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 27d0deb8c67..468ad5e708f 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 da08909d57c..6ce9563e45d 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 1a08275ec9b..3e2e9a52ddd 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 abfb8e4d5b4..88093214607 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 088b20401fa..4a9a4b55c07 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 bbd4550c5fb..6d90bc28df6 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 91ca55292ff..000efe95859 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 2ca6e972365..5ca4dd0c66c 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 a1259be1961..3a1e0003746 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 791d4bd5833..5cb1ca192b6 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 97e75e8cc52..58f5b63d074 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 54180abf57a..0b08da32b32 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 099014aff0c..158e8768f94 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 60f30dd7ed5..b26b144c811 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 230fea35b63..96d3342d83c 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 9da831ac04a..72df3d0199d 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 9421e991b67..7d73681094c 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 7f1a7edf073..9499fa25a36 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 c6dec6fbd56..4f477cdbd42 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 f96a3aadd7c..8e8fcd39362 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 1b079fea16e..11cbefdd5c0 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 e9e380bbb3a..0229d6a47f8 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 8b7ef553803..fa623bf84dd 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 a89ab7d2cc3..38f02f3a4c7 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 c457a92509b..28a78e09db5 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 382232640d7..b36e2d6368e 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 01abe1aae3f..510b64b5d15 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 5d28574cbe5..b9a909fbd39 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 26fa56aef1f..2d6fd0a2e15 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 8b1c445ca3b..62f475dd434 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 17112b29e0b..398a8a9f3e7 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 28709fd5f86..fe71fe5e3b7 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 729cdc545bb..f774c81039f 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 b3457f21bf7..e28cbb96d12 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 3512b32ff9b..e40c4a1157f 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 f678f520fcb..dd1bedd05ac 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 7f70e600c64..d190acdf5e1 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 f7ecd322772..d0caa97812c 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 8b364a01df0..787e8a71e14 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 fa2abe0aa26..871a139c5c6 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 425fe15dad1..c60974be6db 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 c9dee9202a5..64f85463104 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 a8610dc7799..39e520d2760 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 822aa48a144..748e5fa9586 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 fd35d950768..a8a0cacd4bf 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 bf6aa61df35..426712b5979 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 c006aa2e508..27de51708c9 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 ff9adfbd797..738558e224f 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 135d1866bcd..38131eaa724 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 2d1f65c9fa3..b2b8af58d15 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 ad6354e2e8a..96ea85cf9e2 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 e5232794987..577379623f4 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 8177cbe8211..a63aa5dfb0e 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 8ff6af10ba6..d4aad2e5462 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 24f23a228dd..d477461e7bc 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 b0cc1198e94..394fff6f374 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 c4ca260e1e6..4681426cbb8 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 952e90a7e67..6bfbb465ecc 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 5f05e1ef9f1..7b65a85f4e9 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 9c39be6d5c0..5c3d0291a5a 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 db9e7839903..736c085a95c 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 6bc49445eee..f8ac00aa209 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 c3d1bee48b6..eded6588877 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 6f69a8c5b85..149ebcfa0cc 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 eb510a53b10..34c42e2f7c0 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 e5de0b69517..bca7283d397 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 b96d677e6bb..5e24255fa3f 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 b71d5efe42e..2db00be2d42 100644 --- a/protofsm/state_machine.go +++ b/protofsm/state_machine.go @@ -2,6 +2,7 @@ package protofsm import ( "context" + "errors" "fmt" "sync" "time" @@ -10,7 +11,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" ) @@ -347,7 +348,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 +357,14 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( s.SendEvent(event) }) + + if !launched { + return errors.New( + "StateMachine shutting down", + ) + } + + return nil }) } @@ -368,7 +377,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 +416,12 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( } }) + if !launched { + return errors.New("StateMachine shutting down") + } + + return nil + // If this is a broadcast transaction event, then we'll broadcast with // the label attached. case *BroadcastTxn: @@ -436,7 +451,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 +476,12 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( } }) + if !launched { + return errors.New("StateMachine shutting down") + } + + 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 +497,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 +519,12 @@ func (s *StateMachine[Event, Env]) executeDaemonEvent( } } }) + + if !launched { + return errors.New("StateMachine shutting down") + } + + 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 fc30fcefc3d..fc7a4ccfdcf 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 12e82131dc0..c816ed3410a 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 4872b5a7eca..7469bc84c6e 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 7c840634691..0c27e874395 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 410dfaf6434..8f83f7fd82f 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 315b0dff225..e4241dac536 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 d7380439ac3..cd9e58fcaa6 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 de892392e75..3bc9be7aba6 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 3cdb5ebaf2f..25755141023 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 8e40c5bc4b4..80f4b1e68fa 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 da29c79a25a..c463b8135b4 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 267ce3965d2..292397d9dfb 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 315c1bad58a..98fe7ffd219 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 d5f1a6af413..240f801e78a 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 089213d65ed..bc1749dfb1a 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 b213eb1835d..8c67bdeea92 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 9eabe0b2ae6..0b3c90c3218 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 2923f1fb90a..0824146d1ed 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 d7d2e0186cd..72e2fa4afdf 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 b4b66e719cd..b686c9020a8 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 f8f8239ed67..abf898ca31e 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 30755c05e44..102e211187d 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 a0a1b0a5406..e97ccb9a210 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 6df0d73fa26..2cb89bdc385 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 adb4db65ed8..7bb58ae29e0 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 5030dee227f..c9196aee5a6 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 cbf283e37d7..bff44000be2 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 c278bb7f066..a55ce79a784 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 f2fff84b08f..6c8c2cfad28 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 34202b1453d..eeeb2839693 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 6257faac1f5..9eeefc94b84 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 2b61f679334..7d99ba93b9a 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 ce144a8eb3c..adae7cf131e 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 8d0850b20d8..73f056a9649 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 81458fbfb03..3f790dc66f8 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 968d9cb4fb9..c7a5dfc2212 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 7780239f07a..9dc1af6258b 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 a1d6ec9f2c4..0d23e2e0fc1 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 5045b4a0f4c..ded2cd6031d 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 7eb34f6e376..62d7609469e 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 f3a4d5bf4ee..e842876b651 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 01a9fa01ef4..7a39c8ff73e 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 6fec34c8429..9ab77377b41 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 b6f6affce67..6e6adacc023 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 61099cf2f03..76c2c1ecf45 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 3e2d799776b..43ccd5ecb1e 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 7c18253eb01..9c5d86ce2f1 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 a4753431e7f..55718007db4 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" )