From 937aee00629393847a60871bb758995ee2825cce Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Fri, 16 Oct 2020 17:43:04 +0200 Subject: [PATCH] spark-wallet: add regtest support --- modules/clightning.nix | 11 ++++++++--- modules/spark-wallet.nix | 9 +-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/clightning.nix b/modules/clightning.nix index 2c32adf..d33aac0 100644 --- a/modules/clightning.nix +++ b/modules/clightning.nix @@ -68,6 +68,11 @@ in { default = "/var/lib/clightning"; description = "The data directory for clightning."; }; + networkDir = mkOption { + readOnly = true; + default = "${cfg.dataDir}/${network}"; + description = "The network data directory."; + }; extraConfig = mkOption { type = types.lines; default = ""; @@ -119,7 +124,7 @@ in { cp ${configFile} ${cfg.dataDir}/config chown -R '${cfg.user}:${cfg.group}' '${cfg.dataDir}' # The RPC socket has to be removed otherwise we might have stale sockets - rm -f ${cfg.dataDir}/bitcoin/lightning-rpc + rm -f ${cfg.networkDir}/lightning-rpc chmod 640 ${cfg.dataDir}/config echo "bitcoin-rpcpassword=$(cat ${config.nix-bitcoin.secretsDir}/bitcoin-rpcpassword-public)" >> '${cfg.dataDir}/config' ${optionalString cfg.announce-tor "echo announce-addr=$(cat /var/lib/onion-chef/clightning/clightning) >> '${cfg.dataDir}/config'"} @@ -136,11 +141,11 @@ in { ); # Wait until the rpc socket appears postStart = '' - while [[ ! -e ${cfg.dataDir}/${network}/lightning-rpc ]]; do + while [[ ! -e ${cfg.networkDir}/lightning-rpc ]]; do sleep 0.1 done # Needed to enable lightning-cli for users with group 'clightning' - chmod g+x ${cfg.dataDir}/${network} + chmod g+x ${cfg.networkDir} ''; }; }; diff --git a/modules/spark-wallet.nix b/modules/spark-wallet.nix index 9296359..af3760f 100644 --- a/modules/spark-wallet.nix +++ b/modules/spark-wallet.nix @@ -15,7 +15,7 @@ let publicURL="--public-url http://$(cat /var/lib/onion-chef/spark-wallet/spark-wallet)" ''} exec ${pkgs.nix-bitcoin.spark-wallet}/bin/spark-wallet \ - --ln-path '${cfg.ln-path}' \ + --ln-path '${config.services.clightning.networkDir}' \ --host ${cfg.host} \ --config '${config.nix-bitcoin.secretsDir}/spark-wallet-login' \ ${optionalString cfg.enforceTor torRateProvider} \ @@ -36,13 +36,6 @@ in { default = "localhost"; description = "http(s) server listen address."; }; - ln-path = mkOption { - type = types.path; - default = "${config.services.clightning.dataDir}/bitcoin"; - description = '' - "The path of the clightning network data directory."; - ''; - }; onion-service = mkOption { type = types.bool; default = false;