swapserver_gui: announce over nostr immediately on start - #1
Merged
Merged
Conversation
run_nostr_server only emits its first announcement after OFFER_UPDATE_INTERVAL_SEC (~10 min) when liquidity is unchanged, so a freshly-started server is undiscoverable by takers for that window (they see "no swap providers found"). Add publish_now(), a non-blocking helper that spins up a short-lived NostrTransport with the server's nostr keypair, waits until there is liquidity to advertise, publishes a single offer, and tears the transport down. It is called at the end of start_server() so the offer is live within seconds of the server coming up, and is also usable as an explicit "announce now" action. Add PublishNowTests covering immediate announce, waiting for liquidity, and the no-op paths (server stopped / no nostr keypair). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A freshly-started swap server is undiscoverable over nostr for up to ~10 minutes,
so takers hit "no swap providers found" right after the server comes up.
SwapManager.run_nostr_serveronly emits its first announcement afterOFFER_UPDATE_INTERVAL_SEC(~10 min) when liquidity hasn't changed since the loopstarted, and it keeps its
NostrTransportprivate, so nothing can trigger anearlier publish.
Fix
Add
publish_now()to the plugin: a non-blocking helper (safe to call from the QtGUI thread) that spins up a short-lived
NostrTransportwith the server's nostrkeypair — the same pattern the client uses in
get_submarine_swap_providers—waits until there is liquidity to advertise, publishes a single offer, and tears
the transport down.
It is called at the end of
start_server()so the offer is live within seconds ofthe server starting (instead of up to ~10 min later). It doubles as an explicit
"announce now" hook.
stop_server()cancels it.The liquidity wait matters because a server can start before its channels are
funded;
publish_offerrefuses to announce with no liquidity, so we pollserver_update_pairs(bounded) until there is some, then announce immediately.Tests
PublishNowTestscovers:start_server()announces immediately once liquidity is present,All plugin tests pass (
python3 -m pytest tests/test_swapserver_gui.py).