From 8fbba87c0fb3f2126e39bac6d2e569f5876d0136 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Sun, 20 Jun 2021 23:28:46 +0200 Subject: [PATCH 1/5] Update nixpkgs nixos-unstable: a76f6b02852a724059a7b7cfe73ac5b7a2a81831 lnd: 0.12.1-beta -> 0.13.0-beta e2dc2b859674411f5ed5b81781926afc7fde5260 btcpayserver: 1.0.7.2 -> 1.1.1 074b608d01e60fbef9bffe0ac7e25e72d20f4866 nbxplorer: 2.1.49 -> 2.1.51 60c6153ab12229fa3d067460614131da5e67f6da btcpayserver/update.sh: auto-update nbxplorer 1608efae17a36cc6206d929801cf2bd887d157b2 btcpayserver, nbxplorer: gpg verify upstream sources c0693eae1e9cb28ad148ebb49f8200d340432079 hwi: 2.0.1 -> 2.0.2 43031a05d2e2b08ed5f98b3f5255e7d76ef4e403 charge-lnd: init at 0.1.2 5fd4f796b4210d691b1f89e1f29043d635cd20e0 charge-lnd: 0.1.2 -> 0.1.3 --- pkgs/nixpkgs-pinned.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/nixpkgs-pinned.nix b/pkgs/nixpkgs-pinned.nix index 12c0f86..8d81f24 100644 --- a/pkgs/nixpkgs-pinned.nix +++ b/pkgs/nixpkgs-pinned.nix @@ -8,11 +8,11 @@ in { # To update, run ../helper/fetch-channel REV nixpkgs = fetch { - rev = "dc326c78a93862efb30a76216f527a56496e6284"; - sha256 = "094zb1p5i5f2nlxny3dc814jvs90nimdj6wwd80495hgs9z76wgp"; + rev = "69f3a9705014ce75b0489404210995fb6f29836e"; + sha256 = "12rspv54fclh4lsry7jxhg6bidbpvzm14f88wbg7rn7ql1bb4rjc"; }; nixpkgs-unstable = fetch { - rev = "4518794ee53d109d551c210a6d195b79e9995a90"; - sha256 = "1h86bqrkiydn5nwpndg8k5apdjxff5qigbrrwfam3893vgb7hws2"; + rev = "33d42ad7cf2769ce6364ed4e52afa8e9d1439d58"; + sha256 = "0l8vvfq0zk3wdrgr5wnfkk02yx389ikxjgvf7lka2c7rh7rbgvsz"; }; } From bc9199a3864eb963a795b9b4b05ece870e044734 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Wed, 7 Jul 2021 13:06:26 +0000 Subject: [PATCH 2/5] Update nixpkgs --- pkgs/nixpkgs-pinned.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/nixpkgs-pinned.nix b/pkgs/nixpkgs-pinned.nix index 8d81f24..37b0722 100644 --- a/pkgs/nixpkgs-pinned.nix +++ b/pkgs/nixpkgs-pinned.nix @@ -8,11 +8,11 @@ in { # To update, run ../helper/fetch-channel REV nixpkgs = fetch { - rev = "69f3a9705014ce75b0489404210995fb6f29836e"; - sha256 = "12rspv54fclh4lsry7jxhg6bidbpvzm14f88wbg7rn7ql1bb4rjc"; + rev = "359e6542e1d41eb18df55c82bdb08bf738fae2cf"; + sha256 = "05v28njaas9l26ibc6vy6imvy7grbkli32bmv0n32x6x9cf68gf9"; }; nixpkgs-unstable = fetch { - rev = "33d42ad7cf2769ce6364ed4e52afa8e9d1439d58"; - sha256 = "0l8vvfq0zk3wdrgr5wnfkk02yx389ikxjgvf7lka2c7rh7rbgvsz"; + rev = "036dc0c709650e0c833822307af801f576d67273"; + sha256 = "0pnrygs6xf7id63zi17pq5379hfppwbb5cfazhypcqz6l3dfk00g"; }; } From c75347027b1c814deb82c110758cf95df664b8a5 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Wed, 7 Jul 2021 10:24:27 +0000 Subject: [PATCH 3/5] lnd: don't wait until the RPC port is open after unlocking According to the release notes of lnd 0.13.0 [0] the RPC service is available at all times. [0] https://github.com/lightningnetwork/lnd/releases/tag/v0.13.0-beta --- modules/lnd.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/modules/lnd.nix b/modules/lnd.nix index 8093bc9..d82b4b9 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -239,11 +239,6 @@ in { -d "{\"wallet_password\": \"$(cat ${secretsDir}/lnd-wallet-password | tr -d '\n' | base64 -w0)\"}" \ ${restUrl}/unlockwallet fi - - # Wait until the RPC port is open - while ! { exec 3>/dev/tcp/${cfg.rpcAddress}/${toString cfg.rpcPort}; } &>/dev/null; do - sleep 0.1 - done '') # Setting macaroon permission for other users needs root permissions (nbLib.privileged "lnd-create-macaroons" '' From a23b9d1c2d6db6179ccf35abbcdde7603e776f14 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Wed, 7 Jul 2021 12:21:54 +0000 Subject: [PATCH 4/5] lnd: check that state is RPC_ACTIVE after unlocking The state service is newly introduced in lnd 0.13.0. --- modules/lnd.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/lnd.nix b/modules/lnd.nix index d82b4b9..89a67c8 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -239,6 +239,16 @@ in { -d "{\"wallet_password\": \"$(cat ${secretsDir}/lnd-wallet-password | tr -d '\n' | base64 -w0)\"}" \ ${restUrl}/unlockwallet fi + state="" + while [ "$state" != "RPC_ACTIVE" ]; do + state=$(${curl} \ + --cacert ${secretsDir}/lnd-cert \ + -d '{}' \ + -X POST \ + ${restUrl}/state |\ + ${pkgs.jq}/bin/jq -r '.state') + sleep 0.1 + done '') # Setting macaroon permission for other users needs root permissions (nbLib.privileged "lnd-create-macaroons" '' From ce10003747c77e8f075359fe82ca6d0a435ff90c Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Thu, 8 Jul 2021 13:10:16 +0000 Subject: [PATCH 5/5] lnd: allow curl to retry in the create-wallet script --- modules/lnd.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/lnd.nix b/modules/lnd.nix index 89a67c8..950b3b0 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -198,7 +198,10 @@ in { RestartSec = "10s"; ReadWritePaths = cfg.dataDir; ExecStartPost = let - curl = "${pkgs.curl}/bin/curl -s --show-error"; + # Retrying is necessary because it can happen that the lnd socket is + # existing, but the RPC service isn't yet, which results in error + # "waiting to start, RPC services not available". + curl = "${pkgs.curl}/bin/curl -s --show-error --retry 10"; restUrl = "https://${cfg.restAddress}:${toString cfg.restPort}/v1"; in [ (nbLib.script "lnd-create-wallet" ''