82 Commits
Author SHA1 Message Date
Jonas Nick b579fcc371 Merge fort-nix/nix-bitcoin#846: netns-isolation: fix netns-exec being executable by all normal users
34a18f92ee netns-isolation: fix netns-exec being executable by all normal users (Jonas Nick)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: 3aa359bb61967b76299918b893b85f5d92909029237cba892b367f94c82643268dceaf2928157b47d4973a8af81e5e9ef29651bc45db0e3b149966b16c41bc8b
2026-08-12 18:26:21 +00:00
Jonas Nick 34a18f92ee netns-isolation: fix netns-exec being executable by all normal users
The `netns-exec` wrapper was created with `group = ""`, which makes the
`security.wrappers` activation run `chown ${allowedUser}:`. GNU chown
resolves the trailing colon to the owner's login group, and because the
operator is defined with `isNormalUser = true`, that group is the shared
group `users`. Together with mode 550, this made the wrapper executable
by every normal user on the host instead of only by `allowedUser`.

The wrapper carries `cap_sys_admin=ep` and the NixOS security wrapper
performs no owner check, so any normal user could enter `nb-joinmarket`,
the only netns that `netns-exec` permits. This exposes joinmarketd's
unauthenticated control port on 127.0.0.1 inside that netns and allows
sending packets from the joinmarket netns address. This can only ever become a
problem if there's a second, normal user on the host.

Use mode 500 so that only `allowedUser` can execute the wrapper. Also
set the group to `root`, so that `users` doesn't silently become an
authorized group again if the mode is ever loosened.

The netns-isolation test asserted this property with
`runuser -u clightning -- netns-exec nb-bitcoind ip a`, which fails
regardless of the file mode, because `clightning` is a system user with
its own group and `nb-bitcoind` is not in netns-exec's allowlist.
Replace it with a check that a normal user is denied by the exec
permissions, and assert the reason for each failure instead of only the
exit status.
2026-08-09 19:40:39 +00:00
Jonas Nick e8328251af udpate nixos 25.11 -> 26.05 2026-08-08 06:54:06 +00:00
Erik Arvstedt 8f99c63303 update nixpkgs
btcpayserver: 1.13.7 -> 2.0.7
nbxplorer: 2.5.17 -> 2.5.23

Co-authored-by: Erik Arvstedt <erik.arvstedt@gmail.com>
2025-03-11 19:36:26 +00:00
Erik Arvstedt 4aaef5fdf4 services: use wants dependency where possible
Let A be a service that depends on another service B.
When A can gracefully handle failures and restarts of B, use
```
wants = [ "B.service" ];
after = [ "B.service" ];
```
instead of
```
requires = [ "B.service" ];
after = [ "B.service" ];
```
in the definition of A.

This way, A keeps running when B is stopped or restarted after a failure.
With `requires`, A is instead stopped when B is stopped or restarted due to a failure.

This brings two benefits:

1. Improved uptime
Examples:
- RTL keeps running when one lightning node has failed
- btcpayserver keeps running and accepting on-chain payments when the lightning node has crashed

