Repository navigation
fix: open review for requests with an amount #1763
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5399,6 +5399,8 @@ class AppViewModel @Inject constructor( | |
| return | ||
| } | ||
|
|
||
| if (amount > 0u && openOnchainConfirmForInvoiceAmount(amount, fromMainScanner, walletGeneration)) return | ||
|
|
||
| Logger.info( | ||
| when (amount > 0u) { | ||
| true -> "Found amount in invoice, proceeding to edit amount" | ||
|
|
@@ -5410,6 +5412,30 @@ class AppViewModel @Inject constructor( | |
| navigateToSendRoute(fromMainScanner, SendRoute.Amount, SendEffect.NavigateToAmount, walletGeneration) | ||
| } | ||
|
|
||
| /** | ||
| * An on-chain invoice with a payable amount opens on Confirm, as Amount's continue would. | ||
| * Manual coin selection and contact payments keep going through Amount. | ||
| */ | ||
|
Comment on lines
+5415
to
+5418
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: KDoc on a private function
|
||
| private suspend fun openOnchainConfirmForInvoiceAmount( | ||
| amount: ULong, | ||
| fromMainScanner: Boolean, | ||
| walletGeneration: Long?, | ||
| ): Boolean { | ||
| if (_sendUiState.value.payMethod != SendMethod.ONCHAIN || hasActiveContactPaymentContext()) return false | ||
| if (!validateAmount(amount)) return false | ||
| val isHardware = _sendUiState.value.hardwareWalletId != null | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worth doing, does not block: Hardware-wallet direct-Confirm path has no test
|
||
| if (!isHardware && !settingsStore.data.first().coinSelectAuto) return false | ||
| requireCurrentPaymentPreparation(walletGeneration) | ||
| if (isHardware && !prepareHardwareSendFee()) return false | ||
| requireCurrentPaymentPreparation(walletGeneration) | ||
|
|
||
| Logger.info("Found payable amount in invoice, proceeding to confirm", context = TAG) | ||
| _sendUiState.update { it.copy(isAmountInputValid = true, canReturnToAmount = true) } | ||
| navigateToSendRoute(fromMainScanner, SendRoute.Confirm, SendEffect.NavigateToConfirm, walletGeneration) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worth doing, does not block: Tapping the amount on direct Confirm does nothing Open a funded BIP21 request with an amount, then tap the amount on Confirm. Nothing happens: |
||
| refreshOnchainSendIfNeeded(walletGeneration) | ||
| return true | ||
| } | ||
|
|
||
| private suspend fun hardwareMaxSpendable( | ||
| walletId: String, | ||
| address: String, | ||
|
|
@@ -8935,6 +8961,7 @@ data class SendUiState( | |
| val isInitialSubscriptionPayment: Boolean = false, | ||
| val initialSubscriptionPaymentAutoStartPending: Boolean = false, | ||
| val requiresAmountReview: Boolean = false, | ||
| val canReturnToAmount: Boolean = false, | ||
| val initialSubscriptionPaymentNeedsConfirmation: Boolean = false, | ||
| val incomingPaymentRequestId: PaykitPaymentRequestId? = null, | ||
| ) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package to.bitkit.ui.screens.wallets.usdt | ||
|
|
||
| import org.junit.Test | ||
| import kotlin.test.assertFalse | ||
| import kotlin.test.assertTrue | ||
|
|
||
| class UsdtWalletScreenTest { | ||
| private val recipient = "0x1111111111111111111111111111111111111111" | ||
|
|
||
| @Test | ||
| fun `initial payment with recipient and positive amount is quoted`() { | ||
| assertTrue(shouldQuoteInitialUsdtPayment(recipient, "0.010001")) | ||
| assertTrue(shouldQuoteInitialUsdtPayment(recipient, "5")) | ||
| } | ||
|
|
||
| @Test | ||
| fun `initial payment without a payable amount is not quoted`() { | ||
| assertFalse(shouldQuoteInitialUsdtPayment(recipient, "")) | ||
| assertFalse(shouldQuoteInitialUsdtPayment(recipient, "0")) | ||
| assertFalse(shouldQuoteInitialUsdtPayment(recipient, "abc")) | ||
| assertFalse(shouldQuoteInitialUsdtPayment(recipient, "0.0000001")) | ||
| } | ||
|
|
||
| @Test | ||
| fun `initial payment without recipient is not quoted`() { | ||
| assertFalse(shouldQuoteInitialUsdtPayment("", "5")) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Scanning a Bitcoin or USDT payment request that already has an amount now opens the review screen directly instead of the amount screen. |
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.
needs changing before merge: E2E send shard breaks: e2e main still expects Amount for BIP21 with amount
This change makes
@send_1and@send_2onbitkit-e2e-testsmain fail, and nothing lets CI pick up an updated spec. How the E2E workflow behaves: -.github/workflows/e2e.ymlruns on every non-draft PR that touchesapp/**. -default-feature-branchresolves to an e2e branch with the same name as the app branch, and falls back tomainotherwise. -e2e-statusfails when any shard fails. -synonymdev/bitkit-e2e-testshas nofix/scan-amount-to-confirmbranch (gh api repos/synonymdev/bitkit-e2e-tests/branches/fix%2Fscan-amount-to-confirmreturns 404), and the PR body has noCompanion:line. What the specs on e2emainexpect: -send.e2e.ts:157-169(@send_1) entersbitcoin:bcrt1q07x3…?amount=0.0001and tapsAddressContinue. It then callsverifyAmountToSend(10_000)and waits forContinueAmount. -send.e2e.ts:356-366(@send_2 @ios_gate) enters an on-chain 0.0002 BIP21. Its 200 000 sat Lightning invoice is above Spending. It then waits forAssetButton-savingsand tapsContinueAmount. With this PR, both inputs reachopenOnchainConfirmForInvoiceAmount(AppViewModel.kt:5402) and open Confirm instead. The PR's own testsend sheet onchain address with payable amount navigates to confirmasserts exactly that. How I confirmed it: I downloadedsend.e2e.tsfrom e2emainand traced both inputs throughonScanOnchain. I also checked the branch lookup and the workflow's ref resolution. The PR's livesendshard (run 41648112580) had not finished when I checked at 14:40 UTC, so I have not seen the failure itself. The author's Gaps section predicts the same break. Once this merges, thesendshard fails on every later Android PR that touchesapp/**until e2emainis updated. Fix: push the spec update tofix/scan-amount-to-confirmin bitkit-e2e-tests so this PR's E2E run picks it up, link it asCompanion:, and merge the two in lockstep.@send_2is also an iOS gate, so coordinate with the iOS twin too.