@bsv/expo-wallet-toolbox 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +139 -30
  2. package/README.md +79 -79
  3. package/core/backup/RemoteSyncReader.ts +26 -24
  4. package/core/backup/appData.ts +9 -8
  5. package/core/backup/codec.ts +21 -18
  6. package/core/backup/constants.ts +5 -5
  7. package/core/backup/contactsBackup.ts +8 -8
  8. package/core/backup/cursor.ts +12 -7
  9. package/core/backup/derive.ts +3 -3
  10. package/core/backup/deviceId.ts +2 -2
  11. package/core/backup/erase.ts +2 -2
  12. package/core/backup/preference.ts +2 -2
  13. package/core/backup/push.ts +10 -12
  14. package/core/backup/restore.ts +22 -14
  15. package/core/backup/restoreOnImport.ts +3 -2
  16. package/core/config.tsx +17 -13
  17. package/core/constants.ts +34 -11
  18. package/core/contacts/contactsStore.ts +4 -3
  19. package/core/context/WalletConnectionContext.tsx +294 -212
  20. package/core/context/WalletContext.tsx +132 -97
  21. package/core/context/defaultWalletSettings.ts +4 -2
  22. package/core/demo/demoLedger.ts +1 -5
  23. package/core/directpay/DirectPayProvider.tsx +15 -24
  24. package/core/directpay/receive.ts +2 -1
  25. package/core/headers/checkpoints.ts +10 -1
  26. package/core/headers/headerStore.ts +13 -2
  27. package/core/hooks/useConfirmationSound.ts +3 -3
  28. package/core/hooks/useHaptics.ts +23 -6
  29. package/core/i18n/translations.tsx +303 -123
  30. package/core/index.ts +2 -0
  31. package/core/localpay/codec.ts +12 -6
  32. package/core/localpay/deviceCaps.ts +4 -14
  33. package/core/localpay/pending.ts +2 -1
  34. package/core/localpay/qr.ts +1 -1
  35. package/core/localpay/settlementAck.ts +1 -4
  36. package/core/localpay/transport/ble.ts +2 -2
  37. package/core/localpay/transport/socket.ts +1 -1
  38. package/core/mandala/abortGuard.ts +1 -1
  39. package/core/mandala/drain.ts +3 -0
  40. package/core/mandala/permissionModule.ts +3 -2
  41. package/core/mandala/resendTransfer.ts +4 -1
  42. package/core/mandala/runtime.ts +4 -4
  43. package/core/monitor/TaskBackupPush.ts +10 -13
  44. package/core/net/chainMatch.ts +8 -5
  45. package/core/networks.ts +145 -0
  46. package/core/parsePeerPayURI.ts +4 -1
  47. package/core/pay/beefRepair.ts +6 -3
  48. package/core/pay/creditErrors.ts +37 -1
  49. package/core/pay/rails/address.ts +10 -6
  50. package/core/pay/rails/handle.ts +84 -11
  51. package/core/pay/rails/index.ts +18 -2
  52. package/core/pay/receiveHistory.ts +8 -8
  53. package/core/peerpay/handleResendRequests.ts +11 -18
  54. package/core/peerpay/inboxAttempts.ts +1 -4
  55. package/core/peerpay/rebuildToken.ts +12 -9
  56. package/core/profiles/profileStore.ts +2 -1
  57. package/core/profiles/removalProblems.ts +3 -1
  58. package/core/services/arcTokenStorage.ts +2 -1
  59. package/core/services/arcadeBroadcastProvider.ts +7 -17
  60. package/core/services/secrets/envelope.ts +1 -6
  61. package/core/services/secrets/hkdf.ts +1 -6
  62. package/core/services/secrets/index.ts +3 -22
  63. package/core/services/usdFxRates.ts +1 -4
  64. package/core/services/vault/VaultKeyService.ts +2 -1
  65. package/core/services/vault/chainRecovery.ts +48 -21
  66. package/core/services/vault/metaAuthority.ts +4 -1
  67. package/core/services/vault/r1comb.ts +113 -51
  68. package/core/services/vault/session.ts +5 -1
  69. package/core/services/vault/transfers.ts +699 -576
  70. package/core/services/vault/vaultStore.ts +12 -10
  71. package/core/services/walletArgLimits.ts +1 -2
  72. package/core/services/walletConnectionValidation.ts +44 -28
  73. package/core/services/walletServiceConfig.ts +9 -40
  74. package/core/storage/StorageExpoSQLite.ts +7 -21
  75. package/core/storage/methods/listActionsSql.ts +81 -67
  76. package/core/storage/methods/listOutputsSql.ts +21 -16
  77. package/core/storage/methods/reviewStatusSql.ts +1 -4
  78. package/core/stores/ConnectionStore.ts +1 -1
  79. package/core/theme/ThemeContext.tsx +12 -16
  80. package/core/theme/motion.ts +3 -3
  81. package/core/theme/tokens.ts +6 -6
  82. package/core/toolboxConfig.ts +23 -0
  83. package/core/walletDbRegistry.ts +7 -5
  84. package/core/walletRepair/runWalletCheck.ts +1 -4
  85. package/package.json +2 -2
  86. package/ui/components/pay/AddressReceive.tsx +3 -3
  87. package/ui/components/pay/HandleReceive.tsx +58 -15
  88. package/ui/components/pay/MessageBoxConfig.tsx +46 -20
  89. package/ui/components/pay/NearbyFlow.tsx +575 -507
  90. package/ui/components/pay/OfflineNotice.tsx +1 -3
  91. package/ui/components/pay/PayCellRow.tsx +1 -4
  92. package/ui/components/pay/PayForm.tsx +1 -3
  93. package/ui/components/pay/RequestHub.tsx +14 -6
  94. package/ui/components/pay/UniversalSend.tsx +137 -40
  95. package/ui/components/pay/tokenSendCopy.ts +1 -2
  96. package/ui/components/pay/useRecipientInput.ts +2 -2
  97. package/ui/components/security/WalletLockNotice.tsx +1 -3
  98. package/ui/components/ui/AlertCard.tsx +44 -45
  99. package/ui/components/ui/BlurChrome.tsx +4 -15
  100. package/ui/components/ui/Celebration.tsx +3 -3
  101. package/ui/components/ui/ChoiceSheet.ts +1 -3
  102. package/ui/components/ui/ErrorBoundary.tsx +2 -6
  103. package/ui/components/ui/GroupedList.tsx +13 -31
  104. package/ui/components/ui/IconButton.tsx +6 -9
  105. package/ui/components/ui/ListRow.tsx +19 -25
  106. package/ui/components/ui/PresenceRow.tsx +4 -4
  107. package/ui/components/ui/PressableScale.tsx +24 -20
  108. package/ui/components/ui/Toast.tsx +23 -16
  109. package/ui/components/vault/KeyChooser.tsx +9 -6
  110. package/ui/components/vault/VaultBackdrop.tsx +1 -8
  111. package/ui/components/vault/VaultCeremonySheet.tsx +5 -5
  112. package/ui/components/wallet/ActivityRow.tsx +3 -2
  113. package/ui/components/wallet/BackupReminderSheet.tsx +1 -5
  114. package/ui/components/wallet/Balance.tsx +4 -1
  115. package/ui/components/wallet/ContactActivityList.tsx +7 -7
  116. package/ui/components/wallet/IconPickerSheet.tsx +1 -5
  117. package/ui/components/wallet/ProfileSwitcherPopover.tsx +6 -1
  118. package/ui/components/wallet/tokenEviction.ts +4 -1
  119. package/ui/hooks/useMandala.ts +1 -7
  120. package/ui/hooks/useOfflineNoticeActions.ts +21 -27
  121. package/ui/hooks/useSpendableBalance.ts +2 -2
  122. package/ui/hooks/useVaultCoverage.ts +7 -1
  123. package/ui/index.ts +9 -1
  124. package/ui/resolveIdentity.ts +20 -8
  125. package/ui/screens/ConnectionsScreen.tsx +44 -18
  126. package/ui/screens/LogsScreen.tsx +24 -22
  127. package/ui/screens/PairScreen.tsx +85 -54
  128. package/ui/screens/PayScreen.tsx +5 -1
  129. package/ui/screens/ProfileScreen.tsx +0 -3
  130. package/ui/screens/TrustScreen.tsx +125 -80
  131. package/ui/screens/VaultScreen.tsx +19 -7
  132. package/ui/screens/VaultTransferScreen.tsx +5 -1
  133. package/ui/screens/WalletCheckScreen.tsx +14 -17
  134. package/ui/screens/WalletConfigScreen.tsx +414 -376
  135. package/ui/screens/WalletHomeScreen.tsx +47 -42
