Skip to content

Factor out RTL’s systemd proxy and share LND’s IPv6-safe gRPC endpoint - #334

Merged
prusnak merged 2 commits into
bitcoinix:masterfrom
viberaven:refactor/web-proxy-lnd-rpc
Nov 25, 2026
Merged

prusnak merged 2 commits into
bitcoinix:masterfrom
viberaven:refactor/web-proxy-lnd-rpc

Conversation

@viberaven

@viberaven viberaven commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

This PR extracts two independent changes from #326. Each can be reviewed as a separate commit.

  1. RTL socket proxy. Move RTL’s systemd socket and proxy service into a reusable NixOS module. Systemd still reserves the HTTP port while RTL is stopped and forwards connections to RTL’s Unix socket. The rtlIPv6 VM permissions check now uses the configured listener, and only scenarios that enable RTL read its address. The shared module validates the port and preserves the secrets and resolver masks when a dashboard has no data directory. Commit 46cb2f56
  2. LND gRPC endpoint. Use one endpoint for the LND listener, lncli, macaroon creation, charge-lnd and Unbeholden LNURL. Bare and bracketed IPv6 inputs produce the same endpoint syntax. Certificates use the bare IP, and clients keep the configured address when verifying TLS, including wildcard addresses. Empty hosts, whitespace and malformed brackets fail evaluation. Commit b0367d66

The LND module test covers loopback and wildcard addresses on a custom port. The unbeholden-lnurl-lnd regtest VM runs both gRPC clients against [::].

Local verification

