Skip to content

Commit 303d3fc

Browse files
committed
Add eclair node into stack
1 parent 4cdc1cc commit 303d3fc

File tree

8 files changed

+116
-7
lines changed

8 files changed

+116
-7
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@ LIGHTNINGDDAVE_PORT=19765
3333
LIGHTNINGDEMMA_HOST=lightningdemma
3434
LIGHTNINGDEMMA_PORT=19775
3535

36+
ECLAIRDFRANK_HOST=eclairdfrank
37+
ECLAIRDFRANK_PORT=19785
38+
ECLAIRDFRANK_API_PORT=8100
39+
3640
COMPOSE_FILE=docker-compose.yml
3741
COMPOSE_PROJECT_NAME=bitcoindevstack

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 2019-09-28
4+
- Add headless `eclair` implementation on Bitcoin as `eclairdfrank`
5+
36
## 2019-09-11
47
- Add `lightningd-elements` WIP image build & two c-lightning nodes on Elements
58
- Modify Ubuntu base versions in Docker images

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@
88
L+: | YOUR APPLICATION STACK |
99
+---------------------------------+-------+--------------------------+
1010
| |
11-
/ |
12-
+-----------+ +---------+ +-----------+ | +----------+ +----------+
11+
+---------+ | |
12+
| | | |
13+
| FRANK | | |
14+
| | | |
15+
+----+----+ | |
16+
| / |
17+
+-----------+ +----+----+ +-----------+ | +----------+ +----------+
1318
| | | | | | | | | | |
1419
L2: | ALICE +--+ BOB +--+ CAROL | | | DAVE +--+ EMMA |
1520
| | | | | | | | | | |
@@ -25,19 +30,20 @@ L1: | BITCOIND | / | ELEMENTSD |
2530
+------------------+ +------------------+
2631
```
2732

28-
This `docker-compose` template launches `bitcoind`, two `lnd` containers named `lndalice` & `lndbob`, with a `lightningd` container as `lightningdcarol`.
33+
This `docker-compose` template launches `bitcoind`, two `lnd` containers named `lndalice` & `lndbob`, with a `lightningd` container as `lightningdcarol`, and an `eclair` container as `eclairdfrank`.
2934

3035
Additionally it will launch an `elementsd` side chain (aka Liquid), with prototype `lightningd-elements` implementation containers as `lightningddave` & `lightningdemma`.
3136

3237
Everything is configured to run in **regtest** mode but can be adjusted as required.
3338

39+
## See the [changelog](CHANGELOG.md) before upgrading.
40+
3441
### Notes & prerequisites
3542
- `docker` and `docker-compose` installation is required (https://docs.docker.com/install/).
3643
- `jq` tool is used in examples for parsing json responses.
3744
- All nodes will sync to chain after the first Bitcoin & Elements regtest blocks are generated.
3845
- All daemons are compiled from source but it is not recommended to use them in production environments.
3946
- Ports and other daemon configuration can be changed in the `.env` and `docker-compose.yml` files.
40-
- See the [changelog](CHANGELOG.md) when upgrading.
4147

4248
### Coming soon
4349
- Elements token creation and transaction scripts
@@ -52,6 +58,7 @@ It may take up to 30 minutes to launch the stack if container images are not alr
5258
$ docker-compose up -d bitcoind
5359
$ bin/b-cli generate 101
5460
$ docker-compose up -d lndalice lndbob
61+
$ docker-compose up -d eclairdfrank
5562
5663
# Elements can be started optionally
5764
$ docker-compose up -d elementsd
@@ -77,6 +84,7 @@ $ bin/ln-bob getinfo
7784
$ bin/ld-carol getinfo
7885
$ bin/ld-dave getinfo
7986
$ bin/ld-emma getinfo
87+
$ bin/ed-frank getinfo
8088
```
8189

