@bsv/expo-wallet-toolbox 0.19.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 +121 -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 +269 -125
  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 +15 -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 +79 -27
  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
@@ -73,6 +73,7 @@ import { importWalletDatabase } from '../importDatabases'
73
73
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
74
74
  import { profileScopedKey } from '../../core/profiles/profileStore'
75
75
  import { profileLabel } from '../../core/profiles/profileLabel'
76
+ import { NETWORKS } from '../../core/networks'
76
77
 
77
78
  /**
78
79
  * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
@@ -191,7 +192,7 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
191
192
  const { satoshisPerUSD, usdToFiat = {} } = useContext(ExchangeRateContext)
192
193
 
193
194
  const currentCurrency = settings?.currency || 'BSV'
194
- const messageBox = useMessageBoxConfig(t)
195
+ const messageBox = useMessageBoxConfig(t, selectedNetwork)
195
196
 
196
197
  useEffect(() => {
197
198
  if (openBackup) setAdvancedExpanded(true)
@@ -313,7 +314,8 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
313
314
  // chain propagates — a partial erasure must never be reported as done.
314
315
  let deleted = 0
315
316
  for (const chain of BACKUP_CHAINS) {
316
- deleted += (await eraseRemoteBackup({ primaryKey, chain, baseUrl: getBackupUrl(), profileIndex: profile })).deleted
317
+ deleted += (await eraseRemoteBackup({ primaryKey, chain, baseUrl: getBackupUrl(), profileIndex: profile }))
318
+ .deleted
317
319
  }
318
320
  if (profile === activeProfileRef.current) setBackupPushOn(false)
319
321
  showToast(t('backup_erase_done', { count: deleted }), { type: 'success' })
@@ -351,7 +353,7 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
351
353
  // The reorg horizon is measured in confirmations, so the report needs the
352
354
  // current tip. Without it, nothing is eligible — which is the safe
353
355
  // direction to fail in.
354
- const height = pm ? ((await pm.getHeight({}, adminOriginator)) as { height?: number })?.height ?? 0 : 0
356
+ const height = pm ? (((await pm.getHeight({}, adminOriginator)) as { height?: number })?.height ?? 0) : 0
355
357
  const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString()
356
358
  const report = await storage.reclaimReport(height, cutoff)
357
359
 
@@ -396,25 +398,29 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
396
398
  // Load persisted ARC URL + token for current network. The token is read
397
399
  // via getArcApiToken (XR-106: SecureStore-backed, not plaintext AsyncStorage).
398
400
  useEffect(() => {
399
- Promise.all([AsyncStorage.getItem(profileScopedKey(arcUrlStorageKey(selectedNetwork))), getArcApiToken(selectedNetwork)]).then(
400
- ([url, token]) => {
401
- setArcUrlInput(url ?? DEFAULT_ARC_URLS[selectedNetwork] ?? '')
402
- setArcTokenInput(token ?? '')
403
- }
404
- )
401
+ Promise.all([
402
+ AsyncStorage.getItem(profileScopedKey(arcUrlStorageKey(selectedNetwork))),
403
+ getArcApiToken(selectedNetwork)
404
+ ]).then(([url, token]) => {
405
+ setArcUrlInput(url ?? DEFAULT_ARC_URLS[selectedNetwork] ?? '')
406
+ setArcTokenInput(token ?? '')
407
+ })
405
408
  }, [selectedNetwork])
406
409
 
407
410
  const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null)
408
- const handleThresholdInput = useCallback((text: string) => {
409
- setThresholdInput(text)
410
- if (debounceRef.current) clearTimeout(debounceRef.current)
411
- debounceRef.current = setTimeout(() => {
412
- const sats = parseDisplayToSatoshis(text, currentCurrency, satoshisPerUSD, usdToFiat)
413
- const clamped = Math.max(0, Math.round(sats))
414
- setThresholdSats(clamped)
415
- AsyncStorage.setItem(profileScopedKey(AUTO_APPROVE_STORAGE_KEY), String(clamped))
416
- }, 600)
417
- }, [currentCurrency, satoshisPerUSD, usdToFiat])
411
+ const handleThresholdInput = useCallback(
412
+ (text: string) => {
413
+ setThresholdInput(text)
414
+ if (debounceRef.current) clearTimeout(debounceRef.current)
415
+ debounceRef.current = setTimeout(() => {
416
+ const sats = parseDisplayToSatoshis(text, currentCurrency, satoshisPerUSD, usdToFiat)
417
+ const clamped = Math.max(0, Math.round(sats))
418
+ setThresholdSats(clamped)
419
+ AsyncStorage.setItem(profileScopedKey(AUTO_APPROVE_STORAGE_KEY), String(clamped))
420
+ }, 600)
421
+ },
422
+ [currentCurrency, satoshisPerUSD, usdToFiat]
423
+ )
418
424
 
419
425
  const handleToggleAdvanced = useCallback(() => {
420
426
  setAdvancedExpanded(prev => {
@@ -475,7 +481,8 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
475
481
  setArcSaving(true)
476
482
  try {
477
483
  const token = arcTokenInput.trim()
478
- const previousUrl = (await AsyncStorage.getItem(profileScopedKey(arcUrlStorageKey(selectedNetwork)))) ?? defaultUrl
484
+ const previousUrl =
485
+ (await AsyncStorage.getItem(profileScopedKey(arcUrlStorageKey(selectedNetwork)))) ?? defaultUrl
479
486
  const previousToken = (await getArcApiToken(selectedNetwork)) ?? ''
480
487
  const nextUrl = url || defaultUrl
481
488
  const originChanged = previousUrl !== nextUrl
@@ -517,11 +524,16 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
517
524
  await rebuildWallet()
518
525
  }
519
526
 
520
- const NETWORKS: { id: AppChain; label: string; color: string }[] = [
521
- { id: 'main', label: t('mainnet'), color: colors.success },
522
- { id: 'test', label: t('testnet'), color: colors.warning },
523
- { id: 'teratest', label: t('teratest'), color: colors.info }
524
- ]
527
+ // A network that is not available yet is offered to nobody, but stays
528
+ // listed for a wallet already on it so the row can still name it.
529
+ const NETWORK_OPTIONS = (
530
+ [
531
+ { id: 'main', label: t('mainnet'), color: colors.success },
532
+ { id: 'test', label: t('testnet'), color: colors.warning },
533
+ { id: 'teratest', label: t('teratest'), color: colors.info },
534
+ { id: 'scaletest', label: t('scaletest'), color: colors.accent }
535
+ ] as { id: AppChain; label: string; color: string }[]
536
+ ).filter(n => NETWORKS[n.id].available || n.id === selectedNetwork)
525
537
 
526
538
  const handleSelectNetwork = async (target: AppChain) => {
527
539
  if (target === selectedNetwork) {
@@ -549,7 +561,11 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
549
561
  <Text style={[localStyles.headerTitle, { color: colors.textPrimary }]}>{t('settings')}</Text>
550
562
  <View style={localStyles.headerBack} />
551
563
  </View>
552
- <ScrollView ref={scrollRef} style={{ flex: 1 }} contentContainerStyle={{ paddingTop: spacing.lg, paddingBottom: spacing.xxxl }}>
564
+ <ScrollView
565
+ ref={scrollRef}
566
+ style={{ flex: 1 }}
567
+ contentContainerStyle={{ paddingTop: spacing.lg, paddingBottom: spacing.xxxl }}
568
+ >
553
569
  {/* ── Essentials ──
554
570
  The rows a holder reaches for without being told to: what their money
555
571
  is denominated in, how to hand an app access, and the two ways out of
@@ -623,387 +639,409 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
623
639
 
624
640
  {advancedExpanded && (
625
641
  <>
626
- {/* ── Configuration ── */}
627
- <GroupedSection
628
- header={t('configuration')}
629
- footer={
630
- profilesSupported
631
- ? t('profile_settings_scope_note', {
632
- profile: profileLabel(profiles.find(p => p.index === activeProfile) ?? { index: activeProfile }, t)
633
- })
634
- : undefined
635
- }
636
- >
637
- <ListRow
638
- label={t('bsv_network')}
639
- value={
640
- switchingNetwork
641
- ? t('switching')
642
- : (NETWORKS.find(n => n.id === selectedNetwork)?.label ?? selectedNetwork)
642
+ {/* ── Configuration ── */}
643
+ <GroupedSection
644
+ header={t('configuration')}
645
+ footer={
646
+ profilesSupported
647
+ ? t('profile_settings_scope_note', {
648
+ profile: profileLabel(
649
+ profiles.find(p => p.index === activeProfile) ?? { index: activeProfile },
650
+ t
651
+ )
652
+ })
653
+ : undefined
643
654
  }
644
- icon="globe-outline"
645
- iconColor={NETWORKS.find(n => n.id === selectedNetwork)?.color ?? colors.success}
646
- onPress={() => setNetworkExpanded(e => !e)}
647
- showChevron={networkExpanded}
648
- chevronDown={networkExpanded}
649
- />
650
- {networkExpanded && (
651
- <View style={localStyles.networkList}>
652
- {NETWORKS.map(net => {
653
- const isActive = net.id === selectedNetwork
654
- return (
655
+ >
656
+ <ListRow
657
+ label={t('bsv_network')}
658
+ value={
659
+ switchingNetwork
660
+ ? t('switching')
661
+ : (NETWORK_OPTIONS.find(n => n.id === selectedNetwork)?.label ?? selectedNetwork)
662
+ }
663
+ icon="globe-outline"
664
+ iconColor={NETWORK_OPTIONS.find(n => n.id === selectedNetwork)?.color ?? colors.success}
665
+ onPress={() => setNetworkExpanded(e => !e)}
666
+ showChevron={networkExpanded}
667
+ chevronDown={networkExpanded}
668
+ />
669
+ {networkExpanded && (
670
+ <View style={localStyles.networkList}>
671
+ {NETWORK_OPTIONS.map(net => {
672
+ const isActive = net.id === selectedNetwork
673
+ return (
674
+ <TouchableOpacity
675
+ key={net.id}
676
+ style={localStyles.networkOption}
677
+ onPress={() => handleSelectNetwork(net.id)}
678
+ activeOpacity={0.6}
679
+ >
680
+ <View style={[localStyles.networkDot, { backgroundColor: net.color }]} />
681
+ <Text style={[localStyles.networkLabel, { color: colors.textPrimary }]}>{net.label}</Text>
682
+ {isActive && (
683
+ <Ionicons name="checkmark" size={20} color={colors.accent} style={{ marginLeft: 'auto' }} />
684
+ )}
685
+ </TouchableOpacity>
686
+ )
687
+ })}
688
+ </View>
689
+ )}
690
+ <ListRow
691
+ label={t('arc_endpoint')}
692
+ value={(() => {
693
+ const known = KNOWN_ARC_URLS[selectedNetwork].find(k => arcUrlInput.startsWith(k.url))
694
+ return known ? known.label : arcUrlInput.replace('https://', '')
695
+ })()}
696
+ icon="radio-outline"
697
+ iconColor="#6E56CF"
698
+ onPress={() => setArcExpanded(e => !e)}
699
+ showChevron={arcExpanded}
700
+ chevronDown={arcExpanded}
701
+ isLast={arcExpanded}
702
+ />
703
+ {arcExpanded && (
704
+ <View
705
+ style={[
706
+ localStyles.networkList,
707
+ {
708
+ paddingTop: spacing.sm,
709
+ borderBottomWidth: StyleSheet.hairlineWidth,
710
+ borderBottomColor: colors.separator
711
+ }
712
+ ]}
713
+ >
714
+ {KNOWN_ARC_URLS[selectedNetwork].map(preset => {
715
+ const isSelected = arcUrlInput.startsWith(preset.url)
716
+ return (
717
+ <TouchableOpacity
718
+ key={preset.url}
719
+ style={localStyles.networkOption}
720
+ onPress={() => setArcUrlInput(preset.url)}
721
+ activeOpacity={0.6}
722
+ >
723
+ <View
724
+ style={[
725
+ localStyles.networkDot,
726
+ { backgroundColor: isSelected ? colors.accent : colors.separator }
727
+ ]}
728
+ />
729
+ <View style={{ flex: 1 }}>
730
+ <Text style={[localStyles.networkLabel, { color: colors.textPrimary }]}>{preset.label}</Text>
731
+ <Text style={{ ...typography.caption1, color: colors.textSecondary }} numberOfLines={1}>
732
+ {preset.url.replace('https://', '')}
733
+ </Text>
734
+ </View>
735
+ {preset.requiresToken && (
736
+ <Text style={{ ...typography.caption1, color: colors.warning, marginLeft: spacing.sm }}>
737
+ {t('arc_requires_token')}
738
+ </Text>
739
+ )}
740
+ {isSelected && (
741
+ <Ionicons
742
+ name="checkmark"
743
+ size={18}
744
+ color={colors.accent}
745
+ style={{ marginLeft: spacing.sm }}
746
+ />
747
+ )}
748
+ </TouchableOpacity>
749
+ )
750
+ })}
751
+ <View style={localStyles.arcInputRow}>
752
+ <Text style={[localStyles.arcLabel, { color: colors.textSecondary }]}>{t('arc_custom_url')}</Text>
753
+ <TextInput
754
+ style={[
755
+ localStyles.arcInput,
756
+ { color: colors.textPrimary, borderColor: arcUrlError ? colors.error : colors.separator }
757
+ ]}
758
+ value={arcUrlInput}
759
+ onChangeText={text => {
760
+ setArcUrlInput(text)
761
+ if (arcUrlError) setArcUrlError(false)
762
+ }}
763
+ placeholder="https://..."
764
+ placeholderTextColor={colors.textSecondary}
765
+ autoCapitalize="none"
766
+ autoCorrect={false}
767
+ keyboardType="url"
768
+ returnKeyType="next"
769
+ />
770
+ {arcUrlError && (
771
+ <Text style={{ ...typography.caption1, color: colors.error }}>{t('arc_url_https_required')}</Text>
772
+ )}
773
+ </View>
774
+ <View style={localStyles.arcInputRow}>
775
+ <Text style={[localStyles.arcLabel, { color: colors.textSecondary }]}>{t('arc_api_token')}</Text>
776
+ <TextInput
777
+ style={[localStyles.arcInput, { color: colors.textPrimary, borderColor: colors.separator }]}
778
+ value={arcTokenInput}
779
+ onChangeText={setArcTokenInput}
780
+ placeholder="Optional"
781
+ placeholderTextColor={colors.textSecondary}
782
+ autoCapitalize="none"
783
+ autoCorrect={false}
784
+ returnKeyType="done"
785
+ // XR-106: this is a live Bearer credential, not display
786
+ // text — mask it like any other secret field.
787
+ secureTextEntry
788
+ />
789
+ </View>
790
+ <View style={localStyles.arcButtonRow}>
655
791
  <TouchableOpacity
656
- key={net.id}
657
- style={localStyles.networkOption}
658
- onPress={() => handleSelectNetwork(net.id)}
659
- activeOpacity={0.6}
792
+ style={[localStyles.arcButton, { backgroundColor: colors.backgroundTertiary }]}
793
+ onPress={handleResetArc}
794
+ activeOpacity={0.7}
660
795
  >
661
- <View style={[localStyles.networkDot, { backgroundColor: net.color }]} />
662
- <Text style={[localStyles.networkLabel, { color: colors.textPrimary }]}>{net.label}</Text>
663
- {isActive && (
664
- <Ionicons name="checkmark" size={20} color={colors.accent} style={{ marginLeft: 'auto' }} />
665
- )}
796
+ <Text style={{ ...typography.body, color: colors.textSecondary }}>{t('arc_reset_default')}</Text>
666
797
  </TouchableOpacity>
667
- )
668
- })}
669
- </View>
670
- )}
671
- <ListRow
672
- label={t('arc_endpoint')}
673
- value={(() => {
674
- const known = KNOWN_ARC_URLS.find(k => arcUrlInput.startsWith(k.url))
675
- return known ? known.label : arcUrlInput.replace('https://', '')
676
- })()}
677
- icon="radio-outline"
678
- iconColor="#6E56CF"
679
- onPress={() => setArcExpanded(e => !e)}
680
- showChevron={arcExpanded}
681
- chevronDown={arcExpanded}
682
- isLast={arcExpanded}
683
- />
684
- {arcExpanded && (
685
- <View style={[localStyles.networkList, { paddingTop: spacing.sm, borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: colors.separator }]}>
686
- {KNOWN_ARC_URLS.map(preset => {
687
- const isSelected = arcUrlInput.startsWith(preset.url)
688
- return (
689
798
  <TouchableOpacity
690
- key={preset.url}
691
- style={localStyles.networkOption}
692
- onPress={() => setArcUrlInput(preset.url)}
693
- activeOpacity={0.6}
799
+ style={[localStyles.arcButton, { backgroundColor: colors.accent }]}
800
+ onPress={handleApplyArc}
801
+ activeOpacity={0.7}
694
802
  >
695
- <View
696
- style={[
697
- localStyles.networkDot,
698
- { backgroundColor: isSelected ? colors.accent : colors.separator }
699
- ]}
700
- />
701
- <View style={{ flex: 1 }}>
702
- <Text style={[localStyles.networkLabel, { color: colors.textPrimary }]}>
703
- {preset.label}
704
- </Text>
705
- <Text style={{ ...typography.caption1, color: colors.textSecondary }} numberOfLines={1}>
706
- {preset.url.replace('https://', '')}
707
- </Text>
708
- </View>
709
- {preset.requiresToken && (
710
- <Text style={{ ...typography.caption1, color: colors.warning, marginLeft: spacing.sm }}>
711
- {t('arc_requires_token')}
803
+ {arcSaving ? (
804
+ <ActivityIndicator size="small" color={colors.textOnAccent} />
805
+ ) : (
806
+ <Text style={{ ...typography.body, color: colors.textOnAccent, fontWeight: '600' }}>
807
+ {t('arc_apply')}
712
808
  </Text>
713
809
  )}
714
- {isSelected && (
715
- <Ionicons name="checkmark" size={18} color={colors.accent} style={{ marginLeft: spacing.sm }} />
716
- )}
717
810
  </TouchableOpacity>
718
- )
719
- })}
720
- <View style={localStyles.arcInputRow}>
721
- <Text style={[localStyles.arcLabel, { color: colors.textSecondary }]}>{t('arc_custom_url')}</Text>
722
- <TextInput
723
- style={[
724
- localStyles.arcInput,
725
- { color: colors.textPrimary, borderColor: arcUrlError ? colors.error : colors.separator }
726
- ]}
727
- value={arcUrlInput}
728
- onChangeText={text => {
729
- setArcUrlInput(text)
730
- if (arcUrlError) setArcUrlError(false)
731
- }}
732
- placeholder="https://..."
733
- placeholderTextColor={colors.textSecondary}
734
- autoCapitalize="none"
735
- autoCorrect={false}
736
- keyboardType="url"
737
- returnKeyType="next"
738
- />
739
- {arcUrlError && (
740
- <Text style={{ ...typography.caption1, color: colors.error }}>{t('arc_url_https_required')}</Text>
741
- )}
742
- </View>
743
- <View style={localStyles.arcInputRow}>
744
- <Text style={[localStyles.arcLabel, { color: colors.textSecondary }]}>{t('arc_api_token')}</Text>
745
- <TextInput
746
- style={[localStyles.arcInput, { color: colors.textPrimary, borderColor: colors.separator }]}
747
- value={arcTokenInput}
748
- onChangeText={setArcTokenInput}
749
- placeholder="Optional"
750
- placeholderTextColor={colors.textSecondary}
751
- autoCapitalize="none"
752
- autoCorrect={false}
753
- returnKeyType="done"
754
- // XR-106: this is a live Bearer credential, not display
755
- // text — mask it like any other secret field.
756
- secureTextEntry
757
- />
758
- </View>
759
- <View style={localStyles.arcButtonRow}>
760
- <TouchableOpacity
761
- style={[localStyles.arcButton, { backgroundColor: colors.backgroundTertiary }]}
762
- onPress={handleResetArc}
763
- activeOpacity={0.7}
764
- >
765
- <Text style={{ ...typography.body, color: colors.textSecondary }}>{t('arc_reset_default')}</Text>
766
- </TouchableOpacity>
767
- <TouchableOpacity
768
- style={[localStyles.arcButton, { backgroundColor: colors.accent }]}
769
- onPress={handleApplyArc}
770
- activeOpacity={0.7}
771
- >
772
- {arcSaving
773
- ? <ActivityIndicator size="small" color={colors.textOnAccent} />
774
- : <Text style={{ ...typography.body, color: colors.textOnAccent, fontWeight: '600' }}>{t('arc_apply')}</Text>
775
- }
776
- </TouchableOpacity>
811
+ </View>
777
812
  </View>
778
- </View>
779
- )}
780
- {/* The one home of the message-box setting. Save / Default / Use no
813
+ )}
814
+ {/* The one home of the message-box setting. Save / Default / Use no
781
815
  server live in ConfigPanel, unchanged from when it sat on the
782
816
  pay screens; the row's value says which server handle payments
783
817
  go through, or that none does. */}
784
- <ListRow
785
- label={t('message_box_server')}
786
- value={
787
- messageBox.messageBoxUrl === NO_MESSAGE_BOX
788
- ? t('message_box_off')
789
- : messageBox.messageBoxUrl.replace(/^https:\/\//, '')
790
- }
791
- icon="mail-outline"
792
- iconColor="#5E5CE6"
793
- onPress={() => messageBox.setShowConfig(v => !v)}
794
- showChevron={messageBox.showConfig}
795
- chevronDown={messageBox.showConfig}
796
- />
797
- {messageBox.showConfig && (
798
- <View style={{ paddingHorizontal: spacing.lg, paddingBottom: spacing.md }}>
799
- <ConfigPanel
800
- urlInput={messageBox.urlInput}
801
- isSaving={messageBox.isSaving}
802
- colors={colors}
803
- t={t}
804
- onChangeUrl={messageBox.setUrlInput}
805
- onSave={() => {
806
- void messageBox.handleSave(messageBox.urlInput)
807
- }}
808
- onReset={messageBox.handleReset}
809
- onNone={messageBox.handleNone}
810
- />
811
- </View>
812
- )}
813
- <ListRow
814
- label="Auto Spend Up To"
815
- value={thresholdSats === 0 ? 'Off'
816
- : formatAmount(thresholdSats, currentCurrency, satoshisPerUSD, { usdToFiat })}
817
- icon="flash-outline"
818
- iconColor="#FF9F0A"
819
- onPress={() => {
820
- setThresholdExpanded(e => !e)
821
- if (!thresholdExpanded) {
822
- // Pre-fill input with current value in display currency
823
- if (thresholdSats === 0) {
824
- setThresholdInput('0')
825
- } else if (isFiatCurrency(currentCurrency)) {
826
- const per = satoshisPerFiatUnit(currentCurrency, satoshisPerUSD, usdToFiat)
827
- if (per > 0) {
828
- setThresholdInput((thresholdSats / per).toFixed(fiatFractionDigits(currentCurrency)))
829
- } else {
830
- setThresholdInput(String(thresholdSats))
831
- }
832
- } else {
833
- setThresholdInput(String(thresholdSats))
834
- }
818
+ <ListRow
819
+ label={t('message_box_server')}
820
+ value={
821
+ messageBox.messageBoxUrl === NO_MESSAGE_BOX
822
+ ? t('message_box_off')
823
+ : messageBox.messageBoxUrl.replace(/^https:\/\//, '')
835
824
  }
836
- }}
837
- showChevron={thresholdExpanded}
838
- chevronDown={thresholdExpanded}
839
- />
840
- {thresholdExpanded && (
841
- <View style={localStyles.networkList}>
842
- <View style={localStyles.thresholdRow}>
843
- <TextInput
844
- style={[localStyles.thresholdInput, { color: colors.textPrimary, borderColor: colors.separator }]}
845
- value={thresholdInput}
846
- onChangeText={handleThresholdInput}
847
- keyboardType={
848
- isFiatCurrency(currentCurrency) && fiatFractionDigits(currentCurrency) > 0
849
- ? 'decimal-pad'
850
- : 'numeric'
851
- }
852
- placeholder={`0 ${getUnitLabel(currentCurrency)}`}
853
- placeholderTextColor={colors.textSecondary}
854
- returnKeyType="done"
825
+ icon="mail-outline"
826
+ iconColor="#5E5CE6"
827
+ onPress={() => messageBox.setShowConfig(v => !v)}
828
+ showChevron={messageBox.showConfig}
829
+ chevronDown={messageBox.showConfig}
830
+ />
831
+ {messageBox.showConfig && (
832
+ <View style={{ paddingHorizontal: spacing.lg, paddingBottom: spacing.md }}>
833
+ <ConfigPanel
834
+ urlInput={messageBox.urlInput}
835
+ defaultUrl={messageBox.defaultUrl}
836
+ isSaving={messageBox.isSaving}
837
+ colors={colors}
838
+ t={t}
839
+ onChangeUrl={messageBox.setUrlInput}
840
+ onSave={() => {
841
+ void messageBox.handleSave(messageBox.urlInput)
842
+ }}
843
+ onReset={messageBox.handleReset}
844
+ onNone={messageBox.handleNone}
855
845
  />
856
- <Text style={[localStyles.thresholdUnit, { color: colors.textSecondary }]}>
857
- {getUnitLabel(currentCurrency)}
858
- </Text>
859
846
  </View>
860
- </View>
861
- )}
862
- <ListRow
863
- label={t('trust_network')}
864
- icon="shield-checkmark-outline"
865
- iconColor="#BF5AF2"
866
- onPress={() => router.push('/trust' as any)}
867
- isLast
868
- />
869
- </GroupedSection>
870
-
871
- {/* ── Data & Security ── */}
872
- <View onLayout={event => setBackupSectionY(event.nativeEvent.layout.y)}>
873
- <GroupedSection header={t('data_and_security')}>
874
- {/* Demo mode: a wallet full of obviously-fake BSV and stablecoins,
875
- for showing the app without an account or a balance. Literal
876
- copy rather than i18n — this row renders only under `__DEV__`
877
- and never reaches a release build, so it is not user copy. */}
878
- {__DEV__ && demoMod && (
847
+ )}
879
848
  <ListRow
880
- label="Demo mode (dev)"
881
- icon="flask-outline"
882
- iconColor="#8E8E93"
883
- showChevron={false}
884
- value={demoOn ? 'On' : 'Off'}
849
+ label="Auto Spend Up To"
850
+ value={
851
+ thresholdSats === 0
852
+ ? 'Off'
853
+ : formatAmount(thresholdSats, currentCurrency, satoshisPerUSD, { usdToFiat })
854
+ }
855
+ icon="flash-outline"
856
+ iconColor="#FF9F0A"
885
857
  onPress={() => {
886
- const next = !demoOn
887
- setDemoOn(next)
888
- demoMod.setDemoModeEnabled(next)
858
+ setThresholdExpanded(e => !e)
859
+ if (!thresholdExpanded) {
860
+ // Pre-fill input with current value in display currency
861
+ if (thresholdSats === 0) {
862
+ setThresholdInput('0')
863
+ } else if (isFiatCurrency(currentCurrency)) {
864
+ const per = satoshisPerFiatUnit(currentCurrency, satoshisPerUSD, usdToFiat)
865
+ if (per > 0) {
866
+ setThresholdInput((thresholdSats / per).toFixed(fiatFractionDigits(currentCurrency)))
867
+ } else {
868
+ setThresholdInput(String(thresholdSats))
869
+ }
870
+ } else {
871
+ setThresholdInput(String(thresholdSats))
872
+ }
873
+ }
889
874
  }}
875
+ showChevron={thresholdExpanded}
876
+ chevronDown={thresholdExpanded}
890
877
  />
891
- )}
892
- {__DEV__ && demoMod && demoOn && (
878
+ {thresholdExpanded && (
879
+ <View style={localStyles.networkList}>
880
+ <View style={localStyles.thresholdRow}>
881
+ <TextInput
882
+ style={[localStyles.thresholdInput, { color: colors.textPrimary, borderColor: colors.separator }]}
883
+ value={thresholdInput}
884
+ onChangeText={handleThresholdInput}
885
+ keyboardType={
886
+ isFiatCurrency(currentCurrency) && fiatFractionDigits(currentCurrency) > 0
887
+ ? 'decimal-pad'
888
+ : 'numeric'
889
+ }
890
+ placeholder={`0 ${getUnitLabel(currentCurrency)}`}
891
+ placeholderTextColor={colors.textSecondary}
892
+ returnKeyType="done"
893
+ />
894
+ <Text style={[localStyles.thresholdUnit, { color: colors.textSecondary }]}>
895
+ {getUnitLabel(currentCurrency)}
896
+ </Text>
897
+ </View>
898
+ </View>
899
+ )}
893
900
  <ListRow
894
- label="Reset demo data (dev)"
895
- icon="refresh-outline"
896
- iconColor="#8E8E93"
897
- showChevron={false}
898
- onPress={() => demoMod.resetDemoLedger()}
901
+ label={t('trust_network')}
902
+ icon="shield-checkmark-outline"
903
+ iconColor="#BF5AF2"
904
+ onPress={() => router.push('/trust' as any)}
905
+ isLast
899
906
  />
900
- )}
901
- {/* Vault's primary entry lives on the wallet menu (below Payments).
907
+ </GroupedSection>
908
+
909
+ {/* ── Data & Security ── */}
910
+ <View onLayout={event => setBackupSectionY(event.nativeEvent.layout.y)}>
911
+ <GroupedSection header={t('data_and_security')}>
912
+ {/* Demo mode: a wallet full of obviously-fake BSV and stablecoins,
913
+ for showing the app without an account or a balance. Literal
914
+ copy rather than i18n — this row renders only under `__DEV__`
915
+ and never reaches a release build, so it is not user copy. */}
916
+ {__DEV__ && demoMod && (
917
+ <ListRow
918
+ label="Demo mode (dev)"
919
+ icon="flask-outline"
920
+ iconColor="#8E8E93"
921
+ showChevron={false}
922
+ value={demoOn ? 'On' : 'Off'}
923
+ onPress={() => {
924
+ const next = !demoOn
925
+ setDemoOn(next)
926
+ demoMod.setDemoModeEnabled(next)
927
+ }}
928
+ />
929
+ )}
930
+ {__DEV__ && demoMod && demoOn && (
931
+ <ListRow
932
+ label="Reset demo data (dev)"
933
+ icon="refresh-outline"
934
+ iconColor="#8E8E93"
935
+ showChevron={false}
936
+ onPress={() => demoMod.resetDemoLedger()}
937
+ />
938
+ )}
939
+ {/* Vault's primary entry lives on the wallet menu (below Payments).
902
940
  The DEV mock toggle stays here. */}
903
- {__DEV__ && (
904
- <ListRow
905
- label={t('vault_mock_toggle')}
906
- icon="bug-outline"
907
- iconColor="#8E8E93"
908
- showChevron={false}
909
- value={vaultMockOn ? t('vault_on') : t('vault_off')}
910
- onPress={() => {
911
- const next = !vaultMockOn
912
- setVaultMockOn(next)
913
- setMockDriverEnabled(next)
914
- if (next) setMockPresent(getMockPresentKey())
915
- }}
916
- />
917
- )}
918
- {/* Which of the three mock YubiKeys is "on the phone" right now.
941
+ {__DEV__ && (
942
+ <ListRow
943
+ label={t('vault_mock_toggle')}
944
+ icon="bug-outline"
945
+ iconColor="#8E8E93"
946
+ showChevron={false}
947
+ value={vaultMockOn ? t('vault_on') : t('vault_off')}
948
+ onPress={() => {
949
+ const next = !vaultMockOn
950
+ setVaultMockOn(next)
951
+ setMockDriverEnabled(next)
952
+ if (next) setMockPresent(getMockPresentKey())
953
+ }}
954
+ />
955
+ )}
956
+ {/* Which of the three mock YubiKeys is "on the phone" right now.
919
957
  A 1-of-N vault enrolled with MOCK-DEV-1 and MOCK-DEV-2 is
920
958
  exercised by switching the present key between taps. The label
921
959
  is a literal rather than user copy because this row renders
922
960
  only under the `__DEV__` gate just below — it never reaches a
923
961
  release build. */}
924
- {__DEV__ && vaultMockOn && (
925
- <ListRow
926
- label="Mock key present (dev)"
927
- icon="key-outline"
928
- iconColor="#8E8E93"
929
- showChevron={false}
930
- value={mockPresent}
931
- onPress={() => {
932
- const next = NEXT_MOCK_KEY[mockPresent]
933
- setMockPresent(next)
934
- setMockPresentKey(next)
935
- }}
936
- />
937
- )}
938
- <ListRow
939
- label={t('backup_wallet_keys', { defaultValue: 'Backup Wallet Keys' })}
940
- icon="key-outline"
941
- iconColor="#CC8400"
942
- onPress={() => router.push('/auth/mnemonic?flow=backup')}
943
- />
944
- <ListRow
945
- label={t('storage_row')}
946
- icon="server-outline"
947
- iconColor="#8E8E93"
948
- showChevron={false}
949
- onPress={handleStorage}
950
- trailing={storageBusy ? <ActivityIndicator size="small" /> : undefined}
951
- />
952
- <ListRow
953
- label={t('export_wallet_data')}
954
- icon="share-outline"
955
- iconColor="#32ADE6"
956
- onPress={() => void exportData()}
957
- showChevron={false}
958
- trailing={exporting ? <ActivityIndicator size="small" /> : undefined}
959
- />
960
- <ListRow
961
- label={t('import_wallet_data')}
962
- icon="download-outline"
963
- iconColor="#30D158"
964
- onPress={handleImportData}
965
- showChevron={false}
966
- trailing={isImporting ? <ActivityIndicator size="small" /> : undefined}
967
- />
968
- <ListRow
969
- label="Debugging"
970
- icon="terminal-outline"
971
- iconColor="#8E8E93"
972
- onPress={() => router.push('/logs' as any)}
973
- isLast
974
- />
975
- </GroupedSection>
976
- </View>
962
+ {__DEV__ && vaultMockOn && (
963
+ <ListRow
964
+ label="Mock key present (dev)"
965
+ icon="key-outline"
966
+ iconColor="#8E8E93"
967
+ showChevron={false}
968
+ value={mockPresent}
969
+ onPress={() => {
970
+ const next = NEXT_MOCK_KEY[mockPresent]
971
+ setMockPresent(next)
972
+ setMockPresentKey(next)
973
+ }}
974
+ />
975
+ )}
976
+ <ListRow
977
+ label={t('backup_wallet_keys', { defaultValue: 'Backup Wallet Keys' })}
978
+ icon="key-outline"
979
+ iconColor="#CC8400"
980
+ onPress={() => router.push('/auth/mnemonic?flow=backup')}
981
+ />
982
+ <ListRow
983
+ label={t('storage_row')}
984
+ icon="server-outline"
985
+ iconColor="#8E8E93"
986
+ showChevron={false}
987
+ onPress={handleStorage}
988
+ trailing={storageBusy ? <ActivityIndicator size="small" /> : undefined}
989
+ />
990
+ <ListRow
991
+ label={t('export_wallet_data')}
992
+ icon="share-outline"
993
+ iconColor="#32ADE6"
994
+ onPress={() => void exportData()}
995
+ showChevron={false}
996
+ trailing={exporting ? <ActivityIndicator size="small" /> : undefined}
997
+ />
998
+ <ListRow
999
+ label={t('import_wallet_data')}
1000
+ icon="download-outline"
1001
+ iconColor="#30D158"
1002
+ onPress={handleImportData}
1003
+ showChevron={false}
1004
+ trailing={isImporting ? <ActivityIndicator size="small" /> : undefined}
1005
+ />
1006
+ <ListRow
1007
+ label="Debugging"
1008
+ icon="terminal-outline"
1009
+ iconColor="#8E8E93"
1010
+ onPress={() => router.push('/logs' as any)}
1011
+ isLast
1012
+ />
1013
+ </GroupedSection>
1014
+ </View>
977
1015
 
978
- {/* ── Private backup ──
1016
+ {/* ── Private backup ──
979
1017
  Its own section purely so the footer can carry the disclosure: the app sends an
980
1018
  encrypted copy of the wallet database to a BSVA-operated server by default, and
981
1019
  that deserves saying out loud rather than burying in a row label. */}
982
- {getBackupUrl() !== '' && (
983
- <GroupedSection header={t('backup_push_section')} footer={t('backup_push_disclosure')}>
984
- <ListRow
985
- label={t('backup_push_toggle')}
986
- icon="cloud-upload-outline"
987
- iconColor="#0A84FF"
988
- showChevron={false}
989
- value={backupPushOn ? t('vault_on') : t('vault_off')}
990
- onPress={handleToggleBackupPush}
991
- />
992
- {/* Erasure on request. Separate from the toggle because they are different
1020
+ {getBackupUrl() !== '' && (
1021
+ <GroupedSection header={t('backup_push_section')} footer={t('backup_push_disclosure')}>
1022
+ <ListRow
1023
+ label={t('backup_push_toggle')}
1024
+ icon="cloud-upload-outline"
1025
+ iconColor="#0A84FF"
1026
+ showChevron={false}
1027
+ value={backupPushOn ? t('vault_on') : t('vault_off')}
1028
+ onPress={handleToggleBackupPush}
1029
+ />
1030
+ {/* Erasure on request. Separate from the toggle because they are different
993
1031
  asks: the toggle stops sending anything new, this removes what is already
994
1032
  there. Turning the toggle off deliberately deletes nothing. */}
995
- <ListRow
996
- label={t('backup_erase_row')}
997
- icon="trash-outline"
998
- iconColor={colors.error}
999
- destructive
1000
- showChevron={false}
1001
- onPress={handleEraseBackup}
1002
- trailing={erasingBackup ? <ActivityIndicator size="small" /> : undefined}
1003
- isLast
1004
- />
1005
- </GroupedSection>
1006
- )}
1033
+ <ListRow
1034
+ label={t('backup_erase_row')}
1035
+ icon="trash-outline"
1036
+ iconColor={colors.error}
1037
+ destructive
1038
+ showChevron={false}
1039
+ onPress={handleEraseBackup}
1040
+ trailing={erasingBackup ? <ActivityIndicator size="small" /> : undefined}
1041
+ isLast
1042
+ />
1043
+ </GroupedSection>
1044
+ )}
1007
1045
  </>
1008
1046
  )}
1009
1047
 
@@ -1021,8 +1059,8 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
1021
1059
  message: t('delete_wallet_warning_body'),
1022
1060
  buttons: [
1023
1061
  { text: t('cancel'), style: 'cancel', key: 'cancel' },
1024
- { text: t('delete_wallet_confirm'), style: 'destructive', key: 'delete' },
1025
- ],
1062
+ { text: t('delete_wallet_confirm'), style: 'destructive', key: 'delete' }
1063
+ ]
1026
1064
  })
1027
1065
  if (choice !== 'delete') return
1028
1066
  setLoggingOut(true)
@@ -1047,7 +1085,7 @@ export function WalletConfigScreen({ hideLogout = false }: { hideLogout?: boolea
1047
1085
  await showAlert({
1048
1086
  title: t('delete_wallet_failed_title'),
1049
1087
  message: t('delete_wallet_failed_body'),
1050
- buttons: [{ text: t('vault_ok'), key: 'ok' }],
1088
+ buttons: [{ text: t('vault_ok'), key: 'ok' }]
1051
1089
  })
1052
1090
  }
1053
1091
  // On success logout() has already navigated away — the screen