Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
faf45ae
feat: add wear spark payment calls and send keys
jvsena42 Nov 28, 2026
925ac66
feat: add wear payments repository with self-send guard
jvsena42 Nov 28, 2026
37b2614
feat: refuse own spark invoices in the phone's self-send guard
jvsena42 Nov 28, 2026
ea866e6
docs: describe wear payments and the self-send guard
jvsena42 Nov 28, 2026
269907e
refactor: share the wear balance amount rows
jvsena42 Nov 28, 2026
123df06
feat: add wear qr, screen awake and hold to pay components
jvsena42 Nov 28, 2026
53ca479
feat: add wear receive, send and activity screens
jvsena42 Nov 28, 2026
dc6476c
docs: describe wear payments screens and their journeys
jvsena42 Nov 28, 2026
e8a7e72
docs: leave the wear tile for a later pr
jvsena42 Nov 28, 2026
c9996b7
fix: keep wear send keys across retries, fail closed on unknown
jvsena42 Nov 28, 2026
c3fdc8c
fix: fail closed in the phone's own spark invoice guard
jvsena42 Nov 28, 2026
d9bdcef
fix: harden wear send, receive and activity screens
jvsena42 Nov 28, 2026
7d163df
docs: update wear payments docs and journeys for review fixes
jvsena42 Nov 28, 2026
cf84985
fix: tag the dropped own spark invoices log
jvsena42 Nov 28, 2026
b9e7055
fix: tell a busy wear wallet from a pending send, harden receive and …
jvsena42 Nov 28, 2026
1221feb
docs: update wear payments docs and journeys for round 2 fixes
jvsena42 Nov 28, 2026
5bb830b
fix: hide the paid amount in ambient, show a stalled retry as pending
jvsena42 Nov 28, 2026
93bb24e
docs: update wear payments docs and journeys for round 3 fixes
jvsena42 Nov 28, 2026
2432f7a
docs: run the wear ambient paid journey after the activity list
jvsena42 Nov 28, 2026
7744a5c
docs: limit the wear payments changelog to the phone guard
jvsena42 Nov 28, 2026
708eabd
docs: stop the wear screen recorder before pulling the video
jvsena42 Nov 28, 2026
3d358f2
feat: add a balance tile to the wear app
jvsena42 Nov 28, 2026
80fad64
docs: describe the wear balance tile and its journey
jvsena42 Nov 28, 2026
2c22790
chore: verify the wear tile dependencies
jvsena42 Nov 28, 2026
a83ad55
fix: accept the phone's payment link schemes on the watch
jvsena42 Nov 28, 2026
6141d99
feat: show a dedicated offline error when paying offline on the watch
jvsena42 Nov 28, 2026
8070914
fix: show an ok edge button on wear send refusals
jvsena42 Nov 28, 2026
079208e
fix: keep the check drawable for wear success states
jvsena42 Nov 28, 2026
5176962
fix: drop invoices and send notes that a wipe began or ended during
jvsena42 Dec 4, 2026
d283e5b
fix: keep a pending transfer's note until it settles
jvsena42 Dec 4, 2026
7e3d2cd
fix: hide the tile balance whenever the watch is locked
jvsena42 Dec 4, 2026
56195b3
fix: stop waiting for a wallet whose start failed
jvsena42 Dec 4, 2026
4f30db5
docs: describe the wear payment screens after a failed wallet start
jvsena42 Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions app/src/main/java/to/bitkit/data/CacheStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ import kotlin.time.Clock
*/
internal const val MAX_SPARK_SEND_HASHES = 100

/**
* How many unexpired invoices of the wallet's own are remembered; the ones that expire last are kept. Far above what
* a day of receive, contact and transfer invoices makes, as a dropped one could be paid by its own wallet.
*/
internal const val MAX_SPARK_OWN_INVOICES = 2_000