8290
A convenience script is provided to create a channel from `bob` to `alice` with some funding between the two `lnd` containers.
@@ -89,7 +97,7 @@ $ bin/ln-alice listchannels
8997
$ bin/ln-bob listchannels
9098
```
9199

92-
Another convenience script will connect `bob` to `carol` on the `lightningd` implementation of LN on Bitcoin.
100+
Another convenience script will connect `bob` to `carol` across the `lightningd` implementation of LN on Bitcoin.
93101
```
94102
$ bin/ld-connect
95103
# once channels are opened a payment can be simulated (note amount in *mSats*)
@@ -98,6 +106,15 @@ $ bin/ln-bob payinvoice $CAROL_INVOICE
98106
$ bin/ld-carol listfunds
99107
```
100108

109+
A third script will connect `bob` to `frank` across the `eclair` implementation of LN on Bitcoin.
110+
```
111+
$ bin/ed-connect
112+
# once channels are opened a payment can be simulated (note amount in *mSats*)
113+
$ FRANK_INVOICE=$(bin/ed-frank createinvoice --amountMsat=10000000 --description="test" | jq '.serialized' | tr -d '"')
114+
$ bin/ln-bob payinvoice $FRANK_INVOICE
115+
$ bin/ed-frank audit
116+
```
117+
101118
Elements sidechain is available and can be pegged in from regtest Bitcoin chain using the provided convenience script.
102119
```
103120
$ bin/e-pegin 1.337
@@ -114,7 +131,7 @@ $ bin/ld-dave listpays
114131
$ bin/ld-emma listinvoices
115132
```
116133

117-
REST/RPC queries can be executed directly from the host to the daemons as follows:
134+
REST/RPC queries can be executed directly from your application to each daemon. Use standard RPC adapters to connect to these and have full control over money flow; hook into message queues for notifications B).
118135
```
119136
#bitcoind
120137
$ curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getwalletinfo","params":[]}' -H 'content-type:text/plain;' http://bitcoin:bitcoin@127.0.0.1:18889/
@@ -127,6 +144,9 @@ $ echo "$(docker-compose exec -T lndbob cat /shared/tls.cert)" > ./bob-tls.cert
127144
$ curl -XGET --cacert ./alice-tls.cert --header "$ALICE_MACAROON_HEADER" https://127.0.0.1:8080/v1/balance/channels
128145
$ curl -XGET --cacert ./bob-tls.cert --header "$BOB_MACAROON_HEADER" https://127.0.0.1:8090/v1/balance/channels
129146
147+
#eclair
148+
$ curl -XPOST -u :password http://127.0.0.1:8100/getinfo
149+
130150
#elementsd
131151
$ curl --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getwalletinfo","params":[]}' -H 'content-type:text/plain;' http://elements:elements@127.0.0.1:18886/
132152

bin/ed-connect

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
source .env
4+
5+
bin/b-cli sendtoaddress $(bin/ln-bob newaddress np2wkh | jq '.address' | tr -d '"') 1
6+
bin/b-cli generate 1
7+
ECLAIRDFRANK_NODEID=$(bin/ed-frank getinfo | jq '.nodeId' | tr -d '"')
8+
bin/ln-bob connect $ECLAIRDFRANK_NODEID@$ECLAIRDFRANK_HOST:$ECLAIRDFRANK_PORT
9+
bin/ln-bob openchannel --node_key $ECLAIRDFRANK_NODEID --local_amt=10000000 --push_amt=5000000 --private
10+
bin/b-cli generate 5

bin/ed-frank

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
source .env
4+
5+
docker-compose exec -T eclairdfrank eclair-cli \
6+
-p password \
7+
-a eclairdfrank:$ECLAIRDFRANK_API_PORT \
8+
"$@"

docker-compose.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ volumes:
1212
lightningdcarol_data:
1313
lightningddave_data:
1414
lightningdemma_data:
15+
eclairdfrank_data:
1516

