From a602dbef5b0b9a4f3daa699275b117672e46c1a9 Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Fri, 19 Jan 2024 13:31:42 -0700 Subject: [PATCH 1/5] update upstream to v0.15.0 and replace C-Lightning-REST with CLNRest --- Dockerfile | 4 +-- RTL | 2 +- configurator/src/main.rs | 61 +++++++++++++++++++++----------- docker_entrypoint.sh | 4 +-- manifest.yaml | 7 ++-- scripts/procedures/getConfig.ts | 12 +++---- scripts/procedures/migrations.ts | 2 +- 7 files changed, 55 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2fe3150..8082db4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # --------------- # Install Dependencies # --------------- -FROM node:16-alpine as builder +FROM node:18-alpine as builder RUN apk add --no-cache \ python3 \ @@ -34,7 +34,7 @@ RUN npm prune --production --legacy-peer-deps # --------------- # Release App # --------------- -FROM node:16-alpine as runner +FROM node:18-alpine as runner ARG ARCH diff --git a/RTL b/RTL index d083be1..ea7f300 160000 --- a/RTL +++ b/RTL @@ -1 +1 @@ -Subproject commit d083be11965d285c39070c2e04e7e3f86570c6e8 +Subproject commit ea7f300360a884caafd5f7676bf9b36d5d3ccdd0 diff --git a/configurator/src/main.rs b/configurator/src/main.rs index 5688b3f..452f0c5 100644 --- a/configurator/src/main.rs +++ b/configurator/src/main.rs @@ -60,13 +60,13 @@ pub enum NodeType { #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub enum RTLNodeType { LND, - CLT, + CLN, } impl From for RTLNodeType { fn from(nt: NodeType) -> RTLNodeType { match nt { - NodeType::CLightning => RTLNodeType::CLT, + NodeType::CLightning => RTLNodeType::CLN, NodeType::Lnd => RTLNodeType::LND, } } @@ -129,7 +129,10 @@ struct RTLNode { #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] struct RTLNodeAuthentication { - macaroon_path: PathBuf, + #[serde(skip_serializing_if = "Option::is_none")] + macaroon_path: Option, + #[serde(skip_serializing_if = "Option::is_none")] + rune_path: Option, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] @@ -212,15 +215,16 @@ pub enum Property { fn write_macaroons_and_get_connection_details( s9_node: &S9Node, node_index: usize, -) -> Result<(String, u16, PathBuf), anyhow::Error> { +) -> Result<(String, u16, Option, Option), anyhow::Error> { match (&s9_node.typ, &s9_node.connection_settings) { (NodeType::Lnd, S9NodeConnectionSettings::Internal) => { - Ok((String::from("lnd.embassy"), 8080, PathBuf::from("/mnt/lnd"))) + Ok((String::from("lnd.embassy"), 8080, Some(PathBuf::from("/mnt/lnd")), None)) } (NodeType::CLightning, S9NodeConnectionSettings::Internal) => Ok(( String::from("c-lightning.embassy"), - 3001, - PathBuf::from("/mnt/c-lightning"), + 3010, + None, + Some(PathBuf::from("/mnt/c-lightning/clnrest_rune")), )), ( typ, @@ -230,22 +234,31 @@ fn write_macaroons_and_get_connection_details( macaroon, }, ) => { - let (mac_path, mac_dir) = match typ { + let (mac_path, mac_dir, rune_path) = match typ { NodeType::Lnd => { let mac_dir = PathBuf::from(format!("/root/lnd-external-{}", node_index)); - (mac_dir.join("admin.macaroon"), mac_dir) + (mac_dir.join("admin.macaroon"), Some(mac_dir), None) } NodeType::CLightning => { let mac_dir = PathBuf::from(format!("/root/cl-external-{}", node_index)); - (mac_dir.join("access.macaroon"), mac_dir) + (mac_dir.join("access.macaroon"), None, Some(mac_dir.join("clnrest_rune"))) } }; - std::fs::create_dir_all(mac_dir.as_path())?; - File::create(mac_path)?.write_all(&base64::decode_config( - macaroon, - base64::Config::new(base64::CharacterSet::UrlSafe, false), - )?)?; - Ok((address.host().unwrap().to_owned(), *rest_port, mac_dir)) + match mac_dir.is_some() && rune_path.is_none() { + true => { + std::fs::create_dir_all(mac_dir.as_ref().unwrap().as_path())?; + File::create(mac_path)?.write_all(&base64::decode_config( + macaroon, + base64::Config::new(base64::CharacterSet::UrlSafe, false), + )?)?; + }, + false => { + std::fs::create_dir_all(rune_path.as_ref().unwrap().as_path())?; + let content = format!("LIGHTNING_RUNE=\"{}\"", macaroon); + File::create(mac_path)?.write_all(content.as_bytes())?; + } + } + Ok((address.host().unwrap().to_owned(), *rest_port, mac_dir, rune_path)) } } } @@ -263,7 +276,8 @@ fn get_rtl_node_map(nodes: Vec) -> HashMap { fn to_rtl_default( s9_node: S9Node, node_index: usize, - macaroon_path: PathBuf, + macaroon_path: Option, + rune_path: Option, address: String, rest_port: u16, ) -> RTLNode { @@ -271,7 +285,10 @@ fn to_rtl_default( index: node_index, ln_implementation: s9_node.typ.into(), ln_node: s9_node.name, - authentication: RTLNodeAuthentication { macaroon_path }, + authentication: RTLNodeAuthentication { + macaroon_path, + rune_path, + }, settings: RTLNodeSettings { user_persona: RTLNodePersona::OPERATOR, theme_mode: RTLNodeThemeMode::NIGHT, @@ -290,11 +307,12 @@ fn to_rtl( prev_rtl_node: Option, s9_node: S9Node, node_index: usize, - macaroon_path: PathBuf, + macaroon_path: Option, + rune_path: Option, address: String, rest_port: u16, ) -> RTLNode { - let mut def = to_rtl_default(s9_node, node_index, macaroon_path, address, rest_port); + let mut def = to_rtl_default(s9_node, node_index, macaroon_path, rune_path, address, rest_port); if let Some(prev) = prev_rtl_node { def.settings.user_persona = prev.settings.user_persona; def.settings.theme_color = prev.settings.theme_color; @@ -347,13 +365,14 @@ fn main() -> Result<(), anyhow::Error> { .enumerate() .map(|(zero_index, s9_node)| { let one_index = zero_index + 1; - let (address, rest_port, macaroon_path) = + let (address, rest_port, macaroon_path, rune_path) = write_macaroons_and_get_connection_details(&s9_node, one_index)?; Ok(to_rtl( rtl_node_map.remove(&s9_node.name), s9_node, one_index, macaroon_path, + rune_path, address, rest_port, )) diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index 041099a..67957d1 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -37,9 +37,9 @@ if [[ ! -z $result ]] exit 0 fi - while ! test -f /mnt/c-lightning/access.macaroon + while ! test -f /mnt/c-lightning/clnrest_rune do - echo "Waiting for c-Lightning-REST access macaroon to be generated..." + echo "Waiting for clnrest_rune to be generated..." sleep 1 done fi diff --git a/manifest.yaml b/manifest.yaml index 672ab3a..8efbcdd 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -1,9 +1,8 @@ id: ride-the-lightning title: Ride the Lightning -version: 0.14.1 +version: 0.15.0 release-notes: | - * Update upstream to v0.14.1 [Release Notes](https://github.com/Ride-The-Lightning/RTL/releases/tag/v0.14.1) - * Increment LND dependency version + * Update upstream to v0.15.0 [Release Notes](https://github.com/Ride-The-Lightning/RTL/releases/tag/v0.15.0) license: MIT wrapper-repo: https://github.com/Start9Labs/ride-the-lightning-wrapper upstream-repo: https://github.com/Ride-The-Lightning/RTL @@ -84,7 +83,7 @@ dependencies: how: Can opt to use the internal Core Lightning (CLN) instance instead of LND config: ~ c-lightning: - version: ">=0.10.1 <24.0.0" + version: ">=23.11.1 <24.0.0" description: Used to communicate with the Lightning Network. requirement: type: opt-in diff --git a/scripts/procedures/getConfig.ts b/scripts/procedures/getConfig.ts index 71f42b8..5380c94 100644 --- a/scripts/procedures/getConfig.ts +++ b/scripts/procedures/getConfig.ts @@ -107,22 +107,22 @@ export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({ "address": { "type": "string", "name": "Public Address", - "description": "The public address of your C-Lightning-REST server\nNOTE: RTL does not support a .onion URL here\n", + "description": "The public address of your CLNRest server\nNOTE: RTL does not support a .onion URL here\n", "nullable": false }, "rest-port": { "type": "number", - "name": "REST Port", - "description": "The port that your C-Lightning-REST server is bound to", + "name": "CLNRest Port", + "description": "The port that your CLNRest server is bound to", "nullable": false, "range": "[0,65535]", "integral": true, - "default": 3001 + "default": 3010 }, "macaroon": { "type": "string", - "name": "Macaroon", - "description": "Your C-Lightning-REST access.macaroon file, Base64URL encoded.", + "name": "Rune", + "description": "Your CLNRest unrestricted Rune, Base64URL encoded.", "nullable": false, "masked": true } diff --git a/scripts/procedures/migrations.ts b/scripts/procedures/migrations.ts index 5e1e1bc..d81f604 100644 --- a/scripts/procedures/migrations.ts +++ b/scripts/procedures/migrations.ts @@ -85,5 +85,5 @@ export const migration: T.ExpectedExports.migration = compat.migrations ), }, }, - "0.14.1", + "0.15.0", ); From dcfb5e99be81be2a65b6b2042dfc505e999fd664 Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Tue, 23 Jan 2024 14:45:20 -0700 Subject: [PATCH 2/5] update min CLN version --- manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.yaml b/manifest.yaml index 8efbcdd..2230bc7 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -83,7 +83,7 @@ dependencies: how: Can opt to use the internal Core Lightning (CLN) instance instead of LND config: ~ c-lightning: - version: ">=23.11.1 <24.0.0" + version: ">=23.11.2.1 <24.0.0" description: Used to communicate with the Lightning Network. requirement: type: opt-in From a66e4949ded872ba2603f9ec78b6fb1fcd2e627d Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Tue, 23 Jan 2024 15:50:50 -0700 Subject: [PATCH 3/5] update missing macaroon/rune logging to 30 second interval --- docker_entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index 67957d1..7a256ad 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -23,7 +23,7 @@ if [[ ! -z $result ]] while ! test -f /mnt/lnd/admin.macaroon do echo "Waiting for LND admin macaroon to be generated..." - sleep 1 + sleep 30 done fi @@ -40,7 +40,7 @@ if [[ ! -z $result ]] while ! test -f /mnt/c-lightning/clnrest_rune do echo "Waiting for clnrest_rune to be generated..." - sleep 1 + sleep 30 done fi From dbf5ef7df6fc48a8155e16d803dfa83113a004e9 Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Tue, 23 Jan 2024 16:28:10 -0700 Subject: [PATCH 4/5] Improve individual ARCH builds and fix make install --- Makefile | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 8a6117f..ef64cf7 100644 --- a/Makefile +++ b/Makefile @@ -19,35 +19,54 @@ clean: rm -f scripts/*.js verify: $(PKG_ID).s9pk - start-sdk verify s9pk $(PKG_ID).s9pk + @start-sdk verify s9pk $(PKG_ID).s9pk + @echo " Done!" + @echo " Filesize: $(shell du -h $(PKG_ID).s9pk) is ready" -install: $(PKG_ID).s9pk +install: +ifeq (,$(wildcard ~/.embassy/config.yaml)) + @echo; echo "You must define \"host: http://embassy-server-name.local\" in ~/.embassy/config.yaml config file first"; echo +else start-cli package install $(PKG_ID).s9pk +endif -# for rebuilding just the arm image. will include docker-images/x86_64.tar into the s9pk if it exists -arm: docker-images/aarch64.tar scripts/embassy.js - start-sdk pack +$(PKG_ID).s9pk: manifest.yaml docker-images/aarch64.tar docker-images/x86_64.tar scripts/embassy.js +ifeq ($(ARCH),aarch64) + @echo "start-sdk: Preparing aarch64 package ..." +else ifeq ($(ARCH),x86_64) + @echo "start-sdk: Preparing x86_64 package ..." +else + @echo "start-sdk: Preparing Universal Package ..." +endif + @start-sdk pack -# for rebuilding just the x86 image. will include docker-images/aarch64.tar into the s9pk if it exists -x86: docker-images/x86_64.tar scripts/embassy.js - start-sdk pack +arm: + @rm -f docker-images/x86_64.tar + @ARCH=aarch64 $(MAKE) -$(PKG_ID).s9pk: manifest.yaml instructions.md scripts/embassy.js LICENSE docker-images/aarch64.tar docker-images/x86_64.tar - start-sdk pack +x86: + @rm -f docker-images/aarch64.tar + @ARCH=x86_64 $(MAKE) docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh configurator/target/aarch64-unknown-linux-musl/release/configurator $(RTL_SRC) +ifeq ($(ARCH),x86_64) +else mkdir -p docker-images DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --build-arg ARCH=aarch64 --build-arg PLATFORM=arm64 --platform=linux/arm64 -o type=docker,dest=docker-images/aarch64.tar . +endif docker-images/x86_64.tar: Dockerfile docker_entrypoint.sh configurator/target/x86_64-unknown-linux-musl/release/configurator $(RTL_SRC) +ifeq ($(ARCH),aarch64) +else mkdir -p docker-images DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --build-arg ARCH=x86_64 --build-arg PLATFORM=amd64 --platform=linux/amd64 -o type=docker,dest=docker-images/x86_64.tar . +endif configurator/target/aarch64-unknown-linux-musl/release/configurator: $(CONFIGURATOR_SRC) - docker run --rm -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/configurator:/home/rust/src start9/rust-musl-cross:aarch64-musl cargo +beta build --release + docker run --rm -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/configurator:/home/rust/src messense/rust-musl-cross:aarch64-musl cargo build --release configurator/target/x86_64-unknown-linux-musl/release/configurator: $(CONFIGURATOR_SRC) - docker run --rm -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/configurator:/home/rust/src start9/rust-musl-cross:x86_64-musl cargo build --release + docker run --rm -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/configurator:/home/rust/src messense/rust-musl-cross:x86_64-musl cargo build --release scripts/embassy.js: $(TS_FILES) deno bundle scripts/embassy.ts scripts/embassy.js From a76dadea148f34910ba8ac4598fd16286a374a0e Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Sun, 28 Jan 2024 09:40:26 -0700 Subject: [PATCH 5/5] Revert CLN to correct CLT --- configurator/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configurator/src/main.rs b/configurator/src/main.rs index 452f0c5..d3fef69 100644 --- a/configurator/src/main.rs +++ b/configurator/src/main.rs @@ -60,13 +60,13 @@ pub enum NodeType { #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub enum RTLNodeType { LND, - CLN, + CLT, } impl From for RTLNodeType { fn from(nt: NodeType) -> RTLNodeType { match nt { - NodeType::CLightning => RTLNodeType::CLN, + NodeType::CLightning => RTLNodeType::CLT, NodeType::Lnd => RTLNodeType::LND, } }