Commit Graph
20018 Commits
Author SHA1 Message Date
ziggieXXX d5d151cee9 Merge pull request #10462 from ziggie1984/fix-prune-node-race
channeldb: fix race condition in link node pruning
2026-01-07 08:54:33 +01:00
ziggieXXX 99d07fdb78 Merge pull request #10367 from elnosh/rename-endorsement-accountable
multi: rename experimental endorsement signal to accountable
2026-01-06 18:02:22 +01:00
Yong d3ce622bde Merge pull request #10403 from gijswijs/fix-flatmap
Fix FlatMap implementation in Result type
2026-01-06 22:37:18 +08:00
elnosh 6f49bea52b server: remove accountability signal experiment period
In the previous iteration with endorsement
signaling, the recommendation was for the sender to
set it to 1 and that could have had privacy concerns
when first deploying given that the default was to
downgrade the signal to 0. In the latest proposal
the recommended default for both sending and
forwarding nodes is to set `accountable` to 0.
As a result, the dates have been removed given
that there are no privacy risks associated
with relaying the signal with zero values.
2026-01-06 09:12:34 -05:00
elnosh 34329c684e multi: rename experimental endorsement signal to accountable
Renames the endorsement signal to accountable to
match the latest proposal https://github.com/lightning/blips/pull/67
2026-01-06 09:12:31 -05:00
ziggie d9fb9092b6 multi: make sure previous inconsitent states are fixed
We make sure that nodes previously suffering from this error will
have a consitent db view when restarting their node.
2026-01-06 14:34:52 +01:00
ziggie 51f3c6f528 channeldb: fix race condition in link node pruning
This commit fixes a critical race condition in MarkChanFullyClosed and
pruneLinkNode where link nodes could be incorrectly deleted despite
having pending or open channels.

The race occurred because the check for open channels and the link node
deletion happened in separate database transactions:

  Thread A: TX1 checks open channels → [] (empty)
  Thread A: TX1 commits
  Thread B: Opens new channel with same peer
  Thread A: TX2 deletes link node (using stale data)
  Result: Link node deleted despite pending channel existing

This creates a TOCTOU (time-of-check to time-of-use) vulnerability where
database state changes between reading the channel count and deleting
the node.

Fix for MarkChanFullyClosed:
- Move link node deletion into the same transaction as the channel
  closing check, making the check-and-delete operation atomic

Fix for pruneLinkNode:
- Add double-check within the write transaction to verify no channels
  were opened since the caller's initial check
- Maintains performance by keeping early return for common case
- Prevents deletion if channels exist at delete time

This ensures the invariant: "link node exists iff channels exist"
is never violated, preventing database corruption and potential
connection issues.
2026-01-06 10:52:41 +01:00
Gijs van Dam e7b9515edd fn: fix Result[T].FlatMap
For a Result[T], FlatMap should apply f when the result is Ok, and
propagate the error unchanged when it's Err. The original code returns r
on Ok and tries to use r.left when Err, which is wrong. This commit
fixes that.

Secondly, the group of FlatMap/AndThen and OrElse functions and methods
are now properly tested with new unit tests.

fixes #10401
2026-01-06 10:51:49 +01:00
ziggieXXX 801de79cf1 Merge pull request #10476 from ziggie1984/fix-endorsement-testcases
itest: fix endorsement itests
2026-01-05 16:57:46 +01:00
ziggie 5f30797738 itest: fix endorsement itests
Due to the signaling period expiring tests had to be adopted bc
they were not taking the activation time period into account.
2026-01-05 14:28:14 +01:00
ziggieXXX ac006d73cf Merge pull request #10356 from Abdulkbk/ispublicnode-perf
graph: fix inefficient query for IsPublicNode
2026-01-05 10:32:56 +01:00
ziggieXXX eea4840086 Merge pull request #10249 from erickcestari/fix-scid-tlv-length
lnwire+tlv+route: enforce TLV length validation and add tests
2025-12-30 19:31:32 +01:00
Erick Cestari 523002984b docs: add release-notes 2025-12-29 19:19:53 -03:00
Erick Cestari 5a7925008e multi: enforce strict TLV length checks
This commit improves TLV decoding safety and consistency across multiple
packages by enforcing fixed-length requirements and adding unit tests to
prevent malformed TLV records from being accepted.

Changes include:

- lnwire:
  * Enforce 8-byte length in Fee TLV decoder.
  * Enforce PubNonceSize in Musig2Nonce TLV decoder.
  * Enforce 8-byte length in ShortChannelID TLV decoder.
  * Added roundtrip and invalid length tests for Fee, Musig2Nonce,
    and ShortChannelID records.