2. Avoids a systemd bug where depending units (`A.service` in the
above example) are not restarted when their dependency fails
(issue github/systemd#18856, no full link to avoid spamming the issue).
In real world nix-bitcoin deployments, this issue was only likely to
appear when clightning failed during activation, causing depending
units (like `RTL`) to stop and not be restarted.
All services depending on `clightning` have now been changed to use
`wants`, thereby avoiding the bug.

Services `electrs` and `lightning-loop` fail when their respective
dependencies stop, so these services have not been changed.
I also haven't changed services `joinmarket` and
`joinmarket-yieldgenerator`. Further manual testing is needed to
determine if they can be switched to `wants`.
2025-01-29 20:44:26 +01:00
Erik Arvstedt 2d53b57636 tests.py: fix syntax warning
Fixes this warning from the NixOS VM test script linter:
SyntaxWarning: invalid escape sequence '\['
2024-12-14 10:52:27 +01:00
Erik Arvstedt daa3bfbae3 lndconnect: add clnrest 2024-11-27 21:35:46 +01:00
Erik Arvstedt 76ea066809 trustedcoin: 0.8.2 -> 2024-11-15
Supports bitcoind 28.0.
2024-11-15 19:37:56 +01:00
Erik Arvstedt 22c1424552 backups: fix for nixos 24.05 2024-07-20 22:41:18 +02:00
Jonas Nick 97eaa5a604 update nixpkgs
btcpayserver: 1.12.5 -> 1.13.1
clightning: 24.02.1 -> 24.02.2
hwi: 2.4.0 -> 3.0.0
nbxplorer: 2.5.0 -> 2.5.2

Don't update bitcoin to 27.0 due to compatibility issues with lnd.
2024-04-20 07:50:46 +00:00
Erik Arvstedt 457f066e08 tests/trustedcoin: fix
Sometimes trustedcoin outputs `tip: 0`.
Check for `returning block` instead.
2023-11-28 18:33:27 +00:00
Erik Arvstedt 1de259485b mempool: add module 2023-10-31 13:44:04 +01:00
Erik Arvstedt a66c9992d3 tests/trustedcoin: fix test
Sometimes the trustedcoin plugin prevents clightning from starting up
in an offline environment.
2023-10-23 12:12:29 +00:00
Erik Arvstedt ac59f93e63 trustedcoin: add regtest support, reenable test 2023-08-03 18:40:13 +02:00
Erik Arvstedt aa418869b3 tests/trustedcoin: extract fn 2023-08-03 18:40:12 +02:00
Erik Arvstedt 6de5029c49 tests/trustedcoin: refactor
- No need to wait for bitcoind:
  clightning being active implies that bitcoind is active.

- Remove redundant log checks
2023-08-03 18:40:12 +02:00
Erik Arvstedt 9b575e4f3f test/backups: check that bitcoind stops without errors 2023-06-02 10:50:11 +00:00
Jonas Nick 75e54bbb90 spark-wallet: remove package and module 2023-06-02 10:50:11 +00:00
Erik Arvstedt 29a95ea311 clightning-rest: update module to v0.10.3 2023-06-02 10:49:35 +00:00
Otto Sabart 4942130abe tests: add tests for trustedcoin clightning plugin 2023-04-11 21:00:00 +02:00
Erik Arvstedt f996ef37d9 lnd, clightning-rest: remove lndconnectOnion, add generic option lndconnect
For both lnd and clightning-rest, `lndconnectOnion` is replaced by
options `lndconnect.enable` and `lndconnect.onion`.

This allows using lndconnect without Tor.
2023-02-27 14:39:29 +01:00
Erik Arvstedt 77d58162e7 test: update to NixOS 22.11 2022-12-18 20:01:52 +01:00
nixbitcoin 17507835fc clightning: native database replication
Don't put `clightning.replication` options in
`examples/configuration.nix` until it is more "battle-tested."
2022-08-05 13:48:24 +00:00
Jonas Nick 34c4b61402 Merge fort-nix/nix-bitcoin#504: Add fulcrum module
7d7f2df006 fulcrum: add module (Erik Arvstedt)
edd8bd311c bitcoind-rpc-public-whitelist: add `ping`, `help` (Erik Arvstedt)
f946a7cd9b examples: use `mkDefault` for setting `system.stateVersion` (Erik Arvstedt)
79994d0bd2 tests: increase postgresql startup timeout (Erik Arvstedt)

Pull request description:

ACKs for top commit:
  nixbitcoin:
    ACK 7d7f2df006

Tree-SHA512: 866f0a40bb81ceb2008e6efbd415eeee201b9e56aa5ebc60fd1bb4b6eda300155faaa2e6492d8145b3c6084b1e8ef5ec7d4e0ff694beb328d2e5ed755c9d04b4
2022-07-22 13:11:40 +00:00
Erik Arvstedt 8dc4858872 bitcoind: remove banlist loader
Gmaxwell's banlist (https://people.xiph.org/~greg/banlist.cli.txt) is
no longer maintained and hasn't been updated since 2 years.
2022-07-15 14:45:37 +02:00
Erik Arvstedt 7d7f2df006 fulcrum: add module 2022-07-09 11:07:09 +02:00
Erik Arvstedt edfbe700e7 lnd: add certificate options extraIPs and extraDomains
This is useful for non-local access to the lnd REST server.
2022-07-07 16:09:26 +02:00
Erik Arvstedt f9315db52c clightning/feeadjuster: add test 2022-05-27 11:22:00 +02:00
Erik Arvstedt 84fe731c94 treewide: curl: exit with error status on HTTP errors
This makes scripts fail early on request errors.
Previously, curl exited with status 0 when enountering HTTP error status
codes.
`-fsS` equals `--fail --silent --show-error`.
2022-05-17 13:19:38 +02:00
Erik Arvstedt e2fee4bf1a lnd-rest-onion-service.nix: move to lndconnect-onion.nix, add clightning support
Option `services.lnd.restOnionService.package` has been removed.
There's not much use in overriding the [lndconnect pkg](https://github.com/LN-Zap/lndconnect).
2022-05-06 16:26:40 +02:00
Erik Arvstedt acf5fe69ad add standalone clightning-rest service
- Rename `services.rtl.cl-rest` to `services.clightning-rest`.
  `clightning-rest` is generally useful for connecting external REST clients
  to clightning.

- Add a dedicated network namespace in netns-isolation.

- Add nodeinfo entry.

- Add datadir (which contains REST auth data) to backups.
2022-05-06 16:26:40 +02:00
Erik Arvstedt 408486ac9c tests: update nbxplorer 2022-05-06 13:35:28 +00:00
Erik Arvstedt aa21fb454e tests: disable btcpayserver.lbtc for regtest
Previously, in case of btcpayserver.lbtc on regtest, nbxplorer just
printed a log error while trying to generate liquidd regtest blocks.
Now nbxplorer exits with an error, so disable lbtc.
2022-05-06 13:35:27 +00:00
nixbitcoin 4f74690292 joinmarket: 0.9.4 -> 0.9.5
Notes
- We can no longer test for `unknown error in JSON-RPC`. `jm-ob-watcher`
  now simply outputs `Starting ob-watcher`. Tested working on
  https://nixbitcoin.org/orderbook.
- Removed Agora IRC server since it is offline semi-permanently. Should
  probably also be removed upstream.
- Includes patch for
  https://github.com/JoinMarket-Org/joinmarket-clientserver/issues/1193
2022-03-30 11:25:45 +00:00
Jonas Nick 282454f16e update nixpkgs{,-unstable}
btcpayserver: 1.3.7 -> 1.4.4
electrs: 0.9.4 -> 0.9.5
lnd: 0.14.1-beta -> 0.14.2-beta
nbxplorer: 2.2.18 -> 2.2.20
2022-02-11 08:42:51 +00:00
Erik Arvstedt 8f641756ce tests: add TODO-EXTERNAL 2021-12-10 12:15:36 +00:00
Erik Arvstedt b2f7a80f9f tests: add compatibility with 21.11
Adapt to the new test driver and systemd versions.
2021-12-10 12:15:20 +00:00
Erik Arvstedt 62a2602e78 electrs: use dataDir for storing extra config
This is simpler and more memory-efficient.
We've also changed other services to use this appraoch.

Also remove unneded `wait_for_unit` in the electrs regtest test.
2021-11-29 13:22:44 +01:00
nixbitcoin 41c4dd041e test: add rtl & cl-rest 2021-11-09 14:13:49 +00:00
Erik Arvstedt 083e141e3e tests/btcpayserver: test bitcoind P2P connection in regtest
nbxplorer requires at least 100 blocks (coinbase maturity) in regtest.
2021-11-02 17:40:43 +01:00
Erik Arvstedt aada35fc7b minor improvements
- README: add matrix room

- examples/configuration.nix: explain why bitcoind is enabled by default

- btcpayserver: group lnd service settings

- clightning:
  Use public onion port only when the onion service is public

  This allows users to enable the onion service while announcing a
  non-onion public address.

- netns-isolation: move `readOnly` attr to the top

- tests: use mkDefault to allow for easier overriding

- tests/btcpayserver: test web server response
2021-10-30 15:34:48 +02:00
nixbitcoin d5ce1c43a8 test: make joinmarket work with regtest 2021-10-27 16:08:28 +02:00
Erik Arvstedt 75b89f3957 electrs: adapt to version 0.9.0
- `waitfornewblock` was previously not included in the public RPC
  whitelist because it's reserved for testing and marked as hidden
  in bitcoind.

- electrs changed its verbosity settings. `-vv` is now the best choice
  for normal usage.

- bitcoind option `dataDirReadableByGroup` is now unused.
  Because it can be valuable for other use cases and implementing
  it is intricate, we're keeping it for now.

- test: keep `nc` connection open because otherwise the electrs
  RPC server would now close the connection before sending a response.
2021-10-06 15:34:24 +02:00
nixbitcoin 5c14453389 joinmarket-ob-watcher: don't assert running, assert rpc failure
joinmarket-ob-watcher now makes extensive use of bitcoind because of
JoinMarket's new fidelity bond functionality. Therefore it fails on
non-synced nodes, as those in the test suite. We now test that the
service fails with the correct error, rather than asserting that it is
running.
2021-08-30 13:37:04 +02:00
Erik Arvstedt 7c876664b1 netns test: update matching of 'capsh' output
The output now contains multiple lines.
2021-08-14 10:46:42 +02:00
Erik Arvstedt 01804e6dfb tests: improve test script formatting
Remove annyoing spacing constraints enforced by the previous 'black' linter.
2021-08-14 10:46:42 +02:00
Erik Arvstedt 1be924529d tests: adapt to new linter
The Python test driver now uses 'pyflakes'.
Remove hacks that were needed for the 'black' linter.
2021-08-14 10:46:42 +02:00
Erik Arvstedt c1c663d0a9 tests: fix formatting 2021-08-14 10:46:42 +02:00
Erik Arvstedt 35fe939cf8 security: update /proc restriction mechanism
NixOS option `security.hideProcessInformation` for globally restricting
access to /proc has been removed.
Use per-service restrictions via 'ProtectProc' instead.

Rename
`nix-bitcoin.security.hideProcessInformation` to
`nix-bitcoin.security.dbusHideProcessInformation`
because this option now only implements the dbus restriction.
2021-08-14 10:46:41 +02:00
nixbitcoin 54810ce1bf btcpayserver: add L-BTC support 2021-08-10 10:04:54 +00:00