Skip to content

fix(send): retry a payment-request preview that was refused for syncing - #1714

Merged
HashEngineering merged 31 commits into
feat/kotlin-sdk-phase-1from
fix/bip70-gate-retry
Nov 24, 2026
Merged

HashEngineering merged 31 commits into
feat/kotlin-sdk-phase-1from
fix/bip70-gate-retry

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

On 12.0.1-beta a scanned payment request failed with L1 funding gate closed: SDK L1 filter scan is still short of the chain tip while the wallet was seconds from the tip, and every further tap on Send showed the same error until the request was scanned again.

Scope. This PR does not change when a send is allowed (the SDK scan must be at the chain tip) and adds no wait anywhere. It only lets a payment-request preview that was refused for syncing be built again. Letting a catch-up through is a separate change, #1721, stacked on this one.

History. Earlier versions of this branch waited up to 30 s for the sync gate, first in every send and then only in the preview. That wait is removed in 7afc44d: it added time in which an invoice could expire or an earlier payment could settle before the build.

What was done?

Path Before Now
Payment request (BIP70) preview refused at once when not synced unchanged: refused at once
Payment request, Send after a refused preview shows the stored refusal every time fetches the request again and builds the preview; shows "not fully synced" if still refused
Gift card (one-step payment request) refused at once, engine text or "contact support" still refused at once; shows the "not fully synced" copy
Plain send, send-all, Maya deposit and max quote, CoinJoin drain and consolidation asked once unchanged

Supporting changes:

  • SendCoinsTaskRunner types a closed funding gate reported by the deferred build as SendEngineNotSyncedException, so the screens can tell it from other failures. The builds' gate messages use the shared L1_FUNDING_GATE_CLOSED_REASON prefix for that.

  • PaymentProtocolViewModel.retryPreview retries only a preview refused as SendEngineNotSyncedException. A rebuilt preview returns to the fee confirmation; nothing is submitted without a new confirmation.

  • That a retry was asked for is kept in the ViewModel, and its refusal is taken only by a resumed screen (from the observer and from onResume), so the dialog is shown after a rotation, including one that happens while the screen is paused.

  • SendEngineNotSyncedException moved to common, so the payment-request screen and the gift card dialog show the same copy as the send screen.

  • An unbound wallet is refused as on the base, and is not offered the retry.

  • A tap on Send submits only the preview it was made on: a tap made on a refused preview can rebuild it, but its PIN result cannot submit the rebuilt payment (9f85f85).

  • A preview that finishes building after the screen closed releases its own reservation (2ab1814). This covers the first build as well as the retry.

  • If the screen closes while the SDK build is still inside the funding lock, the lock exits cancelled and the finished payment never reaches the ViewModel. SdkL1SendService now releases that reservation itself (4d48e8b). The Maya deposit build reserves the same way and uses the same helper.

  • The retry fetches the payment request again (c0cd58c). It runs the path opening the invoice takes: GET, trust check, earlier-payment lookup, build. A failed fetch drops the request the screen held and shows the screen's usual connection error; a changed request is shown and has to be confirmed again. An authentication that answers after such a failed fetch is ignored (54e4f71), and the screen's observers read the request once per update, so a request dropped mid-update cannot crash them (90fcc58).

Known and not addressed:

  • A payee that still serves an invoice after its payment settled: the wallet's record of that payment is removed when it settles, so a retry, like a reopen on the base, finds nothing and can build a second payment. Closing it needs a record of settled invoice payments, which this PR does not add.

An earlier attempt kept the earlier payment in the screen's memory (eeeae79, 5a6d44c, 32a21ff). It is reverted in c0cd58c: the wallet's records cannot tell a reissued order from another order of the same merchant.

How Has This Been Tested?

  • Unit tests: SdkL1SendServiceTest, PaymentProtocolViewModelRetryPreviewTest, PayTapActionTest, SendCoinsTaskRunnerBIP70Test, CutoverSendRouteTest (pass on _testNet3Debug).
  • Local pre-review of the whole range: clean at 7afc44d and at 9f85f85; at 2ab1814 it listed the funding-lock case, fixed in 4d48e8b; clean at 4d48e8b. 0ad0b1b and bedf47b only change that fix's test (a bounded wait, a latch released in a finally). Two rounds on the re-fetch change; the last, at 54e4f71, lists the payee that still serves a paid invoice (above). Clean at 90fcc58.
  • No unit test for the fragment change (the resumed-screen report of a retry refusal).
  • QA run 52 passed the normal round trip (fetch, preview, pay, ack) on a build with bedf47b. The retry was not exercised there, and nothing was run on a device at 90fcc58.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

🤖 Generated with Claude Code

Loading
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.

2 participants