multi: update to fn v2

This commit is contained in:
Keagan McClelland 2024-12-03 15:51:05 -07:00
parent 48fba10562
commit ed2989ae33
No known key found for this signature in database
GPG key ID: FA7E65C951F12439
167 changed files with 372 additions and 302 deletions

View file

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwire" "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. // 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() return a.ToUint64() != alias.ToUint64()
}, aliasSet) })
// If the alias set is empty, we'll delete the base SCID from the // If the alias set is empty, we'll delete the base SCID from the
// baseToSet map. // 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 // haveAlias returns true if the passed alias is already assigned to a
// channel in the baseToSet map. // channel in the baseToSet map.
haveAlias := func(maybeNextAlias lnwire.ShortChannelID) bool { haveAlias := func(maybeNextAlias lnwire.ShortChannelID) bool {
return fn.Any(func(aliasList []lnwire.ShortChannelID) bool { return fn.Any(
return fn.Any(func(alias lnwire.ShortChannelID) bool { maps.Values(m.baseToSet),
func(aliasList []lnwire.ShortChannelID) bool {
return fn.Any(
aliasList,
func(alias lnwire.ShortChannelID) bool {
return alias == maybeNextAlias return alias == maybeNextAlias
}, aliasList) },
}, maps.Values(m.baseToSet)) )
},
)
} }
err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error { err := kvdb.Update(m.backend, func(tx kvdb.RwTx) error {

View file

@ -15,7 +15,7 @@ import (
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
"github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/queue" "github.com/lightningnetwork/lnd/queue"
) )

View file

@ -17,7 +17,7 @@ import (
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
"github.com/lightningnetwork/lnd/blockcache" "github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/queue" "github.com/lightningnetwork/lnd/queue"
) )

View file

@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
) )
var ( var (

View file

@ -3,7 +3,7 @@ package chainntnfs
import ( import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
) )

View file

@ -23,7 +23,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify" "github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
"github.com/lightningnetwork/lnd/chainntnfs/neutrinonotify" "github.com/lightningnetwork/lnd/chainntnfs/neutrinonotify"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"

View file

@ -5,7 +5,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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 // LiveChannelSource is an interface that allows us to query for the set of

View file

@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/keychain"
"github.com/lightningnetwork/lnd/lnencrypt" "github.com/lightningnetwork/lnd/lnencrypt"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "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/keychain"
"github.com/lightningnetwork/lnd/lnencrypt" "github.com/lightningnetwork/lnd/lnencrypt"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -19,7 +19,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/walletdb" "github.com/btcsuite/btcwallet/walletdb"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db" graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"

View file

@ -18,7 +18,7 @@ import (
_ "github.com/btcsuite/btcwallet/walletdb/bdb" _ "github.com/btcsuite/btcwallet/walletdb/bdb"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/clock" "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/graph/db/models"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"

View file

@ -6,7 +6,7 @@ import (
"io" "io"
"sort" "sort"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv" "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 // ProduceRecordsSorted converts a slice of record producers into a slice of
// records and then sorts it by type. // records and then sorts it by type.
func ProduceRecordsSorted(recordProducers ...tlv.RecordProducer) []tlv.Record { func ProduceRecordsSorted(recordProducers ...tlv.RecordProducer) []tlv.Record {
records := fn.Map(func(producer tlv.RecordProducer) tlv.Record { records := fn.Map(
recordProducers,
func(producer tlv.RecordProducer) tlv.Record {
return producer.Record() return producer.Record()
}, recordProducers) },
)
// Ensure that the set of records are sorted before we attempt to // Ensure that the set of records are sorted before we attempt to
// decode from the stream, to ensure they're canonical. // 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 // RecordsAsProducers converts a slice of records into a slice of record
// producers. // producers.
func RecordsAsProducers(records []tlv.Record) []tlv.RecordProducer { 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 return &record
}, records) })
} }
// EncodeRecords encodes the given records into a byte slice. // EncodeRecords encodes the given records into a byte slice.

View file

@ -8,7 +8,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21" lnwire "github.com/lightningnetwork/lnd/channeldb/migration/lnwire21"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/tlv" "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 // extractMCHops extracts the Hop fields that MC actually uses from a slice of
// Hops. // Hops.
func extractMCHops(hops []*Hop) mcHops { 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. // extractMCHop extracts the Hop fields that MC actually uses from a Hop.

View file

@ -7,7 +7,7 @@ import (
"math" "math"
"github.com/btcsuite/btcd/btcutil" "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/kvdb"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -8,7 +8,7 @@ import (
"testing" "testing"
"github.com/btcsuite/btcd/btcutil" "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/kvdb"
"github.com/lightningnetwork/lnd/lntest/channels" "github.com/lightningnetwork/lnd/lntest/channels"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -10,7 +10,7 @@ import (
"strings" "strings"
"unicode" "unicode"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/macaroons" "github.com/lightningnetwork/lnd/macaroons"
@ -177,12 +177,15 @@ func bakeMacaroon(ctx *cli.Context) error {
"%w", err) "%w", err)
} }
ops := fn.Map(func(p *lnrpc.MacaroonPermission) bakery.Op { ops := fn.Map(
parsedPermissions,
func(p *lnrpc.MacaroonPermission) bakery.Op {
return bakery.Op{ return bakery.Op{
Entity: p.Entity, Entity: p.Entity,
Action: p.Action, Action: p.Action,
} }
}, parsedPermissions) },
)
rawMacaroon, err = macaroons.BakeFromRootKey(macRootKey, ops) rawMacaroon, err = macaroons.BakeFromRootKey(macRootKey, ops)
if err != nil { if err != nil {

View file

@ -33,7 +33,7 @@ import (
"github.com/lightningnetwork/lnd/chainreg" "github.com/lightningnetwork/lnd/chainreg"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/funding" "github.com/lightningnetwork/lnd/funding"
graphdb "github.com/lightningnetwork/lnd/graph/db" graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/invoices"

View file

@ -9,7 +9,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/sweep" "github.com/lightningnetwork/lnd/sweep"
) )

View file

@ -15,7 +15,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db" graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/kvdb" "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 // outputs from the regular, BTC only outputs. So we only need one such
// output, which'll carry the custom channel "valuables" from both the // output, which'll carry the custom channel "valuables" from both the
// breached commitment and HTLC outputs. // 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() return i.ResolutionBlob().IsSome()
}, inputs) })
if hasBlobs { if hasBlobs {
weightEstimate.AddP2TROutput() 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 // First, we'll add the extra sweep output if it exists, subtracting the
// amount from the sweep amt. // amount from the sweep amt.
if b.cfg.AuxSweeper.IsSome() { if b.cfg.AuxSweeper.IsSome() {
extraChangeOut.WhenResult(func(o sweep.SweepOutput) { extraChangeOut.WhenOk(func(o sweep.SweepOutput) {
sweepAmt -= o.Value sweepAmt -= o.Value
txn.AddTxOut(&o.TxOut) txn.AddTxOut(&o.TxOut)
@ -1697,7 +1697,7 @@ func (b *BreachArbitrator) sweepSpendableOutputsTxn(txWeight lntypes.WeightUnit,
return &justiceTxCtx{ return &justiceTxCtx{
justiceTx: txn, justiceTx: txn,
sweepAddr: pkScript, sweepAddr: pkScript,
extraTxOut: extraChangeOut.Option(), extraTxOut: extraChangeOut.OkToSome(),
fee: txFee, fee: txFee,
inputs: inputs, inputs: inputs,
}, nil }, nil

View file

@ -22,7 +22,7 @@ import (
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lntest/channels" "github.com/lightningnetwork/lnd/lntest/channels"

View file

@ -10,7 +10,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"

View file

@ -14,7 +14,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lnmock" "github.com/lightningnetwork/lnd/lnmock"

View file

@ -14,7 +14,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"

View file

@ -18,7 +18,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnutils"
@ -451,7 +451,7 @@ func (c *chainWatcher) handleUnknownLocalState(
leaseExpiry = c.cfg.chanState.ThawHeight leaseExpiry = c.cfg.chanState.ThawHeight
} }
remoteAuxLeaf := fn.ChainOption( remoteAuxLeaf := fn.FlatMapOption(
func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf { func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf {
return l.RemoteAuxLeaf return l.RemoteAuxLeaf
}, },
@ -468,7 +468,7 @@ func (c *chainWatcher) handleUnknownLocalState(
// Next, we'll derive our script that includes the revocation base for // Next, we'll derive our script that includes the revocation base for
// the remote party allowing them to claim this output before the CSV // the remote party allowing them to claim this output before the CSV
// delay if we breach. // delay if we breach.
localAuxLeaf := fn.ChainOption( localAuxLeaf := fn.FlatMapOption(
func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf { func(l lnwallet.CommitAuxLeaves) input.AuxTapLeaf {
return l.LocalAuxLeaf return l.LocalAuxLeaf
}, },
@ -1062,15 +1062,15 @@ func (c *chainWatcher) toSelfAmount(tx *wire.MsgTx) btcutil.Amount {
return false 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 // Grab all of the outputs that correspond with our delivery address
// or our wallet is aware of. // 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. // 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 the sum.
return btcutil.Amount(fn.Sum(vals)) return btcutil.Amount(fn.Sum(vals))

View file

@ -15,7 +15,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
@ -997,7 +997,7 @@ func (c *ChannelArbitrator) stateStep(
getIdx := func(htlc channeldb.HTLC) uint64 { getIdx := func(htlc channeldb.HTLC) uint64 {
return htlc.HtlcIndex return htlc.HtlcIndex
} }
dustHTLCSet := fn.NewSet(fn.Map(getIdx, dustHTLCs)...) dustHTLCSet := fn.NewSet(fn.Map(dustHTLCs, getIdx)...)
err = c.abandonForwards(dustHTLCSet) err = c.abandonForwards(dustHTLCSet)
if err != nil { if err != nil {
return StateError, closeTx, err return StateError, closeTx, err
@ -1306,7 +1306,7 @@ func (c *ChannelArbitrator) stateStep(
return htlc.HtlcIndex return htlc.HtlcIndex
} }
remoteDangling := fn.NewSet(fn.Map( remoteDangling := fn.NewSet(fn.Map(
getIdx, htlcActions[HtlcFailDanglingAction], htlcActions[HtlcFailDanglingAction], getIdx,
)...) )...)
err := c.abandonForwards(remoteDangling) err := c.abandonForwards(remoteDangling)
if err != nil { if err != nil {

View file

@ -16,7 +16,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"

View file

@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/sweep" "github.com/lightningnetwork/lnd/sweep"

View file

@ -9,7 +9,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog/v2" "github.com/btcsuite/btclog/v2"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
) )
var ( var (

View file

@ -10,7 +10,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/invoices"

View file

@ -6,7 +6,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"
) )

View file

@ -6,7 +6,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
) )

View file

@ -12,7 +12,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/labels" "github.com/lightningnetwork/lnd/labels"

View file

@ -12,7 +12,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"

View file

@ -12,7 +12,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnutils"

View file

@ -14,7 +14,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"

View file

@ -15,7 +15,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db" graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/labels" "github.com/lightningnetwork/lnd/labels"

View file

@ -18,7 +18,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lntest/mock" "github.com/lightningnetwork/lnd/lntest/mock"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"

View file

@ -19,7 +19,7 @@ import (
"github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph" "github.com/lightningnetwork/lnd/graph"
graphdb "github.com/lightningnetwork/lnd/graph/db" graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"

View file

@ -24,7 +24,7 @@ import (
"github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph" "github.com/lightningnetwork/lnd/graph"
graphdb "github.com/lightningnetwork/lnd/graph/db" graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"

View file

@ -2,7 +2,7 @@ package funding
import ( import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "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/lntypes"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/msgmux" "github.com/lightningnetwork/lnd/msgmux"

View file

@ -23,7 +23,7 @@ import (
"github.com/lightningnetwork/lnd/chanacceptor" "github.com/lightningnetwork/lnd/chanacceptor"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/discovery" "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"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"

View file

@ -27,7 +27,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channelnotifier" "github.com/lightningnetwork/lnd/channelnotifier"
"github.com/lightningnetwork/lnd/discovery" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"

4
go.mod
View file

@ -36,13 +36,13 @@ require (
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb
github.com/lightningnetwork/lnd/cert v1.2.2 github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/clock v1.1.1 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/healthcheck v1.2.6
github.com/lightningnetwork/lnd/kvdb v1.4.11 github.com/lightningnetwork/lnd/kvdb v1.4.11
github.com/lightningnetwork/lnd/queue v1.1.1 github.com/lightningnetwork/lnd/queue v1.1.1
github.com/lightningnetwork/lnd/sqldb v1.0.5 github.com/lightningnetwork/lnd/sqldb v1.0.5
github.com/lightningnetwork/lnd/ticker v1.1.1 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/lightningnetwork/lnd/tor v1.1.4
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796
github.com/miekg/dns v1.1.43 github.com/miekg/dns v1.1.43

8
go.sum
View file

@ -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/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 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ= 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/v2 v2.0.2 h1:M7o2lYrh/zCp+lntPB3WP/rWTu5U+4ssyHW+kqNJ0fs=
github.com/lightningnetwork/lnd/fn v1.2.5/go.mod h1:SyFohpVrARPKH3XVAJZlXdVe+IwMYc4OMAvrDY32kw0= 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 h1:1sWhqr93GdkWy4+6U7JxBfcyZIE78MhIHTJZfPx7qqI=
github.com/lightningnetwork/lnd/healthcheck v1.2.6/go.mod h1:Mu02um4CWY/zdTOvFje7WJgJcHyX2zq/FG3MhOAiGaQ= 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= 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/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 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA= 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.3.0 h1:exS/KCPEgpOgviIttfiXAPaUqw2rHQrnUOpP7HPBPiY=
github.com/lightningnetwork/lnd/tlv v1.2.6/go.mod h1:/CmY4VbItpOldksocmGT4lxiJqRP9oLxwSZOda2kzNQ= 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 h1:TUW27EXqoZCcCAQPlD4aaDfh8jMbBS9CghNz50qqwtA=
github.com/lightningnetwork/lnd/tor v1.1.4/go.mod h1:qSRB8llhAK+a6kaTPWOLLXSZc6Hg8ZC0mq1sUQ/8JfI= 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= github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw=

View file

@ -16,7 +16,7 @@ import (
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
graphdb "github.com/lightningnetwork/lnd/graph/db" graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"

View file

@ -8,7 +8,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "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 // ChannelEdgeInfo represents a fully authenticated channel along with all its

View file

@ -8,7 +8,7 @@ import (
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/chainntnfs" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

View file

@ -6,7 +6,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/invoices"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

View file

@ -16,7 +16,7 @@ import (
"github.com/btcsuite/btclog/v2" "github.com/btcsuite/btclog/v2"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hodl" "github.com/lightningnetwork/lnd/htlcswitch/hodl"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"

View file

@ -26,7 +26,7 @@ import (
"github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hodl" "github.com/lightningnetwork/lnd/htlcswitch/hodl"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"

View file

@ -24,7 +24,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/contractcourt" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/invoices"

View file

@ -6,7 +6,7 @@ import (
"time" "time"
"github.com/btcsuite/btclog/v2" "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/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
) )

View file

@ -5,7 +5,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View file

@ -17,7 +17,7 @@ import (
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock" "github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/contractcourt" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"

View file

@ -17,7 +17,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "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/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch/hodl" "github.com/lightningnetwork/lnd/htlcswitch/hodl"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"

View file

@ -6,7 +6,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "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/lntypes"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"
) )

View file

@ -8,7 +8,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2" "github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "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/keychain"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"

View file

@ -14,7 +14,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "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/lntypes"
"github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnutils"
"golang.org/x/crypto/ripemd160" "golang.org/x/crypto/ripemd160"

View file

@ -8,7 +8,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/waddrmgr" "github.com/btcsuite/btcwallet/waddrmgr"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
) )
const ( const (

View file

@ -10,7 +10,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "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/keychain"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"

View file

@ -3,7 +3,7 @@ package lnd
import ( import (
"errors" "errors"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"sync/atomic" "sync/atomic"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
) )
var ( var (

View file

@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainreg" "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/funding"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/labels" "github.com/lightningnetwork/lnd/labels"

View file

@ -8,7 +8,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/contractcourt" "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/lncfg"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" "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 // The sweeping tx has two inputs, one from wallet, the other
// from the force close tx. We now check whether the first tx // from the force close tx. We now check whether the first tx
// spends from the force close tx of Alice->Bob. // 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 return inp.PreviousOutPoint.Hash == abCloseTxid
}, txns[0].TxIn) })
// If the first tx spends an outpoint from the force close tx // If the first tx spends an outpoint from the force close tx
// of Alice->Bob, then it must be the incoming HTLC sweeping // of Alice->Bob, then it must be the incoming HTLC sweeping

View file

@ -16,7 +16,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "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/graph/db/models"
"github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"

View file

@ -11,7 +11,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wallet"
"github.com/lightningnetwork/lnd/aliasmgr" "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/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"golang.org/x/exp/maps" "golang.org/x/exp/maps"
@ -221,12 +221,18 @@ func UnmarshallCoinSelectionStrategy(strategy CoinSelectionStrategy,
// MarshalAliasMap converts a ScidAliasMap to its proto counterpart. This is // MarshalAliasMap converts a ScidAliasMap to its proto counterpart. This is
// used in various RPCs that handle scid alias mappings. // used in various RPCs that handle scid alias mappings.
func MarshalAliasMap(scidMap aliasmgr.ScidAliasMap) []*AliasMap { func MarshalAliasMap(scidMap aliasmgr.ScidAliasMap) []*AliasMap {
return fn.Map(func(base lnwire.ShortChannelID) *AliasMap { return fn.Map(
maps.Keys(scidMap),
func(base lnwire.ShortChannelID) *AliasMap {
return &AliasMap{ return &AliasMap{
BaseScid: base.ToUint64(), BaseScid: base.ToUint64(),
Aliases: fn.Map(func(a lnwire.ShortChannelID) uint64 { Aliases: fn.Map(
scidMap[base],
func(a lnwire.ShortChannelID) uint64 {
return a.ToUint64() return a.ToUint64()
}, scidMap[base]), },
),
} }
}, maps.Keys(scidMap)) },
)
} }

View file

@ -3,7 +3,7 @@ package routerrpc
import ( import (
"errors" "errors"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models" "github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch" "github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"

View file

@ -16,7 +16,7 @@ import (
sphinx "github.com/lightningnetwork/lightning-onion" sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/feature" "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/htlcswitch"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

View file

@ -16,7 +16,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/aliasmgr" "github.com/lightningnetwork/lnd/aliasmgr"
"github.com/lightningnetwork/lnd/channeldb" "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"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

View file

@ -31,7 +31,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/labels" "github.com/lightningnetwork/lnd/labels"
@ -1145,9 +1145,9 @@ func (w *WalletKit) getWaitingCloseChannel(
return nil, err return nil, err
} }
channel := fn.Find(func(c *channeldb.OpenChannel) bool { channel := fn.Find(chans, func(c *channeldb.OpenChannel) bool {
return c.FundingOutpoint == chanPoint return c.FundingOutpoint == chanPoint
}, chans) })
return channel.UnwrapOrErr(errors.New("channel not found")) return channel.UnwrapOrErr(errors.New("channel not found"))
} }
@ -1231,18 +1231,23 @@ func (w *WalletKit) BumpForceCloseFee(_ context.Context,
pendingSweeps := maps.Values(inputsMap) pendingSweeps := maps.Values(inputsMap)
// Discard everything except for the anchor sweeps. // Discard everything except for the anchor sweeps.
anchors := fn.Filter(func(sweep *sweep.PendingInputResponse) bool { anchors := fn.Filter(
// Only filter for anchor inputs because these are the only pendingSweeps,
// inputs which can be used to bump a closed unconfirmed func(sweep *sweep.PendingInputResponse) bool {
// commitment transaction. // Only filter for anchor inputs because these are the
if sweep.WitnessType != input.CommitmentAnchor && // only inputs which can be used to bump a closed
sweep.WitnessType != input.TaprootAnchorSweepSpend { // unconfirmed commitment transaction.
isCommitAnchor := sweep.WitnessType ==
input.CommitmentAnchor
isTaprootSweepSpend := sweep.WitnessType ==
input.TaprootAnchorSweepSpend
if !isCommitAnchor && !isTaprootSweepSpend {
return false return false
} }
return commitSet.Contains(sweep.OutPoint.Hash) return commitSet.Contains(sweep.OutPoint.Hash)
}, pendingSweeps) },
)
if len(anchors) == 0 { if len(anchors) == 0 {
return nil, fmt.Errorf("unable to find pending anchor outputs") return nil, fmt.Errorf("unable to find pending anchor outputs")
@ -1754,7 +1759,7 @@ func (w *WalletKit) fundPsbtInternalWallet(account string,
return true return true
} }
eligibleUtxos := fn.Filter(filterFn, utxos) eligibleUtxos := fn.Filter(utxos, filterFn)
// Validate all inputs against our known list of UTXOs // Validate all inputs against our known list of UTXOs
// now. // now.

View file

@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/go-errors/errors" "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/kvdb/etcd"
"github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"

View file

@ -19,7 +19,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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"
"github.com/lightningnetwork/lnd/lnrpc/invoicesrpc" "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc" "github.com/lightningnetwork/lnd/lnrpc/routerrpc"
@ -270,7 +270,7 @@ func (h *HarnessTest) AssertNumActiveEdges(hn *node.HarnessNode,
IncludeUnannounced: includeUnannounced, IncludeUnannounced: includeUnannounced,
} }
resp := hn.RPC.DescribeGraph(req) resp := hn.RPC.DescribeGraph(req)
activeEdges := fn.Filter(filterDisabled, resp.Edges) activeEdges := fn.Filter(resp.Edges, filterDisabled)
total := len(activeEdges) total := len(activeEdges)
if total-old == expected { if total-old == expected {

View file

@ -17,7 +17,7 @@ import (
"github.com/btcsuite/btcd/integration/rpctest" "github.com/btcsuite/btcd/integration/rpctest"
"github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/wire" "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/node"
"github.com/lightningnetwork/lnd/lntest/wait" "github.com/lightningnetwork/lnd/lntest/wait"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -296,10 +296,7 @@ func (h *HarnessMiner) AssertTxInMempool(txid chainhash.Hash) *wire.MsgTx {
return fmt.Errorf("empty mempool") return fmt.Errorf("empty mempool")
} }
isEqual := func(memTx chainhash.Hash) bool { result := fn.Find(mempool, fn.Eq(txid))
return memTx == txid
}
result := fn.Find(isEqual, mempool)
if result.IsNone() { if result.IsNone() {
return fmt.Errorf("txid %v not found in "+ return fmt.Errorf("txid %v not found in "+

View file

@ -16,7 +16,7 @@ import (
base "github.com/btcsuite/btcwallet/wallet" base "github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/wallet/txauthor" "github.com/btcsuite/btcwallet/wallet/txauthor"
"github.com/btcsuite/btcwallet/wtxmgr" "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"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
) )

View file

@ -7,7 +7,7 @@ import (
"time" "time"
"github.com/btcsuite/btcd/wire" "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"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc" "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/lntest/rpc" "github.com/lightningnetwork/lnd/lntest/rpc"
@ -324,11 +324,11 @@ func (s *State) updateEdgeStats() {
req := &lnrpc.ChannelGraphRequest{IncludeUnannounced: true} req := &lnrpc.ChannelGraphRequest{IncludeUnannounced: true}
resp := s.rpc.DescribeGraph(req) 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} req = &lnrpc.ChannelGraphRequest{IncludeUnannounced: false}
resp = s.rpc.DescribeGraph(req) 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. // updateWalletBalance creates stats for the node's wallet balance.

View file

@ -5,7 +5,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -4,7 +4,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"

View file

@ -2,7 +2,7 @@ package lnwallet
import ( import (
"github.com/btcsuite/btcd/wire" "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/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -27,7 +27,7 @@ import (
"github.com/btcsuite/btcwallet/wtxmgr" "github.com/btcsuite/btcwallet/wtxmgr"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/blockcache" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"

View file

@ -9,7 +9,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/rpcclient" "github.com/btcsuite/btcd/rpcclient"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
) )
const ( const (

View file

@ -4,7 +4,7 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "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/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"

View file

@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "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/htlcswitch"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/labels" "github.com/lightningnetwork/lnd/labels"

View file

@ -14,7 +14,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

View file

@ -6,7 +6,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"

View file

@ -8,7 +8,7 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
) )

View file

@ -8,7 +8,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/wtxmgr" "github.com/btcsuite/btcwallet/wtxmgr"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
) )

View file

@ -13,7 +13,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
) )

View file

@ -25,7 +25,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
@ -600,7 +600,7 @@ func (lc *LightningChannel) extractPayDescs(feeRate chainfee.SatPerKWeight,
htlc := htlc htlc := htlc
auxLeaf := fn.ChainOption( auxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.OutgoingHtlcLeaves leaves := l.OutgoingHtlcLeaves
if htlc.Incoming { if htlc.Incoming {
@ -1106,7 +1106,7 @@ func (lc *LightningChannel) logUpdateToPayDesc(logUpdate *channeldb.LogUpdate,
feeRate, wireMsg.Amount.ToSatoshis(), remoteDustLimit, feeRate, wireMsg.Amount.ToSatoshis(), remoteDustLimit,
) )
if !isDustRemote { if !isDustRemote {
auxLeaf := fn.ChainOption( auxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.OutgoingHtlcLeaves leaves := l.OutgoingHtlcLeaves
return leaves[pd.HtlcIndex].AuxTapLeaf 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 // Since it is the remote breach we are reconstructing, the output
// going to us will be a to-remote script with our local params. // going to us will be a to-remote script with our local params.
remoteAuxLeaf := fn.ChainOption( remoteAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
return l.RemoteAuxLeaf return l.RemoteAuxLeaf
}, },
@ -2102,7 +2102,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
return nil, err return nil, err
} }
localAuxLeaf := fn.ChainOption( localAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
return l.LocalAuxLeaf return l.LocalAuxLeaf
}, },
@ -2229,7 +2229,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
return nil, fmt.Errorf("unable to aux resolve: %w", err) 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, // 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) 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 // 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 generate the original second level witness script now, as
// we'll need it if we're revoking an HTLC output on the remote // we'll need it if we're revoking an HTLC output on the remote
// commitment transaction, and *they* go to the second level. // commitment transaction, and *they* go to the second level.
secondLevelAuxLeaf := fn.ChainOption( secondLevelAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) fn.Option[input.AuxTapLeaf] { func(l CommitAuxLeaves) fn.Option[input.AuxTapLeaf] {
return fn.MapOption(func(val uint16) input.AuxTapLeaf { return fn.MapOption(func(val uint16) input.AuxTapLeaf {
idx := input.HtlcIndex(val) 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, // HTLC script. Otherwise, is this was an outgoing HTLC that we sent,
// then from the PoV of the remote commitment state, they're the // then from the PoV of the remote commitment state, they're the
// receiver of this HTLC. // receiver of this HTLC.
htlcLeaf := fn.ChainOption( htlcLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) fn.Option[input.AuxTapLeaf] { func(l CommitAuxLeaves) fn.Option[input.AuxTapLeaf] {
return fn.MapOption(func(val uint16) input.AuxTapLeaf { return fn.MapOption(func(val uint16) input.AuxTapLeaf {
idx := input.HtlcIndex(val) idx := input.HtlcIndex(val)
@ -2693,13 +2693,13 @@ type HtlcView struct {
// AuxOurUpdates returns the outgoing HTLCs as a read-only copy of // AuxOurUpdates returns the outgoing HTLCs as a read-only copy of
// AuxHtlcDescriptors. // AuxHtlcDescriptors.
func (v *HtlcView) AuxOurUpdates() []AuxHtlcDescriptor { 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 // AuxTheirUpdates returns the incoming HTLCs as a read-only copy of
// AuxHtlcDescriptors. // AuxHtlcDescriptors.
func (v *HtlcView) AuxTheirUpdates() []AuxHtlcDescriptor { 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 // 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 fee rate of our view is always the last UpdateFee message from
// the channel's OpeningParty. // the channel's OpeningParty.
openerUpdates := view.Updates.GetForParty(lc.channelState.Initiator()) 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 return u.EntryType == FeeUpdate
}, openerUpdates) })
lastFeeUpdate := fn.Last(feeUpdates) lastFeeUpdate := fn.Last(feeUpdates)
lastFeeUpdate.WhenSome(func(pd *paymentDescriptor) { lastFeeUpdate.WhenSome(func(pd *paymentDescriptor) {
newView.FeePerKw = chainfee.SatPerKWeight( newView.FeePerKw = chainfee.SatPerKWeight(
@ -2942,14 +2942,17 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView,
for _, party := range parties { for _, party := range parties {
// First we run through non-add entries in both logs, // First we run through non-add entries in both logs,
// populating the skip sets. // populating the skip sets.
resolutions := fn.Filter(func(pd *paymentDescriptor) bool { resolutions := fn.Filter(
view.Updates.GetForParty(party),
func(pd *paymentDescriptor) bool {
switch pd.EntryType { switch pd.EntryType {
case Settle, Fail, MalformedFail: case Settle, Fail, MalformedFail:
return true return true
default: default:
return false return false
} }
}, view.Updates.GetForParty(party)) },
)
for _, entry := range resolutions { for _, entry := range resolutions {
addEntry, err := lc.fetchParent( 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 // settled HTLCs, and debiting the chain state balance due to any newly
// added HTLCs. // added HTLCs.
for _, party := range parties { for _, party := range parties {
liveAdds := fn.Filter(func(pd *paymentDescriptor) bool { liveAdds := fn.Filter(
return pd.EntryType == Add && view.Updates.GetForParty(party),
!skip.GetForParty(party).Contains(pd.HtlcIndex) func(pd *paymentDescriptor) bool {
}, view.Updates.GetForParty(party)) isAdd := pd.EntryType == Add
shouldSkip := skip.GetForParty(party).
Contains(pd.HtlcIndex)
return isAdd && !shouldSkip
},
)
for _, entry := range liveAdds { for _, entry := range liveAdds {
// Skip the entries that have already had their add // Skip the entries that have already had their add
@ -3063,7 +3072,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *HtlcView,
uncommittedUpdates := lntypes.MapDual( uncommittedUpdates := lntypes.MapDual(
view.Updates, view.Updates,
func(us []*paymentDescriptor) []*paymentDescriptor { 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) htlcFee := HtlcTimeoutFee(chanType, feePerKw)
outputAmt := htlc.Amount.ToSatoshis() - htlcFee outputAmt := htlc.Amount.ToSatoshis() - htlcFee
auxLeaf := fn.ChainOption( auxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.IncomingHtlcLeaves leaves := l.IncomingHtlcLeaves
return leaves[htlc.HtlcIndex].SecondLevelLeaf return leaves[htlc.HtlcIndex].SecondLevelLeaf
@ -3270,7 +3279,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing,
htlcFee := HtlcSuccessFee(chanType, feePerKw) htlcFee := HtlcSuccessFee(chanType, feePerKw)
outputAmt := htlc.Amount.ToSatoshis() - htlcFee outputAmt := htlc.Amount.ToSatoshis() - htlcFee
auxLeaf := fn.ChainOption( auxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.OutgoingHtlcLeaves leaves := l.OutgoingHtlcLeaves
return leaves[htlc.HtlcIndex].SecondLevelLeaf return leaves[htlc.HtlcIndex].SecondLevelLeaf
@ -4802,7 +4811,7 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel,
htlcFee := HtlcSuccessFee(chanType, feePerKw) htlcFee := HtlcSuccessFee(chanType, feePerKw)
outputAmt := htlc.Amount.ToSatoshis() - htlcFee outputAmt := htlc.Amount.ToSatoshis() - htlcFee
auxLeaf := fn.ChainOption(func( auxLeaf := fn.FlatMapOption(func(
l CommitAuxLeaves) input.AuxTapLeaf { l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.IncomingHtlcLeaves leaves := l.IncomingHtlcLeaves
@ -4895,7 +4904,7 @@ func genHtlcSigValidationJobs(chanState *channeldb.OpenChannel,
htlcFee := HtlcTimeoutFee(chanType, feePerKw) htlcFee := HtlcTimeoutFee(chanType, feePerKw)
outputAmt := htlc.Amount.ToSatoshis() - htlcFee outputAmt := htlc.Amount.ToSatoshis() - htlcFee
auxLeaf := fn.ChainOption(func( auxLeaf := fn.FlatMapOption(func(
l CommitAuxLeaves) input.AuxTapLeaf { l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.OutgoingHtlcLeaves 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 // Before we can generate the proper sign descriptor, we'll need to
// locate the output index of our non-delayed output on the commitment // locate the output index of our non-delayed output on the commitment
// transaction. // transaction.
remoteAuxLeaf := fn.ChainOption( remoteAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
return l.RemoteAuxLeaf return l.RemoteAuxLeaf
}, },
@ -6870,7 +6879,7 @@ func NewUnilateralCloseSummary(chanState *channeldb.OpenChannel, //nolint:funlen
return nil, fmt.Errorf("unable to aux resolve: %w", err) return nil, fmt.Errorf("unable to aux resolve: %w", err)
} }
commitResolution.ResolutionBlob = resolveBlob.Option() commitResolution.ResolutionBlob = resolveBlob.OkToSome()
} }
closeSummary := channeldb.ChannelCloseSummary{ 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 // First, we'll re-generate the script used to send the HTLC to the
// remote party within their commitment transaction. // 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 return l.OutgoingHtlcLeaves[htlc.HtlcIndex].AuxTapLeaf
})(auxLeaves) })(auxLeaves)
htlcScriptInfo, err := genHtlcScript( htlcScriptInfo, err := genHtlcScript(
@ -7149,7 +7158,7 @@ func newOutgoingHtlcResolution(signer input.Signer,
return nil, fmt.Errorf("unable to aux resolve: %w", err) return nil, fmt.Errorf("unable to aux resolve: %w", err)
} }
resolutionBlob := resolveRes.Option() resolutionBlob := resolveRes.OkToSome()
return &OutgoingHtlcResolution{ return &OutgoingHtlcResolution{
Expiry: htlc.RefundTimeout, Expiry: htlc.RefundTimeout,
@ -7171,7 +7180,7 @@ func newOutgoingHtlcResolution(signer input.Signer,
// With the fee calculated, re-construct the second level timeout // With the fee calculated, re-construct the second level timeout
// transaction. // transaction.
secondLevelAuxLeaf := fn.ChainOption( secondLevelAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.OutgoingHtlcLeaves leaves := l.OutgoingHtlcLeaves
return leaves[htlc.HtlcIndex].SecondLevelLeaf return leaves[htlc.HtlcIndex].SecondLevelLeaf
@ -7366,7 +7375,7 @@ func newOutgoingHtlcResolution(signer input.Signer,
if err := resolveRes.Err(); err != nil { if err := resolveRes.Err(); err != nil {
return nil, fmt.Errorf("unable to aux resolve: %w", err) return nil, fmt.Errorf("unable to aux resolve: %w", err)
} }
resolutionBlob := resolveRes.Option() resolutionBlob := resolveRes.OkToSome()
return &OutgoingHtlcResolution{ return &OutgoingHtlcResolution{
Expiry: htlc.RefundTimeout, Expiry: htlc.RefundTimeout,
@ -7406,7 +7415,7 @@ func newIncomingHtlcResolution(signer input.Signer,
// First, we'll re-generate the script the remote party used to // First, we'll re-generate the script the remote party used to
// send the HTLC to us in their commitment transaction. // 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 return l.IncomingHtlcLeaves[htlc.HtlcIndex].AuxTapLeaf
})(auxLeaves) })(auxLeaves)
scriptInfo, err := genHtlcScript( scriptInfo, err := genHtlcScript(
@ -7497,7 +7506,7 @@ func newIncomingHtlcResolution(signer input.Signer,
return nil, fmt.Errorf("unable to aux resolve: %w", err) return nil, fmt.Errorf("unable to aux resolve: %w", err)
} }
resolutionBlob := resolveRes.Option() resolutionBlob := resolveRes.OkToSome()
return &IncomingHtlcResolution{ return &IncomingHtlcResolution{
ClaimOutpoint: op, ClaimOutpoint: op,
@ -7507,7 +7516,7 @@ func newIncomingHtlcResolution(signer input.Signer,
}, nil }, nil
} }
secondLevelAuxLeaf := fn.ChainOption( secondLevelAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
leaves := l.IncomingHtlcLeaves leaves := l.IncomingHtlcLeaves
return leaves[htlc.HtlcIndex].SecondLevelLeaf return leaves[htlc.HtlcIndex].SecondLevelLeaf
@ -7707,7 +7716,7 @@ func newIncomingHtlcResolution(signer input.Signer,
return nil, fmt.Errorf("unable to aux resolve: %w", err) return nil, fmt.Errorf("unable to aux resolve: %w", err)
} }
resolutionBlob := resolveRes.Option() resolutionBlob := resolveRes.OkToSome()
return &IncomingHtlcResolution{ return &IncomingHtlcResolution{
SignedSuccessTx: successTx, SignedSuccessTx: successTx,
@ -8011,7 +8020,7 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel,
leaseExpiry = chanState.ThawHeight leaseExpiry = chanState.ThawHeight
} }
localAuxLeaf := fn.ChainOption( localAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
return l.LocalAuxLeaf return l.LocalAuxLeaf
}, },
@ -8126,7 +8135,7 @@ func NewLocalForceCloseSummary(chanState *channeldb.OpenChannel,
return nil, fmt.Errorf("unable to aux resolve: %w", err) 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 // Once the delay output has been found (if it exists), then we'll also

View file

@ -25,7 +25,7 @@ import (
"github.com/davecgh/go-spew/spew" "github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/graph/db/models"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
@ -730,9 +730,12 @@ func TestCommitHTLCSigCustomRecordSize(t *testing.T) {
// Replace the default PackSigs implementation to return a // Replace the default PackSigs implementation to return a
// large custom records blob. // large custom records blob.
mockSigner.ExpectedCalls = fn.Filter(func(c *mock.Call) bool { mockSigner.ExpectedCalls = fn.Filter(
mockSigner.ExpectedCalls,
func(c *mock.Call) bool {
return c.Method != "PackSigs" return c.Method != "PackSigs"
}, mockSigner.ExpectedCalls) },
)
mockSigner.On("PackSigs", mock.Anything). mockSigner.On("PackSigs", mock.Anything).
Return(fn.Ok(fn.Some(largeBlob))) Return(fn.Ok(fn.Some(largeBlob)))
}) })

View file

@ -11,7 +11,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
@ -836,7 +836,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
continue continue
} }
auxLeaf := fn.ChainOption( auxLeaf := fn.FlatMapOption(
func(leaves input.HtlcAuxLeaves) input.AuxTapLeaf { func(leaves input.HtlcAuxLeaves) input.AuxTapLeaf {
return leaves[htlc.HtlcIndex].AuxTapLeaf return leaves[htlc.HtlcIndex].AuxTapLeaf
}, },
@ -864,7 +864,7 @@ func (cb *CommitmentBuilder) createUnsignedCommitmentTx(ourBalance,
continue continue
} }
auxLeaf := fn.ChainOption( auxLeaf := fn.FlatMapOption(
func(leaves input.HtlcAuxLeaves) input.AuxTapLeaf { func(leaves input.HtlcAuxLeaves) input.AuxTapLeaf {
return leaves[htlc.HtlcIndex].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 // Compute the to_local script. From our PoV, when facing a remote
// commitment, the to_local output belongs to them. // commitment, the to_local output belongs to them.
localAuxLeaf := fn.ChainOption( localAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
return l.LocalAuxLeaf return l.LocalAuxLeaf
}, },
@ -1338,7 +1338,7 @@ func findOutputIndexesFromRemote(revocationPreimage *chainhash.Hash,
// Compute the to_remote script. From our PoV, when facing a remote // Compute the to_remote script. From our PoV, when facing a remote
// commitment, the to_remote output belongs to us. // commitment, the to_remote output belongs to us.
remoteAuxLeaf := fn.ChainOption( remoteAuxLeaf := fn.FlatMapOption(
func(l CommitAuxLeaves) input.AuxTapLeaf { func(l CommitAuxLeaves) input.AuxTapLeaf {
return l.RemoteAuxLeaf return l.RemoteAuxLeaf
}, },

View file

@ -1,7 +1,7 @@
package lnwallet package lnwallet
import ( import (
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn/v2"
) )
// commitmentChain represents a chain of unrevoked commitments. The tail of the // commitmentChain represents a chain of unrevoked commitments. The tail of the

View file

@ -5,7 +5,7 @@ import (
"github.com/btcsuite/btcwallet/wallet" "github.com/btcsuite/btcwallet/wallet"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"

View file

@ -19,7 +19,7 @@ import (
base "github.com/btcsuite/btcwallet/wallet" base "github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/wallet/txauthor" "github.com/btcsuite/btcwallet/wallet/txauthor"
"github.com/btcsuite/btcwallet/wtxmgr" "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/keychain"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwallet/chanvalidate" "github.com/lightningnetwork/lnd/lnwallet/chanvalidate"

View file

@ -18,7 +18,7 @@ import (
"github.com/btcsuite/btcwallet/wtxmgr" "github.com/btcsuite/btcwallet/wtxmgr"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "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/lntypes"
"github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/tlv" "github.com/lightningnetwork/lnd/tlv"

View file

@ -11,7 +11,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"

View file

@ -12,7 +12,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

View file

@ -22,7 +22,7 @@ import (
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/waddrmgr" "github.com/btcsuite/btcwallet/waddrmgr"
basewallet "github.com/btcsuite/btcwallet/wallet" 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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lncfg" "github.com/lightningnetwork/lnd/lncfg"

View file

@ -34,7 +34,7 @@ import (
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify" "github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/kvdb" "github.com/lightningnetwork/lnd/kvdb"

View file

@ -16,7 +16,7 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

View file

@ -21,7 +21,7 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb" "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/input"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"

Some files were not shown because too many files have changed in this diff Show more