2020-05-03 17:42:53 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2020-09-28 14:09:03 +03:00
|
|
|
operatorName = config.nix-bitcoin.operator.name;
|
2020-05-03 17:42:53 +03:00
|
|
|
script = pkgs.writeScriptBin "nodeinfo" ''
|
|
|
|
set -eo pipefail
|
|
|
|
|
2021-01-14 15:24:10 +03:00
|
|
|
BITCOIND_ONION="$(cat /var/lib/onion-addresses/${operatorName}/bitcoind)"
|
2020-05-03 17:42:53 +03:00
|
|
|
echo BITCOIND_ONION="$BITCOIND_ONION"
|
|
|
|
|
|
|
|
if systemctl is-active --quiet clightning; then
|
|
|
|
CLIGHTNING_NODEID=$(lightning-cli getinfo | jq -r '.id')
|
2021-01-14 15:24:10 +03:00
|
|
|
CLIGHTNING_ONION="$(cat /var/lib/onion-addresses/${operatorName}/clightning)"
|
2020-05-03 17:42:53 +03:00
|
|
|
CLIGHTNING_ID="$CLIGHTNING_NODEID@$CLIGHTNING_ONION:9735"
|
|
|
|
echo CLIGHTNING_NODEID="$CLIGHTNING_NODEID"
|
|
|
|
echo CLIGHTNING_ONION="$CLIGHTNING_ONION"
|
|
|
|
echo CLIGHTNING_ID="$CLIGHTNING_ID"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if systemctl is-active --quiet lnd; then
|
|
|
|
LND_NODEID=$(lncli getinfo | jq -r '.uris[0]')
|
|
|
|
echo LND_NODEID="$LND_NODEID"
|
|
|
|
fi
|
|
|
|
|
2021-01-14 15:24:10 +03:00
|
|
|
NGINX_ONION_FILE=/var/lib/onion-addresses/${operatorName}/nginx
|
2020-05-03 17:42:53 +03:00
|
|
|
if [ -e "$NGINX_ONION_FILE" ]; then
|
|
|
|
NGINX_ONION="$(cat $NGINX_ONION_FILE)"
|
|
|
|
echo NGINX_ONION="$NGINX_ONION"
|
|
|
|
fi
|
|
|
|
|
2021-01-14 15:24:10 +03:00
|
|
|
LIQUIDD_ONION_FILE=/var/lib/onion-addresses/${operatorName}/liquidd
|
2020-05-03 17:42:53 +03:00
|
|
|
if [ -e "$LIQUIDD_ONION_FILE" ]; then
|
|
|
|
LIQUIDD_ONION="$(cat $LIQUIDD_ONION_FILE)"
|
|
|
|
echo LIQUIDD_ONION="$LIQUIDD_ONION"
|
|
|
|
fi
|
|
|
|
|
2021-01-14 15:24:10 +03:00
|
|
|
SPARKWALLET_ONION_FILE=/var/lib/onion-addresses/${operatorName}/spark-wallet
|
2020-05-03 17:42:53 +03:00
|
|
|
if [ -e "$SPARKWALLET_ONION_FILE" ]; then
|
|
|
|
SPARKWALLET_ONION="$(cat $SPARKWALLET_ONION_FILE)"
|
|
|
|
echo SPARKWALLET_ONION="http://$SPARKWALLET_ONION"
|
|
|
|
fi
|
|
|
|
|
2021-01-14 15:24:10 +03:00
|
|
|
ELECTRS_ONION_FILE=/var/lib/onion-addresses/${operatorName}/electrs
|
2020-05-03 17:42:53 +03:00
|
|
|
if [ -e "$ELECTRS_ONION_FILE" ]; then
|
|
|
|
ELECTRS_ONION="$(cat $ELECTRS_ONION_FILE)"
|
|
|
|
echo ELECTRS_ONION="$ELECTRS_ONION"
|
|
|
|
fi
|
|
|
|
|
2021-01-14 15:24:10 +03:00
|
|
|
BTCPAYSERVER_ONION_FILE=/var/lib/onion-addresses/${operatorName}/btcpayserver
|
2020-08-26 12:21:54 +03:00
|
|
|
if [ -e "$BTCPAYSERVER_ONION_FILE" ]; then
|
|
|
|
BTCPAYSERVER_ONION="$(cat $BTCPAYSERVER_ONION_FILE)"
|
|
|
|
echo BTCPAYSERVER_ONION="$BTCPAYSERVER_ONION"
|
|
|
|
fi
|
|
|
|
|
2021-01-14 15:24:10 +03:00
|
|
|
SSHD_ONION_FILE=/var/lib/onion-addresses/${operatorName}/sshd
|
2020-05-03 17:42:53 +03:00
|
|
|
if [ -e "$SSHD_ONION_FILE" ]; then
|
|
|
|
SSHD_ONION="$(cat $SSHD_ONION_FILE)"
|
|
|
|
echo SSHD_ONION="$SSHD_ONION"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
programs.nodeinfo = mkOption {
|
|
|
|
readOnly = true;
|
|
|
|
default = script;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
environment.systemPackages = [ script ];
|
|
|
|
};
|
|
|
|
}
|