@@ -1,9 +1,6 @@
1
1
  import React, { createContext, useContext, useEffect, useMemo } from 'react'
2
2
  import { useColorScheme } from 'react-native'
3
- import {
4
- lightColors as tokenLightColors,
5
- darkColors as tokenDarkColors
6
- } from './tokens'
3
+ import { lightColors as tokenLightColors, darkColors as tokenDarkColors } from './tokens'
7
4
  import { assertThemeContrast } from './assertThemeContrast'
8
5
 
9
6
  // Theme type definitions
@@ -137,7 +134,7 @@ const darkColors: ThemeColors = {
137
134
  basketApproval: tokenDarkColors.permissionBasket,
138
135
  identityApproval: tokenDarkColors.permissionIdentity,
139
136
  renewalApproval: tokenDarkColors.accentSecondary,
140
- gold: '#92811f',
137
+ gold: '#92811f'
141
138
  }
142
139
 
143
140
  // Create the context with default values
@@ -167,16 +164,15 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
167
164
  assertThemeContrast(colors, isDark ? 'dark' : 'light')
168
165
  }, [colors, isDark])
169
166
 
170
- const value = useMemo(() => ({
171
- mode: 'system' as ThemeMode,
172
- setThemeMode: () => {},
173
- colors,
174
- isDark
175
- }), [colors, isDark])
176
-
177
- return (
178
- <ThemeContext.Provider value={value}>
179
- {children}
180
- </ThemeContext.Provider>
167
+ const value = useMemo(
168
+ () => ({
169
+ mode: 'system' as ThemeMode,
170
+ setThemeMode: () => {},
171
+ colors,
172
+ isDark
173
+ }),
174
+ [colors, isDark]
181
175
  )
176
+
177
+ return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>
182
178
  }