/**
* How long past its invoice's expiry a send no listing shows may still be pending: no send starts after the expiry,
* and one settles within its HTLC timeout, which LDK caps at 1008 blocks (about a week) and Spark's routes keep
Expand All @@ -51,6 +57,10 @@ class CacheStore internal constructor(
private val store: DataStore<AppCacheData>,
private val clock: Clock = Clock.System,
) {
companion object {
private const val TAG = "CacheStore"
}

@Inject
constructor(@ApplicationContext context: Context) : this(context.appCacheDataStore)

Expand Down Expand Up @@ -167,6 +177,27 @@ class CacheStore internal constructor(
}
}

/**
* Remembers the Spark invoice with [paymentHash] as one this wallet created, until [expiresAt] in epoch seconds,
* so the wallet refuses to pay it. Invoices expired at [now] are dropped, as nobody can pay them. A paired
* device's invoices are added the same way.
*/
suspend fun addSparkOwnInvoice(paymentHash: String, expiresAt: Long, now: Long) {
var dropped = 0
store.updateData { data ->
val unexpired = (data.sparkOwnInvoices + (paymentHash.lowercase() to expiresAt)).entries
.filter { it.value > now }
dropped = (unexpired.size - MAX_SPARK_OWN_INVOICES).coerceAtLeast(0)
val invoices = unexpired.sortedByDescending { it.value }.take(MAX_SPARK_OWN_INVOICES)
data.copy(sparkOwnInvoices = invoices.associate { it.key to it.value })
}
if (dropped > 0) Logger.warn("Dropped '$dropped' unexpired own Spark invoices", context = TAG)
}

/** Whether [paymentHash] is a Spark invoice of this wallet that has not expired at [now], in epoch seconds. */
suspend fun hasSparkOwnInvoice(paymentHash: String, now: Long): Boolean =
store.data.first().sparkOwnInvoices[paymentHash.lowercase()]?.let { it > now } == true

