Repository navigation
fix: Bound ownership lookups and tune receiver defaults - #218
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive ownership checks now depend on concurrent admission, finite retries, and persisted replay recovery that warrant human validation.
No open issues 🎉
What changed in this PR
Bounds wallet ownership lookups in the Payjoin receiver while preserving sessions when lookups are unavailable.
Changes:
- Combines input and output checks under shared request limits, deadlines, and finite retries.
- Adds bounded lookup state, caching, and session-lifecycle cleanup; increases receiver concurrency to 16.
- Adds coverage for retry limits, concurrency, deletion, and replay recovery.
| File | Description |
|---|---|
| BTCPayServer.Plugins.Payjoin/Services/PayjoinWalletOwnershipService.cs | Combines and bounds ownership checks. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinReceiverStateProcessor.cs | Defers unavailable checks and releases completed lookup state. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinReceiverSessionStore.cs | Validates session generations and cleans up lookup state. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinReceiverSessionProcessor.cs | Raises receiver concurrency to 16. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinReceiverSessionGuard.cs | Restores transaction facts and cleans up completed lookups. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinOwnershipLookupStateStore.cs | Adds admission limits, retry tracking, and bounded caching. |
| BTCPayServer.Plugins.Payjoin/Services/IPayjoinReceiverStateProcessor.cs | Shares transaction facts and the combined resolver. |
| BTCPayServer.Plugins.Payjoin/Plugin.cs | Registers and wires lookup state storage. |
| BTCPayServer.Plugins.Payjoin.Tests/SessionStoreFixture.cs | Supports injecting lookup state into tests. |
| BTCPayServer.Plugins.Payjoin.Tests/Services/PayjoinWalletOwnershipServiceTests.cs | Tests lookup limits, retries, caching, and lifecycle handling. |
| BTCPayServer.Plugins.Payjoin.Tests/Services/PayjoinReceiverRelayFlowTests.cs | Tests deferred ownership and replay recovery. |
| BTCPayServer.Plugins.Payjoin.IntegrationTests/PayjoinWalletOwnershipIntegrationTests.cs | Adapts ownership integration tests to session-aware resolution. |
Review effort: Balanced
00c9c97 to
c5eca42
Compare
|
Rebased to include the BTCPay dependency fix from #230 |
c5eca42 to
a9bdd67
Compare
chavic
left a comment
There was a problem hiding this comment.
Upstream won't add an unavailable transition; a declined reply defined in the spec is planned instead (payjoin/rust-payjoin#2036), so please don't wait on it.
On budget exhaustion, cancel instead of leaving the session in MaybeInputsOwned until expiry. proposal.Cancel() returns ReceiverPendingFallback, whose FallbackTx() is the already-validated Original, and it survives a restart. That needs:
- a separate path for
Exhausted, since the resolver is null for both it andDeferred(deferred lookups should keep retrying) ProcessPendingFallbackAsyncto broadcastFallbackTx()before closing
We can switch to declined once it's specified.
|
Correction to my review: on this branch the Original isn't checked for broadcastability yet. |
a4f93e5 to
cdf826d
Compare
@chavic Implemented persisted |
fcf514b to
10b6eaa
Compare
|
Rebased. |
Share one resolver and budget across input and output ownership checks: 128 SDK operations and a 10-second deadline per pass, up to three passes, and four concurrent ownership passes. Increase receiver workers to 16.
Cache positive results across retries, retain sessions on transient failures, and clean up lookup state when ownership completes or the session is deleted. Prevent deleted session generations from starting ownership passes.
Fixes #192.
Merge this PR after #219