@bsv/expo-wallet-toolbox 0.19.0 → 0.21.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 (141) hide show
  1. package/CHANGELOG.md +154 -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/DirectPayManager.ts +148 -29
  24. package/core/directpay/DirectPayProvider.tsx +26 -26
  25. package/core/directpay/payFlow.ts +10 -1
  26. package/core/directpay/receive.ts +2 -1
  27. package/core/directpay/settings.ts +56 -9
  28. package/core/directpay/types.ts +11 -2
  29. package/core/directpay/webrtpay.ts +4 -0
  30. package/core/headers/checkpoints.ts +10 -1
  31. package/core/headers/headerStore.ts +13 -2
  32. package/core/hooks/useConfirmationSound.ts +3 -3
  33. package/core/hooks/useHaptics.ts +23 -6
  34. package/core/i18n/translations.tsx +382 -209
  35. package/core/index.ts +2 -0
  36. package/core/localpay/codec.ts +12 -6
  37. package/core/localpay/deviceCaps.ts +4 -14
  38. package/core/localpay/pending.ts +2 -1
  39. package/core/localpay/qr.ts +1 -1
  40. package/core/localpay/settlementAck.ts +1 -4
  41. package/core/localpay/transport/ble.ts +2 -2
  42. package/core/localpay/transport/socket.ts +1 -1
  43. package/core/mandala/abortGuard.ts +1 -1
  44. package/core/mandala/drain.ts +3 -0
  45. package/core/mandala/permissionModule.ts +3 -2
  46. package/core/mandala/resendTransfer.ts +4 -1
  47. package/core/mandala/runtime.ts +4 -4
  48. package/core/monitor/TaskBackupPush.ts +10 -13
  49. package/core/net/chainMatch.ts +8 -5
  50. package/core/networks.ts +145 -0
  51. package/core/parsePeerPayURI.ts +4 -1
  52. package/core/pay/beefRepair.ts +6 -3
  53. package/core/pay/creditErrors.ts +37 -1
  54. package/core/pay/rails/address.ts +10 -6
  55. package/core/pay/rails/direct.ts +6 -2
  56. package/core/pay/rails/handle.ts +84 -11
  57. package/core/pay/rails/index.ts +18 -2
  58. package/core/pay/receiveHistory.ts +8 -8
  59. package/core/peerpay/handleResendRequests.ts +11 -18
  60. package/core/peerpay/inboxAttempts.ts +1 -4
  61. package/core/peerpay/rebuildToken.ts +12 -9
  62. package/core/profiles/profileStore.ts +2 -1
  63. package/core/profiles/removalProblems.ts +3 -1
  64. package/core/services/arcTokenStorage.ts +2 -1
  65. package/core/services/arcadeBroadcastProvider.ts +7 -17
  66. package/core/services/secrets/envelope.ts +1 -6
  67. package/core/services/secrets/hkdf.ts +1 -6
  68. package/core/services/secrets/index.ts +3 -22
  69. package/core/services/usdFxRates.ts +1 -4
  70. package/core/services/vault/VaultKeyService.ts +2 -1
  71. package/core/services/vault/chainRecovery.ts +48 -21
  72. package/core/services/vault/metaAuthority.ts +4 -1
  73. package/core/services/vault/r1comb.ts +113 -51
  74. package/core/services/vault/session.ts +5 -1
  75. package/core/services/vault/transfers.ts +699 -576
  76. package/core/services/vault/vaultStore.ts +12 -10
  77. package/core/services/walletArgLimits.ts +1 -2
  78. package/core/services/walletConnectionValidation.ts +44 -28
  79. package/core/services/walletServiceConfig.ts +9 -40
  80. package/core/storage/StorageExpoSQLite.ts +7 -21
  81. package/core/storage/methods/listActionsSql.ts +81 -67
  82. package/core/storage/methods/listOutputsSql.ts +21 -16
  83. package/core/storage/methods/reviewStatusSql.ts +1 -4
  84. package/core/stores/ConnectionStore.ts +1 -1
  85. package/core/theme/ThemeContext.tsx +12 -16
  86. package/core/theme/motion.ts +3 -3
  87. package/core/theme/tokens.ts +6 -6
  88. package/core/toolboxConfig.ts +23 -0
  89. package/core/walletDbRegistry.ts +7 -5
  90. package/core/walletRepair/runWalletCheck.ts +1 -4
  91. package/package.json +2 -2
  92. package/ui/components/pay/AddressReceive.tsx +3 -3
  93. package/ui/components/pay/HandleReceive.tsx +21 -15
  94. package/ui/components/pay/MessageBoxConfig.tsx +46 -20
  95. package/ui/components/pay/NearbyFlow.tsx +575 -507
  96. package/ui/components/pay/OfflineNotice.tsx +1 -3
  97. package/ui/components/pay/PayCellRow.tsx +1 -4
  98. package/ui/components/pay/PayForm.tsx +1 -3
  99. package/ui/components/pay/RequestHub.tsx +14 -6
  100. package/ui/components/pay/UniversalSend.tsx +79 -27
  101. package/ui/components/pay/tokenSendCopy.ts +1 -2
  102. package/ui/components/pay/useRecipientInput.ts +2 -2
  103. package/ui/components/security/WalletLockNotice.tsx +1 -3
  104. package/ui/components/ui/AlertCard.tsx +44 -45
  105. package/ui/components/ui/BlurChrome.tsx +4 -15
  106. package/ui/components/ui/Celebration.tsx +3 -3
  107. package/ui/components/ui/ChoiceSheet.ts +1 -3
  108. package/ui/components/ui/ErrorBoundary.tsx +2 -6
  109. package/ui/components/ui/GroupedList.tsx +13 -31
  110. package/ui/components/ui/IconButton.tsx +6 -9
  111. package/ui/components/ui/ListRow.tsx +19 -25
  112. package/ui/components/ui/PresenceRow.tsx +4 -4
  113. package/ui/components/ui/PressableScale.tsx +24 -20
  114. package/ui/components/ui/Toast.tsx +23 -16
  115. package/ui/components/vault/KeyChooser.tsx +9 -6
  116. package/ui/components/vault/VaultBackdrop.tsx +1 -8
  117. package/ui/components/vault/VaultCeremonySheet.tsx +5 -5
  118. package/ui/components/wallet/ActivityRow.tsx +3 -2
  119. package/ui/components/wallet/BackupReminderSheet.tsx +1 -5
  120. package/ui/components/wallet/Balance.tsx +4 -1
  121. package/ui/components/wallet/ContactActivityList.tsx +7 -7
  122. package/ui/components/wallet/IconPickerSheet.tsx +1 -5
  123. package/ui/components/wallet/ProfileSwitcherPopover.tsx +6 -1
  124. package/ui/components/wallet/tokenEviction.ts +4 -1
  125. package/ui/hooks/useMandala.ts +1 -7
  126. package/ui/hooks/useOfflineNoticeActions.ts +21 -27
  127. package/ui/hooks/useSpendableBalance.ts +2 -2
  128. package/ui/hooks/useVaultCoverage.ts +7 -1
  129. package/ui/index.ts +9 -1
  130. package/ui/resolveIdentity.ts +20 -8
  131. package/ui/screens/ConnectionsScreen.tsx +44 -18
  132. package/ui/screens/LogsScreen.tsx +24 -22
  133. package/ui/screens/PairScreen.tsx +85 -54
  134. package/ui/screens/PayScreen.tsx +5 -1
  135. package/ui/screens/ProfileScreen.tsx +0 -3
  136. package/ui/screens/TrustScreen.tsx +125 -80
  137. package/ui/screens/VaultScreen.tsx +19 -7
  138. package/ui/screens/VaultTransferScreen.tsx +5 -1
  139. package/ui/screens/WalletCheckScreen.tsx +14 -17
  140. package/ui/screens/WalletConfigScreen.tsx +414 -376
  141. package/ui/screens/WalletHomeScreen.tsx +47 -42
