diff --git a/configuration.nix b/configuration.nix index 66451b6..8fe2714 100644 --- a/configuration.nix +++ b/configuration.nix @@ -2,7 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, ... }: { +{ config, pkgs, lib, ... }: { imports = [ ./modules/nix-bitcoin.nix @@ -22,6 +22,17 @@ # you are doing. services.nix-bitcoin.enable = true; + ### BITCOIND + # Bitcoind is enabled by default if nix-bitcoin is enabled + # + # You can override default settings from nix-bitcoin.nix as follows + # services.bitcoind.prune = lib.mkForce 100000; + # + # You can add options that are not defined in modules/bitcoind.nix as follows + # services.bitcoind.extraConfig = '' + # maxorphantx=110 + # ''; + ### CLIGHTNING # Enable this module to use clightning, a Lightning Network implementation # in C. diff --git a/modules/bitcoind.nix b/modules/bitcoind.nix index b2a6bf3..e6c44fa 100644 --- a/modules/bitcoind.nix +++ b/modules/bitcoind.nix @@ -12,11 +12,16 @@ let ${optionalString (cfg.prune != null) "prune=${toString cfg.prune}"} ${optionalString (cfg.sysperms != null) "sysperms=${if cfg.sysperms then "1" else "0"}"} ${optionalString (cfg.disablewallet != null) "disablewallet=${if cfg.disablewallet then "1" else "0"}"} + ${optionalString (cfg.assumevalid != null) "assumevalid=${cfg.assumevalid}"} + # Connection options ${optionalString (cfg.port != null) "port=${toString cfg.port}"} ${optionalString (cfg.proxy != null) "proxy=${cfg.proxy}"} listen=${if cfg.listen then "1" else "0"} + ${optionalString (cfg.discover != null) "discover=${if cfg.discover then "1" else "0"}"} + ${lib.concatMapStrings (node: "addnode=${node}\n") cfg.addnodes} + # RPC server options rpcport=${toString cfg.rpc.port} @@ -27,6 +32,9 @@ let ${optionalString (cfg.rpcuser != null) "rpcuser=${cfg.rpcuser}"} ${optionalString (cfg.rpcpassword != null) "rpcpassword=${cfg.rpcpassword}"} + # Wallet options + ${optionalString (cfg.addresstype != null) "addresstype=${cfg.addresstype}"} + # ZMQ options ${optionalString (cfg.zmqpubrawblock != null) "zmqpubrawblock=${cfg.zmqpubrawblock}"} ${optionalString (cfg.zmqpubrawtx != null) "zmqpubrawtx=${cfg.zmqpubrawtx}"} @@ -209,6 +217,32 @@ in { example = "tcp://127.0.0.1:28333"; description = "ZMQ address for zmqpubrawtx notifications"; }; + assumevalid = mkOption { + type = types.nullOr types.str; + default = null; + example = "00000000000000000000e5abc3a74fe27dc0ead9c70ea1deb456f11c15fd7bc6"; + description = '' + If this block is in the chain assume that it and its ancestors are + valid and potentially skip their script verification. + ''; + }; + addnodes = mkOption { + type = types.listOf types.str; + default = []; + example = [ "ecoc5q34tmbq54wl.onion" ]; + description = "Add nodes to connect to and attempt to keep the connections open"; + }; + discover = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Discover own IP addresses"; + }; + addresstype = mkOption { + type = types.nullOr types.str; + default = null; + example = "bech32"; + description = "What type of addresses to use"; + }; cli = mkOption { type = types.package; readOnly = true; diff --git a/modules/nix-bitcoin.nix b/modules/nix-bitcoin.nix index 753e146..7fec571 100644 --- a/modules/nix-bitcoin.nix +++ b/modules/nix-bitcoin.nix @@ -57,13 +57,10 @@ in { services.bitcoind.rpcuser = "bitcoinrpc"; services.bitcoind.zmqpubrawblock = "tcp://127.0.0.1:28332"; services.bitcoind.zmqpubrawtx = "tcp://127.0.0.1:28333"; - services.bitcoind.extraConfig = '' - assumevalid=00000000000000000000e5abc3a74fe27dc0ead9c70ea1deb456f11c15fd7bc6 - addnode=ecoc5q34tmbq54wl.onion - discover=0 - addresstype=bech32 - changetype=bech32 - ''; + services.bitcoind.assumevalid = "00000000000000000000e5abc3a74fe27dc0ead9c70ea1deb456f11c15fd7bc6"; + services.bitcoind.addnodes = [ "ecoc5q34tmbq54wl.onion" ]; + services.bitcoind.discover = false; + services.bitcoind.addresstype = "bech32"; services.bitcoind.prune = 0; services.bitcoind.dbCache = 1000; services.tor.hiddenServices.bitcoind = {