-
Notifications
You must be signed in to change notification settings - Fork 1
fix: fallback expired Bolt 11 to on-chain on unified invoice #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the handling of expired Bolt 11 invoices in unified invoices by implementing a fallback to on-chain payment when the Lightning invoice has expired. It also addresses a navigation bug where the app would incorrectly navigate to the amount screen even when scanning an invalid Bolt 11 invoice without a valid on-chain address.
Changes:
- Added expiration checks for Lightning invoices in unified invoice handling with fallback to on-chain when expired
- Fixed navigation logic to prevent navigation when no valid invoice data exists
- Added expiration validation for standalone Lightning invoices
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Bitkit/ViewModels/AppViewModel.swift | Added expiration checks for Lightning invoices with on-chain fallback logic in unified invoice handling |
| Bitkit/Utilities/PaymentNavigationHelper.swift | Changed return type to optional and added validation to prevent navigation without valid invoice data |
| Bitkit/Views/Wallets/Send/SendEnterManuallyView.swift | Updated to handle optional navigation route from PaymentNavigationHelper |
| Bitkit/Views/Wallets/Send/SendConfirmationView.swift | Added expiration check before processing Lightning payments |
This comment has been minimized.
This comment has been minimized.
ben-kaufman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utAck, changes look good
ovitrif
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested by applying this patch to Android app and then creating an invoice and paying it from iOS:
diff --git a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
index 791204e6..8c39d85c 100644
--- a/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
+++ b/app/src/main/java/to/bitkit/repositories/LightningRepo.kt
@@ -574,7 +574,7 @@ class LightningRepo @Inject constructor(
suspend fun createInvoice(
amountSats: ULong? = null,
description: String,
- expirySeconds: UInt = 86_400u,
+ expirySeconds: UInt = 20u,
): Result<String> = executeWhenNodeRunning("createInvoice") {
updateGeoBlockState()
val invoice = lightningService.receive(amountSats, description, expirySeconds)
pwltr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly good, please check with the react native app for the correct UX for these cases:
- 0 balance -> should show "Insufficient Savings" toast (more relevant)
- 0 spending balance -> fall back to onchain, no toast (or make it type
.infoinstead) - Lightning invoice only -> use title & description for toast: "Decoding Error" "This Lightning invoice has expired"
…ymdev/bitkit-ios into fix/fallback-expired-ln-to-onchain
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Draft to also cover #328 cases |
|
@piotr-iohk we probably need a E2E update |
This comment has been minimized.
This comment has been minimized.
Yes, it's already in place in corresponding e2e branch -> synonymdev/bitkit-e2e-tests#97 |
Description
Linked Issues/Tasks
Fix #300
Fix #328
Screenshot / Video
uniffied-expired-no-amount.mp4
invalid-input.mp4
wrong-network.mp4
fallback-to-sagings.mp4
unsuficcient-spending-failsback-to-onchain.mp4
ln-only-expired-and-insufficient-spending.mp4
expired-insufficient-savings.mp4