Commit graph

532 commits

Author SHA1 Message Date
ziggie
4518bc7276
htlcswitch: fix outgoing cltv spelling
Rename the ForwardingInfo.OutgoingCTLV field to OutgoingCLTV and update all
call sites. This keeps the exported field spelling consistent with the CLTV
terminology used elsewhere.

Also fix the remaining CTLV typos in nearby comments.
2026-06-25 19:06:26 -03:00
Oli
8047149c6a
multi: upgrade to btcd v2 modules
Migrate all btcd dependencies to the new per-package v2 modules (wire/v2,
txscript/v2, chaincfg/v2, chainhash/v2, btcutil/v2, psbt/v2, btcec/v2)
introduced by btcd v0.26.0, and pin the tagged ecosystem versions:
btcwallet v0.17.0, neutrino v0.18.0 and lightning-onion v1.4.0.

The bulk of the import rewrite was produced by the scripted diff from
https://github.com/btcsuite/btcd/pull/2547 (followed by 'make rpc'). The
address symbols that moved out of btcutil into the new address package
are imported as btcaddr where a local "address" variable would otherwise
shadow them. The go.mod/go.sum updates and the remaining manual
compilation fixes are folded into this single commit so it builds on its
own (the migration was previously split into a reproducible scripted-diff
plus follow-ups, intended to be squashed on merge).
2026-06-24 10:58:36 -07:00
Erick Cestari
f1b34b8168
lint: fix wastedassign issues in test files 2026-06-03 16:46:23 -03:00
Erick Cestari
aca27e27f5
lint: remove redundant loop var copies in test files
Since Go 1.22 loop variables are scoped per-iteration, so the
`x := x` / `a, b := a, b` copies inside range/for loops are no longer
needed. This removes the existing redundant copies in test files.
2026-06-03 15:32:45 -03:00
Erick Cestari
2ae1db83b3
multi: drop tor v2 onion production, keep wire codec faithful
Tor stopped serving v2 onion services in October 2021; lnd should not
produce v2 addresses anymore, but it must still verify signatures on
and re-broadcast peer NodeAnnouncement messages that carry v2 entries.

Stop accepting v2 as configuration input (lncfg), strip the legacy
`--tor.v2` flag from the sample config, and remove the
`tor.OnionHostToFakeIP` helper. Operator entry points (`--externalip`,
`--listen`, `lncli connect`, `lncli wtclient towers add`) fail fast on
a v2 `.onion` string, so upgrading nodes must remove any v2 entry from
`lnd.conf` before lnd will start.

Filter persisted v2 state before use without rewriting on-disk records:
the self-announcement builder strips any v2 entry inherited from the
stored self-node; the watchtower client drops v2 entries from each
persisted tower's address list (skipping the tower entirely if no
non-v2 address remains); the autopilot connector, graph bootstrapper,
and static-channel backup restore paths skip v2 entries before
attempting outbound dials. Restrict the Tor controller's ADD_ONION
path to v3 keys, including the encrypted on-disk legacy-key fallback.

For inbound announcements, keep the wire codec wire-faithful:
`lnwire.WriteOnionAddr`, `graph/db.encodeOnionAddr`, and the matching
decoders round-trip v2 bytes so `DataToSign` reproduces the bytes the
remote peer signed, signature validation succeeds, and the announcement
is persisted to the graph DB and re-broadcast across restarts byte-for-
byte. RPC surfaces continue to expose the full address set so external
tools can independently reproduce and verify the signed bytes.

Add a netann regression test that signs a [v3, v2, ipv4] announcement,
round-trips it through Encode/Decode, verifies the signature, and
confirms the resulting models.Node preserves the v2 entry. Add a
graph bootstrapper test asserting v2 entries are skipped while v3 and
plain TCP entries on the same node still surface as bootstrap
candidates.
2026-05-22 09:42:37 -03:00
Elle Mouton
bfb12b1d81 graph/db: remove address loading from cached node iteration
ForEachNodeCached is now only used for topology-oriented traversal,
so the address-loading option forced one autopilot scoring path to
bypass the in-memory graph cache for data it did not consume. Remove
the withAddrs parameter and the associated SQL/KV address plumbing
so cached node iteration can consistently use the graph cache when
it is loaded.

