From bc7763071346da526b9db18f6e6cd2e3df832fc6 Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:17:26 +0200 Subject: [PATCH 1/4] Add CLN ln node to the environment --- cln.conf | 6 ++++++ devenv.lock | 24 ++++++++++++------------ devenv.nix | 10 ++++++++++ 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 cln.conf diff --git a/cln.conf b/cln.conf new file mode 100644 index 000000000..975347ee2 --- /dev/null +++ b/cln.conf @@ -0,0 +1,6 @@ +network=testnet4 +log-level=debug +bitcoin-rpcuser=username +bitcoin-rpcpassword=password +bitcoin-rpcconnect=localhost +bitcoin-rpcport=48332 diff --git a/devenv.lock b/devenv.lock index f0f2df37b..294a917bc 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,10 +3,10 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1746101600, + "lastModified": 1749632886, "owner": "cachix", "repo": "devenv", - "rev": "86dbb4b05ac23147bcc468e7ed77567bae11e418", + "rev": "0d39abfbac9ac9f421f2c43453af4ebc13227521", "type": "github" }, "original": { @@ -24,10 +24,10 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1746081462, + "lastModified": 1749623906, "owner": "nix-community", "repo": "fenix", - "rev": "e3be528e4f03538852ba49b413ec4ac843edeb60", + "rev": "873cccc628f5e39407e319e6711f3b7d6d1f15cc", "type": "github" }, "original": { @@ -39,10 +39,10 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1733328505, + "lastModified": 1747046372, "owner": "edolstra", "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", "type": "github" }, "original": { @@ -60,10 +60,10 @@ ] }, "locked": { - "lastModified": 1742649964, + "lastModified": 1747372754, "owner": "cachix", "repo": "git-hooks.nix", - "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", + "rev": "80479b6ec16fefd9c1db3ea13aeb038c60530f46", "type": "github" }, "original": { @@ -94,10 +94,10 @@ }, "nixpkgs": { "locked": { - "lastModified": 1733477122, + "lastModified": 1746807397, "owner": "cachix", "repo": "devenv-nixpkgs", - "rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857", + "rev": "c5208b594838ea8e6cca5997fbf784b7cca1ca90", "type": "github" }, "original": { @@ -121,10 +121,10 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1746024678, + "lastModified": 1749558764, "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "5d66d45005fef79751294419ab9a9fa304dfdf5c", + "rev": "9c3476d225ccc90c081280c2a20e9f7d8a200325", "type": "github" }, "original": { diff --git a/devenv.nix b/devenv.nix index 94ae4ab78..9a835ec15 100644 --- a/devenv.nix +++ b/devenv.nix @@ -12,6 +12,7 @@ }; bitcoindDataDir = "${config.devenv.root}/.devenv/state/bitcoind"; + lightningClnDataDir = "${config.devenv.root}/.devenv/state/cln"; poolConfig = builtins.fromTOML (builtins.readFile ./config/pool.toml); minerConfig = builtins.fromTOML (builtins.readFile ./config/miner.toml); @@ -43,6 +44,7 @@ in { pkgs.just pkgs.coreutils # Provides stdbuf for disabling output buffering pkgs.redis + pkgs.clightning # Ligtning - CLN ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [pkgs.darwin.apple_sdk.frameworks.Security]; @@ -98,6 +100,14 @@ in { bitcoind -datadir=${bitcoindDataDir} -conf=${config.devenv.root}/bitcoin.conf '' "bitcoind-regtest.log"; }; + # Lightning node -- CLN + lightning-cln = { + exec = withLogging '' + mkdir -p ${lightningClnDataDir} + lightningd --version + lightningd --conf=${config.devenv.root}/cln.conf --lightning-dir=${lightningClnDataDir} + '' "cln.log"; + }; miner = { exec = withLogging '' echo "Waiting for proxy..." From 98303323992a47f12b299cb35473d4a447b34125 Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:40:42 +0200 Subject: [PATCH 2/4] Add polling on bitcoind before stating CLN --- devenv.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/devenv.nix b/devenv.nix index 9a835ec15..0eda18ee7 100644 --- a/devenv.nix +++ b/devenv.nix @@ -44,7 +44,7 @@ in { pkgs.just pkgs.coreutils # Provides stdbuf for disabling output buffering pkgs.redis - pkgs.clightning # Ligtning - CLN + pkgs.clightning # Lightning - CLN ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [pkgs.darwin.apple_sdk.frameworks.Security]; @@ -104,6 +104,11 @@ in { lightning-cln = { exec = withLogging '' mkdir -p ${lightningClnDataDir} + echo "Waiting for bitcoind..." + while ! nc -z localhost 48332; do + sleep 1 + done + echo "bitcoind is up. Starting lightning..." lightningd --version lightningd --conf=${config.devenv.root}/cln.conf --lightning-dir=${lightningClnDataDir} '' "cln.log"; From b415ea0de07b542cb0e11298502c9c3386d1344d Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:58:37 +0200 Subject: [PATCH 3/4] Use regtest (not testnet4) --- cln.conf | 4 ++-- devenv.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cln.conf b/cln.conf index 975347ee2..d3af8cdea 100644 --- a/cln.conf +++ b/cln.conf @@ -1,6 +1,6 @@ -network=testnet4 +network=regtest log-level=debug bitcoin-rpcuser=username bitcoin-rpcpassword=password bitcoin-rpcconnect=localhost -bitcoin-rpcport=48332 +bitcoin-rpcport=18443 diff --git a/devenv.nix b/devenv.nix index 0eda18ee7..2f0ad10c2 100644 --- a/devenv.nix +++ b/devenv.nix @@ -105,7 +105,7 @@ in { exec = withLogging '' mkdir -p ${lightningClnDataDir} echo "Waiting for bitcoind..." - while ! nc -z localhost 48332; do + while ! nc -z localhost 18443; do sleep 1 done echo "bitcoind is up. Starting lightning..." From fa73bbfda51f066ab971a5a4735675c1081d5bb1 Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:59:19 +0200 Subject: [PATCH 4/4] Move conf file to config --- cln.conf => config/cln.conf | 0 devenv.nix | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename cln.conf => config/cln.conf (100%) diff --git a/cln.conf b/config/cln.conf similarity index 100% rename from cln.conf rename to config/cln.conf diff --git a/devenv.nix b/devenv.nix index 2f0ad10c2..ec6c3d4f4 100644 --- a/devenv.nix +++ b/devenv.nix @@ -110,7 +110,7 @@ in { done echo "bitcoind is up. Starting lightning..." lightningd --version - lightningd --conf=${config.devenv.root}/cln.conf --lightning-dir=${lightningClnDataDir} + lightningd --conf=${config.devenv.root}/config/cln.conf --lightning-dir=${lightningClnDataDir} '' "cln.log"; }; miner = {