@@ -29,14 +29,14 @@ import type { WithSpringConfig } from 'react-native-reanimated'
29
29
  */
30
30
  export const easings = {
31
31
  /** cubic-bezier(0.23, 1, 0.32, 1) — a long, soft deceleration. */
32
- out: Easing.bezier(0.23, 1, 0.32, 1),
32
+ out: Easing.bezier(0.23, 1, 0.32, 1)
33
33
  } as const
34
34
 
35
35
  export const springs = {
36
36
  /** Buttons, small elements, alert cards. Custom-tuned — NOT Reanimated's built-in presets. */
37
37
  snappy: { mass: 1, stiffness: 380, damping: 36 } satisfies WithSpringConfig,
38
38
  /** Larger surfaces: sheets, popovers, dropdowns. */
39
- settle: { mass: 1, stiffness: 280, damping: 32 } satisfies WithSpringConfig,
39
+ settle: { mass: 1, stiffness: 280, damping: 32 } satisfies WithSpringConfig
40
40
  } as const
41
41
 
42
42
  /** All values in milliseconds. */
@@ -46,5 +46,5 @@ export const durations = {
46
46
  /** Small movements, toasts. */
47
47
  quick: 250,
48
48
  /** Largest allowed — full-surface transitions. */
49
- moderate: 350,
49
+ moderate: 350
50
50
  } as const
@@ -26,7 +26,7 @@ export const spacing = {
26
26
  lg: 16,
27
27
  xl: 20,
28
28
  xxl: 24,
29
- xxxl: 32,
29
+ xxxl: 32
30
30
  } as const
31
31
 
32
32
  /* --------------------------------- Radii --------------------------------- */
@@ -42,7 +42,7 @@ export const radii = {
42
42
  md: 12,
43
43
  lg: 14,
44
44
  xl: 24,
45
- pill: 999,
45
+ pill: 999
46
46
  } as const
47
47
 
48
48
  /* ------------------------------- Typography ------------------------------ */
@@ -68,7 +68,7 @@ export const typography = {
68
68
  subhead: { fontSize: 15, fontWeight: '400' as const, lineHeight: 20 },
69
69
  footnote: { fontSize: 13, fontWeight: '400' as const, lineHeight: 18 },
70
70
  caption1: { fontSize: 12, fontWeight: '400' as const, lineHeight: 16 },
71
- caption2: { fontSize: 11, fontWeight: '400' as const, lineHeight: 13 },
71
+ caption2: { fontSize: 11, fontWeight: '400' as const, lineHeight: 13 }
72
72
  } as const
73
73
 
74
74
  /* --------------------------------- Colors -------------------------------- */
@@ -151,7 +151,7 @@ export const lightColors = {
151
151
  permissionProtocol: '#34C759',
152
152
  permissionBasket: '#34C759',
153
153
  permissionIdentity: '#007AFF',
154
- permissionSpending: '#FF9500',
154
+ permissionSpending: '#FF9500'
155
155
  } as const
156
156
 
