From 56d5781e913bf8d46dfc1ef74e539feae1413274 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Thu, 12 Nov 2026 17:27:14 +0100 Subject: [PATCH] chore: breez sdk 0.28.3 --- .../main/java/to/bitkit/data/CacheStore.kt | 7 +- .../java/to/bitkit/repositories/BackupRepo.kt | 4 +- .../java/to/bitkit/repositories/SparkRepo.kt | 84 +++++++------- .../java/to/bitkit/services/SparkService.kt | 21 ++++ .../to/bitkit/repositories/SparkRepoTest.kt | 103 ++++++++++++++++-- .../to/bitkit/services/SparkServiceTest.kt | 8 ++ gradle/libs.versions.toml | 2 +- 7 files changed, 173 insertions(+), 56 deletions(-) diff --git a/app/src/main/java/to/bitkit/data/CacheStore.kt b/app/src/main/java/to/bitkit/data/CacheStore.kt index 1db082d407..872ad97ccb 100644 --- a/app/src/main/java/to/bitkit/data/CacheStore.kt +++ b/app/src/main/java/to/bitkit/data/CacheStore.kt @@ -375,9 +375,8 @@ data class AppCacheData( */ val ldkSendHashesSeeded: Boolean = false, /** - * When a metadata restore brought back [sparkSendHashes], in epoch seconds, until Spark's synced list fills them: - * the backup can predate a send Spark made, so meanwhile a Spark that can't list its payments holds the node off - * invoices created before it. Null on an install that was never restored, whose kept hashes are complete. + * When a metadata restore brought back [sparkSendHashes], in epoch seconds, until Spark's synced list fills them, + * as the backup can predate a send Spark made. Null on an install that was never restored. */ val sparkHistoryUnseededSince: Long? = null, /** @@ -388,7 +387,7 @@ data class AppCacheData( /** * When the wallet was restored, in epoch seconds. Spark's list can lack a send it made before then even after a * sync, so both rails refuse a still-valid invoice created before it that Spark hasn't listed as pending or paid, - * until that invoice expires. + * unless the Spark operators show it unsent. */ val sparkRestoredAt: Long? = null, ) { diff --git a/app/src/main/java/to/bitkit/repositories/BackupRepo.kt b/app/src/main/java/to/bitkit/repositories/BackupRepo.kt index 3fde33b58a..27293e4975 100644 --- a/app/src/main/java/to/bitkit/repositories/BackupRepo.kt +++ b/app/src/main/java/to/bitkit/repositories/BackupRepo.kt @@ -1078,8 +1078,8 @@ class BackupRepo @Inject constructor( connectionSession.replay() prepareUsdtRecoveryRestore() // Armed before any category, so a restore whose metadata is missing or unreadable holds each rail off - // invoices from before it too: until that rail lists its own sends, and, for one Spark hasn't listed, - // until the invoice expires. + // invoices from before it too: Spark until the node lists its own sends, and both rails off one Spark + // hasn't listed, until the Spark operators show it unsent or it expires. val restoredAt = currentTimeMillis().milliseconds.inWholeSeconds cacheStore.update { it.copy( diff --git a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt index 9eadf920c6..47ceeaa971 100644 --- a/app/src/main/java/to/bitkit/repositories/SparkRepo.kt +++ b/app/src/main/java/to/bitkit/repositories/SparkRepo.kt @@ -494,7 +494,7 @@ class SparkRepo @Inject constructor( * [paymentDeadlineAt]. A failure inside the send is a [PaymentPendingException], as the payment may have been * dispatched, and its event decides it. An invoice this wallet already sends is not sent again: one in flight or * pending fails with [PaymentPendingException], and one Spark completed returns its hash. After a restore, a - * still-valid invoice created before it that Spark hasn't listed as pending or paid fails with + * still-valid invoice created before it that the Spark operators can't show unsent fails with * [SparkError.RestoredInvoiceUnverified], under the same rule as the node's send. */ suspend fun payInvoice( @@ -529,15 +529,13 @@ class SparkRepo @Inject constructor( } is SparkLightningSend.Found if earlier.status == PaymentStatus.PENDING -> throw PaymentPendingException(paymentHash) - // Before Spark has listed its sends since a restore, an older invoice is refused here; the branch - // below keeps refusing it after the listing, until the invoice expires. - is SparkLightningSend.Unavailable if isUnlistedSinceRestore(method.invoiceDetails.timestamp) -> { - Logger.warn("Refused a Spark send of '$paymentHash' dated before the restore", context = TAG) - throw SparkError.RestoredInvoiceUnverified() - } - // Spark's list, synced or unreadable, can still lack a send it made before the restore, as on the - // node's path. - else -> refuseUnverifiedRestoredInvoice(invoice.timestamp.toEpochSeconds(), expiresAt.toEpochSeconds()) + // Spark's list, synced or unreadable, can lack a send it made before the restore, as on the node's + // path, so the operators decide. + else -> refuseUnverifiedRestoredInvoice( + bolt11, + invoice.timestamp.toEpochSeconds(), + expiresAt.toEpochSeconds(), + ) } // A cancel, block or identity change can land while Spark prepares, so the last check runs right here. if (!onBeforeSend()) throw PaymentAbortedBeforeSend() @@ -1380,12 +1378,11 @@ class SparkRepo @Inject constructor( /** * Spark's pending or paid send of [bolt11], matched by the invoice or its [paymentHash], so the node never pays it * again; a send still inside Spark's send call is pending. Null when Spark's send failed or none is known. - * While Spark can't list its payments, a send it started for [paymentHash] counts as pending, since it may be live, - * and after a restore, until Spark's synced list seeds the kept hashes, [SparkError.SendRefused] is thrown for an - * invoice created before the restore ([invoiceCreatedAt] in epoch seconds, null when unknown), as the restored - * hashes can lack a send Spark made of it. After a restore, an invoice created before it and not yet expired - * ([invoiceExpiresAt], null when unknown) that Spark hasn't listed is refused with - * [SparkError.RestoredInvoiceUnverified] whatever Spark listed, as Spark's list can lack its sends after a sync. + * While Spark can't list its payments, a send it started for [paymentHash] counts as pending, since it may be live. + * After a restore, an invoice created before it ([invoiceCreatedAt] in epoch seconds, null when unknown) and not + * yet expired ([invoiceExpiresAt], null when unknown) that Spark hasn't listed as pending or paid is refused with + * [SparkError.RestoredInvoiceUnverified] unless the Spark operators show it unsent, as Spark's list can lack its + * sends after a restore. */ suspend fun earlierLightningSend( bolt11: String, @@ -1419,13 +1416,7 @@ class SparkRepo @Inject constructor( } if (payments == null) { startedSend(paymentHash)?.let { return@withContext EarlierSend.Pending(it) } - // Restored hashes can lack a send Spark made before the restore, never one of a newer invoice. - val unseededSince = cacheStore.data.first().sparkHistoryUnseededSince - if (sparkService.isSupported && unseededSince != null && (invoiceCreatedAt ?: 0L) < unseededSince) { - Logger.warn("Refused a node send until Spark lists its earlier sends once", context = TAG) - throw SparkError.RestoredInvoiceUnverified() - } - refuseUnverifiedRestoredInvoice(invoiceCreatedAt, invoiceExpiresAt) + refuseUnverifiedRestoredInvoice(bolt11, invoiceCreatedAt, invoiceExpiresAt) return@withContext null } seedSendHashes(payments) @@ -1437,12 +1428,12 @@ class SparkRepo @Inject constructor( if (send == null) { (retried() ?: paymentHash?.lowercase()?.takeIf { it in unlisted }) ?.let { return@withContext EarlierSend.Pending(it) } - refuseUnverifiedRestoredInvoice(invoiceCreatedAt, invoiceExpiresAt) + refuseUnverifiedRestoredInvoice(bolt11, invoiceCreatedAt, invoiceExpiresAt) return@withContext null } if (send.status == PaymentStatus.FAILED) { retried()?.let { return@withContext EarlierSend.Pending(it) } - refuseUnverifiedRestoredInvoice(invoiceCreatedAt, invoiceExpiresAt) + refuseUnverifiedRestoredInvoice(bolt11, invoiceCreatedAt, invoiceExpiresAt) } val hash = (send.details as PaymentDetails.Lightning).htlcDetails.paymentHash when (send.status) { @@ -1454,30 +1445,47 @@ class SparkRepo @Inject constructor( /** Whether a node send needs its invoice's times for the checks after a restore in [earlierLightningSend]. */ suspend fun holdsRestoredInvoices(): Boolean { - val cache = cacheStore.data.first() - return cache.sparkHistoryUnseededSince != null || cache.sparkRestoredAt != null - } - - private suspend fun isUnlistedSinceRestore(invoiceCreatedAt: ULong): Boolean { - val unseededSince = cacheStore.data.first().sparkHistoryUnseededSince ?: return false - return invoiceCreatedAt < unseededSince.coerceAtLeast(0L).toULong() + return cacheStore.data.first().sparkRestoredAt != null } /** - * The rule both rails apply after a restore, as Spark's list can lack a send it made before it: an invoice created - * before the restore that hasn't expired, or one whose times are unknown, is refused with - * [SparkError.RestoredInvoiceUnverified] until it expires. + * The rule both rails apply after a restore, as Spark's list can lack a send it made before it: [bolt11], when + * created before the restore and not yet expired, or when its times are unknown, is refused with + * [SparkError.RestoredInvoiceUnverified] unless [isUnsentPerOperators]. */ - private suspend fun refuseUnverifiedRestoredInvoice(invoiceCreatedAt: Long?, invoiceExpiresAt: Long?) { + private suspend fun refuseUnverifiedRestoredInvoice( + bolt11: String, + invoiceCreatedAt: Long?, + invoiceExpiresAt: Long?, + ) { val restoredAt = cacheStore.data.first().sparkRestoredAt ?: return val isHeld = sparkService.isSupported && (invoiceCreatedAt ?: 0L) < restoredAt && (invoiceExpiresAt == null || clock.now().epochSeconds < invoiceExpiresAt) - if (!isHeld) return - Logger.warn("Refused a send of a pre-restore invoice Spark hasn't listed", context = TAG) + if (!isHeld || isUnsentPerOperators(bolt11)) return + Logger.warn("Refused a send of a pre-restore invoice the Spark operators can't show unsent", context = TAG) throw SparkError.RestoredInvoiceUnverified() } + /** + * Whether the Spark operators confirm this wallet never sent [bolt11] over Lightning, and it can't have been paid + * by a direct Spark transfer, which they don't see: false when they show a send, completed, pending or failed, or + * can't be asked. + */ + private suspend fun isUnsentPerOperators(bolt11: String): Boolean { + if (!sparkService.isConnected) return false + val status = runSuspendCatching { sparkService.lightningSendStatus(bolt11) } + .onFailure { Logger.warn("Failed to fetch Spark's send status", it, context = TAG) } + .getOrElse { return false } + if (status != null) { + Logger.info("Spark's operators show a '$status' send of the pre-restore invoice", context = TAG) + return false + } + // A send preferring Spark pays an invoice's Spark address as a direct transfer. + if (!sparkService.prefersSpark) return true + return runCatching { !sparkService.carriesSparkAddress(bolt11) }.getOrDefault(false) + } + private fun ULong.toEpochSeconds(): Long = coerceAtMost(Long.MAX_VALUE.toULong()).toLong() /** The count of sends recorded so far, read before a node send's checks for [hasRecordedSendSince]. */ diff --git a/app/src/main/java/to/bitkit/services/SparkService.kt b/app/src/main/java/to/bitkit/services/SparkService.kt index f6aacd68a3..d2b1448ca5 100644 --- a/app/src/main/java/to/bitkit/services/SparkService.kt +++ b/app/src/main/java/to/bitkit/services/SparkService.kt @@ -13,6 +13,7 @@ import breez_sdk_spark.EventListener import breez_sdk_spark.FeePolicy import breez_sdk_spark.FetchClaimDepositQuoteRequest import breez_sdk_spark.FetchClaimDepositQuoteResponse +import breez_sdk_spark.FetchLightningSendStatusRequest import breez_sdk_spark.GetInfoRequest import breez_sdk_spark.GetInfoResponse import breez_sdk_spark.ImportUnilateralExitStateRequest @@ -25,6 +26,7 @@ import breez_sdk_spark.MaxOnchainFee import breez_sdk_spark.OnchainConfirmationSpeed import breez_sdk_spark.Payment import breez_sdk_spark.PaymentRequest +import breez_sdk_spark.PaymentStatus import breez_sdk_spark.PrepareRecoverFundsRequest import breez_sdk_spark.PrepareRecoverFundsResponse import breez_sdk_spark.PrepareSendPaymentRequest @@ -46,6 +48,7 @@ import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import org.lightningdevkit.ldknode.Bolt11Invoice import org.lightningdevkit.ldknode.Network import to.bitkit.data.keychain.Keychain import to.bitkit.env.Env @@ -127,6 +130,13 @@ class SparkService @Inject constructor( */ fun bolt11SendOptions(prefersSpark: Boolean): SendPaymentOptions = SendPaymentOptions.Bolt11Invoice(preferSpark = prefersSpark, completionTimeoutSecs = null) + + /** The route hint short channel id under which an invoice carries its Spark address, as spark-sdk sets it. */ + private const val SPARK_ADDRESS_HINT_SCID = 17_592_187_092_992_000_001uL + + /** Whether [shortChannelIds], an invoice's route hint hops, carry a Spark address. */ + internal fun hasSparkAddressHint(shortChannelIds: List): Boolean = + SPARK_ADDRESS_HINT_SCID in shortChannelIds } private val mutex = Mutex() @@ -295,6 +305,17 @@ class SparkService @Inject constructor( suspend fun invoiceExpiresAt(bolt11: String): ULong? = (requireSdk().parse(bolt11) as? InputType.Bolt11Invoice)?.v1?.let { invoiceExpiresAt(it.timestamp, it.expiry) } + /** + * This wallet's Lightning send of [bolt11] as the Spark operators record it, without the local history: null when + * they know none. A direct Spark transfer to the invoice's Spark address is not covered. + */ + suspend fun lightningSendStatus(bolt11: String): PaymentStatus? = + requireSdk().fetchLightningSendStatus(FetchLightningSendStatusRequest(bolt11)).status + + /** Whether [bolt11] carries a Spark address, so a send preferring Spark pays it as a direct transfer. */ + fun carriesSparkAddress(bolt11: String): Boolean = + hasSparkAddressHint(Bolt11Invoice.fromStr(bolt11).routeHints().flatten().map { it.shortChannelId }) + /** Exports what a unilateral exit needs if the Spark operators stop cooperating; it can reach several MB. */ suspend fun exportExitState(): String = requireSdk().exportUnilateralExitState().exitState diff --git a/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt b/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt index 1f3d8f7ec1..28837d44e5 100644 --- a/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt +++ b/app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt @@ -123,6 +123,9 @@ class SparkRepoTest : BaseUnitTest() { private val payoutChain = mock() private val settingsStore = mock { on { data } doReturn flowOf(SettingsData()) } private var now = Instant.fromEpochSeconds(1_800_000_000) + + /** The Spark operators' answer to a send status fetch; unreachable unless a test says otherwise. */ + private var sendStatus: () -> PaymentStatus? = { throw IllegalStateException("operators unreachable") } private val clock = object : Clock { override fun now() = this@SparkRepoTest.now } @@ -155,6 +158,7 @@ class SparkRepoTest : BaseUnitTest() { whenever { activityRepo.upsertActivity(any()) }.thenReturn(Result.success(Unit)) whenever(sparkService.isSupported).thenReturn(true) whenever(sparkService.networkName).thenReturn("regtest") + whenever { sparkService.lightningSendStatus(any()) }.thenAnswer { sendStatus() } whenever { cacheStore.update(any()) }.thenAnswer { val transform = it.getArgument<(AppCacheData) -> AppCacheData>(0) cacheData.update(transform) @@ -282,9 +286,10 @@ class SparkRepoTest : BaseUnitTest() { } @Test - fun `a restored wallet's unsynced history refuses the node's send of an invoice from before the restore`() = + fun `a restored wallet's unsynced spark refuses the node's pre-restore send while operators can't be asked`() = test { - cacheData.value = AppCacheData(sparkHistoryUnseededSince = now.epochSeconds) + val restoredAt = now.epochSeconds + cacheData.value = AppCacheData(sparkHistoryUnseededSince = restoredAt, sparkRestoredAt = restoredAt) whenever(sparkService.isConnected).thenReturn(true) val sut = createSut() @@ -295,7 +300,7 @@ class SparkRepoTest : BaseUnitTest() { } @Test - fun `a pre-restore invoice spark's synced list lacks is refused over the node until it expires`() = test { + fun `a pre-restore invoice spark's list lacks is refused over the node while operators can't be asked`() = test { val restoredAt = now.epochSeconds - 60 val cache = AppCacheData(sparkHistoryUnseededSince = restoredAt, sparkRestoredAt = restoredAt) val store = CacheStore(InMemoryDataStore(cache), clock) @@ -340,7 +345,7 @@ class SparkRepoTest : BaseUnitTest() { @Test fun `an invoice created after the restore pays over the node while spark is unsynced`() = test { - cacheData.value = AppCacheData(sparkHistoryUnseededSince = now.epochSeconds) + cacheData.value = AppCacheData(sparkHistoryUnseededSince = now.epochSeconds, sparkRestoredAt = now.epochSeconds) whenever(sparkService.isConnected).thenReturn(false) assertNull(createSut().earlierLightningSend("lnbc1280n1send", "hash", invoiceCreatedAt = now.epochSeconds + 60)) @@ -394,17 +399,19 @@ class SparkRepoTest : BaseUnitTest() { val restarted = createSut(store) restarted.start(0).getOrThrow() - restarted.payInvoice("lnbc1280n1send", 128uL) + val result = restarted.payInvoice("lnbc1280n1send", 128uL) + assertIs(result.exceptionOrNull()) verify(sparkService, never()).send(any(), anyOrNull()) } @Test - fun `a ready spark that hasn't synced since the restore refuses an invoice from before it`() = test { - val store = CacheStore(InMemoryDataStore(AppCacheData(sparkHistoryUnseededSince = now.epochSeconds)), clock) + fun `an unsynced spark refuses a pre-restore invoice while operators can't be asked`() = test { + val restored = AppCacheData(sparkHistoryUnseededSince = now.epochSeconds, sparkRestoredAt = now.epochSeconds) + val store = CacheStore(InMemoryDataStore(restored), clock) whenever(sparkService.isConnected).thenReturn(true) whenever { sparkService.getInfo() }.thenReturn(info(10_000uL).copy(lastSyncedAt = null)) - val prepared = prepared(feeSats = 0uL) + val prepared = prepared(feeSats = 0uL, createdAt = (now.epochSeconds - 600).toULong(), expirySecs = 3_600uL) whenever { sparkService.prepareSend(any(), anyOrNull(), anyOrNull()) }.thenReturn(prepared) whenever { sparkService.send(any(), anyOrNull()) }.thenReturn(sentPayment(fees = 0)) val sut = createSut(store) @@ -417,7 +424,7 @@ class SparkRepoTest : BaseUnitTest() { } @Test - fun `a synced spark whose list lacks a pre-restore invoice refuses to send it`() = test { + fun `a synced spark refuses a pre-restore invoice its list lacks while operators can't be asked`() = test { val restoredAt = now.epochSeconds - 60 val cache = AppCacheData(sparkHistoryUnseededSince = restoredAt, sparkRestoredAt = restoredAt) val store = CacheStore(InMemoryDataStore(cache), clock) @@ -437,7 +444,7 @@ class SparkRepoTest : BaseUnitTest() { } @Test - fun `a synced spark whose list can't be read refuses a pre-restore invoice`() = test { + fun `a synced spark whose list and operators can't be read refuses a pre-restore invoice`() = test { val restoredAt = now.epochSeconds - 60 val cache = AppCacheData(sparkHistoryUnseededSince = restoredAt, sparkRestoredAt = restoredAt) val store = CacheStore(InMemoryDataStore(cache), clock) @@ -473,6 +480,80 @@ class SparkRepoTest : BaseUnitTest() { verify(sparkService).send(any(), anyOrNull()) } + @Test + fun `a pre-restore invoice the operators show completed is refused on both rails`() = test { + assertRestoredInvoiceRefusedOnBothRails(status = PaymentStatus.COMPLETED) + } + + @Test + fun `a pre-restore invoice the operators show pending is refused on both rails`() = test { + assertRestoredInvoiceRefusedOnBothRails(status = PaymentStatus.PENDING) + } + + @Test + fun `a pre-restore invoice the operators show failed is refused on both rails`() = test { + assertRestoredInvoiceRefusedOnBothRails(status = PaymentStatus.FAILED) + } + + @Test + fun `a pre-restore invoice the operators show unsent pays on both rails when spark isn't preferred`() = test { + whenever(sparkService.prefersSpark).thenReturn(false) + whenever(sparkService.carriesSparkAddress(any())).thenReturn(true) + assertRestoredInvoicePaysOnBothRails() + } + + @Test + fun `a pre-restore invoice the operators show unsent pays on both rails when it carries no spark address`() = + test { + whenever(sparkService.prefersSpark).thenReturn(true) + whenever(sparkService.carriesSparkAddress(any())).thenReturn(false) + assertRestoredInvoicePaysOnBothRails() + } + + @Test + fun `a spark-addressed pre-restore invoice the operators show unsent is refused while spark is preferred`() = test { + whenever(sparkService.prefersSpark).thenReturn(true) + whenever(sparkService.carriesSparkAddress(any())).thenReturn(true) + assertRestoredInvoiceRefusedOnBothRails(status = null) + } + + @Test + fun `a pre-restore invoice is refused on both rails when the operators can't be asked`() = test { + // setUp's status fetch fails, as when the operators are unreachable. + assertRestoredInvoiceRefusedOnBothRails(status = null, stubStatus = false) + } + + private suspend fun restoredSparkForPreRestoreInvoice(status: PaymentStatus?, stubStatus: Boolean): SparkRepo { + val restoredAt = now.epochSeconds - 60 + val cache = AppCacheData(sparkHistoryUnseededSince = restoredAt, sparkRestoredAt = restoredAt) + whenever(sparkService.isConnected).thenReturn(true) + if (stubStatus) sendStatus = { status } + val prepared = prepared(feeSats = 0uL, createdAt = (restoredAt - 600).toULong(), expirySecs = 3_600uL) + whenever { sparkService.prepareSend(any(), anyOrNull(), anyOrNull()) }.thenReturn(prepared) + whenever { sparkService.send(any(), anyOrNull()) }.thenReturn(sentPayment(fees = 0)) + return createSut(CacheStore(InMemoryDataStore(cache), clock)).also { it.start(0).getOrThrow() } + } + + private suspend fun assertRestoredInvoiceRefusedOnBothRails(status: PaymentStatus?, stubStatus: Boolean = true) { + val sut = restoredSparkForPreRestoreInvoice(status, stubStatus) + val createdAt = now.epochSeconds - 660 + + assertFailsWith { + sut.earlierLightningSend("lnbc1280n1send", "hash", createdAt, createdAt + 3_600) + } + assertIs(sut.payInvoice("lnbc1280n1send", 128uL).exceptionOrNull()) + verify(sparkService, never()).send(any(), anyOrNull()) + } + + private suspend fun assertRestoredInvoicePaysOnBothRails() { + val sut = restoredSparkForPreRestoreInvoice(status = null, stubStatus = true) + val createdAt = now.epochSeconds - 660 + + assertNull(sut.earlierLightningSend("lnbc1280n1send", "hash", createdAt, createdAt + 3_600)) + sut.payInvoice("lnbc1280n1send", 128uL).getOrThrow() + verify(sparkService).send(any(), anyOrNull()) + } + @Test fun `restored spark sends with valid invoices survive the hash cap`() = test { val store = CacheStore(InMemoryDataStore(AppCacheData(sparkHistoryUnseededSince = now.epochSeconds)), clock) @@ -515,7 +596,7 @@ class SparkRepoTest : BaseUnitTest() { } @Test - fun `spark's synced event seeds the restored hashes and ends the hold`() = test { + fun `spark's synced event seeds the restored hashes`() = test { val store = CacheStore(InMemoryDataStore(AppCacheData(sparkHistoryUnseededSince = now.epochSeconds)), clock) whenever(sparkService.isConnected).thenReturn(true) whenever { sparkService.getInfo() }.thenReturn(info(0uL).copy(lastSyncedAt = null)) diff --git a/app/src/test/java/to/bitkit/services/SparkServiceTest.kt b/app/src/test/java/to/bitkit/services/SparkServiceTest.kt index 5919d4b41e..4671099654 100644 --- a/app/src/test/java/to/bitkit/services/SparkServiceTest.kt +++ b/app/src/test/java/to/bitkit/services/SparkServiceTest.kt @@ -18,6 +18,7 @@ import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertIs import kotlin.test.assertNull +import kotlin.test.assertTrue class SparkServiceTest { @get:Rule @@ -56,6 +57,13 @@ class SparkServiceTest { assertEquals(true, options.preferSpark) } + @Test + fun `only spark's own route hint marks an invoice as carrying a spark address`() { + assertTrue(SparkService.hasSparkAddressHint(listOf(1uL, 17_592_187_092_992_000_001uL))) + assertFalse(SparkService.hasSparkAddressHint(listOf(1uL, 17_592_187_092_992_000_000uL))) + assertFalse(SparkService.hasSparkAddressHint(emptyList())) + } + @Test fun `an invoice expiry past the largest time stays at the largest time`() { val farOff = SparkService.invoiceExpiresAt(timestamp = ULong.MAX_VALUE - 1uL, expiry = 3_600uL) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1240b9225e..4891bba8bf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -24,7 +24,7 @@ appcompat = { module = "androidx.appcompat:appcompat", version = "1.8.0" } barcode-scanning = { module = "com.google.mlkit:barcode-scanning", version = "17.3.0" } biometric = { module = "androidx.biometric:biometric", version = "1.4.0-beta01" } bitkit-core = { module = "com.synonym:bitkit-core-android", version = "0.8.0-rc15" } -breez-sdk-spark = { module = "breez_sdk_spark:bindings-android", version = "0.28.2" } +breez-sdk-spark = { module = "breez_sdk_spark:bindings-android", version = "0.28.3" } paykit = { module = "com.synonym:paykit-android", version = "0.1.1-rc8" } bouncycastle-pkix-jdk = { module = "org.bouncycastle:bcpkix-jdk18on", version = "1.86" } bouncycastle-provider-jdk = { module = "org.bouncycastle:bcprov-jdk18on", version = "1.86" }