From 3ebae8807c6aae4b86412931aec5a676d06fbfdd Mon Sep 17 00:00:00 2001 From: 2ro <17595647+2ro@users.noreply.github.com> Date: Sat, 13 Jun 2026 23:15:36 -0400 Subject: [PATCH] Build 59: start the nostr service immediately on wallet open (fix slow connect) The Nym/relay connection could take up to a full SYNC_DELAY (60s) to even start: the nostr service was kicked off deep inside the wallet sync loop, behind the grin node-sync checks and !sync_error, so opening a wallet left the profile on "Connecting..." until the next 60s sync tick (or never, while the node errored). Move the (idempotent) service start to the very top of the loop, right after the open check - independent of node sync - so the connection comes up right away. --- src/wallet/wallet.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/wallet/wallet.rs b/src/wallet/wallet.rs index 9b6a4aa..db4bcf8 100644 --- a/src/wallet/wallet.rs +++ b/src/wallet/wallet.rs @@ -1857,6 +1857,19 @@ fn start_sync(wallet: Wallet) -> Thread { return; } + // Start the nostr payment-messaging service the moment the wallet is + // open — BEFORE (and independent of) the grin node sync. Previously + // this lived deep in the sync body behind `!sync_error` and the node + // checks, so the Nym/relay connection could wait up to a full + // SYNC_DELAY (60s) — or never start while the node errored — leaving + // the profile stuck on "Connecting…". Idempotent. + if let Some(service) = wallet.nostr_service() { + service.start(wallet.clone()); + // Auto-cancel/expire stale pending transactions (frees outputs + // locked by stale sends). + service.expire_stale(&wallet); + } + // Check integrated node state. if wallet.get_current_connection() == ConnectionMethod::Integrated { let not_enabled = !Node::is_running() || Node::is_stopping(); @@ -1900,14 +1913,6 @@ fn start_sync(wallet: Wallet) -> Thread { Err(_) => {} } } - - // Start nostr payment-messaging service (idempotent). - if let Some(service) = wallet.nostr_service() { - service.start(wallet.clone()); - // Auto-cancel/expire transactions left pending past the - // configured window (frees outputs locked by stale sends). - service.expire_stale(&wallet); - } } // Sync wallet from node.