157
157
  export const darkColors = {
@@ -222,11 +222,11 @@ export const darkColors = {
222
222
  permissionProtocol: '#1fae4378',
223
223
  permissionBasket: '#1fae4378',
224
224
  permissionIdentity: '#24588dff',
225
- permissionSpending: '#FF9F0A',
225
+ permissionSpending: '#FF9F0A'
226
226
  } as const
227
227
 
228
228
  /* ------------------------------ Hit Targets ------------------------------ */
229
229
 
230
230
  export const hitTargets = {
231
- minimum: 44, // iOS HIG minimum touch target
231
+ minimum: 44 // iOS HIG minimum touch target
232
232
  } as const
@@ -16,6 +16,11 @@ export interface ToolboxServiceConfig {
16
16
  chaintracksUrl?: string
17
17
  whatsOnChainApiKey?: string
18
18
  taalApiKey?: string
19
+ /**
20
+ * The chain's default MessageBox origin. A user's own choice in Settings
21
+ * still wins; this only replaces the built-in default in `NETWORKS`.
22
+ */
23
+ messageBoxUrl?: string
19
24
  }
20
25
 
21
26
  /**
@@ -299,6 +304,24 @@ export function getServiceConfig(chain: AppChain): ToolboxServiceConfig {
299
304
  return current.services[chain] ?? {}
300
305
  }
301
306
 
307
+ /**
308
+ * The host's default MessageBox origin for a chain, or undefined to use the
309
+ * built-in one. Never throws, like `getMandalaEndpoints`: it is read while
310
+ * rendering, and an unconfigured or malformed value must look like "no
311
+ * override" rather than crash.
312
+ */
313
+ export function getMessageBoxUrlOverride(chain: AppChain): string | undefined {
314
+ const url = trimTrailingSlashes(current?.services[chain]?.messageBoxUrl?.trim() ?? '')
315
+ if (url === '') return undefined
316
+ let parsed: URL
317
+ try {
318
+ parsed = new URL(url)
319
+ } catch {
320
+ return undefined
321
+ }
322
+ return isAllowedServiceOrigin(parsed) ? url : undefined
323
+ }
324
+
302
325
  const COMPRESSED_KEY = /^0[23][0-9a-fA-F]{64}$/
303
326
 
304
327
  /**
@@ -11,6 +11,8 @@
11
11
  * Current : wallet-<keySuffix>-<chain>net-<unix_s>.db → timestamp = <unix_s>
12
12
  */
13
13
 
14
+ import { APP_CHAINS } from './networks'
15
+
14
16
  // ── Filename parsing ────────────────────────────────────────────────────────
15
17
 
16
18
  /**
@@ -18,14 +20,14 @@
18
20
  *
19
21
  * Groups:
20
22
  * 1 – keySuffix (8 hex chars from the end of the identityKey)
21
- * 2 – chain (main | test | teratest)
23
+ * 2 – chain (main | test | teratest | scaletest)
22
24
  * 3 – timestamp (digits, optional)
23
25
  */
24
- const DB_FILENAME_RE = /^wallet-([a-fA-F0-9]{8})-(main|test|teratest)net(?:-(\d+))?\.db$/
26
+ const DB_FILENAME_RE = /^wallet-([a-fA-F0-9]{8})-(main|test|teratest|scaletest)net(?:-(\d+))?\.db$/
25
27
 
26
28
  export interface ParsedDbFilename {
27
29
  keySuffix: string
28
- chain: string // 'main' | 'test' | 'teratest'
30
+ chain: string // an AppChain
29
31
  timestamp: number // 0 for legacy files without a timestamp segment
30
32
  }
31
33
 
@@ -85,7 +87,7 @@ export function selectLatestDb(filenames: string[]): string {
85
87
  // the barrel, which breaks a plain `jest` host that never touches the
86
88
  // registry (no native module to resolve). Same class of issue documented on
87
89
  // useHaptics.ts and services/vault/driver.ts/random.ts's lazy requires.
88
- type AsyncStorageModule = typeof import('@react-native-async-storage/async-storage')['default']
90
+ type AsyncStorageModule = (typeof import('@react-native-async-storage/async-storage'))['default']
89
91
  let asyncStorage: AsyncStorageModule | undefined
90
92
  function getAsyncStorage(): AsyncStorageModule {
91
93
  if (!asyncStorage) {
@@ -114,7 +116,7 @@ export async function getRegisteredDbs(keySuffix: string, chain: string): Promis
114
116
  }
115
117
 
116
118
  /** The networks a wallet database can belong to. */
117
- const WALLET_DB_CHAINS = ['main', 'test', 'teratest'] as const
119
+ const WALLET_DB_CHAINS = APP_CHAINS
118
120
 
119
121
  /**
120
122
  * Every registered wallet DB filename for an identity, on every network. Unlike
@@ -98,7 +98,6 @@ function pushStatus(
98
98
  onStepDone?.(id, status)
99
99
  }
100
100
 
101
-
102
101
  export async function runWalletCheck(
103
102
  ports: WalletCheckPorts,
104
103
  onStep: (id: WalletCheckStepId) => void,
@@ -161,9 +160,7 @@ export async function runWalletCheck(
161
160
  )
162
161
 
163
162
  onStep('proofs')
164
- const proofs = await guard(skips, 'proofs', { repaired: 0 }, () =>
165
- settle(() => ports.checkProofs(), { repaired: 0 })
166
- )
163
+ const proofs = await guard(skips, 'proofs', { repaired: 0 }, () => settle(() => ports.checkProofs(), { repaired: 0 }))
167
164
  record('proofs', proofs, () => ((proofs as { ok?: boolean }).ok === true ? 'ok' : 'error'))
168
165
 
169
166
  onStep('backup')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/expo-wallet-toolbox",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "private": false,
5
5
  "description": "Wallet screens and P2P local-payment backend for Expo/React Native apps, extracted from BSV Wallet.",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -38,7 +38,7 @@
38
38
  "@bsv/sdk": "^2.8.11",
39
39
  "@bsv/templates": "^2.0.0",
40
40
  "@bsv/webrtpay": "^0.2.1",
41
- "@bsv/wallet-toolbox-mobile": "^2.14.3",
41
+ "@bsv/wallet-toolbox-mobile": "^2.14.9",
42
42
  "@expo/vector-icons": "^15.0.3",
43
43
  "@noble/curves": "^2.3.0",
44
44
  "@react-native-async-storage/async-storage": "^2.2.0",
@@ -174,7 +174,7 @@ export default function AddressReceive({
174
174
 
175
175
  const load = useCallback(
176
176
  async (offset: number) => {
177
- if (!wallet) return
177
+ if (!wallet || !woc) return
178
178
  setLoading(true)
179
179
  try {
180
180
  const date = getCurrentDate(offset)
@@ -202,7 +202,7 @@ export default function AddressReceive({
202
202
  setLoading(false)
203
203
  }
204
204
  },
205
- [wallet, adminOriginator, woc.network, storage, t]
205
+ [wallet, adminOriginator, woc?.network, storage, t]
206
206
  )
207
207
 
208
208
  useEffect(() => {
@@ -273,7 +273,7 @@ export default function AddressReceive({
273
273
  * screen precisely because they want an answer immediately.
274
274
  */
275
275
  const handleSweepNow = useCallback(async () => {
276
- if (!wallet || !address) return
276
+ if (!wallet || !address || !woc) return
277
277
  setSweeping(true)
278
278
  try {
279
279
  const { importedSatoshis } = await sweepAddress({
@@ -25,6 +25,7 @@ import {
25
25
  TouchableOpacity,
26
26
  View
27
27
  } from 'react-native'
28
+ import { useDirectPay } from '../../../core/directpay/DirectPayProvider'
28
29
  import { useTranslation } from 'react-i18next'
29
30
  import { PeerPayClient, type IncomingPayment } from '@bsv/message-box-client'
30
31
  import { type DisplayableIdentity } from '@bsv/sdk'
@@ -42,6 +43,7 @@ import PressableScale from '../ui/PressableScale'
42
43
  import { showAlert } from '../ui/AlertCard'
43
44
  import { showToast } from '../ui/Toast'
44
45
  import { makeIdentityClient, resolveIdentity } from '../../resolveIdentity'
46
+ import { bindMessageBoxNetwork } from '../../../core/pay/rails/handle'
45
47
  import { makeBeefRepair } from '../../../core/pay/beefRepair'
46
48
  import { wocConfigFor } from '../../../core/pay/rails/address'
47
49
  import { makeCreditClassifier } from '../../../core/pay/creditErrors'
@@ -408,6 +410,7 @@ export default function HandleReceive({
408
410
  }: HandleReceiveProps = {}) {
409
411
  const { t } = useTranslation()
410
412
  const { colors } = useTheme()
413
+ const directPay = useDirectPay()
411
414
  const Ionicons = loadIonicons()
412
415
  const QRCode = loadQRCode()
413
416
  const { useFocusEffect } = loadExpoRouter()
@@ -419,7 +422,7 @@ export default function HandleReceive({
419
422
  const mandala = useMandala()
420
423
  const [identityError, setIdentityError] = useState(false)
421
424
  const [copied, setCopied] = useState(false)
422
- const { messageBoxUrl } = useMessageBoxConfig(t)
425
+ const { messageBoxUrl } = useMessageBoxConfig(t, selectedNetwork)
423
426
  const isConfigured = !!messageBoxUrl && messageBoxUrl !== NO_MESSAGE_BOX
424
427
 
425
428
  const [payments, setPayments] = useState<IncomingPayment[]>([])
@@ -495,15 +498,18 @@ export default function HandleReceive({
495
498
  const newPeerPayClient = useCallback((): PeerPayClient | null => {
496
499
  if (!isConfigured || !messageBoxUrl || !wallet) return null
497
500
  try {
498
- return new PeerPayClient({
499
- messageBoxHost: messageBoxUrl,
500
- walletClient: wallet as any,
501
- originator: adminOriginator
502
- })
501
+ return bindMessageBoxNetwork(
502
+ new PeerPayClient({
503
+ messageBoxHost: messageBoxUrl,
504
+ walletClient: wallet as any,
505
+ originator: adminOriginator
506
+ }),
507
+ selectedNetwork
508
+ )
503
509
  } catch {
504
510
  return null
505
511
  }
506
- }, [isConfigured, messageBoxUrl, wallet, adminOriginator])
512
+ }, [isConfigured, messageBoxUrl, wallet, adminOriginator, selectedNetwork])
507
513
  /** The client every inbox read, accept and discard goes through. */
508
514
  const peerPayClient = useMemo(() => newPeerPayClient(), [newPeerPayClient])
509
515
 
@@ -688,9 +694,7 @@ export default function HandleReceive({
688
694
  // receipt says both rather than claiming a settlement nobody has.
689
695
  statusNote: arrival.status === 'settled' ? undefined : t('local_pay_token_not_cleared', { issuer }),
690
696
  // Disclosure at the one moment the user is definitely looking.
691
- firstHoldNote: firstHold
692
- ? t('token_first_hold', { ticker: arrival.asset.ticker, issuer })
693
- : undefined
697
+ firstHoldNote: firstHold ? t('token_first_hold', { ticker: arrival.asset.ticker, issuer }) : undefined
694
698
  })
695
699
  } catch {
696
700
  // A drain that could not run is not news on this screen: the monitor task
@@ -948,6 +952,34 @@ export default function HandleReceive({
948
952
  // Scrolls, because a 240pt QR plus the inbox overflows a small screen and a
949
953
  // note being edited puts the keyboard over the row that owns it.
950
954
  <ScrollView contentContainerStyle={styles.container} keyboardShouldPersistTaps="handled">
955
+ {/* Live payments: whether this wallet can be paid directly while the app is open. Only in a
956
+ build that offers them, and only for BSV (a token always arrives by message box). */}
957
+ {directPay.available && !asset && (
958
+ <View
959
+ style={[styles.liveCard, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
960
+ accessibilityLiveRegion="polite"
961
+ >
962
+ <View
963
+ style={[
964
+ styles.liveDot,
965
+ {
966
+ backgroundColor:
967
+ directPay.live.tone === 'on'
968
+ ? colors.success
969
+ : directPay.live.tone === 'error'
970
+ ? colors.error
971
+ : directPay.live.tone === 'connecting'
972
+ ? colors.warning
973
+ : colors.separator
974
+ }
975
+ ]}
976
+ />
977
+ <View style={styles.liveText}>
978
+ <Text style={[styles.liveTitle, { color: colors.textPrimary }]}>{t(directPay.live.titleKey)}</Text>
979
+ <Text style={[styles.liveBody, { color: colors.textSecondary }]}>{t(directPay.live.bodyKey)}</Text>
980
+ </View>
981
+ </View>
982
+ )}
951
983
  {/* Your handle. The QR is the focal element — it is the thing physically
952
984
  held up to another device. */}
953
985
  {/* The figure the code asks for, as its price. Only when one was named. */}
@@ -965,11 +997,9 @@ export default function HandleReceive({
965
997
  would actually deliver. Advisory: the code below still works for
966
998
  every OTHER rail, and the mismatch may resolve itself (a Settings
967
999
  change, a fresh registry read) before anyone acts on it. */}
968
- {asset &&
969
- !admission &&
970
- !!assetMessageBoxUrl &&
971
- isConfigured &&
972
- assetMessageBoxUrl !== messageBoxUrl && <ConsequenceNote textKey="token_messagebox_mismatch" />}
1000
+ {asset && !admission && !!assetMessageBoxUrl && isConfigured && assetMessageBoxUrl !== messageBoxUrl && (
1001
+ <ConsequenceNote textKey="token_messagebox_mismatch" />
1002
+ )}
973
1003
  {admission && asset ? (
974
1004
  <AdmissionNotice
975
1005
  ticker={asset.ticker}
@@ -1071,6 +1101,19 @@ export default function HandleReceive({
1071
1101
  }
1072
1102
 
1073
1103
  const styles = StyleSheet.create({
1104
+ liveCard: {
1105
+ flexDirection: 'row',
1106
+ alignItems: 'flex-start',
1107
+ gap: 10,
1108
+ padding: 14,
1109
+ borderRadius: 14,
1110
+ borderWidth: StyleSheet.hairlineWidth,
1111
+ marginBottom: 16
1112
+ },
1113
+ liveDot: { width: 10, height: 10, borderRadius: 5, marginTop: 5 },
1114
+ liveText: { flex: 1 },
1115
+ liveTitle: { fontSize: 15, fontWeight: '600' },
1116
+ liveBody: { fontSize: 13, marginTop: 2 },
1074
1117
  container: {
1075
1118
  paddingHorizontal: spacing.lg,
1076
1119
  paddingTop: spacing.lg
@@ -16,13 +16,14 @@ import {
16
16
  typography,
17
17
  radii,
18
18
  isAllowedServiceOrigin,
19
- DEFAULT_MESSAGE_BOX_URL,
20
19
  LEGACY_MESSAGE_BOX_URL,
21
20
  MESSAGE_BOX_URL_KEY,
22
21
  NO_MESSAGE_BOX
23
22
  } from '@bsv/expo-wallet-toolbox'
24
23
  import { profileScopedKey } from '../../../core/profiles/profileStore'
25
24
  import { trimTrailingSlashes } from '../../../core/net/trimTrailingSlashes'
25
+ import { defaultMessageBoxUrlFor, resolveMessageBoxUrl } from '../../../core/pay/rails/handle'
26
+ import type { AppChain } from '../../../core/networks'
26
27
 
27
28
  /**
28
29
  * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
@@ -41,9 +42,14 @@ function loadIonicons(): IoniconsComponent {
41
42
  return ioniconsComponent
42
43
  }
43
44
 
44
- export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next').useTranslation>['t']) {
45
- const [messageBoxUrl, setMessageBoxUrl] = useState(DEFAULT_MESSAGE_BOX_URL)
46
- const [urlInput, setUrlInput] = useState(DEFAULT_MESSAGE_BOX_URL)
45
+ export function useMessageBoxConfig(
46
+ t: ReturnType<typeof import('react-i18next').useTranslation>['t'],
47
+ /** Each network has its own server: the default, and what a saved preference resolves to, follow it. */
48
+ selectedNetwork: AppChain
49
+ ) {
50
+ const defaultUrl = defaultMessageBoxUrlFor(selectedNetwork)
51
+ const [messageBoxUrl, setMessageBoxUrl] = useState(defaultUrl)
52
+ const [urlInput, setUrlInput] = useState(defaultUrl)
47
53
  const [isSaving, setIsSaving] = useState(false)
48
54
  const [showConfig, setShowConfig] = useState(false)
49
55
 
@@ -53,15 +59,13 @@ export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next')
53
59
  // deliberate choice of that server — follow the new default instead.
54
60
  if (saved === LEGACY_MESSAGE_BOX_URL) {
55
61
  void AsyncStorage.removeItem(profileScopedKey(MESSAGE_BOX_URL_KEY))
56
- return
57
- }
58
- if (saved) {
59
- setMessageBoxUrl(saved)
60
- setUrlInput(saved)
61
- if (saved === NO_MESSAGE_BOX) setShowConfig(true)
62
62
  }
63
+ const resolved = resolveMessageBoxUrl(saved, selectedNetwork) ?? NO_MESSAGE_BOX
64
+ setMessageBoxUrl(resolved)
65
+ setUrlInput(resolved)
66
+ if (resolved === NO_MESSAGE_BOX) setShowConfig(true)
63
67
  })
64
- }, [])
68
+ }, [selectedNetwork])
65
69
 
66
70
  const handleSave = useCallback(
67
71
  async (input: string) => {
@@ -87,8 +91,17 @@ export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next')
87
91
  }
88
92
  setIsSaving(true)
89
93
  try {
90
- await AsyncStorage.setItem(profileScopedKey(MESSAGE_BOX_URL_KEY), trimmed)
91
- setMessageBoxUrl(trimmed)
94
+ // Saved the way every reader will resolve it: a network default (any
95
+ // network's) means "the default", so it is stored as no preference at
96
+ // all, and this screen shows the host the rails will actually use.
97
+ const resolved = resolveMessageBoxUrl(trimmed, selectedNetwork) ?? trimmed
98
+ if (resolved === trimmed) {
99
+ await AsyncStorage.setItem(profileScopedKey(MESSAGE_BOX_URL_KEY), trimmed)
100
+ } else {
101
+ await AsyncStorage.removeItem(profileScopedKey(MESSAGE_BOX_URL_KEY))
102
+ }
103
+ setMessageBoxUrl(resolved)
104
+ setUrlInput(resolved)
92
105
  setShowConfig(false)
93
106
  showToast(t('message_box_saved'), { type: 'success' })
94
107
  } catch (error: any) {
@@ -97,16 +110,16 @@ export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next')
97
110
  setIsSaving(false)
98
111
  }
99
112
  },
100
- [t]
113
+ [t, selectedNetwork]
101
114
  )
102
115
 
103
116
  const handleReset = useCallback(async () => {
104
117
  await AsyncStorage.removeItem(profileScopedKey(MESSAGE_BOX_URL_KEY))
105
- setMessageBoxUrl(DEFAULT_MESSAGE_BOX_URL)
106
- setUrlInput(DEFAULT_MESSAGE_BOX_URL)
118
+ setMessageBoxUrl(defaultUrl)
119
+ setUrlInput(defaultUrl)
107
120
  setShowConfig(false)
108
121
  showToast(t('message_box_removed'), { type: 'success' })
109
- }, [t])
122
+ }, [t, defaultUrl])
110
123
 
111
124
  const handleNone = useCallback(async () => {
112
125
  const noneValue = NO_MESSAGE_BOX
@@ -126,6 +139,7 @@ export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next')
126
139
 
127
140
  return {
128
141
  messageBoxUrl,
142
+ defaultUrl,
129
143
  urlInput,
130
144
  setUrlInput,
131
145
  isSaving,
@@ -139,6 +153,8 @@ export function useMessageBoxConfig(t: ReturnType<typeof import('react-i18next')
139
153
 
140
154
  interface ConfigPanelProps {
141
155
  readonly urlInput: string
156
+ /** This network's default server: the placeholder, and what "reset" returns to. */
157
+ readonly defaultUrl: string
142
158
  readonly isSaving: boolean
143
159
  readonly colors: ReturnType<typeof import('@bsv/expo-wallet-toolbox').useTheme>['colors']
144
160
  readonly t: ReturnType<typeof import('react-i18next').useTranslation>['t']
@@ -148,10 +164,20 @@ interface ConfigPanelProps {
148
164
  readonly onNone: () => void
149
165
  }
150
166
 
151
- export function ConfigPanel({ urlInput, isSaving, colors, t, onChangeUrl, onSave, onReset, onNone }: ConfigPanelProps) {
167
+ export function ConfigPanel({
168
+ urlInput,
169
+ defaultUrl,
170
+ isSaving,
171
+ colors,
172
+ t,
173
+ onChangeUrl,
174
+ onSave,
175
+ onReset,
176
+ onNone
177
+ }: ConfigPanelProps) {
152
178
  const Ionicons = loadIonicons()
153
179
  const hasUrl = !!urlInput.trim()
154
- const isNonDefault = urlInput.trim() !== DEFAULT_MESSAGE_BOX_URL && urlInput !== NO_MESSAGE_BOX
180
+ const isNonDefault = urlInput.trim() !== defaultUrl && urlInput !== NO_MESSAGE_BOX
155
181
  return (
156
182
  <View style={[styles.configPanel, { backgroundColor: colors.backgroundSecondary }]}>
157
183
  <Text style={[styles.configTitle, { color: colors.textPrimary }]}>{t('message_box_server')}</Text>
@@ -159,7 +185,7 @@ export function ConfigPanel({ urlInput, isSaving, colors, t, onChangeUrl, onSave
159
185
  <TextInput
160
186
  value={urlInput}
161
187
  onChangeText={onChangeUrl}
162
- placeholder={DEFAULT_MESSAGE_BOX_URL}
188
+ placeholder={defaultUrl}
163
189
  placeholderTextColor={colors.textTertiary}
164
190
  autoCapitalize="none"
165
191
  autoCorrect={false}