suspend fun removeSparkSendHash(paymentHash: String) {
val hash = paymentHash.lowercase()
if (hash !in store.data.first().sparkSendHashes) return
Expand Down Expand Up @@ -434,6 +465,11 @@ data class AppCacheData(
val sparkSendHashes: List<String> = listOf(),
/** Invoice expiry in epoch seconds of the [sparkSendHashes] that know it. */
val sparkSendExpiries: Map<String, Long> = mapOf(),
/**
* Payment hashes of the unexpired Spark invoices this wallet created, with their expiry in epoch seconds, which
* the wallet refuses to pay: such an invoice names only Spark's provider, so nothing in it tells whose it is.
*/
val sparkOwnInvoices: Map<String, Long> = mapOf(),
/**
* Spark's sends whose outcome it didn't report, by hash, with when they started in epoch seconds, kept across a
* restart until Spark settles them.
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/to/bitkit/repositories/LightningRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3133,6 +3133,10 @@ class LightningRepo @Inject constructor(
/** Whether Spark alone can pay [amountSats], which it does whenever the node cannot. */
fun canSendWithSpark(amountSats: ULong): Boolean = sparkRepo.canSend(amountSats)

/** Whether [bolt11], with [paymentHash] in hex, pays this wallet's Spark balance, see [SparkRepo.isOwnInvoice]. */
suspend fun isOwnSparkInvoice(bolt11: String, paymentHash: String): Boolean =
sparkRepo.isOwnInvoice(bolt11, paymentHash)

/** Whether Spark's whole balance covers a withdrawal debiting [debitSats], its fees included. */
fun canWithdrawWithSpark(debitSats: ULong): Boolean = sparkRepo.canWithdraw(debitSats)

Expand Down
30 changes: 29 additions & 1 deletion app/src/main/java/to/bitkit/repositories/SparkRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,39 @@ class SparkRepo @Inject constructor(
/** A withdrawal's debit already holds its fees, so it is weighed against the whole balance. */
fun canWithdraw(debitSats: ULong): Boolean = _state.value.isReady && _state.value.balanceSats >= debitSats

/**
* Creates a Spark invoice and remembers it as this wallet's own, which [isOwnInvoice] then recognises. An invoice
* that cannot be read or remembered is not handed out.
*/
suspend fun createInvoice(amountSats: ULong?, description: String, expirySecs: UInt): Result<String> =
withContext(bgDispatcher) {
runSuspendCatching { sparkService.receiveBolt11(amountSats, description, expirySecs) }
runSuspendCatching {
sparkService.receiveBolt11(amountSats, description, expirySecs).also { rememberOwnInvoice(it) }
}
}

private suspend fun rememberOwnInvoice(bolt11: String) {
val invoice = sparkService.invoiceDetails(bolt11) ?: throw SparkError.InvoiceUnreadable()
val expiresAt = SparkService.invoiceExpiresAt(invoice.timestamp, invoice.expiry)
cacheStore.addSparkOwnInvoice(invoice.paymentHash, expiresAt.toEpochSeconds(), clock.now().epochSeconds)
}

/**
* Whether [bolt11], with [paymentHash] in hex, pays this Spark wallet: an unexpired invoice this wallet remembers
* creating, or one that carries this wallet's Spark address. Remembered invoices that cannot be read count as
* own, so the invoice is refused instead of paid unchecked. The second check needs Spark connected and is skipped
* without it, as on a build or network without Spark. An invoice a paired watch created is known only once its
* hash was added to the cache.
*/
suspend fun isOwnInvoice(bolt11: String, paymentHash: String): Boolean = withContext(bgDispatcher) {
val isRemembered = runSuspendCatching { cacheStore.hasSparkOwnInvoice(paymentHash, clock.now().epochSeconds) }
.onFailure { Logger.warn("Failed to read the wallet's own Spark invoices", it, context = TAG) }
.getOrDefault(true)
isRemembered || runSuspendCatching { sparkService.carriesOwnSparkAddress(bolt11) }
.onFailure { Logger.debug("Skipped the Spark address check of an invoice: '${it.message}'", context = TAG) }
.getOrDefault(false)
}

/** Returns the Lightning routing fee plus Spark's 0.25% service fee for paying [bolt11]. */
suspend fun estimateFeeSats(bolt11: String, amountSats: ULong?): Result<ULong> = withContext(bgDispatcher) {
runSuspendCatching {
Expand Down
37 changes: 36 additions & 1 deletion app/src/main/java/to/bitkit/services/SparkService.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package to.bitkit.services

import breez_sdk_spark.Bolt11InvoiceDetails
import breez_sdk_spark.BreezSdk
import breez_sdk_spark.ChainApiType
import breez_sdk_spark.CheckRecoverFundsRequest
Expand Down Expand Up @@ -151,6 +152,29 @@ class SparkService @Inject constructor(
/** Whether [shortChannelIds], an invoice's route hint hops, carry a Spark address. */
internal fun hasSparkAddressHint(shortChannelIds: List<ULong>): Boolean =
SPARK_ADDRESS_HINT_SCID in shortChannelIds

private const val SCID_BLOCK_SHIFT = 40
private const val SCID_TX_SHIFT = 16
private const val SCID_TX_MASK = 0xFFFFFFuL
private const val SCID_OUTPUT_MASK = 0xFFFFuL

/** [SPARK_ADDRESS_HINT_SCID] as the SDK's parser prints a hop's: block x transaction x output. */
internal val sparkAddressHintScid: String = SPARK_ADDRESS_HINT_SCID.let {
"${it shr SCID_BLOCK_SHIFT}x${(it shr SCID_TX_SHIFT) and SCID_TX_MASK}x${it and SCID_OUTPUT_MASK}"
}

/**
* Whether [invoice] carries the Spark address of the wallet with [identityPubkey], its Spark identity in hex:
* the node of the Spark address hint is the identity of the wallet that asked for the invoice. Bitkit's own
* invoices carry no such hint, so this only recognises invoices made with the SDK's
* `preferSparkOverLightning` on.
*/
internal fun namesSparkIdentity(invoice: Bolt11InvoiceDetails, identityPubkey: String): Boolean =
invoice.routingHints.any { hint ->
hint.hops.any {
it.shortChannelId == sparkAddressHintScid && it.srcNodeId.equals(identityPubkey, ignoreCase = true)
}
}
}

private val mutex = Mutex()
Expand Down Expand Up @@ -336,7 +360,15 @@ class SparkService @Inject constructor(

/** When [bolt11] expires, in epoch seconds, read by the SDK's own parser; null when it isn't a BOLT11 invoice. */
suspend fun invoiceExpiresAt(bolt11: String): ULong? =
(requireSdk().parse(bolt11) as? InputType.Bolt11Invoice)?.v1?.let { invoiceExpiresAt(it.timestamp, it.expiry) }
invoiceDetails(bolt11)?.let { invoiceExpiresAt(it.timestamp, it.expiry) }

/** [bolt11] as the SDK's own parser reads it; null when it isn't a BOLT11 invoice. */
suspend fun invoiceDetails(bolt11: String): Bolt11InvoiceDetails? =
(requireSdk().parse(bolt11) as? InputType.Bolt11Invoice)?.v1

/** Whether [bolt11] carries this wallet's own Spark address, see [namesSparkIdentity]. */
suspend fun carriesOwnSparkAddress(bolt11: String): Boolean =
invoiceDetails(bolt11)?.let { namesSparkIdentity(it, getInfo().identityPubkey) } == true

/**
* This wallet's Lightning send of [bolt11] as the Spark operators record it, without the local history: null when
Expand Down Expand Up @@ -393,6 +425,9 @@ sealed class SparkError(message: String, cause: Throwable? = null) : AppError(me
class WipeInProgress : SparkError("Spark wallet cannot connect while the wallet is wiped")
class WipeFailed(path: String) : SparkError("Failed to delete Spark storage at '$path'")

/** An invoice Spark created that its own parser cannot read, so it cannot be remembered as the wallet's own. */
class InvoiceUnreadable : SparkError("Spark invoice cannot be read")

/** Stored exit data Spark can never import: an exit state version it doesn't support, or one it can't read. */
class ExitStateUnimportable(cause: Throwable? = null) : SparkError("Spark can't import the exit data", cause)

Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3940,7 +3940,15 @@ class AppViewModel @Inject constructor(
return@takeIf canSend
}

private suspend fun LightningInvoice.isOwnInvoice(): Boolean = isPayee(lightningRepo.awaitNodeId())
/**
* Whether this wallet created the invoice: the node is its payee, or it pays the wallet's Spark balance, which
* the phone and a paired watch share.
*/
private suspend fun LightningInvoice.isOwnInvoice(): Boolean =
isPayee(lightningRepo.awaitNodeId()) || isOwnSparkInvoice()

private suspend fun LightningInvoice.isOwnSparkInvoice(): Boolean =
lightningRepo.isOwnSparkInvoice(bolt11, paymentHash.toHex())

private fun LightningInvoice.isPayee(nodeId: String?): Boolean {
val payee = payeeNodeId?.toHex() ?: return false
Expand All @@ -3951,7 +3959,7 @@ class AppViewModel @Inject constructor(
params: Map<String, String>?,
walletGeneration: Long? = connectionRecovery.currentGeneration(),
): Boolean = decodeLightningParam(params).also { requireCurrentPaymentPreparation(walletGeneration) }
?.isPayee(lightningRepo.getLastKnownNodeId()) == true
?.let { it.isPayee(lightningRepo.getLastKnownNodeId()) || it.isOwnSparkInvoice() } == true

private suspend fun decodeLightningParam(params: Map<String, String>?): LightningInvoice? =
params?.get("lightning")?.let { bolt11 ->
Expand Down
34 changes: 34 additions & 0 deletions app/src/test/java/to/bitkit/data/CacheStoreTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,40 @@ class CacheStoreTest : BaseUnitTest() {
@After
fun tearDown() = runBlocking { sut.reset() }

@Test
fun `an own spark invoice is known in either case until it expires`() = test {
sut.addSparkOwnInvoice("AB12", expiresAt = 2_000, now = 1_000)

assertTrue(sut.hasSparkOwnInvoice("ab12", now = 1_999))
assertTrue(sut.hasSparkOwnInvoice("AB12", now = 1_999))
assertFalse(sut.hasSparkOwnInvoice("ab12", now = 2_000))
assertFalse(sut.hasSparkOwnInvoice("cd34", now = 1_000))
}

@Test
fun `adding an own spark invoice drops the expired ones and keeps those that expire last`() = test {
sut.addSparkOwnInvoice("expired", expiresAt = 1_500, now = 1_000)
sut.addSparkOwnInvoice("first", expiresAt = 3_000, now = 1_600)

assertEquals(mapOf("first" to 3_000L), sut.data.first().sparkOwnInvoices)

repeat(MAX_SPARK_OWN_INVOICES) { sut.addSparkOwnInvoice("hash$it", expiresAt = 3_001L + it, now = 1_600) }

val kept = sut.data.first().sparkOwnInvoices
assertEquals(MAX_SPARK_OWN_INVOICES, kept.size)
assertFalse("first" in kept)
assertTrue("hash0" in kept)
}

@Test
fun `a wallet reset forgets the own spark invoices`() = test {
sut.addSparkOwnInvoice("ab12", expiresAt = 2_000, now = 1_000)

sut.reset()

assertFalse(sut.hasSparkOwnInvoice("ab12", now = 1_000))
}

@Test
fun `a spark send attempt drops expired ones and restores the earlier one`() = test {
sut.setSparkSendAttempt("OLD", attempt = 2, amountSats = 100uL, expiresAt = 1_500, now = 1_000)
Expand Down
64 changes: 64 additions & 0 deletions app/src/test/java/to/bitkit/repositories/SparkRepoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,70 @@ class SparkRepoTest : BaseUnitTest() {
}
}

@Test
fun `an invoice spark creates is remembered as the wallet's own until it expires`() = test {
val store = CacheStore(InMemoryDataStore(AppCacheData()), clock)
val created = now.epochSeconds.toULong()
val details = mock<Bolt11InvoiceDetails> {
on { paymentHash } doReturn "AB12"
on { timestamp } doReturn created
on { expiry } doReturn 3_600uL
}
whenever { sparkService.receiveBolt11(null, "", 3_600u) }.thenReturn("lnbcrt1own")
whenever { sparkService.invoiceDetails("lnbcrt1own") }.thenReturn(details)
whenever { sparkService.carriesOwnSparkAddress(any()) }.thenReturn(false)
val sut = createSut(cacheStore = store)

assertEquals("lnbcrt1own", sut.createInvoice(null, "", 3_600u).getOrThrow())

assertEquals(mapOf("ab12" to now.epochSeconds + 3_600), store.data.first().sparkOwnInvoices)
assertTrue(sut.isOwnInvoice("lnbcrt1own", "ab12"))
assertFalse(sut.isOwnInvoice("lnbcrt1other", "cd34"))

now += 3_600.seconds
assertFalse(sut.isOwnInvoice("lnbcrt1own", "ab12"))
}

@Test
fun `an invoice spark's parser cannot read is not handed out`() = test {
whenever { sparkService.receiveBolt11(null, "", 3_600u) }.thenReturn("lnbcrt1own")
whenever { sparkService.invoiceDetails("lnbcrt1own") }.thenReturn(null)
val sut = createSut(cacheStore = CacheStore(InMemoryDataStore(AppCacheData()), clock))

assertIs<SparkError.InvoiceUnreadable>(sut.createInvoice(null, "", 3_600u).exceptionOrNull())
}

@Test
fun `an invoice is refused as the wallet's own while its remembered invoices cannot be read`() = test {
val store = mock<CacheStore>()
whenever { store.hasSparkOwnInvoice(any(), any()) }.doSuspendableAnswer { throw IOException("disk") }
whenever { sparkService.carriesOwnSparkAddress(any()) }.thenReturn(false)
val sut = createSut(cacheStore = store)

assertTrue(sut.isOwnInvoice("lnbcrt1other", "cd34"))
}

@Test
fun `an invoice that carries this wallet's spark address is its own without being remembered`() = test {
whenever { sparkService.carriesOwnSparkAddress("lnbcrt1hint") }.thenReturn(true)
whenever { sparkService.carriesOwnSparkAddress("lnbcrt1other") }.thenReturn(false)
val sut = createSut(cacheStore = CacheStore(InMemoryDataStore(AppCacheData()), clock))

assertTrue(sut.isOwnInvoice("lnbcrt1hint", "ab12"))
assertFalse(sut.isOwnInvoice("lnbcrt1other", "cd34"))
}

@Test
fun `a remembered invoice is the wallet's own while spark is not connected`() = test {
val store = CacheStore(InMemoryDataStore(AppCacheData()), clock)
store.addSparkOwnInvoice("ab12", now.epochSeconds + 60, now.epochSeconds)
whenever { sparkService.carriesOwnSparkAddress(any()) }.doSuspendableAnswer { throw SparkError.NotConnected() }
val sut = createSut(cacheStore = store)

assertTrue(sut.isOwnInvoice("lnbcrt1own", "AB12"))
assertFalse(sut.isOwnInvoice("lnbcrt1other", "cd34"))
}

@Test
fun `imports a restored exit backup once Spark connects`() = test {
whenever { sparkService.importExitState(any()) }.thenReturn(ImportUnilateralExitStateResponse(2u, 0u, 0u, 0u))
Expand Down
46 changes: 46 additions & 0 deletions app/src/test/java/to/bitkit/services/SparkServiceTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package to.bitkit.services

import breez_sdk_spark.BitcoinNetwork
import breez_sdk_spark.Bolt11Invoice
import breez_sdk_spark.Bolt11InvoiceDetails
import breez_sdk_spark.Bolt11RouteHint
import breez_sdk_spark.Bolt11RouteHintHop
import breez_sdk_spark.ChainApiType
import breez_sdk_spark.Config
import breez_sdk_spark.LeafOptimizationConfig
import breez_sdk_spark.Network
import breez_sdk_spark.PaymentRequestSource
import breez_sdk_spark.SendPaymentOptions
import breez_sdk_spark.SparkConfig
import breez_sdk_spark.TokenOptimizationConfig
Expand All @@ -28,6 +34,11 @@ import kotlin.test.assertNull
import kotlin.test.assertTrue

class SparkServiceTest {
private companion object {
const val SPARK_IDENTITY = "02698b27ac308b275671b3ca25436346469d04a5bba578ae39feba1d65897a6abc"
const val SPARK_PROVIDER_NODE = "0313ee54b3e35eed377248c83e77004972a3807af648a22ea1e8a9d22ef8b9a11c"
}

@get:Rule
val tempFolder = TemporaryFolder()

Expand Down Expand Up @@ -71,6 +82,22 @@ class SparkServiceTest {
assertFalse(SparkService.hasSparkAddressHint(emptyList()))
}

// What SDK 0.28.3 printed on the local regtest Spark stack (2026-11-27) for a wallet whose identity is
// SPARK_IDENTITY: an invoice made with Bitkit's settings carries only the provider's channel hint, and one made
// with `preferSparkOverLightning` on also carries the Spark address hint, whose node is the identity.
@Test
fun `an invoice names a spark identity only by its spark address hint`() {
val providerHint = hint("026ccad2762df4865753f7adc464acdbb9ae4509d0f2109789b91941cfe0e67261", "1x1026x2")
val sparkHint = hint(SPARK_IDENTITY, "16000000x16000000x1")

assertEquals("16000000x16000000x1", SparkService.sparkAddressHintScid)
assertTrue(SparkService.namesSparkIdentity(invoice(providerHint, sparkHint), SPARK_IDENTITY))
assertTrue(SparkService.namesSparkIdentity(invoice(providerHint, sparkHint), SPARK_IDENTITY.uppercase()))
assertFalse(SparkService.namesSparkIdentity(invoice(providerHint), SPARK_IDENTITY))
assertFalse(SparkService.namesSparkIdentity(invoice(providerHint, sparkHint), SPARK_PROVIDER_NODE))
assertFalse(SparkService.namesSparkIdentity(invoice(hint(SPARK_IDENTITY, "1x1026x2")), SPARK_IDENTITY))
}

@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)
Expand Down Expand Up @@ -160,6 +187,25 @@ class SparkServiceTest {
assertNull(config.watchtowerFeeLadderEnabled)
}

private fun hint(srcNodeId: String, shortChannelId: String) = Bolt11RouteHint(
listOf(Bolt11RouteHintHop(srcNodeId, shortChannelId, 0u, 0u, 0u, null, null)),
)

private fun invoice(vararg hints: Bolt11RouteHint) = Bolt11InvoiceDetails(
amountMsat = null,
description = "",
descriptionHash = null,
expiry = 3_600uL,
invoice = Bolt11Invoice("lnbcrt1invoice", PaymentRequestSource(null, null)),
minFinalCltvExpiryDelta = 60uL,
network = BitcoinNetwork.REGTEST,
payeePubkey = SPARK_PROVIDER_NODE,
paymentHash = "0a00a78ffbde5c36ad8220a26bb2609347bbf7e7c195622c42b81f088ccf1f6e",
paymentSecret = "secret",
routingHints = hints.toList(),
timestamp = 1_795_827_219uL,
)

@Test
fun `invoices carry no spark address on any network, so every payment is a lightning payment bitkit records`() {
Network.entries.forEach { network ->
Expand Down
Loading