From 24113ac456b3f33768c874bc9de12de397ab5579 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 17:28:21 +0100 Subject: [PATCH 01/10] fix: transfer banner opens transfer progress --- .../java/to/bitkit/repositories/SparkRepo.kt | 3 +++ app/src/main/java/to/bitkit/ui/ContentView.kt | 15 ++++++++---- .../screens/transfer/SparkFundingViewModel.kt | 10 ++++++++ .../bitkit/ui/screens/wallets/HomeScreen.kt | 13 ++++++++++- .../test/java/to/bitkit/ui/ContentViewTest.kt | 14 +++++++++++ .../transfer/SparkFundingViewModelTest.kt | 23 +++++++++++++++++++ .../transfer-banner-opens-progress.xml | 22 ++++++++++++++++++ 7 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 journeys/transfer/transfer-banner-opens-progress.xml diff --git a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt index 47ceeaa971..713c1371ec 100644 --- a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt +++ b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt @@ -2011,6 +2011,9 @@ data class SparkState( /** The [spendingSats] shown in Spending, which [keptBalanceSats] stands in for. */ val shownSpendingSats: ULong get() = if (isExiting) 0uL else shownBalanceSats + + /** The deposit whose progress the transfer banner opens: the first one Spark has not claimed yet. */ + val inProgressDepositTxid: String? get() = deposits.firstOrNull { !it.isClaimed }?.txid } object SparkFees { diff --git a/app/src/main/java/to/bitkit/ui/ContentView.kt b/app/src/main/java/to/bitkit/ui/ContentView.kt index e3899f6cb4..0c32da832e 100644 --- a/app/src/main/java/to/bitkit/ui/ContentView.kt +++ b/app/src/main/java/to/bitkit/ui/ContentView.kt @@ -1211,7 +1211,7 @@ private fun RootNavHost( SpendingHwSignedScreen( viewModel = hiltViewModel(parentEntry), onContinue = { - navController.navigateTo(Routes.SettingUp) { + navController.navigateTo(Routes.SettingUp()) { popUpTo { inclusive = true } } }, @@ -1242,9 +1242,12 @@ private fun RootNavHost( } composableWithDefaultTransitions { val parentEntry = remember(it) { navController.getBackStackEntry(Routes.SparkFundingNav) } + val viewModel = hiltViewModel(parentEntry) + val txid = it.toRoute().txid + LaunchedEffect(txid) { txid?.let(viewModel::showDeposit) } BackHandler { navController.navigateToHome() } SettingUpScreen( - viewModel = hiltViewModel(parentEntry), + viewModel = viewModel, onContinueClick = { navController.navigateToHome() }, ) } @@ -2460,10 +2463,13 @@ internal fun transferSpendingStartRoute(hasSeenSpendingIntro: Boolean, walletId: } /** Shows the transfer's progress in place of its confirm screen, so going back cannot swipe it again. */ -fun NavController.navigateToSettingUp() = navigateTo(Routes.SettingUp) { +fun NavController.navigateToSettingUp() = navigateTo(Routes.SettingUp()) { popUpTo { inclusive = true } } +/** Opens the progress of the deposit in [txid], as the transfer banner on Home does. */ +fun NavController.navigateToTransferProgress(txid: String) = navigateTo(Routes.SettingUp(txid)) + fun NavController.navToActivityDetail(activity: Activity) = navigateTo( Routes.ActivityDetail( id = activity.rawId(), @@ -2727,8 +2733,9 @@ sealed interface Routes { @Serializable data object TransferLearnMore : Routes.InternalOnly + /** The transfer's progress; [txid] names the deposit to show when the screen opens outside the transfer flow. */ @Serializable - data object SettingUp : Routes.InternalOnly + data class SettingUp(val txid: String? = null) : Routes.InternalOnly @Serializable data class ExternalConnection(val scannedNodeUri: String? = null) : Routes.DeepLinkable diff --git a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt index e6404b800b..79d328ffc5 100644 --- a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt +++ b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt @@ -112,6 +112,16 @@ class SparkFundingViewModel @Inject constructor( } } + /** + * Shows the progress of the deposit in [txid], as when the transfer banner opens it. A deposit no claim is followed + * for, as after a relaunch, is added by Spark at 3 confirmations. + */ + fun showDeposit(txid: String) { + _uiState.update { + it.copy(txid = txid, claim = sparkRepo.depositClaims.value[txid] ?: SparkDepositClaim.Later) + } + } + /** Sends from the hardware wallet [walletId] instead of Savings. */ fun useHardwareWallet(walletId: String) { if (_uiState.value.hwWalletId == walletId) return diff --git a/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt b/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt index 18d3fb6708..4b49df3924 100644 --- a/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt @@ -168,6 +168,7 @@ import to.bitkit.ui.navigateToAllActivity import to.bitkit.ui.navigateToProfile import to.bitkit.ui.navigateToTransferFunding import to.bitkit.ui.navigateToTransferIntro +import to.bitkit.ui.navigateToTransferProgress import to.bitkit.ui.scaffold.AppAlertDialog import to.bitkit.ui.screens.wallets.activity.components.ActivityListSimple import to.bitkit.ui.screens.wallets.activity.utils.previewActivityItems @@ -406,6 +407,9 @@ fun HomeScreen( }, onNavigateToSavings = { walletNavController.navigate(Routes.Savings) }, onNavigateToSpending = { walletNavController.navigate(Routes.Spending) }, + onTransferBannerClick = sparkState.inProgressDepositTxid?.let { txid -> + { rootNavController.navigateToTransferProgress(txid) } + }, onClickHardwareWallet = { walletNavController.navigateTo(Routes.HardwareWallet(it)) }, onClickUsdt = { walletNavController.navigateTo(Routes.UsdtWallet) }, onCalculatorInputActiveChanged = onCalculatorInputActiveChanged, @@ -446,6 +450,7 @@ private fun Content( onNavigateToActivityItem: (Activity) -> Unit = {}, onNavigateToSavings: () -> Unit = {}, onNavigateToSpending: () -> Unit = {}, + onTransferBannerClick: (() -> Unit)? = null, onClickHardwareWallet: (String) -> Unit = {}, onClickUsdt: () -> Unit = {}, onCalculatorInputActiveChanged: (Boolean) -> Unit = {}, @@ -583,6 +588,7 @@ private fun Content( onNavigateToActivityItem = onNavigateToActivityItem, onNavigateToSavings = onNavigateToSavings, onNavigateToSpending = onNavigateToSpending, + onTransferBannerClick = onTransferBannerClick, onClickHardwareWallet = onClickHardwareWallet, onClickUsdt = onClickUsdt, ) @@ -634,6 +640,7 @@ private fun WalletPage( onNavigateToActivityItem: (Activity) -> Unit, onNavigateToSavings: () -> Unit, onNavigateToSpending: () -> Unit, + onTransferBannerClick: (() -> Unit)?, onClickHardwareWallet: (String) -> Unit, onClickUsdt: () -> Unit, ) { @@ -708,11 +715,15 @@ private fun WalletPage( .padding(bottom = 16.dp) ) { homeUiState.banners.forEach { banner -> + val isSpending = banner.type == ActivityBannerType.SPENDING ActivityBanner( gradientColor = banner.type.color, title = banner.title, icon = banner.type.icon, - modifier = Modifier.fillMaxWidth() + onClick = onTransferBannerClick.takeIf { isSpending }, + modifier = Modifier + .fillMaxWidth() + .testTag(if (isSpending) "ActivityBanner" else "ActivityBannerSavings") ) } } diff --git a/app/src/test/java/to/bitkit/ui/ContentViewTest.kt b/app/src/test/java/to/bitkit/ui/ContentViewTest.kt index 079b6637d6..e60335a4cf 100644 --- a/app/src/test/java/to/bitkit/ui/ContentViewTest.kt +++ b/app/src/test/java/to/bitkit/ui/ContentViewTest.kt @@ -7,6 +7,7 @@ import androidx.navigation.compose.ComposeNavigator import androidx.navigation.compose.composable import androidx.navigation.createGraph import androidx.navigation.navigation +import androidx.navigation.toRoute import androidx.test.core.app.ApplicationProvider import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow @@ -309,6 +310,19 @@ class ContentViewTest { assertTrue(navController.currentDestination?.hasRoute() == true) } + @Test + fun `transfer banner opens the deposit's progress and back returns home`() { + val navController = transferNavController() + + navController.navigateToTransferProgress("txid") + val entry = navController.currentBackStackEntry!! + assertTrue(entry.destination.hasRoute()) + assertEquals("txid", entry.toRoute().txid) + + navController.popBackStack() + assertTrue(navController.currentDestination?.hasRoute() == true) + } + private fun transferNavController(): NavHostController = NavHostController(ApplicationProvider.getApplicationContext()).apply { navigatorProvider.addNavigator(ComposeNavigator()) diff --git a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt index 7fad969d84..0f2bfb708a 100644 --- a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt +++ b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt @@ -319,6 +319,29 @@ class SparkFundingViewModelTest : BaseUnitTest() { assertTrue(sut.uiState.value.claim == SparkDepositClaim.Later) } + @Test + fun `the transfer banner opens the followed deposit at its claim step`() = test { + whenever(sparkRepo.depositClaims).thenReturn(MutableStateFlow(mapOf("txid" to SparkDepositClaim.Adding))) + val sut = createSut() + advanceUntilIdle() + + sut.showDeposit("txid") + + assertEquals("txid", sut.uiState.value.txid) + assertEquals(SparkDepositClaim.Adding, sut.uiState.value.claim) + } + + @Test + fun `the transfer banner opens a deposit no claim follows, as after a relaunch, as added at maturity`() = test { + val sut = createSut() + advanceUntilIdle() + + sut.showDeposit("txid") + + assertEquals("txid", sut.uiState.value.txid) + assertEquals(SparkDepositClaim.Later, sut.uiState.value.claim) + } + @Test fun `a funding that was signed but not accepted opens its recovery instead of an error`() = test { whenever { diff --git a/journeys/transfer/transfer-banner-opens-progress.xml b/journeys/transfer/transfer-banner-opens-progress.xml new file mode 100644 index 0000000000..c384403212 --- /dev/null +++ b/journeys/transfer/transfer-banner-opens-progress.xml @@ -0,0 +1,22 @@ + + + Verifies that tapping the "TRANSFER IN PROGRESS" banner on Home reopens the "Funds in transfer" screen of the + pending transfer to spending at its current step, also after a relaunch. A Later transfer keeps its deposit + pending until 3 confirmations, so the banner stays up while the journey taps it. + + Precondition: a Debug build with Spark connected on its regtest, launched against that regtest's Esplora (as + spark-transfer-to-spending.xml sets up), a wallet with a positive confirmed on-chain Savings balance, no pending + transfer, and at least one activity so Home shows its activity list. Start on the wallet home screen. + + + Tap the Savings balance card (testTag "ActivitySavings"), then "Transfer To Spending" (testTag "TransferToSpending"); tap "Get Started" (testTag "SpendingIntro-button") if the intro appears + Tap "25%" (testTag "SpendingAmountQuarter") and "Continue" (testTag "SpendingAmountContinue") + Tap "Later" (testTag "SpendingConfirmLater") and swipe the "Swipe To Transfer" handle (testTag "GRAB") fully to the right + Verify the "Funds in transfer" screen (testTag "LightningSettingUp") opens, then tap "Continue Using Bitkit" (testTag "TransferSuccess-button") + Verify Home shows the "TRANSFER IN PROGRESS" banner (testTag "ActivityBanner") + Tap the banner and verify "Funds in transfer" (testTag "LightningSettingUp") opens with "Payment Successful" as the current step and the speed (testTag "SettingUpSpeed") reading Later + Go back and verify the wallet home screen shows with the banner still visible + Relaunch the app, tap the banner and verify the same screen and step open again + Mine 3 blocks on the regtest and wait until the screen shows the transfer as done (testTag "TransferSuccess"); tap its button and verify Home no longer shows the banner + + From a368f86a6683a63839d1e7b076ae9f49bfa4bb60 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 17:48:38 +0100 Subject: [PATCH 02/10] fix: savings banner opens a running spark exit --- .../to/bitkit/ui/screens/wallets/HomeScreen.kt | 15 ++++++++++----- .../java/to/bitkit/viewmodels/AppViewModel.kt | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt b/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt index 4b49df3924..ea154e93b8 100644 --- a/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt @@ -242,6 +242,7 @@ fun HomeScreen( val resources = LocalResources.current val hasSeenTransferIntro by settingsViewModel.hasSeenTransferIntro.collectAsStateWithLifecycle() val sparkState by walletViewModel.sparkState.collectAsStateWithLifecycle() + val isSparkExiting by appViewModel.isSparkExiting.collectAsStateWithLifecycle() val hasSeenShopIntro by settingsViewModel.hasSeenShopIntro.collectAsStateWithLifecycle() val hasSeenProfileIntro by settingsViewModel.hasSeenProfileIntro.collectAsStateWithLifecycle() val profileNavigationScope = rememberCoroutineScope() @@ -407,9 +408,10 @@ fun HomeScreen( }, onNavigateToSavings = { walletNavController.navigate(Routes.Savings) }, onNavigateToSpending = { walletNavController.navigate(Routes.Spending) }, - onTransferBannerClick = sparkState.inProgressDepositTxid?.let { txid -> + onSpendingBannerClick = sparkState.inProgressDepositTxid?.let { txid -> { rootNavController.navigateToTransferProgress(txid) } }, + onSavingsBannerClick = appViewModel::onSparkExitBannerTapped.takeIf { isSparkExiting }, onClickHardwareWallet = { walletNavController.navigateTo(Routes.HardwareWallet(it)) }, onClickUsdt = { walletNavController.navigateTo(Routes.UsdtWallet) }, onCalculatorInputActiveChanged = onCalculatorInputActiveChanged, @@ -450,7 +452,8 @@ private fun Content( onNavigateToActivityItem: (Activity) -> Unit = {}, onNavigateToSavings: () -> Unit = {}, onNavigateToSpending: () -> Unit = {}, - onTransferBannerClick: (() -> Unit)? = null, + onSpendingBannerClick: (() -> Unit)? = null, + onSavingsBannerClick: (() -> Unit)? = null, onClickHardwareWallet: (String) -> Unit = {}, onClickUsdt: () -> Unit = {}, onCalculatorInputActiveChanged: (Boolean) -> Unit = {}, @@ -588,7 +591,8 @@ private fun Content( onNavigateToActivityItem = onNavigateToActivityItem, onNavigateToSavings = onNavigateToSavings, onNavigateToSpending = onNavigateToSpending, - onTransferBannerClick = onTransferBannerClick, + onSpendingBannerClick = onSpendingBannerClick, + onSavingsBannerClick = onSavingsBannerClick, onClickHardwareWallet = onClickHardwareWallet, onClickUsdt = onClickUsdt, ) @@ -640,7 +644,8 @@ private fun WalletPage( onNavigateToActivityItem: (Activity) -> Unit, onNavigateToSavings: () -> Unit, onNavigateToSpending: () -> Unit, - onTransferBannerClick: (() -> Unit)?, + onSpendingBannerClick: (() -> Unit)?, + onSavingsBannerClick: (() -> Unit)?, onClickHardwareWallet: (String) -> Unit, onClickUsdt: () -> Unit, ) { @@ -720,7 +725,7 @@ private fun WalletPage( gradientColor = banner.type.color, title = banner.title, icon = banner.type.icon, - onClick = onTransferBannerClick.takeIf { isSpending }, + onClick = if (isSpending) onSpendingBannerClick else onSavingsBannerClick, modifier = Modifier .fillMaxWidth() .testTag(if (isSpending) "ActivityBanner" else "ActivityBannerSavings") diff --git a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt index 03cc20685f..7ef03bf158 100644 --- a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt +++ b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt @@ -1499,6 +1499,13 @@ class AppViewModel @Inject constructor( fun onSparkExitNotificationTapped() = _isSparkExitRequested.update { true } + /** A Spark emergency exit is under way, so the Savings transfer banner on Home opens its progress. */ + val isSparkExiting: StateFlow = sparkExitRepo.state.map { it.isExiting } + .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), false) + + /** Opens the running emergency exit's progress, the way its notification does. */ + fun onSparkExitBannerTapped() = _isSparkExitRequested.update { true } + /** * Says whether the exit opens on its progress rather than a new exit, then clears the tapped notification: cleared * once nothing more suspends, as the screen that waits on it restarts and would cut the open short. From 0c8a46132c58e0ac1c909f5ed2b4b7a7d7fff945 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 18:16:22 +0100 Subject: [PATCH 03/10] feat: spark transfer status matches the funds in transfer designs Maps the deposit states onto the six Funds In Transfer (spark) frames: processing, payment successful, fast fee changed, fast transfer unavailable, adding to spending balance and transfer successful. Adds a journey and tests for the mapping. --- .../java/to/bitkit/repositories/SparkRepo.kt | 6 +- .../ui/screens/transfer/SettingUpScreen.kt | 365 +++++++++++------- .../screens/transfer/SparkFundingViewModel.kt | 32 +- .../components/TransferAnimationView.kt | 12 +- app/src/main/res/values-ar/strings.xml | 9 - app/src/main/res/values-b+es+419/strings.xml | 9 - app/src/main/res/values-ca/strings.xml | 9 - app/src/main/res/values-cs/strings.xml | 9 - app/src/main/res/values-de/strings.xml | 9 - app/src/main/res/values-el/strings.xml | 9 - app/src/main/res/values-es-rES/strings.xml | 9 - app/src/main/res/values-es/strings.xml | 9 - app/src/main/res/values-fr/strings.xml | 9 - app/src/main/res/values-it/strings.xml | 9 - app/src/main/res/values-nl/strings.xml | 9 - app/src/main/res/values-pl/strings.xml | 9 - app/src/main/res/values-pt-rBR/strings.xml | 9 - app/src/main/res/values-pt/strings.xml | 9 - app/src/main/res/values-ru/strings.xml | 9 - app/src/main/res/values/strings.xml | 18 +- .../screens/transfer/SettingUpScreenTest.kt | 61 +-- .../transfer/SparkFundingViewModelTest.kt | 41 ++ .../ui/screens/transfer/TransferStatusTest.kt | 74 ++++ docs/screens-map.md | 2 +- journeys/transfer/spark-transfer-status.xml | 32 ++ 25 files changed, 458 insertions(+), 320 deletions(-) create mode 100644 app/src/test/java/to/bitkit/ui/screens/transfer/TransferStatusTest.kt create mode 100644 journeys/transfer/spark-transfer-status.xml diff --git a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt index 713c1371ec..b8c64c0dd0 100644 --- a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt +++ b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt @@ -1072,7 +1072,9 @@ class SparkRepo @Inject constructor( private fun SparkState.withBroadcastDeposits(): SparkState { val known = deposits.map { it.txid }.toSet() val local = broadcastDeposits.filterKeys { it !in known } - .map { (txid, amount) -> SparkDeposit(txid = txid, amountSats = amount, isClaimed = false) } + .map { (txid, amount) -> + SparkDeposit(txid = txid, amountSats = amount, isClaimed = false, isListed = false) + } if (local.isEmpty()) return this val all = local + deposits return copy( @@ -2059,6 +2061,8 @@ data class SparkDeposit( val isClaimed: Boolean, val feeSats: ULong = 0uL, val claimedAt: ULong? = null, + /** Whether Spark lists it, rather than only the app that just broadcast it. */ + val isListed: Boolean = true, ) /** diff --git a/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt b/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt index 66ce211857..367bcefec2 100644 --- a/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt @@ -1,5 +1,6 @@ package to.bitkit.ui.screens.transfer +import androidx.annotation.StringRes import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -11,7 +12,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.Immutable import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale @@ -22,15 +25,14 @@ import androidx.compose.ui.tooling.preview.Devices.NEXUS_5 import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.toImmutableList import to.bitkit.R import to.bitkit.models.formatToModernDisplay import to.bitkit.repositories.SparkClaimOffer -import to.bitkit.repositories.SparkClaimSpeed import to.bitkit.repositories.SparkDepositClaim import to.bitkit.ui.appViewModel import to.bitkit.ui.components.BodyM -import to.bitkit.ui.components.Caption13Up import to.bitkit.ui.components.Display import to.bitkit.ui.components.PrimaryButton import to.bitkit.ui.components.SecondaryButton @@ -47,14 +49,14 @@ import to.bitkit.ui.utils.screenWidth import to.bitkit.ui.utils.withAccent import to.bitkit.ui.utils.withAccentBoldBright -/** Confirmations Spark waits for before it adds a deposit by itself. */ -private const val MATURE_CONFIRMATIONS = 3 - /** The success check's width against the screen's, as iOS draws its 256 pt check on a 402 pt screen. */ private const val CHECK_SCREEN_SHARE = 256f / 402f -/** About how long [MATURE_CONFIRMATIONS] take. */ -private const val MATURE_MINUTES = 30 +/** The coins' side against the outer ring, as Figma draws them: 329 pt on a 311 pt ring. */ +private const val COINS_FIGURE_SHARE = 329.2f / 311f + +/** How far below the rings' centre Figma draws the coins, against the outer ring. */ +private const val COINS_OFFSET_SHARE = 6.9f / 311f @Composable fun SettingUpScreen( @@ -73,8 +75,10 @@ fun SettingUpScreen( Content( claim = state.claim, - speed = state.speed, - onPayClick = viewModel::onPayRepriced, + isDepositSeen = state.isDepositSeen, + isFeeApproved = state.isFeeApproved, + hasWaited = state.hasWaited, + onApproveClick = viewModel::onPayRepriced, onWaitClick = viewModel::onWait, onContinueClick = onContinueClick, ) @@ -83,19 +87,25 @@ fun SettingUpScreen( @Composable internal fun Content( claim: SparkDepositClaim, - speed: SparkClaimSpeed = SparkClaimSpeed.Instant, - onPayClick: () -> Unit = {}, + isDepositSeen: Boolean = false, + isFeeApproved: Boolean = false, + hasWaited: Boolean = false, + onApproveClick: () -> Unit = {}, onWaitClick: () -> Unit = {}, onContinueClick: () -> Unit = {}, ) { - val inProgress = claim != SparkDepositClaim.Claimed + val status = remember(claim, isDepositSeen, isFeeApproved, hasWaited) { + transferStatusOf(claim, isDepositSeen, isFeeApproved, hasWaited) + } + val frame = status.frame + val isSuccess = frame == TransferStatusFrame.Success ScreenColumn( - modifier = Modifier.testTag(if (inProgress) "LightningSettingUp" else "TransferSuccess") + modifier = Modifier.testTag(if (isSuccess) "TransferSuccess" else "LightningSettingUp") ) { AppTopBar( titleText = when { - inProgress -> stringResource(R.string.lightning__transfer__nav_title) - else -> stringResource(R.string.lightning__transfer_success__nav_title) + isSuccess -> stringResource(R.string.lightning__transfer_success__nav_title) + else -> stringResource(R.string.lightning__transfer__nav_title) }, onBackClick = null, actions = { DrawerNavIcon() }, @@ -107,64 +117,20 @@ internal fun Content( .padding(horizontal = 16.dp) ) { VerticalSpacer(12.dp) - if (inProgress) { - Display( - text = stringResource(R.string.lightning__savings_progress__title) - .withAccent(accentColor = Colors.Purple), - modifier = Modifier.fillMaxWidth(), - ) - VerticalSpacer(8.dp) - BodyM( - text = claimText(claim).withAccentBoldBright(), - color = Colors.White64, - modifier = Modifier - .fillMaxWidth() - .testTag("SettingUpText") - ) - VerticalSpacer(8.dp) - Caption13Up( - text = speedText(claim, speed), - color = Colors.White64, - modifier = Modifier - .fillMaxWidth() - .testTag("SettingUpSpeed") - ) - } else { - Display( - text = stringResource(R.string.lightning__transfer_success__title_spending) - .withAccent(accentColor = Colors.Purple), - modifier = Modifier.fillMaxWidth(), - ) - VerticalSpacer(8.dp) - BodyM( - text = stringResource(R.string.lightning__transfer_success__text_spending), - color = Colors.White64, - modifier = Modifier.fillMaxWidth(), - ) - } + Display( + text = stringResource(frame.titleRes).withAccent(accentColor = Colors.Purple), + modifier = Modifier.fillMaxWidth(), + ) + VerticalSpacer(8.dp) + BodyM( + text = statusText(status, claim).withAccentBoldBright(), + color = Colors.White64, + modifier = Modifier + .fillMaxWidth() + .testTag("SettingUpText") + ) VerticalSpacer(28.dp) - if (inProgress) { - TransferAnimationView( - largeCircleRes = R.drawable.ln_sync_large, - smallCircleRes = R.drawable.ln_sync_small, - keepAssetRatios = true, - modifier = Modifier - .weight(1f) - .fillMaxWidth() - ) - VerticalSpacer(16.dp) - val steps = persistentListOf( - stringResource(R.string.lightning__setting_up_step1), - stringResource(R.string.lightning__setting_up_step2), - stringResource(R.string.lightning__setting_up__step_adding), - ) - ProgressSteps( - steps = steps, - activeStepIndex = claim.stepIndex(), - modifier = Modifier.align(alignment = Alignment.CenterHorizontally) - ) - VerticalSpacer(16.dp) - } else { + if (isSuccess) { Box( contentAlignment = Alignment.Center, modifier = Modifier @@ -181,131 +147,248 @@ internal fun Content( .testTag("TransferSuccessCheck") ) } - } - - if (claim is SparkDepositClaim.Repriced) { - Row( - horizontalArrangement = Arrangement.spacedBy(16.dp), - modifier = Modifier.fillMaxWidth(), - ) { - SecondaryButton( - text = stringResource(R.string.lightning__spark_deposit__wait_button), - onClick = onWaitClick, - modifier = Modifier - .weight(1f) - .testTag("SettingUpWait") - ) - PrimaryButton( - text = stringResource(R.string.lightning__setting_up__pay) - .replace("{amount}", claim.offer.earlyFeeSats.formatToModernDisplay()), - onClick = onPayClick, - modifier = Modifier - .weight(1f) - .testTag("SettingUpPay") - ) - } } else { - val randomOkText = localizedRandom(R.string.common__ok_random) - PrimaryButton( - text = if (inProgress) stringResource(R.string.lightning__setting_up_button) else randomOkText, - onClick = onContinueClick, - modifier = Modifier.testTag("TransferSuccess-button") + Illustration( + hasCoins = frame.hasCoins, + modifier = Modifier + .weight(1f) + .fillMaxWidth() + ) + VerticalSpacer(16.dp) + ProgressSteps( + steps = steps(frame), + activeStepIndex = frame.stepIndex, + modifier = Modifier.align(alignment = Alignment.CenterHorizontally) ) + VerticalSpacer(16.dp) } + Buttons( + frame = frame, + onApproveClick = onApproveClick, + onWaitClick = onWaitClick, + onContinueClick = onContinueClick, + ) VerticalSpacer(16.dp) } } } @Composable -private fun claimText(claim: SparkDepositClaim): String = when (claim) { - SparkDepositClaim.Looking -> stringResource(R.string.lightning__spark_deposit__looking) - SparkDepositClaim.Adding, SparkDepositClaim.Claimed -> stringResource(R.string.lightning__spark_deposit__claimed) - is SparkDepositClaim.Repriced -> stringResource(R.string.lightning__setting_up__repriced) - .replace("{amount}", claim.offer.earlyFeeSats.formatToModernDisplay()) +private fun Illustration(hasCoins: Boolean, modifier: Modifier = Modifier) { + if (hasCoins) { + TransferAnimationView( + largeCircleRes = R.drawable.ln_sync_large, + smallCircleRes = R.drawable.ln_sync_small, + contentRes = R.drawable.coin_stack_4, + rotateContent = false, + keepAssetRatios = true, + figureShare = COINS_FIGURE_SHARE, + figureOffsetShare = COINS_OFFSET_SHARE, + modifier = modifier.testTag("SettingUpCoins") + ) + return + } + TransferAnimationView( + largeCircleRes = R.drawable.ln_sync_large, + smallCircleRes = R.drawable.ln_sync_small, + keepAssetRatios = true, + modifier = modifier + ) +} - SparkDepositClaim.Unavailable -> stringResource(R.string.lightning__setting_up__unavailable) - SparkDepositClaim.Later -> stringResource(R.string.lightning__spark_deposit__standard) - .replace("{standard}", MATURE_CONFIRMATIONS.toString()) - .replace("{minutes}", MATURE_MINUTES.toString()) +@Composable +private fun Buttons( + frame: TransferStatusFrame, + onApproveClick: () -> Unit, + onWaitClick: () -> Unit, + onContinueClick: () -> Unit, +) { + if (frame == TransferStatusFrame.FeeChanged) { + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp), + modifier = Modifier.fillMaxWidth(), + ) { + SecondaryButton( + text = stringResource(R.string.lightning__spark_deposit__wait_button), + onClick = onWaitClick, + modifier = Modifier + .weight(1f) + .testTag("SettingUpWait") + ) + PrimaryButton( + text = stringResource(R.string.lightning__setting_up__approve_button), + onClick = onApproveClick, + modifier = Modifier + .weight(1f) + .testTag("SettingUpPay") + ) + } + return + } + val randomOkText = localizedRandom(R.string.common__ok_random) + PrimaryButton( + text = when (frame) { + TransferStatusFrame.Success -> randomOkText + else -> stringResource(R.string.lightning__setting_up_button) + }, + onClick = onContinueClick, + modifier = Modifier.testTag("TransferSuccess-button") + ) +} - SparkDepositClaim.NotSeen -> stringResource(R.string.lightning__setting_up__not_seen) +@Composable +private fun statusText(status: TransferStatus, claim: SparkDepositClaim): String = when { + status.frame == TransferStatusFrame.Success -> stringResource(R.string.lightning__transfer_success__text_spending) + claim is SparkDepositClaim.Repriced -> stringResource(R.string.lightning__setting_up__fee_changed_text) + .replace("{amount}", claim.offer.earlyFeeSats.formatToModernDisplay()) + + status.isNormalSpeed -> stringResource(R.string.lightning__setting_up__text_normal) + else -> stringResource(R.string.lightning__setting_up__text_fast) } @Composable -private fun speedText(claim: SparkDepositClaim, speed: SparkClaimSpeed): String { - // Unavailable and not seen add the transfer after 3 confirmations, whatever speed the user chose. - val isLater = speed == SparkClaimSpeed.Later || claim == SparkDepositClaim.Later || - claim == SparkDepositClaim.Unavailable || claim == SparkDepositClaim.NotSeen - return stringResource(R.string.lightning__setting_up__speed).replace( - "{speed}", - stringResource(if (isLater) R.string.common__later else R.string.fee__instant__title), +private fun steps(frame: TransferStatusFrame): ImmutableList { + val labels = mutableListOf( + stringResource(R.string.lightning__setting_up_step1), + stringResource(R.string.lightning__setting_up_step2), + stringResource(frame.stepRes), ) + labels[frame.stepIndex] = stringResource(frame.stepRes) + return labels.toImmutableList() +} + +/** The frames of the Funds In Transfer (spark) design, in the order a transfer moves through them. */ +enum class TransferStatusFrame( + val stepIndex: Int, + @StringRes val titleRes: Int, + @StringRes val stepRes: Int, + val hasCoins: Boolean = false, +) { + /** Spark has not seen the deposit yet. */ + Processing(0, R.string.lightning__savings_progress__title, R.string.lightning__setting_up_step1), + + /** Spark has seen the deposit. */ + PaymentSuccessful(1, R.string.lightning__savings_progress__title, R.string.lightning__setting_up_step2), + + /** The fast transfer fee rose above what the user accepted; Approve pays it, Wait takes the normal speed. */ + FeeChanged( + 2, + R.string.lightning__setting_up__fee_changed_title, + R.string.lightning__setting_up__step_fee_changed, + hasCoins = true, + ), + + /** Spark offers no fast transfer for the deposit, so it takes the normal speed. */ + FastUnavailable( + 2, + R.string.lightning__setting_up__unavailable_title, + R.string.lightning__setting_up__step_normal, + hasCoins = true, + ), + + /** The user chose Wait over the changed fast transfer fee. */ + NormalSpeed(2, R.string.lightning__savings_progress__title, R.string.lightning__setting_up__step_normal), + + /** Spark is adding the deposit to the spending balance. */ + Adding(2, R.string.lightning__savings_progress__title, R.string.lightning__setting_up__step_adding_balance), + + /** The deposit is in the spending balance. */ + Success( + 2, + R.string.lightning__transfer_success__title_spending, + R.string.lightning__setting_up__step_adding_balance, + ), } -private fun SparkDepositClaim.stepIndex(): Int = when (this) { - SparkDepositClaim.Looking, SparkDepositClaim.Later, SparkDepositClaim.NotSeen -> 1 - SparkDepositClaim.Adding, is SparkDepositClaim.Repriced, SparkDepositClaim.Unavailable -> 2 - SparkDepositClaim.Claimed -> 3 +/** The frame a transfer shows, and whether its text names the normal speed's 30 minutes. */ +@Immutable +data class TransferStatus( + val frame: TransferStatusFrame, + val isNormalSpeed: Boolean = false, +) + +/** + * Maps a deposit's claim onto the design's frames. [isFeeApproved] keeps an approved fee change on the last step while + * the claim looks again, and [hasWaited] keeps it there at the normal speed after Wait. + */ +internal fun transferStatusOf( + claim: SparkDepositClaim, + isDepositSeen: Boolean, + isFeeApproved: Boolean, + hasWaited: Boolean, +): TransferStatus { + val seenOrProcessing = if (isDepositSeen) TransferStatusFrame.PaymentSuccessful else TransferStatusFrame.Processing + return when (claim) { + SparkDepositClaim.Claimed -> TransferStatus(TransferStatusFrame.Success) + is SparkDepositClaim.Repriced -> TransferStatus(TransferStatusFrame.FeeChanged) + SparkDepositClaim.Unavailable -> TransferStatus(TransferStatusFrame.FastUnavailable, isNormalSpeed = true) + SparkDepositClaim.Adding -> TransferStatus(TransferStatusFrame.Adding) + SparkDepositClaim.Later if hasWaited -> + TransferStatus(TransferStatusFrame.NormalSpeed, isNormalSpeed = true) + + SparkDepositClaim.Later, SparkDepositClaim.NotSeen -> TransferStatus(seenOrProcessing, isNormalSpeed = true) + SparkDepositClaim.Looking if isFeeApproved -> TransferStatus(TransferStatusFrame.Adding) + SparkDepositClaim.Looking -> TransferStatus(seenOrProcessing) + } } private val previewRepriced = SparkDepositClaim.Repriced( SparkClaimOffer.Choice( txid = "txid", vout = 0u, - earlyFeeSats = 1_850uL, + earlyFeeSats = 2_134uL, earlyConfirmations = 0u, standardFeeSats = 198uL, standardConfirmations = 3u, ) ) -@Preview(name = "Looking", showSystemUi = true, showBackground = true) +@Preview(name = "Processing", showSystemUi = true, showBackground = true) @Composable -private fun PreviewLooking() { +private fun PreviewProcessing() { AppThemeSurface { Content(claim = SparkDepositClaim.Looking) } } -@Preview(name = "Looking", showSystemUi = true, showBackground = true, device = NEXUS_5) +@Preview(name = "Processing", showSystemUi = true, showBackground = true, device = NEXUS_5) @Composable -private fun PreviewLookingSmall() { +private fun PreviewProcessingSmall() { AppThemeSurface { Content(claim = SparkDepositClaim.Looking) } } -@Preview(name = "Adding", showSystemUi = true, showBackground = true) +@Preview(name = "Payment successful", showSystemUi = true, showBackground = true) @Composable -private fun PreviewAdding() { - AppThemeSurface { Content(claim = SparkDepositClaim.Adding) } +private fun PreviewSeen() { + AppThemeSurface { Content(claim = SparkDepositClaim.Looking, isDepositSeen = true) } } -@Preview(name = "Repriced", showSystemUi = true, showBackground = true) +@Preview(name = "Fee changed", showSystemUi = true, showBackground = true) @Composable -private fun PreviewRepriced() { +private fun PreviewFeeChanged() { AppThemeSurface { Content(claim = previewRepriced) } } -@Preview(name = "Repriced", showSystemUi = true, showBackground = true, device = NEXUS_5) +@Preview(name = "Fee changed", showSystemUi = true, showBackground = true, device = NEXUS_5) @Composable -private fun PreviewRepricedSmall() { +private fun PreviewFeeChangedSmall() { AppThemeSurface { Content(claim = previewRepriced) } } -@Preview(name = "Unavailable", showSystemUi = true, showBackground = true) +@Preview(name = "Fast unavailable", showSystemUi = true, showBackground = true) @Composable private fun PreviewUnavailable() { AppThemeSurface { Content(claim = SparkDepositClaim.Unavailable) } } -@Preview(name = "Later", showSystemUi = true, showBackground = true) +@Preview(name = "Waited", showSystemUi = true, showBackground = true) @Composable -private fun PreviewLater() { - AppThemeSurface { Content(claim = SparkDepositClaim.Later) } +private fun PreviewWaited() { + AppThemeSurface { Content(claim = SparkDepositClaim.Later, isDepositSeen = true, hasWaited = true) } } -@Preview(name = "Not seen", showSystemUi = true, showBackground = true) +@Preview(name = "Adding", showSystemUi = true, showBackground = true) @Composable -private fun PreviewNotSeen() { - AppThemeSurface { Content(claim = SparkDepositClaim.NotSeen) } +private fun PreviewAdding() { + AppThemeSurface { Content(claim = SparkDepositClaim.Adding) } } @Preview(name = "Success", showSystemUi = true, showBackground = true) diff --git a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt index 79d328ffc5..48ada133ad 100644 --- a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt +++ b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt @@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.first @@ -110,6 +111,11 @@ class SparkFundingViewModel @Inject constructor( _uiState.update { state -> state.copy(claim = state.txid?.let { claims[it] } ?: state.claim) } } } + viewModelScope.launch { + combine(_uiState.map { it.txid }, sparkRepo.state.map { it.deposits }) { txid, deposits -> + txid != null && deposits.any { it.isListed && it.txid.equals(txid, ignoreCase = true) } + }.distinctUntilChanged().collect { isSeen -> _uiState.update { it.copy(isDepositSeen = isSeen) } } + } } /** @@ -324,7 +330,14 @@ class SparkFundingViewModel @Inject constructor( sparkRepo.followDepositClaim(txid, state.speed, quote.instantFeeSats.toULong()) } Logger.info("Funded Spark from a hardware wallet with '$amountSats' sats in '$txid'", context = TAG) - _uiState.update { it.copy(txid = txid, claim = sparkRepo.depositClaims.value[txid] ?: it.claim) } + _uiState.update { + it.copy( + txid = txid, + claim = sparkRepo.depositClaims.value[txid] ?: it.claim, + isFeeApproved = false, + hasWaited = false, + ) + } _effects.emit(SideEffect.Sent) } } @@ -391,7 +404,14 @@ class SparkFundingViewModel @Inject constructor( sparkRepo.followDepositClaim(txid, speed, ceilingSats) } Logger.info("Funded Spark with '$amountSats' sats in '$txid'", context = TAG) - _uiState.update { it.copy(txid = txid, claim = sparkRepo.depositClaims.value[txid] ?: it.claim) } + _uiState.update { + it.copy( + txid = txid, + claim = sparkRepo.depositClaims.value[txid] ?: it.claim, + isFeeApproved = false, + hasWaited = false, + ) + } _effects.emit(SideEffect.Sent) } @@ -434,11 +454,13 @@ class SparkFundingViewModel @Inject constructor( fun onPayRepriced() { val txid = _uiState.value.txid ?: return + _uiState.update { it.copy(isFeeApproved = true) } sparkRepo.payRepricedClaim(txid) } fun onWait() { val txid = _uiState.value.txid ?: return + _uiState.update { it.copy(hasWaited = true) } sparkRepo.waitForMatureClaim(txid) } @@ -555,6 +577,12 @@ interface SparkFundingContract { val isSending: Boolean = false, val txid: String? = null, val claim: SparkDepositClaim = SparkDepositClaim.Looking, + /** Whether Spark lists the deposit in [txid]. */ + val isDepositSeen: Boolean = false, + /** Whether the user approved the changed fast transfer fee of the deposit in [txid]. */ + val isFeeApproved: Boolean = false, + /** Whether the user chose Wait over the changed fast transfer fee of the deposit in [txid]. */ + val hasWaited: Boolean = false, ) /** What the transfer costs, priced together so the confirm screen's tiles always agree. */ diff --git a/app/src/main/java/to/bitkit/ui/screens/transfer/components/TransferAnimationView.kt b/app/src/main/java/to/bitkit/ui/screens/transfer/components/TransferAnimationView.kt index 84fcfd8820..1c71ec2bd6 100644 --- a/app/src/main/java/to/bitkit/ui/screens/transfer/components/TransferAnimationView.kt +++ b/app/src/main/java/to/bitkit/ui/screens/transfer/components/TransferAnimationView.kt @@ -13,7 +13,9 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredSize import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.runtime.Composable @@ -49,6 +51,7 @@ fun TransferAnimationView( keepAssetRatios: Boolean = false, innerRingShare: Float = ELLIPSE_INNER_SHARE, figureShare: Float = ELLIPSE_FIGURE_SHARE, + figureOffsetShare: Float = 0f, maxSize: Dp = Dp.Infinity, ) { val animationSpec: InfiniteRepeatableSpec = infiniteRepeatable( @@ -90,6 +93,7 @@ fun TransferAnimationView( rotationContent = if (rotateContent) rotationArrows else 0f, innerRingShare = innerRingShare, figureShare = figureShare, + figureOffsetShare = figureOffsetShare, maxSize = maxSize, ) return@Box @@ -132,7 +136,8 @@ fun TransferAnimationView( /** * Draws the rings and figure as iOS's `EllipseLoader` does: the outer ring fills the largest square that fits, up to - * [maxSize], the inner ring takes [innerRingShare] of it and the figure fits a square of [figureShare] of it. + * [maxSize], the inner ring takes [innerRingShare] of it and the figure fits a square of [figureShare] of it, moved + * down by [figureOffsetShare] of it. */ @Composable private fun ScaledLayers( @@ -144,6 +149,7 @@ private fun ScaledLayers( rotationContent: Float, innerRingShare: Float, figureShare: Float, + figureOffsetShare: Float, maxSize: Dp, ) { BoxWithConstraints(contentAlignment = Alignment.Center) { @@ -174,7 +180,9 @@ private fun ScaledLayers( contentDescription = null, contentScale = ContentScale.Fit, modifier = Modifier - .size(container * figureShare) + .offset(y = container * figureOffsetShare) + // Required, as a figure can be drawn larger than the outer ring, clipped to it. + .requiredSize(container * figureShare) .rotate(rotationContent), ) } diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index e4cd0e3bca..66165af2a8 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -210,12 +210,6 @@ يرجى الانتظار، جارٍ تحويل أموالك. يجب أن يستغرق هذا <accent>±10 ثوانٍ.</accent> الأموال\n<accent>قيد التحويل</accent> وقت مزامنة درجات تحديد المسار - لم يرَ Spark تحويلك بعد. يُضاف بعد 3 تأكيدات؛ يمكنك مغادرة هذه الشاشة. - ادفع ₿ {amount} - أصبح الفوري يكلّف الآن <accent>₿ {amount}</accent>. ادفعه، أو انتظر 3 تأكيدات، نحو 30 دقيقة، برسوم أقل. - السرعة: {speed} - جارٍ الإضافة إلى الإنفاق - الفوري غير متاح لهذا التحويل. يضيفه Spark إلى رصيد الإنفاق بعد 3 تأكيدات، نحو 30 دقيقة. متابعة استخدام Bitkit جارٍ معالجة الدفع الدفع ناجح @@ -223,9 +217,6 @@ رسوم المطالبة %1$d/3 تأكيدات إيداع - يضيفه Spark إلى رصيد الإنفاق. - بانتظار أن يرى Spark تحويلك. - يضيفه Spark إلى رصيد الإنفاق بعد {standard} تأكيدات، أي بعد نحو {minutes} دقيقة. انتظر إيداعات تمت المطالبة بها إيداعات قيد التنفيذ diff --git a/app/src/main/res/values-b+es+419/strings.xml b/app/src/main/res/values-b+es+419/strings.xml index 692bc2f515..177bb0f22a 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -217,12 +217,6 @@ Espera un momento, tu transferencia está en proceso. Tomará aproximadamente <accent>10 segundos.</accent> Fondos\n<accent>en proceso</accent> Hora de sincronización de puntuaciones de ruta - Spark todavía no vio tu transferencia. Se agrega después de 3 confirmaciones; puedes salir de esta pantalla. - Pagar ₿ {amount} - Instantáneo ahora cuesta <accent>₿ {amount}</accent>. Págalo o espera 3 confirmaciones, unos 30 minutos, con una comisión menor. - Velocidad: {speed} - Agregando a gastos - Instantáneo no está disponible para esta transferencia. Spark la agrega a tu saldo para gastos después de 3 confirmaciones, unos 30 minutos. Continuar Usando Bitkit Procesando pago Pago Efectuado @@ -230,9 +224,6 @@ Comisión de reclamo %1$d/3 confirmaciones Depósito - Spark lo está agregando a tu saldo de gastos. - Esperando a que Spark vea tu transferencia. - Spark lo agrega a tu saldo de gastos después de {standard} confirmaciones, en unos {minutes} minutos. Esperar Depósitos reclamados Depósitos en curso diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 012af26c5e..10ce42b850 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -214,12 +214,6 @@ Si us plau, espera, la transferència de fons està en curs. Hauria de trigar <accent>±10 segons.</accent> Fons\n<accent>en transferència</accent> Temps de sincronització de puntuacions de rutes - Spark encara no ha vist la teva transferència. S\'afegeix després de 3 confirmacions; pots sortir d\'aquesta pantalla. - Paga ₿ {amount} - Instant ara costa <accent>₿ {amount}</accent>. Paga-ho o espera 3 confirmacions, uns 30 minuts, amb una comissió més baixa. - Velocitat: {speed} - Afegint a despesa - Instant no està disponible per a aquesta transferència. Spark l\'afegeix al teu saldo de despesa després de 3 confirmacions, uns 30 minuts. Continua utilitzant Bitkit Processant pagament Pagament realitzat amb èxit @@ -227,9 +221,6 @@ Comissió de reclamació %1$d/3 confirmacions Dipòsit - Spark ho està afegint al teu saldo de despeses. - Esperant que Spark vegi la teva transferència. - Spark ho afegeix al teu saldo de despeses després de {standard} confirmacions, d\'aquí a uns {minutes} minuts. Espera Dipòsits reclamats Dipòsits en curs diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 32e9c3b9be..a2ef35be50 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -217,12 +217,6 @@ Počkejte prosím, probíhá převod finančních prostředků. To by mělo trvat <accent>±10 sekund.</accent> Finanční prostředky\n<accent>v převodu</accent> Čas synchronizace skóre hledání cest - Spark tvůj převod zatím neviděl. Připíše se po 3 potvrzeních; tuto obrazovku můžeš opustit. - Zaplatit ₿ {amount} - Okamžitě nyní stojí <accent>₿ {amount}</accent>. Zaplať, nebo počkej na 3 potvrzení, asi 30 minut, s nižším poplatkem. - Rychlost: {speed} - Přidávání do výdajů - Okamžitě není pro tento převod dostupné. Spark ho přidá do tvého zůstatku pro výdaje po 3 potvrzeních, asi za 30 minut. Pokračujte v používání Bitkit Zpracování platby Platba úspěšně proběhla @@ -230,9 +224,6 @@ Poplatek za připsání %1$d/3 potvrzení Vklad - Spark ji připisuje na váš zůstatek k utrácení. - Čekáme, až Spark uvidí váš převod. - Spark ji připíše na váš zůstatek k utrácení po {standard} potvrzeních, asi za {minutes} minut. Počkat Připsané vklady Probíhající vklady diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 3c67d6f9ec..9ef6c0003e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -106,9 +106,6 @@ Einlösegebühr %1$d/3 Bestätigungen Einzahlung - Spark schreibt es deinem Ausgabenguthaben gut. - Warte, bis Spark deine Überweisung sieht. - Spark schreibt es deinem Ausgabenguthaben nach {standard} Bestätigungen gut, in etwa {minutes} Minuten. Warten Eingelöste Einzahlungen Laufende Einzahlungen @@ -363,12 +360,6 @@ Verbindung inaktiv Rapid Gossip Sync Snapshot-Zeit Pathfinding-Scores Sync-Zeit - Spark hat deine Überweisung noch nicht gesehen. Sie wird nach 3 Bestätigungen gutgeschrieben; du kannst diesen Bildschirm verlassen. - ₿ {amount} zahlen - Sofort kostet jetzt <accent>₿ {amount}</accent>. Zahle es oder warte auf 3 Bestätigungen, etwa 30 Minuten, zu einer niedrigeren Gebühr. - Geschwindigkeit: {speed} - Wird hinzugefügt - Sofort ist für diese Überweisung nicht verfügbar. Spark fügt sie nach 3 Bestätigungen, etwa 30 Minuten, deinem Ausgabenguthaben hinzu. Bitkit weiter verwenden Zahlung wird verarbeitet Zahlung erfolgreich diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index e63ed7a2bd..5dc0f30ec6 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -210,12 +210,6 @@ Περίμενε, η μεταφορά κεφαλαίων σου είναι σε εξέλιξη. Αυτό θα διαρκέσει <accent>±10 δευτερόλεπτα.</accent> Κεφάλαια\n<accent>σε μεταφορά</accent> Χρόνος συγχρονισμού βαθμολογιών εύρεσης διαδρομής - Το Spark δεν έχει δει ακόμα τη μεταφορά σου. Προστίθεται μετά από 3 επιβεβαιώσεις· μπορείς να φύγεις από αυτή την οθόνη. - Πλήρωσε ₿ {amount} - Το Άμεσα κοστίζει τώρα <accent>₿ {amount}</accent>. Πλήρωσέ το ή περίμενε 3 επιβεβαιώσεις, περίπου 30 λεπτά, με χαμηλότερη χρέωση. - Ταχύτητα: {speed} - Προσθήκη στις δαπάνες - Το Άμεσα δεν είναι διαθέσιμο για αυτή τη μεταφορά. Το Spark την προσθέτει στο υπόλοιπο δαπανών σου μετά από 3 επιβεβαιώσεις, περίπου 30 λεπτά. Συνέχισε να χρησιμοποιείς το Bitkit Επεξεργασία πληρωμής Επιτυχής πληρωμή @@ -223,9 +217,6 @@ Χρέωση εξαργύρωσης %1$d/3 επιβεβαιώσεις Κατάθεση - Το Spark το προσθέτει στο υπόλοιπο δαπανών σας. - Αναμονή για να δει το Spark τη μεταφορά σας. - Το Spark το προσθέτει στο υπόλοιπο δαπανών σας μετά από {standard} επιβεβαιώσεις, σε περίπου {minutes} λεπτά. Αναμονή Εξαργυρωμένες καταθέσεις Καταθέσεις σε εξέλιξη diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index f4b03b2a0e..c7c2e9829b 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -216,12 +216,6 @@ Por favor espera, tu transferencia de fondos está en curso. Debería tardar <accent>±10 segundos.</accent> Fondos\n<accent>en transferencia</accent> Hora de sincronización de puntuaciones de rutas - Spark aún no ha visto su transferencia. Se añade tras 3 confirmaciones; puede salir de esta pantalla. - Pagar ₿ {amount} - Instantáneo ahora cuesta <accent>₿ {amount}</accent>. Páguelo o espere 3 confirmaciones, unos 30 minutos, con una comisión menor. - Velocidad: {speed} - Añadiendo a gastos - Instantáneo no está disponible para esta transferencia. Spark la añade a su saldo para gastos tras 3 confirmaciones, unos 30 minutos. Continuar Usando Bitkit Procesando Pago Pago exitoso @@ -229,9 +223,6 @@ Comisión de reclamación %1$d/3 confirmaciones Depósito - Spark lo está añadiendo a tu saldo de gastos. - Esperando a que Spark vea tu transferencia. - Spark lo añade a tu saldo de gastos tras {standard} confirmaciones, en unos {minutes} minutos. Esperar Depósitos reclamados Depósitos en curso diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index cb250a075a..a3b769f099 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -158,12 +158,6 @@ Por favor espera, la transferencia de tus fondos está en progreso. Esto debería llevar <accent>±10 segundos.</accent> Fondos\n<accent>en transferencia</accent> Hora de sincronización de puntuaciones de rutas - Spark aún no ha visto tu transferencia. Se añade tras 3 confirmaciones; puedes salir de esta pantalla. - Pagar ₿ {amount} - Instantáneo ahora cuesta <accent>₿ {amount}</accent>. Págalo o espera 3 confirmaciones, unos 30 minutos, con una comisión menor. - Velocidad: {speed} - Añadiendo a gastos - Instantáneo no está disponible para esta transferencia. Spark la añade a tu saldo para gastos tras 3 confirmaciones, unos 30 minutos. Continuar Usando Bitkit Pago Exitoso Procesando Pago @@ -171,9 +165,6 @@ Comisión de reclamo %1$d/3 confirmaciones Depósito - Spark lo está añadiendo a tu saldo de gastos. - Esperando a que Spark vea tu transferencia. - Spark lo añade a tu saldo de gastos tras {standard} confirmaciones, en unos {minutes} minutos. Esperar Depósitos reclamados Depósitos en curso diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index f4a8687132..427f94355c 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -105,9 +105,6 @@ Frais de réclamation %1$d/3 confirmations Dépôt - Spark l\'ajoute à votre solde de dépenses. - En attente que Spark voie votre transfert. - Spark l\'ajoute à votre solde de dépenses après {standard} confirmations, dans environ {minutes} minutes. Attendre Dépôts réclamés Dépôts en cours @@ -280,12 +277,6 @@ Capacité de réception Heure de l\'instantané Rapid Gossip Sync Heure de synchronisation des scores de routage - Spark n\'a pas encore vu votre transfert. Il est ajouté après 3 confirmations ; vous pouvez quitter cet écran. - Payer ₿ {amount} - Instantané coûte maintenant <accent>₿ {amount}</accent>. Payez-le, ou attendez 3 confirmations, environ 30 minutes, pour des frais moins élevés. - Vitesse : {speed} - Ajout aux dépenses - Instantané n\'est pas disponible pour ce transfert. Spark l\'ajoute à votre solde de dépenses après 3 confirmations, environ 30 minutes. Continuer à utiliser Bitkit Traitement des paiements Paiement réussi diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index a44dda72c2..ace9278c70 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -215,12 +215,6 @@ Attendi, il trasferimento dei fondi e\' in corso. Dovrebbe richiedere <accent>circa 10 secondi.</accent> Fondi\n<accent>in trasferimento</accent> Tempo Sincronizzazione Punteggi Pathfinding - Spark non ha ancora visto il tuo trasferimento. Viene aggiunto dopo 3 conferme; puoi lasciare questa schermata. - Paga ₿ {amount} - Istantanea ora costa <accent>₿ {amount}</accent>. Pagala, oppure attendi 3 conferme, circa 30 minuti, con una commissione più bassa. - Velocità: {speed} - Aggiunta alle spese - Istantanea non è disponibile per questo trasferimento. Spark lo aggiunge al tuo conto di spesa dopo 3 conferme, circa 30 minuti. Continua ad utilizzare Bitkit Elaborazione del pagamento Pagamento Riuscito @@ -228,9 +222,6 @@ Commissione di riscatto %1$d/3 conferme Deposito - Spark lo sta aggiungendo al tuo saldo di spesa. - In attesa che Spark veda il tuo trasferimento. - Spark lo aggiunge al tuo saldo di spesa dopo {standard} conferme, tra circa {minutes} minuti. Attendi Depositi riscattati Depositi in corso diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index b210d10775..f2ad8202f8 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -214,12 +214,6 @@ Even geduld, je geld wordt overgeboekt. Dit duurt <accent>±10 seconden.</accent> Geld\n<accent>in overboeking</accent> Pathfinding scores synchronisatietijd - Spark heeft je overboeking nog niet gezien. Hij wordt toegevoegd na 3 bevestigingen; je kunt dit scherm verlaten. - Betaal ₿ {amount} - Direct kost nu <accent>₿ {amount}</accent>. Betaal het, of wacht op 3 bevestigingen, ongeveer 30 minuten, tegen lagere kosten. - Snelheid: {speed} - Toevoegen aan besteding - Direct is niet beschikbaar voor deze overboeking. Spark voegt hem na 3 bevestigingen, ongeveer 30 minuten, toe aan je bestedingssaldo. Doorgaan met Bitkit Betaling verwerken Betaling succesvol @@ -227,9 +221,6 @@ Claimkosten %1$d/3 bevestigingen Storting - Spark voegt het toe aan je bestedingssaldo. - Wachten tot Spark je overboeking ziet. - Spark voegt het na {standard} bevestigingen toe aan je bestedingssaldo, over ongeveer {minutes} minuten. Wachten Geclaimde stortingen Lopende stortingen diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 480fd04042..7eaa34d776 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -107,9 +107,6 @@ Opłata za odbiór %1$d/3 potwierdzeń Wpłata - Spark dodaje je do Twojego salda wydatków. - Czekamy, aż Spark zobaczy Twój przelew. - Spark doda je do Twojego salda wydatków po {standard} potwierdzeniach, za około {minutes} minut. Czekaj Odebrane wpłaty Wpłaty w toku @@ -364,12 +361,6 @@ Połączenie nieaktywne Czas snapshotu Rapid Gossip Sync Czas synchronizacji wyników ścieżek - Spark jeszcze nie widzi Twojego przelewu. Zostanie dodany po 3 potwierdzeniach; możesz opuścić ten ekran. - Zapłać ₿ {amount} - Natychmiast kosztuje teraz <accent>₿ {amount}</accent>. Zapłać albo poczekaj na 3 potwierdzenia, około 30 minut, z niższą opłatą. - Prędkość: {speed} - Dodawanie do wydatków - Natychmiast nie jest dostępne dla tego przelewu. Spark doda go do Twojego salda wydatków po 3 potwierdzeniach, około 30 minut. Kontunuuj korzystanie z Bitkit\'a Przetwarzanie płatności Płatność powiodła się diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 7d48e5a6f6..3d53f1fd52 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -218,12 +218,6 @@ Aguarde, sua transferência de fundos está em andamento. Isso deve levar <accent>±10 segundos.</accent> <accent>Transferindo</accent>\nfundos Sincronização de Scores de Roteamento - A Spark ainda não viu sua transferência. Ela é adicionada após 3 confirmações; você pode sair desta tela. - Pagar ₿ {amount} - Instantâneo agora custa <accent>₿ {amount}</accent>. Pague ou aguarde 3 confirmações, cerca de 30 minutos, com uma taxa menor. - Velocidade: {speed} - Adicionando aos gastos - Instantâneo não está disponível para esta transferência. A Spark a adiciona ao seu saldo de gastos após 3 confirmações, cerca de 30 minutos. Continuar Usando o Bitkit Processando Pagamento Pagamento Realizado @@ -231,9 +225,6 @@ Taxa de resgate %1$d/3 confirmações Depósito - A Spark está adicionando ao seu saldo de gastos. - Aguardando a Spark ver sua transferência. - A Spark adiciona ao seu saldo de gastos após {standard} confirmações, em cerca de {minutes} minutos. Esperar Depósitos resgatados Depósitos em andamento diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index aef7c3de1f..fda7354a3b 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -102,9 +102,6 @@ Taxa de resgate %1$d/3 confirmações Depósito - A Spark está a adicioná-lo ao seu saldo de gastos. - A aguardar que a Spark veja a sua transferência. - A Spark adiciona-o ao seu saldo de gastos após {standard} confirmações, dentro de cerca de {minutes} minutos. Esperar Depósitos resgatados Depósitos em curso @@ -354,12 +351,6 @@ Tempo de Sinc. da Carteira Lightning Tempo do Snapshot Rapid Gossip Sync Tempo de Sinc. das Pontuações de Pathfinding - A Spark ainda não viu a sua transferência. É adicionada após 3 confirmações; pode sair deste ecrã. - Pagar ₿ {amount} - Instantâneo custa agora <accent>₿ {amount}</accent>. Pague-o ou aguarde 3 confirmações, cerca de 30 minutos, com uma taxa mais baixa. - Velocidade: {speed} - A adicionar aos gastos - Instantâneo não está disponível para esta transferência. A Spark adiciona-a ao seu saldo de gastos após 3 confirmações, cerca de 30 minutos. Continuar Usando o Bitkit Processando Pagamento Pagamento Realizado diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 6885fd0628..79d7faf3e0 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -226,12 +226,6 @@ Пожалуйста, подождите, ваш перевод средств выполняется. Это займёт <accent>±10 секунд.</accent> Средства\n<accent>в Процессе Перевода</accent> Время синхронизации оценок маршрутизации - Spark ещё не увидел ваш перевод. Он будет зачислен после 3 подтверждений; можно покинуть этот экран. - Оплатить ₿ {amount} - Мгновенно теперь стоит <accent>₿ {amount}</accent>. Оплатите или дождитесь 3 подтверждений, около 30 минут, с меньшей комиссией. - Скорость: {speed} - Зачисление на расходы - Мгновенно недоступно для этого перевода. Spark зачислит его на баланс расходов после 3 подтверждений, примерно через 30 минут. Продолжить Использование Bitkit Обработка Платежа Платеж Успешен @@ -239,9 +233,6 @@ Комиссия за зачисление %1$d/3 подтверждений Депозит - Spark зачисляет их на ваш расходный баланс. - Ждём, пока Spark увидит ваш перевод. - Spark зачислит их на ваш расходный баланс после {standard} подтверждений, примерно через {minutes} минут. Ждать Зачисленные депозиты Депозиты в обработке diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c195a779ce..8b66cbb104 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -401,12 +401,15 @@ Transfer\n<accent>failed</accent> Your channel funds are moving to savings, but your Spark balance could not move and stays in your spending balance. Pathfinding Scores Sync Time - Spark hasn\'t seen your transfer yet. It\'s added after 3 confirmations; you can leave this screen. - Pay ₿ {amount} - Instant now costs <accent>₿ {amount}</accent>. Pay it to add your transfer now, or wait for 3 confirmations, about 30 minutes. - Speed: {speed} - Adding To Spending - Instant isn\'t available for this transfer. Spark adds it to your spending balance after 3 confirmations, about 30 minutes. + Approve + <accent>The fast transfer fee is now ₿ {amount}.</accent> Approve to access your funds quickly, or wait ±30 min. + Fast transfer\n<accent>fee changed</accent> + Adding To Spending Balance + Fast Transfer Fee Changed + Using Normal Transfer Speed + Please wait, your funds transfer is in progress. This should take <accent>a few minutes.</accent> + Please wait, your funds transfer is in progress. This should take <accent>about 30 minutes.</accent> + Fast transfer\n<accent>unavailable</accent> Continue Using Bitkit Processing Payment Payment Successful @@ -414,9 +417,6 @@ Claim fee %1$d/3 confirmations Deposit - Spark is adding it to your spending balance. - Waiting for Spark to see your transfer. - Spark adds it to your spending balance after {standard} confirmations, about {minutes} minutes. Wait Claimed deposits Deposits in progress diff --git a/app/src/test/java/to/bitkit/ui/screens/transfer/SettingUpScreenTest.kt b/app/src/test/java/to/bitkit/ui/screens/transfer/SettingUpScreenTest.kt index 96d6b34116..0981fa1b71 100644 --- a/app/src/test/java/to/bitkit/ui/screens/transfer/SettingUpScreenTest.kt +++ b/app/src/test/java/to/bitkit/ui/screens/transfer/SettingUpScreenTest.kt @@ -15,7 +15,6 @@ import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config import to.bitkit.repositories.SparkClaimOffer -import to.bitkit.repositories.SparkClaimSpeed import to.bitkit.repositories.SparkDepositClaim import to.bitkit.ui.theme.AppThemeSurface import kotlin.test.assertEquals @@ -28,54 +27,59 @@ class SettingUpScreenTest { val composeRule = createComposeRule() @Test - fun `repriced steps and their label sit above the side by side buttons on a small screen`() { - setContent(repriced, SparkClaimSpeed.Instant) + fun `fee changed steps and their label sit above the side by side buttons on a small screen`() { + setContent(repriced) - val label = composeRule.onNodeWithText("Adding To Spending").getUnclippedBoundsInRoot() + val label = composeRule.onNodeWithText("Fast Transfer Fee Changed").getUnclippedBoundsInRoot() val wait = composeRule.onNodeWithTag("SettingUpWait").getUnclippedBoundsInRoot() - val pay = composeRule.onNodeWithTag("SettingUpPay").getUnclippedBoundsInRoot() + val approve = composeRule.onNodeWithTag("SettingUpPay").getUnclippedBoundsInRoot() assertTrue(label.bottom <= wait.top) - assertTrue(wait.top == pay.top && wait.right < pay.left) - composeRule.onNodeWithText("SPEED: INSTANT").assertExists() - composeRule.onNodeWithText( - "Pay it to add your transfer now, or wait for 3 confirmations, about 30 minutes.", - substring = true, - ).assertExists() + assertTrue(wait.top == approve.top && wait.right < approve.left) + composeRule.onNodeWithText("FEE CHANGED", substring = true).assertExists() + composeRule.onNodeWithText("Approve").assertExists() + composeRule.onNodeWithText("The fast transfer fee is now ₿ ", substring = true).assertExists() + composeRule.onNodeWithText("Approve to access your funds quickly, or wait ±30 min.", substring = true) + .assertExists() + composeRule.onNodeWithTag("SettingUpCoins").assertExists() } @Test - fun `later steps and their label sit above the button on a small screen`() { - setContent(SparkDepositClaim.Later, SparkClaimSpeed.Instant) + fun `normal speed steps and their label sit above the button on a small screen`() { + setContent(SparkDepositClaim.Later) - val label = composeRule.onNodeWithText("Payment Successful").getUnclippedBoundsInRoot() + val label = composeRule.onNodeWithText("Processing Payment").getUnclippedBoundsInRoot() val button = composeRule.onNodeWithTag("TransferSuccess-button").getUnclippedBoundsInRoot() assertTrue(label.bottom <= button.top) - composeRule.onNodeWithText("SPEED: LATER").assertExists() + composeRule.onNodeWithText("This should take about 30 minutes.", substring = true).assertExists() } @Test - fun `a transfer added after 3 confirmations shows the later speed`() { - setContent(SparkDepositClaim.Unavailable, SparkClaimSpeed.Instant) + fun `no fast transfer shows the coins and the normal speed`() { + setContent(SparkDepositClaim.Unavailable) - composeRule.onNodeWithText("SPEED: LATER").assertExists() + composeRule.onNodeWithText("UNAVAILABLE", substring = true).assertExists() + composeRule.onNodeWithText("Using Normal Transfer Speed").assertExists() + composeRule.onNodeWithText("This should take about 30 minutes.", substring = true).assertExists() + composeRule.onNodeWithTag("SettingUpCoins").assertExists() } @Test - fun `a transfer spark has not seen yet shows the later speed`() { - setContent(SparkDepositClaim.NotSeen, SparkClaimSpeed.Instant) + fun `adding names a few minutes`() { + setContent(SparkDepositClaim.Adding) - composeRule.onNodeWithText("SPEED: LATER").assertExists() + composeRule.onNodeWithText("Adding To Spending Balance").assertExists() + composeRule.onNodeWithText("This should take a few minutes.", substring = true).assertExists() } @Config(sdk = [34], qualifiers = "w448dp-h997dp") @Test fun `the rings fill the width less 16 per side and keep their size when repriced`() { - setContent(SparkDepositClaim.Looking, SparkClaimSpeed.Instant) + setContent(SparkDepositClaim.Looking) val looking = composeRule.onNodeWithTag("TransferAnimation").getUnclippedBoundsInRoot() - setContent(repriced, SparkClaimSpeed.Instant) + setContent(repriced) val repricedRings = composeRule.onNodeWithTag("TransferAnimation").getUnclippedBoundsInRoot() assertEquals(448f - 4 * 16f, looking.width.value, 0.5f) @@ -85,7 +89,7 @@ class SettingUpScreenTest { @Config(sdk = [34], qualifiers = "w448dp-h997dp") @Test fun `the funds moved check takes the share of the screen width ios gives it`() { - setContent(SparkDepositClaim.Claimed, SparkClaimSpeed.Instant) + setContent(SparkDepositClaim.Claimed) val check = composeRule.onNodeWithTag("TransferSuccessCheck").getUnclippedBoundsInRoot() @@ -93,15 +97,14 @@ class SettingUpScreenTest { assertEquals(check.width.value, check.height.value, 0.5f) } - private var claimState by mutableStateOf?>(null) + private var claimState by mutableStateOf(null) - private fun setContent(claim: SparkDepositClaim, speed: SparkClaimSpeed) { + private fun setContent(claim: SparkDepositClaim) { val isFirst = claimState == null - claimState = claim to speed + claimState = claim if (!isFirst) return composeRule.waitForIdle() composeRule.setContent { - val (shownClaim, shownSpeed) = requireNotNull(claimState) - AppThemeSurface { Content(claim = shownClaim, speed = shownSpeed) } + AppThemeSurface { Content(claim = requireNotNull(claimState)) } } } diff --git a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt index 0f2bfb708a..9322d26b20 100644 --- a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt +++ b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModelStore import androidx.lifecycle.viewmodel.initializer import androidx.lifecycle.viewmodel.viewModelFactory import com.synonym.bitkitcore.FeeRates +import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow @@ -43,13 +44,16 @@ import to.bitkit.repositories.OnchainSendNotDispatchedError import to.bitkit.repositories.OnchainSendOutcome import to.bitkit.repositories.OnchainSendPendingError import to.bitkit.repositories.SparkClaimSpeed +import to.bitkit.repositories.SparkDeposit import to.bitkit.repositories.SparkDepositClaim import to.bitkit.repositories.SparkRepo +import to.bitkit.repositories.SparkState import to.bitkit.repositories.WalletRepo import to.bitkit.test.BaseUnitTest import to.bitkit.ui.screens.transfer.SparkFundingContract.SideEffect import to.bitkit.ui.shared.toast.ToastEventBus import kotlin.test.assertEquals +import kotlin.test.assertFalse import kotlin.test.assertTrue @OptIn(ExperimentalCoroutinesApi::class) @@ -62,6 +66,7 @@ class SparkFundingViewModelTest : BaseUnitTest() { private val hwWalletRepo = mock() private val feeRates = FeeRates(fast = 5u, mid = 3u, slow = 1u) private val attemptUpdates = MutableStateFlow(0L) + private val sparkState = MutableStateFlow(SparkState()) private fun createSut() = SparkFundingViewModel(context, walletRepo, lightningRepo, sparkRepo, currencyRepo, hwWalletRepo) @@ -77,6 +82,7 @@ class SparkFundingViewModelTest : BaseUnitTest() { whenever(lightningRepo.onchainSendAttemptUpdates).thenReturn(attemptUpdates) whenever(currencyRepo.currencyState).thenReturn(MutableStateFlow(CurrencyState())) whenever(sparkRepo.depositClaims).thenReturn(MutableStateFlow(emptyMap())) + whenever(sparkRepo.state).thenReturn(sparkState) whenever { sparkRepo.depositAddress() }.thenReturn(Result.success("bcrt1qspark")) whenever { sparkRepo.estimateDepositClaimFeeSats(any()) }.thenReturn(Result.success(1_350uL)) whenever { sparkRepo.estimateMatureClaimFeeSats() }.thenReturn(Result.success(198uL)) @@ -342,6 +348,41 @@ class SparkFundingViewModelTest : BaseUnitTest() { assertEquals(SparkDepositClaim.Later, sut.uiState.value.claim) } + @Test + fun `the deposit counts as seen once spark lists it and the choice on a changed fee is kept`() = test { + whenever { + lightningRepo.sendOnChain( + any(), any(), anyOrNull(), anyOrNull(), anyOrNull(), any(), anyOrNull(), + any(), any(), any(), any(), anyOrNull(), anyOrNull(), anyOrNull(), anyOrNull(), + paymentDeadlineAt = anyOrNull(), + contactPublicKey = anyOrNull(), + approvedMiningFeeSats = anyOrNull(), + ) + }.thenReturn(Result.success(OnchainSendOutcome.Accepted("TXID", 50_000uL))) + val sut = createSut() + advanceUntilIdle() + sut.onAmountChange(50_000) + sut.onAmountContinue() + advanceUntilIdle() + sut.onConfirm() + advanceUntilIdle() + + sparkState.value = SparkState( + deposits = persistentListOf(SparkDeposit("TXID", 50_000uL, isClaimed = false, isListed = false)), + ) + advanceUntilIdle() + assertFalse(sut.uiState.value.isDepositSeen) + + sparkState.value = SparkState(deposits = persistentListOf(SparkDeposit("txid", 50_000uL, isClaimed = false))) + advanceUntilIdle() + assertTrue(sut.uiState.value.isDepositSeen) + + sut.onPayRepriced() + assertTrue(sut.uiState.value.isFeeApproved) + sut.onWait() + assertTrue(sut.uiState.value.hasWaited) + } + @Test fun `a funding that was signed but not accepted opens its recovery instead of an error`() = test { whenever { diff --git a/app/src/test/java/to/bitkit/ui/screens/transfer/TransferStatusTest.kt b/app/src/test/java/to/bitkit/ui/screens/transfer/TransferStatusTest.kt new file mode 100644 index 0000000000..f0ce01d4d6 --- /dev/null +++ b/app/src/test/java/to/bitkit/ui/screens/transfer/TransferStatusTest.kt @@ -0,0 +1,74 @@ +package to.bitkit.ui.screens.transfer + +import org.junit.Test +import to.bitkit.repositories.SparkClaimOffer +import to.bitkit.repositories.SparkDepositClaim +import to.bitkit.ui.screens.transfer.TransferStatusFrame.Adding +import to.bitkit.ui.screens.transfer.TransferStatusFrame.FastUnavailable +import to.bitkit.ui.screens.transfer.TransferStatusFrame.FeeChanged +import to.bitkit.ui.screens.transfer.TransferStatusFrame.NormalSpeed +import to.bitkit.ui.screens.transfer.TransferStatusFrame.PaymentSuccessful +import to.bitkit.ui.screens.transfer.TransferStatusFrame.Processing +import to.bitkit.ui.screens.transfer.TransferStatusFrame.Success +import kotlin.test.assertEquals + +class TransferStatusTest { + @Test + fun `a fast transfer moves through processing, payment successful, adding and success`() { + assertEquals(TransferStatus(Processing), status(SparkDepositClaim.Looking)) + assertEquals(TransferStatus(PaymentSuccessful), status(SparkDepositClaim.Looking, isSeen = true)) + assertEquals(TransferStatus(Adding), status(SparkDepositClaim.Adding, isSeen = true)) + assertEquals(TransferStatus(Success), status(SparkDepositClaim.Claimed, isSeen = true)) + } + + @Test + fun `a normal speed transfer names about 30 minutes until spark sees it and after`() { + assertEquals(TransferStatus(Processing, isNormalSpeed = true), status(SparkDepositClaim.Later)) + assertEquals( + TransferStatus(PaymentSuccessful, isNormalSpeed = true), + status(SparkDepositClaim.Later, isSeen = true), + ) + } + + @Test + fun `a changed fee asks on the last step and approving it stays there while the claim looks again`() { + val repriced = SparkDepositClaim.Repriced( + SparkClaimOffer.Choice("txid", 0u, 2_134uL, 0u, 198uL, 3u) + ) + + assertEquals(TransferStatus(FeeChanged), status(repriced, isSeen = true)) + assertEquals(TransferStatus(Adding), status(SparkDepositClaim.Looking, isSeen = true, isFeeApproved = true)) + } + + @Test + fun `waiting over a changed fee keeps the last step at the normal speed`() { + assertEquals( + TransferStatus(NormalSpeed, isNormalSpeed = true), + status(SparkDepositClaim.Later, isSeen = true, hasWaited = true), + ) + } + + @Test + fun `no fast transfer shows fast transfer unavailable at the normal speed`() { + assertEquals(TransferStatus(FastUnavailable, isNormalSpeed = true), status(SparkDepositClaim.Unavailable)) + } + + @Test + fun `a transfer spark did not see in time stays on processing at the normal speed`() { + assertEquals(TransferStatus(Processing, isNormalSpeed = true), status(SparkDepositClaim.NotSeen)) + } + + @Test + fun `the frames show the design's three steps`() { + val frames = listOf(Processing, PaymentSuccessful, FeeChanged, FastUnavailable, NormalSpeed, Adding) + + assertEquals(listOf(0, 1, 2, 2, 2, 2), frames.map { it.stepIndex }) + } + + private fun status( + claim: SparkDepositClaim, + isSeen: Boolean = false, + isFeeApproved: Boolean = false, + hasWaited: Boolean = false, + ) = transferStatusOf(claim, isSeen, isFeeApproved, hasWaited) +} diff --git a/docs/screens-map.md b/docs/screens-map.md index 547b21ce62..7ef0a7c707 100644 --- a/docs/screens-map.md +++ b/docs/screens-map.md @@ -135,7 +135,7 @@ Frame names are stable across handoff iterations; node ids are not, so the map l | SavingsConfirmScreen.kt | Transfer to Savings (Channel Closure) › Transfer all funds to savings review | | SavingsIntroScreen.kt | Transfer to Savings (Channel Closure) › Transfer to savings | | SavingsProgressScreen.kt | Transfer to Savings (Channel Closure) › Transfer to savings progress 2 | -| SettingUpScreen.kt | Funds In Transfer › Transfer to Spending Progress 1 | +| SettingUpScreen.kt | Funds In Transfer (spark) › Transfer - Processing Payment | | SpendingAmountScreen.kt | Transfer to Spending Balance From Savings (Channel Opening) › Transfer to Spending Input | | SpendingConfirmScreen.kt | Transfer to Spending Balance From Savings (Channel Opening) › Transfer to Spending Confirm | | SpendingIntroScreen.kt | Transfer to Spending Balance From Savings (Channel Opening) › Transfer to Spending Intro | diff --git a/journeys/transfer/spark-transfer-status.xml b/journeys/transfer/spark-transfer-status.xml new file mode 100644 index 0000000000..032b618570 --- /dev/null +++ b/journeys/transfer/spark-transfer-status.xml @@ -0,0 +1,32 @@ + + + Verifies the transfer status screen after a transfer to spending through Spark, against the Figma section + "Funds In Transfer (spark)". Every in-progress frame shows "Transfer Funds" with the menu and no back + button, three steps, the active step's label under them, and one bottom-pinned button. A fast (Instant) + transfer moves through: + "Processing Payment" (step 1, Spark has not seen the deposit), "Payment Successful" (step 1 done, step 2, + Spark lists it), "Adding To Spending Balance" (steps 1 and 2 done, step 3), all under "FUNDS IN TRANSFER" + with "This should take a few minutes.", and ends on "Transfer Successful": "FUNDS MOVED TO SPENDING", the + check, and the OK button. A normal speed (Later) transfer shows the same frames with "This should take about + 30 minutes.". + + Whether Spark reprices the fast transfer or offers none is the provider's call, so the run can't stage the + "FAST TRANSFER FEE CHANGED" frame (coins, "Wait" and "Approve", testTags "SettingUpWait" and "SettingUpPay") + or "FAST TRANSFER UNAVAILABLE" (coins, "Using Normal Transfer Speed"); TransferStatusTest.kt and + SettingUpScreenTest.kt cover them. Spark lists a deposit about a minute after its broadcast, so each step + shows for a few seconds at least. + + Precondition: as in spark-transfer-to-spending.xml, a dev build with Spark connected on its regtest, built + with `ESPLORA_URL` on Spark's regtest chain through `scripts/spark-regtest-esplora.py`, and Savings funded + on that chain with `scripts/spark-regtest-fund.py` (at least 20 000 sats, confirmed). Start on the wallet + home screen. + + + Tap the Savings balance card (testTag "ActivitySavings"), tap "Transfer To Spending" (testTag "TransferToSpending"), tap "25%" (testTag "SpendingAmountQuarter") and tap "Continue" (testTag "SpendingAmountContinue") + Verify "Instant" (testTag "SpendingConfirmInstant") is selected and swipe to confirm + Verify the status screen (testTag "LightningSettingUp") shows "Transfer Funds", "FUNDS IN TRANSFER", "Please wait, your funds transfer is in progress. This should take a few minutes." (testTag "SettingUpText"), step 1 active with "Processing Payment", and "Continue Using Bitkit" (testTag "TransferSuccess-button") + Wait up to 3 minutes for "Payment Successful" with step 1 checked, then for "Adding To Spending Balance" with steps 1 and 2 checked; each keeps the same headline, text and button + Wait up to 3 minutes for "Transfer Successful" (testTag "TransferSuccess"): "FUNDS MOVED TO SPENDING", "Your funds have been transferred and your spending balance is ready to use.", the check (testTag "TransferSuccessCheck") and the OK button (testTag "TransferSuccess-button") + Tap the OK button and verify the wallet home screen shows the higher Spending balance + + From c3654cafbcacac3be69cfb49971175554e2f3acd Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 18:21:56 +0100 Subject: [PATCH 04/10] fix: transfer success button reads awesome The success frame's button shows the design's "Awesome!". The banner journey drops the removed speed line. --- .../java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt | 4 +--- .../main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt | 4 +++- app/src/main/res/values/strings.xml | 1 + journeys/transfer/spark-transfer-status.xml | 6 +++--- journeys/transfer/transfer-banner-opens-progress.xml | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt b/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt index 367bcefec2..cf1e507fd6 100644 --- a/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/transfer/SettingUpScreen.kt @@ -44,7 +44,6 @@ import to.bitkit.ui.screens.transfer.components.ProgressSteps import to.bitkit.ui.screens.transfer.components.TransferAnimationView import to.bitkit.ui.theme.AppThemeSurface import to.bitkit.ui.theme.Colors -import to.bitkit.ui.utils.localizedRandom import to.bitkit.ui.utils.screenWidth import to.bitkit.ui.utils.withAccent import to.bitkit.ui.utils.withAccentBoldBright @@ -225,10 +224,9 @@ private fun Buttons( } return } - val randomOkText = localizedRandom(R.string.common__ok_random) PrimaryButton( text = when (frame) { - TransferStatusFrame.Success -> randomOkText + TransferStatusFrame.Success -> stringResource(R.string.lightning__setting_up__success_button) else -> stringResource(R.string.lightning__setting_up_button) }, onClick = onContinueClick, diff --git a/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt b/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt index ea154e93b8..e68c9d3166 100644 --- a/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/wallets/HomeScreen.kt @@ -409,7 +409,9 @@ fun HomeScreen( onNavigateToSavings = { walletNavController.navigate(Routes.Savings) }, onNavigateToSpending = { walletNavController.navigate(Routes.Spending) }, onSpendingBannerClick = sparkState.inProgressDepositTxid?.let { txid -> - { rootNavController.navigateToTransferProgress(txid) } + { + rootNavController.navigateToTransferProgress(txid) + } }, onSavingsBannerClick = appViewModel::onSparkExitBannerTapped.takeIf { isSparkExiting }, onClickHardwareWallet = { walletNavController.navigateTo(Routes.HardwareWallet(it)) }, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b66cbb104..77c89fb9fa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -407,6 +407,7 @@ Adding To Spending Balance Fast Transfer Fee Changed Using Normal Transfer Speed + Awesome! Please wait, your funds transfer is in progress. This should take <accent>a few minutes.</accent> Please wait, your funds transfer is in progress. This should take <accent>about 30 minutes.</accent> Fast transfer\n<accent>unavailable</accent> diff --git a/journeys/transfer/spark-transfer-status.xml b/journeys/transfer/spark-transfer-status.xml index 032b618570..9e5423e989 100644 --- a/journeys/transfer/spark-transfer-status.xml +++ b/journeys/transfer/spark-transfer-status.xml @@ -7,7 +7,7 @@ "Processing Payment" (step 1, Spark has not seen the deposit), "Payment Successful" (step 1 done, step 2, Spark lists it), "Adding To Spending Balance" (steps 1 and 2 done, step 3), all under "FUNDS IN TRANSFER" with "This should take a few minutes.", and ends on "Transfer Successful": "FUNDS MOVED TO SPENDING", the - check, and the OK button. A normal speed (Later) transfer shows the same frames with "This should take about + check, and "Awesome!". A normal speed (Later) transfer shows the same frames with "This should take about 30 minutes.". Whether Spark reprices the fast transfer or offers none is the provider's call, so the run can't stage the @@ -26,7 +26,7 @@ Verify "Instant" (testTag "SpendingConfirmInstant") is selected and swipe to confirm Verify the status screen (testTag "LightningSettingUp") shows "Transfer Funds", "FUNDS IN TRANSFER", "Please wait, your funds transfer is in progress. This should take a few minutes." (testTag "SettingUpText"), step 1 active with "Processing Payment", and "Continue Using Bitkit" (testTag "TransferSuccess-button") Wait up to 3 minutes for "Payment Successful" with step 1 checked, then for "Adding To Spending Balance" with steps 1 and 2 checked; each keeps the same headline, text and button - Wait up to 3 minutes for "Transfer Successful" (testTag "TransferSuccess"): "FUNDS MOVED TO SPENDING", "Your funds have been transferred and your spending balance is ready to use.", the check (testTag "TransferSuccessCheck") and the OK button (testTag "TransferSuccess-button") - Tap the OK button and verify the wallet home screen shows the higher Spending balance + Wait up to 3 minutes for "Transfer Successful" (testTag "TransferSuccess"): "FUNDS MOVED TO SPENDING", "Your funds have been transferred and your spending balance is ready to use.", the check (testTag "TransferSuccessCheck") and "Awesome!" (testTag "TransferSuccess-button") + Tap "Awesome!" and verify the wallet home screen shows the higher Spending balance diff --git a/journeys/transfer/transfer-banner-opens-progress.xml b/journeys/transfer/transfer-banner-opens-progress.xml index c384403212..0a2667f09b 100644 --- a/journeys/transfer/transfer-banner-opens-progress.xml +++ b/journeys/transfer/transfer-banner-opens-progress.xml @@ -14,7 +14,7 @@ Tap "Later" (testTag "SpendingConfirmLater") and swipe the "Swipe To Transfer" handle (testTag "GRAB") fully to the right Verify the "Funds in transfer" screen (testTag "LightningSettingUp") opens, then tap "Continue Using Bitkit" (testTag "TransferSuccess-button") Verify Home shows the "TRANSFER IN PROGRESS" banner (testTag "ActivityBanner") - Tap the banner and verify "Funds in transfer" (testTag "LightningSettingUp") opens with "Payment Successful" as the current step and the speed (testTag "SettingUpSpeed") reading Later + Tap the banner and verify "Funds in transfer" (testTag "LightningSettingUp") opens at its current step: "Processing Payment", or "Payment Successful" once Spark lists the deposit, with "This should take about 30 minutes." (testTag "SettingUpText") Go back and verify the wallet home screen shows with the banner still visible Relaunch the app, tap the banner and verify the same screen and step open again Mine 3 blocks on the regtest and wait until the screen shows the transfer as done (testTag "TransferSuccess"); tap its button and verify Home no longer shows the banner From 4f253a093c66955174dd5d7425b79175a1ef1f1f Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 19:15:21 +0100 Subject: [PATCH 05/10] fix: reopened transfer status keeps its step --- .../java/to/bitkit/repositories/SparkRepo.kt | 21 +++++++++ .../screens/transfer/SparkFundingViewModel.kt | 26 ++++++++--- .../to/bitkit/repositories/SparkRepoTest.kt | 46 +++++++++++++++++++ .../transfer/SparkFundingViewModelTest.kt | 24 +++++++++- 4 files changed, 109 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt index b8c64c0dd0..9e5a0eb0b6 100644 --- a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt +++ b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt @@ -219,6 +219,11 @@ class SparkRepo @Inject constructor( /** Where the claim of each deposit sent from the transfer flow stands, by txid. */ val depositClaims: StateFlow> = _depositClaims.asStateFlow() + private val _claimChoices = MutableStateFlow>(emptyMap()) + + /** What the user chose over a changed fast transfer fee, by txid, so a reopened status screen keeps its step. */ + val claimChoices: StateFlow> = _claimChoices.asStateFlow() + private val _state = MutableStateFlow(SparkState(isSupported = sparkService.isSupported)) val state: StateFlow = _state.asStateFlow() @@ -304,6 +309,7 @@ class SparkRepo @Inject constructor( hasSyncedActivities = false hasMergedRemoteExitState = false _depositClaims.update { emptyMap() } + _claimChoices.update { emptyMap() } _state.update { SparkState(isSupported = sparkService.isSupported) } val storage = runSuspendCatching { sparkService.wipeStorage(walletIndex) } val exitRecords = runSuspendCatching { @@ -707,6 +713,7 @@ class SparkRepo @Inject constructor( /** Accepts the repriced Instant claim of [txid], at the fee the provider asks now. */ fun payRepricedClaim(txid: String) { val repriced = _depositClaims.value[txid] as? SparkDepositClaim.Repriced ?: return + _claimChoices.update { it + (txid to SparkClaimChoice.Approved) } followDepositClaim(txid, SparkClaimSpeed.Instant, repriced.offer.earlyFeeSats) } @@ -715,6 +722,9 @@ class SparkRepo @Inject constructor( * it, so Spark doesn't still claim it early. */ fun waitForMatureClaim(txid: String) { + if (_depositClaims.value[txid] is SparkDepositClaim.Repriced) { + _claimChoices.update { it + (txid to SparkClaimChoice.Waited) } + } claimJobs.remove(txid)?.cancel() setDepositClaim(txid, SparkDepositClaim.Later) val vout = earlyClaimVouts.remove(txid) ?: return @@ -762,6 +772,14 @@ class SparkRepo @Inject constructor( setDepositClaim(txid, if (isSeen) SparkDepositClaim.Unavailable else SparkDepositClaim.NotSeen) } + /** + * Follows the deposit in [txid] as claimed at 3 confirmations when no claim is followed for it, as after a + * relaunch, so it turns to [SparkDepositClaim.Claimed] once Spark adds it. + */ + fun followShownDeposit(txid: String) { + _depositClaims.update { if (txid in it) it else it + (txid to SparkDepositClaim.Later) } + } + private fun isClaimed(txid: String): Boolean = _state.value.deposits.any { it.isClaimed && it.txid.equals(txid, ignoreCase = true) } @@ -2156,6 +2174,9 @@ enum class SparkClaimSpeed { } /** Where the claim of a deposit the user sent stands. */ +/** What the user chose over a changed fast transfer fee. */ +enum class SparkClaimChoice { Approved, Waited } + sealed interface SparkDepositClaim { /** Spark has not listed the deposit yet, or offers no early claim at this depth. */ data object Looking : SparkDepositClaim diff --git a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt index 48ada133ad..050649f686 100644 --- a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt +++ b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt @@ -40,6 +40,7 @@ import to.bitkit.repositories.OnchainSendBlockedError import to.bitkit.repositories.OnchainSendChangedError import to.bitkit.repositories.OnchainSendOutcome import to.bitkit.repositories.OnchainSendPendingError +import to.bitkit.repositories.SparkClaimChoice import to.bitkit.repositories.SparkClaimSpeed import to.bitkit.repositories.SparkDepositClaim import to.bitkit.repositories.SparkRepo @@ -107,9 +108,17 @@ class SparkFundingViewModel @Inject constructor( } } viewModelScope.launch { - sparkRepo.depositClaims.collect { claims -> - _uiState.update { state -> state.copy(claim = state.txid?.let { claims[it] } ?: state.claim) } - } + combine(sparkRepo.depositClaims, sparkRepo.claimChoices) { claims, choices -> claims to choices } + .collect { (claims, choices) -> + _uiState.update { state -> + val choice = state.txid?.let { choices[it] } + state.copy( + claim = state.txid?.let { claims[it] } ?: state.claim, + isFeeApproved = choice == SparkClaimChoice.Approved, + hasWaited = choice == SparkClaimChoice.Waited, + ) + } + } } viewModelScope.launch { combine(_uiState.map { it.txid }, sparkRepo.state.map { it.deposits }) { txid, deposits -> @@ -123,8 +132,15 @@ class SparkFundingViewModel @Inject constructor( * for, as after a relaunch, is added by Spark at 3 confirmations. */ fun showDeposit(txid: String) { + sparkRepo.followShownDeposit(txid) + val choice = sparkRepo.claimChoices.value[txid] _uiState.update { - it.copy(txid = txid, claim = sparkRepo.depositClaims.value[txid] ?: SparkDepositClaim.Later) + it.copy( + txid = txid, + claim = sparkRepo.depositClaims.value[txid] ?: SparkDepositClaim.Later, + isFeeApproved = choice == SparkClaimChoice.Approved, + hasWaited = choice == SparkClaimChoice.Waited, + ) } } @@ -454,13 +470,11 @@ class SparkFundingViewModel @Inject constructor( fun onPayRepriced() { val txid = _uiState.value.txid ?: return - _uiState.update { it.copy(isFeeApproved = true) } sparkRepo.payRepricedClaim(txid) } fun onWait() { val txid = _uiState.value.txid ?: return - _uiState.update { it.copy(hasWaited = true) } sparkRepo.waitForMatureClaim(txid) } diff --git a/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt b/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt index 28837d44e5..a2a35da650 100644 --- a/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt +++ b/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt @@ -2458,6 +2458,52 @@ class SparkRepoTest : BaseUnitTest() { assertEquals(SparkDepositClaim.Claimed, sut.depositClaims.value["txid"]) } + @Test + fun `a deposit shown with no claim followed, as after a relaunch, reads as claimed once spark claims it`() = test { + whenever(sparkService.isConnected).thenReturn(true) + val sut = createSut() + sut.start(0).getOrThrow() + sut.followShownDeposit("txid") + assertEquals(SparkDepositClaim.Later, sut.depositClaims.value["txid"]) + + whenever { sparkService.listPayments() }.thenReturn(listOf(depositPayment())) + sparkEvents.emit(SdkEvent.ClaimedDeposits(emptyList())) + + assertEquals(SparkDepositClaim.Claimed, sut.depositClaims.value["txid"]) + } + + @Test + fun `the choice over a changed fee is kept for a reopened status screen`() = test { + listDeposit() + whenever { sparkService.fetchClaimQuote("txid", 0u) }.thenReturn(quote(earlyFee = 900uL)) + val sut = createSut() + sut.followDepositClaim("txid", SparkClaimSpeed.Instant, ceilingSats = 500uL) + advanceUntilIdle() + + sut.waitForMatureClaim("txid") + advanceUntilIdle() + assertEquals(SparkClaimChoice.Waited, sut.claimChoices.value["txid"]) + + sut.followShownDeposit("txid") + assertEquals(SparkDepositClaim.Later, sut.depositClaims.value["txid"]) + assertEquals(SparkClaimChoice.Waited, sut.claimChoices.value["txid"]) + } + + @Test + fun `approving a changed fee is kept for a reopened status screen`() = test { + listDeposit() + whenever { sparkService.fetchClaimQuote("txid", 0u) }.thenReturn(quote(earlyFee = 900uL)) + whenever { sparkService.claimDeposit("txid", 0u, 900uL) }.thenReturn(ClaimDepositOutcome.Submitted) + val sut = createSut() + sut.followDepositClaim("txid", SparkClaimSpeed.Instant, ceilingSats = 500uL) + advanceUntilIdle() + + sut.payRepricedClaim("txid") + advanceUntilIdle() + + assertEquals(SparkClaimChoice.Approved, sut.claimChoices.value["txid"]) + } + @Test fun `a payment event settles even when the balance read fails`() = test { whenever(sparkService.isConnected).thenReturn(true) diff --git a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt index 9322d26b20..5f8f1cce34 100644 --- a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt +++ b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt @@ -43,6 +43,7 @@ import to.bitkit.repositories.OnchainSendEvidence import to.bitkit.repositories.OnchainSendNotDispatchedError import to.bitkit.repositories.OnchainSendOutcome import to.bitkit.repositories.OnchainSendPendingError +import to.bitkit.repositories.SparkClaimChoice import to.bitkit.repositories.SparkClaimSpeed import to.bitkit.repositories.SparkDeposit import to.bitkit.repositories.SparkDepositClaim @@ -67,6 +68,7 @@ class SparkFundingViewModelTest : BaseUnitTest() { private val feeRates = FeeRates(fast = 5u, mid = 3u, slow = 1u) private val attemptUpdates = MutableStateFlow(0L) private val sparkState = MutableStateFlow(SparkState()) + private val claimChoices = MutableStateFlow>(emptyMap()) private fun createSut() = SparkFundingViewModel(context, walletRepo, lightningRepo, sparkRepo, currencyRepo, hwWalletRepo) @@ -82,6 +84,7 @@ class SparkFundingViewModelTest : BaseUnitTest() { whenever(lightningRepo.onchainSendAttemptUpdates).thenReturn(attemptUpdates) whenever(currencyRepo.currencyState).thenReturn(MutableStateFlow(CurrencyState())) whenever(sparkRepo.depositClaims).thenReturn(MutableStateFlow(emptyMap())) + whenever(sparkRepo.claimChoices).thenReturn(claimChoices) whenever(sparkRepo.state).thenReturn(sparkState) whenever { sparkRepo.depositAddress() }.thenReturn(Result.success("bcrt1qspark")) whenever { sparkRepo.estimateDepositClaimFeeSats(any()) }.thenReturn(Result.success(1_350uL)) @@ -344,10 +347,24 @@ class SparkFundingViewModelTest : BaseUnitTest() { sut.showDeposit("txid") + verify(sparkRepo).followShownDeposit("txid") assertEquals("txid", sut.uiState.value.txid) assertEquals(SparkDepositClaim.Later, sut.uiState.value.claim) } + @Test + fun `the transfer banner reopens a deposit with the choice made over its changed fee`() = test { + whenever(sparkRepo.depositClaims).thenReturn(MutableStateFlow(mapOf("txid" to SparkDepositClaim.Later))) + claimChoices.value = mapOf("txid" to SparkClaimChoice.Waited) + val sut = createSut() + advanceUntilIdle() + + sut.showDeposit("txid") + + assertTrue(sut.uiState.value.hasWaited) + assertFalse(sut.uiState.value.isFeeApproved) + } + @Test fun `the deposit counts as seen once spark lists it and the choice on a changed fee is kept`() = test { whenever { @@ -377,10 +394,13 @@ class SparkFundingViewModelTest : BaseUnitTest() { advanceUntilIdle() assertTrue(sut.uiState.value.isDepositSeen) - sut.onPayRepriced() + claimChoices.value = mapOf("TXID" to SparkClaimChoice.Approved) + advanceUntilIdle() assertTrue(sut.uiState.value.isFeeApproved) - sut.onWait() + claimChoices.value = mapOf("TXID" to SparkClaimChoice.Waited) + advanceUntilIdle() assertTrue(sut.uiState.value.hasWaited) + assertFalse(sut.uiState.value.isFeeApproved) } @Test From ad7df3fad69f4a648df3701ff46e766107422ea4 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 19:15:22 +0100 Subject: [PATCH 06/10] docs: transfer status journey matches ios --- journeys/README.md | 1 + journeys/transfer/spark-transfer-status.xml | 36 ++++++++++----------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/journeys/README.md b/journeys/README.md index 2ccec967ac..f728833058 100644 --- a/journeys/README.md +++ b/journeys/README.md @@ -202,6 +202,7 @@ Known differences in the corpus, as of the iOS port (synonymdev/bitkit-ios#691): | `transfer/spending-confirm-amount-change.xml` | same file — both platforms show the same "Fees changed" info toast; closing the received sheet re-sizes iOS's Spending Confirm, so the lower amounts can show before the swipe | | `transfer/spark-emergency-exit.xml` | same file, ported in synonymdev/bitkit-ios#1217 — same steps and identifiers; only the description differs, naming the iOS unit tests and the Background App Refresh, Low Power Mode and notification notes in place of Android's battery notes | | `transfer/savings-select-funds.xml` | same file and steps — iOS runs it as J8 on synonymdev/bitkit-ios#1128 | +| `transfer/spark-transfer-status.xml` | same file and steps — the Wait and Approve identifiers differ (Android `SettingUpWait` and `SettingUpPay`, iOS `SparkDepositWait` and `SparkDepositPay`), and each names its own unit tests | | — | `hardware-wallet/transfer-to-spending-over-max.xml` exists only on iOS | ### Running one on iOS diff --git a/journeys/transfer/spark-transfer-status.xml b/journeys/transfer/spark-transfer-status.xml index 9e5423e989..8a2624b770 100644 --- a/journeys/transfer/spark-transfer-status.xml +++ b/journeys/transfer/spark-transfer-status.xml @@ -1,32 +1,30 @@ Verifies the transfer status screen after a transfer to spending through Spark, against the Figma section - "Funds In Transfer (spark)". Every in-progress frame shows "Transfer Funds" with the menu and no back - button, three steps, the active step's label under them, and one bottom-pinned button. A fast (Instant) - transfer moves through: - "Processing Payment" (step 1, Spark has not seen the deposit), "Payment Successful" (step 1 done, step 2, - Spark lists it), "Adding To Spending Balance" (steps 1 and 2 done, step 3), all under "FUNDS IN TRANSFER" - with "This should take a few minutes.", and ends on "Transfer Successful": "FUNDS MOVED TO SPENDING", the - check, and "Awesome!". A normal speed (Later) transfer shows the same frames with "This should take about - 30 minutes.". + "Funds In Transfer (spark)". Every in-progress frame shows the nav title "Transfer Funds" with the menu and no + back button, three steps, the active step's label under them and one bottom-pinned button; headlines show in + capitals. A fast (Instant) transfer moves through "Processing Payment" (step 1, Spark has not listed the + deposit), "Payment Successful" (step 1 done, Spark lists it) and "Adding To Spending Balance" (steps 1 and 2 + done), all with the transfer arrows in dashed rings, and ends on "Transfer Successful" with the check and + "Awesome!". A normal speed (Later) transfer shows the same steps with "This should take about 30 minutes.". - Whether Spark reprices the fast transfer or offers none is the provider's call, so the run can't stage the - "FAST TRANSFER FEE CHANGED" frame (coins, "Wait" and "Approve", testTags "SettingUpWait" and "SettingUpPay") - or "FAST TRANSFER UNAVAILABLE" (coins, "Using Normal Transfer Speed"); TransferStatusTest.kt and - SettingUpScreenTest.kt cover them. Spark lists a deposit about a minute after its broadcast, so each step - shows for a few seconds at least. + Whether Spark reprices the fast transfer or offers none is the provider's call, so those two frames (coins in + place of the arrows) are conditional steps here; TransferStatusTest.kt and SettingUpScreenTest.kt cover every frame. Spark lists a deposit about a + minute after its broadcast, so each step shows for a few seconds at least. - Precondition: as in spark-transfer-to-spending.xml, a dev build with Spark connected on its regtest, built - with `ESPLORA_URL` on Spark's regtest chain through `scripts/spark-regtest-esplora.py`, and Savings funded - on that chain with `scripts/spark-regtest-fund.py` (at least 20 000 sats, confirmed). Start on the wallet - home screen. + Precondition: as in spark-transfer-to-spending.xml: a dev build with Spark connected on its regtest and + reading Bitkit's chain, Savings funded on that chain (at least 20 000 sats, confirmed) and no channels. Start + on the wallet home screen. Tap the Savings balance card (testTag "ActivitySavings"), tap "Transfer To Spending" (testTag "TransferToSpending"), tap "25%" (testTag "SpendingAmountQuarter") and tap "Continue" (testTag "SpendingAmountContinue") Verify "Instant" (testTag "SpendingConfirmInstant") is selected and swipe to confirm - Verify the status screen (testTag "LightningSettingUp") shows "Transfer Funds", "FUNDS IN TRANSFER", "Please wait, your funds transfer is in progress. This should take a few minutes." (testTag "SettingUpText"), step 1 active with "Processing Payment", and "Continue Using Bitkit" (testTag "TransferSuccess-button") + Verify the status screen (testTag "LightningSettingUp") shows "Transfer Funds", the headline "Funds in transfer", the text (testTag "SettingUpText") "Please wait, your funds transfer is in progress. This should take a few minutes.", step 1 active with "Processing Payment", and "Continue Using Bitkit" (testTag "TransferSuccess-button") Wait up to 3 minutes for "Payment Successful" with step 1 checked, then for "Adding To Spending Balance" with steps 1 and 2 checked; each keeps the same headline, text and button - Wait up to 3 minutes for "Transfer Successful" (testTag "TransferSuccess"): "FUNDS MOVED TO SPENDING", "Your funds have been transferred and your spending balance is ready to use.", the check (testTag "TransferSuccessCheck") and "Awesome!" (testTag "TransferSuccess-button") + If the fast transfer fee rose, verify the headline "Fast transfer fee changed", the text "The fast transfer fee is now ₿ …. Approve to access your funds quickly, or wait ±30 min.", the coins, the label "Fast Transfer Fee Changed" and "Wait" (testTag "SettingUpWait") and "Approve" (testTag "SettingUpPay") side by side; tap "Wait" and verify the headline "Funds in transfer", the text ending "about 30 minutes." and the label "Using Normal Transfer Speed" on step 3 + If the fast transfer is unavailable, verify the headline "Fast transfer unavailable", the text ending "about 30 minutes.", the coins and the label "Using Normal Transfer Speed" + Wait up to 3 minutes for "Transfer Successful" (testTag "TransferSuccess"): the headline "Funds moved to spending", "Your funds have been transferred and your spending balance is ready to use.", the check and "Awesome!" (testTag "TransferSuccess-button") Tap "Awesome!" and verify the wallet home screen shows the higher Spending balance + Start another transfer the same way, tap "Later" (testTag "SpendingConfirmLater"), swipe to confirm and verify the text ends "about 30 minutes." with step 1 active and "Processing Payment", then "Payment Successful" once Spark lists the deposit From a1d2f09dd3d5a19100d6f0a5b187ad68cc4fc7fa Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 19:15:22 +0100 Subject: [PATCH 07/10] chore: add changelog fragment --- changelog.d/next/1901.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/next/1901.fixed.md diff --git a/changelog.d/next/1901.fixed.md b/changelog.d/next/1901.fixed.md new file mode 100644 index 0000000000..789311290d --- /dev/null +++ b/changelog.d/next/1901.fixed.md @@ -0,0 +1 @@ +Funds in transfer to spending through Spark follows the new design, and the Home transfer and Savings banners open the transfer or emergency exit in progress. From 5598bea39e1a5216715c0daf8a048572896c7901 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 20:02:54 +0100 Subject: [PATCH 08/10] docs: journeys wait for normal speed and leave by continue --- journeys/transfer/spark-transfer-status.xml | 2 +- journeys/transfer/transfer-banner-opens-progress.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/journeys/transfer/spark-transfer-status.xml b/journeys/transfer/spark-transfer-status.xml index 8a2624b770..39b7f6d101 100644 --- a/journeys/transfer/spark-transfer-status.xml +++ b/journeys/transfer/spark-transfer-status.xml @@ -23,7 +23,7 @@ Wait up to 3 minutes for "Payment Successful" with step 1 checked, then for "Adding To Spending Balance" with steps 1 and 2 checked; each keeps the same headline, text and button If the fast transfer fee rose, verify the headline "Fast transfer fee changed", the text "The fast transfer fee is now ₿ …. Approve to access your funds quickly, or wait ±30 min.", the coins, the label "Fast Transfer Fee Changed" and "Wait" (testTag "SettingUpWait") and "Approve" (testTag "SettingUpPay") side by side; tap "Wait" and verify the headline "Funds in transfer", the text ending "about 30 minutes." and the label "Using Normal Transfer Speed" on step 3 If the fast transfer is unavailable, verify the headline "Fast transfer unavailable", the text ending "about 30 minutes.", the coins and the label "Using Normal Transfer Speed" - Wait up to 3 minutes for "Transfer Successful" (testTag "TransferSuccess"): the headline "Funds moved to spending", "Your funds have been transferred and your spending balance is ready to use.", the check and "Awesome!" (testTag "TransferSuccess-button") + Wait for "Transfer Successful" (testTag "TransferSuccess"), up to 3 minutes for a fast transfer; after Wait or an unavailable fast transfer, mine 3 blocks on the regtest first: the headline "Funds moved to spending", "Your funds have been transferred and your spending balance is ready to use.", the check and "Awesome!" (testTag "TransferSuccess-button") Tap "Awesome!" and verify the wallet home screen shows the higher Spending balance Start another transfer the same way, tap "Later" (testTag "SpendingConfirmLater"), swipe to confirm and verify the text ends "about 30 minutes." with step 1 active and "Processing Payment", then "Payment Successful" once Spark lists the deposit diff --git a/journeys/transfer/transfer-banner-opens-progress.xml b/journeys/transfer/transfer-banner-opens-progress.xml index 0a2667f09b..716a21dad2 100644 --- a/journeys/transfer/transfer-banner-opens-progress.xml +++ b/journeys/transfer/transfer-banner-opens-progress.xml @@ -15,7 +15,7 @@ Verify the "Funds in transfer" screen (testTag "LightningSettingUp") opens, then tap "Continue Using Bitkit" (testTag "TransferSuccess-button") Verify Home shows the "TRANSFER IN PROGRESS" banner (testTag "ActivityBanner") Tap the banner and verify "Funds in transfer" (testTag "LightningSettingUp") opens at its current step: "Processing Payment", or "Payment Successful" once Spark lists the deposit, with "This should take about 30 minutes." (testTag "SettingUpText") - Go back and verify the wallet home screen shows with the banner still visible + Tap "Continue Using Bitkit" (testTag "TransferSuccess-button") and verify the wallet home screen shows with the banner still visible Relaunch the app, tap the banner and verify the same screen and step open again Mine 3 blocks on the regtest and wait until the screen shows the transfer as done (testTag "TransferSuccess"); tap its button and verify Home no longer shows the banner From a80e66977571b0d9ad94a2d0e45dca93b470dc0e Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 20:41:03 +0100 Subject: [PATCH 09/10] docs: journeys wait for confirmations on spark's regtest --- journeys/transfer/spark-transfer-status.xml | 2 +- journeys/transfer/transfer-banner-opens-progress.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/journeys/transfer/spark-transfer-status.xml b/journeys/transfer/spark-transfer-status.xml index 39b7f6d101..b1a13c9ca1 100644 --- a/journeys/transfer/spark-transfer-status.xml +++ b/journeys/transfer/spark-transfer-status.xml @@ -23,7 +23,7 @@ Wait up to 3 minutes for "Payment Successful" with step 1 checked, then for "Adding To Spending Balance" with steps 1 and 2 checked; each keeps the same headline, text and button If the fast transfer fee rose, verify the headline "Fast transfer fee changed", the text "The fast transfer fee is now ₿ …. Approve to access your funds quickly, or wait ±30 min.", the coins, the label "Fast Transfer Fee Changed" and "Wait" (testTag "SettingUpWait") and "Approve" (testTag "SettingUpPay") side by side; tap "Wait" and verify the headline "Funds in transfer", the text ending "about 30 minutes." and the label "Using Normal Transfer Speed" on step 3 If the fast transfer is unavailable, verify the headline "Fast transfer unavailable", the text ending "about 30 minutes.", the coins and the label "Using Normal Transfer Speed" - Wait for "Transfer Successful" (testTag "TransferSuccess"), up to 3 minutes for a fast transfer; after Wait or an unavailable fast transfer, mine 3 blocks on the regtest first: the headline "Funds moved to spending", "Your funds have been transferred and your spending balance is ready to use.", the check and "Awesome!" (testTag "TransferSuccess-button") + Wait for "Transfer Successful" (testTag "TransferSuccess"), up to 3 minutes for a fast transfer; after Wait or an unavailable fast transfer, up to 10 minutes for the deposit's 3 confirmations (Spark's regtest mines about once a minute): the headline "Funds moved to spending", "Your funds have been transferred and your spending balance is ready to use.", the check and "Awesome!" (testTag "TransferSuccess-button") Tap "Awesome!" and verify the wallet home screen shows the higher Spending balance Start another transfer the same way, tap "Later" (testTag "SpendingConfirmLater"), swipe to confirm and verify the text ends "about 30 minutes." with step 1 active and "Processing Payment", then "Payment Successful" once Spark lists the deposit diff --git a/journeys/transfer/transfer-banner-opens-progress.xml b/journeys/transfer/transfer-banner-opens-progress.xml index 716a21dad2..cc434e00cd 100644 --- a/journeys/transfer/transfer-banner-opens-progress.xml +++ b/journeys/transfer/transfer-banner-opens-progress.xml @@ -17,6 +17,6 @@ Tap the banner and verify "Funds in transfer" (testTag "LightningSettingUp") opens at its current step: "Processing Payment", or "Payment Successful" once Spark lists the deposit, with "This should take about 30 minutes." (testTag "SettingUpText") Tap "Continue Using Bitkit" (testTag "TransferSuccess-button") and verify the wallet home screen shows with the banner still visible Relaunch the app, tap the banner and verify the same screen and step open again - Mine 3 blocks on the regtest and wait until the screen shows the transfer as done (testTag "TransferSuccess"); tap its button and verify Home no longer shows the banner + Wait up to 10 minutes for the deposit's 3 confirmations (Spark's regtest mines about once a minute) until the screen shows the transfer as done (testTag "TransferSuccess"); tap its button and verify Home no longer shows the banner From a6ade5b1820fbc073e17c512cac479d4fbe8dbf8 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Fri, 13 Nov 2026 13:58:39 +0100 Subject: [PATCH 10/10] fix: transfer status never steps back while spark claims Spark drops a deposit from its list while claiming it, so the status screen went back to Processing Payment for a moment before Transfer Successful. A deposit once listed now stays seen. The journey treats Adding To Spending Balance as a step Spark's regtest may skip. --- app/src/main/java/to/bitkit/repositories/SparkRepo.kt | 2 +- .../bitkit/ui/screens/transfer/SparkFundingViewModel.kt | 7 ++++++- .../ui/screens/transfer/SparkFundingViewModelTest.kt | 8 +++++++- journeys/transfer/spark-transfer-status.xml | 7 ++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt index 9e5a0eb0b6..639089682c 100644 --- a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt +++ b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt @@ -2173,10 +2173,10 @@ enum class SparkClaimSpeed { Later, } -/** Where the claim of a deposit the user sent stands. */ /** What the user chose over a changed fast transfer fee. */ enum class SparkClaimChoice { Approved, Waited } +/** Where the claim of a deposit the user sent stands. */ sealed interface SparkDepositClaim { /** Spark has not listed the deposit yet, or offers no early claim at this depth. */ data object Looking : SparkDepositClaim diff --git a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt index 050649f686..106a47ea12 100644 --- a/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt +++ b/app/src/main/java/to/bitkit/ui/screens/transfer/SparkFundingViewModel.kt @@ -121,8 +121,13 @@ class SparkFundingViewModel @Inject constructor( } } viewModelScope.launch { + // Spark drops a deposit from its list while claiming it, so a deposit once listed stays seen. + var seenTxid: String? = null combine(_uiState.map { it.txid }, sparkRepo.state.map { it.deposits }) { txid, deposits -> - txid != null && deposits.any { it.isListed && it.txid.equals(txid, ignoreCase = true) } + if (txid != null && deposits.any { it.isListed && it.txid.equals(txid, ignoreCase = true) }) { + seenTxid = txid + } + txid != null && txid == seenTxid }.distinctUntilChanged().collect { isSeen -> _uiState.update { it.copy(isDepositSeen = isSeen) } } } } diff --git a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt index 5f8f1cce34..8018f7367f 100644 --- a/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt +++ b/app/src/test/java/to/bitkit/ui/screens/transfer/SparkFundingViewModelTest.kt @@ -366,7 +366,7 @@ class SparkFundingViewModelTest : BaseUnitTest() { } @Test - fun `the deposit counts as seen once spark lists it and the choice on a changed fee is kept`() = test { + fun `the deposit stays seen once spark lists it and the choice on a changed fee is kept`() = test { whenever { lightningRepo.sendOnChain( any(), any(), anyOrNull(), anyOrNull(), anyOrNull(), any(), anyOrNull(), @@ -394,6 +394,12 @@ class SparkFundingViewModelTest : BaseUnitTest() { advanceUntilIdle() assertTrue(sut.uiState.value.isDepositSeen) + sparkState.value = SparkState( + deposits = persistentListOf(SparkDeposit("TXID", 50_000uL, isClaimed = false, isListed = false)), + ) + advanceUntilIdle() + assertTrue(sut.uiState.value.isDepositSeen) + claimChoices.value = mapOf("TXID" to SparkClaimChoice.Approved) advanceUntilIdle() assertTrue(sut.uiState.value.isFeeApproved) diff --git a/journeys/transfer/spark-transfer-status.xml b/journeys/transfer/spark-transfer-status.xml index b1a13c9ca1..67d9e14e7d 100644 --- a/journeys/transfer/spark-transfer-status.xml +++ b/journeys/transfer/spark-transfer-status.xml @@ -9,8 +9,9 @@ "Awesome!". A normal speed (Later) transfer shows the same steps with "This should take about 30 minutes.". Whether Spark reprices the fast transfer or offers none is the provider's call, so those two frames (coins in - place of the arrows) are conditional steps here; TransferStatusTest.kt and SettingUpScreenTest.kt cover every frame. Spark lists a deposit about a - minute after its broadcast, so each step shows for a few seconds at least. + place of the arrows) are conditional steps here; TransferStatusTest.kt and SettingUpScreenTest.kt cover every frame. On Spark's regtest a fast + transfer can finish within seconds, so "Processing Payment" may show only briefly and Spark may claim the + deposit before "Adding To Spending Balance" shows; a step once passed never comes back. Precondition: as in spark-transfer-to-spending.xml: a dev build with Spark connected on its regtest and reading Bitkit's chain, Savings funded on that chain (at least 20 000 sats, confirmed) and no channels. Start @@ -20,7 +21,7 @@ Tap the Savings balance card (testTag "ActivitySavings"), tap "Transfer To Spending" (testTag "TransferToSpending"), tap "25%" (testTag "SpendingAmountQuarter") and tap "Continue" (testTag "SpendingAmountContinue") Verify "Instant" (testTag "SpendingConfirmInstant") is selected and swipe to confirm Verify the status screen (testTag "LightningSettingUp") shows "Transfer Funds", the headline "Funds in transfer", the text (testTag "SettingUpText") "Please wait, your funds transfer is in progress. This should take a few minutes.", step 1 active with "Processing Payment", and "Continue Using Bitkit" (testTag "TransferSuccess-button") - Wait up to 3 minutes for "Payment Successful" with step 1 checked, then for "Adding To Spending Balance" with steps 1 and 2 checked; each keeps the same headline, text and button + Wait up to 3 minutes for "Payment Successful" with step 1 checked, then, if it shows before the transfer ends, "Adding To Spending Balance" with steps 1 and 2 checked; each keeps the same headline, text and button, and the label never goes back to an earlier step If the fast transfer fee rose, verify the headline "Fast transfer fee changed", the text "The fast transfer fee is now ₿ …. Approve to access your funds quickly, or wait ±30 min.", the coins, the label "Fast Transfer Fee Changed" and "Wait" (testTag "SettingUpWait") and "Approve" (testTag "SettingUpPay") side by side; tap "Wait" and verify the headline "Funds in transfer", the text ending "about 30 minutes." and the label "Using Normal Transfer Speed" on step 3 If the fast transfer is unavailable, verify the headline "Fast transfer unavailable", the text ending "about 30 minutes.", the coins and the label "Using Normal Transfer Speed" Wait for "Transfer Successful" (testTag "TransferSuccess"), up to 3 minutes for a fast transfer; after Wait or an unavailable fast transfer, up to 10 minutes for the deposit's 3 confirmations (Spark's regtest mines about once a minute): the headline "Funds moved to spending", "Your funds have been transferred and your spending balance is ready to use.", the check and "Awesome!" (testTag "TransferSuccess-button")