Commit Graph
19981 Commits
Author SHA1 Message Date
Yong 1e15efc473 Merge pull request #10439 from ziggie1984/bugfix/probing
Always add the payment address when probing an invoice
2025-12-10 22:39:58 +08:00
ziggie ac30443cc1 docs: add release-notes for LND 20.1 2025-12-10 09:49:57 +01:00
ziggie 1c4bcc3b7d routerrpc: fix payment address deep copy
using copy for a slice of size 0 will not copy anything so we need
to first initialize the slice before we do the deep copy.
2025-12-10 09:49:57 +01:00
Elle 3d7ff866f8 Merge pull request #10436 from ellemouton/musigRegisterAggNonce 2025-12-10 09:58:58 +02:00
Elle Mouton a7b61f3ec1 docs: add release notes for combined nonce RPC methods
Document the new MuSig2RegisterCombinedNonce and MuSig2GetCombinedNonce RPC
methods in the v0.21.0 release notes. These methods enable coordinator-based
signing patterns as an alternative to the standard MuSig2RegisterNonces
workflow.
2025-12-10 07:19:07 +02:00
Elle Mouton fb48697ffa itest+lntest: add coordinator pattern test for combined nonce
Add integration test for MuSig2RegisterCombinedNonce and
MuSig2GetCombinedNonce RPCs to verify the coordinator pattern workflow.

The test:
- Creates three signing sessions without initial nonce exchange
- Manually aggregates nonces using the coordinator pattern (btcec musig2)
- Tests v0.4.0 returns unsupported errors (as expected)
- Tests v1.0.0rc2 successfully registers and retrieves combined nonces
- Verifies mutual exclusivity (error: already have all nonces)
- Completes a full signing flow to ensure signatures are valid

Also adds the required RPC harness wrapper methods to lntest/rpc/signer.go for
the new RPCs and adds MuSig2RegisterNoncesErr wrapper for error testing.
2025-12-10 07:19:04 +02:00
Elle Mouton 16b9192dad signrpc: implement combined nonce RPC server handlers
Add server-side RPC handlers for MuSig2RegisterCombinedNonce and
MuSig2GetCombinedNonce.

The handlers:
- Delegate to the Signer interface methods
- Validate input (session ID format, combined nonce length)
- Include macaroon permissions (generate for register, read for get)

These handlers complete the server-side RPC implementation.
2025-12-10 07:15:06 +02:00
Elle Mouton c945f6749e input+signrpc+lnwallet+multi: implement combined nonce support
Add CombinedNonce() and RegisterCombinedNonce() methods with full implementation
stack.

Interface and core implementation:
- input/musig2.go: Added methods to MuSig2Session and MuSig2Signer interfaces
- input/musig2_session_manager.go: MusigSessionManager implementation using
  HaveAllNonces flag for state tracking (simplified, no extra fields)
- internal/musig2v040: Stub implementations returning ErrUnsupportedMethod
- Mock implementations (MockInputSigner, MockSigner, DummySigner)

RPC layer:
- lnrpc/signrpc/signer.proto: RPC method definitions and messages
- lnrpc/signrpc/signer.yaml: REST API endpoint mappings
- Generated protobuf code (all .pb.go files)
- lnwallet/rpcwallet/rpcwallet.go: RPCKeyRing client implementation

The proto types and RPCKeyRing are added together since RPCKeyRing implements
the Signer interface and requires proto types to fulfill the contract.

For v0.4.0, these methods return ErrUnsupportedMethod. Use MuSig2Version100RC2
to access these features.
2025-12-10 07:15:06 +02:00
Elle Mouton cbcb6a4dcf go.mod: update btcec dep
To include the update to the musig2 Session which allows the aggregate
nonce for the session to be registered instead of requiring the
individual nonces to be registered.
2025-12-10 07:14:59 +02:00
Olaoluwa Osuntokun 456d7dcf05 Merge pull request #10424 from MPins/sat_per_byte_remove_warning
docs: release-notes-0.21
2025-12-09 17:59:15 -08:00
Olaoluwa Osuntokun ea5466a127 Merge pull request #10412 from Roasbeef/faster-linter
make: use Docker named volumes for ~21x faster local linting (Mac OS)
2025-12-09 17:45:16 -08:00
Olaoluwa Osuntokun a21d436fb2 make: use Docker named volumes for ~21x faster local linting
This commit optimizes Docker cache mounting for the linter with a
CI-aware strategy:

**Local development (macOS/Windows)**: Uses Docker named volumes which
keep data inside Docker's native Linux filesystem, avoiding the slow
host-syncing overhead of bind mounts. This yields ~21x faster linting
on warm cache.

