From 34501db5fb625a19103b7be15113ced14308e714 Mon Sep 17 00:00:00 2001 From: LORDBABUINO Date: Tue, 26 May 2026 14:01:18 -0300 Subject: [PATCH] fix(api): also read rpc credentials from network-specific bitcoin.conf sections --- api/src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/api/src/main.rs b/api/src/main.rs index b744f2f..124c6a9 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -167,8 +167,14 @@ fn cookie_candidates(bitcoin_dir: &Path, port: u16) -> Vec { fn read_bitcoin_conf_credentials() -> Option<(String, String)> { let conf = Ini::load_from_file("bitcoin.conf").ok()?; - let section = conf.general_section(); - let user = section.get("rpcuser")?; - let pass = section.get("rpcpassword")?; - Some((user.to_owned(), pass.to_owned())) + let try_section = |props: &ini::Properties| -> Option<(String, String)> { + let user = props.get("rpcuser")?; + let pass = props.get("rpcpassword")?; + Some((user.to_owned(), pass.to_owned())) + }; + try_section(conf.general_section()) + .or_else(|| conf.section(Some("regtest")).and_then(try_section)) + .or_else(|| conf.section(Some("test")).and_then(try_section)) + .or_else(|| conf.section(Some("signet")).and_then(try_section)) + .or_else(|| conf.section(Some("main")).and_then(try_section)) }