@bsv/expo-wallet-toolbox 0.4.0 → 0.5.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 (118) hide show
  1. package/CHANGELOG.md +292 -0
  2. package/README.md +0 -1
  3. package/assets/sounds/vault-deposit.wav +0 -0
  4. package/assets/sounds/vault-withdraw.wav +0 -0
  5. package/core/config.tsx +9 -1
  6. package/core/context/VaultContext.tsx +8 -11
  7. package/core/context/WalletConnectionContext.tsx +137 -52
  8. package/core/context/WalletContext.tsx +409 -20
  9. package/core/hooks/useConfirmationSound.ts +14 -8
  10. package/core/i18n/translations.tsx +3368 -952
  11. package/core/index.ts +97 -14
  12. package/core/localpay/build.ts +674 -37
  13. package/core/localpay/codec.ts +68 -5
  14. package/core/localpay/pending.ts +240 -22
  15. package/core/localpay/settlementAck.ts +149 -0
  16. package/core/localpay/types.ts +14 -1
  17. package/core/localpay/verify.ts +118 -69
  18. package/core/mandala/abortGuard.ts +134 -0
  19. package/core/mandala/basketMigration.ts +166 -0
  20. package/core/mandala/bundle.ts +244 -0
  21. package/core/mandala/createRuntime.ts +2437 -0
  22. package/core/mandala/drain.ts +670 -0
  23. package/core/mandala/permissionModule.ts +642 -0
  24. package/core/mandala/resendTransfer.ts +175 -0
  25. package/core/mandala/runtime.ts +357 -0
  26. package/core/mandala/settlementStore.ts +412 -0
  27. package/core/mandala/types.ts +290 -0
  28. package/core/offline/cancelParked.ts +94 -1
  29. package/core/offline/payerHold.ts +152 -12
  30. package/core/offline/tokenFrames.ts +197 -0
  31. package/core/parsePeerPayURI.ts +70 -17
  32. package/core/pay/rails/address.ts +51 -3
  33. package/core/pay/rails/handle.ts +88 -9
  34. package/core/pay/rails/index.ts +16 -6
  35. package/core/pay/rails/nearby.ts +114 -4
  36. package/core/services/capWalletArgs.ts +8 -9
  37. package/core/services/externalOrigin.ts +39 -0
  38. package/core/services/vault/VaultKeyService.ts +912 -251
  39. package/core/services/vault/ceremony.ts +435 -367
  40. package/core/services/vault/ceremonyHost.ts +27 -21
  41. package/core/services/vault/devMock.ts +30 -7
  42. package/core/services/vault/driver.ts +95 -41
  43. package/core/services/vault/guard.ts +514 -56
  44. package/core/services/vault/hardwareLease.ts +22 -0
  45. package/core/services/vault/mockYubiKey.ts +258 -90
  46. package/core/services/vault/pivReset.ts +145 -0
  47. package/core/services/vault/r1comb.ts +976 -0
  48. package/core/services/vault/session.ts +93 -26
  49. package/core/services/vault/transfers.ts +2617 -747
  50. package/core/services/vault/types.ts +100 -43
  51. package/core/services/vault/vaultStore.ts +991 -74
  52. package/core/services/walletConnectionValidation.ts +293 -0
  53. package/core/storage/StorageExpoSQLite.ts +382 -56
  54. package/core/storage/dbImage.ts +48 -0
  55. package/core/storage/methods/findSql.ts +0 -54
  56. package/core/storage/methods/listOutputsSql.ts +7 -3
  57. package/core/storage/methods/offlineActions.ts +15 -0
  58. package/core/storage/methods/processOfflineActions.ts +263 -6
  59. package/core/storage/methods/walletBalanceSql.ts +16 -4
  60. package/core/storage/schema/createTables.ts +123 -0
  61. package/core/storage/sqlUpdateValue.ts +24 -0
  62. package/core/toolboxConfig.ts +112 -1
  63. package/core/walletRepair/runWalletCheck.ts +19 -2
  64. package/package.json +25 -24
  65. package/ui/components/QRScanner.tsx +1 -1
  66. package/ui/components/pay/AdmissionNotice.tsx +99 -0
  67. package/ui/components/pay/AssetPicker.tsx +184 -0
  68. package/ui/components/pay/AvailableBalance.tsx +33 -2
  69. package/ui/components/pay/HandleReceive.tsx +213 -50
  70. package/ui/components/pay/NearbyFlow.tsx +616 -69
  71. package/ui/components/pay/PayForm.tsx +73 -8
  72. package/ui/components/pay/PaymentSuccessOverlay.tsx +43 -2
  73. package/ui/components/pay/RecipientField.tsx +49 -4
  74. package/ui/components/pay/RequestHub.tsx +68 -8
  75. package/ui/components/pay/ResultBanner.tsx +41 -4
  76. package/ui/components/pay/UniversalSend.tsx +534 -30
  77. package/ui/components/pay/tokenSendCopy.ts +116 -0
  78. package/ui/components/pay/useRecipientInput.ts +36 -7
  79. package/ui/components/ui/PermissionSheet.tsx +65 -4
  80. package/ui/components/ui/Sheet.tsx +9 -2
  81. package/ui/components/vault/EnrollWizard.tsx +1432 -488
  82. package/ui/components/vault/KeyChooser.tsx +96 -0
  83. package/ui/components/vault/VaultCeremonySheet.tsx +107 -43
  84. package/ui/components/vault/vaultErrorCopy.ts +145 -0
  85. package/ui/components/wallet/ActivityRow.tsx +101 -17
  86. package/ui/components/wallet/AmountInput.tsx +77 -25
  87. package/ui/components/wallet/AssetAmount.tsx +95 -0
  88. package/ui/components/wallet/AssetSwitcherDropdown.tsx +261 -0
  89. package/ui/components/wallet/tokenEviction.ts +65 -0
  90. package/ui/hooks/useExportWalletData.ts +39 -0
  91. package/ui/hooks/useMandala.ts +303 -0
  92. package/ui/hooks/useVaultBalance.ts +105 -7
  93. package/ui/hooks/useVaultCoverage.ts +52 -0
  94. package/ui/importDatabases.ts +7 -3
  95. package/ui/index.ts +50 -7
  96. package/ui/screens/ConnectionsScreen.tsx +46 -29
  97. package/ui/screens/PairScreen.tsx +12 -12
  98. package/ui/screens/PayScreen.tsx +130 -10
  99. package/ui/screens/SettingsScreen.tsx +18 -9
  100. package/ui/screens/VaultScreen.tsx +925 -171
  101. package/ui/screens/VaultTransferScreen.tsx +376 -123
  102. package/ui/screens/WalletCheckScreen.tsx +10 -1
  103. package/ui/screens/WalletConfigScreen.tsx +38 -16
  104. package/ui/screens/WalletHomeScreen.tsx +417 -86
  105. package/ui/screens/homeBadges.ts +9 -1
  106. package/ui/screens/tokenRowTitle.ts +68 -0
  107. package/ui/tokenFormat.ts +108 -0
  108. package/ui/tokenSeen.ts +75 -0
  109. package/ui/tokenStatus.ts +79 -0
  110. package/assets/sounds/vault-close.wav +0 -0
  111. package/assets/sounds/vault-open.wav +0 -0
  112. package/core/services/vault/k1.ts +0 -75
  113. package/core/services/vault/sealing.ts +0 -84
  114. package/core/services/vault/vaultDerivation.ts +0 -152
  115. package/core/services/vault/vaultPassphrase.ts +0 -287
  116. package/ui/components/vault/PassphraseField.tsx +0 -306
  117. package/ui/components/vault/PhraseBackupSheet.tsx +0 -227
  118. package/ui/screens/VaultRecoverScreen.tsx +0 -226
