clightning: add public port

Co-authored-by: Erik Arvstedt <erik.arvstedt@gmail.com>
This commit is contained in:
kon 2021-10-26 21:27:48 +02:00
parent bfe8ac972c
commit b6d1928e90

View File

@ -90,6 +90,12 @@ let
rpc-file-mode=0660 rpc-file-mode=0660
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
# If the clightning onion service is enabled, use the onion port as the public port
publicPort = if config.nix-bitcoin.onionServices.clightning.enable or false then
(builtins.elemAt config.services.tor.relay.onionServices.clightning.map 0).port
else
cfg.port;
in { in {
inherit options; inherit options;
@ -119,7 +125,7 @@ in {
{ {
echo "bitcoin-rpcpassword=$(cat ${config.nix-bitcoin.secretsDir}/bitcoin-rpcpassword-public)" echo "bitcoin-rpcpassword=$(cat ${config.nix-bitcoin.secretsDir}/bitcoin-rpcpassword-public)"
${optionalString (cfg.getPublicAddressCmd != "") '' ${optionalString (cfg.getPublicAddressCmd != "") ''
echo "announce-addr=$(${cfg.getPublicAddressCmd})" echo "announce-addr=$(${cfg.getPublicAddressCmd}):${toString publicPort}"
''} ''}
} >> '${cfg.dataDir}/config' } >> '${cfg.dataDir}/config'
''; '';