fix(bitcoin): support electrs 0.12.0 (drop --daemon-p2p-addr, enable bitcoind rest=1)

- Ensure bitcoind enables rest=1 and electrs.service omits the removed
  --daemon-p2p-addr flag even before Sovran_Bitcoin flake input is re-locked.
- Clean up pre-0.12.0 (FixedPrefix.8) RocksDB directories in electrs
  preStart so bindex 0.12.0 reindexes cleanly.
This commit is contained in:
Sovran Systems authored and naturallaw77 committed 2026-10-18 16:47:36 -05:00
1 parent 8fd0318083
commit 497ac49cfd
1 file changed
+32 -3
+32 -3
View File
@@ -12,7 +12,7 @@
# 3. Applies OS-specific overrides (Second_Drive paths, operator "free", # 3. Applies OS-specific overrides (Second_Drive paths, operator "free",
# forced wallet enable, Hub firewall port, domain requirements) # forced wallet enable, Hub firewall port, domain requirements)
# 4. Wires the Sovran Hub's NWC environment to the Alby Hub service # 4. Wires the Sovran Hub's NWC environment to the Alby Hub service
{ config, pkgs, lib, ... }: { config, pkgs, lib, options, ... }:
let let
cfg = config.sovran_systemsOS; cfg = config.sovran_systemsOS;
@@ -59,6 +59,8 @@ in {
dataDir = "/run/media/Second_Drive/BTCEcoandBackup/Bitcoin_Node"; dataDir = "/run/media/Second_Drive/BTCEcoandBackup/Bitcoin_Node";
# The OS always enables the bitcoind wallet — the Hub and BTCPay need it. # The OS always enables the bitcoind wallet — the Hub and BTCPay need it.
disablewallet = lib.mkForce false; disablewallet = lib.mkForce false;
# electrs 0.12.0 (bindex) requires bitcoind's REST interface (rest=1).
extraConfig = lib.optionalString (!(options.services.bitcoind ? rest)) "rest=1";
}; };
services.electrs = lib.mkIf cfg.services.bitcoin { services.electrs = lib.mkIf cfg.services.bitcoin {
@@ -72,11 +74,38 @@ in {
serviceConfig.PrivateUsers = lib.mkForce false; serviceConfig.PrivateUsers = lib.mkForce false;
}; };
systemd.services.electrs = lib.mkIf cfg.services.bitcoin { systemd.services.electrs = lib.mkIf cfg.services.bitcoin (
let
bitcoind = config.services.bitcoind;
electrsCfg = config.services.electrs;
nbLib = config.nix-bitcoin.lib;
in {
requires = lib.mkForce [ "run-media-Second_Drive.mount" ]; requires = lib.mkForce [ "run-media-Second_Drive.mount" ];
after = [ "run-media-Second_Drive.mount" "bitcoind.service" ]; after = [ "run-media-Second_Drive.mount" "bitcoind.service" ];
wants = [ "bitcoind.service" ]; wants = [ "bitcoind.service" ];
}; } // lib.optionalAttrs (!(options.services.bitcoind ? rest)) {
# Fallback when locked against Sovran_Bitcoin <= 1.1.1:
# electrs 0.12.0 removed --daemon-p2p-addr and switched to bindex (format v1).
preStart = lib.mkAfter ''
dbNetDir='${electrsCfg.dataDir}/${bitcoind.makeNetworkName "bitcoin" "regtest"}'
if [[ -d "$dbNetDir" ]] && grep -q 'prefix_extractor=rocksdb\.FixedPrefix\.8' "$dbNetDir"/OPTIONS-* 2>/dev/null; then
echo "electrs: removing pre-0.12.0 database at $dbNetDir for bindex 0.12.0 reindex"
rm -rf "$dbNetDir"
fi
'';
serviceConfig.ExecStart = lib.mkForce ''
${pkgs.electrs}/bin/electrs \
--log-filters=INFO \
--network=${bitcoind.makeNetworkName "bitcoin" "regtest"} \
--db-dir='${electrsCfg.dataDir}' \
--daemon-dir='${bitcoind.dataDir}' \
--electrum-rpc-addr=${electrsCfg.address}:${toString electrsCfg.port} \
--monitoring-addr=${electrsCfg.address}:${toString electrsCfg.monitoringPort} \
--daemon-rpc-addr=${nbLib.addressWithPort bitcoind.rpc.address bitcoind.rpc.port} \
${electrsCfg.extraArgs}
'';
}
);
systemd.services.lnd = lib.mkIf cfg.services.bitcoin { systemd.services.lnd = lib.mkIf cfg.services.bitcoin {
wants = [ "bitcoind.service" ]; wants = [ "bitcoind.service" ];