fix: await ln payment before gift card confetti#929
Conversation
|
Looking for a reliable way to reproduce it |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25dd0c6052
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
|
Tested the gift false-positive failure path on regtest. ✅ Setup:
Observed:
After removing the firewall rule, the delayed payment arrived, which confirms the test blocked settlement long enough to exercise the timeout path. Also regression tested:
|
This PR:
Description
1. False-positive confetti
BlocktankRepo.claimGiftCodeWithLiquiditypreviously returned success as soon as Blocktank'sgiftPayHTTP RPC returned — but that response only confirms the LSP accepted the request, not that the LN payment actually landed. If Blocktank's background payer subsequently failed to route the HTLC, Bitkit still played confetti and surfaced a "received" sheet with the requested amount, while no incoming payment ever arrived.The repo now subscribes to
LightningRepo.nodeEventsfor theEvent.PaymentReceivedmatching the freshly-created invoice's payment hash before triggeringgiftPay, then awaits that event with a 45 second timeout. On timeout it throwsServiceError.GiftClaimPaymentNotReceived, which the existing error handler inGiftViewModelroutes to the standardGiftRoute.Errorscreen. The success result reports the actual received sat amount instead of the requested amount.The without-liquidity path (channel open +
openChannel) is unchanged — that path already blocks on the funding transaction.2. Intent re-delivery on Activity recreate
When the app language is changed, Android destroys and recreates the Activity, re-delivering the original launching intent.
MainActivity.onCreatewas unconditionally callinghandleDeeplinkIntent(intent), so any deeplink-driven flow (gift sheet, send sheet, pubky auth, etc.) re-fired on the locale switch.onCreatenow only processes the launching intent on a fresh start (savedInstanceState == null). New deeplinks that arrive while the app is running are still handled viaonNewIntent.Preview
N/A
QA Notes
Reproducing the failure path
The originally-reported
gUCdzXfm12V71xztGzDoiQ-3000is now exhausted and returnsGIFT_CODE_USED_UP(a separate, already-handled path), so it can no longer reproduce the false-positive. To exercise case 1, use one of:giftPayreturns success butEvent.PaymentReceivednever fires.Regtest helpers
Fire the gift deeplink directly without scanning a QR (replace the package id per flavor —
to.bitkit.devfor dev/regtest,to.bitkit.tnetfor testnet,to.bitkitfor mainnet):adb shell am start -a android.intent.action.VIEW -d "bitkit://gift-gUCdzXfm12V71xztGzDoiQ-3000" to.bitkit.dev