Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible places where named args for integral literals may be used (e.g.
2026-12-01 18:36:07 |
There was a problem hiding this comment.
concept ACK
users of other projects that rely on Core have always wanted sth similar to this and implemented workarounds in the meantime:
there was also an attempt to add this back in 2017:
unfortunately, that attempt ran into a limitation in libevent's HTTP client. supporting Unix Domain sockets in bitcoin-cli required a libevent patch to pass an already-open Unix socket connection to the HTTP client. this was eventually addressed in libevent/libevent#1722, but by then Core had decided to moved away from libevent. anyway, with libevent dropped, this is no longer an issue
|
Don't forget libevent/libevent#1615 ! Its been a long time coming... now that that pesky little refactor is out of the way we can finally get to it ;-) |
|
concept ACK...i found an issue by running two nodes and noticed that second node can take over a live rpc unix socket path, if two nodes use different datadirs but the same -rpcbind=unix: the second node starts with no error..since it removes the first node socket file and creates its own then after that bitcoin cli talks to the second node.. the first node keeps running but becomes unreachable so with TCP the second bind fails with address already in use i reproduced this on regtest 1: for node A 2: for node B 3: ss -xlp | grep btc-hijack 4: $CLI stop; sleep 2 5: pgrep -a bitcoind 6: $CLI -rpcwait=0 getblockcount |
|
i noticed a change in bitcoin-cli the host header contains the resolved IP instead of the hostname given in i reproduced the result by running this py file on terminal 1 import socket
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind(("127.0.0.1", 18555))
srv.listen()
print("listening on 127.0.0.1:18555")
while True:
conn, _ = srv.accept()
request = conn.recv(4096).decode(errors="replace")
for line in request.split("\r\n"):
if line.lower().startswith("host:"):
print(line)
conn.close()on terminal 2 i ran this command and the output was |
6876eb2 to
022a6aa
Compare
|
push to 022a6aa:
Major change is copying the parameter format from |
022a6aa to
81b8369
Compare
|
push to 81b8369
|
ccbace1 to
c01d87c
Compare
|
push to c01d87c
That issue was also caught by running @hebasto nightly BSD tests on this branch: NetBSD (failed) I'll re-run the extra CI tests with this new fix in place |
Include unit tests to ensure the API matches CService
Co-authored-by: winterrdog <[email protected]>
Most functional tests will pass with --httpunix, which uses unix sockets instead of TCP for all RPC commands in the test. For now, only require interface_http, rpc_bind --httpunix in CI to cover the specific changes from this branch.
c01d87c to
31a19bf
Compare

Closes #5029
Accept unix socket paths as options for
-rpcbind=(server) and-rpcconnect=(bitcoin-cli). Options follow the same pattern asipcbind:=unixis a magic keyword that means<datadir>/http.sock=unix:relative/pathmeans<datadir>/relative/path=unix:/absolute/pathmeans/absolute/pathWe delete any existing
http.sockbefore callingbind()and do not clean up at shutdown.Because access is handled by the filesystem,
-rpcallowipis ignored for unix sockets and not required at all if we are only binding to unix sockets.Authentication by username/password/cookie is still required.
A new option
--httpunixis added to the test framework and added to test_runner forrpc_bind.pyandinterface_http.pyfor CI, but (like--usecli) most other tests should also pass with that option. When set, bitcoind is started with-rpcbind=unix...which overridestcp://localhostentirely.AuthProxyhas been extended to connect directly to the unix socket.Try it out!
Refactored code:
Back in #27375 we added unix socket support but it was isolated to the
Proxyclass. That created a bit of tech debt which we pay off in this PR. Two new classes are implemented:UnixSocketAddrreflects theCServiceAPI for generic unix sockets, without bitcoin-p2p-specific attributesSocketAddrholds a variant ofUnixSocketAddrandCserviceso classes likeProxyandHTTPServercan operate on an abstract level, with either socket type.CNetAddrandCServiceare left untouched -- they are somewhat dirty combinations of generic socket classes and bitcoin p2p code, adding unix sockets to those classes wouldn't make sense for bitcoin p2p operations and that's why this design was chosen.Follow-up suggestions:
Production code and test framework changes designed and authored by my own cranial meatball. Unit tests added by Opus. C++ cleaned up by Fable, security tightened by Kimi-k3 🧠 🤖 🤖 🤖