-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eb21012 pool: add pkg, module & tests (kon) Pull request description: ACKs for top commit: erikarvstedt: ACK eb21012 nixbitcoin: ACK eb21012 Tree-SHA512: 0083b5f7bcc803c475cce3414923f43df0b80d6b85aaa54d6b5da637f2aaa7ea6e7525a5eff41be49921bed0214972e356c79b6e4086468c13716c925ec6f8b0
- Loading branch information
Showing
12 changed files
with
215 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.lightning-pool; | ||
nbLib = config.nix-bitcoin.lib; | ||
secretsDir = config.nix-bitcoin.secretsDir; | ||
network = config.services.bitcoind.network; | ||
rpclisten = "${cfg.rpcAddress}:${toString cfg.rpcPort}"; | ||
configFile = builtins.toFile "pool.conf" '' | ||
rpclisten=${rpclisten} | ||
restlisten=${cfg.restAddress}:${toString cfg.restPort} | ||
${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"} | ||
lnd.host=${config.services.lnd.rpcAddress}:${toString config.services.lnd.rpcPort} | ||
lnd.macaroondir=${config.services.lnd.networkDir} | ||
lnd.tlspath=${secretsDir}/lnd-cert | ||
${cfg.extraConfig} | ||
''; | ||
in { | ||
options.services.lightning-pool = { | ||
enable = mkEnableOption "lightning-pool"; | ||
rpcAddress = mkOption { | ||
type = types.str; | ||
default = "localhost"; | ||
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; | ||
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.enforceTor then config.services.tor.client.socksListenAddress 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.writeScriptBin "pool" '' | ||
exec ${cfg.package}/bin/pool \ | ||
--rpcserver ${rpclisten} \ | ||
--network ${network} \ | ||
--basedir '${cfg.dataDir}' "$@" | ||
''; | ||
description = "Binary to connect with the lightning-pool instance."; | ||
}; | ||
enforceTor = nbLib.enforceTor; | ||
}; | ||
|
||
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 // { | ||
ExecStart = "${cfg.package}/bin/poold --basedir='${cfg.dataDir}' --network=${network}"; | ||
User = "lnd"; | ||
Restart = "on-failure"; | ||
RestartSec = "10s"; | ||
ReadWritePaths = cfg.dataDir; | ||
} // (if cfg.enforceTor | ||
then nbLib.allowTor | ||
else nbLib.allowAnyIP); | ||
}; | ||
}; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ pkgs, buildGoModule, fetchurl, lib }: | ||
|
||
buildGoModule rec { | ||
pname = "lightning-pool"; | ||
version = "0.4.4-alpha"; | ||
|
||
src = fetchurl { | ||
url = "https://github.com/lightninglabs/pool/archive/v${version}.tar.gz"; | ||
# Use ./get-sha256.sh to fetch latest (verified) sha256 | ||
sha256 = "c50f3b10a4fa7ce1afd6a00fd6c44474f44c8c773de34261e62ae805540ab140"; | ||
}; | ||
|
||
subPackages = [ "cmd/pool" "cmd/poold" ]; | ||
|
||
vendorSha256 = "190qy3cz18ipv8ilpqhbaaxfi9j2isxpwhagzzspa3pwcpssrv52"; | ||
|
||
meta = with lib; { | ||
description = '' | ||
A non-custodial batched uniform clearing-price auction for Lightning Channel Leases (LCL) | ||
''; | ||
homepage = "https://github.com/lightninglabs/pool"; | ||
license = lib.licenses.mit; | ||
maintainers = with maintainers; [ sputn1ck ]; | ||
}; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#! /usr/bin/env nix-shell | ||
#! nix-shell -i bash -p git gnupg | ||
set -euo pipefail | ||
|
||
TMPDIR="$(mktemp -d -p /tmp)" | ||
trap "rm -rf $TMPDIR" EXIT | ||
cd $TMPDIR | ||
|
||
echo "Fetching latest release" | ||
git clone https://github.com/lightninglabs/pool 2> /dev/null | ||
cd pool | ||
latest=$(git describe --tags `git rev-list --tags --max-count=1`) | ||
echo "Latest release is ${latest}" | ||
|
||
# GPG verification | ||
export GNUPGHOME=$TMPDIR | ||
echo "Fetching Olaoluwa Osuntokun's key" | ||
gpg --keyserver hkps://keys.openpgp.org --recv-keys 60A1FA7DA5BFF08BDCBBE7903BBD59E99B280306 2> /dev/null | ||
echo "Fetching Oliver Gugger's key" | ||
gpg --keyserver hkps://keys.openpgp.org --recv-keys F4FC70F07310028424EFC20A8E4256593F177720 2> /dev/null | ||
|
||
echo "Verifying latest release" | ||
git verify-tag ${latest} | ||
|
||
echo "tag: ${latest}" | ||
# The prefix option is necessary because GitHub prefixes the archive contents in this format | ||
echo "sha256: $(git archive --format tar.gz --prefix=pool-${latest//v}/ ${latest} | sha256sum | cut -d\ -f1)" |
This file contains 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
This file contains 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
This file contains 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