Skip to content

fix: validate minimum paykit request amounts - #1457

Merged
ben-kaufman merged 1 commit into
masterfrom
fix/paykit-payment-validation-20261010
Oct 12, 2026
Merged

ben-kaufman merged 1 commit into
masterfrom
fix/paykit-payment-validation-20261010

Conversation

@ben-kaufman

@ben-kaufman ben-kaufman commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes misleading balance feedback for on-chain Paykit requests below 547 sats.

Description

  • Validate the minimum on-chain request amount before balance checks so sufficient funds cannot produce “0 more needed”; close preparation while keeping the unpaid request available for manual retry.
  • Add a shared QA journey so both platforms verify the minimum boundary, retry cleanup, and another payable request.

Out of Scope

  • Paykit SDK: shared-state lease contention, abandoned-write recovery waits, and server reconciliation delays.
  • Wallet networking: Electrum connection and synchronization delays.

Design

N/A — no design available. Reuses the existing minimum-invoice toast.

Preview

QA Notes

Journeys

  • J1 new minimum-onchain-amount.xml — 100 and 546 sats show the 547-sat minimum, preparation closes, unpaid requests remain retryable, and 547 sats reaches confirmation.

Manual Tests

N/A

Automated Checks

  • added AppViewModelSendFlowTest.kt — five regressions cover below-minimum feedback, delayed preparation cleanup and retry, the payable boundary, genuine balance shortfall, and a small valid Lightning alternative.
  • ran a complete base-versus-final lint SARIF comparison — all 1,981 findings match the base; no introduced violations.
  • ran minimum-onchain-amount.xml on an API 36 regtest emulator with a disposable staging issuer — minimum feedback and manual retry verified; a prepared 547-sat confirmation was dismissed without paying.

@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

This PR checks the on-chain minimum before reporting a balance shortfall for incoming Paykit requests.

  • On-chain Paykit requests below 547 sats now show the minimum amount.

No actionable issues were found. Tests were inspected, not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Incoming Paykit request] --> B[Choose payment method]
  B --> C{On-chain and below 547 sats?}
  C -->|Yes| D[Show minimum amount]
  D --> E[Close preparation and keep unpaid request]
  E --> F[Manual retry remains available]
  C -->|No| G[Check available funds]
  G --> H[Confirmation or balance feedback]
Loading

Reviews (1) · Last reviewed commit: "fix: validate minimum paykit request amo..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 43a184e (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. Rejects incoming on-chain Paykit requests of 546 sats or less with the existing Amount Too Low toast before the balance check, so a funded wallet no longer sees "0 more needed". Reviewed 43a184e, light tier (one 11-line change in AppViewModel.onScanOnchain).

What I checked, and 4 candidates I ruled out

Read: the commit's diff, onScanOnchain around the new guard, validateAmount, Env.dustLimit (546), the five new tests in AppViewModelSendFlowTest.kt, the journey and README rows.
CI at review time: lint, detekt, build-local and Greptile green; build and the local e2e shards still running. This review is reasoned from the code and CI; the branch was not built here.

Ruled out

  • Off by one: amount <= dustLimit with dustLimit = 546 rejects 546 and accepts 547, matching the > dustLimit rule in validateAmount and the 547 shown in the toast. The boundary test covers both sides.
  • Rejecting a payable Lightning request: the guard runs only once payMethod is ONCHAIN, after the unified fallback, and small incoming unified request remains payable over Lightning covers that path.
  • Hardware funding source: a hardware wallet forces ONCHAIN and the guard runs before selectHardwareFundingSourceForAmount, so dust never reaches the hardware send path.
  • Request lost or auto-reopening: clearActiveContactPaymentContext(retryIncomingRequest = false) is the same cleanup the shortfall branch uses. The test keeps the request pending and shows that manual Pay retries it while a new 547-sat request still opens.

Merge confidence: 4/5, no findings and the change has tests, but build and e2e had not finished at review time.

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: 👍 Approve

Review: diff 6 files.
Twin: synonymdev/bitkit-ios#913 identical at commit

QA:
Tests queued.


Reviewed by gpt-6.1-sol-high via gh-pr-review-loop skill
Commands: @ovi-reviewer review · test · retest

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: 👍 Approve

Interim test report for the review; the rest resumes on its own.

QA:

🟠 Test J1
Test J1

Incomplete: The lane disconnected during app launch and UI inspection.



Reviewed by gpt-6.1-sol-high via gh-pr-review-loop skill
Commands: @ovi-reviewer review · test · retest

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA review

