From 42205cef207d8c1618e16f3ede5d76781a057af0 Mon Sep 17 00:00:00 2001 From: keraliss Date: Sat, 9 May 2026 14:26:54 +0530 Subject: [PATCH 1/2] start maker on creation --- src/api/makers.rs | 17 +++++++++++++---- src/maker_manager/mod.rs | 13 +++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/api/makers.rs b/src/api/makers.rs index 5f86937..02324c9 100644 --- a/src/api/makers.rs +++ b/src/api/makers.rs @@ -208,10 +208,19 @@ async fn create_maker( } match mgr.create_maker(body.id.clone(), config) { - Ok(()) => ( - StatusCode::CREATED, - Json(ApiResponse::ok(MakerInfo { id: body.id })), - ), + Ok(()) => { + if let Err(e) = mgr.start_maker(&body.id) { + tracing::warn!( + "Maker '{}' created but failed to auto-start: {}", + body.id, + e + ); + } + ( + StatusCode::CREATED, + Json(ApiResponse::ok(MakerInfo { id: body.id })), + ) + } Err(e) => ( StatusCode::INTERNAL_SERVER_ERROR, Json(ApiResponse::err(e.to_string())), diff --git a/src/maker_manager/mod.rs b/src/maker_manager/mod.rs index 905547b..bbe9954 100644 --- a/src/maker_manager/mod.rs +++ b/src/maker_manager/mod.rs @@ -145,6 +145,19 @@ impl MakerManager { mgr.persist(); } + // Auto-start all successfully restored makers + let restored_ids: Vec = mgr.configs.keys().cloned().collect(); + for id in restored_ids { + if mgr.pool.contains(&id) { + match mgr.pool.start_server(&id) { + Ok(()) => tracing::info!("Maker '{}' auto-started on dashboard startup", id), + Err(e) => { + tracing::warn!("Maker '{}' restored but failed to auto-start: {}", id, e) + } + } + } + } + Ok(mgr) } From c04b858eafb67e9666d923ae3983f7d78753c82e Mon Sep 17 00:00:00 2001 From: keraliss Date: Mon, 11 May 2026 15:39:14 +0530 Subject: [PATCH 2/2] fix test --- src/api/bitcoind.rs | 37 ++++++++++++++++++++++++++++++++++++- tests/integration_test.rs | 6 +----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/api/bitcoind.rs b/src/api/bitcoind.rs index 63b8675..1336659 100644 --- a/src/api/bitcoind.rs +++ b/src/api/bitcoind.rs @@ -29,6 +29,41 @@ fn probe_rpc(config: &MakerConfig) -> Option { Some(info.chain.to_string()) } +/// Try well-known default RPC ports for regtest and signet. +/// Returns the chain name on the first successful connection, or None if all fail. +fn probe_standard_ports() -> Option { + use coinswap::bitcoind::bitcoincore_rpc::{Auth, Client, RpcApi}; + use std::net::TcpStream; + use std::time::Duration; + + let addresses = [ + "127.0.0.1:18443", // regtest + "127.0.0.1:38332", // signet + ]; + // Localhost-only fallback credentials; not suitable for remote hosts. + let auth_methods = [Auth::UserPass("user".into(), "password".into()), Auth::None]; + + for address in &addresses { + let Ok(socket_addr) = address.parse() else { + continue; + }; + // Fast TCP check to avoid blocking on OS connect timeouts (~30 s) for + // ports that are not listening or behind a packet filter. + if TcpStream::connect_timeout(&socket_addr, Duration::from_millis(300)).is_err() { + continue; + } + let url = format!("http://{}", address); + for auth in auth_methods.clone() { + if let Ok(client) = Client::new(&url, auth) { + if let Ok(info) = client.get_blockchain_info() { + return Some(info.chain.to_string()); + } + } + } + } + None +} + /// Get bitcoind status by probing RPC connectivity via any registered maker's config. /// Falls back to the dashboard-managed process state if no makers are configured. #[utoipa::path( @@ -56,7 +91,7 @@ async fn get_status(State(state): State) -> Json