@@ -1642,7 +1642,9 @@ function NearbyFlow({
1642
1642
  if (scanLatchRef.current) return
1643
1643
  scanLatchRef.current = true
1644
1644
  if (data.startsWith(POS_PREFIX)) {
1645
- void decodePaymentRequest(data).then(adoptSession).catch(() => fail('generic', t('invalid_qr_code')))
1645
+ void decodePaymentRequest(data)
1646
+ .then(adoptSession)
1647
+ .catch(() => fail('generic', t('invalid_qr_code')))
1646
1648
  return
1647
1649
  }
1648
1650
  let session: Session
@@ -1852,10 +1854,14 @@ function NearbyFlow({
1852
1854
  } catch (e) {
1853
1855
  console.warn('[localpay] abortAction failed:', messageOf(e))
1854
1856
  if (storage) {
1855
- await queuePendingAbort(storage, { reference, originator: adminOriginator }, {
1856
- wallet: wallet as unknown as PendingAbortTagWallet,
1857
- originator: adminOriginator
1858
- }).catch(() => undefined)
1857
+ await queuePendingAbort(
1858
+ storage,
1859
+ { reference, originator: adminOriginator },
1860
+ {
1861
+ wallet: wallet as unknown as PendingAbortTagWallet,
1862
+ originator: adminOriginator
1863
+ }
1864
+ ).catch(() => undefined)
1859
1865
  }
1860
1866
  }
1861
1867
  })()
@@ -1976,10 +1982,14 @@ function NearbyFlow({
1976
1982
  // same replay on the next wallet build.
1977
1983
  async reference => {
1978
1984
  if (!storage) return
1979
- await queuePendingAbort(storage, { reference, originator: adminOriginator }, {
1980
- wallet: wallet as unknown as PendingAbortTagWallet,
1981
- originator: adminOriginator
1982
- })
1985
+ await queuePendingAbort(
1986
+ storage,
1987
+ { reference, originator: adminOriginator },
1988
+ {
1989
+ wallet: wallet as unknown as PendingAbortTagWallet,
1990
+ originator: adminOriginator
1991
+ }
1992
+ )
1983
1993
  }
1984
1994
  )
1985
1995
  } catch (e) {
@@ -2137,10 +2147,14 @@ function NearbyFlow({
2137
2147
  },
2138
2148
  queueFailedAbort: async reference => {
2139
2149
  if (!storage) return
2140
- await queuePendingAbort(storage, { reference, originator: adminOriginator }, {
2141
- wallet: wallet as unknown as PendingAbortTagWallet,
2142
- originator: adminOriginator
2143
- })
2150
+ await queuePendingAbort(
2151
+ storage,
2152
+ { reference, originator: adminOriginator },
2153
+ {
2154
+ wallet: wallet as unknown as PendingAbortTagWallet,
2155
+ originator: adminOriginator
2156
+ }
2157
+ )
2144
2158
  },
2145
2159
  // P1-3: the payee's decline is unverifiable from here — watch the
2146
2160
  // txid so a later reappearance on chain (the payee's claim was wrong,
@@ -2392,10 +2406,14 @@ function NearbyFlow({
2392
2406
  },
2393
2407
  queueFailedAbort: async reference => {
2394
2408
  if (!storage) return
2395
- await queuePendingAbort(storage, { reference, originator: adminOriginator }, {
2396
- wallet: wallet as unknown as PendingAbortTagWallet,
2397
- originator: adminOriginator
2398
- })
2409
+ await queuePendingAbort(
2410
+ storage,
2411
+ { reference, originator: adminOriginator },
2412
+ {
2413
+ wallet: wallet as unknown as PendingAbortTagWallet,
2414
+ originator: adminOriginator
2415
+ }
2416
+ )
2399
2417
  }
2400
2418
  }
2401
2419
  )
@@ -2698,35 +2716,35 @@ function NearbyFlow({
2698
2716
  }
2699
2717
 
2700
2718
  const flowBody = (
2701
- <ScrollView
2702
- style={{ flex: 1, backgroundColor: colors.background }}
2703
- contentContainerStyle={[styles.scroll, { paddingBottom: insets.bottom + spacing.xxxl }]}
2704
- keyboardShouldPersistTaps="handled"
2705
- >
2706
- {/* ══ Payer entry ══
2719
+ <ScrollView
2720
+ style={{ flex: 1, backgroundColor: colors.background }}
2721
+ contentContainerStyle={[styles.scroll, { paddingBottom: insets.bottom + spacing.xxxl }]}
2722
+ keyboardShouldPersistTaps="handled"
2723
+ >
2724
+ {/* ══ Payer entry ══
2707
2725
  The Pay screen's grid already asked which side of the exchange this
2708
2726
  device is on, so there is no role choice left to make here and only
2709
2727
  one action: raise the camera again. Reached only by dismissing the
2710
2728
  scanner that opens on mount — a payee never sees this view, they go
2711
2729
  straight to naming an amount. */}
2712
- {phase === 'entry' && initialRole === 'payer' && (
2713
- <Animated.View entering={settleIn} style={styles.stage}>
2714
- <View style={[styles.heroCircle, { backgroundColor: colors.fillTertiary }]}>
2715
- <Ionicons name="qr-code-outline" size={44} color={colors.textSecondary} />
2716
- </View>
2717
- <View style={styles.gapLg} />
2718
- {phaseTitle(t('local_pay_scan_qr'))}
2719
- {supportText(t('pay_pre_nearby'))}
2720
- <View style={styles.gapXl} />
2721
- <PrimaryButton
2722
- styles={styles}
2723
- colors={colors}
2724
- icon="scan-outline"
2725
- label={t('local_pay_scan_qr')}
2726
- onPress={() => openScanner('send_scan')}
2727
- />
2730
+ {phase === 'entry' && initialRole === 'payer' && (
2731
+ <Animated.View entering={settleIn} style={styles.stage}>
2732
+ <View style={[styles.heroCircle, { backgroundColor: colors.fillTertiary }]}>
2733
+ <Ionicons name="qr-code-outline" size={44} color={colors.textSecondary} />
2734
+ </View>
2735
+ <View style={styles.gapLg} />
2736
+ {phaseTitle(t('local_pay_scan_qr'))}
2737
+ {supportText(t('pay_pre_nearby'))}
2738
+ <View style={styles.gapXl} />
2739
+ <PrimaryButton
2740
+ styles={styles}
2741
+ colors={colors}
2742
+ icon="scan-outline"
2743
+ label={t('local_pay_scan_qr')}
2744
+ onPress={() => openScanner('send_scan')}
2745
+ />
2728
2746
 
2729
- {/* TEMPORARY simulator affordance — __DEV__ only, never ships.
2747
+ {/* TEMPORARY simulator affordance — __DEV__ only, never ships.
2730
2748
  The simulator has no camera, so the payer flow is unreachable
2731
2749
  there. This mints an OPEN session (no amount) and feeds it
2732
2750
  through the real `onSessionScanned`, so decodeSession and every
@@ -2734,207 +2752,207 @@ function NearbyFlow({
2734
2752
  what you see is the genuine payer UI, not a mock.
2735
2753
  supportsAwdl is false so selectTransport picks the QR path,
2736
2754
  which is the one a simulator can actually complete. */}
2737
- {__DEV__ && (
2738
- <>
2739
- <View style={styles.gapMd} />
2740
- <SecondaryButton
2741
- styles={styles}
2742
- colors={colors}
2743
- icon="construct"
2744
- label="DEV: pay an open request"
2745
- onPress={() => {
2746
- scanLatchRef.current = false
2747
- onSessionScanned(
2748
- encodeSession(
2749
- mintSession({
2750
- // secp256k1 generator point: a genuinely valid
2751
- // compressed pubkey, so key derivation won't throw.
2752
- identityKey: '0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798',
2753
- derivationPrefix: 'ZGV2LXByZWZpeA==',
2754
- derivationSuffix: 'ZGV2LXN1ZmZpeA==',
2755
- supportsAwdl: false
2756
- })
2757
- )
2755
+ {__DEV__ && (
2756
+ <>
2757
+ <View style={styles.gapMd} />
2758
+ <SecondaryButton
2759
+ styles={styles}
2760
+ colors={colors}
2761
+ icon="construct"
2762
+ label="DEV: pay an open request"
2763
+ onPress={() => {
2764
+ scanLatchRef.current = false
2765
+ onSessionScanned(
2766
+ encodeSession(
2767
+ mintSession({
2768
+ // secp256k1 generator point: a genuinely valid
2769
+ // compressed pubkey, so key derivation won't throw.
2770
+ identityKey: '0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798',
2771
+ derivationPrefix: 'ZGV2LXByZWZpeA==',
2772
+ derivationSuffix: 'ZGV2LXN1ZmZpeA==',
2773
+ supportsAwdl: false
2774
+ })
2758
2775
  )
2759
- }}
2760
- />
2761
- </>
2762
- )}
2763
- </Animated.View>
2764
- )}
2776
+ )
2777
+ }}
2778
+ />
2779
+ </>
2780
+ )}
2781
+ </Animated.View>
2782
+ )}
2765
2783
 
2766
- {/* ══ Receive: amount ══
2784
+ {/* ══ Receive: amount ══
2767
2785
  Focal: the amount field. Everything else on the view is a label. */}
2768
- {phase === 'receive_amount' && (
2769
- <Animated.View entering={settleIn}>
2770
- {phaseTitle(t('local_pay_request'))}
2771
- <View style={styles.gapXl} />
2786
+ {phase === 'receive_amount' && (
2787
+ <Animated.View entering={settleIn}>
2788
+ {phaseTitle(t('local_pay_request'))}
2789
+ <View style={styles.gapXl} />
2772
2790
 
2773
- {/* No max button and no balance line: this asks the PAYER for money,
2791
+ {/* No max button and no balance line: this asks the PAYER for money,
2774
2792
  so the requester's own balance is meaningless here. Zero or blank
2775
2793
  is a real choice — payer decides — and the design says so by not
2776
2794
  gating on it. */}
2777
- <PayAmountField value={requestAmount} onChangeText={setRequestAmount} showMax={false} showBalance={false} />
2778
- {/* Never disabled. Leaving the amount at zero is a real choice — it
2795
+ <PayAmountField value={requestAmount} onChangeText={setRequestAmount} showMax={false} showBalance={false} />
2796
+ {/* Never disabled. Leaving the amount at zero is a real choice — it
2779
2797
  means "payer decides" — so gating Continue on a non-zero amount
2780
2798
  would make that choice unreachable. startRequest maps 0 to an
2781
2799
  open session. */}
2782
- <PrimaryButton
2783
- styles={styles}
2784
- colors={colors}
2785
- label={t('continue_action')}
2786
- onPress={() => void startRequest(satsFrom(requestAmount) || undefined)}
2787
- />
2788
- <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
2789
- </Animated.View>
2790
- )}
2800
+ <PrimaryButton
2801
+ styles={styles}
2802
+ colors={colors}
2803
+ label={t('continue_action')}
2804
+ onPress={() => void startRequest(satsFrom(requestAmount) || undefined)}
2805
+ />
2806
+ <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
2807
+ </Animated.View>
2808
+ )}
2791
2809
 
2792
- {/* Focal on each of these: the single status line. */}
2793
- {phase === 'receive_minting' && spinnerBlock(t('local_pay_preparing'))}
2794
- {phase === 'receive_settling' && spinnerBlock(t('local_pay_saving'))}
2795
- {phase === 'send_working' && spinnerBlock(t('local_pay_delivering'))}
2810
+ {/* Focal on each of these: the single status line. */}
2811
+ {phase === 'receive_minting' && spinnerBlock(t('local_pay_preparing'))}
2812
+ {phase === 'receive_settling' && spinnerBlock(t('local_pay_saving'))}
2813
+ {phase === 'send_working' && spinnerBlock(t('local_pay_delivering'))}
2796
2814
 
2797
- {/* ══ Receive: pairing QR (always) + AWDL listener (when supported) ══
2815
+ {/* ══ Receive: pairing QR (always) + AWDL listener (when supported) ══
2798
2816
  Focal: the pairing code. This is the one view whose focal element is
2799
2817
  not the amount, and deliberately: the code is the object being
2800
2818
  physically held up to another person, and shrinking a working
2801
2819
  scanner target to win a typographic argument would be the wrong
2802
2820
  trade. The amount sits above it at title scale, as the code's price. */}
2803
- {phase === 'receive_wait' && hostedSession && (
2804
- <Animated.View entering={settleIn} style={styles.stage}>
2805
- {phaseTitle(t('local_pay_show_qr'))}
2806
- <Text
2807
- style={[styles.amountTitle, { color: colors.textSecondary }]}
2808
- maxFontSizeMultiplier={1.4}
2809
- numberOfLines={1}
2810
- >
2811
- {hostedSession.amount === undefined ? (
2812
- t('local_pay_any_amount')
2813
- ) : hostedSession.asset ? (
2814
- formatTokenAmountWithUnit(hostedSession.amount, {
2815
- decimals: hostedSession.asset.decimals ?? 0,
2816
- ticker: hostedSession.asset.ticker ?? ''
2817
- })
2818
- ) : (
2819
- <AmountDisplay>{hostedSession.amount}</AmountDisplay>
2820
- )}
2821
- </Text>
2822
- <View style={styles.gapLg} />
2821
+ {phase === 'receive_wait' && hostedSession && (
2822
+ <Animated.View entering={settleIn} style={styles.stage}>
2823
+ {phaseTitle(t('local_pay_show_qr'))}
2824
+ <Text
2825
+ style={[styles.amountTitle, { color: colors.textSecondary }]}
2826
+ maxFontSizeMultiplier={1.4}
2827
+ numberOfLines={1}
2828
+ >
2829
+ {hostedSession.amount === undefined ? (
2830
+ t('local_pay_any_amount')
2831
+ ) : hostedSession.asset ? (
2832
+ formatTokenAmountWithUnit(hostedSession.amount, {
2833
+ decimals: hostedSession.asset.decimals ?? 0,
2834
+ ticker: hostedSession.asset.ticker ?? ''
2835
+ })
2836
+ ) : (
2837
+ <AmountDisplay>{hostedSession.amount}</AmountDisplay>
2838
+ )}
2839
+ </Text>
2840
+ <View style={styles.gapLg} />
2823
2841
 
2824
- {sessionQr && !sessionQrBroken ? (
2825
- <View style={[styles.qrCard, { shadowColor: colors.textPrimary }]}>
2826
- <View style={styles.qrPlate}>
2827
- {/* onError is mandatory: without it the encoder rethrows from
2842
+ {sessionQr && !sessionQrBroken ? (
2843
+ <View style={[styles.qrCard, { shadowColor: colors.textPrimary }]}>
2844
+ <View style={styles.qrPlate}>
2845
+ {/* onError is mandatory: without it the encoder rethrows from
2828
2846
  render and the app-level ErrorBoundary swallows the app. */}
2829
- <QRCode
2830
- value={sessionQr}
2831
- size={PAYMENT_QR_SIZE}
2832
- ecl="M"
2833
- color="#000"
2834
- backgroundColor="#fff"
2835
- onError={onSessionQrError}
2836
- />
2837
- </View>
2838
- </View>
2839
- ) : (
2840
- // Error state for this data area. The session cannot be handed
2841
- // over at all, so the only way forward is a fresh one.
2842
- <View
2843
- style={[styles.qrError, { backgroundColor: colors.fillTertiary, borderColor: colors.separator }]}
2844
- accessibilityRole="alert"
2845
- >
2846
- <Ionicons name="alert-circle-outline" size={28} color={colors.error} />
2847
- <View style={styles.gapSm} />
2848
- <Text style={[styles.support, { color: colors.textSecondary }]}>{t('local_pay_qr_unavailable')}</Text>
2847
+ <QRCode
2848
+ value={sessionQr}
2849
+ size={PAYMENT_QR_SIZE}
2850
+ ecl="M"
2851
+ color="#000"
2852
+ backgroundColor="#fff"
2853
+ onError={onSessionQrError}
2854
+ />
2849
2855
  </View>
2850
- )}
2856
+ </View>
2857
+ ) : (
2858
+ // Error state for this data area. The session cannot be handed
2859
+ // over at all, so the only way forward is a fresh one.
2860
+ <View
2861
+ style={[styles.qrError, { backgroundColor: colors.fillTertiary, borderColor: colors.separator }]}
2862
+ accessibilityRole="alert"
2863
+ >
2864
+ <Ionicons name="alert-circle-outline" size={28} color={colors.error} />
2865
+ <View style={styles.gapSm} />
2866
+ <Text style={[styles.support, { color: colors.textSecondary }]}>{t('local_pay_qr_unavailable')}</Text>
2867
+ </View>
2868
+ )}
2851
2869
 
2852
- <View style={styles.gapLg} />
2853
- {presenceBlock}
2870
+ <View style={styles.gapLg} />
2871
+ {presenceBlock}
2854
2872
 
2855
- {/* A frame arrived that could not be credited. Advisory, not a
2873
+ {/* A frame arrived that could not be credited. Advisory, not a
2856
2874
  failure: this session was deliberately NOT marked spent, so
2857
2875
  the pairing QR above is still live for the real payer. `notice`
2858
2876
  (set only for a token frame that failed COVER) names the
2859
2877
  ISSUER's records as the reason — a specific true sentence beats
2860
2878
  the generic "wrong session" one, and must never read as a
2861
2879
  scanning mistake this device made (ux design §4.3). */}
2862
- {sessionMismatch && (
2863
- <>
2864
- <View style={styles.gapLg} />
2865
- {notice ? (
2866
- noticeBlock(notice)
2867
- ) : (
2868
- <Animated.View
2869
- entering={fadeIn}
2870
- style={[styles.notice, { backgroundColor: colors.error + '15', borderColor: colors.error + '40' }]}
2871
- accessibilityRole="alert"
2872
- >
2873
- <Ionicons name="alert-circle-outline" size={16} color={colors.error} />
2874
- <Text style={[styles.noticeText, { color: colors.error }]}>{t('local_pay_wrong_session')}</Text>
2875
- </Animated.View>
2876
- )}
2877
- </>
2878
- )}
2879
-
2880
- {/* A radio gave up. The request is still live over QR — and over
2881
- any other radio still listening — so each of these is an
2882
- advisory, not a failure: the pairing QR above still works. */}
2883
- {radioFailures.map(([kind, err]) => (
2884
- <React.Fragment key={kind}>
2885
- <View style={styles.gapLg} />
2880
+ {sessionMismatch && (
2881
+ <>
2882
+ <View style={styles.gapLg} />
2883
+ {notice ? (
2884
+ noticeBlock(notice)
2885
+ ) : (
2886
2886
  <Animated.View
2887
2887
  entering={fadeIn}
2888
- style={[styles.notice, { backgroundColor: colors.fillTertiary, borderColor: colors.separator }]}
2888
+ style={[styles.notice, { backgroundColor: colors.error + '15', borderColor: colors.error + '40' }]}
2889
+ accessibilityRole="alert"
2889
2890
  >
2890
- <Ionicons name="information-circle-outline" size={16} color={colors.textSecondary} />
2891
- <Text style={[styles.noticeText, { color: colors.textSecondary }]}>
2892
- {err.networkDenied
2893
- ? t('local_pay_network_denied')
2894
- : kind === 'ble'
2895
- ? t('local_pay_ble_unavailable')
2896
- : t('local_pay_nearby_unavailable')}
2897
- </Text>
2891
+ <Ionicons name="alert-circle-outline" size={16} color={colors.error} />
2892
+ <Text style={[styles.noticeText, { color: colors.error }]}>{t('local_pay_wrong_session')}</Text>
2898
2893
  </Animated.View>
2899
- </React.Fragment>
2900
- ))}
2901
-
2902
- <View style={styles.gapXl} />
2903
- {radioFailures.some(([, err]) => err.networkDenied) && (
2904
- <>
2905
- <SecondaryButton
2906
- styles={styles}
2907
- colors={colors}
2908
- icon="settings-outline"
2909
- label={t('open_settings')}
2910
- onPress={() => void Linking.openSettings()}
2911
- />
2912
- <View style={styles.gapMd} />
2913
- </>
2914
- )}
2915
- <SecondaryButton
2916
- styles={styles}
2917
- colors={colors}
2918
- icon="scan-outline"
2919
- label={t('local_pay_scan_payer_qr')}
2920
- onPress={() => openScanner('receive_scan')}
2921
- />
2922
- <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
2923
- </Animated.View>
2924
- )}
2894
+ )}
2895
+ </>
2896
+ )}
2897
+
2898
+ {/* A radio gave up. The request is still live over QR — and over
2899
+ any other radio still listening — so each of these is an
2900
+ advisory, not a failure: the pairing QR above still works. */}
2901
+ {radioFailures.map(([kind, err]) => (
2902
+ <React.Fragment key={kind}>
2903
+ <View style={styles.gapLg} />
2904
+ <Animated.View
2905
+ entering={fadeIn}
2906
+ style={[styles.notice, { backgroundColor: colors.fillTertiary, borderColor: colors.separator }]}
2907
+ >
2908
+ <Ionicons name="information-circle-outline" size={16} color={colors.textSecondary} />
2909
+ <Text style={[styles.noticeText, { color: colors.textSecondary }]}>
2910
+ {err.networkDenied
2911
+ ? t('local_pay_network_denied')
2912
+ : kind === 'ble'
2913
+ ? t('local_pay_ble_unavailable')
2914
+ : t('local_pay_nearby_unavailable')}
2915
+ </Text>
2916
+ </Animated.View>
2917
+ </React.Fragment>
2918
+ ))}
2919
+
2920
+ <View style={styles.gapXl} />
2921
+ {radioFailures.some(([, err]) => err.networkDenied) && (
2922
+ <>
2923
+ <SecondaryButton
2924
+ styles={styles}
2925
+ colors={colors}
2926
+ icon="settings-outline"
2927
+ label={t('open_settings')}
2928
+ onPress={() => void Linking.openSettings()}
2929
+ />
2930
+ <View style={styles.gapMd} />
2931
+ </>
2932
+ )}
2933
+ <SecondaryButton
2934
+ styles={styles}
2935
+ colors={colors}
2936
+ icon="scan-outline"
2937
+ label={t('local_pay_scan_payer_qr')}
2938
+ onPress={() => openScanner('receive_scan')}
2939
+ />
2940
+ <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
2941
+ </Animated.View>
2942
+ )}
2925
2943
 
2926
- {/* ══ Send: confirm ══
2944
+ {/* ══ Send: confirm ══
2927
2945
  Focal: the amount — the figure being handed over, at display scale
2928
2946
  when the payee fixed it, or the live field when they left it open. */}
2929
- {phase === 'send_confirm' && scannedSession && (
2930
- <Animated.View entering={settleIn}>
2931
- {phaseTitle(scannedSession.amount === undefined ? t('local_pay_choose_amount') : t('local_pay_send'))}
2932
-
2933
- {scannedSession.amount === undefined ? (
2934
- <>
2935
- {supportText(t('local_pay_enter_amount_send'))}
2936
- <View style={styles.gapXl} />
2937
- {/* Token mode on a token session: the field takes and emits base
2947
+ {phase === 'send_confirm' && scannedSession && (
2948
+ <Animated.View entering={settleIn}>
2949
+ {phaseTitle(scannedSession.amount === undefined ? t('local_pay_choose_amount') : t('local_pay_send'))}
2950
+
2951
+ {scannedSession.amount === undefined ? (
2952
+ <>
2953
+ {supportText(t('local_pay_enter_amount_send'))}
2954
+ <View style={styles.gapXl} />
2955
+ {/* Token mode on a token session: the field takes and emits base
2938
2956
  units of the payee's asset and labels itself with its ticker,
2939
2957
  Max writes this payer's real holding, and the line under it is
2940
2958
  that holding — never the BSV spendable figure, which is the
@@ -2942,283 +2960,288 @@ function NearbyFlow({
2942
2960
  the payer would be typing satoshis against a USDX request,
2943
2961
  and Max would write the satoshi send-max sentinel straight
2944
2962
  into a token build. */}
2945
- <PayAmountField
2946
- value={sendAmount}
2947
- onChangeText={setSendAmount}
2948
- asset={scannedAssetUnits}
2949
- maxValue={scannedHolding && !unitsUnknown ? String(scannedHolding.baseUnits) : undefined}
2950
- availableText={
2951
- scannedHolding && scannedAssetUnits && !unitsUnknown
2952
- ? (formatTokenAmount(scannedHolding.baseUnits, scannedAssetUnits.decimals) ?? undefined)
2953
- : undefined
2954
- }
2955
- // No money chrome at all while the unit is unknown: an
2956
- // unlabelled balance is exactly the figure principle 4 forbids.
2957
- showBalance={!scannedAssetUnits || (scannedHolding != null && !unitsUnknown)}
2958
- />
2959
- </>
2960
- ) : (
2961
- <>
2962
- <View style={styles.stageTight}>
2963
- {unitsUnknown ? (
2964
- // The payee named a figure this device cannot denominate:
2965
- // a bare number at a guessed scale is exactly what must not
2966
- // be printed (principle 4), so the slot says so instead.
2967
- <Animated.View entering={settleIn} style={styles.amountBlock}>
2968
- <Text
2969
- style={[styles.amountDisplay, { color: colors.textSecondary }]}
2970
- maxFontSizeMultiplier={1.3}
2971
- numberOfLines={1}
2972
- adjustsFontSizeToFit
2973
- accessibilityRole="text"
2974
- >
2975
- {t('token_row_amount_pending')}
2976
- </Text>
2977
- </Animated.View>
2978
- ) : (
2979
- amountBlock(scannedSession.amount, undefined, scannedAssetUnits)
2980
- )}
2981
- </View>
2982
- <View style={styles.gapXl} />
2983
- {/* The payer's own BSV balance is the fee balance and says
2963
+ <PayAmountField
2964
+ value={sendAmount}
2965
+ onChangeText={setSendAmount}
2966
+ asset={scannedAssetUnits}
2967
+ maxValue={scannedHolding && !unitsUnknown ? String(scannedHolding.baseUnits) : undefined}
2968
+ availableText={
2969
+ scannedHolding && scannedAssetUnits && !unitsUnknown
2970
+ ? (formatTokenAmount(scannedHolding.baseUnits, scannedAssetUnits.decimals) ?? undefined)
2971
+ : undefined
2972
+ }
2973
+ // No money chrome at all while the unit is unknown: an
2974
+ // unlabelled balance is exactly the figure principle 4 forbids.
2975
+ showBalance={!scannedAssetUnits || (scannedHolding != null && !unitsUnknown)}
2976
+ />
2977
+ </>
2978
+ ) : (
2979
+ <>
2980
+ <View style={styles.stageTight}>
2981
+ {unitsUnknown ? (
2982
+ // The payee named a figure this device cannot denominate:
2983
+ // a bare number at a guessed scale is exactly what must not
2984
+ // be printed (principle 4), so the slot says so instead.
2985
+ <Animated.View entering={settleIn} style={styles.amountBlock}>
2986
+ <Text
2987
+ style={[styles.amountDisplay, { color: colors.textSecondary }]}
2988
+ maxFontSizeMultiplier={1.3}
2989
+ numberOfLines={1}
2990
+ adjustsFontSizeToFit
2991
+ accessibilityRole="text"
2992
+ >
2993
+ {t('token_row_amount_pending')}
2994
+ </Text>
2995
+ </Animated.View>
2996
+ ) : (
2997
+ amountBlock(scannedSession.amount, undefined, scannedAssetUnits)
2998
+ )}
2999
+ </View>
3000
+ <View style={styles.gapXl} />
3001
+ {/* The payer's own BSV balance is the fee balance and says
2984
3002
  nothing about what they hold of the asset; on a token
2985
3003
  request it would be a figure beside an unrelated one. */}
2986
- {!scannedSession.asset && <AvailableBalance withUnit />}
2987
- </>
2988
- )}
2989
-
2990
- <PayField labelKey="note">
2991
- <TextInput
2992
- value={note}
2993
- onChangeText={setNote}
2994
- placeholder={t('note_placeholder')}
2995
- placeholderTextColor={colors.textQuaternary}
2996
- maxLength={280}
2997
- style={[
2998
- styles.noteInput,
2999
- {
3000
- backgroundColor: colors.backgroundSecondary,
3001
- borderColor: colors.separator,
3002
- color: colors.textPrimary
3003
- }
3004
- ]}
3005
- />
3006
- </PayField>
3004
+ {!scannedSession.asset && <AvailableBalance withUnit />}
3005
+ </>
3006
+ )}
3007
3007
 
3008
- <RecipientSummary
3009
- name={peerName ?? scannedSession.merchantName ?? abbreviateKey(scannedSession.identityKey)}
3010
- detail={scannedSession.merchantName ? `Merchant · ${abbreviateKey(scannedSession.identityKey)}` : peerName ? abbreviateKey(scannedSession.identityKey) : undefined}
3008
+ <PayField labelKey="note">
3009
+ <TextInput
3010
+ value={note}
3011
+ onChangeText={setNote}
3012
+ placeholder={t('note_placeholder')}
3013
+ placeholderTextColor={colors.textQuaternary}
3014
+ maxLength={280}
3015
+ style={[
3016
+ styles.noteInput,
3017
+ {
3018
+ backgroundColor: colors.backgroundSecondary,
3019
+ borderColor: colors.separator,
3020
+ color: colors.textPrimary
3021
+ }
3022
+ ]}
3011
3023
  />
3024
+ </PayField>
3025
+
3026
+ <RecipientSummary
3027
+ name={peerName ?? scannedSession.merchantName ?? abbreviateKey(scannedSession.identityKey)}
3028
+ detail={
3029
+ scannedSession.merchantName
3030
+ ? `Merchant · ${abbreviateKey(scannedSession.identityKey)}`
3031
+ : peerName
3032
+ ? abbreviateKey(scannedSession.identityKey)
3033
+ : undefined
3034
+ }
3035
+ />
3012
3036
 
3013
- {!!scannedSession.merchantTip && supportText(t('merchant_tip_breakdown', {
3014
- defaultValue: '{{subtotal}} sats sale + {{tip}} sats tip',
3015
- subtotal: scannedSession.merchantSubtotal?.toLocaleString(), tip: scannedSession.merchantTip.toLocaleString()
3016
- }))}
3017
- <View style={styles.gapLg} />
3018
- {presenceBlock}
3019
- {floorReason !== 'none' && (
3020
- <>
3021
- <View style={styles.gapLg} />
3022
- {supportText(t(FLOOR_KEYS[floorReason]))}
3023
- {floorReason === 'local_ble_denied' && (
3024
- <>
3025
- <View style={styles.gapMd} />
3026
- <SecondaryButton
3027
- styles={styles}
3028
- colors={colors}
3029
- icon="settings-outline"
3030
- label={t('open_settings')}
3031
- onPress={() => void Linking.openSettings()}
3032
- />
3033
- </>
3034
- )}
3035
- </>
3037
+ {!!scannedSession.merchantTip &&
3038
+ supportText(
3039
+ t('merchant_tip_breakdown', {
3040
+ defaultValue: '{{subtotal}} sats sale + {{tip}} sats tip',
3041
+ subtotal: scannedSession.merchantSubtotal?.toLocaleString(),
3042
+ tip: scannedSession.merchantTip.toLocaleString()
3043
+ })
3036
3044
  )}
3045
+ <View style={styles.gapLg} />
3046
+ {presenceBlock}
3047
+ {floorReason !== 'none' && (
3048
+ <>
3049
+ <View style={styles.gapLg} />
3050
+ {supportText(t(FLOOR_KEYS[floorReason]))}
3051
+ {floorReason === 'local_ble_denied' && (
3052
+ <>
3053
+ <View style={styles.gapMd} />
3054
+ <SecondaryButton
3055
+ styles={styles}
3056
+ colors={colors}
3057
+ icon="settings-outline"
3058
+ label={t('open_settings')}
3059
+ onPress={() => void Linking.openSettings()}
3060
+ />
3061
+ </>
3062
+ )}
3063
+ </>
3064
+ )}
3037
3065
 
3038
- {overHolding && scannedAssetUnits && !unitsUnknown && (
3039
- <>
3040
- <View style={styles.gapLg} />
3041
- {supportText(t('pay_asset_over_balance', { ticker: scannedAssetUnits.ticker }))}
3042
- </>
3043
- )}
3044
- {unitsUnknown && (
3045
- <>
3046
- <View style={styles.gapLg} />
3047
- {supportText(t('pay_asset_unidentified'))}
3048
- </>
3049
- )}
3050
- <View style={styles.gapXl} />
3051
- <PrimaryButton
3052
- styles={styles}
3053
- colors={colors}
3054
- icon="arrow-up"
3055
- label={t('local_pay_send')}
3056
- disabled={!canSend}
3057
- onPress={() => void executeSend()}
3058
- />
3059
- <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
3060
- </Animated.View>
3061
- )}
3066
+ {overHolding && scannedAssetUnits && !unitsUnknown && (
3067
+ <>
3068
+ <View style={styles.gapLg} />
3069
+ {supportText(t('pay_asset_over_balance', { ticker: scannedAssetUnits.ticker }))}
3070
+ </>
3071
+ )}
3072
+ {unitsUnknown && (
3073
+ <>
3074
+ <View style={styles.gapLg} />
3075
+ {supportText(t('pay_asset_unidentified'))}
3076
+ </>
3077
+ )}
3078
+ <View style={styles.gapXl} />
3079
+ <PrimaryButton
3080
+ styles={styles}
3081
+ colors={colors}
3082
+ icon="arrow-up"
3083
+ label={t('local_pay_send')}
3084
+ disabled={!canSend}
3085
+ onPress={() => void executeSend()}
3086
+ />
3087
+ <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
3088
+ </Animated.View>
3089
+ )}
3062
3090
 
3063
- {/* ══ Send: hand the frame over as a QR ══
3091
+ {/* ══ Send: hand the frame over as a QR ══
3064
3092
  Focal: the payment code. The amount is settled by this point and
3065
3093
  demotes to a caption. */}
3066
- {phase === 'send_qr' && paymentQr && (
3067
- <Animated.View entering={settleIn} style={styles.stage}>
3068
- {phaseTitle(t('local_pay_show_payment_qr'))}
3069
- <Text
3070
- style={[styles.amountTitle, { color: colors.textSecondary }]}
3071
- maxFontSizeMultiplier={1.4}
3072
- numberOfLines={1}
3073
- >
3074
- {scannedAssetUnits ? (
3075
- formatTokenAmountWithUnit(payAmount, scannedAssetUnits)
3076
- ) : (
3077
- <AmountDisplay>{payAmount}</AmountDisplay>
3078
- )}
3079
- </Text>
3080
- {paymentQrBlocks > 1 && (
3081
- <Text style={[styles.support, { color: colors.textSecondary }]}>{t('local_pay_animated_hint')}</Text>
3094
+ {phase === 'send_qr' && paymentQr && (
3095
+ <Animated.View entering={settleIn} style={styles.stage}>
3096
+ {phaseTitle(t('local_pay_show_payment_qr'))}
3097
+ <Text
3098
+ style={[styles.amountTitle, { color: colors.textSecondary }]}
3099
+ maxFontSizeMultiplier={1.4}
3100
+ numberOfLines={1}
3101
+ >
3102
+ {scannedAssetUnits ? (
3103
+ formatTokenAmountWithUnit(payAmount, scannedAssetUnits)
3104
+ ) : (
3105
+ <AmountDisplay>{payAmount}</AmountDisplay>
3082
3106
  )}
3083
- <View style={styles.gapLg} />
3084
- <View style={[styles.qrCard, { shadowColor: colors.textPrimary }]}>
3085
- <View style={styles.qrPlate}>
3086
- {/* onError is mandatory: without it an oversize payload rethrows
3107
+ </Text>
3108
+ {paymentQrBlocks > 1 && (
3109
+ <Text style={[styles.support, { color: colors.textSecondary }]}>{t('local_pay_animated_hint')}</Text>
3110
+ )}
3111
+ <View style={styles.gapLg} />
3112
+ <View style={[styles.qrCard, { shadowColor: colors.textPrimary }]}>
3113
+ <View style={styles.qrPlate}>
3114
+ {/* onError is mandatory: without it an oversize payload rethrows
3087
3115
  from render and the app-level ErrorBoundary swallows the app. */}
3088
- <PaymentQrDisplay frameQr={paymentQr} size={PAYMENT_QR_SIZE} onError={onPaymentQrError} />
3089
- </View>
3116
+ <PaymentQrDisplay frameQr={paymentQr} size={PAYMENT_QR_SIZE} onError={onPaymentQrError} />
3090
3117
  </View>
3091
- <View style={styles.gapLg} />
3092
- {presenceBlock}
3093
- {!!notice && (
3094
- <>
3095
- <View style={styles.gapLg} />
3096
- {noticeBlock(notice)}
3097
- </>
3098
- )}
3099
- <View style={styles.gapXl} />
3100
- {/* Done asserts delivery: persist the frame, then broadcast when
3118
+ </View>
3119
+ <View style={styles.gapLg} />
3120
+ {presenceBlock}
3121
+ {!!notice && (
3122
+ <>
3123
+ <View style={styles.gapLg} />
3124
+ {noticeBlock(notice)}
3125
+ </>
3126
+ )}
3127
+ <View style={styles.gapXl} />
3128
+ {/* Done asserts delivery: persist the frame, then broadcast when
3101
3129
  online (see completeQrDelivery / finalizeDelivery). Never an
3102
3130
  abort — the payee may be about to broadcast this frame, and
3103
3131
  freeing its inputs would let this wallet respend them. */}
3104
- <PrimaryButton
3105
- styles={styles}
3106
- colors={colors}
3107
- label={t('done')}
3108
- onPress={() => void completeQrDelivery()}
3109
- />
3110
- {/* Not "Cancel": leaving keeps the payment exactly as Done does,
3132
+ <PrimaryButton styles={styles} colors={colors} label={t('done')} onPress={() => void completeQrDelivery()} />
3133
+ {/* Not "Cancel": leaving keeps the payment exactly as Done does,
3111
3134
  so the old label promised an abort that no longer happens. */}
3112
- <CancelButton
3113
- styles={styles}
3114
- colors={colors}
3115
- label={t('back')}
3116
- onPress={() => void handleSendQrExit(false)}
3117
- />
3118
- </Animated.View>
3119
- )}
3135
+ <CancelButton
3136
+ styles={styles}
3137
+ colors={colors}
3138
+ label={t('back')}
3139
+ onPress={() => void handleSendQrExit(false)}
3140
+ />
3141
+ </Animated.View>
3142
+ )}
3120
3143
 
3121
- {/* ══ Done ══
3144
+ {/* ══ Done ══
3122
3145
  Focal: the amount. The celebration mark is a transient overlay that
3123
3146
  owns attention for ~700ms and then hands it back, so the two never
3124
3147
  compete for the same beat. */}
3125
- {/* ══ Already paid — a success terminal, not an error ══
3148
+ {/* ══ Already paid — a success terminal, not an error ══
3126
3149
  Focal: the headline. There is no figure to show — this device never
3127
3150
  saw a second payment — so nothing here is at display scale. */}
3128
- {phase === 'already_paid' && (
3129
- <Animated.View entering={settleIn} style={styles.stage}>
3130
- <Ionicons name="checkmark-done-circle-outline" size={56} color={colors.textSecondary} />
3131
- <View style={styles.gapLg} />
3132
- {phaseTitle(t('local_pay_already_paid'))}
3133
- {supportText(t('local_pay_queued'))}
3134
- <View style={styles.gapXl} />
3135
- {/* Deliberately no retry: reset() would mint a fresh session and ask
3151
+ {phase === 'already_paid' && (
3152
+ <Animated.View entering={settleIn} style={styles.stage}>
3153
+ <Ionicons name="checkmark-done-circle-outline" size={56} color={colors.textSecondary} />
3154
+ <View style={styles.gapLg} />
3155
+ {phaseTitle(t('local_pay_already_paid'))}
3156
+ {supportText(t('local_pay_queued'))}
3157
+ <View style={styles.gapXl} />
3158
+ {/* Deliberately no retry: reset() would mint a fresh session and ask
3136
3159
  the payer to pay a second time for money already queued here. */}
3137
- <PrimaryButton styles={styles} colors={colors} label={t('done')} onPress={goBack} />
3138
- </Animated.View>
3139
- )}
3160
+ <PrimaryButton styles={styles} colors={colors} label={t('done')} onPress={goBack} />
3161
+ </Animated.View>
3162
+ )}
3140
3163
 
3141
- {/* ══ Failed ══
3164
+ {/* ══ Failed ══
3142
3165
  Focal: the reason. The title is generic by design, so the sentence
3143
3166
  under it carries the information and gets the weight. */}
3144
- {phase === 'failed' && (
3145
- <Animated.View entering={settleIn} style={styles.stage} accessibilityRole="alert">
3146
- <View style={[styles.heroCircle, { backgroundColor: colors.error + '15' }]}>
3147
- <Ionicons name="alert-circle-outline" size={40} color={colors.error} />
3148
- </View>
3149
- <View style={styles.gapLg} />
3150
- {phaseTitle(t('local_pay_failed'))}
3151
- <Text style={[styles.reason, { color: colors.textPrimary }]} textBreakStrategy="balanced">
3152
- {failure?.detail}
3153
- </Text>
3154
- <View style={styles.gapXl} />
3155
-
3156
- {/* A frame reached this device but never reached storage. Retry the
3167
+ {phase === 'failed' && (
3168
+ <Animated.View entering={settleIn} style={styles.stage} accessibilityRole="alert">
3169
+ <View style={[styles.heroCircle, { backgroundColor: colors.error + '15' }]}>
3170
+ <Ionicons name="alert-circle-outline" size={40} color={colors.error} />
3171
+ </View>
3172
+ <View style={styles.gapLg} />
3173
+ {phaseTitle(t('local_pay_failed'))}
3174
+ <Text style={[styles.reason, { color: colors.textPrimary }]} textBreakStrategy="balanced">
3175
+ {failure?.detail}
3176
+ </Text>
3177
+ <View style={styles.gapXl} />
3178
+
3179
+ {/* A frame reached this device but never reached storage. Retry the
3157
3180
  SAME session — reset() would mint one that can never receive it. */}
3158
- {unsettled && (
3159
- <>
3160
- <PrimaryButton
3161
- styles={styles}
3162
- colors={colors}
3163
- icon="refresh"
3164
- label={t('local_pay_retry_save')}
3165
- onPress={retrySettle}
3166
- />
3167
- <View style={styles.gapMd} />
3168
- </>
3169
- )}
3181
+ {unsettled && (
3182
+ <>
3183
+ <PrimaryButton
3184
+ styles={styles}
3185
+ colors={colors}
3186
+ icon="refresh"
3187
+ label={t('local_pay_retry_save')}
3188
+ onPress={retrySettle}
3189
+ />
3190
+ <View style={styles.gapMd} />
3191
+ </>
3192
+ )}
3170
3193
 
3171
- {failure?.settings && (
3172
- <>
3173
- <SecondaryButton
3174
- styles={styles}
3175
- colors={colors}
3176
- icon="settings-outline"
3177
- label={t('open_settings')}
3178
- onPress={() => void Linking.openSettings()}
3179
- />
3180
- <View style={styles.gapMd} />
3181
- </>
3182
- )}
3194
+ {failure?.settings && (
3195
+ <>
3196
+ <SecondaryButton
3197
+ styles={styles}
3198
+ colors={colors}
3199
+ icon="settings-outline"
3200
+ label={t('open_settings')}
3201
+ onPress={() => void Linking.openSettings()}
3202
+ />
3203
+ <View style={styles.gapMd} />
3204
+ </>
3205
+ )}
3183
3206
 
3184
- {failure?.offerWalletCheck && (
3185
- <>
3186
- <SecondaryButton
3187
- styles={styles}
3188
- colors={colors}
3189
- label={t('check_wallet')}
3190
- onPress={() => router.push('/wallet-check' as never)}
3191
- />
3192
- <View style={styles.gapMd} />
3193
- </>
3194
- )}
3207
+ {failure?.offerWalletCheck && (
3208
+ <>
3209
+ <SecondaryButton
3210
+ styles={styles}
3211
+ colors={colors}
3212
+ label={t('check_wallet')}
3213
+ onPress={() => router.push('/wallet-check' as never)}
3214
+ />
3215
+ <View style={styles.gapMd} />
3216
+ </>
3217
+ )}
3195
3218
 
3196
- {paymentQr && (
3197
- <>
3198
- <SecondaryButton
3199
- styles={styles}
3200
- colors={colors}
3201
- icon="qr-code-outline"
3202
- label={t('local_pay_show_qr_instead')}
3203
- onPress={() => {
3204
- setFailure(null)
3205
- setPhase('send_qr')
3206
- }}
3207
- />
3208
- <View style={styles.gapMd} />
3209
- </>
3210
- )}
3219
+ {paymentQr && (
3220
+ <>
3221
+ <SecondaryButton
3222
+ styles={styles}
3223
+ colors={colors}
3224
+ icon="qr-code-outline"
3225
+ label={t('local_pay_show_qr_instead')}
3226
+ onPress={() => {
3227
+ setFailure(null)
3228
+ setPhase('send_qr')
3229
+ }}
3230
+ />
3231
+ <View style={styles.gapMd} />
3232
+ </>
3233
+ )}
3211
3234
 
3212
- {/* With a frame in hand, reset() means abandoning it — the frame lives
3235
+ {/* With a frame in hand, reset() means abandoning it — the frame lives
3213
3236
  only in memory — so it is demoted to the secondary action. */}
3214
- {unsettled ? (
3215
- <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
3216
- ) : (
3217
- <PrimaryButton styles={styles} colors={colors} label={t('retry')} onPress={retry} />
3218
- )}
3219
- </Animated.View>
3220
- )}
3221
- </ScrollView>
3237
+ {unsettled ? (
3238
+ <CancelButton styles={styles} colors={colors} label={t('cancel')} onPress={reset} />
3239
+ ) : (
3240
+ <PrimaryButton styles={styles} colors={colors} label={t('retry')} onPress={retry} />
3241
+ )}
3242
+ </Animated.View>
3243
+ )}
3244
+ </ScrollView>
3222
3245
  )
