lnd: add option 'restOnionService'
This commit is contained in:
parent
a344ae95c9
commit
ebd478fd0d
|
@ -63,6 +63,7 @@ NixOS modules
|
|||
* [summary](https://github.com/lightningd/plugins/tree/master/summary): print a nice summary of the node status
|
||||
* [zmq](https://github.com/lightningd/plugins/tree/master/zmq): publishes notifications via ZeroMQ to configured endpoints
|
||||
* [lnd](https://github.com/lightningnetwork/lnd) with support for announcing an onion service
|
||||
* [lndconnect](https://github.com/LN-Zap/lndconnect) via a REST onion service
|
||||
* [spark-wallet](https://github.com/shesek/spark-wallet)
|
||||
* [electrs](https://github.com/romanz/electrs)
|
||||
* [btcpayserver](https://github.com/btcpayserver/btcpayserver)
|
||||
|
|
|
@ -63,6 +63,12 @@
|
|||
# The onion service is automatically announced to peers.
|
||||
# nix-bitcoin.onionServices.lnd.public = true;
|
||||
#
|
||||
# Set this to create an lnd REST onion service.
|
||||
# Adds binary `lndconnect-rest-onion` to the system environment.
|
||||
# This binary generates QR codes or URIs for connecting applications to lnd via the
|
||||
# REST onion service.
|
||||
# services.lnd.restOnionService.enable = true;
|
||||
#
|
||||
## WARNING
|
||||
# If you use lnd, you should manually backup your wallet mnemonic
|
||||
# seed. This will allow you to recover on-chain funds. You can run the
|
||||
|
|
51
modules/lnd-rest-onion-service.nix
Normal file
51
modules/lnd-rest-onion-service.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.lnd.restOnionService;
|
||||
nbLib = config.nix-bitcoin.lib;
|
||||
secretsDir = config.nix-bitcoin.secretsDir;
|
||||
|
||||
lnd = config.services.lnd;
|
||||
|
||||
bin = pkgs.writeScriptBin "lndconnect-rest-onion" ''
|
||||
#!/usr/bin/env -S sudo -u lnd ${pkgs.bash}/bin/bash
|
||||
|
||||
exec ${cfg.package}/bin/lndconnect \
|
||||
--host=$(cat ${config.nix-bitcoin.onionAddresses.dataDir}/lnd/lnd-rest) \
|
||||
--port=${toString lnd.restPort} \
|
||||
--lnddir=${lnd.dataDir} \
|
||||
--tlscertpath=${secretsDir}/lnd-cert "$@"
|
||||
'';
|
||||
in {
|
||||
options.services.lnd.restOnionService = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Create an onion service for the lnd REST service.
|
||||
Add a `lndconnect-rest-onion` binary (https://github.com/LN-Zap/lndconnect) to the system environment.
|
||||
This binary generates QR codes or URIs for connecting applications to lnd via the REST onion service.
|
||||
'';
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = config.nix-bitcoin.pkgs.lndconnect;
|
||||
description = "The package providing lndconnect binaries.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.tor = {
|
||||
enable = true;
|
||||
hiddenServices.lnd-rest = nbLib.mkHiddenService {
|
||||
toHost = lnd.restAddress;
|
||||
port = lnd.restPort;
|
||||
};
|
||||
};
|
||||
nix-bitcoin.onionAddresses.access.lnd = [ "lnd-rest" ];
|
||||
|
||||
environment.systemPackages = [ bin ];
|
||||
};
|
||||
}
|
|
@ -13,6 +13,7 @@ with lib;
|
|||
./clightning-plugins
|
||||
./spark-wallet.nix
|
||||
./lnd.nix
|
||||
./lnd-rest-onion-service.nix
|
||||
./lightning-loop.nix
|
||||
./btcpayserver.nix
|
||||
./electrs.nix
|
||||
|
|
|
@ -11,6 +11,7 @@ in
|
|||
bitcoind
|
||||
clightning
|
||||
lnd
|
||||
lndconnect
|
||||
nbxplorer
|
||||
btcpayserver;
|
||||
|
||||
|
|
|
@ -46,6 +46,8 @@ let testEnv = rec {
|
|||
tests.lnd = cfg.lnd.enable;
|
||||
services.lnd.port = 9736;
|
||||
|
||||
tests.lnd-rest-onion-service = cfg.lnd.restOnionService.enable;
|
||||
|
||||
tests.lightning-loop = cfg.lightning-loop.enable;
|
||||
|
||||
tests.electrs = cfg.electrs.enable;
|
||||
|
@ -115,6 +117,7 @@ let testEnv = rec {
|
|||
test.features.clightningPlugins = true;
|
||||
services.spark-wallet.enable = true;
|
||||
services.lnd.enable = true;
|
||||
services.lnd.restOnionService.enable = true;
|
||||
services.lightning-loop.enable = true;
|
||||
services.electrs.enable = true;
|
||||
services.liquidd.enable = true;
|
||||
|
|
|
@ -162,6 +162,11 @@ def _():
|
|||
assert_no_failure("lnd")
|
||||
|
||||
|
||||
@test("lnd-rest-onion-service")
|
||||
def _():
|
||||
assert_matches("runuser -u operator -- lndconnect-rest-onion -j", ".onion")
|
||||
|
||||
|
||||
@test("lightning-loop")
|
||||
def _():
|
||||
assert_running("lightning-loop")
|
||||
|
|
Loading…
Reference in New Issue
Block a user