@@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next'
17
17
 
18
18
  import AvailableBalance from './AvailableBalance'
19
19
  import { useTheme, radii, spacing, typography } from '@bsv/expo-wallet-toolbox'
20
- import { AmountInput } from '../wallet/AmountInput'
20
+ import { AmountInput, type AmountInputAsset } from '../wallet/AmountInput'
21
21
  import PressableScale from '../ui/PressableScale'
22
22
 
23
23
  /**
@@ -59,31 +59,85 @@ export function PayAmountField({
59
59
  value,
60
60
  onChangeText,
61
61
  showMax = true,
62
- showBalance = true
62
+ showBalance = true,
63
+ asset,
64
+ maxValue,
65
+ availableText,
66
+ availableNote
63
67
  }: {
64
68
  value: string
65
69
  onChangeText: (text: string) => void
66
70
  showMax?: boolean
67
71
  showBalance?: boolean
72
+ /** Token mode: the field takes and emits base units of this asset. */
73
+ asset?: AmountInputAsset
74
+ /** Token mode: what Max writes (the real spendable figure, not a sentinel). */
75
+ maxValue?: string
76
+ /**
77
+ * Token mode: the available figure, already formatted. `AvailableBalance`
78
+ * sources its own BSV figure and takes no balance prop, so this is the only
79
+ * way a token figure can appear under the field.
80
+ */
81
+ availableText?: string
82
+ /** A second line under the available figure — today, the frozen subtotal. */
83
+ availableNote?: string
68
84
  }) {
69
85
  return (
70
86
  <PayField labelKey="amount">
71
- <AmountInput value={value} onChangeText={onChangeText} showMax={showMax} />
72
- {showBalance && <AvailableBalance />}
87
+ <AmountInput value={value} onChangeText={onChangeText} showMax={showMax} asset={asset} maxValue={maxValue} />
88
+ {showBalance && <AvailableBalance text={availableText} note={availableNote} />}
73
89
  </PayField>
74
90
  )
75
91
  }
