Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ada3465
feat: add watch limits and the pay request handoff to wearlink
jvsena42 Nov 29, 2026
b4fce20
feat: hold watch quickpay to its own limits set from the phone's watc…
jvsena42 Nov 29, 2026
dde6c49
feat: hand a lightning request from the phone's send review to the watch
jvsena42 Nov 29, 2026
11d56b4
feat: prompt once to install bitkit on a connected watch
jvsena42 Nov 29, 2026
3e11795
docs: describe watch limits, pay on watch and the install prompt
jvsena42 Nov 29, 2026
2474f52
fix: clear lint findings in the wear watch management
jvsena42 Nov 29, 2026
8f5bdf9
fix: offer pay on watch for a reviewed bolt11 invoice with an amount
jvsena42 Nov 29, 2026
cd65fef
fix: cap a watch quickpay payment by the lower of the two amounts
jvsena42 Nov 29, 2026
58d765a
fix: ask for the pin on watch quickpay changes by the phone's rule
jvsena42 Nov 29, 2026
5ee6f58
fix: take only bolt11 with an amount on a handoff and show refusals
jvsena42 Nov 29, 2026
f685bd1
fix: say what became of install on watch and keep the prompt on failure
jvsena42 Nov 29, 2026
98e452f
fix: format the watch's quickpay spend with the app's fiat formatter
jvsena42 Nov 29, 2026
e4f2aa0
fix: use title case for the russian watch titles and buttons
jvsena42 Nov 29, 2026
b721f19
test: make watch quickpay journeys fail on the pin rule, cover back
jvsena42 Nov 29, 2026
6ca03ac
fix: clear lint findings in the watch management review fixes
jvsena42 Nov 29, 2026
9de7f9e
feat: open the watch's pair screen only from the phone
jvsena42 Nov 29, 2026
79cd57c
feat: prompt to pair a connected watch that has bitkit
jvsena42 Nov 29, 2026
1753c7d
docs: describe phone-started watch pairing and the pair prompt
jvsena42 Nov 29, 2026
b592675
fix: pair the watch the prompt offered, once, noting it on success
jvsena42 Nov 29, 2026
3be0287
feat: check the pair prompt when a watch with bitkit connects
jvsena42 Nov 29, 2026
563c190
fix: offer watches to pair again after a wallet wipe
jvsena42 Nov 29, 2026
0cb943e
feat: show start on phone on watch onboarding, connecting on pair
jvsena42 Nov 29, 2026
6eed307
docs: describe the pair prompt's recheck, retry and wipe rules
jvsena42 Nov 29, 2026
572a41e
fix: start no prompted pairing once the watch sheet closed
jvsena42 Nov 29, 2026
9ceed1f
docs: restart the phone app before the pair prompt returns
jvsena42 Nov 29, 2026
4c679f2
test: cover the pair prompt's recheck, handover and queued restart
jvsena42 Nov 29, 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
10 changes: 10 additions & 0 deletions app/src/main/java/to/bitkit/data/SettingsStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ data class SettingsData(
val isQuickPayEnabled: Boolean = false,
val quickPayAmount: Int = 5,
val quickPayDailyLimitMultiplier: Int = 5,
/**
* The paired Wear OS watch's own QuickPay, set here and pushed to the watch, and carried by the settings backup
* to a watch that reads it. Off until the user turns it on; it holds on the watch only while [isQuickPayEnabled]
* is on too. Older builds and bitkit-ios ignore these keys, and a backup without them gives these defaults.
*/
val isWatchQuickPayEnabled: Boolean = false,
val watchQuickPayAmount: Int = 5,
val watchQuickPayDailyLimitMultiplier: Int = 5,
/** Whether the prompt to install Bitkit on a connected watch was shown; it shows once. */
val watchInstallPromptSeen: Boolean = false,
val isPinEnabled: Boolean = false,
val isBiometricEnabled: Boolean = false,
val isPinForPaymentsEnabled: Boolean = false,
Expand Down
31 changes: 28 additions & 3 deletions app/src/main/java/to/bitkit/data/WatchLinkStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,28 @@ interface WatchGuardState {

/**
* The phone's note of its paired watch, this install's random id for pairings, the count of seed transfers that
* were started and not finished, and what the watch last said for the shared guards ([WatchGuardState]). It belongs
* to the install and is in no backup: the link keys are in the Keystore and cannot be restored, so a restored phone
* pairs again. Nothing here is secret.
* were started and not finished, what the watch last said for the shared guards ([WatchGuardState]) and the watches
* already offered to pair. It belongs to the install and is in no backup: the link keys are in the Keystore and
* cannot be restored, so a restored phone pairs again. Nothing here is secret.
*/
@Singleton
class WatchLinkStore internal constructor(
private val store: DataStore<WatchLinkData>,
) : LinkRecordStore, WatchGuardState {
companion object {
/** How many watches offered to pair are remembered; the oldest is forgotten first. */
const val PAIR_PROMPTS_KEPT = 10
}

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

override val record: Flow<LinkRecord?> = store.data.map { it.record }.distinctUntilChanged()

/** The watch's last QuickPay count as it changes, or null without a paired watch or before its first count. */
val watchQuickPayUpdates: Flow<QuickPayDoc?> =
store.data.map { data -> data.watchQuickPay?.takeIf { data.record != null } }.distinctUntilChanged()

override suspend fun load(): LinkRecord? = store.data.first().record

override suspend fun update(transform: (LinkRecord?) -> LinkRecord?): LinkRecord? =
Expand Down Expand Up @@ -106,6 +115,21 @@ class WatchLinkStore internal constructor(
store.updateData { it.copy(watchInvoices = emptyMap(), watchQuickPay = null, watchSends = emptyList()) }
}

/** The node ids of the watches the prompt to pair was shown for, oldest first. */
suspend fun pairPromptNodeIds(): List<String> = store.data.first().pairPromptNodeIds

/** Notes that the prompt to pair was shown for the watch [nodeId], so it is not shown for it again. */
suspend fun notePairPrompt(nodeId: String) {
store.updateData {
it.copy(pairPromptNodeIds = (it.pairPromptNodeIds - nodeId + nodeId).takeLast(PAIR_PROMPTS_KEPT))
}
}

/** Forgets the watches the prompt to pair was shown for, as when the phone's wallet is wiped. */
suspend fun clearPairPrompts() {
store.updateData { it.copy(pairPromptNodeIds = emptyList()) }
}

private suspend fun paired(): WatchLinkData? = store.data.first().takeIf { it.record != null }

/** This install's id for pairings, made at first use. */
Expand All @@ -125,4 +149,5 @@ data class WatchLinkData(
val watchInvoices: Map<String, Long> = emptyMap(),
val watchQuickPay: QuickPayDoc? = null,
val watchSends: List<OpenSend> = emptyList(),
val pairPromptNodeIds: List<String> = emptyList(),
)
20 changes: 19 additions & 1 deletion app/src/main/java/to/bitkit/repositories/QuickPayRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,10 @@ class QuickPayAuthorization(
val useBiometrics: Boolean,
)

/** One QuickPay setting the user asked to change, with its new value. */
/**
* One QuickPay setting the user asked to change, with its new value: the phone's own QuickPay or the watch's. Both
* follow one rule: a raise asks for the PIN or biometric check while payments need the PIN.
*/
sealed interface QuickPayChange {
fun isRaise(settings: SettingsData): Boolean
fun applyTo(settings: SettingsData): SettingsData
Expand All @@ -1008,6 +1011,21 @@ sealed interface QuickPayChange {
override fun isRaise(settings: SettingsData) = value > settings.quickPayDailyLimitMultiplier
override fun applyTo(settings: SettingsData) = settings.copy(quickPayDailyLimitMultiplier = value)
}

data class WatchEnabled(val value: Boolean) : QuickPayChange {
override fun isRaise(settings: SettingsData) = value && !settings.isWatchQuickPayEnabled
override fun applyTo(settings: SettingsData) = settings.copy(isWatchQuickPayEnabled = value)
}

data class WatchAmount(val value: Int) : QuickPayChange {
override fun isRaise(settings: SettingsData) = value > settings.watchQuickPayAmount
override fun applyTo(settings: SettingsData) = settings.copy(watchQuickPayAmount = value)
}

data class WatchDailyLimitMultiplier(val value: Int) : QuickPayChange {
override fun isRaise(settings: SettingsData) = value > settings.watchQuickPayDailyLimitMultiplier
override fun applyTo(settings: SettingsData) = settings.copy(watchQuickPayDailyLimitMultiplier = value)
}
}

fun interface QuickPayInvoiceParser {
Expand Down
Loading