joinmarket: use preStart, postStart
This commit is contained in:
parent
e2c6eb6681
commit
881a3aa004
@ -231,37 +231,35 @@ in {
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
requires = [ "bitcoind.service" ];
|
requires = [ "bitcoind.service" ];
|
||||||
after = [ "bitcoind.service" ];
|
after = [ "bitcoind.service" ];
|
||||||
serviceConfig = nbLib.defaultHardening // {
|
preStart = ''
|
||||||
ExecStartPre = nbLib.script "joinmarket-create-config" ''
|
install -o '${cfg.user}' -g '${cfg.group}' -m 640 ${configFile} ${cfg.dataDir}/joinmarket.cfg
|
||||||
install -o '${cfg.user}' -g '${cfg.group}' -m 640 ${configFile} ${cfg.dataDir}/joinmarket.cfg
|
|
||||||
sed -i \
|
sed -i \
|
||||||
"s|@@RPC_PASSWORD@@|rpc_password = $(cat ${secretsDir}/bitcoin-rpcpassword-privileged)|" \
|
"s|@@RPC_PASSWORD@@|rpc_password = $(cat ${secretsDir}/bitcoin-rpcpassword-privileged)|" \
|
||||||
'${cfg.dataDir}/joinmarket.cfg'
|
'${cfg.dataDir}/joinmarket.cfg'
|
||||||
'';
|
'';
|
||||||
# Generating wallets (jmclient/wallet.py) is only supported for mainnet or testnet
|
# Generating wallets (jmclient/wallet.py) is only supported for mainnet or testnet
|
||||||
ExecStartPost = mkIf (bitcoind.network == "mainnet")
|
postStart = mkIf (bitcoind.network == "mainnet") ''
|
||||||
(nbLib.script "joinmarket-create-wallet" ''
|
walletname=wallet.jmdat
|
||||||
walletname=wallet.jmdat
|
wallet=${cfg.dataDir}/wallets/$walletname
|
||||||
wallet=${cfg.dataDir}/wallets/$walletname
|
if [[ ! -f $wallet ]]; then
|
||||||
if [[ ! -f $wallet ]]; then
|
${optionalString (cfg.rpcWalletFile != null) ''
|
||||||
${optionalString (cfg.rpcWalletFile != null) ''
|
echo "Create watch-only wallet ${cfg.rpcWalletFile}"
|
||||||
echo "Create watch-only wallet ${cfg.rpcWalletFile}"
|
${bitcoind.cli}/bin/bitcoin-cli -named createwallet \
|
||||||
${bitcoind.cli}/bin/bitcoin-cli -named createwallet \
|
wallet_name="${cfg.rpcWalletFile}" disable_private_keys=true
|
||||||
wallet_name="${cfg.rpcWalletFile}" \
|
''}
|
||||||
disable_private_keys=true
|
pw=$(cat "${secretsDir}"/jm-wallet-password)
|
||||||
''}
|
cd ${cfg.dataDir}
|
||||||
pw=$(cat "${secretsDir}"/jm-wallet-password)
|
if ! ${nbPkgs.joinmarket}/bin/jm-genwallet --datadir=${cfg.dataDir} $walletname $pw \
|
||||||
cd ${cfg.dataDir}
|
| grep 'recovery_seed' \
|
||||||
if ! ${nbPkgs.joinmarket}/bin/jm-genwallet --datadir=${cfg.dataDir} $walletname $pw \
|
| cut -d ':' -f2 \
|
||||||
| grep 'recovery_seed' \
|
| (umask u=r,go=; cat > jm-wallet-seed); then
|
||||||
| cut -d ':' -f2 \
|
echo "wallet creation failed"
|
||||||
| (umask u=r,go=; cat > jm-wallet-seed); then
|
rm -f "$wallet" jm-wallet-seed
|
||||||
echo "wallet creation failed"
|
exit 1
|
||||||
rm -f "$wallet" jm-wallet-seed
|
fi
|
||||||
exit 1
|
fi
|
||||||
fi
|
'';
|
||||||
fi
|
serviceConfig = nbLib.defaultHardening // {
|
||||||
'');
|
|
||||||
ExecStart = "${nbPkgs.joinmarket}/bin/joinmarketd";
|
ExecStart = "${nbPkgs.joinmarket}/bin/joinmarketd";
|
||||||
WorkingDirectory = cfg.dataDir; # The service creates 'commitmentlist' in the working dir
|
WorkingDirectory = cfg.dataDir; # The service creates 'commitmentlist' in the working dir
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
|
Loading…
Reference in New Issue
Block a user