Autopilot still requires peer addresses before opening channels.
That filtering remains in Agent.openChans via ForEachNode, where the
selected candidates' addresses are collected for ConnectToPeer. The
trade-off is that ForEachNodesChannels no longer excludes
addressless nodes from graph-wide scoring inputs such as median
channel size or centrality, which also feed lncli getnetworkinfo
statistics like graph diameter. In practice the only addressless
nodes our local view tends to know about are nodes with no public
channels (e.g. our own node or peers we share only private channels
with), so the impact on the reported stats should be negligible.
Active channel candidates remain address-filtered before dialing.
2026-05-07 16:29:12 -07:00
Elle Mouton
ebb199d215
graph/db: fix FetchChannelEdgesByID zombie fallback versioning
The zombie fallback in SQLStore.FetchChannelEdgesByID unconditionally
constructed a models.NewV1Channel regardless of the requested gossip
version. Use the passed version to select the correct constructor so
that v2 zombie edges carry the right version.

A new testFetchZombieEdgeVersioning versioned test verifies that
zombie edges returned by FetchChannelEdgesByID have the correct
gossip version for both v1 and v2.
2026-04-09 10:45:49 +05:45
Elle Mouton
12f8e50958
graph/db: add gossip version parameter to FilterKnownChanIDs
Add an explicit lnwire.GossipVersion parameter to FilterKnownChanIDs
on the Store interface, SQLStore, KVStore, and ChannelGraph. Since
FilterKnownChanIDs is always called from a version-scoped ChanSeries
context, a single version parameter is cleaner than per-item version
reads. A convenience wrapper on VersionedGraph preserves the existing
ChanSeries call-site signature by threading c.v automatically.
2026-04-09 10:45:49 +05:45
Elle Mouton
bcadafa1ab
graph/db: parameterize forEachChanInSCIDList with gossip version
Replace the hardcoded GossipVersion1 in forEachChanInSCIDList with an
explicit version parameter so the helper can be used for v2 channel
lookups. The caller in FilterKnownChanIDs now passes the version
through.
2026-04-09 10:04:09 +05:45
Elle Mouton
a390ddd08e
graph/db: tighten TestFilterChannelRangeVersionGuard assertions
Use isSQLDB to explicitly assert the expected outcome per backend:
SQL should succeed with empty results, KV should return
ErrVersionNotSupportedForKVDB.
2026-04-07 14:20:48 +05:45
Elle Mouton
b73fa5f3e0
graph/db: convert TestDisconnectBlockAtHeight to versioned test
Rename to testDisconnectBlockAtHeight and add it to the versionedTests
table so it runs against both v1 and v2 backends.
2026-04-07 14:13:44 +05:45
Elle Mouton
0d82676d53
graph/db: convert TestGraphZombieIndex to versioned test
Rename to testGraphZombieIndex and add it to the versionedTests table
so it runs against both v1 and v2 backends. The assertNumZombies
helper is updated to accept a gossip version parameter.
2026-04-07 14:07:41 +05:45
Elle Mouton
a9c9e76560
graph/db: convert TestLightningNodeSigVerification to versioned test
Rename to testLightningNodeSigVerification and add it to the
versionedTests table so it runs against both v1 and v2. The signing
step is version-specific (ECDSA for v1, Schnorr for v2) while the
verification path is shared.
2026-04-07 14:03:58 +05:45
Elle Mouton
f7b689d576
graph/db: convert TestNodePruningUpdateIndexDeletion to versioned test
Rename to testNodePruningUpdateIndexDeletion and add it to the
versionedTests table so it runs against both v1 and v2 backends.