76
92
 
77
93
  /** The consequence, before the button — not after. Boxed so it reads as fact,
78
94
  * not fine print. */
79
- export function ConsequenceNote({ textKey }: { textKey: string }) {
95
+ export function ConsequenceNote({
96
+ textKey,
97
+ values,
98
+ text,
99
+ action
100
+ }: {
101
+ textKey: string
102
+ /**
103
+ * An already-resolved sentence that wins over the key — for a reason that
104
+ * comes from somewhere other than this app's own string table (today: the
105
+ * Mandala runtime's plain refusals).
106
+ */
107
+ text?: string
108
+ /**
109
+ * Interpolation values. Every token note carries `{{ticker}}` or
110
+ * `{{issuer}}`, and `t(key)` with no options renders the placeholders raw.
111
+ */
112
+ values?: Record<string, string | number>
113
+ /**
114
+ * The one inline affordance a note may carry — "Get BSV", "Check again".
115
+ * Its hit area is padded to the 44pt minimum because the note's own text is
116
+ * a footnote and a footnote-sized target is not a target.
117
+ */
118
+ action?: { label: string; onPress: () => void }
119
+ }) {
80
120
  const { t } = useTranslation()
81
121
  const { colors } = useTheme()
82
122
  const Ionicons = loadIonicons()
83
123
  return (
84
124
  <View style={[styles.consequence, { backgroundColor: colors.fillTertiary, borderColor: colors.separator }]}>
85
125
  <Ionicons name="information-circle-outline" size={16} color={colors.textSecondary} />
86
- <Text style={[styles.consequenceText, { color: colors.textSecondary }]}>{t(textKey)}</Text>
126
+ <Text style={[styles.consequenceText, { color: colors.textSecondary }]}>{text ?? t(textKey, values)}</Text>
127
+ {action && (
128
+ <PressableScale
129
+ onPress={action.onPress}
130
+ haptic="tap"
131
+ hitSlop={{ top: 14, bottom: 14, left: 12, right: 12 }}
132
+ style={styles.consequenceAction}
133
+ accessibilityRole="button"
134
+ accessibilityLabel={action.label}
135
+ >
136
+ <Text style={[styles.consequenceActionText, { color: colors.accent }]} numberOfLines={1}>
137
+ {action.label}
138
+ </Text>
139
+ </PressableScale>
140
+ )}
87
141
  </View>
88
142
  )
89
143
  }
@@ -94,18 +148,27 @@ export function PayCta({
94
148
  disabled,
95
149
  busy,
96
150
  labelKey = 'pay',
151
+ label,
97
152
  icon = 'arrow-up'
98
153
  }: {
99
154
  onPress: () => void
100
155
  disabled: boolean
101
156
  busy: boolean
102
157
  labelKey?: string
158
+ /**
159
+ * A raw, already-interpolated label, which wins over `labelKey`. The token
160
+ * CTA names the exact figure and asset ("Send 25.00 USDX") and is the
161
+ * confirmation this flow has instead of a review screen — and `t(labelKey)`
162
+ * takes no options, so it could never produce that sentence from a key.
163
+ */
164
+ label?: string
103
165
  icon?: keyof IoniconsComponent['glyphMap']
104
166
  }) {
105
167
  const { t } = useTranslation()
106
168
  const { colors } = useTheme()
107
169
  const Ionicons = loadIonicons()
108
170
  const enabled = !disabled
171
+ const text = label ?? t(labelKey)
109
172
  return (
110
173
  <PressableScale
111
174
  onPress={onPress}
@@ -113,7 +176,7 @@ export function PayCta({
113
176
  haptic="confirm"
114
177
  style={[styles.cta, { backgroundColor: enabled ? colors.accent : colors.fill }]}
115
178
  accessibilityRole="button"
116
- accessibilityLabel={t(labelKey)}
179
+ accessibilityLabel={text}
117
180
  accessibilityState={{ disabled }}
118
181
  >
119
182
  {busy ? (
@@ -122,7 +185,7 @@ export function PayCta({
122
185
  <>
123
186
  <Ionicons name={icon} size={20} color={enabled ? colors.textOnAccent : colors.textTertiary} />
124
187
  <Text style={[styles.ctaText, { color: enabled ? colors.textOnAccent : colors.textTertiary }]}>
125
- {t(labelKey)}
188
+ {text}
126
189
  </Text>
127
190
  </>
128
191
  )}
@@ -187,6 +250,8 @@ const styles = StyleSheet.create({
187
250
  marginBottom: spacing.lg
188
251
  },
189
252
  consequenceText: { ...typography.footnote, flex: 1 },
253
+ consequenceAction: { paddingVertical: spacing.xs, paddingHorizontal: spacing.xs },
254
+ consequenceActionText: { ...typography.footnote, fontWeight: '600' },
190
255
  cta: {
191
256
  flexDirection: 'row',
192
257
  alignItems: 'center',
@@ -71,6 +71,24 @@ export interface ReceivedOverlayProps {
71
71
  direction?: 'received' | 'sent'
72
72
  /** Sent only: the resolved counterparty (name, handle, or abbreviated address). */
73
73
  recipientName?: string
74
+ /**
75
+ * Token mode: the figure in the asset's own units, already formatted
76
+ * ("25.00 USDX"). It replaces the satoshi figure entirely — `AmountDisplay`
77
+ * would read `settings.currency` and print a token amount as satoshis or,
78
+ * worse, cross it into fiat at the BSV rate.
79
+ */
80
+ amountText?: string
81
+ /**
82
+ * One already-interpolated line about what has and has not happened yet:
83
+ * "Settling with Acme Bank", "not yet confirmed by Acme Bank", "we couldn't
84
+ * tell them yet". Never a claim of settlement the wallet does not have.
85
+ */
86
+ statusNote?: string
87
+ /**
88
+ * First time this wallet has ever held this asset: who issues it and what
89
+ * they can do. Disclosure at the one moment the user is definitely looking.
90
+ */
91
+ firstHoldNote?: string
74
92
  /**
75
93
  * Where acknowledging the overlay sends the user. Defaults to `/`, the
76
94
  * wallet's own home route. A host that embeds the wallet as a sub-screen
@@ -91,6 +109,9 @@ export default function PaymentSuccessOverlay({
91
109
  broadcast = true,
92
110
  direction = 'received',
93
111
  recipientName,
112
+ amountText,
113
+ statusNote,
114
+ firstHoldNote,
94
115
  dismissTo = '/',
95
116
  onDismiss
96
117
  }: ReceivedOverlayProps) {
@@ -178,7 +199,7 @@ export default function PaymentSuccessOverlay({
178
199
  adjustsFontSizeToFit
179
200
  accessibilityRole="text"
180
201
  >
181
- <AmountDisplay>{amount}</AmountDisplay>
202
+ {amountText ?? <AmountDisplay>{amount}</AmountDisplay>}
182
203
  </Text>
183
204
  </Animated.View>
184
205
 
@@ -194,8 +215,24 @@ export default function PaymentSuccessOverlay({
194
215
  </Text>
195
216
  )}
196
217
 
218
+ {/* `pay_received_not_broadcast` is the RECEIVED-side sentence and was
219
+ rendered ungated by direction; a sent payment gets its own, because
220
+ "Received offline" over an outgoing payment is simply wrong. */}
197
221
  {!broadcast && (
198
- <Text style={[styles.pending, { color: colors.textSecondary }]}>{t('pay_received_not_broadcast')}</Text>
222
+ <Text style={[styles.pending, { color: colors.textSecondary }]}>
223
+ {t(sent ? 'pay_sent_not_broadcast' : 'pay_received_not_broadcast')}
224
+ </Text>
225
+ )}
226
+
227
+ {!!statusNote && <Text style={[styles.pending, { color: colors.textSecondary }]}>{statusNote}</Text>}
228
+
229
+ {!!firstHoldNote && (
230
+ <Text
231
+ style={[styles.pending, styles.firstHold, { color: colors.textSecondary }]}
232
+ textBreakStrategy="balanced"
233
+ >
234
+ {firstHoldNote}
235
+ </Text>
199
236
  )}
200
237
  </View>
201
238
 
@@ -257,6 +294,10 @@ const styles = StyleSheet.create({
257
294
  textAlign: 'center',
258
295
  marginTop: spacing.xs
259
296
  },
297
+ firstHold: {
298
+ marginTop: spacing.lg,
299
+ maxWidth: 300
300
+ },
260
301
  footer: {
261
302
  paddingBottom: spacing.md
262
303
  },
@@ -43,6 +43,24 @@ interface RecipientFieldProps {
43
43
  readonly onSelectIdentity: (i: DisplayableIdentity) => void
44
44
  readonly onClear: () => void
45
45
  readonly onOpenScanner: () => void
46
+ /**
47
+ * Token mode. When an asset is selected, an address is not a recipient this
48
+ * payment can have: the output locks to an ECDH product of the recipient's
49
+ * identity key, so there is nothing an address could be turned into (D4).
50
+ *
51
+ * The refusal is INLINE and NON-DESTRUCTIVE — the typed text stays exactly
52
+ * where it is, in a warning tone with a plain reason, and switching the
53
+ * picker back to BSV makes it valid again with no retyping. Deleting the
54
+ * user's input to enforce a rule they have not been told about yet would be
55
+ * the wallet punishing them for a choice it made.
56
+ */
57
+ readonly assetTicker?: string
58
+ /**
59
+ * A status line the caller owns, for facts this component cannot know —
60
+ * today the recipient's standing with the issuer (blocked, unregistered).
61
+ * Rendered in place of the resolved-target line.
62
+ */
63
+ readonly statusOverride?: { readonly text: string; readonly tone: 'warning' | 'error' }
46
64
  }
47
65
 
48
66
  export default function RecipientField({
@@ -57,10 +75,14 @@ export default function RecipientField({
57
75
  onChangeText,
58
76
  onSelectIdentity,
59
77
  onClear,
60
- onOpenScanner
78
+ onOpenScanner,
79
+ assetTicker,
80
+ statusOverride
61
81
  }: RecipientFieldProps) {
62
82
  const Ionicons = loadIonicons()
63
83
  const reducedMotion = useReducedMotion()
84
+ /** An address typed while a token is selected: refused, but not erased. */
85
+ const addressRefused = !!assetTicker && (target?.kind === 'address' || inlineError === 'invalid_bsv_address')
64
86
  if (selectedIdentity) {
65
87
  const identityEntering = reducedMotion
66
88
  ? undefined
@@ -92,8 +114,17 @@ export default function RecipientField({
92
114
  )
93
115
  }
94
116
  const showDropdown = (isSearching || searchResults.length > 0) && !target && !inlineError
95
- const borderColor = inlineError ? colors.error : target ? colors.success : colors.separator
96
- const borderWidth = inlineError || target ? 1 : StyleSheet.hairlineWidth
117
+ const overrideColor = statusOverride?.tone === 'error' ? colors.error : colors.warning
118
+ const borderColor = addressRefused
119
+ ? colors.warning
120
+ : statusOverride
121
+ ? overrideColor
122
+ : inlineError
123
+ ? colors.error
124
+ : target
125
+ ? colors.success
126
+ : colors.separator
127
+ const borderWidth = addressRefused || statusOverride || inlineError || target ? 1 : StyleSheet.hairlineWidth
97
128
  return (
98
129
  <>
99
130
  <View style={[styles.inputRow, { backgroundColor: colors.backgroundSecondary, borderColor, borderWidth }]}>
@@ -110,7 +141,21 @@ export default function RecipientField({
110
141
  <Ionicons name="qr-code-outline" size={20} color={colors.accent} />
111
142
  </TouchableOpacity>
112
143
  </View>
113
- {inlineError ? (
144
+ {addressRefused ? (
145
+ // A sentence, not just a colour: no state in this app is communicated
146
+ // by colour alone.
147
+ <View style={styles.statusRow}>
148
+ <Ionicons name="alert-circle-outline" size={14} color={colors.warning} />
149
+ <Text style={[styles.statusText, { color: colors.warning }]}>
150
+ {t('pay_asset_address_status', { ticker: assetTicker })}
151
+ </Text>
152
+ </View>
153
+ ) : statusOverride ? (
154
+ <View style={styles.statusRow}>
155
+ <Ionicons name="alert-circle-outline" size={14} color={overrideColor} />
156
+ <Text style={[styles.statusText, { color: overrideColor }]}>{statusOverride.text}</Text>
157
+ </View>
158
+ ) : inlineError ? (
114
159
  <View style={styles.statusRow}>
115
160
  <Ionicons name="close-circle-outline" size={14} color={colors.error} />
116
161
  <Text style={[styles.statusText, { color: colors.error }]}>{t(inlineError)}</Text>
@@ -12,17 +12,36 @@ import { ScrollView, StyleSheet, View } from 'react-native'
12
12
  import { useTranslation } from 'react-i18next'
13
13
 
14
14
  import PayCellRow from './PayCellRow'
15
- import { PayAmountField, PayField } from './PayForm'
15
+ import { ConsequenceNote, PayAmountField, PayField } from './PayForm'
16
16
  import { spacing } from '@bsv/expo-wallet-toolbox'
17
+ import type { TokenAssetStatus, TokenBalance } from '../../../core/mandala/runtime'
17
18
 
18
19
  export type RequestMethod = 'get-nearby' | 'get-handle' | 'get-address'
19
20
 
20
21
  export interface RequestHubProps {
21
- /** Raw satoshi string from the amount field. '' is an open request. */
22
+ /**
23
+ * Raw figure from the amount field. '' is an open request. Satoshis when no
24
+ * asset is selected, base units of that asset when one is — which is exactly
25
+ * why the screen above must not hand this to a satoshi-shaped prop.
26
+ */
22
27
  requestSats: string
23
28
  onChangeRequestSats: (v: string) => void
24
29
  onPick: (method: RequestMethod) => void
25
30
  online: boolean
31
+ /** Held assets; empty means no picker and today's screen. */
32
+ balances?: TokenBalance[]
33
+ /** `null` is BSV. Chosen upstream (Home's coin switcher, or a deep link). */
34
+ selectedAssetId?: string | null
35
+ /** Kept for callers that still pass it; the hub no longer offers a picker. */
36
+ onSelectAsset?: (assetId: string | null) => void
37
+ /**
38
+ * Regulatory/registry facts for `selectedAssetId`, from the caller's own
39
+ * `useAssetStatus` — this component stays a plain prop-driven view (like
40
+ * `balances` above) rather than reaching for the runtime itself. `null`
41
+ * (unknown/no asset) shows no note; advisory only, since a paused issuer
42
+ * can still resume before the payer ever acts on this request.
43
+ */
44
+ assetStatus?: TokenAssetStatus | null
26
45
  }
27
46
 
28
47
  /** Satoshis from the hub's raw field, or undefined for an open request. */
@@ -31,13 +50,42 @@ export function requestSatsFrom(text: string): number | undefined {
31
50
  return Number.isFinite(n) && n > 0 ? n : undefined
32
51
  }
33
52
 
34
- export default function RequestHub({ requestSats, onChangeRequestSats, onPick, online }: RequestHubProps) {
53
+ export default function RequestHub({
54
+ requestSats,
55
+ onChangeRequestSats,
56
+ onPick,
57
+ online,
58
+ balances = [],
59
+ selectedAssetId = null,
60
+ assetStatus = null
61
+ }: RequestHubProps) {
35
62
  const { t } = useTranslation()
63
+ const holding = balances.find(b => b.asset.assetId === selectedAssetId) ?? null
64
+ const asset = holding?.asset ?? null
36
65
  return (
37
66
  <ScrollView contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled">
67
+ {/* No "Getting paid in" picker here (design 1b, 2026-09-15): the coin
68
+ was chosen on Home's switcher and arrives as `selectedAssetId`; the
69
+ amount field's unit is what says which money is being asked for. */}
70
+
38
71
  {/* No max button and no balance line: this asks the PAYER for money, so
39
72
  the requester's own balance is meaningless here. */}
40
- <PayAmountField value={requestSats} onChangeText={onChangeRequestSats} showMax={false} showBalance={false} />
73
+ <PayAmountField
74
+ value={requestSats}
75
+ onChangeText={onChangeRequestSats}
76
+ showMax={false}
77
+ showBalance={false}
78
+ asset={asset ? { ticker: asset.ticker, decimals: asset.decimals } : undefined}
79
+ />
80
+
81
+ {/* Advisory only: a paused issuer can resume before the payer ever acts
82
+ on this request, so this never blocks picking a method. */}
83
+ {asset && assetStatus?.paused && (
84
+ <ConsequenceNote
85
+ textKey="pay_asset_request_paused"
86
+ values={{ issuer: asset.issuerName || t('token_issuer_fallback'), ticker: asset.ticker }}
87
+ />
88
+ )}
41
89
 
42
90
  <PayField labelKey="pay_method">
43
91
  <View style={styles.rows}>
@@ -48,19 +96,31 @@ export default function RequestHub({ requestSats, onChangeRequestSats, onPick, o
48
96
  onPress={() => onPick('get-nearby')}
49
97
  />
50
98
  {/* Remote and address both need the network: a message-box round-trip
51
- and an overlay lookup respectively. Nearby is the offline rail. */}
99
+ and an overlay lookup respectively. Nearby is the offline rail.
100
+ With an asset selected the link names it and carries the figure
101
+ in its base units (`asset=`/`amount=`), so the row reads the same
102
+ in either money. */}
52
103
  <PayCellRow
53
104
  title={t('pay_method_remote_link')}
54
- subtitle={online ? t('pay_cell_handle_get_sub') : t('pay_offline_needs_internet')}
105
+ subtitle={!online ? t('pay_offline_needs_internet') : t('pay_cell_handle_get_sub')}
55
106
  icon="share-outline"
56
107
  disabled={!online}
57
108
  onPress={() => onPick('get-handle')}
58
109
  />
110
+ {/* D4: disabled with a plain reason, never removed. Deleting one of
111
+ three rows the user has learned would be a silent answer to a
112
+ question they are entitled to have answered. */}
59
113
  <PayCellRow
60
114
  title={t('pay_method_address')}
61
- subtitle={online ? t('pay_cell_address_get_sub') : t('pay_offline_needs_internet')}
115
+ subtitle={
116
+ asset
117
+ ? t('pay_asset_address_status', { ticker: asset.ticker })
118
+ : online
119
+ ? t('pay_cell_address_get_sub')
120
+ : t('pay_offline_needs_internet')
121
+ }
62
122
  icon="wallet-outline"
63
- disabled={!online}
123
+ disabled={!online || !!asset}
64
124
  onPress={() => onPick('get-address')}
65
125
  />
66
126
  </View>
@@ -29,16 +29,42 @@ interface ResultBannerProps {
29
29
  readonly result: { type: 'success' | 'error'; message: string }
30
30
  readonly onDismiss: () => void
31
31
  readonly colors: ReturnType<typeof import('@bsv/expo-wallet-toolbox').useTheme>['colors']
32
+ /**
33
+ * The one thing a failed money message may offer to DO — "Check again" after
34
+ * an overlay this wallet could not reach, "Get BSV" after a funding refusal.
35
+ *
36
+ * Deliberately not a retry. When a submit fails without a verdict, the
37
+ * transaction may have been admitted and the response lost; a retry would
38
+ * build a second spend of the same coins and be refused for conservation
39
+ * forever. So the action offered is always one that reads state, never one
40
+ * that moves money.
41
+ */
42
+ readonly action?: { readonly label: string; readonly onPress: () => void }
32
43
  }
33
44
 
34
- export default function ResultBanner({ result, onDismiss, colors }: ResultBannerProps) {
45
+ export default function ResultBanner({ result, onDismiss, colors, action }: ResultBannerProps) {
35
46
  const Ionicons = loadIonicons()
36
47
  const isSuccess = result.type === 'success'
37
48
  const color = isSuccess ? colors.success : colors.error
38
49
  return (
39
50
  <View style={[styles.resultBanner, { backgroundColor: color + '15', borderColor: color }]}>
40
51
  <Ionicons name={isSuccess ? 'checkmark-circle' : 'alert-circle'} size={20} color={color} />
41
- <Text style={[styles.resultText, { color }]}>{result.message}</Text>
52
+ <View style={styles.resultBody}>
53
+ <Text style={[styles.resultText, { color }]}>{result.message}</Text>
54
+ {action && (
55
+ <TouchableOpacity
56
+ onPress={action.onPress}
57
+ // A footnote-sized target is not a target: padded to the 44pt
58
+ // minimum in the direction it can grow.
59
+ hitSlop={{ top: 12, bottom: 12, left: 12, right: 12 }}
60
+ style={styles.resultAction}
61
+ accessibilityRole="button"
62
+ accessibilityLabel={action.label}
63
+ >
64
+ <Text style={[styles.resultActionText, { color }]}>{action.label}</Text>
65
+ </TouchableOpacity>
66
+ )}
67
+ </View>
42
68
  <TouchableOpacity onPress={onDismiss} style={styles.resultDismiss}>
43
69
  <Ionicons name="close" size={18} color={color} />
44
70
  </TouchableOpacity>
@@ -58,10 +84,21 @@ const styles = StyleSheet.create({
58
84
  marginTop: spacing.lg,
59
85
  marginBottom: spacing.lg
60
86
  },
87
+ resultBody: {
88
+ flex: 1,
89
+ gap: spacing.xs
90
+ },
61
91
  resultText: {
62
92
  ...typography.subhead,
63
- fontWeight: '500',
64
- flex: 1
93
+ fontWeight: '500'
94
+ },
95
+ resultAction: {
96
+ alignSelf: 'flex-start',
97
+ paddingVertical: spacing.xs
98
+ },
99
+ resultActionText: {
100
+ ...typography.subhead,
101
+ fontWeight: '700'
65
102
  },
66
103
  resultDismiss: {
67
104
  padding: spacing.xs