Skip to content

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Sep 18, 2025

Description

Implement deeplink handling

Preview

zero_amount.mp4
with_amount.mp4
only_lightning.mp4
not_initialized_zero_amount.mp4
not_initialized_with_amount.mp4
no_wallet.mp4
Screen_recording_20250918_141851.webm
Screen_recording_20250918_142616.webm
Screen_recording_20250918_142641.webm

QA Notes

Scan a qr code or clink in a URI with the scheme:

  • Wallet not created > should skip decoding
  • bitcoin > send flow
  • lightning > lightning send flow
  • Node not running > scan invoice with amount > display syncing screen
  • Node not running > scan invoice with zero amount > display syncing screen
  • lnurl > LNURL payment flow
  • lnurlw > LNURL withdraw flow
  • lnurlc > LNURL channel flow
  • lnurlp > LNURL payment flow

@jvsena42 jvsena42 self-assigned this Sep 18, 2025
@jvsena42 jvsena42 requested a review from Copilot September 18, 2025 12:59
Copy link
Contributor

Copilot AI left a 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 implements deeplink handling functionality for the Bitcoin wallet app, allowing users to initiate payments and other actions through external links and QR codes. The implementation includes support for various schemes including bitcoin, lightning, and LNURL protocols.

  • Adds deeplink intent handling in the main activity for both app launch and new intents
  • Integrates deeplink processing with existing scan/payment flow via the AppViewModel
  • Updates the send confirmation screen to display node syncing state when the Lightning node is not running

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
app/src/main/AndroidManifest.xml Adds intent filters for deeplinks, universal links, and NFC support with various Bitcoin/Lightning schemes
app/src/main/java/to/bitkit/ui/MainActivity.kt Integrates deeplink handling in onCreate and onNewIntent methods
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt Implements deeplink processing logic and extracts screen transition delay constant
app/src/main/java/to/bitkit/ui/sheets/SendSheet.kt Passes node running state to the send confirmation screen
app/src/main/java/to/bitkit/ui/screens/wallets/send/SendConfirmScreen.kt Conditionally displays sync view when node is not running and refactors content layout

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jvsena42 jvsena42 marked this pull request as ready for review September 18, 2025 14:54
@jvsena42
Copy link
Member Author

jvsena42 commented Sep 18, 2025

Still trying to setup LNURL server

@jvsena42 jvsena42 requested a review from ovitrif September 18, 2025 14:57
@jvsena42
Copy link
Member Author

doesn't recognize lnurl schemes

Screen_recording_20250918_135353.webm
2025-09-18 13:54:58.805  7179-7237  APP                     to.bitkit.dev                        E  ERROR❌️: Failed to decode scan data: 'lnurl:lnurl1dp68gup69uhnzwfj9ccnvwpwxyuzuvfc8genqvps9amkjargv3exzacnu333s' [InvalidAddress=''] - AppViewModel [AppViewModel.kt:497]
                                                                                                    com.synonym.bitkitcore.DecodingException$InvalidAddress: 
2025-09-18 13:55:13.448  7179-7225  APP                     to.bitkit.dev                        E  ERROR❌️: Failed to decode scan data: 'lnurlw:lnurl1dp68gup69uhnzwfj9ccnvwpwxyuzuvfc8genqvps9amkjargv3exzacnu333s' [InvalidAddress=''] - AppViewModel [AppViewModel.kt:497]

@jvsena42 jvsena42 marked this pull request as draft September 18, 2025 17:55
@jvsena42
Copy link
Member Author

drafted to check E2E tests

@jvsena42 jvsena42 marked this pull request as ready for review September 22, 2025 10:54
@jvsena42 jvsena42 enabled auto-merge September 22, 2025 13:51
@ovitrif
Copy link
Collaborator

ovitrif commented Sep 22, 2025

@jvsena42 Can I review this?
If yes, please merge again with master 🙏🏻 :

@jvsena42
Copy link
Member Author

Can I review this?

Yes, updating...

Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

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

LGTM & works

Tested on Pixel phone with adb:

adb shell am start -W -a android.intent.action.VIEW -d  "<deeplink>" to.bitkit.dev

Comment on lines +1508 to +1523
private fun processDeeplink(uri: Uri) = viewModelScope.launch {
if (!walletRepo.walletExists()) return@launch

val data = uri.toString()
delay(SCREEN_TRANSITION_DELAY_MS)
handleScan(data.removeLightningSchemes())
}

// Todo Temporaary fix while these schemes can't be decoded
private fun String.removeLightningSchemes(): String {
return this
.replace("lnurl:", "")
.replace("lnurlw:", "")
.replace("lnurlc:", "")
.replace("lnurlp:", "")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: don't really need a separate processDeeplink and removeLightningSchemes functions, would've been ok all in one, probably a bit less code in this class which is already having too many lines of code 🙈

Copy link
Member Author

@jvsena42 jvsena42 Sep 22, 2025

Choose a reason for hiding this comment

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

I implemented it like this because removeLightningSchemes should be removed in the future

private const val TEN_USD = 10
private const val MAX_BALANCE_FRACTION = 0.5
private const val MAX_FEE_AMOUNT_RATIO = 0.5
private const val SCREEN_TRANSITION_DELAY_MS = 300L
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: already having this constant defined in TRANSITION_SCREEN_MS:

const val TRANSITION_SCREEN_MS = AnimationConstants.DefaultDurationMillis.toLong() // 300ms

Copy link
Member Author

@jvsena42 jvsena42 Sep 22, 2025

Choose a reason for hiding this comment

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

Thanks, I'll update in #406

@jvsena42 jvsena42 merged commit 05d12bb into master Sep 22, 2025
7 of 8 checks passed
@jvsena42 jvsena42 deleted the feat/deeplinks branch September 22, 2025 15:10
@jvsena42 jvsena42 mentioned this pull request Sep 22, 2025
2 tasks
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.

3 participants