The rtlIPv6 VM passed on x86_64 Linux. The RTL commit and the PR head produce the same test derivation. The unbeholden-lnurl-lnd VM passed on the PR head. nix flake check --all-systems, the CI test-driver evaluation (nix eval --raw .#ciTestInfo), shellcheck, release-note validation, and the empty LND RPC host diagnostic also passed.

Applying the complete pre-rebase diff (2fbd6ef5..71196a9e) directly to master at a760f5d3 produced the same Git tree (0b34b85e) as the two commits above.

@github-actions github-actions Bot added area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: feature New capability or service size: L 100–499 changed lines (additions + deletions) labels Nov 25, 2026
@viberaven
viberaven force-pushed the refactor/web-proxy-lnd-rpc branch from 23faed5 to 405a08f Compare November 25, 2026 10:02
@viberaven viberaven changed the title Extract RTL’s socket proxy and fix LND gRPC endpoints for IPv6 Factor out RTL’s systemd proxy and share LND’s IPv6-safe gRPC endpoint Nov 25, 2026
@prusnak
prusnak requested a review from ostermayer November 25, 2026 10:26
@prusnak prusnak added this to the v0.2.1 milestone Nov 25, 2026

@ostermayer ostermayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the gate on both commits with GPT-6 Astra, Kimi K3.1 Pro twice, DeepSeek V4.1 Flash and Gemini 4 Carbon. RTL's units come out of the extraction the same as on master for every config I evaluated, including ::1, ::, tor.enforce, clightning, a custom user and group, and netns. The shared endpoint gives lnd, lncli, the macaroon setup, charge-lnd and Unbeholden LNURL the same address, and the CI run of unbeholden-lnurl-lnd shows all of them on [::]:10009. Two reviewers thought the clients' IP filters would block a wildcard target. They don't, because the kernel sends a connect to 0.0.0.0 or :: to loopback before the filter sees the packets. One small point is inline.

web-interface-proxy.nix now has the address check for the socket, but the port != 0 check that goes with it stays in rtl.nix. That's fine while RTL is the only user. A second dashboard on the module would need its own copy.

Comment thread modules/lnd.nix Resolved
@ostermayer ostermayer added type: bug Behaviour is wrong vs. documented or intended type: maintenance No user-visible change: refactor, CI, deps, tooling, docs-only labels Nov 25, 2026
@viberaven

Copy link
Copy Markdown
Contributor Author

Addressed both review points in 6c6e987.

  • LND validates services.lnd.rpcAddress before stripping IPv6 brackets. A lone [ or ] now fails evaluation, so a typo cannot turn into a listener on all interfaces. I verified this with manual TLS secrets and added regression cases for empty, partial, and nested brackets. The upgrade note covers nodes that used an empty host as a wildcard.
  • The shared systemd proxy now checks that its TCP port is nonzero. I verified the check with a second service name and confirmed it only applies when the proxy is active.

nix flake check --all-systems, CI test-driver evaluation, and release-note validation passed locally. Nix reused passing results for the rtlIPv6 and unbeholden-lnurl-lnd VM scenarios.

@ostermayer ostermayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked 6c6e987 with GPT-6 Astra and an eval on the KVM host. The bracket check and the moved port assertion hold. One point is inline.

Comment thread modules/lnd.nix Resolved

@ostermayer ostermayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the empty-host migration guidance and upgrade notice. The rpcEndpoint sharing and proxy extraction look solid overall; I left a few notes on whitespace handling in rpcAddress, the 0.2.1 upgrade doc link and manual-cert SAN guidance, and making web-interface-proxy.nix safe for services with optional settings.

Comment thread modules/lnd.nix Resolved
Comment thread modules/lnd.nix Resolved
Comment thread test/configuration.nix Resolved
Comment thread modules/web-interface-proxy.nix Resolved
@viberaven
viberaven force-pushed the refactor/web-proxy-lnd-rpc branch from 56b6126 to fa4814d Compare November 25, 2026 15:52

@ostermayer ostermayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the gate on fa4814d with Gemini 4 Carbon (high), Gemini 4 Neon (high), Kimi K3.1 Pro (max, x2) and DeepSeek V4.1 Flash 1017 (max). All five points from the previous round are fixed. Three passes claimed :: and :10009 are dual-stack in Go, which isn't true for LND because lncfg.ListenOnAddress maps ResolveTCPAddr addresses without IPv4 bytes to tcp6, so IPv6-only is right. Two small points are inline.

Comment thread modules/web-interface-proxy.nix Resolved
Comment thread test/ci/check-lnd-rpc-error.sh Resolved

@sebsgent sebsgent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: no must-fix or should-fix items.

Tested: at 71196a9, evaluated RTL with LND on 127.0.0.1 and ::. The rtl-proxy-*.socket and rtl-proxy.service units and the check-rtl-address derivation are identical to master. A dashboard with dataDir = null keeps all four path masks; on fa4814d it got an empty InaccessiblePaths= line. A Go program that copies LND's ResolveTCPAddr and parseNetwork steps listens on tcp6 for an empty host and :: (IPv6 only, even with bindv6only=0), and on tcp4 for 0.0.0.0. So the notice and the upgrade note describe the listener families correctly. CI is green, including unbeholden-lnurl-lnd on [::] and the new error check.

Assisted-by: Claude Code (Claude Opus 5.5)

@ostermayer ostermayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the gate on 71196a9 with Gemini 4 Carbon (high), Gemini 4 Neon (high), Kimi K3.1 Pro (max, x2) and DeepSeek V4.1 Flash 1017 (max). Both points from fa4814d are fixed. A dashboard with a null or empty dataDir now keeps all of its InaccessiblePaths masks, and check-lnd-rpc-error.sh evaluates x86_64-linux cleanly regardless of the host platform or working directory.

Parameterize the socket and proxy service by dashboard name, Unix socket
path and user. Check the port in the shared module and copy the IP
filters the dashboard defines. Keep the secrets and resolver paths
masked even when the dashboard has no data directory.

Cover those optional settings in the module checks. Use RTL's configured
listener for the permissions test, including in the IPv6 VM, and read it
only in scenarios that enable RTL.

Assisted-by: OpenAI Codex (GPT-6.2 Astra)
Build the listener and client endpoints from the same address and port.
Bracket IPv6 in the endpoint and use the bare IP in the TLS certificate.
Use that endpoint for lncli, macaroon creation, charge-lnd and
Unbeholden LNURL, including when the configured IP is a wildcard.

Reject malformed brackets, whitespace and empty hosts during evaluation.
Show users of an empty host how to keep their intended listener and
check that the diagnostic points them to the upgrade guide.

Cover address formats and custom ports in the module checks. Run both
gRPC clients against the IPv6 wildcard in the LNURL regtest VM.

Assisted-by: OpenAI Codex (GPT-6.2 Astra)
@viberaven
viberaven force-pushed the refactor/web-proxy-lnd-rpc branch from 71196a9 to b0367d6 Compare November 25, 2026 21:40
@prusnak
prusnak merged commit 9e37b52 into bitcoinix:master Nov 25, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix size: L 100–499 changed lines (additions + deletions) type: bug Behaviour is wrong vs. documented or intended type: feature New capability or service type: maintenance No user-visible change: refactor, CI, deps, tooling, docs-only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants