Skip to content

Commit

Permalink
Feat/clams remote (#128)
Browse files Browse the repository at this point in the history
* expose clams config option, interface, and properties

* update clboss to 0.13.1

* only show last 4 chars of Runes in logs

* fix bash substitution

* copy python packages from non-standard path to final image
  • Loading branch information
Dominion5254 authored May 16, 2024
1 parent 3481f56 commit 231cd9e
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 74 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ RUN cargo install --locked --path watchtower-plugin
WORKDIR /opt/lightningd
COPY lightning/. /tmp/lightning-wrapper/lightning
COPY ./.git/modules/lightning /tmp/lightning-wrapper/lightning/.git/

RUN git clone --recursive /tmp/lightning-wrapper/lightning . && \
git checkout $(git --work-tree=/tmp/lightning-wrapper/lightning --git-dir=/tmp/lightning-wrapper/lightning/.git rev-parse HEAD)

ENV PYTHON_VERSION=3
RUN curl -sSL https://install.python-poetry.org | python3 -

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1
Expand Down Expand Up @@ -165,6 +167,9 @@ COPY --from=clboss /usr/local/bin/clboss /usr/local/libexec/c-lightning/plugins/
# lightningd
COPY --from=builder /tmp/lightning_install/ /usr/local/
COPY --from=builder /usr/local/lib/python3.9/dist-packages/ /usr/local/lib/python3.9/dist-packages/
COPY --from=builder /opt/lightningd/plugins/clnrest /usr/local/lib/python3.9/dist-packages/
COPY --from=builder /opt/lightningd/contrib/pyln-client /usr/local/lib/python3.9/dist-packages/
COPY --from=builder /opt/lightningd/contrib/pyln-testing /usr/local/lib/python3.9/dist-packages/
COPY --from=downloader /opt/bitcoin/bin /usr/bin

RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
17 changes: 7 additions & 10 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export RPC_TOR_ADDRESS=$(yq e '.rpc-tor-address' /root/.lightning/start9/config.
export UI_TOR_ADDRESS=$(yq e '.web-ui-tor-address' /root/.lightning/start9/config.yaml)
export UI_LAN_ADDRESS=$(echo "$UI_TOR_ADDRESS" | sed 's/\.onion/\.local/')
export REST_TOR_ADDRESS=$(yq e '.rest-tor-address' /root/.lightning/start9/config.yaml)
# export CLAMS_WEBSOCKET_TOR_ADDRESS=$(yq e '.clams-websocket-tor-address' /root/.lightning/start9/config.yaml)
export CLAMS_WEBSOCKET_TOR_ADDRESS=$(yq e '.clams-websocket-tor-address' /root/.lightning/start9/config.yaml)
export WATCHTOWER_TOR_ADDRESS=$(yq e '.watchtower-tor-address' /root/.lightning/start9/config.yaml)
export TOWERS_DATA_DIR=/root/.lightning/.watchtower
export REST_LAN_ADDRESS=$(echo "$REST_TOR_ADDRESS" | sed 's/\.onion/\.local/')
Expand Down Expand Up @@ -82,7 +82,7 @@ mkdir -p /root/.lightning/public
echo $PEER_TOR_ADDRESS > /root/.lightning/start9/peerTorAddress
echo $RPC_TOR_ADDRESS > /root/.lightning/start9/rpcTorAddress
echo $REST_TOR_ADDRESS > /root/.lightning/start9/restTorAddress
# echo $CLAMS_WEBSOCKET_TOR_ADDRESS > /root/.lightning/start9/clamsRemoteWebsocketTorAddress
echo $CLAMS_WEBSOCKET_TOR_ADDRESS > /root/.lightning/start9/clamsRemoteWebsocketTorAddress
echo $WATCHTOWER_TOR_ADDRESS > /root/.lightning/start9/watchtowerTorAddress

sh /root/.lightning/start9/waitForStart.sh
Expand Down Expand Up @@ -280,14 +280,12 @@ generate_new_rune() {

RUNE=$(echo "$RUNE_RESPONSE" | jq -r '.result.rune')
UNIQUE_ID=$(echo "$RUNE_RESPONSE" | jq -r '.result.unique_id')
echo "RUNE_RESPONSE"
echo "$RUNE_RESPONSE"
echo "RUNE"
echo "$RUNE"

if [ "$RUNE" != "" ] && [ "$RUNE" != "null" ]; then
# Save rune in env file
echo "LIGHTNING_RUNE=\"$RUNE\"" >> "$RUNE_FILE"
LAST_FOUR=$(echo "$RUNE" | rev | cut -c 1-4 | rev)
echo "Rune ending with ${LAST_FOUR} saved to env file"
fi

if [ "$UNIQUE_ID" != "" ] && [ "$UNIQUE_ID" != "null" ]; then
Expand All @@ -308,10 +306,9 @@ fi
if [ -f "$COMMANDO_CONFIG" ]; then
EXISTING_PUBKEY=$(head -n1 "$COMMANDO_CONFIG")
EXISTING_RUNE=$(sed -n "2p" "$COMMANDO_CONFIG")
echo "EXISTING_PUBKEY"
echo "$EXISTING_PUBKEY"
echo "EXISTING_RUNE"
echo "$EXISTING_RUNE"
LAST_FOUR=$(echo "$EXISTING_RUNE" | rev | cut -c 2-5 | rev)
echo "Found existing Pubkey in commando config: $EXISTING_PUBKEY"
echo "Found existing Rune ending with: ${LAST_FOUR} in commando config"
fi

# Getinfo from CLN
Expand Down
37 changes: 19 additions & 18 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
id: c-lightning
version: 24.02.2
version: 24.02.2.1
title: Core Lightning
license: BSD-MIT
wrapper-repo: https://github.com/Start9Labs/cln-startos
upstream-repo: https://github.com/ElementsProject/lightning
support-site: https://github.com/ElementsProject/lightning/issues
marketing-site: https://blockstream.com/lightning
release-notes: |-
* Update lightning to 24.02.2 - [Release Notes](https://github.com/ElementsProject/lightning/releases/tag/v24.02.2)
* Bump Bitcoin dependency version
* Add Clams Remote Config option
* Update clboss to 0.13.1
* Minor logging changes
build: ["make"]
description:
short: "An implementation of the Lightning Network protocol by Blockstream."
Expand Down Expand Up @@ -170,21 +171,21 @@ interfaces:
protocols:
- tcp
- http
# websocket:
# name: Clams Websocket
# description: Websocket endpoint for Clams Remote.
# tor-config:
# port-mapping:
# 7272: "7272"
# lan-config:
# 7272:
# ssl: true
# internal: 7272
# ui: false
# protocols:
# - tcp
# - http
# - ws
websocket:
name: Clams Websocket
description: Websocket endpoint for Clams Remote.
tor-config:
port-mapping:
7272: "7272"
lan-config:
7272:
ssl: true
internal: 7272
ui: false
protocols:
- tcp
- http
- ws
dependencies:
bitcoind:
version: ">=0.21.1.2 <29.0.0"
Expand Down
30 changes: 15 additions & 15 deletions scripts/procedures/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export const [getConfig, setConfigMatcher] = compat.getConfigAndMatcher({
target: "tor-address",
interface: "clnrest",
},
// "clams-websocket-tor-address": {
// name: "Websocket Tor Address",
// description: "The Tor address of the CLN websocket service.",
// type: "pointer",
// subtype: "package",
// "package-id": "c-lightning",
// target: "tor-address",
// interface: "websocket",
// },
"clams-websocket-tor-address": {
name: "Websocket Tor Address",
description: "The Tor address of the CLN websocket service.",
type: "pointer",
subtype: "package",
"package-id": "c-lightning",
target: "tor-address",
interface: "websocket",
},
"watchtower-tor-address": {
name: "TEoS Watchtower API Address",
description: "The Tor address of the TEoS Watchtower API",
Expand Down Expand Up @@ -263,12 +263,12 @@ export const [getConfig, setConfigMatcher] = compat.getConfigAndMatcher({
default: false,

},
// "clams-remote-websocket": {
// type: "boolean",
// name: "Clams Remote",
// description: "Accept incoming connections on port 7272, allowing Clams Remote to connect to Core Lightning.",
// default: false,
// },
"clams-remote-websocket": {
type: "boolean",
name: "Clams Remote",
description: "Accept incoming connections on port 7272, allowing Clams Remote to connect to Core Lightning.",
default: false,
},
"fee-base": {
type: "number",
name: "Routing Base Fee",
Expand Down
28 changes: 27 additions & 1 deletion scripts/procedures/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,34 @@ export const migration: T.ExpectedExports.migration =
throw new Error("Cannot downgrade");
},
},
"24.02.2.1": {
up: compat.migrations.updateConfig(
(config) => {
if (matches.shape({
advanced: matches.any
}).test(config)) {
config.advanced["clams-remote-websocket"] = false;
}
return config;
},
true,
{ version: "24.02.2.1", type: "up"},
),
down: compat.migrations.updateConfig(
(config) => {
if (matches.shape({
advanced: matches.shape({"clams-remote-websocket": matches.any})
}).test(config)) {
delete config.advanced["clams-remote-websocket"];
}
return config;
},
true,
{ version: "24.02.2.1", type: "down" }
)
},
},
"24.02.2",
"24.02.2.1",
);

function generateRandomString(length: number) {
Expand Down
52 changes: 26 additions & 26 deletions scripts/procedures/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export const properties: T.ExpectedExports.properties = async (
) {
return noPropertiesFound;
}
// if (
// (await util.exists(effects, {
// volumeId: "main",
// path: "start9/clamsRemoteWebsocketTorAddress",
// })) === false
// ) {
// return noPropertiesFound;
// }
if (
(await util.exists(effects, {
volumeId: "main",
path: "start9/clamsRemoteWebsocketTorAddress",
})) === false
) {
return noPropertiesFound;
}
if (
(await util.exists(effects, {
volumeId: "main",
Expand Down Expand Up @@ -121,12 +121,12 @@ export const properties: T.ExpectedExports.properties = async (
path: "start9/restTorAddress",
})
.then((x) => x.trim());
// const clamsRemoteWebsocketTorAddress = await effects
// .readFile({
// volumeId: "main",
// path: "start9/clamsRemoteWebsocketTorAddress",
// })
// .then((x) => x.trim());
const clamsRemoteWebsocketTorAddress = await effects
.readFile({
volumeId: "main",
path: "start9/clamsRemoteWebsocketTorAddress",
})
.then((x) => x.trim());
const watchtowerTorAddress = await effects
.readFile({
volumeId: "main",
Expand Down Expand Up @@ -353,18 +353,18 @@ export const properties: T.ExpectedExports.properties = async (
qr: true,
masked: true,
},
// ...(config.advanced["clams-remote-websocket"]
// ? {"Clams Remote Websocket URI": {
// type: "string",
// value: `${nodeInfo.id}@${clamsRemoteWebsocketTorAddress}:7272`,
// description:
// "The URI needed by Clams Remote to connect to Core Lightning's websocket interface.",
// copyable: true,
// qr: true,
// masked: true,
// }
// }
// : {}),
...(config.advanced["clams-remote-websocket"]
? {"Clams Remote Websocket URI": {
type: "string",
value: `${nodeInfo.id}@${clamsRemoteWebsocketTorAddress}:7272`,
description:
"The URI needed by Clams Remote to connect to Core Lightning's websocket interface.",
copyable: true,
qr: true,
masked: true,
}
}
: {}),
"UI Password": {
type: "string",
value: config["ui-password"],
Expand Down
7 changes: 4 additions & 3 deletions scripts/procedures/setConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ function configMaker(alias: Alias, config: SetConfig) {
const enableCLNRestPlugin = config.advanced.plugins.clnrest
? "clnrest-port=3010\nclnrest-host=0.0.0.0\n"
: "";
// const enableClamsRemoteWebsocket = config.advanced["clams-remote-websocket"]
// ? "bind-addr=ws::7272\n"
// : "";
const enableClamsRemoteWebsocket = config.advanced["clams-remote-websocket"]
? "bind-addr=ws::7272\n"
: "";
const enableClbossPlugin =
config.advanced.plugins.clboss.enabled === "enabled"
? "plugin=/usr/local/libexec/c-lightning/plugins/clboss"
Expand Down Expand Up @@ -335,6 +335,7 @@ experimental-onion-messages
experimental-offers
${enableExperimentalShutdownWrongFunding}
bind-addr=ws::4269
${enableClamsRemoteWebsocket}
${enableSlingPlugin}
${enableRestPlugin}
${enableCLNRestPlugin}
Expand Down

0 comments on commit 231cd9e

Please sign in to comment.