Repository navigation
btcpayserver: document that the clightning backend controls the node's funds - #274
Conversation
|
Ugh, that is nasty. Maybe we should use clnrest to connect btcpayserver to cln instead so runes are allowed? Does using clnrest fix this issue? FTR: i am ok with merging this PR as is. I am just raising a question for possible future PR. |
viberaven
left a comment
There was a problem hiding this comment.
Reviewed 214db51fb893.
No actionable findings. Checked the documented access against BTCPay's configured Core Lightning socket/group membership, clnrest admin-rune permissions, and the actual LND macaroon permission list. The distinction is accurate: the Core Lightning connection provides unrestricted RPC access, while the default LND macaroon lacks the permissions to spend or manage channels. The mdBook build passes. This review covers the documentation change, not a fix for the broader access tracked in #87.
Review performed with Codex (GPT-6 Astra).
|
It would help, but BTCPay Server can't use it yet. Its Lightning library connects to Core Lightning only through JSON-RPC, over the With rune support, a rune that allows only the invoice methods would fix this for stores that only receive payments. Stores that pay out over Lightning would still need I believe there are two ways to fix this issue.
#87 tracks it, and I added these details there. I'll work on the upstream rune support in BTCPayServer.Lightning. |
…s funds With `lightningBackend = "clightning"`, BTCPay Server joins the clightning group and talks to lightningd over its RPC socket. The socket allows every method, so BTCPay Server can pay invoices, withdraw on-chain funds, open and close channels and start plugins. A bug in BTCPay Server, a malicious BTCPay plugin or a stolen admin session can drain the node. With `lnd`, BTCPay Server gets a macaroon that can't send funds. Neither the option nor the docs said so. Describe the access of each backend in the option description and in a new BTCPay Server section in docs/services.md, and recommend `lnd` when BTCPay Server should be limited. Part of bitcoinix#87. Assisted-by: Claude Code (Claude Opus 5.5)
The docs said that with `lnd` BTCPay Server can't send funds. That holds for the Lightning node only. A hot wallet created in BTCPay Server keeps its keys on the node, so BTCPay Server can spend it with either backend. The docs also advised switching to `lnd` without saying that bitcoinix turns on Core Lightning for BTCPay Server only while it's the backend. On a node that relies on that, the switch stops Core Lightning while it has channels, and nothing watches them. Say to set `services.clightning.enable = true` first, or to close the channels, and to give lnd another port, since both daemons default to 9735. Assisted-by: Claude Code (Claude Opus 5.5)
|
The content is accurate: I checked it against Must:
Tested: read the diff and checked the docs against the module on master. No local build, CI covers it. Assisted-by: Claude Code (Claude Opus 5.5) |
8f01f16 to
536049e
Compare
Part of #87.
With
services.btcpayserver.lightningBackend = "clightning", BTCPay Server joins theclightning group and talks to lightningd over its RPC socket
lightning-rpc. The socketallows every method. So BTCPay Server can pay invoices (
pay,xpay), withdraw on-chainfunds (
withdraw), open and close channels (fundchannel,close) and start plugins(
plugin), which run as the clightning user. A bug in BTCPay Server, a malicious BTCPayplugin or a stolen admin session can drain the node.
With
lnd, BTCPay Server gets its own macaroon (services.lnd.macaroons.btcpayserver).It can read the node's state and create invoices and addresses, but it can't send funds
or open or close channels.
Neither the option nor the docs said this. This PR changes no behavior. It adds these docs.
lightningBackendoption description, with arecommendation to use
lndwhen BTCPay Server should be limited.docs/services.mdwith the same facts and the reason. Italso says that with clnrest enabled, the clightning group can read clnrest's admin rune.
examples/configuration.nix.The second commit adds two notes that the red-team review found. The backend limits only
the Lightning node, so BTCPay Server can spend a hot wallet with either backend. And
bitcoinix turns on Core Lightning for BTCPay Server only while it's the backend. So before
a node with Core Lightning channels switches to
lnd, it needsservices.clightning.enable = trueand another lnd port, or its channels closed.bitcoinix can't give BTCPay Server a restricted rune today. BTCPay Server 2.4.7 uses
BTCPayServer.Lightning 1.7.14. Its Core Lightning client accepts only
type=clightning;server=unix://...ortcp://...and sends raw JSON-RPC. It has noclnrest or rune support.
It needs no versioning notice, since nothing changes at runtime.
Not in this PR
The fix for the access itself stays open in #87. I believe there are two ways to fix it.
lightning-rpcfor BTCPay Server. Receiving paymentsneeds
invoice,listinvoices,waitanyinvoice,getinfoanddelinvoice. TheLightning node page and payouts need more, including
xpay.through clnrest with a restricted rune.
Testing
nix eval .#ciTestInfopasses.nix build .#checks.x86_64-linux.module-configand.#checks.x86_64-linux.test-runnerpass.nix shell --inputs-from . nixpkgs#mdbook -c mdbook buildsucceeds. The new section andits link to Custom macaroons render.
module-config,test-runner,ci-workflowsand the mdBook build pass on the KVM host.Models
Claude Opus 5.5 wrote the change. Codex GPT-5.6 Sol, Codex GPT-6 Astra (two passes plus rechecks), Kimi K3.1 Pro (two passes), DeepSeek V4.1 Flash 1017 and GLM 5.3 reviewed it. Claude Opus 5.5 rebased it onto #224.