Repository navigation
clightning, mempool: connect to bitcoind as their own RPC users - #277
Merged
prusnak merged 2 commits intoNov 18, 2026
Merged
Conversation
viberaven
reviewed
Nov 16, 2026
viberaven
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 1c0796fe84c4.
No actionable findings. Traced both new RPC users through generated usernames, passwords/HMACs, secret permissions, service group removal, and bitcoind whitelist construction. The shared public whitelist loses the service-specific methods, and the empty-whitelist override retains its documented meaning. The migration guidance covers generated, supplied, and remote-node credentials and removal of the old remote grants. Local module-config and mdBook builds pass. I inspected the per-user RPC assertions and successful CI results; I did not rerun the service VMs locally.
Review performed with Codex (GPT-6 Astra).
ostermayer
force-pushed
the
bitcoind-rpc-user-per-service
branch
from
November 18, 2026 00:19
1c0796f to
28301ae
Compare
clightning added getblockfrompeer and mempool added gettxoutsetinfo to the whitelist of the `public` RPC user. `rpcwhitelist` is a list option, so the module system merged both into one list, and every service that connects as `public` got them. With mempool enabled, electrs, fulcrum and lnd could call gettxoutsetinfo, which walks the whole UTXO set and can keep bitcoind busy for minutes. BTCPay's user builds on the public list, so it got gettxoutsetinfo too. Give clightning and mempool their own RPC users, as btcpayserver has, with the public whitelist plus the method that each of them calls. An empty public whitelist disables whitelisting, so their whitelists stay empty then too. Each user gets its own generated password and HMAC. The public user keeps only the base whitelist. The two services leave the bitcoinrpc-public group, since they no longer read its password. Setups that supply secrets themselves have to create the secrets of the new users, and setups with bitcoind on another node also the users there. So add a 0.2.0 notice for every config with clightning or mempool. Document the new users in the guide for a bitcoind on another node. The 0.1.5 notice for mempool's RPC password is evaluated against the current code, so point it and its upgrade notes at `bitcoin-rpcpassword-mempool`. A new test checks the 0.1.5 notices by their message, since later notices block every older config once 0.2.0 is released. Fixes bitcoinix#127. Assisted-by: Claude Code (Claude Opus 5.5)
ostermayer
force-pushed
the
bitcoind-rpc-user-per-service
branch
from
November 18, 2026 01:01
28301ae to
d422ca9
Compare
prusnak
previously approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #127.
clightning added
getblockfrompeerand mempool addedgettxoutsetinfoto the whitelist ofthe shared
publicRPC user.rpcwhitelistis a list option, so the module system mergedboth into one list for
public, and every service that connects aspublicgot them. Withmempool enabled, electrs, fulcrum and lnd could call
gettxoutsetinfo, which walks the wholeUTXO set and can keep bitcoind busy for minutes. BTCPay's user builds on the public list, so
it got
gettxoutsetinfotoo. The comment inbitcoind-rpc-public-whitelist.nixsaid eachmodule grants these methods to itself, which only btcpayserver did.
This PR gives clightning and mempool their own RPC users, as btcpayserver has:
clightning: the public whitelist plusgetblockfrompeerwhen bcli is the backend. Withtrustedcoin, it's the public whitelist alone.
mempool: the public whitelist plusgettxoutsetinfo.rpcwhitelistdisables whitelisting for its user. So when the publicwhitelist is empty, both new whitelists stay empty too, and the services keep the
unrestricted access they had through
public.bitcoin-rpcpassword-<user>,bitcoin-HMAC-<user>), owned like the btcpayserver ones.bitcoinrpc-publicgroup, since they no longer read its password.
publicuser keeps only the base whitelist. BTCPay's whitelist is now the base listplus
getblockfrompeer, which is what nbxplorer probes for. It never neededgettxoutsetinfo.The pinned trustedcoin 0.8.7 reads
bitcoin-rpcuserandbitcoin-rpcpasswordfromlightningd and calls
getblockchaininfo,getblockhash,getblock,getrawtransaction,estimatesmartfeeandsendrawtransaction. All of them are in the base list, so it keepsworking with the
clightninguser. It still logs that password at startup (#191), but nowit's the password of the clightning user, not the one that electrs, fulcrum and lnd share.
The other clightning plugins don't talk to bitcoind.
Migration
A 0.2.0 notice fires for every config that enables clightning or mempool. No option
marks a bitcoind on another node, since the
bitcoind-remote.nixpreset only changes thebitcoind unit. And configs that supply their own secrets have to act either way. So the
text depends on the config instead. With
nix-bitcoin.generateSecrets, it says there'snothing else to do when bitcoind runs on the node. Otherwise it says to create the new secrets first.
For a bitcoind on another node, it lists the whitelists to set there. It also says to
remove
getblockfrompeerandgettxoutsetinfofrom the remote public user if it hasthem, whatever the new config enables, since the old config may have added them. With
BTCPay Server, it says to set the remote BTCPay user's whitelist again, since that list
builds on the public one and had
gettxoutsetinfowith mempool.The released 0.1.5 notice for mempool's RPC password told users to save the password
to
bitcoin-rpcpassword-public. Notices are evaluated against the current code, whichreads
bitcoin-rpcpassword-mempool, so it now names that file. So does the 0.1.5 sectionof
docs/upgrading.md, which also says that releases before 0.2.0 readbitcoin-rpcpassword-public.docs/upgrading.mdsays what each setup has to do. The guide for a bitcoind on anothernode in
docs/configuration.mdnow lists the new users, their whitelists, theirpassword files, and the local HMAC files that setup checks.
The migration tests for the currencyrate and rebalance plugins and for mempool's RPC
password stay as master has them. Once 0.2.0 is released, later notices block every
older config there, so a new test checks the 0.1.5 notices by their message.
Testing
test/configuration.nix: new checks thatpublichas neither method,clightningandbtcpayserverhave onlygetblockfrompeer,mempoolhas onlygettxoutsetinfo, andclightningwith trustedcoin has neither. With an empty public whitelist, both newwhitelists are empty. Also that both services read their own
password and aren't in
bitcoinrpc-public, and what the notice says for which config,including the remote public and BTCPay whitelists.
test/suite/security.py, testrpc-whitelist:publiccan't call either method, andeach service user can call only its own. Before this change,
publiccould callgettxoutsetinfoin theregtestscenario.module-configandtest-runnerchecks pass, and the mdBook build succeeds.regtestscenario passes. The bitcoind log showspublicrefusedgettxoutsetinfoandgetblockfrompeer,mempoolrefusedgetblockfrompeer, andclightningandbtcpayserverrefusedgettxoutsetinfo.trustedcoinscenario fails, as it does on master 772846d. trustedcoin logsbitcoind RPC workingas userclightning, andrpc-whitelistpasses:clightningis refused
getblockfrompeerandgettxoutsetinfo. The failure is a startup race intrustedcoin, unrelated to this change. When clightning restarts right after bitcoind,
lightningd asks for the chain tip before trustedcoin's
OnInithas set up itsbitcoind client. trustedcoin then falls back to block explorers, which the VM can't
reach, returns
tip: 0, and lightningd exits withbitcoind has gone backwards.The start then hangs in clightning's
postStartuntil it times out.module-config,test-runner,ci-workflows,regtestandtrustedcoinpass on the KVM host.acknowledgedreplacescurrent, because master now rejects config version 0.2.0 before the release. It checks that a config at 0.2.0 doesn't get the notice once 0.2.0 is released. On master, the notice is a warning until 0.2.0 is released, and the tests pass withversion.nixat 0.1.6 and at 0.2.0. Deleting a 0.1.5 notice failstestMigrationNotices015withversion.nixat 0.1.6 and at 0.2.0.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 and #283. Kimi K3.1 Pro (two passes) and Claude Fable 5.2 reviewed both rebases.