The NodeUpdateRange is now built per-version: time-based for v1
and block-height-based for v2.
2026-04-07 13:57:45 +05:45
Elle Mouton
2fda82b68c
graph/db: add node horizon index benchmark
Add BenchmarkNodeHorizonIndex to compare query performance under old
vs new index configurations for NodeUpdatesInHorizon. Tests both
all-nodes and public-only variants against native SQLite and
optionally Postgres backends, swapping indexes via DDL between runs.
2026-03-31 12:05:36 +02:00
Elle Mouton
561edf8c96
sqldb/sqlc: split public-only node horizon query and upgrade channel indexes
Split GetNodesByLastUpdateRange into two query variants: one for all
nodes and a new GetPublicNodesByLastUpdateRange for public-only nodes.
The public-only variant uses two separate EXISTS checks (one per
node_id column) instead of a single OR, allowing the planner to do
direct index probes on each channel node-id index.

Also upgrade the channel node-id indexes from single-column
(node_id_1) and (node_id_2) to composite (node_id_1, version) and
(node_id_2, version) to support version-aware public node checks
while preserving usefulness for node-centric lookups.
2026-03-31 12:04:24 +02:00
Elle Mouton
7f5be5a494
graph/db: add v2 block-height path for ChanUpdatesInHorizon
Add GetChannelsByPolicyBlockRange SQL query and wire it into
SQLStore.chanUpdatesInHorizonV2. This mirrors the existing v1
time-based query but filters on policy block_height instead of
last_update, using the same [start, end) exclusive-end semantics
and (max_block_height, channel_id) compound cursor pagination.

