From 75043a4ef8090c84484b832db098b49f781f4200 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 18 Nov 2026 05:23:51 +0100 Subject: [PATCH 1/6] fix: start pay to confirm once the fees are covered Pay to confirm starts the force transfer on its own as soon as a read finds the fees covered, on entry too, as in the frame without Continue. A failed start shows Try again and never retries by itself; a running start spins the button. Verified: swiftformat --lint, validate-translations, SparkExitMath, Sweep, Record, Review and Driver unit tests on the iOS simulator --- .../Services/SparkExit/SparkExitFunding.swift | 10 +++---- .../Settings/Advanced/SparkExitViews.swift | 28 ++++++++----------- BitkitTests/SparkExitTests.swift | 25 ++++++++--------- 3 files changed, 27 insertions(+), 36 deletions(-) diff --git a/Bitkit/Services/SparkExit/SparkExitFunding.swift b/Bitkit/Services/SparkExit/SparkExitFunding.swift index 3a59185aa..d851fef3f 100644 --- a/Bitkit/Services/SparkExit/SparkExitFunding.swift +++ b/Bitkit/Services/SparkExit/SparkExitFunding.swift @@ -439,11 +439,11 @@ enum SparkExitMath { return SparkExitReturned(spendingSats: received - funding, feesSats: sweptLeftoverSats(record).saturatingAdd(funding)) } - /// Pay to confirm starts the exit on its own, once, for a payment that arrived after its first read of the funding - /// address (`entrySeenCount`, nil until that read) and covers the funding. Funding already there when it opened - /// waits for a tap, so nothing starts unseen. A start already running, such as one Continue began, is the only one. - static func canAutoStartFunding(isFunded: Bool, isStarting: Bool, hasAutoStarted: Bool, entrySeenCount: Int?, seenCount: Int) -> Bool { - isFunded && !isStarting && !hasAutoStarted && entrySeenCount.map { seenCount > $0 } == true + /// Pay to confirm starts the exit on its own, once a visit, as soon as a read of the funding address this visit + /// finds the funding covered, funding already there on entry included. A failed start waits for Try again, and a + /// start already running is the only one. + static func canAutoStartFunding(isFunded: Bool, isStarting: Bool, hasAutoStarted: Bool, hasReadFunding: Bool) -> Bool { + isFunded && !isStarting && !hasAutoStarted && hasReadFunding } /// The exit's sweeps to savings: the recovery's, else the one that landed before a retry replaced it, and those of diff --git a/Bitkit/Views/Settings/Advanced/SparkExitViews.swift b/Bitkit/Views/Settings/Advanced/SparkExitViews.swift index 7677a818a..95065b20c 100644 --- a/Bitkit/Views/Settings/Advanced/SparkExitViews.swift +++ b/Bitkit/Views/Settings/Advanced/SparkExitViews.swift @@ -356,15 +356,14 @@ struct SparkExitFundingView: View { } } -/// The emergency fees paid from another wallet to the funding address: the force transfer starts on its own once a -/// payment that covers them arrives here; fees already there wait for a tap on Continue. +/// The emergency fees paid from another wallet to the funding address: the force transfer starts on its own once the +/// funding address holds them, on entry too; a failed start shows Try again. struct SparkExitPayView: View { @EnvironmentObject var app: AppViewModel @EnvironmentObject var navigation: NavigationViewModel - /// The payments the first read of the funding address found this visit; only one arriving after them starts the - /// exit on its own. - @State private var entrySeenCount: Int? + /// The funding address was read this visit, so what it holds is current. + @State private var hasReadFunding = false /// A start ran this visit, on its own or from a tap: a failed one shows its error and waits for a tap, never /// retrying by itself. @State private var hasAutoStarted = false @@ -395,8 +394,7 @@ struct SparkExitPayView: View { isFunded: isFunded, isStarting: isStarting, hasAutoStarted: hasAutoStarted, - entrySeenCount: entrySeenCount, - seenCount: exit.fundingSeenCount + hasReadFunding: hasReadFunding ) } @@ -425,11 +423,9 @@ struct SparkExitPayView: View { .padding(.bottom, 32) } - // Funds already at the address on entry wait for a tap; a failed start offers Try Again. - if isFunded, !isStarting, !canAutoStart { - CustomButton(title: t(hasAutoStarted ? "common__try_again" : "common__continue")) { - // The visit's start is spent: a payment arriving after a failed start never starts one by itself. - hasAutoStarted = true + // A failed start offers Try again. A start can wait minutes for Spark, so its button spins until it ends. + if isStarting || (isFunded && hasAutoStarted) { + CustomButton(title: t("common__try_again"), isLoading: isStarting) { start() } .padding(.bottom, 16) @@ -445,12 +441,10 @@ struct SparkExitPayView: View { .padding(.horizontal, 16) .bottomSafeAreaPadding() .task { - entrySeenCount = nil + hasReadFunding = false hasAutoStarted = false await exit.watchFundingAddress { - if entrySeenCount == nil { - entrySeenCount = exit.fundingSeenCount - } + hasReadFunding = true } } .onChange(of: canAutoStart) { _, canAutoStart in @@ -460,7 +454,7 @@ struct SparkExitPayView: View { } } - /// Claims the one start this screen runs at a time before its task begins, so neither a tap nor a payment can + /// Claims the one start this screen runs at a time before its task begins, so neither a tap nor the funding can /// launch a second. private func start() { guard !isStarting else { return } diff --git a/BitkitTests/SparkExitTests.swift b/BitkitTests/SparkExitTests.swift index 5d1c1af32..572e4651f 100644 --- a/BitkitTests/SparkExitTests.swift +++ b/BitkitTests/SparkExitTests.swift @@ -3317,20 +3317,17 @@ final class SparkExitMathTests: XCTestCase { XCTAssertEqual(SparkExitMath.neededSats(record, state: .ask(sats: 500)), 500) } - /// Pay to confirm starts on its own only for a covering payment that arrives while it shows, and only once. - func testPayToConfirmAutoStartsOnlyForAPaymentThatArrivesWhileItShows() { - // Before its first read, and for funding already there on entry, it waits for a tap. - XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: false, entrySeenCount: nil, seenCount: 1)) - XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: false, entrySeenCount: 1, seenCount: 1)) - // A payment arriving after the first read starts it once it covers the funding. - XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: false, isStarting: false, hasAutoStarted: false, entrySeenCount: 0, seenCount: 1)) - XCTAssertTrue(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: false, entrySeenCount: 0, seenCount: 1)) - XCTAssertTrue(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: false, entrySeenCount: 1, seenCount: 2)) - // A failed auto-start waits for Try Again. - XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: true, entrySeenCount: 0, seenCount: 2)) - // A start already running, such as one Continue began, is never joined by a second. - XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: true, hasAutoStarted: false, entrySeenCount: 0, seenCount: 1)) - XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: true, hasAutoStarted: false, entrySeenCount: 1, seenCount: 2)) + /// Pay to confirm starts on its own once its read finds the funding covered, on entry too, and only once a visit. + func testPayToConfirmAutoStartsOnceTheFundingIsCovered() { + // Before its first read this visit, it waits. + XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: false, hasReadFunding: false)) + // Funding already there on entry, or arriving later, starts it once covered. + XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: false, isStarting: false, hasAutoStarted: false, hasReadFunding: true)) + XCTAssertTrue(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: false, hasReadFunding: true)) + // A failed start waits for Try again. + XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: false, hasAutoStarted: true, hasReadFunding: true)) + // A start already running is never joined by a second. + XCTAssertFalse(SparkExitMath.canAutoStartFunding(isFunded: true, isStarting: true, hasAutoStarted: false, hasReadFunding: true)) } /// qa-03: 2,000 of 4,348 at the address showed no hint until the whole sum arrived. From ec3c5b39bc8aa7a84d2a9a0bfca2d3d9ff1c51fb Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 18 Nov 2026 05:23:52 +0100 Subject: [PATCH 2/6] fix: trim completed force transfer progress to figma The done text drops the small amounts left on Spark, and a completed exit names only leftover fee funding that stays at the address: what a sweep sent back is in the returned note. Verified: swiftformat --lint, validate-translations, SparkExitMath, Sweep, Record, Review and Driver unit tests on the iOS simulator --- .../Localization/ar.lproj/Localizable.strings | 1 - .../Localization/ca.lproj/Localizable.strings | 1 - .../Localization/cs.lproj/Localizable.strings | 1 - .../Localization/de.lproj/Localizable.strings | 1 - .../Localization/el.lproj/Localizable.strings | 1 - .../Localization/en.lproj/Localizable.strings | 1 - .../es-419.lproj/Localizable.strings | 1 - .../Localization/es.lproj/Localizable.strings | 1 - .../Localization/fr.lproj/Localizable.strings | 1 - .../Localization/it.lproj/Localizable.strings | 1 - .../Localization/nl.lproj/Localizable.strings | 1 - .../Localization/pl.lproj/Localizable.strings | 1 - .../pt-BR.lproj/Localizable.strings | 1 - .../Localization/pt.lproj/Localizable.strings | 1 - .../Localization/ru.lproj/Localizable.strings | 1 - .../Settings/Advanced/SparkExitViews.swift | 38 ++++++++++++++----- 16 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Bitkit/Resources/Localization/ar.lproj/Localizable.strings b/Bitkit/Resources/Localization/ar.lproj/Localizable.strings index b1b0c1edd..1cec5f24f 100644 --- a/Bitkit/Resources/Localization/ar.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/ar.lproj/Localizable.strings @@ -339,7 +339,6 @@ "lightning__spark_exit__step_sweep" = "الإرسال إلى رصيد المدخرات"; "lightning__spark_exit__done_title" = "اكتمل\nالتحويل"; "lightning__spark_exit__done_text" = "تم تحويل أموالك إلى رصيد مدخراتك."; -"lightning__spark_exit__partial_text" = "بقيت {count} مبالغ صغيرة على Spark."; "lightning__spark_exit__failed_leaves" = "نقل مشغّلو Spark مبلغ {amount} إلى السلسلة وهو ليس على Spark. لا يزال بإمكان المشغّلين تحريره لك."; "lightning__spark_exit__leftover" = "ما زال {amount} من رسوم الطوارئ في {address}."; "lightning__spark_exit__leftover_swept" = "أُرسل {amount} من رسوم الطوارئ غير المستخدمة إلى المدخرات."; diff --git a/Bitkit/Resources/Localization/ca.lproj/Localizable.strings b/Bitkit/Resources/Localization/ca.lproj/Localizable.strings index b3648c987..92d1ba0ea 100644 --- a/Bitkit/Resources/Localization/ca.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/ca.lproj/Localizable.strings @@ -376,7 +376,6 @@ "lightning__spark_exit__step_sweep" = "Enviat al saldo d'estalvis"; "lightning__spark_exit__done_title" = "Transferència\ncompletada"; "lightning__spark_exit__done_text" = "Els teus fons s'han transferit al teu saldo d'estalvis."; -"lightning__spark_exit__partial_text" = "{count} quantitats petites s'han quedat a Spark."; "lightning__spark_exit__failed_leaves" = "Els operadors de Spark han mogut {amount} on-chain i no és a Spark. Els operadors encara te'ls poden alliberar."; "lightning__spark_exit__leftover" = "{amount} de comissions d'emergència encara són a {address}."; "lightning__spark_exit__leftover_swept" = "{amount} de comissions d'emergència no utilitzades s'han enviat als estalvis."; diff --git a/Bitkit/Resources/Localization/cs.lproj/Localizable.strings b/Bitkit/Resources/Localization/cs.lproj/Localizable.strings index 2149a94f9..7d20e2bd9 100644 --- a/Bitkit/Resources/Localization/cs.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/cs.lproj/Localizable.strings @@ -392,7 +392,6 @@ "lightning__spark_exit__step_sweep" = "Odesláno do úspor"; "lightning__spark_exit__done_title" = "Převod\ndokončen"; "lightning__spark_exit__done_text" = "Vaše prostředky byly převedeny do úspor."; -"lightning__spark_exit__partial_text" = "Malé částky ({count}) zůstaly na Spark."; "lightning__spark_exit__failed_leaves" = "{amount} přesunuli operátoři Spark na blockchain a není na Spark. Operátoři vám ji stále mohou uvolnit."; "lightning__spark_exit__leftover" = "{amount} z nouzových poplatků je stále na adrese {address}."; "lightning__spark_exit__leftover_swept" = "{amount} nepoužitých nouzových poplatků bylo odesláno do úspor."; diff --git a/Bitkit/Resources/Localization/de.lproj/Localizable.strings b/Bitkit/Resources/Localization/de.lproj/Localizable.strings index 8b2eaa456..5d085d3dd 100644 --- a/Bitkit/Resources/Localization/de.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/de.lproj/Localizable.strings @@ -390,7 +390,6 @@ "lightning__spark_exit__step_sweep" = "An Sparkonto gesendet"; "lightning__spark_exit__done_title" = "Übertragung\nabgeschlossen"; "lightning__spark_exit__done_text" = "Deine Mittel wurden auf dein Sparkonto übertragen."; -"lightning__spark_exit__partial_text" = "{count} kleine Beträge sind auf Spark geblieben."; "lightning__spark_exit__failed_leaves" = "{amount} wurden von den Spark-Betreibern on-chain verschoben und sind nicht auf Spark. Die Betreiber können sie dir weiterhin freigeben."; "lightning__spark_exit__leftover" = "{amount} der Notfallgebühren liegt noch bei {address}."; "lightning__spark_exit__leftover_swept" = "{amount} nicht verbrauchte Notfallgebühren wurden an dein Sparkonto gesendet."; diff --git a/Bitkit/Resources/Localization/el.lproj/Localizable.strings b/Bitkit/Resources/Localization/el.lproj/Localizable.strings index e8e7a7539..225ae2950 100644 --- a/Bitkit/Resources/Localization/el.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/el.lproj/Localizable.strings @@ -363,7 +363,6 @@ "lightning__spark_exit__step_sweep" = "Στάλθηκε στο υπόλοιπο αποταμιεύσεων"; "lightning__spark_exit__done_title" = "Η μεταφορά\nολοκληρώθηκε"; "lightning__spark_exit__done_text" = "Τα κεφάλαιά σας μεταφέρθηκαν στο υπόλοιπο αποταμιεύσεών σας."; -"lightning__spark_exit__partial_text" = "{count} μικρά ποσά παρέμειναν στο Spark."; "lightning__spark_exit__failed_leaves" = "{amount} μεταφέρθηκε on-chain από τους διαχειριστές του Spark και δεν βρίσκεται στο Spark. Οι διαχειριστές μπορούν ακόμη να το αποδεσμεύσουν σε εσάς."; "lightning__spark_exit__leftover" = "Τα {amount} έκτακτων τελών βρίσκονται ακόμα στη διεύθυνση {address}."; "lightning__spark_exit__leftover_swept" = "Τα {amount} αχρησιμοποίητων έκτακτων τελών στάλθηκαν στις αποταμιεύσεις."; diff --git a/Bitkit/Resources/Localization/en.lproj/Localizable.strings b/Bitkit/Resources/Localization/en.lproj/Localizable.strings index 24320fe71..ed2215b06 100644 --- a/Bitkit/Resources/Localization/en.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/en.lproj/Localizable.strings @@ -419,7 +419,6 @@ "lightning__spark_exit__step_sweep" = "Sent to savings balance"; "lightning__spark_exit__done_title" = "Transfer\ncompleted"; "lightning__spark_exit__done_text" = "Your funds have been transferred to your savings balance."; -"lightning__spark_exit__partial_text" = "{count} small amounts stayed on Spark."; "lightning__spark_exit__failed_leaves" = "{amount} was moved on-chain by the Spark operators and is not on Spark. The operators can still release it to you."; "lightning__spark_exit__leftover" = "{amount} of emergency fees is still at {address}."; "lightning__spark_exit__leftover_swept" = "{amount} of unused emergency fees was sent to savings."; diff --git a/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings b/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings index e04949552..e6e276304 100644 --- a/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/es-419.lproj/Localizable.strings @@ -393,7 +393,6 @@ "lightning__spark_exit__step_sweep" = "Enviado al saldo de ahorros"; "lightning__spark_exit__done_title" = "Transferencia\ncompletada"; "lightning__spark_exit__done_text" = "Tus fondos se transfirieron a tu saldo de ahorros."; -"lightning__spark_exit__partial_text" = "{count} cantidades pequeñas se quedaron en Spark."; "lightning__spark_exit__failed_leaves" = "Los operadores de Spark movieron {amount} on-chain y ya no está en Spark. Los operadores todavía pueden liberártelo."; "lightning__spark_exit__leftover" = "{amount} de comisiones de emergencia sigue en {address}."; "lightning__spark_exit__leftover_swept" = "{amount} de comisiones de emergencia sin usar se envió a tus ahorros."; diff --git a/Bitkit/Resources/Localization/es.lproj/Localizable.strings b/Bitkit/Resources/Localization/es.lproj/Localizable.strings index ef8dcd92f..e586c4011 100644 --- a/Bitkit/Resources/Localization/es.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/es.lproj/Localizable.strings @@ -377,7 +377,6 @@ "lightning__spark_exit__step_sweep" = "Enviado al saldo de ahorros"; "lightning__spark_exit__done_title" = "Transferencia\ncompletada"; "lightning__spark_exit__done_text" = "Tus fondos se han transferido a tu saldo de ahorros."; -"lightning__spark_exit__partial_text" = "{count} cantidades pequeñas se quedaron en Spark."; "lightning__spark_exit__failed_leaves" = "Los operadores de Spark movieron {amount} on-chain y ya no está en Spark. Los operadores todavía pueden liberártelo."; "lightning__spark_exit__leftover" = "{amount} de comisiones de emergencia sigue en {address}."; "lightning__spark_exit__leftover_swept" = "Se han enviado a tus ahorros {amount} de comisiones de emergencia sin usar."; diff --git a/Bitkit/Resources/Localization/fr.lproj/Localizable.strings b/Bitkit/Resources/Localization/fr.lproj/Localizable.strings index 19cab475f..17c5f0e5a 100644 --- a/Bitkit/Resources/Localization/fr.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/fr.lproj/Localizable.strings @@ -393,7 +393,6 @@ "lightning__spark_exit__step_sweep" = "Envoyé vers le solde d'épargne"; "lightning__spark_exit__done_title" = "Transfert\nterminé"; "lightning__spark_exit__done_text" = "Vos fonds ont été transférés vers votre solde d'épargne."; -"lightning__spark_exit__partial_text" = "{count} petits montants sont restés sur Spark."; "lightning__spark_exit__failed_leaves" = "{amount} a été déplacé on-chain par les opérateurs Spark et n'est plus sur Spark. Les opérateurs peuvent encore vous le libérer."; "lightning__spark_exit__leftover" = "{amount} de frais d'urgence se trouvent encore à {address}."; "lightning__spark_exit__leftover_swept" = "{amount} de frais d'urgence inutilisés ont été envoyés vers l'épargne."; diff --git a/Bitkit/Resources/Localization/it.lproj/Localizable.strings b/Bitkit/Resources/Localization/it.lproj/Localizable.strings index 5aa453bbb..aa7dd4303 100644 --- a/Bitkit/Resources/Localization/it.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/it.lproj/Localizable.strings @@ -386,7 +386,6 @@ "lightning__spark_exit__step_sweep" = "Inviato al saldo dei risparmi"; "lightning__spark_exit__done_title" = "Trasferimento\ncompletato"; "lightning__spark_exit__done_text" = "I tuoi fondi sono stati trasferiti nel saldo dei tuoi risparmi."; -"lightning__spark_exit__partial_text" = "{count} piccoli importi sono rimasti su Spark."; "lightning__spark_exit__failed_leaves" = "{amount} è stato spostato on-chain dagli operatori Spark e non è su Spark. Gli operatori possono ancora rilasciarlo a te."; "lightning__spark_exit__leftover" = "{amount} di commissioni di emergenza si trova ancora su {address}."; "lightning__spark_exit__leftover_swept" = "{amount} di commissioni di emergenza non utilizzate è stato inviato ai risparmi."; diff --git a/Bitkit/Resources/Localization/nl.lproj/Localizable.strings b/Bitkit/Resources/Localization/nl.lproj/Localizable.strings index 99162b04f..8c2147e3e 100644 --- a/Bitkit/Resources/Localization/nl.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/nl.lproj/Localizable.strings @@ -390,7 +390,6 @@ "lightning__spark_exit__step_sweep" = "Naar spaargeld gestuurd"; "lightning__spark_exit__done_title" = "Overboeking\nvoltooid"; "lightning__spark_exit__done_text" = "Uw geld is overgeboekt naar uw spaargeld."; -"lightning__spark_exit__partial_text" = "{count} kleine bedragen zijn op Spark gebleven."; "lightning__spark_exit__failed_leaves" = "{amount} is door de Spark-operators on-chain gezet en staat niet op Spark. De operators kunnen het nog steeds aan je vrijgeven."; "lightning__spark_exit__leftover" = "{amount} aan noodkosten staat nog op {address}."; "lightning__spark_exit__leftover_swept" = "{amount} aan ongebruikte noodkosten is naar spaargeld gestuurd."; diff --git a/Bitkit/Resources/Localization/pl.lproj/Localizable.strings b/Bitkit/Resources/Localization/pl.lproj/Localizable.strings index 57504e077..38f5aff25 100644 --- a/Bitkit/Resources/Localization/pl.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/pl.lproj/Localizable.strings @@ -392,7 +392,6 @@ "lightning__spark_exit__step_sweep" = "Wysłano na saldo oszczędności"; "lightning__spark_exit__done_title" = "Transfer\nzakończony"; "lightning__spark_exit__done_text" = "Twoje środki zostały przesłane na saldo oszczędności."; -"lightning__spark_exit__partial_text" = "Małe kwoty pozostałe na Spark: {count}."; "lightning__spark_exit__failed_leaves" = "{amount} zostało przeniesione on-chain przez operatorów Spark i nie jest na Spark. Operatorzy wciąż mogą Ci je wydać."; "lightning__spark_exit__leftover" = "{amount} opłat awaryjnych nadal znajduje się pod adresem {address}."; "lightning__spark_exit__leftover_swept" = "{amount} niewykorzystanych opłat awaryjnych zostało wysłane do oszczędności."; diff --git a/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings b/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings index 4b0e29568..c0ea27f7a 100644 --- a/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/pt-BR.lproj/Localizable.strings @@ -392,7 +392,6 @@ "lightning__spark_exit__step_sweep" = "Enviado para o saldo de poupança"; "lightning__spark_exit__done_title" = "Transferência\nconcluída"; "lightning__spark_exit__done_text" = "Seus fundos foram transferidos para o seu saldo de poupança."; -"lightning__spark_exit__partial_text" = "{count} valores pequenos ficaram na Spark."; "lightning__spark_exit__failed_leaves" = "{amount} foi movido on-chain pelos operadores da Spark e não está na Spark. Os operadores ainda podem liberá-lo para você."; "lightning__spark_exit__leftover" = "{amount} de taxas de emergência ainda está em {address}."; "lightning__spark_exit__leftover_swept" = "{amount} de taxas de emergência não utilizadas foi enviado para a poupança."; diff --git a/Bitkit/Resources/Localization/pt.lproj/Localizable.strings b/Bitkit/Resources/Localization/pt.lproj/Localizable.strings index 5097ee8f9..59804118a 100644 --- a/Bitkit/Resources/Localization/pt.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/pt.lproj/Localizable.strings @@ -390,7 +390,6 @@ "lightning__spark_exit__step_sweep" = "Enviado para o saldo de poupança"; "lightning__spark_exit__done_title" = "Transferência\nconcluída"; "lightning__spark_exit__done_text" = "Os seus fundos foram transferidos para o seu saldo de poupança."; -"lightning__spark_exit__partial_text" = "{count} montantes pequenos ficaram na Spark."; "lightning__spark_exit__failed_leaves" = "{amount} foi movido on-chain pelos operadores da Spark e não está na Spark. Os operadores ainda o podem libertar para si."; "lightning__spark_exit__leftover" = "{amount} de taxas de emergência ainda está em {address}."; "lightning__spark_exit__leftover_swept" = "{amount} de taxas de emergência não utilizadas foi enviado para a poupança."; diff --git a/Bitkit/Resources/Localization/ru.lproj/Localizable.strings b/Bitkit/Resources/Localization/ru.lproj/Localizable.strings index 49f2fcee4..b29b8c897 100644 --- a/Bitkit/Resources/Localization/ru.lproj/Localizable.strings +++ b/Bitkit/Resources/Localization/ru.lproj/Localizable.strings @@ -387,7 +387,6 @@ "lightning__spark_exit__step_sweep" = "Отправлено на баланс сбережений"; "lightning__spark_exit__done_title" = "Перевод\nзавершён"; "lightning__spark_exit__done_text" = "Ваши средства переведены на баланс сбережений."; -"lightning__spark_exit__partial_text" = "Небольших сумм, оставшихся в Spark: {count}."; "lightning__spark_exit__failed_leaves" = "{amount} перевели ончейн операторы Spark, и в Spark этой суммы нет. Операторы всё ещё могут выдать её вам."; "lightning__spark_exit__leftover" = "{amount} экстренных комиссий всё ещё находятся на {address}."; "lightning__spark_exit__leftover_swept" = "Неиспользованные экстренные комиссии ({amount}) отправлены в сбережения."; diff --git a/Bitkit/Views/Settings/Advanced/SparkExitViews.swift b/Bitkit/Views/Settings/Advanced/SparkExitViews.swift index 95065b20c..870ead4ab 100644 --- a/Bitkit/Views/Settings/Advanced/SparkExitViews.swift +++ b/Bitkit/Views/Settings/Advanced/SparkExitViews.swift @@ -568,7 +568,8 @@ struct SparkExitTxNote: View { } } -/// Where the ended exit's leftover fee funding is: on its way to savings, sent, or too small to send. +/// Where the ended exit's leftover fee funding is: on its way to savings, sent, or too small to send. A completed exit +/// counts what it sends back in its returned note, so it names only funding that stays at the address. struct SparkExitLeftoverStatus: View { @EnvironmentObject var currency: CurrencyViewModel @@ -579,17 +580,41 @@ struct SparkExitLeftoverStatus: View { SparkExitFundingKey.path(index: record.fundingIndex, network: Env.bitkitCoreNetwork) } + private var isDone: Bool { + record.phase == .done + } + + /// The line to show: on a completed exit, none for funding a sweep sent back. + private var line: SparkExitRecord.LeftoverLine? { + switch record.leftoverLine { + case .sending, .swept: isDone ? nil : record.leftoverLine + default: record.leftoverLine + } + } + + /// What earlier sweeps sent back, listed only before the exit completed. + private var sweptEarlier: [SparkExitRecord.SweptLeftover] { + isDone ? [] : record.sweptLeftover ?? [] + } + /// One line with the total of every UTXO at the funding address, never one per UTXO, after what earlier sweeps sent. var body: some View { + if line != nil || !sweptEarlier.isEmpty { + lines + .padding(.top, 16) + } + } + + private var lines: some View { VStack(alignment: .leading, spacing: 8) { - ForEach(record.sweptLeftover ?? [], id: \.txid) { swept in + ForEach(sweptEarlier, id: \.txid) { swept in SparkExitTxNote( text: t("lightning__spark_exit__leftover_swept", variables: ["amount": sparkExitAmountAccent(currency.primaryAmountText(sats: swept.valueSats))]), txid: swept.txid ) } - switch record.leftoverLine { + switch line { case let .sending(sats, txid): if let txid { SparkExitTxNote( @@ -760,8 +785,6 @@ struct SparkExitProgressView: View { case .done: [ t("lightning__spark_exit__done_text"), - (record?.skippedLeafCount ?? 0) > 0 - ? t("lightning__spark_exit__partial_text", variables: ["count": "\(record?.skippedLeafCount ?? 0)"]) : nil, record.flatMap { $0.isFailedLeavesReleased == true && $0.failedLeavesSats > 0 ? $0.failedLeavesSats : nil }.map { t("lightning__spark_exit__failed_leaves", variables: ["amount": sparkExitAmountAccent(currency.primaryAmountText(sats: $0))]) }, @@ -916,11 +939,8 @@ struct SparkExitProgressView: View { .padding(.top, 16) } - if !record.isActive, !record.leftover.isEmpty || !(record.sweptLeftover ?? []).isEmpty, - let address = record.funding.first?.address - { + if !record.isActive, let address = record.funding.first?.address { SparkExitLeftoverStatus(record: record, address: address) - .padding(.top, 16) } } } From 698853c69141bd7fbeeb758210c823f00070016e Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 18 Nov 2026 05:26:23 +0100 Subject: [PATCH 3/6] fix: keep unsent leftover lines on completed transfer A done force transfer hides leftover lines only for confirmed sweeps the returned note counts as unused fees. A sweep still sending, or one the note cannot count, keeps its line and transaction link. Verified: swiftformat --lint --- .../Settings/Advanced/SparkExitViews.swift | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Bitkit/Views/Settings/Advanced/SparkExitViews.swift b/Bitkit/Views/Settings/Advanced/SparkExitViews.swift index 870ead4ab..6ff563427 100644 --- a/Bitkit/Views/Settings/Advanced/SparkExitViews.swift +++ b/Bitkit/Views/Settings/Advanced/SparkExitViews.swift @@ -568,33 +568,31 @@ struct SparkExitTxNote: View { } } -/// Where the ended exit's leftover fee funding is: on its way to savings, sent, or too small to send. A completed exit -/// counts what it sends back in its returned note, so it names only funding that stays at the address. +/// Where the ended exit's leftover fee funding is: on its way to savings, sent, or too small to send. Once the returned +/// note counts what the sweeps sent back, it names only funding that has not reached savings yet. struct SparkExitLeftoverStatus: View { @EnvironmentObject var currency: CurrencyViewModel let record: SparkExitRecord let address: String + /// The returned note shows the unused fees, confirmed sweeps included, so their lines would repeat it. + var isSweptCounted = false private var path: String { SparkExitFundingKey.path(index: record.fundingIndex, network: Env.bitkitCoreNetwork) } - private var isDone: Bool { - record.phase == .done - } - - /// The line to show: on a completed exit, none for funding a sweep sent back. + /// The line to show: none for a confirmed sweep the returned note already counts. private var line: SparkExitRecord.LeftoverLine? { switch record.leftoverLine { - case .sending, .swept: isDone ? nil : record.leftoverLine + case .swept: isSweptCounted ? nil : record.leftoverLine default: record.leftoverLine } } - /// What earlier sweeps sent back, listed only before the exit completed. + /// What earlier sweeps sent back, unless the returned note already counts it. private var sweptEarlier: [SparkExitRecord.SweptLeftover] { - isDone ? [] : record.sweptLeftover ?? [] + isSweptCounted ? [] : record.sweptLeftover ?? [] } /// One line with the total of every UTXO at the funding address, never one per UTXO, after what earlier sweeps sent. @@ -811,6 +809,12 @@ struct SparkExitProgressView: View { ) } + /// The returned note names the unused emergency fees, so a done exit's confirmed sweeps are counted there. + private var isReturnedFeesShown: Bool { + guard let record, record.phase == .done, let returned = SparkExitMath.returned(record) else { return false } + return returned.spendingSats > 0 && returned.feesSats > 0 + } + private var isFailedOrMissing: Bool { switch record?.phase { case .failed, nil: true @@ -940,7 +944,7 @@ struct SparkExitProgressView: View { } if !record.isActive, let address = record.funding.first?.address { - SparkExitLeftoverStatus(record: record, address: address) + SparkExitLeftoverStatus(record: record, address: address, isSweptCounted: isReturnedFeesShown) } } } From d3eaf6c87d1fbe496018973b143b8a13abb6bdaa Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 18 Nov 2026 06:36:24 +0100 Subject: [PATCH 4/6] fix: inset transfer to savings intro text as the frame The intro's title and text sat 32 pt in, inside both the screen's and the text block's padding; they now share the button's 16 pt inset. Verified: swiftformat --lint --- Bitkit/Views/OnboardingView.swift | 10 +++++----- Bitkit/Views/Transfer/SavingsIntroView.swift | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Bitkit/Views/OnboardingView.swift b/Bitkit/Views/OnboardingView.swift index c3a0a6fc6..f4f0016ca 100644 --- a/Bitkit/Views/OnboardingView.swift +++ b/Bitkit/Views/OnboardingView.swift @@ -16,7 +16,7 @@ struct OnboardingView: View { let accentColor: Color let imagePosition: ImagePosition let titleDescriptionSpacing: CGFloat - let buttonHorizontalPadding: CGFloat + let contentHorizontalPadding: CGFloat let maxImageSize: CGFloat? let testID: String? @@ -38,7 +38,7 @@ struct OnboardingView: View { accentColor: Color = .brandAccent, imagePosition: ImagePosition = .bottom, titleDescriptionSpacing: CGFloat = 14, - buttonHorizontalPadding: CGFloat = 16, + contentHorizontalPadding: CGFloat = 16, maxImageSize: CGFloat? = nil, testID: String? = nil ) { @@ -54,7 +54,7 @@ struct OnboardingView: View { self.accentColor = accentColor self.imagePosition = imagePosition self.titleDescriptionSpacing = titleDescriptionSpacing - self.buttonHorizontalPadding = buttonHorizontalPadding + self.contentHorizontalPadding = contentHorizontalPadding self.maxImageSize = maxImageSize self.testID = testID } @@ -93,13 +93,13 @@ struct OnboardingView: View { .frame(maxWidth: .infinity, alignment: .leading) .fixedSize(horizontal: false, vertical: true) } - .padding(.horizontal, 16) + .padding(.horizontal, contentHorizontalPadding) CustomButton(title: buttonText) { onButtonPress() } .padding(.top, 32) - .padding(.horizontal, buttonHorizontalPadding) + .padding(.horizontal, contentHorizontalPadding) .accessibilityIdentifierIfPresent(testID.map { "\($0)-button" }) } } diff --git a/Bitkit/Views/Transfer/SavingsIntroView.swift b/Bitkit/Views/Transfer/SavingsIntroView.swift index fab1d7ed9..ed3cf1e16 100644 --- a/Bitkit/Views/Transfer/SavingsIntroView.swift +++ b/Bitkit/Views/Transfer/SavingsIntroView.swift @@ -19,7 +19,7 @@ struct SavingsIntroView: View { }, imagePosition: .center, titleDescriptionSpacing: 8, - buttonHorizontalPadding: 0, + contentHorizontalPadding: 0, maxImageSize: 256, testID: "SavingsIntro" ) From b81eaf89449388029e63b570731331e36109afaf Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 18 Nov 2026 07:00:36 +0100 Subject: [PATCH 5/6] chore: add changelog entry Verified: none (changelog only) --- changelog.d/next/1362.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/next/1362.fixed.md diff --git a/changelog.d/next/1362.fixed.md b/changelog.d/next/1362.fixed.md new file mode 100644 index 000000000..f08e63c24 --- /dev/null +++ b/changelog.d/next/1362.fixed.md @@ -0,0 +1 @@ +Pay to confirm now starts the Spark force transfer on its own once the fees are paid, and its completed screen matches the new design. From 7b012e9b1e4f1e90a9eb0f3a8c03319cf780c92a Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 18 Nov 2026 11:20:43 +0100 Subject: [PATCH 6/6] fix: show a running force transfer on spark connection Spark stays connected through a force transfer, so its connection screen read a green "Connection open" while App Status showed the transfer in yellow. The screen now shows the same yellow status and wording as App Status's Spark row. Verified: swiftformat --lint, AppStatusExitTests, AppStatusHelperTests, SparkExitMathTests on the iPhone 17 Pro simulator --- Bitkit/Utilities/AppStatusHelper.swift | 5 +++++ .../Views/Settings/Advanced/SparkConnectionViews.swift | 9 +++++++-- Bitkit/Views/Settings/AppStatusView.swift | 2 +- BitkitTests/AppStatusExitTests.swift | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Bitkit/Utilities/AppStatusHelper.swift b/Bitkit/Utilities/AppStatusHelper.swift index d543c23e7..4e8c35a7e 100644 --- a/Bitkit/Utilities/AppStatusHelper.swift +++ b/Bitkit/Utilities/AppStatusHelper.swift @@ -27,6 +27,11 @@ enum HealthStatus: String { enum ExitStatusStep: String { case funding case pending + + /// The Spark row's text while the force transfer runs, on App Status and Spark's connection screen. + var descriptionKey: String { + self == .funding ? "settings__status__exit__funding" : "settings__status__spark__exit" + } } @MainActor diff --git a/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift b/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift index b90b0c9e0..726a1bd2e 100644 --- a/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift +++ b/Bitkit/Views/Settings/Advanced/SparkConnectionViews.swift @@ -108,9 +108,14 @@ struct SparkConnectionDetailView: View { spark.shownBalanceSats > 0 || spark.recoverableFundsSats > 0 || SparkExitManager.shared.showsResult } - /// Spark's connection state, worded and coloured like a channel's: open, connecting or offline. + /// Spark's connection state, worded and coloured like a channel's: open, connecting or offline; while a force + /// transfer runs, its pending state worded as on App Status. private var status: (text: String, color: Color) { - switch AppStatusHelper.sparkStatus(network: network) ?? .error { + let exit = SparkExitManager.shared + if let step = AppStatusHelper.exitStep(record: exit.record, fundingState: exit.fundingState) { + return (t(step.descriptionKey), .yellowAccent) + } + return switch AppStatusHelper.sparkStatus(network: network) ?? .error { case .ready: (t("lightning__order_state__open"), .greenAccent) case .pending: (t("settings__status__spark__pending"), .yellowAccent) case .error: (t("settings__status__spark__error"), .redAccent) diff --git a/Bitkit/Views/Settings/AppStatusView.swift b/Bitkit/Views/Settings/AppStatusView.swift index 109348da8..3c70e5108 100644 --- a/Bitkit/Views/Settings/AppStatusView.swift +++ b/Bitkit/Views/Settings/AppStatusView.swift @@ -159,7 +159,7 @@ struct AppStatusView: View { StatusRow( imageName: "warning", title: t("settings__status__spark__title"), - description: t(step == .funding ? "settings__status__exit__funding" : "settings__status__spark__exit"), + description: t(step.descriptionKey), status: .pending, onTap: { navigation.navigate(.sparkExitProgress) diff --git a/BitkitTests/AppStatusExitTests.swift b/BitkitTests/AppStatusExitTests.swift index 56ddf2beb..6d22cc876 100644 --- a/BitkitTests/AppStatusExitTests.swift +++ b/BitkitTests/AppStatusExitTests.swift @@ -20,6 +20,11 @@ final class AppStatusExitTests: XCTestCase { XCTAssertEqual(AppStatusHelper.exitStep(record: record(.needsFunding(requiredSats: 1000)), fundingState: .seen(txid: "txid")), .pending) } + func testExitStepWordsTheSparkRow() { + XCTAssertEqual(ExitStatusStep.funding.descriptionKey, "settings__status__exit__funding") + XCTAssertEqual(ExitStatusStep.pending.descriptionKey, "settings__status__spark__exit") + } + func testExitStepIsPendingWithNothingToFund() { XCTAssertEqual(AppStatusHelper.exitStep(record: record(.awaitingFunding(requiredSats: 0))), .pending) }