HTLC Watchtower

It generates the schema file for the database’s data model: htlc_data.g.dart This file has to exist.
The libisar.so library is automatically downloaded by the database when it initializes itself for the first time. I’m not 100% sure if this works as expected with Docker.

I can get it to build in docker, just can’t run it. probably b/ I’m missing the DB.

Does main only need htlc_data.g.dart and config.json to run after being built? And it seems like htlc_data.g.dart needs to persist on a volume? I can get docker to do this. I’m going to add this to znndNode if I can get it to work.

htlc_data.g.dart is a source file used at compile time. Are you getting some error when trying to run it?

I’m not really familiar with Docker, but these commands should be enough to build and run the service (on Ubuntu). In the top level directory:

dart pub get
dart run build_runner build --delete-conflicting-outputs
mkdir build
dart compile exe src/main.dart -o build/htlc-watchtower
cp example.config.json build/config.json

This will build the htlc-watchtower binary into a directory named build. The libisar.so library has to be in the build directory as well. The service will automatically attempt to download it when its run, but maybe this doesn’t work with Docker.

To download the library on command line in Ubuntu this should work:

wget https://github.com/isar/isar/releases/download/3.1.0/libisar_linux_x64.so -O build/libisar.so
1 Like

perfect. this is exactly what I need. I’ll get this running and report back.

I added this option to the config.json: unlock_threshold_in_minutes

It can be used to configure a custom threshold for how much time is left until expiration before the watchtower unlocks an HTLC.

The default is 60 minutes, which means that the watchtower will unlock an HTLC once it is 60 minutes away from expiring. The minimum it can be set to is 30 minutes.

With this last change, I get the following error when running locally on Ubuntu

x3639@0x3639-NoM:~/Github/htlc-watchtower/build$ ./htlc-watchtower 
INFO: 2023-05-10 13:25:44.132974: Initializing websocket connection ...
SEVERE: 2023-05-10 13:25:44.134157: Failed to connect to Zenon node. Is the node running?

cat config.json

x3639@0x3639-NoM:~/Github/htlc-watchtower/build$ cat config.json 
node_url_ws: 'ws://public.deeZNNodez.com:35998'
unlock_threshold_in_minutes: 60

I’ve tried 3 different nodes - both ws and wss

When I try to run the Dockerfile Image I get the folllowing error:

SEVERE: 2023-05-10 18:51:41.965667: Invalid argument(s): Failed to load dynamic library '/app/src/libisar.so': libgcc_s.so.1: cannot open shared object file: No such file or directory

But I doubt that is related to the issue above. I’ve manually downloaded https://github.com/isar/isar/releases/download/3.1.0/libisar_linux_x64.so and moved here src/libisar.so If we can get the native build to work in Ubuntu, I can trouble shoot the Dockerfile

FROM dart:stable AS build

# Resolve app dependencies.
WORKDIR /app
COPY pubspec.* ./
RUN dart pub get

# Copy app source code and AOT compile it.
COPY . .
# Ensure packages are still up-to-date if anything has changed
RUN dart pub get --offline
RUN dart run build_runner build --delete-conflicting-outputs
RUN dart compile exe src/main.dart -o src/main

# Build minimal serving image from AOT-compiled `/main` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/src/. /app/src/

#Start service.
CMD ["/app/src/main"]

Looks like I typo’d the file extension in the last post, it should be:

cp example.config.yaml build/config.yaml

And for this:

I’ll have to write some proper instructions and add them to the repo’s readme.

got it. makes sense now. build is required. I’ll get this going today.

I got the Dockerfile to work!!! I’ll make it less shitty and share here. Maybe I can submit a PR to add that to your repo along with instructions.

2 Likes
x3639@0x3639-NoM:~/Github/htlc-watchtower$ docker run -v wallet:/root/.znn/wallet htlc-watchtower
INFO: 2023-05-11 22:18:28.464656: Initializing websocket connection ...
INFO: 2023-05-11 22:18:28.729298: Websocket connection successfully established
INFO: 2023-05-11 22:18:28.729423: Connected to node ws://public.deeznnodez.com:35998
INFO: 2023-05-11 22:18:28.750339: Node is in sync
INFO: 2023-05-11 22:18:28.816243: Loading ./libargon2_ffi_plugin.so from path /root/.pub-cache/git/znn_sdk_dart-abf887d30311494d7e6cd87b2d74b87f55d37abd/lib/src/argon2/blobs/./libargon2_ffi_plugin.so
INFO: 2023-05-11 22:18:29.684808: The watchtower does not have enough Plasma. Please fuse at least 120 QSR to address: z1qpu77xejhe2pcxmkhyh5m9vlssxynxaakmk34c
INFO: 2023-05-11 22:18:29.684876: Waiting for Plasma
INFO: 2023-05-11 22:25:20.597073: The watchtower has enough Plasma now
INFO: 2023-05-11 22:25:20.597150: Watchtower initialized with address z1qpu77xejhe2pcxmkhyh5m9vlssxynxaakmk34c
INFO: 2023-05-11 22:25:20.597238: Running watchtower

That was not easy to get this to work with Docker. I gave up on downloading the libisar.so file on build. I just downloaded manually and put in the build folder. Maybe I’ll try again later.