Also adds extractMaxBlockHeight helper (returns the max of both
policies' block heights for cursor tracking) and
buildChannelFromBlockRangeRow (structurally identical to the v1
variant but accepts the distinct sqlc-generated row type). The
extractChannelPolicies type-switch is extended with a case for the
new GetChannelsByPolicyBlockRangeRow type.
2026-03-31 09:14:49 +02:00
Elle Mouton
c14a79c0ae
graph/db: add v2 block-height path for NodeUpdatesInHorizon
Add GetNodesByBlockHeightRange SQL query and wire it into
SQLStore.nodeUpdatesInHorizonV2. This mirrors the existing v1
time-based query but filters on (version, block_height) instead of
last_update, using the same [start, end) exclusive-end semantics
and (block_height, pub_key) compound cursor pagination.

The public-node filter for v2 checks for channels with a non-empty
channel announcement signature (c.signature), matching the v2
protocol's public channel indicator.
2026-03-31 09:14:49 +02:00
Elle Mouton
fc7204ca25
graph/db: remove ChannelGraph horizon wrappers, use VersionedGraph
The ChannelGraph.NodeUpdatesInHorizon and
ChannelGraph.ChanUpdatesInHorizon methods were only used in tests.
All production callers already use VersionedGraph (which supplies
the gossip version from its embedded field).

Remove the ChannelGraph wrappers and update tests to instantiate a
VersionedGraph via NewVersionedGraph(MakeTestGraph(t), v1) instead,
dropping the explicit version parameter from horizon calls.
2026-03-31 09:14:49 +02:00
Elle Mouton
497d479440
graph/db: version NodeUpdatesInHorizon and ChanUpdatesInHorizon
Replace the (startTime, endTime time.Time) parameters on
NodeUpdatesInHorizon and ChanUpdatesInHorizon with
(v GossipVersion, r NodeUpdateRange/ChanUpdateRange). The range
types enforce version-correct bounds at the type level: v1 uses unix
timestamps, v2 will use block heights.

The KV store rejects non-v1 versions since it only stores v1 data.
The SQL store dispatches to version-specific helpers
(nodeUpdatesInHorizonV1, chanUpdatesInHorizonV1); the v2
block-height paths return an error for now and will be wired up in
follow-up commits.

VersionedGraph wrappers supply the version from the embedded field,
so callers only pass the range.
2026-03-31 09:14:49 +02:00
Elle Mouton
8b5d21a8f7
graph/db: add ChanUpdateRange and NodeUpdateRange types
Add version-aware range types for channel and node update horizon
queries. V1 gossip uses unix timestamps for ordering while v2 uses
block heights, so each range type validates that the correct bound
type is provided for the requested gossip version.

These types will be used in follow-up commits to version the
NodeUpdatesInHorizon and ChanUpdatesInHorizon Store methods.
2026-03-31 09:14:49 +02:00
Elle Mouton
57a32b9232
graph/db: use exclusive end time for horizon queries per BOLT 07
BOLT 07 specifies that gossip_timestamp_filter range semantics are
"greater or equal to first_timestamp, and less than first_timestamp
plus timestamp_range", i.e. [start, end). Three of the four
implementations (KV ChanUpdatesInHorizon, KV NodeUpdatesInHorizon,
SQL NodeUpdatesInHorizon) were incorrectly using an inclusive end
time (<= instead of <). Only SQL ChanUpdatesInHorizon was correct.

This commit fixes the KV store's fetchNextChanUpdateBatch and
fetchNextNodeBatch to use >= (instead of >) for the end time break
condition, and < (instead of <=) for the hasMore check. It also
fixes the SQL GetNodesByLastUpdateRange query to use < instead of <=
on the end_time bound.

All godocs are updated to reference the BOLT 07 spec language and
explicitly document the [start, end) range semantics. New dedicated
tests (TestNodeUpdatesInHorizonExclusiveEnd and
TestChanUpdatesInHorizonExclusiveEnd) verify that items at exactly
the end time are excluded while items at the start time are included.
2026-03-31 09:14:48 +02:00
Elle Mouton
0806a27abc
graph/db: honor taproot feature bit in v1 funding script construction
Fix FundingPKScript() to check for the taproot staging feature bit on
v1 channel edges. When present, reconstruct a taproot funding script
via GenTaprootFundingScript instead of the legacy P2WSH multisig.

This is a pre-existing bug: private taproot channels have always been
stored as v1 gossip objects with the taproot feature bit, but
FundingPKScript() never checked for it. The discovery/gossiper layer
(makeFundingScript) already handled this correctly on the insertion
path, but any read path that called FundingPKScript() -- notably
ChannelView() used for chain filter reconstruction on restart --
would produce the wrong script.

Update the tests from the previous commit to assert the correct
taproot funding script instead of the legacy P2WSH script.
2026-03-27 14:19:18 +02:00
Elle Mouton
ad2dc38668
graph/db: add tests to document v1 taproot funding script bug
Private taproot channels are currently represented in the gossip/graph
layer as v1 gossip objects with the SimpleTaprootChannelsRequiredStaging
feature bit set on the v1 ChannelAnnouncement1.

However, FundingPKScript() on a v1 ChannelEdgeInfo unconditionally
reconstructs a legacy 2-of-2 P2WSH multisig script, ignoring the
taproot feature bit entirely. This means that code paths such as
ChannelView() (used to rebuild the chain watch filter on restart)
produce the wrong funding script for these channels.

This bug has always been present since private taproot channels were
first introduced. The discovery/gossiper path (makeFundingScript)
correctly honors the taproot bit when validating announcements on
insertion, but the graph DB read paths never did.

Add failing tests at both the model level (FundingPKScript) and the
graph level (ChannelView round-trip) to document this mismatch. The
next commit fixes the behavior so these tests pass.
2026-03-27 11:57:51 +02:00
Elle Mouton
844d0460a1
lnrpc: expose graph cache state in GetInfo
Add a GraphCacheStatus enum to GetInfoResponse so callers can tell
whether the graph cache is disabled, still loading, or fully loaded.

This makes the async graph cache startup state visible to operators and
clients without changing the existing DB fallback behaviour for reads.
2026-03-24 09:49:23 +02:00
Elle Mouton
4486b5261d
graph/db: allow async cache population
Introduce graphCacheState, a wrapper around GraphCache that tracks its
population lifecycle (loading -> loaded) and buffers concurrent mutations
during the initial DB scan. Once population completes, buffered updates
are replayed and the cache begins serving reads.

Start() now launches populateCache in a background goroutine by default.
While the cache is loading, all graph reads fall back to the database.
The KV iterators (ForEachNodeCacheable, ForEachChannelCacheable) now
respect context cancellation so that Stop() can interrupt a long-running
population.

Tests cover: concurrent reads during population, concurrent write replay,
shutdown cancellation during load, population failure with DB fallback,
and KV iterator cancellation.
2026-03-24 09:49:23 +02:00
Elle Mouton
ee4bc4dde5
graph/db: add startup context cancellation
Create a cancellable context in Start() and store its cancel function
on the struct. Stop() invokes it so that long-running DB iterations
(e.g. cache population) can be interrupted promptly during shutdown.
2026-03-23 15:12:57 +02:00
Elle Mouton
24d6e9d618
graph/db: move graph disabled check to inside populateCache
Refactor so that we don't have two layers of indentation later on when
we want to spin populateCache off into a goroutine.
2026-03-23 14:37:33 +02:00
Elle Mouton
19216ee32d
graph/db: add cacheLoaded atomic bool
Use this to block reading from the cache unless cacheLoaded returns
true. This will start being useful once cache population is done
asynchronously.
2026-03-23 14:37:32 +02:00
Elle Mouton
7f7b85ee22
graph/db: misc graphCache test updates
Clean up TestGraphCacheTraversal so that we are explicitly enabling the
graphCache. This removes the need to explicitly make calls to the cache.

Also remove a duplicate check from assertNodeNotInCache.
2026-03-23 14:37:32 +02:00
Elle Mouton
3c25195330
graph/db: don't let tests write to graphCache
Instead of letting tests set the graphCache to nil in order to simulate
it not being set, we instead make use of the WithUseGraphCache helper.
2026-03-23 14:37:32 +02:00
Elle Mouton
4ae4c70307
graph/db: version ChannelView and add v2 queries
Add a gossip version parameter to ChannelView in the Store interface,
KV and SQL implementations, and the ChannelGraph wrapper. The KVStore
guards v2 requests with ErrVersionNotSupportedForKVDB; the SQLStore
filters by the requested version.

Add three new SQL queries to support version-scoped channel lookups:

  - GetPublicV1ChannelsBySCID: public v1 channels in a SCID range,
    ordered by SCID.
  - GetPublicV2ChannelsBySCID: public v2 channels in a SCID range,
    ordered by SCID.
  - ListChannelsPaginatedV2: paginate v2 channels by internal DB ID,
    used by ChanUpdateRange.

Add TestVersionedDBs/channel_view to verify that v1 and v2 channel
views each return only their respective channels.
2026-03-16 11:29:41 +02:00
Elle Mouton
8a7afc1bac
multi: version ForEachNode, ForEachNodeCached, NumZombies
Add a gossip version parameter to ForEachNode, ForEachNodeCached, and
NumZombies in the Store interface and propagate it through the KV and
SQL implementations and the ChannelGraph wrapper.

The KVStore gates each method against GossipVersion1, returning
ErrVersionNotSupportedForKVDB for any other version. The SQLStore uses
the version to filter the underlying queries.

All call sites—routing graph, autopilot, RPC server, and the graph
migration integration test—are updated to pass the appropriate version
explicitly.
2026-03-16 11:29:41 +02:00
Elle Mouton
50b2567a83
graph/db: add VersionedGraph routing/cache methods
Add version-free shadow methods to VersionedGraph so it satisfies the
routing.Graph, graphdb.NodeTraverser, and related interfaces used by the
channel router and RPC layer.

FetchNodeFeatures and ForEachNodeDirectedChannel delegate to the graph
cache when available, falling back to the store with the baked-in
version. ForEachNode, ForEachNodeCached, ChannelView, and
NodeUpdatesInHorizon all forward to the embedded ChannelGraph with the
version pre-applied.

Update server.go and rpcserver.go to pass s.v1Graph (a *VersionedGraph
wrapping the main graphDB with GossipVersion1) wherever the routing and
session interfaces are needed, replacing direct *ChannelGraph references
that no longer satisfy those interfaces after the version parameters were
added.
2026-03-16 11:29:41 +02:00
Elle Mouton
084bac6e1e
graph/db: version DeleteChannelEdges, IsPublicNode, IsZombieEdge
Propagate the gossip version parameter through DeleteChannelEdges,
IsPublicNode, and IsZombieEdge on ChannelGraph, passing it down to the
underlying Store. Previously these methods hard-coded GossipVersion1
internally; surfacing the parameter lets callers operate on the version
appropriate for the channel.

Also fix two call sites that were still passing *ChannelGraph where a
version-aware interface was expected:

  - rpcserver.go AddInvoice now uses s.v1Graph (a *VersionedGraph) so
    that the invoicesrpc.GraphSource interface—whose IsPublicNode method
    does not take a version parameter—is satisfied.
  - subrpcserver_config.go wraps graphDB in NewVersionedGraph with
    GossipVersion1 when populating the invoicesrpc config Graph field
    via reflection, for the same reason.
2026-03-16 11:29:41 +02:00
Elle Mouton
3c06daed8b
graph/db: version FilterChannelRange
Add a gossip version parameter to FilterChannelRange in the Store interface,
both KV and SQL implementations, and the ChannelGraph wrapper.

KVStore guards against non-v1 versions with ErrVersionNotSupportedForKVDB.
SQLStore accepts any known gossip version, filtering the channel results by
version and using it in policy lookups. The SQL query still uses
GetPublicV1ChannelsBySCID for now (a TODO marks where a version-aware query
will be substituted in a follow-up).

VersionedGraph.FilterChannelRange shadows the ChannelGraph method with a
version-free signature, passing its baked-in version to the store. This keeps
the ChannelGraphTimeSeries interface and ChanSeries implementation unchanged.

Add TestFilterChannelRangeVersionGuard to verify that the KV store returns
ErrVersionNotSupportedForKVDB for v2 requests while the SQL store handles
them gracefully.
2026-03-16 11:29:40 +02:00
Elle Mouton
23288dce6f
graph/db: version MarkEdgeZombie
Add a gossip version parameter to MarkEdgeZombie in the Store interface,
both KV and SQL implementations, and the ChannelGraph wrapper, following
the same pattern established for MarkEdgeLive.

KVStore guards against non-v1 versions with ErrVersionNotSupportedForKVDB.
SQLStore accepts any known gossip version and uses it in the UpsertZombieChannel
call and cache invalidation.

Builder.MarkZombieEdge (the ad-hoc path for validation failures) passes
GossipVersion1 as all channels in that path are v1.
2026-03-16 11:29:40 +02:00
Elle Mouton
cb99637f0d
graph,discovery: version IsZombieChannel
Change the IsZombieChannel / isStillZombieChannel function signature
throughout the gossip and routing stacks from
func(time.Time, time.Time) bool to func(ChannelUpdateInfo) bool.

This allows zombie detection to inspect the full channel update info—
including version and freshness type—rather than receiving two raw unix
timestamps that carry no meaning for v2 channels.

Builder.IsZombieChannel is updated to extract version-appropriate
freshness from the ChannelUpdateInfo: unix-time expiry for v1, and a
block-count expiry (derived from ChannelPruneExpiry and
avgBitcoinBlockTime) for v2. The gossipSyncer, SyncManager, and gossiper
Config fields are updated to use the new signature.
2026-03-16 11:29:40 +02:00
Elle Mouton
2a9a431516
graph/db: rework ChannelUpdateInfo to use lnwire.Timestamp
Replace the separate Node1UpdateTimestamp/Node2UpdateTimestamp (time.Time)
and Node1BlockHeight/Node2BlockHeight (uint32) fields in ChannelUpdateInfo
with a unified Node1Freshness/Node2Freshness pair typed as lnwire.Timestamp.

The lnwire.Timestamp interface (added in the previous commit) is either a
UnixTimestamp (v1) or BlockHeightTimestamp (v2), making it structurally
impossible to pass block-height values into a v1 constructor or vice versa.

Two version-specific constructors replace the old single constructor:
  - NewV1ChannelUpdateInfo(scid, node1Time, node2Time time.Time)
  - NewV2ChannelUpdateInfo(scid, node1BlockHeight, node2BlockHeight uint32)

Add Node1FreshnessTime/Node2FreshnessTime helper methods on ChannelUpdateInfo
to extract the underlying time.Time from a UnixTimestamp, which the discovery
syncer needs for its v1-only isStale/isSkewed and isStillZombieChannel checks.

All call sites in kv_store, sql_store, graph_test, and syncer are updated
accordingly.
2026-03-16 11:25:32 +02:00
Elle Mouton
08823ac079
graph/db: version FilterKnownChanIDs callback
Change the isZombieChan callback in FilterKnownChanIDs (and its
ChannelGraphTimeSeries interface counterpart) from
func(time.Time, time.Time) bool to func(ChannelUpdateInfo) bool.

This allows callers to make version-aware zombie decisions using the full
ChannelUpdateInfo—including freshness type—rather than two raw time.Time
values that are meaningless for v2 channels.

The GossipSyncer adapts its v1-only isStillZombieChannel check by
wrapping it in a closure that extracts Node1/Node2FreshnessTime from the
ChannelUpdateInfo. All other call sites are updated accordingly.
2026-03-16 11:25:31 +02:00
Elle Mouton
e9eff6297f
graph/db: version MarkEdgeLive
Add a gossip version parameter to MarkEdgeLive throughout the stack:

- Store interface and KVStore/SQLStore implementations now take
  lnwire.GossipVersion; KVStore rejects non-v1 with
  ErrVersionNotSupportedForKVDB, SQLStore uses the version in the
  DeleteZombieChannel query and cache invalidation.
- ChannelGraph.MarkEdgeLive passes the version through to both the
  store call and the FetchChanInfos cache repopulation.
- FilterKnownChanIDs uses GossipVersion1 explicitly for its internal
  MarkEdgeLive call; this site will be properly versioned when
  FilterKnownChanIDs itself is versioned.
- graph.ChannelGraphSource interface and Builder.MarkEdgeLive updated
  accordingly.
- Discovery gossiper and test mock updated to pass GossipVersion1 at
  their (v1-only) call sites.
2026-03-16 11:25:31 +02:00
Elle Mouton
787dbcf7b3
graph: make zombie detection version-aware
Introduce isPolicyZombie to handle version-specific channel staleness.
For v1 policies, staleness is measured by wall-clock time since the last
update (unchanged behaviour). For v2 policies, staleness is measured by
the number of blocks elapsed since LastBlockHeight, using
avgBitcoinBlockTime to convert the configured prune expiry into an
equivalent block count.

isZombieChannel is simplified to call isPolicyZombie for each edge and
inline the strict/non-strict pruning logic directly, removing the prior
indirect call through IsZombieChannel.
2026-03-16 11:25:31 +02:00
ziggieXXX
2aec8f3380
Merge pull request #10485 from ziggie1984/migration-kvdb-sql-payments-part1
payments: kv-to-sql migration (tests + wiring)
2026-03-02 10:29:46 +01:00
ziggie
932fbc33f0
graph/db/migration1: fix defer commit/rollback in test tx executor
The defer closure checked a local err variable for commit/rollback
decisions, but err remained nil after a successful BeginTx. When
txBody failed, the error was returned directly without assigning to
err, so the defer always committed instead of rolling back.

Additionally, since err was not a named return value, the defer's
Commit error assignment was silently swallowed.

Replace the error-prone defer pattern with explicit rollback on
txBody failure and a direct Commit return.
2026-02-25 18:52:34 +01:00
Elle Mouton
262e9208b9
graphdb: thread topology update context 2026-02-25 16:11:47 +02:00
Elle Mouton
0bb0d66952
graphdb: pass context to GraphSession 2026-02-25 16:11:46 +02:00
Elle Mouton
8722a96a4e
graphdb: pass context to IsClosedScid 2026-02-25 16:11:46 +02:00
Elle Mouton
4dcaf1c16a
graphdb: pass context to PutClosedScid 2026-02-25 16:11:46 +02:00
Elle Mouton
68c5206017
graphdb: pass context to AddEdgeProof 2026-02-25 16:11:46 +02:00
Elle Mouton
3dc2efd7f3
graphdb: pass context to DisconnectBlockAtHeight 2026-02-25 16:11:46 +02:00