**CI (GitHub Actions)**: Uses bind mounts to host paths (`~/.cache/go-build`,
`~/go/pkg/mod`) that GitHub Actions already caches via the setup-go
action. This ensures CI benefits from cached dependencies across runs.

The Makefile detects CI mode via the `CI` environment variable that
GitHub Actions sets automatically.

Local benchmark results:
- Cold run (empty cache): ~2m 28s
- Warm run (cached): ~11s (~21x faster)

Key improvements in warm runs:
- Go packages loading: 1m 58s → 5.6s
- Linters execution: 20.5s → 2.7s
- Total execution: 2m 20s → 8.6s
2025-12-09 17:44:47 -08:00
Yong cb3991ea6e Merge pull request #10428 from ziggie1984/fix-sql-pool-exhaustion
graphdb: fix potential sql tx exhaustion
2025-12-09 21:09:50 +08:00
ziggie f289e4920e docs: add release-notes for LND 20.1 2025-12-09 11:51:47 +01:00
ziggie 2d25bce1bf graphdb: fix potential sql tx exhaustion
We should avoid taking the lock of a mutex inside transaction.
Currently we also take this lock in other places and there is a
chance that in case the application lock aquires the lock but
all transactions are already blocked waiting for the mutex to
unlock, we end up in a deadlock.
2025-12-09 11:51:46 +01:00
Elle bc670fab82 Merge pull request #10396 from ziggie1984/enhance-lsp-heuritic
Enhance Lsp Heuristic when probing a payment
2025-12-09 10:43:43 +02:00
MPins bf473431bd docs: release-notes-0.21
Warning message about removing the deprecated option --sat_per_byte
2025-12-08 14:31:37 -03:00
Yong 0a6907d44b Merge pull request #10415 from yyforyongyu/race-test-sql
github: add `unit-race` for sql tests
2025-12-08 22:40:18 +08:00
yyforyongyu 57448a90c8 github: add unit-race for sql tests 2025-12-08 19:31:56 +08:00
Yong d962b146b0 Merge pull request #10420 from ellemouton/removePubKeyCaching
graph: fix various races
2025-12-08 19:31:32 +08:00
Elle Mouton e68bf6c58d docs: add release notes for race condition fixes 2025-12-08 11:57:01 +02:00
Elle Mouton 9f715555c4 graph/db: fix race in DisconnectBlockAtHeight cache access
The DisconnectBlockAtHeight method was modifying the rejectCache and
chanCache without holding the cacheMu lock. This caused races with
other operations that properly held the lock, such as AddChannelEdge
which modifies the caches in its OnCommit callback while the batch
scheduler holds cacheMu.

Fix by acquiring cacheMu before removing channels from the caches.
2025-12-08 11:56:36 +02:00
Elle Mouton 31b3e7424d graph/db/models: fix race conditions in ChannelEdgeInfo
Both NodeKey1 and NodeKey2 methods had the same race condition as the
Node.PubKey method, where concurrent calls could race to write to the
cached fields.

Remove the caching for the same reasons: parsing overhead is minimal
and doesn't justify the complexity and race risk.
2025-12-08 11:56:36 +02:00
Elle Mouton 9906e61774 graph/db/models: fix race condition in Node.PubKey
The PubKey method had a race condition where concurrent calls could
all pass the nil check and race to write to the cached pubKey field.
This is a classic check-then-act race.

Remove the caching entirely to fix the race. The overhead of parsing
a public key is minimal and doesn't justify the added complexity and
race risk of caching.
2025-12-08 11:56:35 +02:00
Yong a76f22da9d Merge pull request #10419 from AbelLykens/patch-2
[docs] Document use-native-sql=true for SQL migration step 2
2025-12-04 19:27:30 +08:00
AbelLykens f811805c65 docs: update sql migration guide 2025-12-04 09:34:58 +00:00
Elle 20473482d4 Merge pull request #10371 from ellemouton/fixSourceNodeSetting
graph/db: fix SetSourceNode no rows error
2025-12-03 15:34:41 +02:00
Elle Mouton 3e0bc6b18c docs: add release note 2025-12-03 13:09:22 +02:00
Elle Mouton c04aa655b9 graph/db: fix SetSourceNode race with lenient upsert
This commit fixes a race condition where multiple goroutines call
SetSourceNode concurrently during startup, causing sql.ErrNoRows
errors. The race occurs when multiple code paths (setSelfNode,
createNewHiddenService, RPC updates) read the same old timestamp,
independently increment it to the same new value (T+1), and race to
write.

