Skip to content

Persist payjoin receiver sessions across restarts#6

Draft
chavic wants to merge 2 commits intoValeraFinebits:masterfrom
chavic:chavic/persist-receiver-sessions
Draft

Persist payjoin receiver sessions across restarts#6
chavic wants to merge 2 commits intoValeraFinebits:masterfrom
chavic:chavic/persist-receiver-sessions

Conversation

@chavic
Copy link
Copy Markdown
Collaborator

@chavic chavic commented Apr 12, 2026

Summary

This makes Payjoin receiver-session state durable enough for milestone one so active negotiations can survive a BTCPay restart and replay deterministically enough to keep progressing.

What changed

  • add plugin-owned ReceiverSessions and ReceiverSessionEvents persistence tables plus the EF migration
  • replace the in-memory receiver session store with a database-backed replay store
  • persist the contributed receiver input metadata needed to resume replay beyond WantsInputs
  • persist close-request and invoice-status lifecycle metadata instead of keeping it only in process memory
  • start plugin migrations before the poller and lifecycle hosted services so recovery runs against migrated tables

Why

The previous implementation kept receiver negotiations in memory. A restart lost active session state and made recovery non-deterministic, which is below the milestone-one durability bar.

Impact

  • active Payjoin negotiations can be reloaded from the plugin database after restart
  • the Payjoin URI path can create or reuse stable session state instead of rebuilding it only in memory
  • cleanup removes both session metadata and the ordered event log, keeping lifecycle handling restart-safe

Validation

  • reviewed the persistence and replay path changes end to end in the plugin diff
  • attempted dotnet build BTCPayServer.Plugins.Payjoin/BTCPayServer.Plugins.Payjoin.csproj -p:NuGetAudit=false
  • build verification could not complete in this checkout because the referenced BTCPayServer project tree was missing (btcpayserver/BTCPayServer/BTCPayServer.csproj)

Follow-up

A full checkout still needs:

  • a restart scenario where an active receiver negotiation resumes through replay

chavic added 2 commits April 12, 2026 12:18
- add durable receiver session and event entities plus EF migration
- replace the in-memory session store with a database-backed replay store
- persist contributed receiver input metadata for restart-time replay
- start plugin migrations before background session processing
@chavic chavic force-pushed the chavic/persist-receiver-sessions branch from 55a99ed to 05b232e Compare April 12, 2026 11:58
@chavic chavic marked this pull request as draft April 12, 2026 16:59
@ValeraFinebits ValeraFinebits requested review from ValeraFinebits and removed request for ValeraFinebits April 13, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant