From 42f7e9f874efea1f75503ca740efb2311582d457 Mon Sep 17 00:00:00 2001 From: nixbitcoin Date: Wed, 10 Feb 2021 14:02:05 +0000 Subject: [PATCH] joinmarket: 0.8.0-a5e8879 -> 0.8.1 - Update joinmarket package - Revert unofficial release settings - Move Yield Generator config to configFile - Add new config option max_sweep_fee_change --- docs/usage.md | 12 ++-- modules/joinmarket.nix | 104 ++++++++++++++++++++++++---------- pkgs/joinmarket/default.nix | 6 +- pkgs/joinmarket/get-sha256.sh | 8 +-- test/tests.nix | 9 +-- 5 files changed, 92 insertions(+), 47 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 5631f85..0525cb9 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -363,12 +363,12 @@ See [here](https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master 1. Enable yield generator bot in your node configuration ``` - services.joinmarket.yieldgenerator.enable = true; - - # Optional: Add custom parameters - services.joinmarket.yieldgenerator.customParameters = '' - txfee = 200 - cjfee_a = 300 + services.joinmarket.yieldgenerator = { + enable = true; + # Optional: Add custom parameters + txfee = 200; + cjfee_a = 300; + }; ''; ``` diff --git a/modules/joinmarket.nix b/modules/joinmarket.nix index 80da753..e8bc76e 100644 --- a/modules/joinmarket.nix +++ b/modules/joinmarket.nix @@ -12,6 +12,7 @@ let inherit (config.services) bitcoind; torAddress = builtins.head (builtins.split ":" config.services.tor.client.socksListenAddress); # Based on https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/jmclient/jmclient/configure.py + yg = cfg.yieldgenerator; configFile = builtins.toFile "config" '' [DAEMON] no_daemon = 0 @@ -56,6 +57,7 @@ let merge_algorithm = default tx_fees = 3 absurd_fee_per_kb = 350000 + max_sweep_fee_change = 0.8 tx_broadcast = self minimum_makers = 4 max_sats_freeze_reuse = -1 @@ -74,6 +76,17 @@ let onion_socks5_port = 9050 tor_control_host = unix:/run/tor/control hidden_service_ssl = false + + [YIELDGENERATOR] + ordertype = ${yg.ordertype} + cjfee_a = ${toString yg.cjfee_a} + cjfee_r = ${toString yg.cjfee_r} + cjfee_factor = ${toString yg.cjfee_factor} + txfee = ${toString yg.txfee} + txfee_factor = ${toString yg.txfee_factor} + minsize = ${toString yg.minsize} + size_factor = ${toString yg.size_factor} + gaplimit = 6 ''; # The jm scripts create a 'logs' dir in the working dir, @@ -93,21 +106,6 @@ let in { options.services.joinmarket = { enable = mkEnableOption "JoinMarket"; - yieldgenerator = { - enable = mkEnableOption "yield generator bot"; - customParameters = mkOption { - type = types.str; - default = ""; - example = '' - txfee = 200 - cjfee_a = 300 - ''; - description = '' - Python code to define custom yield generator parameters, as described in - https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/docs/YIELDGENERATOR.md - ''; - }; - }; dataDir = mkOption { type = types.path; default = "/var/lib/joinmarket"; @@ -139,6 +137,66 @@ in { default = true; }; inherit (nbLib) cliExec; + + yieldgenerator = { + enable = mkEnableOption "yield generator bot"; + ordertype = mkOption { + type = types.enum [ "reloffer" "absoffer" ]; + default = "reloffer"; + description = '' + Which fee type to actually use + ''; + }; + cjfee_a = mkOption { + type = types.ints.unsigned; + default = 500; + description = '' + Absolute offer fee you wish to receive for coinjoins (cj) in Satoshis + ''; + }; + cjfee_r = mkOption { + type = types.float; + default = 0.00002; + description = '' + Relative offer fee you wish to receive based on a cj's amount + ''; + }; + cjfee_factor = mkOption { + type = types.float; + default = 0.1; + description = '' + Variance around the average cj fee + ''; + }; + txfee = mkOption { + type = types.ints.unsigned; + default = 100; + description = '' + The average transaction fee you're adding to coinjoin transactions + ''; + }; + txfee_factor = mkOption { + type = types.float; + default = 0.3; + description = '' + Variance around the average tx fee + ''; + }; + minsize = mkOption { + type = types.ints.unsigned; + default = 100000; + description = '' + Minimum size of your cj offer in Satoshis. Lower cj amounts will be disregarded. + ''; + }; + size_factor = mkOption { + type = types.float; + default = 0.1; + description = '' + Variance around all offer sizes + ''; + }; + }; }; config = mkIf cfg.enable (mkMerge [{ @@ -219,25 +277,13 @@ in { } (mkIf cfg.yieldgenerator.enable { - systemd.services.joinmarket-yieldgenerator = let - ygDefault = "${nbPkgs.joinmarket}/bin/jm-yg-privacyenhanced"; - ygBinary = if cfg.yieldgenerator.customParameters == "" then - ygDefault - else - pkgs.runCommand "jm-yieldgenerator-custom" { - inherit (cfg.yieldgenerator) customParameters; - } '' - substitute ${ygDefault} $out \ - --replace "# end of settings customization" "$customParameters" - chmod +x $out - ''; - in { + systemd.services.joinmarket-yieldgenerator = { wantedBy = [ "joinmarket.service" ]; requires = [ "joinmarket.service" ]; after = [ "joinmarket.service" ]; preStart = let start = '' - exec ${ygBinary} --datadir='${cfg.dataDir}' --wallet-password-stdin wallet.jmdat + exec ${nbPkgs.joinmarket}/bin/jm-yg-privacyenhanced --datadir='${cfg.dataDir}' --wallet-password-stdin wallet.jmdat ''; in '' pw=$(cat "${secretsDir}"/jm-wallet-password) diff --git a/pkgs/joinmarket/default.nix b/pkgs/joinmarket/default.nix index 4649953..f4d7bc9 100644 --- a/pkgs/joinmarket/default.nix +++ b/pkgs/joinmarket/default.nix @@ -1,10 +1,10 @@ { stdenv, lib, fetchurl, python3, nbPython3Packages, pkgs }: let - version = "0.8.0-a5e8879"; + version = "0.8.1"; src = fetchurl { - url = "https://github.com/JoinMarket-Org/joinmarket-clientserver/archive/a5e8879d119c8702476da32957d2cfecc3584c89.tar.gz"; - sha256 = "1l98mjk5rc5kji4yads6iicvyps0blsddwzclsiv0ha1az6dzpci"; + url = "https://github.com/JoinMarket-Org/joinmarket-clientserver/archive/v${version}.tar.gz"; + sha256 = "1q3x1x0a78v6apwvbyhl7yh4dgr7xpikd8j07gi3by004ns3789d"; }; runtimePackages = with nbPython3Packages; [ diff --git a/pkgs/joinmarket/get-sha256.sh b/pkgs/joinmarket/get-sha256.sh index 79e5ca9..6bdb149 100755 --- a/pkgs/joinmarket/get-sha256.sh +++ b/pkgs/joinmarket/get-sha256.sh @@ -9,19 +9,17 @@ cd $TMPDIR echo "Fetching latest release" git clone https://github.com/joinmarket-org/joinmarket-clientserver 2> /dev/null cd joinmarket-clientserver -latest=a5e8879d119c8702476da32957d2cfecc3584c89 +latest=$(git describe --tags `git rev-list --tags --max-count=1`) echo "Latest release is ${latest}" # GPG verification export GNUPGHOME=$TMPDIR echo "Fetching Adam Gibson's key" gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys 2B6FC204D9BF332D062B461A141001A1AF77F20B 2> /dev/null -echo "Fetching Kristaps Kaupe's key" -gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys BF60DF964F88DD88174089A2D47B1B4232B55437 2> /dev/null echo "Verifying latest release" -git verify-commit ${latest} +git verify-tag ${latest} -echo "commit: ${latest}" +echo "tag: ${latest}" # The prefix option is necessary because GitHub prefixes the archive contents in this format echo "sha256: $(nix-hash --type sha256 --flat --base32 \ <(git archive --format tar.gz --prefix=joinmarket-clientserver-"${latest//v}"/ ${latest}))" diff --git a/test/tests.nix b/test/tests.nix index b99462c..bd23012 100644 --- a/test/tests.nix +++ b/test/tests.nix @@ -65,10 +65,11 @@ let testEnv = rec { tests.joinmarket-ob-watcher = cfg.joinmarket-ob-watcher.enable; services.joinmarket.yieldgenerator = { enable = config.services.joinmarket.enable; - customParameters = '' - txfee = 200 - cjfee_a = 300 - ''; + # Test a smattering of custom parameters + ordertype = "absoffer"; + cjfee_a = 300; + cjfee_r = 0.00003; + txfee = 200; }; tests.nodeinfo = config.nix-bitcoin.nodeinfo.enable;