From fcef52adbf0af5e70e2dfa2cb8e8068b6fde4efe Mon Sep 17 00:00:00 2001 From: LORDBABUINO Date: Thu, 5 Mar 2026 14:00:56 -0800 Subject: [PATCH] fix: pass datadir to bitcoin-cli so Python scripts find cookie auth setup.sh starts bitcoind with -datadir=bitcoin-data, but bitcoin_rpc.py was calling bitcoin-cli without it, so it looked in ~/.bitcoin for the auth cookie and failed with "Incorrect rpcuser or rpcpassword". Add datadir config to config.ini and resolve it in _build_base_args(). --- backend/script/bitcoin_rpc.py | 7 +++++++ backend/script/config.ini | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/script/bitcoin_rpc.py b/backend/script/bitcoin_rpc.py index 7a0b328..0e06552 100644 --- a/backend/script/bitcoin_rpc.py +++ b/backend/script/bitcoin_rpc.py @@ -22,6 +22,13 @@ def _build_base_args(section): args = [cli_bin] + # Datadir — resolve relative paths from this file's directory + datadir = section.get("datadir", "").strip() + if datadir: + if not os.path.isabs(datadir): + datadir = os.path.join(os.path.dirname(os.path.abspath(__file__)), datadir) + args.append(f"-datadir={datadir}") + network_flags = { "regtest": "-regtest", "testnet": "-testnet", diff --git a/backend/script/config.ini b/backend/script/config.ini index 7bb6162..f863e5f 100644 --- a/backend/script/config.ini +++ b/backend/script/config.ini @@ -5,8 +5,12 @@ network = regtest # Path to the bitcoin-cli binary (use full path if not on PATH) cli = bitcoin-cli +# Data directory for bitcoind (matches setup.sh). +# Relative paths are resolved from the directory containing this file. +datadir = bitcoin-data + # Optional: override RPC connection details. -# Leave these blank to use the defaults from ~/.bitcoin/bitcoin.conf. +# Leave these blank to use cookie auth from the datadir. rpchost = rpcport = rpcuser =