bitcoin: 30.0 -> 30.2 bitcoind: 30.0 -> 30.2 bitcoind-knots: 29.2.knots20251110 -> 29.3.knots20260210 btcpayserver: 2.2.1 -> 2.3.4 clightning: 25.09.2 -> 25.12.1 elementsd: 23.2.4 -> 23.3.2 lnd: 0.19.3-beta -> 0.20.1-beta lnd 0.20 makes its chain notifier subsystem ready later in startup than its RPC server. lightning-loop and lightning-pool both subscribe to chain notifications right after dialing lnd, which fails before the notifier is up and crashes the daemon. Add a 5s ExecStartPre sleep to both services as a temporary workaround.
114 lines
3.5 KiB
Nix
114 lines
3.5 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
let
|
|
options.services.lightning-pool = {
|
|
enable = mkEnableOption "Lightning Pool, a marketplace for inbound lightning liquidity ";
|
|
rpcAddress = mkOption {
|
|
type = types.str;
|
|
default = "127.0.0.1";
|
|
description = "Address to listen for gRPC connections.";
|
|
};
|
|
rpcPort = mkOption {
|
|
type = types.port;
|
|
default = 12010;
|
|
description = "Port to listen for gRPC connections.";
|
|
};
|
|
restAddress = mkOption {
|
|
type = types.str;
|
|
default = cfg.rpcAddress;
|
|
description = "Address to listen for REST connections.";
|
|
};
|
|
restPort = mkOption {
|
|
type = types.port;
|
|
default = 8281;
|
|
description = "Port to listen for REST connections.";
|
|
};
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = config.nix-bitcoin.pkgs.lightning-pool;
|
|
defaultText = "config.nix-bitcoin.pkgs.lightning-pool";
|
|
description = "The package providing lightning-pool binaries.";
|
|
};
|
|
dataDir = mkOption {
|
|
type = types.path;
|
|
default = "/var/lib/lightning-pool";
|
|
description = "The data directory for lightning-pool.";
|
|
};
|
|
proxy = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = if cfg.tor.proxy then config.nix-bitcoin.torClientAddressWithPort else null;
|
|
description = "host:port of SOCKS5 proxy for connnecting to the pool auction server.";
|
|
};
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
example = ''
|
|
debuglevel=trace
|
|
'';
|
|
description = "Extra lines appended to the configuration file.";
|
|
};
|
|
cli = mkOption {
|
|
default = pkgs.writers.writeBashBin "pool" ''
|
|
exec ${cfg.package}/bin/pool \
|
|
--rpcserver ${nbLib.addressWithPort cfg.rpcAddress cfg.rpcPort} \
|
|
--network ${network} \
|
|
--basedir '${cfg.dataDir}' "$@"
|
|
'';
|
|
defaultText = "(See source)";
|
|
description = "Binary to connect with the lightning-pool instance.";
|
|
};
|
|
tor = nbLib.tor;
|
|
};
|
|
|
|
cfg = config.services.lightning-pool;
|
|
nbLib = config.nix-bitcoin.lib;
|
|
|
|
lnd = config.services.lnd;
|
|
|
|
network = config.services.bitcoind.network;
|
|
configFile = builtins.toFile "pool.conf" ''
|
|
rpclisten=${cfg.rpcAddress}:${toString cfg.rpcPort}
|
|
restlisten=${cfg.restAddress}:${toString cfg.restPort}
|
|
${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"}
|
|
|
|
lnd.host=${lnd.rpcAddress}:${toString lnd.rpcPort}
|
|
lnd.macaroondir=${lnd.networkDir}
|
|
lnd.tlspath=${lnd.certPath}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
in {
|
|
inherit options;
|
|
|
|
config = mkIf cfg.enable {
|
|
services.lnd.enable = true;
|
|
|
|
environment.systemPackages = [ cfg.package (hiPrio cfg.cli) ];
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d '${cfg.dataDir}' 0770 lnd lnd - -"
|
|
];
|
|
|
|
systemd.services.lightning-pool = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
requires = [ "lnd.service" ];
|
|
after = [ "lnd.service" ];
|
|
preStart = ''
|
|
mkdir -p '${cfg.dataDir}/${network}'
|
|
ln -sfn ${configFile} '${cfg.dataDir}/${network}/poold.conf'
|
|
'';
|
|
serviceConfig = nbLib.defaultHardening // {
|
|
# TODO: temporary sleep to prevent race condition
|
|
ExecStartPre = "${pkgs.coreutils}/bin/sleep 5";
|
|
ExecStart = "${cfg.package}/bin/poold --basedir='${cfg.dataDir}' --network=${network}";
|
|
User = "lnd";
|
|
Restart = "on-failure";
|
|
RestartSec = "10s";
|
|
ReadWritePaths = [ cfg.dataDir ];
|
|
} // (nbLib.allowedIPAddresses cfg.tor.enforce)
|
|
// nbLib.allowNetlink; # required by gRPC-Go
|
|
};
|
|
};
|
|
}
|