Repository navigation
fix: Preserve unknown prevout ownership in receiver sessions - #219
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Security-sensitive ownership decisions and persisted native transitions require human validation against live NBXplorer and Bitcoin Core behavior.
No open issues 🎉
What changed in this PR
Preserves unknown input ownership so receiver sessions wait for reliable wallet evidence before advancing.
Changes:
- Adds three-state ownership resolution and retry-safe receiver transitions.
- Gates Async Payjoin on supported wallet profiles and limits output replacement to the invoice script.
- Expands ownership, replay, checkout, and integration coverage.
| File | Description |
|---|---|
| docs/installation.md | Documents supported wallet requirements. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinWalletOwnershipService.cs | Resolves exact input ownership while preserving unknown results. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinUriSessionService.cs | Checks availability before creating sessions. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinReceiverStateProcessor.cs | Pauses unknown ownership and matches invoice outputs only. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinReceiverSessionGuard.cs | Restores original input outpoints during replay. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinBitcoinCheckoutModelExtension.cs | Gates checkout publication by wallet profile. |
| BTCPayServer.Plugins.Payjoin/Services/PayjoinAvailabilityService.cs | Adds wallet-profile and tracking checks. |
| BTCPayServer.Plugins.Payjoin/Services/IPayjoinReceiverStateProcessor.cs | Removes unused output-ownership context. |
| BTCPayServer.Plugins.Payjoin/Models/PayjoinUnavailableReasons.cs | Adds wallet availability explanations. |
| BTCPayServer.Plugins.Payjoin/Controllers/UIPayjoinOverviewController.cs | Displays profile-aware status and fallback guidance. |
| BTCPayServer.Plugins.Payjoin.Tests/UIPayjoinOverviewControllerTests.cs | Covers profile status and read failures. |
| BTCPayServer.Plugins.Payjoin.Tests/Services/PayjoinWalletOwnershipServiceTests.cs | Tests ownership evidence and unavailable lookups. |
| BTCPayServer.Plugins.Payjoin.Tests/Services/PayjoinReceiverStateProcessorTests.cs | Tests unknown ownership and invoice matching. |
| BTCPayServer.Plugins.Payjoin.Tests/Services/PayjoinReceiverRelayFlowTests.cs | Tests session preservation, retries, and recovery. |
| BTCPayServer.Plugins.Payjoin.Tests/PayjoinCheckoutModelAssemblyTests.cs | Tests profile-aware checkout and session retention. |
| BTCPayServer.Plugins.Payjoin.IntegrationTests/TestUtils/PayjoinTestPayer.cs | Adds proposal hooks and output-substitution controls. |
| BTCPayServer.Plugins.Payjoin.IntegrationTests/PayjoinWalletOwnershipIntegrationTests.cs | Covers missing history, additional outputs, and unsupported profiles. |
Review effort: Balanced
09890cc to
39f987a
Compare
|
Rebased to include the BTCPay dependency fix from #230 |
| { | ||
| internal static PayjoinAvailabilityStatus GetProfileStatus(DerivationSchemeSettings? settings) => | ||
| settings is null ? PayjoinAvailabilityStatus.TemporarilyUnavailable : | ||
| !settings.IsHotWallet || settings.Source != "NBXplorerGenerated" ? PayjoinAvailabilityStatus.MerchantRequirementsUnmet : |
There was a problem hiding this comment.
This turns Async Payjoin off for hot wallets restored from a seed (ImportedSeed/SeedImported), which #193 didn't need. Since ContributedInputSigner only signs our contributed coins, a missed registration can't make us sign a sender input. Could imported hot wallets stay supported, or is there another reason to exclude them?
There was a problem hiding this comment.
Agreed. Fixed: restored hot wallets remain supported under the documented NBXplorer registration requirements. Added a seed-restore regression; signing restrictions and session preservation on Unknown are unchanged.
ad648e6 to
ad4d7a1
Compare
Co-authored-by: ValeraFinebits <50830352+ValeraFinebits@users.noreply.github.com>
627fb1c to
8794e00
Compare
chavic
left a comment
There was a problem hiding this comment.
cACK a3f39be
This now conflicts with master: #231 changed the same line in PayjoinSeenInputConcurrencyIntegrationTests.cs. Keeping master's fixture.Sessions.Owner(winningInvoice) resolves it, and the build is clean.
RecordingSeenInputCallback? winningCallback = null;
- Assert.True(fixture.Sessions.TryGetSession(winningInvoice, out var winningSession));
- var winningOwner = fixture.Sessions.CreatePersister(winningSession!);
- using var next = fixture.SeenInputs.ExecuteSeenInputTransition(winningOwner, (callback, persister) =>
+ using var next = fixture.SeenInputs.ExecuteSeenInputTransition(fixture.Sessions.Owner(winningInvoice), (callback, persister) =>
Resolve Original input ownership from authenticated prevouts and hot-account script registrations instead of relying on derivation-scoped transaction history. Preserve the existing receiver session and retry while ownership is Unknown, before advancing the native ownership check.
Support BTCPay-generated hot accounts used exclusively through one BTCPay/NBXplorer installation with intact address registration. Identify receiver outputs by the invoice script and keep the cold wallet for settlement.
Handle wallet-profile read failures as temporary unavailability in checkout and overview. Add coverage for ownership classification, session recovery, profile failures and ordinary Payjoin.
Fixes #193.
Merge this PR before #218, then rebase #218 onto the updated master and adapt its lookup budgeting, caching and retries to the ownership model introduced here.