Fix spark wallet QR code display by providing the onion hostname as public url

This commit is contained in:
Jonas Nick 2019-03-27 00:49:54 +00:00
parent fe23ced5ec
commit 0d5c67c1cf
No known key found for this signature in database
GPG Key ID: 4861DBF262123605
3 changed files with 35 additions and 11 deletions

View File

@ -39,8 +39,7 @@ The `nix-bitcoin.nix` module provides the two profiles "minimal" and "all":
* [nanopos](https://github.com/ElementsProject/nanopos) * [nanopos](https://github.com/ElementsProject/nanopos)
* adds an index page using nginx to display node information and link to nanopos * adds an index page using nginx to display node information and link to nanopos
* [spark-wallet](https://github.com/shesek/spark-wallet) * [spark-wallet](https://github.com/shesek/spark-wallet)
* Notes: run `nodeinfo` to get its onion address and `systemctl status spark-wallet` to get the access key. * Notes: run `journalctl -eu spark-wallet` to get the onion address, access key and QR access code for the spark wallet android app.
When entering the onion address on the Android app don't forgot to prepend "http://"
* other * other
* [electrs](https://github.com/romanz/electrs) can be enabled by setting `services.electrs.enable` in modules `nix-bitcoin.nix` to `true` * [electrs](https://github.com/romanz/electrs) can be enabled by setting `services.electrs.enable` in modules `nix-bitcoin.nix` to `true`

View File

@ -172,12 +172,7 @@ in {
services.nix-bitcoin-webindex.enable = cfg.modules == "all"; services.nix-bitcoin-webindex.enable = cfg.modules == "all";
services.clightning.autolisten = cfg.modules == "all"; services.clightning.autolisten = cfg.modules == "all";
services.spark-wallet.enable = cfg.modules == "all"; services.spark-wallet.enable = cfg.modules == "all";
services.tor.hiddenServices.spark-wallet = { services.spark-wallet.onion-service = true;
map = [{
port = 80; toPort = 9737;
}];
version = 3;
};
services.electrs.enable = false; services.electrs.enable = false;
services.electrs.high-memory = false; services.electrs.high-memory = false;
services.tor.hiddenServices.electrs = { services.tor.hiddenServices.electrs = {

View File

@ -4,6 +4,19 @@ with lib;
let let
cfg = config.services.spark-wallet; cfg = config.services.spark-wallet;
dataDir = "/var/lib/spark-wallet/";
onion-chef-service = (if cfg.onion-service then [ "onion-chef.service" ] else []);
run-spark-wallet = pkgs.writeScript "run-spark-wallet" ''
CMD="${pkgs.spark-wallet}/bin/spark-wallet --ln-path ${cfg.ln-path} -Q -k -c /secrets/spark-wallet-login"
${optionalString cfg.onion-service
''
echo Getting onion hostname
CMD="$CMD --public-url http://$(cat /var/lib/onion-chef/clightning/spark-wallet)"
''
}
echo Running $CMD
$CMD
'';
in { in {
options.services.spark-wallet = { options.services.spark-wallet = {
enable = mkOption { enable = mkOption {
@ -20,16 +33,33 @@ in {
"The path of the clightning data directory."; "The path of the clightning data directory.";
''; '';
}; };
onion-service = mkOption {
type = types.bool;
default = false;
description = ''
"If enabled, configures spark-wallet to be reachable through an onion service.";
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.tor.enable = cfg.onion-service;
services.tor.hiddenServices.spark-wallet = mkIf cfg.onion-service {
map = [{
port = 80; toPort = 9737;
}];
version = 3;
};
services.onion-chef.enable = cfg.onion-service;
services.onion-chef.access.clightning = if cfg.onion-service then [ "spark-wallet" ] else [];
systemd.services.spark-wallet = { systemd.services.spark-wallet = {
description = "Run spark-wallet"; description = "Run spark-wallet";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
requires = [ "clightning.service" ]; requires = [ "clightning.service" ] ++ onion-chef-service;
after = [ "clightning.service" ]; after = [ "clightning.service" ] ++ onion-chef-service;
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.spark-wallet}/bin/spark-wallet --ln-path ${cfg.ln-path} -k -c /secrets/spark-wallet-login"; PermissionsStartOnly = "true";
ExecStart = "${pkgs.bash}/bin/bash ${run-spark-wallet}";
User = "clightning"; User = "clightning";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "10s"; RestartSec = "10s";