Scope: Reviewed the full PR diff against its merge base, at 43a184ec.

No new actionable code findings.

Incoming on-chain Paykit requests of 546 sats or less are rejected in onScanOnchain after payment-method selection. That matches validateAmount: Defaults.dustLimit is 546, so 547 sats remains payable. The existing Amount Too Low toast states that minimum, preparation closes, and the request stays in the pending list so Pay can retry it. A funded 547-sat on-chain request still reaches confirmation, and a small unified request that Lightning can pay does not hit this guard. Amounts above the minimum still use the balance-shortfall toast.

Parity with bitkit-ios#913 at 932ed17 matches this boundary. iOS rejects amounts below Env.dustLimit (547) and shows 547. Both platforms share journeys/payment-requests/minimum-onchain-amount.xml and PaymentRequestAmountTooLowToast. Android formats the amount with the active display unit; the journey sets that unit to sats.

Validation: inspected the five new AppViewModelSendFlowTest cases and the journey. Did not run them locally. CI build on this revision completed testDevDebugUnitTest successfully; lint and detekt also passed. Device testing: not performed in this review. The author reports running the new journey on an API 36 regtest emulator and dismissing the 547-sat confirmation without paying.

Ready for device testing.

Suggested additional test cases

  • Android. Payer has a usable Lightning channel and at least 100,000 spendable sats. Issuer sends a new 100-sat unified request with on-chain and Lightning endpoints. Expected: Lightning confirmation opens, and the amount-too-low toast does not appear.

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA tested on Android at 43a184ec using staging regtest and a dedicated fresh wallet/profile.

Device checks passed:

  • 100- and 546-sat on-chain contact requests show the 547-sat minimum feedback and close preparation.
  • Unpaid requests remain retryable; manual retry repeats the minimum feedback.
  • A fresh 547-sat request reaches enabled confirmation; dismissing it creates no payment.
  • An above-minimum 500,000-sat request shows the genuine balance shortfall.
  • Unpaid state survives app restart, and retry still clears preparation correctly.

Manual follow-up by Piotr: 100-sat unified contact payment requests paid successfully over Lightning in both directions (Android → iOS and iOS → Android). This is user-reported testing, without an agent recording.

Deferred Lightning preparation falling back to on-chain below the minimum remains untested on both platforms. No confirmed product defect was found in the tested scope. Approving as explicitly requested by Piotr with that coverage gap disclosed.

@jvsena42 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No finding at 43a184e.

Checked and clean:

  • Validated amount = paid amount. The guard reads incomingPaymentRequest.amountSats, the same value written to sendUiState.amount, and the request amount is fixed on Confirm. The guard only rejects; it never changes what is spent.
  • Boundary. Defaults.dustLimit is 546, the guard rejects amount <= 546, and 547 passes both the guard and validateAmount. The toast value is dustLimit + 1 through USat.
  • Only the on-chain route is rejected. The guard runs after payment-method selection, so a small unified request Lightning can pay still opens confirmation, and a hardware wallet (forced on-chain) is rejected before selectHardwareFundingSourceForAmount.
  • No other way to pay the rejected amount. The request is marked presented, stays in the pending list and can be retried from it, which repeats the guard. The same address opened without the request context lands on the Amount screen, where validateAmount blocks dust. Switching funding source on Confirm recomputes isAmountInputValid and cannot enable Pay for a sub-dust on-chain amount.
  • Cancel and Back. Closing the preparing sheet before the guard cancels the scheduled scan and marks nothing presented. After the guard the sheet, the contact context and the requested id are all cleared, and the next presentation skips this request and opens the following one.
  • Journey. PaymentRequestsBell and PaymentRequestAmountTooLowToast exist at head and the strings match; minimum-onchain-amount.xml is byte-identical to the one in synonymdev/bitkit-ios#913.

CI is green at this head.

Device gate: 43a184e — journeys: 0 driven by me; perf: not relevant; Figma: no screen changed; iOS: same journey file on synonymdev/bitkit-ios#913.
Skipped — already driven this round: minimum-onchain-amount.xml (Android, by @piotr-iohk at 43a184e, passed: 100, 546, 547 and 500,000 sats, manual retry and restart, in the approving review of 2026-10-12)
Skipped — covered by CI at 43a184e: unit tests, lint, detekt, e2e (all green)

@ben-kaufman
ben-kaufman merged commit 0a90927 into master Oct 12, 2026
23 checks passed
@ben-kaufman
ben-kaufman deleted the fix/paykit-payment-validation-20261010 branch October 12, 2026 12:00
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.

4 participants