Uh oh!
There was an error while loading. Please reload this page.
fix: harden Paykit request handling - #684
Conversation
Greptile SummaryThis PR hardens incoming Paykit contact-payment handling by isolating malformed receiver markers and validating request amounts against the balance before entering the send flow.
Confidence Score: 5/5The PR appears safe to merge, with the changed preflight checks aligned to the amount ultimately paid and malformed markers safely isolated from valid contacts. Private Paykit endpoints are intentionally amountless, the incoming request amount is injected into payment execution and checked again during confirmation, and valid receiver paths continue through publication while malformed paths remain rejected and logged.
|
| Filename | Overview |
|---|---|
| Bitkit/Services/PrivatePaykitService+Contacts.swift | Stops a malformed receiver marker from becoming the aggregate publication error while retaining logging and processing valid receiver paths. |
| Bitkit/ViewModels/AppViewModel.swift | Uses the incoming request amount for initial Lightning and on-chain affordability checks, matching the amount later injected into payment execution. |
| changelog.d/next/paykit-request-qa.fixed.md | Accurately documents the malformed-marker isolation and insufficient-balance handling fixes. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Incoming Paykit request] --> B[Resolve private amountless endpoint]
B --> C[Decode Lightning, on-chain, or unified target]
C --> D[Read amount from incoming request]
D --> E{Preferred route has sufficient balance?}
E -->|Yes| F[Open shared send flow]
E -->|No, unified request| G{On-chain balance sufficient?}
G -->|Yes| F
G -->|No| H[Show insufficient balance message]
E -->|No, single route| H
F --> I[Inject request amount]
I --> J[Confirm exact request amount]
J --> K[Pay]
Reviews (1): Last reviewed commit: "fix: harden Paykit contact payments" | Re-trigger Greptile
Retested after 97033fe. Enable — still fails. ❌ Toggle Enable payments with contacts → Private Paykit is not available, toggle does not stay on. Same staging contact as the Android QA ( This is not the malformed-marker isolation path. Same surface on Android #1172 (toast there is Unknown error). Steps:
Screen.Recording.2026-08-27.at.10.25.35.-.ios.movbitkit_logs_2026-08-27_08-28-24.zip Over-balance — copy is fixed, toast loops. ❌ Pay on a request larger than the wallet now shows the right message (Insufficient Savings, e.g. ₿ 26,717 more needed) instead of coin selection. On Android that toast fires once. On iOS it keeps coming back. Tapping Pay again then shows The payment request is already being processed. Recording attached.
Steps:
Screen.Recording.2026-08-27.at.11.14.21-os.overbalance.mov |
ben-kaufman
commented
Aug 31, 2026
Fixed both retest findings in 5ba7ee7. Private publication is now enabled before immediate endpoint preparation, with rollback still handled by the existing failure path. An unaffordable request is marked surfaced after the single balance toast, so it remains in the bell/history queue without the 2-second automatic retry loop or already-processing follow-up. The focused iOS suites pass 56/56 tests. |
ovitrif
left a comment
There was a problem hiding this comment.
The unaffordable incoming request path and the malformed-marker isolation both lack tests that would fail if those behaviors regressed.
handleScannedDatanow usesincomingPaymentRequest.amountSatsand the insufficient-balance path marks the request presented so it does not retry. No test drives an unaffordable request through that routing.- A malformed private receiver marker no longer assigns
firstError, so other contacts can still publish. No fixture would fail if that assignment returned.
Inline comments have the specific coverage to add.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
piotr-iohk
commented
Sep 1, 2026
Retested 112fb70. Over-balance: fixed. One insufficient-capacity toast, no retry loop. ✅ Enable: still broken. Five toggles failed with privateUnavailable ❌ Logs never reach inspect/prepare/queue/deliver. 09:46:04 is Also still had pubky8u997gg after deleting pubky1jy146y, so this Need the failing canPublish clause logged, and enable should not Screen.Recording.2026-09-01.at.11.58.31.mov |
112fb70 to
154b3d6Compareben-kaufman
commented
Sep 1, 2026
Fixed the remaining enable failure in 2d90e0e. Private endpoint preparation during enable is now best effort, so temporary wallet, node, app, or Pubky unreadiness defers publication instead of returning privateUnavailable and rolling the toggle back. Real errors after publication starts still fail and restore the previous state. The readiness check now logs the exact unavailable condition. ContactPaymentsServiceTests and PrivatePaykitServiceTests pass 24 of 24. @piotr-iohk please retest the Enable case, and @ovitrif please re-review the updated head. |
Retested latest revision ( Enable still fail-closes. Toggle →
Hypothesis: Android enable stays on after the matching defer change. |
ben-kaufman
commented
Sep 1, 2026
You were right about the remaining fail-closed path. The The regression test covers this exact selection failure, and the focused private/contact/request suites pass 74/74. I also installed this exact head over the saved-contact QA state, enabled Paykit UI, and verified the toggle stayed enabled past 15 seconds with the success toast and no |
This PR hardens incoming Paykit contact-payment handling after QA on the cross-platform payment-request flow.
Description
No Paykit SDK or binding change is required. Companion Android fix: synonymdev/bitkit-android#1172
Linked Issues/Tasks
Screenshot / Video
N/A — this corrects error handling in the existing payment-request flow.
QA Notes
Manual Tests
Automated Checks
PrivatePaykitServiceTests: 15 tests passed on an iPhone 16 simulator.git diff --checkpassed.