From 8aa28da110123c1d5de9dad343615dace8cb4337 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Fri, 26 Nov 2021 15:13:28 +0100 Subject: [PATCH] remove `recurring-donations` module This module has failed to evaluate for quite some time. We might bring it back someday with bolt12 and LNURL support. --- README.md | 1 - examples/configuration.nix | 16 ----- modules/default.nix | 1 - modules/modules.nix | 1 - modules/netns-isolation.nix | 4 -- modules/presets/enable-tor.nix | 1 - modules/recurring-donations.nix | 107 -------------------------------- 7 files changed, 131 deletions(-) delete mode 100644 modules/recurring-donations.nix diff --git a/README.md b/README.md index 2956de9..dea57e3 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,6 @@ NixOS modules ([src](modules/modules.nix)) * [liquid](https://github.com/elementsproject/elements) * [JoinMarket](https://github.com/joinmarket-org/joinmarket-clientserver) * [JoinMarket Orderbook Watcher](https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/docs/orderbook.md) - * [recurring-donations](modules/recurring-donations.nix): for periodic lightning payments * [bitcoin-core-hwi](https://github.com/bitcoin-core/HWI) * Helper * [netns-isolation](modules/netns-isolation.nix): isolates applications on the network-level via network namespaces diff --git a/examples/configuration.nix b/examples/configuration.nix index 03dd1ba..66212ff 100644 --- a/examples/configuration.nix +++ b/examples/configuration.nix @@ -145,22 +145,6 @@ # # Liquid can be controlled with command 'elements-cli'. - ### RECURRING-DONATIONS - # Set this to enable recurring donations. This is EXPERIMENTAL; it's - # not guaranteed that payments are succeeding or that you will notice payment - # failure. - # services.recurring-donations.enable = true; - # This automatically enables clightning. - # - # Specify the receivers of the donations. By default donations are every - # Monday at a randomized time. Check `journalctl -eu recurring-donations` or - # `lightning-cli listpayments` for successful lightning donations. - # services.recurring-donations.tallycoin = { - # "" = " - # "" = ; - # "djbooth007" = 1000; - # }; - ### Hardware wallets # Enable the following to allow using hardware wallets. # See https://github.com/bitcoin-core/HWI for more information. diff --git a/modules/default.nix b/modules/default.nix index 6cef1ed..f173f9a 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -8,7 +8,6 @@ presets.secure-node = ./presets/secure-node.nix; rtl = ./rtl.nix; spark-wallet = ./spark-wallet.nix; - recurring-donations = ./recurring-donations.nix; lnd = ./lnd.nix; charge-lnd = ./charge-lnd.nix; joinmarket = ./joinmarket.nix; diff --git a/modules/modules.nix b/modules/modules.nix index 428eff8..e7a6a63 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -25,7 +25,6 @@ ./joinmarket.nix ./joinmarket-ob-watcher.nix ./hardware-wallets.nix - ./recurring-donations.nix # Support features ./versioning.nix diff --git a/modules/netns-isolation.nix b/modules/netns-isolation.nix index ff39ac8..afce2a5 100644 --- a/modules/netns-isolation.nix +++ b/modules/netns-isolation.nix @@ -246,10 +246,6 @@ in { id = 17; # communicates with clightning over lightning-rpc socket }; - recurring-donations = { - id = 20; - # communicates with clightning over lightning-rpc socket - }; nginx = { id = 21; }; diff --git a/modules/presets/enable-tor.nix b/modules/presets/enable-tor.nix index 583c6c1..ccde835 100644 --- a/modules/presets/enable-tor.nix +++ b/modules/presets/enable-tor.nix @@ -19,7 +19,6 @@ in { # btcpayserver.enforceTor = true; nbxplorer.enforceTor = true; spark-wallet.enforceTor = true; - recurring-donations.enforceTor = true; lightning-pool.enforceTor = true; rtl.enforceTor = true; }; diff --git a/modules/recurring-donations.nix b/modules/recurring-donations.nix deleted file mode 100644 index 84922a0..0000000 --- a/modules/recurring-donations.nix +++ /dev/null @@ -1,107 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; -let - options.services.recurring-donations = { - enable = mkEnableOption "recurring-donations"; - tallycoin = mkOption { - type = types.attrs; - default = {}; - description = '' - This option is used to specify tallycoin donation receivers using an - attribute set. For example the following setting instructs the module - to repeatedly send 1000 satoshis to djbooth007. - { - "djbooth007" = 1000; - } - ''; - }; - interval = mkOption { - type = types.str; - default = "Mon *-*-* 00:00:00"; - description = '' - Schedules the donations. Default is weekly on Mon 00:00:00. See `man - systemd.time` for further options. - ''; - }; - randomizedDelaySec = mkOption { - type = types.int; - default = 86400; - description = '' - Random delay to add to scheduled time for donation. Default is one day. - ''; - }; - enforceTor = nbLib.enforceTor; - }; - - cfg = config.services.recurring-donations; - nbLib = config.nix-bitcoin.lib; - recurring-donations-script = pkgs.writeScript "recurring-donations.sh" '' - LNCLI="${config.nix-bitcoin.pkgs.clightning}/bin/lightning-cli --lightning-dir=${config.services.clightning.dataDir}" - pay_tallycoin() { - NAME=$1 - AMOUNT=$2 - echo "Attempting to pay $AMOUNT sat to $NAME" - INVOICE=$(curl --socks5-hostname ${config.nix-bitcoin.torClientAddressWithPort} -d "satoshi_amount=$AMOUNT&payment_method=ln&id=$NAME&type=profile" -X POST https://api.tallyco.in/v1/payment/request/ | jq -r '.lightning_pay_request') 2> /dev/null - if [ -z "$INVOICE" ] || [ "$INVOICE" = "null" ]; then - echo "ERROR: did not get invoice from tallycoin" - return - fi - # Decode invoice and compare amount with requested amount - DECODED_AMOUNT=$($LNCLI decodepay "$INVOICE" | jq -r '.amount_msat' | head -c -8) - if [ -z "$DECODED_AMOUNT" ] || [ "$DECODED_AMOUNT" = "null" ]; then - echo "ERROR: did not get response from clightning" - return - fi - if [ $DECODED_AMOUNT -eq $AMOUNT ]; then - echo "Paying with invoice $INVOICE" - $LNCLI pay "$INVOICE" - else - echo "ERROR: requested amount and invoice amount do not match. $AMOUNT vs $DECODED_AMOUNT" - return - fi - } - ${ builtins.foldl' - (x: receiver: x + - '' - pay_tallycoin ${receiver} ${toString (builtins.getAttr receiver cfg.tallycoin)} - '') - "" - (builtins.attrNames cfg.tallycoin) - } - ''; -in { - inherit options; - - config = mkIf cfg.enable { - services.clightning.enable = true; - - systemd.services.recurring-donations = { - requires = [ "clightning.service" ]; - after = [ "clightning.service" ]; - path = with pkgs; [ nix-bitcoin.clightning curl jq ]; - serviceConfig = nbLib.defaultHardening // { - ExecStart = "${pkgs.bash}/bin/bash ${recurring-donations-script}"; - User = "recurring-donations"; - Type = "oneshot"; - } // nbLib.allowedIPAddresses cfg.enforceTor; - }; - systemd.timers.recurring-donations = { - requires = [ "clightning.service" ]; - after = [ "clightning.service" ]; - timerConfig = { - Unit = "recurring-donations.service"; - OnCalendar = cfg.interval; - RandomizedDelaySec = toString cfg.randomizedDelaySec; - }; - wantedBy = [ "multi-user.target" ]; - }; - - users.users.recurring-donations = { - isSystemUser = true; - group = "recurring-donations"; - extraGroups = [ config.services.clightning.group ]; - }; - users.groups.recurring-donations = {}; - }; -}