3223
3246
 
3224
3247
  /**
@@ -3259,7 +3282,15 @@ function NearbyFlow({
3259
3282
  </View>
3260
3283
  ) : phase === 'receive_wait' && hostedSession ? (
3261
3284
  <View
3262
- style={[styles.qrError, { width: embeddedQrSize, height: embeddedQrSize, backgroundColor: colors.fillTertiary, borderColor: colors.separator }]}
3285
+ style={[
3286
+ styles.qrError,
3287
+ {
3288
+ width: embeddedQrSize,
3289
+ height: embeddedQrSize,
3290
+ backgroundColor: colors.fillTertiary,
3291
+ borderColor: colors.separator
3292
+ }
3293
+ ]}
3263
3294
  accessibilityRole="alert"
3264
3295
  >
3265
3296
  <Ionicons name="alert-circle-outline" size={28} color={colors.error} />
@@ -3269,7 +3300,10 @@ function NearbyFlow({
3269
3300
  ) : (
3270
3301
  // the code's own footprint, so the host's layout does not jump
3271
3302
  <View
3272
- style={[styles.embeddedPending, { width: embeddedQrSize + spacing.lg * 2, height: embeddedQrSize + spacing.lg * 2 }]}
3303
+ style={[
3304
+ styles.embeddedPending,
3305
+ { width: embeddedQrSize + spacing.lg * 2, height: embeddedQrSize + spacing.lg * 2 }
3306
+ ]}
3273
3307
  accessibilityRole="progressbar"
3274
3308
  accessibilityLabel={phase === 'receive_settling' ? t('local_pay_saving') : t('local_pay_preparing')}
3275
3309
  >
@@ -3336,7 +3370,9 @@ function NearbyFlow({
3336
3370
  accessibilityLabel={t('local_pay_scan_payer_qr')}
3337
3371
  >
3338
3372
  <Ionicons name="scan-outline" size={16} color={colors.textSecondary} />
3339
- <Text style={[styles.embeddedScanText, { color: colors.textSecondary }]}>{t('local_pay_scan_payer_qr')}</Text>
3373
+ <Text style={[styles.embeddedScanText, { color: colors.textSecondary }]}>
3374
+ {t('local_pay_scan_payer_qr')}
3375
+ </Text>
3340
3376
  </PressableScale>
3341
3377
  </>
3342
3378
  )}
@@ -3358,68 +3394,100 @@ function NearbyFlow({
3358
3394
  role !== 'payer' || !renderPayer
3359
3395
  ? null
3360
3396
  : phase === 'send_confirm' && scannedSession && renderPayer.confirm
3361
- ? { node: <Hosted render={renderPayer.confirm} value={{
3362
- session: scannedSession,
3363
- fixedAmount: scannedSession.amount,
3364
- amount: payAmount,
3365
- setAmount: units => setSendAmount(units !== undefined && units > 0 ? String(Math.round(units)) : ''),
3366
- asset: scannedAssetUnits,
3367
- holding: scannedHolding && !unitsUnknown ? scannedHolding.baseUnits : undefined,
3368
- note,
3369
- setNote,
3370
- recipient: payerRecipient,
3371
- tipText: scannedSession.merchantTip
3372
- ? t('merchant_tip_breakdown', {
3373
- defaultValue: '{{subtotal}} sats sale + {{tip}} sats tip',
3374
- subtotal: scannedSession.merchantSubtotal?.toLocaleString(),
3375
- tip: scannedSession.merchantTip.toLocaleString()
3376
- })
3377
- : undefined,
3378
- presence,
3379
- advisories: [
3380
- ...(floorReason !== 'none' ? [t(FLOOR_KEYS[floorReason])] : []),
3381
- ...(overHolding && scannedAssetUnits && !unitsUnknown
3382
- ? [t('pay_asset_over_balance', { ticker: scannedAssetUnits.ticker })]
3383
- : []),
3384
- ...(unitsUnknown ? [t('pay_asset_unidentified')] : [])
3385
- ],
3386
- openSettings: floorReason === 'local_ble_denied' ? () => void Linking.openSettings() : undefined,
3387
- canSend,
3388
- send: () => void executeSend(),
3389
- cancel: reset
3390
- }} /> }
3397
+ ? {
3398
+ node: (
3399
+ <Hosted
3400
+ render={renderPayer.confirm}
3401
+ value={{
3402
+ session: scannedSession,
3403
+ fixedAmount: scannedSession.amount,
3404
+ amount: payAmount,
3405
+ setAmount: units => setSendAmount(units !== undefined && units > 0 ? String(Math.round(units)) : ''),
3406
+ asset: scannedAssetUnits,
3407
+ holding: scannedHolding && !unitsUnknown ? scannedHolding.baseUnits : undefined,
3408
+ note,
3409
+ setNote,
3410
+ recipient: payerRecipient,
3411
+ tipText: scannedSession.merchantTip
3412
+ ? t('merchant_tip_breakdown', {
3413
+ defaultValue: '{{subtotal}} sats sale + {{tip}} sats tip',
3414
+ subtotal: scannedSession.merchantSubtotal?.toLocaleString(),
3415
+ tip: scannedSession.merchantTip.toLocaleString()
3416
+ })
3417
+ : undefined,
3418
+ presence,
3419
+ advisories: [
3420
+ ...(floorReason !== 'none' ? [t(FLOOR_KEYS[floorReason])] : []),
3421
+ ...(overHolding && scannedAssetUnits && !unitsUnknown
3422
+ ? [t('pay_asset_over_balance', { ticker: scannedAssetUnits.ticker })]
3423
+ : []),
3424
+ ...(unitsUnknown ? [t('pay_asset_unidentified')] : [])
3425
+ ],
3426
+ openSettings: floorReason === 'local_ble_denied' ? () => void Linking.openSettings() : undefined,
3427
+ canSend,
3428
+ send: () => void executeSend(),
3429
+ cancel: reset
3430
+ }}
3431
+ />
3432
+ )
3433
+ }
3391
3434
  : phase === 'send_working' && renderPayer.sending
3392
- ? { node: <Hosted render={renderPayer.sending} value={{ amount: payAmount, asset: scannedAssetUnits, recipient: payerRecipient, presence }} /> }
3435
+ ? {
3436
+ node: (
3437
+ <Hosted
3438
+ render={renderPayer.sending}
3439
+ value={{ amount: payAmount, asset: scannedAssetUnits, recipient: payerRecipient, presence }}
3440
+ />
3441
+ )
3442
+ }
3393
3443
  : phase === 'send_qr' && paymentQr && renderPayer.showCode
3394
- ? { node: <Hosted render={renderPayer.showCode} value={{
3395
- code: size => <PaymentQrDisplay frameQr={paymentQr} size={size} onError={onPaymentQrError} />,
3396
- animated: paymentQrBlocks > 1,
3397
- amount: payAmount,
3398
- asset: scannedAssetUnits,
3399
- recipient: payerRecipient,
3400
- presence,
3401
- notice: notice ?? undefined,
3402
- done: () => void completeQrDelivery(),
3403
- back: () => void handleSendQrExit(false)
3404
- }} /> }
3444
+ ? {
3445
+ node: (
3446
+ <Hosted
3447
+ render={renderPayer.showCode}
3448
+ value={{
3449
+ code: size => <PaymentQrDisplay frameQr={paymentQr} size={size} onError={onPaymentQrError} />,
3450
+ animated: paymentQrBlocks > 1,
3451
+ amount: payAmount,
3452
+ asset: scannedAssetUnits,
3453
+ recipient: payerRecipient,
3454
+ presence,
3455
+ notice: notice ?? undefined,
3456
+ done: () => void completeQrDelivery(),
3457
+ back: () => void handleSendQrExit(false)
3458
+ }}
3459
+ />
3460
+ )
3461
+ }
3405
3462
  : phase === 'done' && renderPayer.done
3406
- ? { node: <Hosted render={renderPayer.done} value={{
3407
- amount: settledAmount,
3408
- amountText: settledTokenText ?? undefined,
3409
- statusNote: settledStatusNote ?? undefined,
3410
- recipientName:
3411
- peerName ?? (scannedSession ? abbreviateKey(scannedSession.identityKey) : undefined),
3412
- dismiss: () => {
3413
- goBack()
3414
- router.dismissTo(dismissTo)
3415
- }
3416
- }} /> }
3463
+ ? {
3464
+ node: (
3465
+ <Hosted
3466
+ render={renderPayer.done}
3467
+ value={{
3468
+ amount: settledAmount,
3469
+ amountText: settledTokenText ?? undefined,
3470
+ statusNote: settledStatusNote ?? undefined,
3471
+ recipientName:
3472
+ peerName ?? (scannedSession ? abbreviateKey(scannedSession.identityKey) : undefined),
3473
+ dismiss: () => {
3474
+ goBack()
3475
+ router.dismissTo(dismissTo)
3476
+ }
3477
+ }}
3478
+ />
3479
+ )
3480
+ }
3417
3481
  : null
3418
3482
 
3419
3483
  return (
3420
3484
  <View
3421
3485
  style={
3422
- hosted ? styles.container : embedded ? undefined : [styles.container, { backgroundColor: colors.backgroundSecondary }]
3486
+ hosted
3487
+ ? styles.container
3488
+ : embedded
3489
+ ? undefined
3490
+ : [styles.container, { backgroundColor: colors.backgroundSecondary }]
3423
3491
  }
3424
3492
  >
3425
3493
  {hosted ? (