Repository navigation
fix: Add Mailroom manager logic to more closely match reference - #194
Conversation
6df8980 to
4179fc7
Compare
The btcpay plugin was not properly rejecting ohttp-relays when a call out resulted in a transient error meaning that if some error occured, in this case selecting the same server for mailroom and relay instead of dropping the relay for the remainder of the seession it just kept retrying. This adds the appropriate logic to drop the relay allowing a new relay to be selected avoiding the problems of that particular relay for the session.
4179fc7 to
1e2da17
Compare
|
I am also working now to merge payjoin/rust-payjoin#1696 and some subsequent commits to fully bring the mailroom management logic into the core library so it may not be necessary for long. But as it stands now this is a bug in prod for this plugin. |
|
@benalleng Thanks for putting this together. I tested the receiver polling flow and found a few cases that still need attention: the same-instance rejection currently removes the session before another relay can be tried, downstream wallet errors can mark a healthy relay as failed, and temporary network failures can leave the session unable to retry after recovery. |
There was a problem hiding this comment.
🟡 Changes recommended
Session-specific relay failures expire after ten minutes instead of remaining blocked for the session lifetime.
1 open finding
What changed in this PR
Adds session-aware OHTTP relay quarantine and failover to prevent repeated polling through an incompatible relay.
Changes:
- Distinguishes session-specific HTTP/protocol failures from global transport failures.
- Adds relay quarantine lifecycle management and HTTP status validation.
- Adds extensive unit and end-to-end relay-flow coverage.
| File | Description |
|---|---|
PayjoinReceiverStateProcessor.cs |
Quarantines relays after transient protocol failures. |
PayjoinReceiverSessionStore.cs |
Clears quarantine when sessions are removed. |
PayjoinReceiverSessionProcessor.cs |
Documents deferred storage recovery. |
PayjoinReceiverRelayRequestSender.cs |
Adds session-aware selection and failure classification. |
PayjoinReceiverRelayClient.cs |
Validates HTTP status before reading bodies. |
PayjoinReceiverProposalFinalizer.cs |
Documents deferred POST recovery. |
PayjoinMailroomManager.cs |
Implements session relay quarantine and injectable time. |
Plugin.cs |
Injects the mailroom manager into session storage. |
PayjoinReceiverStateProcessorTests.cs |
Tests truncated poll-response handling. |
PayjoinReceiverRelayRequestSenderTests.cs |
Tests quarantine scope, expiry, and cancellation. |
PayjoinReceiverRelayFlowTests.cs |
Adds full receiver relay-flow scenarios. |
PayjoinReceiverRelayClientTests.cs |
Tests status validation and body timeouts. |
PayjoinMailroomManagerTests.cs |
Tests session quarantine behavior. |
PayjoinReceiverSessionStoreRelationalTests.cs |
Tests quarantine cleanup after deletion. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@benalleng Thanks for catching this and providing the initial fix! I’ve prepared a follow-up based on your changes. |

The btcpay plugin was not properly rejecting ohttp-relays when a call out resulted in a transient error meaning that if some error occured, in this case selecting the same server for mailroom and relay instead of dropping the relay for the remainder of the seession it just kept retrying. This adds the appropriate logic to drop the relay allowing a new relay to be selected avoiding the problems of that particular relay for the session.
This is pretty critical logic as it prevents errors that WILL occur whenever a relay and directory are chosen as the same server. depending on the server defaults chosen this could be a pretty high % of all sessions
Here was the error my directory saw.
and the implementation just saw this. but really any error should just drop a relay for a session and move on.
This was quickly vibed together but I wanted to post it this way rather than an issue as a demonstration of the problem + a possible fix. Feel free to close this in favor of a better fix or push additional changes to clean this up.