From 3b2aa866aab113c1f25612d86b5b35cddce07708 Mon Sep 17 00:00:00 2001 From: DanS Date: Sun, 30 Aug 2026 16:32:20 -0500 Subject: [PATCH] rpc: honor a command-line rpcpassword across restarts; fix dead -rpcusername key hush_configfile(), on any restart where the auto-generated DRAGONX.conf already exists, hard-assigned mapArgs["-rpcpassword"] from the conf and wrote the username to mapArgs["-rpcusername"] -- a key nothing reads (InitRPCAuthentication in httprpc.cpp and bitcoin-cli.cpp both read "-rpcuser"). The hard assignment silently overwrote a -rpcpassword passed on the command line, so after the first run the effective RPC credentials became {cmdline-user}:{conf-password}, matching neither the command-line pair the operator passed nor the full conf pair. Automation or external clients that connect with the known command-line password broke on every restart. Use SoftSetArg for both, so a command-line (or explicitly configured) value wins and the conf-derived credential is only a fallback. Verified on regtest: after a restart an external client with the command-line password gets HTTP 200 and the conf's random password gets 401; the conf-only operator path (no command-line creds) still authenticates. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01PGhWvdBSgt6UxxHANr7gfN --- src/hush_utils.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hush_utils.h b/src/hush_utils.h index 1b1cb2eeb..6241b93ba 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -1383,8 +1383,14 @@ void hush_configfile(char *symbol,uint16_t rpcport) #endif } else { _hush_userpass(myusername,mypassword,fp); - mapArgs["-rpcpassword"] = mypassword; - mapArgs["-rpcusername"] = myusername; + // Feed the credentials read by InitRPCAuthentication (httprpc.cpp) and the + // CLI (bitcoin-cli.cpp) -- both read "-rpcuser"/"-rpcpassword". Use SoftSetArg + // so a value passed on the command line (or an explicit -rpcuser/-rpcpassword) + // still wins: the old direct assignment silently overwrote a command-line + // -rpcpassword on every restart once this conf existed, and the username was + // written to a misspelled "-rpcusername" key that nothing ever reads. + SoftSetArg("-rpcpassword", mypassword); + SoftSetArg("-rpcuser", myusername); fclose(fp); } }