1617
services:
1718
bitcoind:
@@ -220,4 +221,19 @@ services:
220221
- elementsd
221222
volumes:
222223
- lightningdemma_data:/lightningd
223-
- elements_shared:/elements
224+
- elements_shared:/elements
225+
226+
eclairdfrank:
227+
container_name: ${COMPOSE_PROJECT_NAME}_eclairdfrank
228+
image: eclaird:0.3.1
229+
build: ./eclaird
230+
command: ["java", "-jar", "eclair-node.jar"]
231+
environment:
232+
- JAVA_TOOL_OPTIONS=-Xmx512m -Declair.chain=regtest -Declair.server.port=${ECLAIRDFRANK_PORT} -Declair.bitcoind.host=${BITCOIN_HOST} -Declair.bitcoind.rpcport=${BITCOIN_RPC_PORT} -Declair.bitcoind.rpcuser=${BITCOIN_RPC_USER} -Declair.bitcoind.rpcpassword=${BITCOIN_RPC_PASSWORD} -Declair.bitcoind.zmqtx=tcp://${BITCOIN_HOST}:${BITCOIN_ZMQ_TX_PORT} -Declair.bitcoind.zmqblock=tcp://${BITCOIN_HOST}:${BITCOIN_ZMQ_BLOCK_PORT} -Declair.api.enabled=true -Declair.api.port=${ECLAIRDFRANK_API_PORT} -Declair.api.password=password -Declair.api.binding-ip=0.0.0.0
233+
ports:
234+
- "${ECLAIRDFRANK_API_PORT}:${ECLAIRDFRANK_API_PORT}"
235+
- "127.0.0.1:${ECLAIRDFRANK_API_PORT}:${ECLAIRDFRANK_API_PORT}"
236+
depends_on:
237+
- bitcoind
238+
volumes:
239+
- eclairdfrank_data:/data

eclaird/Dockerfile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FROM adoptopenjdk/openjdk11:jdk-11.0.3_7-alpine as BUILD
2+
3+
# Setup maven, we don't use https://hub.docker.com/_/maven/ as it declare .m2 as volume, we loose all mvn cache
4+
# We can alternatively do as proposed by https://github.com/carlossg/docker-maven#packaging-a-local-repository-with-the-image
5+
# this was meant to make the image smaller, but we use multi-stage build so we don't care
6+
RUN apk add --no-cache curl tar bash git
7+
8+
ARG MAVEN_VERSION=3.6.2
9+
ARG USER_HOME_DIR="/root"
10+
ARG SHA=3fbc92d1961482d6fbd57fbf3dd6d27a4de70778528ee3fb44aa7d27eb32dfdc
11+
ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries
12+
13+
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
14+
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \
15+
&& echo "${SHA} /tmp/apache-maven.tar.gz" | sha256sum -c - \
16+
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \
17+
&& rm -f /tmp/apache-maven.tar.gz \
18+
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
19+
20+
ENV MAVEN_HOME /usr/share/maven
21+
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
22+
23+
# Let's fetch eclair dependencies, so that Docker can cache them
24+
# This way we won't have to fetch dependencies again if only the source code changes
25+
# The easiest way to reliably get dependencies is to build the project with no sources
26+
WORKDIR /usr/src
27+
RUN git clone -n https://github.com/ACINQ/eclair.git . \
28+
&& git checkout v0.3.1
29+
RUN mvn package -pl eclair-node -am -DskipTests
30+
# It might be good idea to run the tests here, so that the docker build fail if the code is bugged
31+
32+
# We currently use a debian image for runtime because of some jni-related issue with sqlite
33+
FROM openjdk:11.0.4-jre-slim
34+
WORKDIR /app
35+
36+
# install jq for eclair-cli
37+
RUN apt-get update && apt-get install -y bash jq curl
38+
39+
# copy and install eclair-cli executable
40+
COPY --from=BUILD /usr/src/eclair-core/eclair-cli .
41+
RUN chmod +x eclair-cli && mv eclair-cli /sbin/eclair-cli
42+
43+
# Eclair only needs the eclair-node-*.jar to run
44+
COPY --from=BUILD /usr/src/eclair-node/target/eclair-node-*.jar eclair-node.jar
45+
46+
ADD ./eclair.conf /data/eclair.conf

eclaird/eclair.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclair.printToConsole
2+
eclair.headless

0 commit comments

Comments
 (0)