breez / breez-sdk-liquid

MIT License
26 stars 7 forks source link

Consolidate `send_payment` loop with `try_handle_submarine_swap_status` #200

Closed ok300 closed 6 months ago

ok300 commented 6 months ago

The send_payment has its own socket and its own status handling loop.

There is a lot of overlap with BoltzStatusStream for the socket handling, and with try_handle_submarine_swap_status for the state transition handling.

There is also a chance of race conditions with the status stream socket, whereby the new Send swap could be handled by both loops.

We should try to reuse the existing methods.

roeierez commented 6 months ago

That's right. Ideally I IMO the background thread would be the single point of tracking swap statuses and handle them (claim or refund). This thread can emit events for the payment lifecycle (success/fail/refund) which will be handled by the send_payment waiting until some timeout.