joinmarket-ob-watcher: extra permissions & functionality for fidelity bonds
This commit is contained in:
parent
d7f9e33e1c
commit
00a0759884
@ -5,7 +5,11 @@ let
|
|||||||
cfg = config.services.joinmarket-ob-watcher;
|
cfg = config.services.joinmarket-ob-watcher;
|
||||||
nbLib = config.nix-bitcoin.lib;
|
nbLib = config.nix-bitcoin.lib;
|
||||||
nbPkgs = config.nix-bitcoin.pkgs;
|
nbPkgs = config.nix-bitcoin.pkgs;
|
||||||
|
secretsDir = config.nix-bitcoin.secretsDir;
|
||||||
|
|
||||||
|
inherit (config.services) bitcoind;
|
||||||
|
|
||||||
|
torAddress = config.services.tor.client.socksListenAddress;
|
||||||
socks5Settings = with config.services.tor.client.socksListenAddress; ''
|
socks5Settings = with config.services.tor.client.socksListenAddress; ''
|
||||||
socks5 = true
|
socks5 = true
|
||||||
socks5_host = ${addr}
|
socks5_host = ${addr}
|
||||||
@ -14,7 +18,11 @@ let
|
|||||||
|
|
||||||
configFile = builtins.toFile "config" ''
|
configFile = builtins.toFile "config" ''
|
||||||
[BLOCKCHAIN]
|
[BLOCKCHAIN]
|
||||||
blockchain_source = no-blockchain
|
blockchain_source = bitcoin-rpc
|
||||||
|
network = ${bitcoind.network}
|
||||||
|
rpc_host = ${bitcoind.rpc.address}
|
||||||
|
rpc_port = ${toString bitcoind.rpc.port}
|
||||||
|
rpc_user = ${bitcoind.rpc.users.joinmarket-ob-watcher.name}
|
||||||
|
|
||||||
[MESSAGING:server1]
|
[MESSAGING:server1]
|
||||||
host = darkirc6tqgpnwd3blln3yfv5ckl47eg7llfxkmtovrv7c7iwohhb6ad.onion
|
host = darkirc6tqgpnwd3blln3yfv5ckl47eg7llfxkmtovrv7c7iwohhb6ad.onion
|
||||||
@ -48,6 +56,16 @@ in {
|
|||||||
default = "/var/lib/joinmarket-ob-watcher";
|
default = "/var/lib/joinmarket-ob-watcher";
|
||||||
description = "The data directory for JoinMarket orderbook watcher.";
|
description = "The data directory for JoinMarket orderbook watcher.";
|
||||||
};
|
};
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "joinmarket-ob-watcher";
|
||||||
|
description = "The user as which to run JoinMarket.";
|
||||||
|
};
|
||||||
|
group = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = cfg.user;
|
||||||
|
description = "The group as which to run JoinMarket.";
|
||||||
|
};
|
||||||
# This option is only used by netns-isolation
|
# This option is only used by netns-isolation
|
||||||
enforceTor = mkOption {
|
enforceTor = mkOption {
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
@ -56,12 +74,23 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
services.bitcoind.rpc.users.joinmarket-ob-watcher = {
|
||||||
|
passwordHMACFromFile = true;
|
||||||
|
rpcwhitelist = bitcoind.rpc.users.public.rpcwhitelist ++ [
|
||||||
|
"listwallets"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Joinmarket is Tor-only
|
# Joinmarket is Tor-only
|
||||||
services.tor = {
|
services.tor = {
|
||||||
enable = true;
|
enable = true;
|
||||||
client.enable = true;
|
client.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
|
||||||
|
];
|
||||||
|
|
||||||
systemd.services.joinmarket-ob-watcher = {
|
systemd.services.joinmarket-ob-watcher = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
requires = [ "tor.service" ];
|
requires = [ "tor.service" ];
|
||||||
@ -69,13 +98,18 @@ in {
|
|||||||
# The service writes to HOME/.config/matplotlib
|
# The service writes to HOME/.config/matplotlib
|
||||||
environment.HOME = cfg.dataDir;
|
environment.HOME = cfg.dataDir;
|
||||||
preStart = ''
|
preStart = ''
|
||||||
ln -snf ${configFile} ${cfg.dataDir}/joinmarket.cfg
|
{
|
||||||
|
cat ${configFile}
|
||||||
|
echo
|
||||||
|
echo '[BLOCKCHAIN]'
|
||||||
|
echo "rpc_password = $(cat ${secretsDir}/bitcoin-rpcpassword-joinmarket-ob-watcher)"
|
||||||
|
} > '${cfg.dataDir}/joinmarket.cfg'
|
||||||
'';
|
'';
|
||||||
serviceConfig = nbLib.defaultHardening // rec {
|
serviceConfig = nbLib.defaultHardening // rec {
|
||||||
DynamicUser = true;
|
|
||||||
StateDirectory = "joinmarket-ob-watcher";
|
StateDirectory = "joinmarket-ob-watcher";
|
||||||
StateDirectoryMode = "770";
|
StateDirectoryMode = "770";
|
||||||
WorkingDirectory = cfg.dataDir; # The service creates dir 'logs' in the working dir
|
WorkingDirectory = cfg.dataDir; # The service creates dir 'logs' in the working dir
|
||||||
|
User = cfg.user;
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${nbPkgs.joinmarket}/bin/jm-ob-watcher --datadir=${cfg.dataDir} \
|
${nbPkgs.joinmarket}/bin/jm-ob-watcher --datadir=${cfg.dataDir} \
|
||||||
--host=${cfg.address} --port=${toString cfg.port}
|
--host=${cfg.address} --port=${toString cfg.port}
|
||||||
@ -85,5 +119,17 @@ in {
|
|||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
} // nbLib.allowTor;
|
} // nbLib.allowTor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
users.users.${cfg.user} = {
|
||||||
|
isSystemUser = true;
|
||||||
|
group = cfg.group;
|
||||||
|
home = cfg.dataDir;
|
||||||
|
};
|
||||||
|
users.groups.${cfg.group} = {};
|
||||||
|
|
||||||
|
nix-bitcoin.secrets = {
|
||||||
|
bitcoin-rpcpassword-joinmarket-ob-watcher.user = cfg.user;
|
||||||
|
bitcoin-HMAC-joinmarket-ob-watcher.user = bitcoind.user;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -251,6 +251,7 @@ in {
|
|||||||
};
|
};
|
||||||
joinmarket-ob-watcher = {
|
joinmarket-ob-watcher = {
|
||||||
id = 26;
|
id = 26;
|
||||||
|
connections = [ "bitcoind" ];
|
||||||
};
|
};
|
||||||
lightning-pool = {
|
lightning-pool = {
|
||||||
id = 27;
|
id = 27;
|
||||||
|
@ -15,6 +15,7 @@ makeHMAC() {
|
|||||||
|
|
||||||
makePasswordSecret bitcoin-rpcpassword-privileged
|
makePasswordSecret bitcoin-rpcpassword-privileged
|
||||||
makePasswordSecret bitcoin-rpcpassword-btcpayserver
|
makePasswordSecret bitcoin-rpcpassword-btcpayserver
|
||||||
|
makePasswordSecret bitcoin-rpcpassword-joinmarket-ob-watcher
|
||||||
makePasswordSecret bitcoin-rpcpassword-public
|
makePasswordSecret bitcoin-rpcpassword-public
|
||||||
makePasswordSecret lnd-wallet-password
|
makePasswordSecret lnd-wallet-password
|
||||||
makePasswordSecret liquid-rpcpassword
|
makePasswordSecret liquid-rpcpassword
|
||||||
@ -25,6 +26,7 @@ makePasswordSecret jm-wallet-password
|
|||||||
[[ -e bitcoin-HMAC-privileged ]] || makeHMAC privileged
|
[[ -e bitcoin-HMAC-privileged ]] || makeHMAC privileged
|
||||||
[[ -e bitcoin-HMAC-public ]] || makeHMAC public
|
[[ -e bitcoin-HMAC-public ]] || makeHMAC public
|
||||||
[[ -e bitcoin-HMAC-btcpayserver ]] || makeHMAC btcpayserver
|
[[ -e bitcoin-HMAC-btcpayserver ]] || makeHMAC btcpayserver
|
||||||
|
[[ -e bitcoin-HMAC-joinmarket-ob-watcher ]] || makeHMAC joinmarket-ob-watcher
|
||||||
[[ -e spark-wallet-login ]] || echo "login=spark-wallet:$(cat spark-wallet-password)" > spark-wallet-login
|
[[ -e spark-wallet-login ]] || echo "login=spark-wallet:$(cat spark-wallet-password)" > spark-wallet-login
|
||||||
[[ -e backup-encryption-env ]] || echo "PASSPHRASE=$(cat backup-encryption-password)" > backup-encryption-env
|
[[ -e backup-encryption-env ]] || echo "PASSPHRASE=$(cat backup-encryption-password)" > backup-encryption-env
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user