The fix uses the new UpsertSourceNode SQL query (without strict
timestamp constraint) instead of UpsertNode. This allows
last-write-wins semantics for our own node, ensuring all parameter
changes persist even when timestamps collide.

Refactored sql_store.go for reusability:
- upsertNodeAncillaryData: common logic for features/addresses/extras
- populateNodeParams: common parameter building with callback pattern
- buildNodeUpsertParams: builds params for strict UpsertNode
- buildSourceNodeUpsertParams: builds params for lenient UpsertSourceNode
- upsertSourceNode: new function using lenient query

Updated TestSetSourceNodeSameTimestamp to verify that concurrent
updates with the same timestamp now succeed and parameter changes
persist.

Fixes the itest error:
"unable to upsert source node: upserting node(...): sql: no rows in
result set"
2025-12-03 13:08:31 +02:00
Elle Mouton 8349a6f84d sqldb: add UpsertSelfNode query
This query is less strict in terms of the latest update timestamp field.
We want to be less strict with our own node data since we always want
our own updates recorded.
2025-12-03 13:08:31 +02:00
Elle Mouton 41615f74a5 graph/db: add test for SetSourceNode same timestamp behavior
This commit adds TestSetSourceNodeSameTimestamp to demonstrate the
current behavior when SetSourceNode is called with the same last update
timestamp. The test reveals a difference between the SQL and bbolt
implementations:

- SQL store returns sql.ErrNoRows when attempting to update with the
  same timestamp, as the upsert query's UPDATE clause requires the new
  timestamp to be strictly greater than the existing one
- bbolt store silently ignores stale updates and returns no error

This behavior is important to document because our own node
announcements may change quickly with the same timestamp, unlike
announcements from other nodes where same timestamp typically means
identical parameters.
2025-12-03 13:08:30 +02:00
Yong 4b1c4998ad Merge pull request #10399 from mohamedawnallah/handle-partial-tls-files
tls_manager: Handle partial TLS files
2025-12-03 18:27:39 +08:00
Mohamed Awnallah 0a6f69dd7e docs: update release notes 2025-12-03 09:13:23 +00:00
Olaoluwa Osuntokun 140248ba9d Merge pull request #10383 from ziggie1984/bugfix/fix-mission-control-startup
routing: allow misson control manager to startup despite errors
2025-12-02 16:19:15 -08:00
ziggie 17b77b64a3 docs: add release-notes for LND 20.1 2025-12-02 20:38:55 +01:00
ziggie f6bc88f348 routing: allow misson control manager to startup despite errors
We now allow the mission control manager to skip over deserializable
errors. We cannot repair this these results but we just skip over
it so we can startup properly.

When fetchAll() encounters entries that fail to deserialize, in
addition to skipping them, now also:

- Delete the corrupted entries from the database
- Remove them from the in-memory keysMap and keys tracking structures

This prevents corrupted entries from:
- Being counted toward maxRecords, which would cause valid entries
  to be pruned prematurely
- Persisting in the database indefinitely
- Causing inaccurate entry counts in startup logs
2025-12-02 20:38:55 +01:00
ziggie de0424eca8 docs: add release-notes for LND 20.1 2025-12-01 18:07:57 +01:00
ziggie 34619d4758 docs: update api documentation for estimateRouteFee 2025-12-01 18:07:56 +01:00
ziggie 0e6bab1730 itest: enhance testEstimateRouteFee with multi-LSP scenarios
This commit enhances the integration test to validate the LSP heuristic
end-to-end with real network topology and payment probing.

Network topology additions:
- Added Frank node as a private destination
- Created multi-LSP test scenario with Bob, Eve, and Dave as LSPs

New test cases:

1. "probe based estimate, public target with public hop hints"
   - Validates Rule 1: public invoice target routes directly
   - Even with public hop hints, direct routing is used
   - Expected: standard single-hop fees

2. "probe based estimate, multiple different public LSPs"
   - Validates multi-LSP worst-case selection
   - Frank has routes through Bob (low fee), Eve (HIGH fee), Dave (medium)
   - Expected: Eve's worst-case fees (most expensive)
   - Tests griefing protection (max 3 LSP probes)
2025-12-01 18:07:56 +01:00
ziggie 79fe67619b routerrpc: implement LSP heuristic and multi-LSP worst-case probing
This commit implements a comprehensive LSP (Lightning Service Provider)
detection heuristic and updates the payment probing logic to handle
multiple LSPs with worst-case fee estimation.

Key changes:

