Skip to content

Commit

Permalink
Merge pull request #44 from Start9Labs/update/v0.15.0
Browse files Browse the repository at this point in the history
update upstream to v0.15.0 and replace C-Lightning-REST with CLNRest
  • Loading branch information
Dominion5254 authored Jan 29, 2024
2 parents a814cd6 + a76dade commit cc9a575
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 49 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------
# Install Dependencies
# ---------------
FROM node:16-alpine as builder
FROM node:18-alpine as builder

RUN apk add --no-cache \
python3 \
Expand Down Expand Up @@ -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

Expand Down
43 changes: 31 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion RTL
Submodule RTL updated 166 files
57 changes: 38 additions & 19 deletions configurator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
rune_path: Option<PathBuf>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -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<PathBuf>, Option<PathBuf>), 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,
Expand All @@ -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))
}
}
}
Expand All @@ -263,15 +276,19 @@ fn get_rtl_node_map(nodes: Vec<RTLNode>) -> HashMap<String, RTLNode> {
fn to_rtl_default(
s9_node: S9Node,
node_index: usize,
macaroon_path: PathBuf,
macaroon_path: Option<PathBuf>,
rune_path: Option<PathBuf>,
address: String,
rest_port: u16,
) -> RTLNode {
RTLNode {
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,
Expand All @@ -290,11 +307,12 @@ fn to_rtl(
prev_rtl_node: Option<RTLNode>,
s9_node: S9Node,
node_index: usize,
macaroon_path: PathBuf,
macaroon_path: Option<PathBuf>,
rune_path: Option<PathBuf>,
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;
Expand Down Expand Up @@ -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,
))
Expand Down
8 changes: 4 additions & 4 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -37,10 +37,10 @@ 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..."
sleep 1
echo "Waiting for clnrest_rune to be generated..."
sleep 30
done
fi

Expand Down
7 changes: 3 additions & 4 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.2.1 <24.0.0"
description: Used to communicate with the Lightning Network.
requirement:
type: opt-in
Expand Down
12 changes: 6 additions & 6 deletions scripts/procedures/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/procedures/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ export const migration: T.ExpectedExports.migration = compat.migrations
),
},
},
"0.14.1",
"0.15.0",
);

0 comments on commit cc9a575

Please sign in to comment.