Skip to content

Commit 2e537fb

Browse files
committed
Merge #477: Add standalone clightning-rest service, add lndconnect-onion for clightning
8e1ad6e docs/services: update Zeus usage section, add clightning (Erik Arvstedt) 20c0194 readme: add hint about github table of contents button (Erik Arvstedt) e2fee4b lnd-rest-onion-service.nix: move to lndconnect-onion.nix, add clightning support (Erik Arvstedt) acf5fe6 add standalone `clightning-rest` service (Erik Arvstedt) c30aa33 cl-rest: rename pkg to clightning-rest (Erik Arvstedt) Pull request description: ACKs for top commit: jonasnick: ACK 8e1ad6e Tree-SHA512: 7d70648aa404fd9b452b6b015c68f72f24f284aae69f4d7df6e94167864d28aae0fca5642c9f6f469ce3ad9a2fd441d6b2de0a0178cc5b0c88ef1cd14bc3d104
2 parents e31e578 + 8e1ad6e commit 2e537fb

23 files changed

+389
-187
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Get started
4949

5050
Docs
5151
---
52+
Hint: To show a table of contents, click the button (![Github TOC button](docs/img/github-table-of-contents.svg)) in the
53+
top left corner of the documents.
54+
5255
* [Hardware requirements](docs/hardware.md)
5356
* [Installation](docs/install.md)
5457
* [Configuration and maintenance](docs/configuration.md)
@@ -73,11 +76,12 @@ NixOS modules ([src](modules/modules.nix))
7376
* [rebalance](https://github.com/lightningd/plugins/tree/master/rebalance): keeps your channels balanced
7477
* [summary](https://github.com/lightningd/plugins/tree/master/summary): print a nice summary of the node status
7578
* [zmq](https://github.com/lightningd/plugins/tree/master/zmq): publishes notifications via ZeroMQ to configured endpoints
79+
* [clightning-rest](https://github.com/Ride-The-Lightning/c-lightning-REST): REST server for clightning
7680
* [lnd](https://github.com/lightningnetwork/lnd) with support for announcing an onion service and [static channel backups](https://github.com/lightningnetwork/lnd/blob/master/docs/recovery.md)
7781
* [Lightning Loop](https://github.com/lightninglabs/loop)
7882
* [Lightning Pool](https://github.com/lightninglabs/pool)
7983
* [charge-lnd](https://github.com/accumulator/charge-lnd): policy-based channel fee manager
80-
* [lndconnect](https://github.com/LN-Zap/lndconnect) via a REST onion service
84+
* [lndconnect](https://github.com/LN-Zap/lndconnect): connect your wallet to lnd or clightning via a REST onion service
8185
* [Ride The Lightning](https://github.com/Ride-The-Lightning/RTL): web interface for `lnd` and `clightning`
8286
* [spark-wallet](https://github.com/shesek/spark-wallet)
8387
* [electrs](https://github.com/romanz/electrs)
Lines changed: 3 additions & 0 deletions
Loading

docs/services.md

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,61 @@ You can find the `<onion-address>` with command `nodeinfo`.
4444
The default password location is `$secretsDir/rtl-password`.
4545
See: [Secrets dir](./configuration.md#secrets-dir)
4646

47+
# Use LND or clightning with Zeus (smartphone wallet) via Tor
48+
1. Install [Zeus](https://zeusln.app)
49+
50+
2. Edit your `configuration.nix`
51+
52+
##### For lnd
53+
54+
Add the following config:
55+
```
56+
services.lnd.lndconnectOnion.enable = true;
57+
```
58+
59+
##### For clightning
60+
61+
Add the following config:
62+
```
63+
services.clightning-rest = {
64+
enable = true;
65+
lndconnectOnion.enable = true;
66+
};
67+
```
68+
69+
3. Deploy your configuration
70+
71+
3. Run the following command on your node (as user `operator`) to create a QR code
72+
with address and authentication information:
73+
74+
##### For lnd
75+
```
76+
lndconnect-onion
77+
```
78+
79+
##### For clightning
80+
```
81+
lndconnect-onion-clightning
82+
```
83+
84+
4. Configure Zeus
85+
- Add a new node
86+
- Select `Scan lndconnect config` (at the bottom) and scan the QR code
87+
- For clightning: Set `Node interface` to `c-lightning-REST`
88+
- Click `Save node config`
89+
- Start sending sats privately
90+
91+
### Additional lndconnect features
92+
Create plain text URLs or QR code images:
93+
```
94+
lndconnect-onion --url
95+
lndconnect-onion --image
96+
``````
97+
Create a QR code for a custom hostname:
98+
```
99+
lndconnect-onion --host=mynode.org
100+
```
101+
47102
# Connect to spark-wallet
48103
### Requirements
49104
* Android phone
@@ -87,42 +142,6 @@ See: [Secrets dir](./configuration.md#secrets-dir)
87142
Done
88143
```
89144
90-
# Connect to LND with Zeus
91-
### Requirements
92-
* Android phone
93-
* [Orbot](https://guardianproject.info/apps/orbot/) installed from
94-
[F-Droid](https://guardianproject.info/fdroid) (recommended) or
95-
[Google Play](https://play.google.com/store/apps/details?id=org.torproject.android&hl=en)
96-
* [Zeus](https://zeusln.app/) installed from
97-
[F-Droid](https://f-droid.org/en/packages/app.zeusln.zeus/) (recommended) or
98-
[Google Play](https://play.google.com/store/apps/details?id=app.zeusln.zeus)
99-
100-
1. Enable `restOnionService` in `configuration.nix`
101-
102-
Change
103-
```
104-
# services.lnd.restOnionService.enable = true;
105-
```
106-
to
107-
```
108-
services.lnd.restOnionService.enable = true;
109-
```
110-
111-
2. Deploy new `configuration.nix`
112-
113-
3. Run command `lndconnect-rest-onion` (under `operator` user) to create a QR code for
114-
connecting to LND via the REST onion service.
115-
116-
4. Enable Orbot VPN for Zeus
117-
```
118-
Open Orbot app
119-
Turn on "VPN Mode"
120-
Select Gear icon under "Tor-Enabled Apps"
121-
Toggle checkbox under Zeus icon
122-
```
123-
124-
5. Scan the QR code with your Zeus wallet and start sending Satoshis privately
125-
126145
# Connect to electrs
127146
### Requirements Android
128147
* Android phone

examples/configuration.nix

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@
5353
# == Plugins
5454
# See ../README.md (Features → clightning) for the list of available plugins.
5555
# services.clightning.plugins.prometheus.enable = true;
56+
#
57+
# == REST server
58+
# Set this to create a clightning REST onion service.
59+
# This also adds binary `lndconnect-onion-clightning` to the system environment.
60+
# This binary creates QR codes or URLs for connecting applications to clightning
61+
# via the REST onion service (see ../docs/services.md).
62+
#
63+
# services.clightning-rest = {
64+
# enable = true;
65+
# lndconnectOnion.enable = true;
66+
# };
5667

5768
### LND
5869
# Set this to enable lnd, a lightning implementation written in Go.
@@ -68,10 +79,10 @@
6879
# nix-bitcoin.onionServices.lnd.public = true;
6980
#
7081
# Set this to create an lnd REST onion service.
71-
# Adds binary `lndconnect-rest-onion` to the system environment.
72-
# This binary generates QR codes or URIs for connecting applications to lnd via the
73-
# REST onion service.
74-
# services.lnd.restOnionService.enable = true;
82+
# This also adds binary `lndconnect-onion` to the system environment.
83+
# This binary generates QR codes or URLs for connecting applications to lnd via the
84+
# REST onion service (see ../docs/services.md).
85+
# services.lnd.lndconnectOnion.enable = true;
7586
#
7687
## WARNING
7788
# If you use lnd, you should manually backup your wallet mnemonic

modules/backups.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ let
6262
''}
6363
${config.services.bitcoind.dataDir}
6464
${config.services.clightning.dataDir}
65+
${config.services.clightning-rest.dataDir}
6566
${config.services.lnd.dataDir}
6667
${optionalString (!cfg.with-bulk-data) ''
6768
- ${config.services.liquidd.dataDir}/*/blocks

modules/clightning-rest.nix

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{ config, lib, pkgs, ... }:
2+
3+
with lib;
4+
let
5+
options.services.clightning-rest = {
6+
enable = mkEnableOption "lightning-rest";
7+
port = mkOption {
8+
type = types.port;
9+
default = 3001;
10+
description = "REST server port.";
11+
};
12+
docPort = mkOption {
13+
type = types.port;
14+
default = 4001;
15+
description = "Swagger API documentation server port.";
16+
};
17+
dataDir = mkOption {
18+
type = types.path;
19+
default = "/var/lib/clightning-rest";
20+
description = "The data directory for clightning-rest.";
21+
};
22+
extraConfig = mkOption {
23+
type = types.attrs;
24+
default = {};
25+
example = {
26+
DOMAIN = "mynode.org";
27+
};
28+
description = ''
29+
Extra config options.
30+
See: https://github.com/Ride-The-Lightning/c-lightning-REST#option-1-via-config-file-cl-rest-configjson
31+
'';
32+
};
33+
# Used by ./rtl.nix
34+
group = mkOption {
35+
readOnly = true;
36+
default = clightning.group;
37+
description = "The group under which clightning-rest is run.";
38+
};
39+
# Rest server address.
40+
# Not configurable. The server always listens on all interfaces:
41+
# https://github.com/Ride-The-Lightning/c-lightning-REST/issues/84
42+
# Required by netns-isolation.
43+
address = mkOption {
44+
internal = true;
45+
default = "0.0.0.0";
46+
};
47+
tor.enforce = nbLib.tor.enforce;
48+
};
49+
50+
cfg = config.services.clightning-rest;
51+
nbLib = config.nix-bitcoin.lib;
52+
nbPkgs = config.nix-bitcoin.pkgs;
53+
54+
inherit (config.services)
55+
bitcoind
56+
clightning;
57+
58+
configFile = builtins.toFile "clightning-rest-config" (builtins.toJSON ({
59+
PORT = cfg.port;
60+
DOCPORT = cfg.docPort;
61+
LNRPCPATH = "${clightning.dataDir}/${bitcoind.makeNetworkName "bitcoin" "regtest"}/lightning-rpc";
62+
EXECMODE = "production";
63+
PROTOCOL = "https";
64+
RPCCOMMANDS = ["*"];
65+
} // cfg.extraConfig));
66+
in {
67+
inherit options;
68+
69+
config = mkIf cfg.enable {
70+
services.clightning.enable = true;
71+
72+
systemd.tmpfiles.rules = [
73+
"d '${cfg.dataDir}' 0770 ${clightning.user} ${cfg.group} - -"
74+
];
75+
76+
systemd.services.clightning-rest = mkIf cfg.enable {
77+
wantedBy = [ "multi-user.target" ];
78+
requires = [ "clightning.service" ];
79+
after = [ "clightning.service" ];
80+
path = [ pkgs.openssl ];
81+
environment.CL_REST_STATE_DIR = cfg.dataDir;
82+
preStart = ''
83+
ln -sfn ${configFile} cl-rest-config.json
84+
'';
85+
postStart = ''
86+
while [[ ! -e '${cfg.dataDir}/certs/access.macaroon' ]]; do
87+
sleep 0.1
88+
done
89+
'';
90+
serviceConfig = nbLib.defaultHardening // {
91+
# clightning-rest reads the config file from the working directory
92+
WorkingDirectory = cfg.dataDir;
93+
ExecStart = "${nbPkgs.clightning-rest}/bin/cl-rest";
94+
# Show "clightning-rest" instead of "node" in the journal
95+
SyslogIdentifier = "clightning-rest";
96+
User = clightning.user;
97+
Restart = "on-failure";
98+
RestartSec = "10s";
99+
ReadWritePaths = cfg.dataDir;
100+
} // nbLib.allowedIPAddresses cfg.tor.enforce
101+
// nbLib.nodejs;
102+
};
103+
};
104+
}

modules/lnd-rest-onion-service.nix

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)