- routing/route:
  * Enforce Vertex TLV length (33 bytes).
  * Added encode/decode and invalid length tests for Vertex.

- tlv:
  * Enforce correct length in DBytes33 decoder (33 bytes).
  * Added tests ensuring all fixed-size primitive decoders reject
    incorrect TLV lengths.

By strictly validating TLV lengths, we prevent malformed or corrupted
TLV records from being silently accepted, improving protocol safety.
2025-12-29 19:18:49 -03:00
Abdullahi Yunus 68f558c865 docs: add release note 2025-12-24 18:08:46 +01:00
Abdullahi Yunus ac2cec462c graph: use UNION for isPublicNode query
In this commit we updated the IsPublicV1Node query to use UNION
instead of OR, since sqlite struggles to efficiently use
multiple indexes in a single query involving OR conditions across
different columns.

We use UNION ALL since the query doesn't care about duplicates.
2025-12-23 21:04:36 +01:00
Abdullahi Yunus 86cde4b93f graphdb: add benchmark for isPublicNode query
In this commit we add a benchmark to test the performance of
IsPublicNode query.
2025-12-23 21:04:36 +01:00
Yong 013f5c93ed Merge pull request #10455 from ziggie1984/fix-onchain-timeout-terminal
Fix flaky itest multihop testcase
2025-12-22 23:10:09 +08:00
ziggie c493f7d9dd itest: accept NO_ROUTE or TIMEOUT in testLocalClaimOutgoingHTLC
Fix flaky test due to race between channel closure propagation and
payment timeout. Both failure reasons are correct depending on timing.
2025-12-19 00:27:20 +01:00
Yong 91423ee519 Merge pull request #10449 from ziggie1984/bugfix/setsource-node-sql
server: fix timestamp comparison in setSelfNode
2025-12-16 16:58:25 +08:00
ziggie e5b0704d73 docs: add release-notes for LND 20.1 2025-12-16 08:21:11 +01:00
ziggie 865e1556d4 server: fix timestamp comparison in setSelfNode
Fix bug where setSelfNode compared only the seconds component of
timestamps instead of the full timestamp. This caused the node to
attempt persisting an older timestamp than what existed in the
database during restart, resulting in "sql: no rows in result set"
errors.
2025-12-16 08:21:11 +01:00
Olaoluwa Osuntokun 04f6108051 Merge pull request #10446 from ziggie1984/bugfix/backport-workflow
ci: fix some minor issues in the backport ci job
2025-12-15 10:59:36 -08:00
ziggieXXX 06cc0f3aa3 Merge pull request #10448 from ziggie1984/bugfix/fix-comment-lsp-heuristic
routerrpc: fix comment in lsp heuristic
2025-12-15 15:10:09 +01:00
Yong 0cc84d0b00 Merge pull request #10353 from starius/fix-rbf_coop_test
chancloser: stabilize remote RBF coop tests
2025-12-15 14:56:00 +08:00
Boris Nagaev d47d86ce0c chancloser: stabilize remote RBF coop tests
CI started panicking in TestRbfChannelFlushingTransitions/early_offer /
TestRbfCloseClosingNegotiationRemote (see GitHub Actions run
https://github.com/lightningnetwork/lnd/actions/runs/19155841408/job/54756127218?pr=10352)
because the cached remote offer could fire before the test harness
registered its mock CloseSigner expectations. When that happened,
the mock complained that CreateCloseProposal was unexpected:

panic:
assert: mock: I don't know what to return because the method call was unexpected.

Fix this by having assertSingleRemoteRbfIteration take a sendEvent callback
that receives the context and initial offer, so tests can install expectations
first and then fire the event via SendEvent (or the early-offer test's custom
flush sender).

Reproduction (on master)
------------------------
1. Modify lnwallet/chancloser/rbf_coop_test.go
   Add time.Sleep(10 * time.Millisecond) before the first call of
   closeHarness.assertSingleRemoteRbfIteration (in function
   TestRbfChannelFlushingTransitions).

2. go test ./lnwallet/chancloser -run TestRbfChannelFlushingTransitions/early_offer

3. The panic reproduces immediately.
2025-12-14 20:03:43 -03:00
ziggie 5580c40cb0 routerrpc: fix comment in lsp heuristic 2025-12-14 09:25:30 +01:00
ziggie dbb3a9e953 ci: fix some minor issues in the backport ci job
-Due to a newer version we need to use add_labels instead of just
 labels

-The backport PR will now also copy the milestones in case the
 milstones were set
2025-12-14 09:00:02 +01:00
ziggieXXX 9fcd7c2972 Merge pull request #10435 from ziggie1984/test-backport-workflow
Backport workflow
2025-12-13 00:16:24 +01:00
ziggie 4af13745e5 docs: add comprehensive backport workflow documentation
This commit adds detailed documentation for the automated backport
workflow and updates the contribution guidelines to reference it.

New documentation (docs/backport-workflow.md):
- Complete overview of the automated backport process
- Step-by-step usage instructions with examples
- Detailed explanation of workflow triggers and label format
- Technical details about workflow implementation
- Conflict resolution procedures and best practices
- Multiple backport scenarios and examples
- Comprehensive troubleshooting guide

Updated contribution guidelines (docs/code_contribution_guidelines.md):
- Replaced detailed backport instructions with brief overview
- Added reference to the new detailed documentation
- Keeps contribution guidelines focused and concise

The detailed documentation provides:
- How to use backport labels correctly
- What happens when labels are added before/after merge
- How the workflow validates branches and handles errors
- Step-by-step conflict resolution instructions
- Solutions for common problems and edge cases
- Examples of valid vs invalid label formats

This documentation ensures contributors and maintainers have clear
guidance on using the automated backport workflow effectively.
2025-12-12 22:48:51 +01:00
ziggie 7ecdb9b807 ci: add automated backport workflow
This commit introduces an automated GitHub Actions workflow to streamline
the backporting process for merged PRs from master to release branches.

Key features:
- Triggers on merged PRs with labels matching 'backport-v*' pattern
  (e.g., backport-v0.20.x-branch)
- Validates that target branches exist before attempting backport
- Creates separate backport PRs for each target branch
- Automatically adds 'no-changelog' label to backport PRs
- Handles merge conflicts by creating draft PRs with conflict markers
- Supports multiple simultaneous backports via multiple labels

Workflow steps:
1. Checkout repository with full git history
2. Validate all target branches exist in the remote repository
3. For each valid backport label:
   - Create a new branch (backport-<pr-num>-to-<target-branch>)
   - Cherry-pick commits from the master PR
   - Create a new PR targeting the release branch
   - Link back to the original PR
4. If conflicts occur, create a draft PR for manual resolution

Label format:
- Valid: backport-v0.20.x-branch, backport-v0.19.x-branch
- Invalid: backport candidate, backport-candidate, backport-needed

This automation reduces manual work and ensures consistency in the
backporting process while maintaining full visibility and control
for maintainers.
2025-12-12 22:48:51 +01:00
Elle 363aeb5f15 Merge pull request #10410 from ellemouton/bypassBuilderForMissingEdges
localchans: populate FundingScript for missing edges
2025-12-12 10:22:14 +02:00
ziggieXXX f4b3ed73e3 Merge pull request #10440 from ziggie1984/bugfix/itest-race
funding: fix race in itest for zero-conf funding
2025-12-12 00:05:27 +01:00
Elle Mouton da9868b06d docs: update release notes 2025-12-11 18:13:47 +02:00
Elle Mouton 710c676662 localchans: populate funding script for missing edges
When creating a missing edge, we need to populate the funding script too
so that the graph builder can update its ChainView appropriately. We use
the MakeFundingScript helper from the funding package which ensures that
we are using the same logic for creating a funding script as is used for
any of the channels that we own.
2025-12-11 18:13:47 +02:00
Elle Mouton 66bc0b8f8e funding: export MakeFundingScript
So that we can re-use this helper else where.
2025-12-11 17:54:57 +02:00
ziggie fe9a3e103b funding: fix race in itest for zero-conf funding
Fix a race condition where forwarding through a public zero-conf channel
could fail with UnknownNextPeer when using the confirmed SCID. The issue
occurred because ReportShortChanID (which updates the switch's baseIndex
to handle the confirmed SCID) was called AFTER addToGraph (which announces
the confirmed SCID to the network).

With slow backends like postgres, addToGraph takes significant time,
creating a window where other nodes learn about the confirmed SCID from
gossip and attempt to route through it, but the receiving node's switch
hasn't been updated yet to handle forwards using the confirmed SCID.

The fix reorders operations to call ReportShortChanID before addToGraph,
ensuring the switch is ready to handle the confirmed SCID before it's
announced to the network. Forwards using either the alias or confirmed
SCID will work since getLinkByMapping uses baseIndex to map both to the
same link in forwardingIndex.

Fixes flaky test: zero_conf-channel_policy_update_public_zero_conf
2025-12-10 19:44:18 +01:00
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