From 10a744a59845e59c7a31ac4fd922368110728047 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Fri, 26 Nov 2021 15:13:37 +0100 Subject: [PATCH] rtl: add option `extraCurrency` --- modules/rtl.nix | 18 +++++++++++++++++- test/tests.nix | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/rtl.nix b/modules/rtl.nix index f4111f3..095fe4a 100644 --- a/modules/rtl.nix +++ b/modules/rtl.nix @@ -49,6 +49,17 @@ let default = false; description = "Enable the Night UI Theme."; }; + extraCurrency = mkOption { + type = with types; nullOr str; + default = null; + example = "USD"; + description = '' + Currency code (ISO 4217) of the extra currency used for displaying balances. + When set, this option enables online currency rate fetching. + Warning: Rate fetching requires outgoing clearnet connections, so option + `tor.enforce` is automatically disabled. + ''; + }; user = mkOption { type = types.str; default = "rtl"; @@ -118,7 +129,10 @@ let ''"channelBackupPath": "${cfg.dataDir}/backup/lnd",'' } "logLevel": "INFO", - "fiatConversion": false, + "fiatConversion": ${if cfg.extraCurrency == null then "false" else "true"}, + ${optionalString (cfg.extraCurrency != null) + ''"currencyUnit": "${cfg.extraCurrency}",'' + } ${optionalString (isLnd && cfg.loop) ''"swapServerUrl": "https://${nbLib.addressWithPort lightning-loop.restAddress lightning-loop.restPort}",'' } @@ -190,6 +204,8 @@ in { "d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -" ]; + services.rtl.tor.enforce = mkIf (cfg.extraCurrency != null) false; + systemd.services.rtl = rec { wantedBy = [ "multi-user.target" ]; requires = optional cfg.nodes.clightning "cl-rest.service" ++ diff --git a/test/tests.nix b/test/tests.nix index 9afcd97..7f06a16 100644 --- a/test/tests.nix +++ b/test/tests.nix @@ -67,6 +67,7 @@ let nix-bitcoin.generateSecretsCmds.rtl = mkIf cfg.rtl.enable (mkForce '' echo a > rtl-password ''); + services.rtl.extraCurrency = mkDefault "CHF"; tests.spark-wallet = cfg.spark-wallet.enable;