1. LSP Detection Heuristic (isLSP function):
   Implements three rules to detect LSP setups:
   - Rule 1: If invoice target is public → NOT an LSP (route directly)
   - Rule 2: If at least one destination hop is public → IS an LSP
   - Rule 3: If all destination hops are private → NOT an LSP

2. LSP Route Preparation (prepareLspRouteHints function):
   - Groups route hints by unique public LSP nodes
   - Filters out non-LSP routes based on the heuristic
   - Tracks worst-case fees and CLTV delays for each LSP
   - Returns adjusted route hints with LSP hop stripped

3. Multi-LSP Probing (probePaymentRequest updates):
   - Probes up to 3 unique LSPs maximum (griefing protection)
   - Selects the WORST-CASE (most expensive) route for conservative
     fee estimation
   - Adds comprehensive debug logging for worst-case selection process
   - Properly formats vertex logging using %v (calls Vertex.String())

The worst-case approach ensures users won't be surprised by higher fees
when the actual payment is sent, providing a more conservative and
reliable fee estimate.

This commit also  adds extensive unit test coverage for the LSP detection
heuristic and route preparation logic.

TestIsLsp:
- Edge cases: empty route hints, nil scenarios
- Rule 1: Public invoice target (3 tests)
- Rule 2: All private destination hops (4 tests)
- Rule 3: At least one public destination hop (6 tests)

TestPrepareLspRouteHints:
- LSP grouping and filtering logic
- Worst-case fee selection across route hints
- Worst-case CLTV delta tracking
- Adjusted route hints validation (LSP hop stripped)
- Multi-LSP scenarios with different fees
2025-12-01 18:07:56 +01:00
ziggie 48da56b285 routerrpc: add HasNode backend function for LSP heuristic
This commit adds the HasNode function to the RouterBackend struct,
which checks if a node exists in the graph (i.e., has public channels).
This function is needed by the LSP detection heuristic to determine
if a node is publicly reachable.

The function is wired up in rpcserver.go to query the graph database.
2025-11-29 01:04:28 +01:00
ziggie 06886e71b2 graph/db: fix HasNode comment
The comment was incorrectly referring to HasLightningNode but the
function is named HasNode. Update the comment to match the actual
function name.
2025-11-29 01:04:25 +01:00
Yong 0a2a5b29c7 Merge pull request #10394 from ziggie1984/add-back-globallock
lncfg: readd global lock for postgres and the channeldb_kv table
2025-11-28 20:19:40 +08:00
ziggie 565633578f docs: add release-notes for LND 20.1 2025-11-28 09:22:20 +01:00
ziggie 4f051d97ea lncfg+scripts: use configurable global lock for postgres backends
Replace hardcoded WithGlobalLock assignment with configurable
options wallet postgres backends. Also add the WithGlobalLock
option to the channeldb table for postgres backends.

Defaults:
- channeldb: false (allow concurrent access)
- wallet: true (maintain safe single-writer behavior)

Users can now override these defaults via:
- db.postgres.channeldb-with-global-lock
- db.postgres.walletdb-with-global-lock

This gives operators flexibility while maintaining safe defaults
until full native SQL migration is complete.

Moreover exclude db.postgres.walletdb-with-global-lock check
in the sample config file script. We cannot easily check the
correct default because we set it later in the LND startup
sequence so we exclude it.
2025-11-28 09:22:19 +01:00
ziggie 2e16efed30 sqldb: add global lock config options for postgres
Add two configuration options to control global lock usage for
different postgres database backends:

- ChannelDBWithGlobalLock: for channeldb access (default: false)
- WalletDBWithGlobalLock: for wallet database access (default: true)

These allow fine-grained control over which databases use global
locks, rather than hardcoding the behavior. This is a temporary
measure until the revocation log and wallet are migrated to native
SQL and become fully concurrent-safe.
2025-11-28 09:22:19 +01:00
Thiago Romão Barcala c7fe6425f3 tls_manager.go: handle case when either TLS pair files exist 2025-11-27 13:33:14 +00:00
Mohamed Awnallah c9dea6d621 tls_manager_test.go: reproduce partial tls files handling
When there is only one of the tls pairs (key/certificate) and the
other is missing, the TLS manager currently assumes it exists
and ignore generating them. This results in error propgated to user
that the other tls pair file is missing/not found.
2025-11-27 13:33:06 +00:00
Yong 85a5bf294c Merge pull request #10341 from bitromortac/2511-fix-tor-healthcheck
server: prevent duplicate onion addresses in getinfo
2025-11-27 18:40:27 +08:00
bitromortac b513efc5c1 docs: add release-notes for lnd v0.20.1 2025-11-26 16:58:45 +01:00