@bsv/expo-wallet-toolbox 0.7.0 → 0.9.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.
- package/CHANGELOG.md +1745 -0
- package/README.md +47 -1
- package/core/amountFormatHelpers.ts +20 -2
- package/core/backup/RemoteSyncReader.ts +131 -19
- package/core/backup/appData.ts +157 -0
- package/core/backup/client.ts +15 -1
- package/core/backup/codec.ts +147 -9
- package/core/backup/constants.ts +30 -1
- package/core/backup/cursor.ts +31 -2
- package/core/backup/push.ts +70 -4
- package/core/backup/restore.ts +104 -16
- package/core/backup/restoreOnImport.ts +94 -30
- package/core/backup/status.ts +13 -8
- package/core/constants.ts +14 -1
- package/core/context/ExchangeRateContext.tsx +34 -27
- package/core/context/LocalStorageProvider.tsx +43 -40
- package/core/context/UserContext.tsx +18 -7
- package/core/context/VaultContext.tsx +49 -2
- package/core/context/WalletConnectionContext.tsx +203 -11
- package/core/context/WalletContext.tsx +631 -162
- package/core/headers/OfflineFirstChaintracks.ts +48 -4
- package/core/headers/headerStore.ts +26 -4
- package/core/headers/syncHeaders.ts +12 -1
- package/core/i18n/translations.tsx +953 -25
- package/core/identity/handleRegistry/client.ts +31 -2
- package/core/identity/handleRegistry/keyPinStore.ts +70 -0
- package/core/identity/handleRegistry/resolver.ts +71 -3
- package/core/index.ts +33 -3
- package/core/localpay/build.ts +225 -24
- package/core/localpay/pending.ts +110 -7
- package/core/localpay/pendingAbortAuthority.ts +95 -0
- package/core/localpay/pendingAborts.ts +264 -28
- package/core/localpay/session.ts +42 -17
- package/core/localpay/settlementAck.ts +10 -1
- package/core/localpay/transport/socket.ts +52 -3
- package/core/localpay/verify.ts +100 -10
- package/core/mandala/abortGuard.ts +96 -20
- package/core/mandala/createRuntime.ts +206 -33
- package/core/mandala/drain.ts +89 -11
- package/core/mandala/inboxPrehold.ts +186 -0
- package/core/mandala/permissionModule.ts +202 -20
- package/core/mandala/settlementStore.ts +24 -2
- package/core/mandala/types.ts +40 -5
- package/core/monitor/TaskBackupPush.ts +14 -0
- package/core/monitor/TaskDrainOutbox.ts +14 -0
- package/core/monitor/TaskSendOffline.ts +14 -0
- package/core/net/publicDestination.ts +91 -0
- package/core/net/validateArcUrl.ts +22 -0
- package/core/offline/cancelParked.ts +134 -13
- package/core/offline/payerHold.ts +100 -24
- package/core/offline/plan.ts +36 -7
- package/core/pay/beefRepair.ts +6 -2
- package/core/pay/damagedInbox.ts +24 -0
- package/core/pay/rails/address.ts +107 -12
- package/core/pay/rails/handle.ts +117 -22
- package/core/pay/rails/index.ts +45 -7
- package/core/pay/rails/nativeIntent.ts +61 -0
- package/core/pay/receiveHistory.ts +93 -0
- package/core/pay/recordProof.ts +19 -1
- package/core/pay/refreshProofGuard.ts +42 -1
- package/core/pay/watchlist.ts +5 -2
- package/core/peerpay/control.ts +17 -18
- package/core/peerpay/handleResendRequests.ts +58 -4
- package/core/peerpay/outbox.ts +3 -1
- package/core/recovery/backupMaterial.ts +61 -0
- package/core/recovery/createWallet.ts +95 -0
- package/core/recovery/recoverWallet.ts +120 -0
- package/core/recovery/restoreWallet.ts +170 -0
- package/core/recovery/secret.ts +92 -0
- package/core/recovery/shareCollector.ts +71 -0
- package/core/recovery/shareParsing.ts +87 -0
- package/core/recovery/shares.ts +116 -0
- package/core/recovery/useRecoveryDeps.ts +70 -0
- package/core/services/arcTokenStorage.ts +52 -0
- package/core/services/arcadeBroadcastProvider.ts +232 -48
- package/core/services/autoApprovePolicy.ts +105 -0
- package/core/services/callbackToken.ts +19 -0
- package/core/services/capWalletArgs.ts +14 -2
- package/core/services/connectionAuthority.ts +98 -0
- package/core/services/exchangeRate.ts +35 -12
- package/core/services/externalOrigin.ts +11 -0
- package/core/services/secrets/kek.ts +126 -29
- package/core/services/secrets/migration.ts +16 -4
- package/core/services/secrets/store.ts +42 -14
- package/core/services/vault/VaultKeyService.ts +228 -45
- package/core/services/vault/chainRecovery.ts +483 -0
- package/core/services/vault/driver.ts +9 -1
- package/core/services/vault/enrolledSerialRegistry.ts +150 -0
- package/core/services/vault/guard.ts +218 -32
- package/core/services/vault/hardwareLease.ts +19 -0
- package/core/services/vault/metaAuthority.ts +210 -0
- package/core/services/vault/pivReset.ts +64 -23
- package/core/services/vault/r1comb.ts +139 -3
- package/core/services/vault/session.ts +25 -4
- package/core/services/vault/transfers.ts +866 -170
- package/core/services/vault/types.ts +19 -4
- package/core/services/vault/vaultStore.ts +256 -29
- package/core/services/walletArgLimits.ts +45 -2
- package/core/services/walletConnectionValidation.ts +76 -6
- package/core/services/walletServiceConfig.ts +10 -8
- package/core/storage/StorageExpoSQLite.ts +47 -13
- package/core/storage/methods/findSql.ts +21 -2
- package/core/storage/methods/offlineActions.ts +10 -1
- package/core/storage/methods/processOfflineActions.ts +116 -23
- package/core/storage/schema/createTables.ts +126 -2
- package/core/stores/ConnectionStore.ts +34 -0
- package/core/toolboxConfig.ts +45 -11
- package/core/walletDbRegistry.ts +63 -0
- package/core/walletMonitor.ts +17 -1
- package/core/walletRepair/releaseStuckReservations.ts +72 -0
- package/core/walletRepair/shouldMarkUnspendable.ts +20 -0
- package/core/walletRepair/spenderConsumesOutpoint.ts +29 -0
- package/package.json +2 -2
- package/ui/backupShares.ts +26 -169
- package/ui/components/pay/AddressReceive.tsx +13 -6
- package/ui/components/pay/AssetPicker.tsx +30 -9
- package/ui/components/pay/MessageBoxConfig.tsx +16 -0
- package/ui/components/pay/NearbyFlow.tsx +480 -243
- package/ui/components/pay/PaymentSuccessOverlay.tsx +39 -4
- package/ui/components/pay/UniversalSend.tsx +167 -73
- package/ui/components/ui/AlertCard.tsx +38 -5
- package/ui/components/ui/PermissionSheet.tsx +197 -66
- package/ui/components/vault/EnrollWizard.tsx +61 -13
- package/ui/components/vault/vaultErrorCopy.ts +3 -1
- package/ui/components/wallet/ActivityRow.tsx +5 -3
- package/ui/components/wallet/AmountInput.tsx +8 -2
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +22 -2
- package/ui/components/wallet/Balance.tsx +42 -23
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +16 -3
- package/ui/exportTransactions.ts +36 -4
- package/ui/hooks/useExportWalletData.ts +25 -2
- package/ui/importDatabases.ts +339 -24
- package/ui/index.ts +9 -3
- package/ui/isImageUrl.ts +6 -0
- package/ui/printRecoveryShares.ts +9 -10
- package/ui/recoveryPrompts.ts +91 -0
- package/ui/resolveIdentity.ts +31 -9
- package/ui/screens/ConnectionsScreen.tsx +86 -19
- package/ui/screens/IdentifierScreen.tsx +30 -8
- package/ui/screens/PairScreen.tsx +74 -2
- package/ui/screens/SettingsScreen.tsx +10 -4
- package/ui/screens/TrustScreen.tsx +99 -4
- package/ui/screens/VaultScreen.tsx +410 -61
- package/ui/screens/VaultTransferScreen.tsx +59 -7
- package/ui/screens/WalletCheckScreen.tsx +17 -6
- package/ui/screens/WalletConfigScreen.tsx +82 -28
- package/ui/screens/WalletHomeScreen.tsx +179 -88
- package/ui/screens/detailActionKeys.ts +55 -0
- package/ui/tokenFormat.ts +44 -4
- package/ui/txStatus.ts +5 -0
- package/core/storage/LocalStorageAdapter.ts +0 -58
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* key can sign.
|
|
21
21
|
*/
|
|
22
22
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
23
|
-
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, ActivityIndicator, TextInput } from 'react-native'
|
|
23
|
+
import { View, Text, StyleSheet, ScrollView, TouchableOpacity, ActivityIndicator, TextInput, AppState } from 'react-native'
|
|
24
24
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
25
25
|
import { GroupedSection } from '../components/ui/GroupedList'
|
|
26
26
|
import { ListRow } from '../components/ui/ListRow'
|
|
@@ -46,12 +46,18 @@ import {
|
|
|
46
46
|
useLocalStorage,
|
|
47
47
|
relockVault,
|
|
48
48
|
recoverVaultMetaFromOutputs,
|
|
49
|
+
requireAuthenticatedMeta,
|
|
50
|
+
computeVaultMetaAuthorityTag,
|
|
51
|
+
recoverVaultFromChain,
|
|
52
|
+
wocChainLookup,
|
|
53
|
+
resolveHeldVaultDeposit,
|
|
49
54
|
adoptVaultKey,
|
|
50
55
|
beginVaultKeyRemoval,
|
|
51
56
|
finalizeVaultKeyRemoval,
|
|
52
57
|
estimateRelockFee,
|
|
53
58
|
R1C_LOCK_LEN,
|
|
54
59
|
type VaultWallet,
|
|
60
|
+
type HmacCapableWallet,
|
|
55
61
|
type VaultSpendResult,
|
|
56
62
|
vaultStore,
|
|
57
63
|
type VaultMeta,
|
|
@@ -60,6 +66,7 @@ import {
|
|
|
60
66
|
type AdoptPhase,
|
|
61
67
|
VAULT_MIN_KEYS,
|
|
62
68
|
VAULT_MAX_KEYS,
|
|
69
|
+
VAULT_MAX_ACTIVE_KEYS,
|
|
63
70
|
getVaultDriver,
|
|
64
71
|
isVaultEnabled,
|
|
65
72
|
isVaultAvailable,
|
|
@@ -70,13 +77,18 @@ import {
|
|
|
70
77
|
getOnline,
|
|
71
78
|
generateMnemonicWallet,
|
|
72
79
|
backupAttestation,
|
|
80
|
+
readBackupAttestation,
|
|
73
81
|
VaultError,
|
|
74
82
|
haptics,
|
|
75
|
-
i18n
|
|
83
|
+
i18n,
|
|
84
|
+
resolveProvisioningPolicy
|
|
76
85
|
} from '@bsv/expo-wallet-toolbox'
|
|
77
86
|
|
|
78
87
|
const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
|
|
79
88
|
|
|
89
|
+
/** How often a removal whose re-lock is not yet accepted is re-checked. */
|
|
90
|
+
const REMOVAL_RECHECK_MS = 30_000
|
|
91
|
+
|
|
80
92
|
/**
|
|
81
93
|
* @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
|
|
82
94
|
* etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
|
|
@@ -152,12 +164,27 @@ export function VaultScreen() {
|
|
|
152
164
|
const [showBiometricAdvisory, setShowBiometricAdvisory] = useState(false)
|
|
153
165
|
const [creatingWallet, setCreatingWallet] = useState(false)
|
|
154
166
|
const [walletCreationIntent, setWalletCreationIntent] = useState<'deposit' | 'enroll'>('deposit')
|
|
167
|
+
// XR-114: whether provisioning would actually land on a disclosed
|
|
168
|
+
// (non-biometric) policy for this device/build, so the advisory below
|
|
169
|
+
// never promises Face ID/fingerprint protection it will not deliver.
|
|
170
|
+
const [advisoryDegraded, setAdvisoryDegraded] = useState(false)
|
|
155
171
|
const [recoveryError, setRecoveryError] = useState<string | null>(null)
|
|
156
172
|
const [adopting, setAdopting] = useState<{ record: VaultKeyRecord; scopeToken: VaultScopeToken } | null>(null)
|
|
157
173
|
const [adoptionPin, setAdoptionPin] = useState('')
|
|
158
174
|
const [adoptionPhase, setAdoptionPhase] = useState<AdoptPhase | null>(null)
|
|
159
175
|
const [adoptionBusy, setAdoptionBusy] = useState(false)
|
|
160
176
|
const [adoptionError, setAdoptionError] = useState<string | null>(null)
|
|
177
|
+
// F-04: a signed but unbroadcast deposit left by a crash refuses every
|
|
178
|
+
// vault-mutating call with 'action-pending' forever until it is
|
|
179
|
+
// reconciled. Once any of that surfaces here, offer the one safe manual
|
|
180
|
+
// resolution (resolveHeldVaultDeposit) instead of leaving the vault stuck.
|
|
181
|
+
const [actionPendingNotice, setActionPendingNotice] = useState(false)
|
|
182
|
+
const [resolvingDeposit, setResolvingDeposit] = useState(false)
|
|
183
|
+
// Chain recovery (v7 marker/descriptor, spec v7 §1.2 item 3): offered only
|
|
184
|
+
// while this wallet has no local vault meta at all. Never needs a YubiKey —
|
|
185
|
+
// only the wallet identity — so it is not gated on `supported`.
|
|
186
|
+
const [restoringFromChain, setRestoringFromChain] = useState(false)
|
|
187
|
+
const [restoreNotice, setRestoreNotice] = useState<string | null>(null)
|
|
161
188
|
|
|
162
189
|
// Release flag AND mainnet (task 11). Read from the reactive `selectedNetwork`
|
|
163
190
|
// so everything this gates collapses on a network switch without a remount —
|
|
@@ -174,20 +201,46 @@ export function VaultScreen() {
|
|
|
174
201
|
const pm = managers?.permissionsManager
|
|
175
202
|
|
|
176
203
|
const reload = useCallback(async (): Promise<VaultMeta | null> => {
|
|
204
|
+
if (!pm) {
|
|
205
|
+
metaRef.current = null
|
|
206
|
+
setMeta(null)
|
|
207
|
+
setRecoveryError(null)
|
|
208
|
+
return null
|
|
209
|
+
}
|
|
210
|
+
// INT-07 / XR-007: recoverVaultMetaFromOutputs used to run only when the
|
|
211
|
+
// local cache was EMPTY. A stale-but-PRESENT local record (an iOS
|
|
212
|
+
// reinstall Keychain survives, or a revision bump made elsewhere for the
|
|
213
|
+
// same enrollment) then skipped this reconciliation forever — every
|
|
214
|
+
// subsequent spend against the newer on-chain revision failed closed
|
|
215
|
+
// with 'template-invalid', with no in-app way to force it (disableVault
|
|
216
|
+
// refuses on any funded vault). recoverVaultMetaFromOutputs already keeps
|
|
217
|
+
// the cached record whenever the authenticated scan does not supersede it
|
|
218
|
+
// (recoveredSupersedesExisting), so calling it unconditionally only
|
|
219
|
+
// widens WHEN that existing ratchet runs, never what it decides.
|
|
220
|
+
let cached: VaultMeta | null = null
|
|
177
221
|
try {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
let m = await vaultStore.getMeta()
|
|
185
|
-
if (!m) m = await recoverVaultMetaFromOutputs(pm as unknown as VaultWallet, adminOriginator)
|
|
222
|
+
cached = await vaultStore.getMeta()
|
|
223
|
+
} catch {
|
|
224
|
+
// Nothing to fall back to either; the scan below still gets a chance.
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
const m = await recoverVaultMetaFromOutputs(pm as unknown as VaultWallet, adminOriginator)
|
|
186
228
|
metaRef.current = m
|
|
187
229
|
setMeta(m)
|
|
188
230
|
setRecoveryError(null)
|
|
189
231
|
return m
|
|
190
232
|
} catch (error) {
|
|
233
|
+
// A scan that cannot complete (offline, a pending action another call
|
|
234
|
+
// site already surfaces its own notice for, etc.) must not regress an
|
|
235
|
+
// already-correct cached record's instant, offline-safe display into a
|
|
236
|
+
// hard recoveryError screen — only a device with NOTHING cached has
|
|
237
|
+
// nothing safe to fall back to.
|
|
238
|
+
if (cached) {
|
|
239
|
+
metaRef.current = cached
|
|
240
|
+
setMeta(cached)
|
|
241
|
+
setRecoveryError(null)
|
|
242
|
+
return cached
|
|
243
|
+
}
|
|
191
244
|
metaRef.current = null
|
|
192
245
|
setRecoveryError(vaultErrorCopy(error instanceof VaultError ? error.code : undefined))
|
|
193
246
|
throw error
|
|
@@ -204,16 +257,127 @@ export function VaultScreen() {
|
|
|
204
257
|
void reload().catch(error => console.error('[vault] recovery scan failed:', error))
|
|
205
258
|
}, [reload])
|
|
206
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Restore vault from the blockchain (spec v7 §1.2 item 3 / item 7):
|
|
262
|
+
* scans for chain-published v7 markers and internalizes every confirmed,
|
|
263
|
+
* unspent, authenticated one — no local DB, SecureStore, or backup needed,
|
|
264
|
+
* and no YubiKey either (that is only needed afterward, to spend). Shown
|
|
265
|
+
* only while this wallet has no local vault meta at all.
|
|
266
|
+
*/
|
|
267
|
+
const onRestoreFromChain = useCallback(async () => {
|
|
268
|
+
if (!pm || restoringFromChain) return
|
|
269
|
+
setRestoringFromChain(true)
|
|
270
|
+
setRestoreNotice(null)
|
|
271
|
+
try {
|
|
272
|
+
const result = await recoverVaultFromChain(
|
|
273
|
+
pm as unknown as VaultWallet,
|
|
274
|
+
adminOriginator,
|
|
275
|
+
wocChainLookup(selectedNetwork),
|
|
276
|
+
selectedNetwork
|
|
277
|
+
)
|
|
278
|
+
if (result.found > 0) {
|
|
279
|
+
haptics.success()
|
|
280
|
+
setRestoreNotice(t('vault_restore_found', { count: result.found }))
|
|
281
|
+
await reload()
|
|
282
|
+
} else if (result.pendingConfirmation > 0) {
|
|
283
|
+
setRestoreNotice(t('vault_restore_pending', { count: result.pendingConfirmation }))
|
|
284
|
+
} else {
|
|
285
|
+
setRestoreNotice(t('vault_restore_none_found'))
|
|
286
|
+
}
|
|
287
|
+
} catch (error) {
|
|
288
|
+
haptics.error()
|
|
289
|
+
setRestoreNotice(vaultErrorCopy(error instanceof VaultError ? error.code : undefined))
|
|
290
|
+
} finally {
|
|
291
|
+
setRestoringFromChain(false)
|
|
292
|
+
}
|
|
293
|
+
}, [pm, restoringFromChain, adminOriginator, selectedNetwork, reload])
|
|
294
|
+
|
|
295
|
+
/** F-04: surface the one recovery action for a signed deposit crash left
|
|
296
|
+
* behind — every other vault call keeps refusing with 'action-pending'
|
|
297
|
+
* until this resolves it, and there was previously no in-app way to. */
|
|
298
|
+
const onResolveHeldDeposit = useCallback(async () => {
|
|
299
|
+
if (!pm || !metaRef.current || resolvingDeposit) return
|
|
300
|
+
setResolvingDeposit(true)
|
|
301
|
+
try {
|
|
302
|
+
const result = await resolveHeldVaultDeposit(pm as unknown as VaultWallet, adminOriginator, metaRef.current)
|
|
303
|
+
if (result.kind === 'failed') {
|
|
304
|
+
console.error('[vault] could not resolve the held deposit:', result.error)
|
|
305
|
+
showToast(vaultErrorCopy('action-pending'), { type: 'error' })
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
if (result.kind === 'nothing-held') {
|
|
309
|
+
// XR-006 / INT-03: 'nothing-held' means no held deposit OR
|
|
310
|
+
// withdraw/relock this function knows how to authenticate was
|
|
311
|
+
// found — it does NOT mean the underlying action-pending block is
|
|
312
|
+
// gone. Reporting success here previously cleared the notice while
|
|
313
|
+
// the freeze remained, silently reappearing on the very next vault
|
|
314
|
+
// operation.
|
|
315
|
+
showToast(t('vault_resolve_held_deposit_none'), { type: 'error' })
|
|
316
|
+
return
|
|
317
|
+
}
|
|
318
|
+
setActionPendingNotice(false)
|
|
319
|
+
haptics.success()
|
|
320
|
+
showToast(t('vault_resolve_held_deposit_done'), { type: 'success' })
|
|
321
|
+
await reload()
|
|
322
|
+
} catch (e) {
|
|
323
|
+
console.error('[vault] could not resolve the held deposit:', e)
|
|
324
|
+
showToast(t('vault_resolve_held_deposit_failed'), { type: 'error' })
|
|
325
|
+
} finally {
|
|
326
|
+
setResolvingDeposit(false)
|
|
327
|
+
}
|
|
328
|
+
}, [pm, adminOriginator, resolvingDeposit, reload, t])
|
|
329
|
+
|
|
330
|
+
// A removal whose re-lock is broadcast finishes once the network accepts
|
|
331
|
+
// that re-lock ('unproven'). Usually that is already true when the re-lock
|
|
332
|
+
// returns; when the toolbox is still retrying ('sending'), nothing else
|
|
333
|
+
// reloads this screen when it lands. Re-check while it waits (and on return
|
|
334
|
+
// to the foreground) so the user is not told to leave and come back. A
|
|
335
|
+
// 'prepared' removal is not polled: it needs a re-lock, which reconciles on
|
|
336
|
+
// its own.
|
|
337
|
+
const removalState = meta?.pendingRemoval?.state
|
|
207
338
|
useEffect(() => {
|
|
208
339
|
if (!pm || !meta?.pendingRemoval) return
|
|
209
340
|
let stale = false
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
341
|
+
let running = false
|
|
342
|
+
const reconcile = () => {
|
|
343
|
+
if (running) return
|
|
344
|
+
running = true
|
|
345
|
+
void finalizeVaultKeyRemoval(pm as unknown as VaultWallet, adminOriginator)
|
|
346
|
+
.then(async complete => {
|
|
347
|
+
if (stale) return
|
|
348
|
+
if (complete) {
|
|
349
|
+
await reload()
|
|
350
|
+
return
|
|
351
|
+
}
|
|
352
|
+
// Reconciliation can itself infer 'broadcast' for a crash-interrupted
|
|
353
|
+
// re-lock; show that without a full rescan.
|
|
354
|
+
const current = await vaultStore.getMeta()
|
|
355
|
+
if (!stale && current?.pendingRemoval?.state !== metaRef.current?.pendingRemoval?.state) {
|
|
356
|
+
metaRef.current = current
|
|
357
|
+
setMeta(current)
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
.catch(error => console.error('[vault] pending key-removal reconciliation failed:', error))
|
|
361
|
+
.finally(() => {
|
|
362
|
+
running = false
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
reconcile()
|
|
366
|
+
if (removalState !== 'broadcast') {
|
|
367
|
+
return () => {
|
|
368
|
+
stale = true
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const timer = setInterval(reconcile, REMOVAL_RECHECK_MS)
|
|
372
|
+
const foreground = AppState.addEventListener('change', next => {
|
|
373
|
+
if (next === 'active') reconcile()
|
|
374
|
+
})
|
|
375
|
+
return () => {
|
|
376
|
+
stale = true
|
|
377
|
+
clearInterval(timer)
|
|
378
|
+
foreground.remove()
|
|
379
|
+
}
|
|
380
|
+
}, [pm, meta?.pendingRemoval, removalState, adminOriginator, reload])
|
|
217
381
|
|
|
218
382
|
// ── helpers ─────────────────────────────────────────────────────────
|
|
219
383
|
/** `nickname · …tail4` for each referenced key; a key no longer in meta shows its pubkey tail. */
|
|
@@ -222,8 +386,9 @@ export function VaultScreen() {
|
|
|
222
386
|
refs
|
|
223
387
|
.map(r => {
|
|
224
388
|
const current = metaRef.current
|
|
225
|
-
const rec = [...(current?.keys ?? []), ...(current?.pendingRemoval ? [current.pendingRemoval.key] : [])]
|
|
226
|
-
|
|
389
|
+
const rec = [...(current?.keys ?? []), ...(current?.pendingRemoval ? [current.pendingRemoval.key] : [])].find(
|
|
390
|
+
k => (r.serial !== undefined && k.serial === r.serial) || k.pubkey === r.pubkey
|
|
391
|
+
)
|
|
227
392
|
return rec ? vaultKeyLabel(rec) : `…${r.pubkey.slice(-4)}`
|
|
228
393
|
})
|
|
229
394
|
.join(', '),
|
|
@@ -302,10 +467,12 @@ export function VaultScreen() {
|
|
|
302
467
|
return
|
|
303
468
|
}
|
|
304
469
|
if (vaultError?.code === 'pin-invalid') setAdoptionPin('')
|
|
305
|
-
setAdoptionError(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
470
|
+
setAdoptionError(
|
|
471
|
+
vaultErrorCopy(vaultError?.code, {
|
|
472
|
+
count: vaultError?.retriesLeft,
|
|
473
|
+
names: metaRef.current?.keys.map(vaultKeyLabel).join(', ') || undefined
|
|
474
|
+
})
|
|
475
|
+
)
|
|
309
476
|
} finally {
|
|
310
477
|
setAdoptionBusy(false)
|
|
311
478
|
}
|
|
@@ -365,7 +532,8 @@ export function VaultScreen() {
|
|
|
365
532
|
throw new VaultError('template-invalid', 'Vault re-lock made no progress')
|
|
366
533
|
}
|
|
367
534
|
previousCapped = result.cappedInputs
|
|
368
|
-
if (result.cappedInputs > 0)
|
|
535
|
+
if (result.cappedInputs > 0)
|
|
536
|
+
showToast(t('vault_relock_capped', { count: result.cappedInputs }), { type: 'info' })
|
|
369
537
|
} while (result.cappedInputs > 0)
|
|
370
538
|
refresh()
|
|
371
539
|
refreshCoverage()
|
|
@@ -408,6 +576,7 @@ export function VaultScreen() {
|
|
|
408
576
|
} catch (e) {
|
|
409
577
|
console.error('[vault] re-lock failed:', e instanceof Error ? e.message : e, e)
|
|
410
578
|
const code = e instanceof VaultError ? e.code : undefined
|
|
579
|
+
if (code === 'action-pending') setActionPendingNotice(true)
|
|
411
580
|
if (code === 'backup-off') {
|
|
412
581
|
await backupOffAlert()
|
|
413
582
|
return
|
|
@@ -421,7 +590,20 @@ export function VaultScreen() {
|
|
|
421
590
|
} finally {
|
|
422
591
|
setRelocking(false)
|
|
423
592
|
}
|
|
424
|
-
}, [
|
|
593
|
+
}, [
|
|
594
|
+
pm,
|
|
595
|
+
relock,
|
|
596
|
+
relockSerial,
|
|
597
|
+
relocking,
|
|
598
|
+
adminOriginator,
|
|
599
|
+
transferOpts,
|
|
600
|
+
closeRelock,
|
|
601
|
+
refresh,
|
|
602
|
+
refreshCoverage,
|
|
603
|
+
namesFor,
|
|
604
|
+
reload,
|
|
605
|
+
backupOffAlert
|
|
606
|
+
])
|
|
425
607
|
|
|
426
608
|
// ── wizard hand-offs ────────────────────────────────────────────────
|
|
427
609
|
/**
|
|
@@ -457,7 +639,9 @@ export function VaultScreen() {
|
|
|
457
639
|
// The new key can open deposits made from now on; a re-lock makes it open
|
|
458
640
|
// everything. Pointless on an empty vault, so only offered when it holds
|
|
459
641
|
// something — the wizard's done step already said so either way.
|
|
460
|
-
|
|
642
|
+
// Not at six keys either: a lock holds five, so the key being replaced has
|
|
643
|
+
// to be removed first, and that removal's re-lock covers both changes.
|
|
644
|
+
if (added.length > 0 && (balance ?? 0) > 0 && m.keys.length <= VAULT_MAX_KEYS) {
|
|
461
645
|
openRelock({
|
|
462
646
|
reason: t('vault_relock_reason', { names: others.map(vaultKeyLabel).join(', ') }),
|
|
463
647
|
exclude: added[0].serial
|
|
@@ -471,7 +655,20 @@ export function VaultScreen() {
|
|
|
471
655
|
const next = renameText.trim()
|
|
472
656
|
if (next && next !== renaming.nickname) {
|
|
473
657
|
try {
|
|
474
|
-
|
|
658
|
+
// XR-002: renameKey only changes a nickname, but its `next` meta
|
|
659
|
+
// still bumps revision — never trust the CURRENT record as the basis
|
|
660
|
+
// for a freshly tagged one without re-verifying it first (the same
|
|
661
|
+
// laundering caveat as vaultStore.addKey).
|
|
662
|
+
if (!pm) throw new VaultError('driver-unavailable', 'Wallet is not ready for a vault operation')
|
|
663
|
+
const currentMeta = metaRef.current
|
|
664
|
+
if (!currentMeta) throw new VaultError('not-enrolled', 'Vault is not set up')
|
|
665
|
+
const scopeToken = vaultStore.captureScopeToken()
|
|
666
|
+
await requireAuthenticatedMeta(pm as unknown as VaultWallet, adminOriginator, scopeToken, currentMeta)
|
|
667
|
+
const scope = vaultStore.getScope()
|
|
668
|
+
if (!scope) throw new VaultError('not-enrolled', 'Wallet vault scope is not configured')
|
|
669
|
+
await vaultStore.renameKey(renaming.serial, next, scopeToken, nextMeta =>
|
|
670
|
+
computeVaultMetaAuthorityTag(pm as unknown as HmacCapableWallet, adminOriginator, nextMeta, scope)
|
|
671
|
+
)
|
|
475
672
|
await reload()
|
|
476
673
|
} catch (e) {
|
|
477
674
|
haptics.error()
|
|
@@ -479,7 +676,7 @@ export function VaultScreen() {
|
|
|
479
676
|
}
|
|
480
677
|
}
|
|
481
678
|
setRenaming(null)
|
|
482
|
-
}, [renaming, renameText, reload])
|
|
679
|
+
}, [renaming, renameText, reload, pm, adminOriginator])
|
|
483
680
|
|
|
484
681
|
const removeKey = useCallback(
|
|
485
682
|
async (rec: VaultKeyRecord) => {
|
|
@@ -533,15 +730,20 @@ export function VaultScreen() {
|
|
|
533
730
|
// for the re-lock that makes the keys still on it open every deposit.
|
|
534
731
|
openRelock({
|
|
535
732
|
reason: t('vault_relock_reason_remaining', {
|
|
536
|
-
names: m.keys
|
|
733
|
+
names: m.keys
|
|
734
|
+
.filter(k => k.serial !== rec.serial)
|
|
735
|
+
.map(vaultKeyLabel)
|
|
736
|
+
.join(', ')
|
|
537
737
|
}),
|
|
538
738
|
revoke: rec
|
|
539
739
|
})
|
|
540
740
|
} catch (e) {
|
|
541
741
|
haptics.error()
|
|
742
|
+
const code = e instanceof VaultError ? e.code : undefined
|
|
743
|
+
if (code === 'action-pending') setActionPendingNotice(true)
|
|
542
744
|
await showAlert({
|
|
543
745
|
title,
|
|
544
|
-
message: vaultErrorCopy(
|
|
746
|
+
message: vaultErrorCopy(code),
|
|
545
747
|
buttons: [{ text: t('vault_ok'), key: 'ok' }]
|
|
546
748
|
})
|
|
547
749
|
return
|
|
@@ -552,14 +754,14 @@ export function VaultScreen() {
|
|
|
552
754
|
|
|
553
755
|
const keyActions = useCallback(
|
|
554
756
|
async (rec: VaultKeyRecord) => {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
})
|
|
757
|
+
// Remove only when it leaves at least VAULT_MIN_KEYS, and one removal at
|
|
758
|
+
// a time. To replace a key in a two-key vault, add the new one first.
|
|
759
|
+
const current = metaRef.current
|
|
760
|
+
const canRemove = !!current && !current.pendingRemoval && current.keys.length > VAULT_MIN_KEYS
|
|
761
|
+
const buttons: AlertButton[] = [{ text: t('vault_key_action_rename'), key: 'rename' }]
|
|
762
|
+
if (canRemove) buttons.push({ text: t('vault_key_action_remove'), key: 'remove', style: 'destructive' })
|
|
763
|
+
buttons.push({ text: t('vault_cancel'), key: 'cancel', style: 'cancel' })
|
|
764
|
+
const choice = await showAlert({ title: vaultKeyLabel(rec), buttons })
|
|
563
765
|
if (choice === 'rename') {
|
|
564
766
|
setRenameText(rec.nickname)
|
|
565
767
|
setRenaming(rec)
|
|
@@ -629,6 +831,13 @@ export function VaultScreen() {
|
|
|
629
831
|
* destinationPress → BiometricAdvisoryModal → ensureWalletExists.
|
|
630
832
|
*/
|
|
631
833
|
const creatingWalletRef = useRef(false)
|
|
834
|
+
// XR-003: set only on the branch below that generates a BRAND NEW mnemonic.
|
|
835
|
+
// A freshly generated wallet is certainly unattested (markPending was just
|
|
836
|
+
// written for it); onAdvisoryContinue reads this to skip a redundant
|
|
837
|
+
// attestation lookup and go straight to the mandatory seed-preservation
|
|
838
|
+
// screen, rather than risk a stale `managers.permissionsManager` closure
|
|
839
|
+
// read immediately after this same call just built it.
|
|
840
|
+
const justCreatedIdentityRef = useRef<string | null>(null)
|
|
632
841
|
const ensureWalletExists = useCallback(async (): Promise<boolean> => {
|
|
633
842
|
if (managers.permissionsManager) return true
|
|
634
843
|
if (!secretsReady || walletBuilding || creatingWalletRef.current) return false
|
|
@@ -646,6 +855,7 @@ export function VaultScreen() {
|
|
|
646
855
|
if (!(await hasStoredIdentity())) router.replace('/auth/mnemonic')
|
|
647
856
|
return false
|
|
648
857
|
}
|
|
858
|
+
justCreatedIdentityRef.current = wallet.identityKey
|
|
649
859
|
try {
|
|
650
860
|
await backupAttestation.markPending(wallet.identityKey)
|
|
651
861
|
} catch (error) {
|
|
@@ -659,10 +869,42 @@ export function VaultScreen() {
|
|
|
659
869
|
} finally {
|
|
660
870
|
creatingWalletRef.current = false
|
|
661
871
|
}
|
|
662
|
-
}, [
|
|
872
|
+
}, [
|
|
873
|
+
managers.permissionsManager,
|
|
874
|
+
secretsReady,
|
|
875
|
+
walletBuilding,
|
|
876
|
+
hasStoredIdentity,
|
|
877
|
+
createMnemonic,
|
|
878
|
+
buildWalletFromMnemonic,
|
|
879
|
+
router
|
|
880
|
+
])
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* XR-003: neither the enroll wizard nor a deposit may be reached before the
|
|
884
|
+
* mnemonic that alone can recover this vault (I1/I2 — YubiKeys carry no
|
|
885
|
+
* seed) has been durably preserved off-device at least once. Distinct from
|
|
886
|
+
* the ordinary wallet's dismissible backupAttestation reminder (which stays
|
|
887
|
+
* non-blocking): here the same record BLOCKS instead of reminding, because
|
|
888
|
+
* real money is about to depend on it. `knownUnattested` skips the lookup
|
|
889
|
+
* for the one caller (onAdvisoryContinue, immediately after generating a
|
|
890
|
+
* brand new mnemonic) where `managers.permissionsManager` may still be a
|
|
891
|
+
* stale pre-build closure read.
|
|
892
|
+
*/
|
|
893
|
+
const requireBackupAttested = useCallback(
|
|
894
|
+
async (knownUnattested = false): Promise<boolean> => {
|
|
895
|
+
const attested = knownUnattested
|
|
896
|
+
? null
|
|
897
|
+
: await readBackupAttestation(managers.permissionsManager, adminOriginator)
|
|
898
|
+
if (attested) return true
|
|
899
|
+
router.push('/auth/mnemonic?flow=backup')
|
|
900
|
+
return false
|
|
901
|
+
},
|
|
902
|
+
[managers.permissionsManager, adminOriginator, router]
|
|
903
|
+
)
|
|
663
904
|
|
|
664
905
|
const onDeposit = useCallback(async () => {
|
|
665
906
|
if (managers.permissionsManager) {
|
|
907
|
+
if (!(await requireBackupAttested())) return
|
|
666
908
|
router.push('/vault-transfer?direction=deposit')
|
|
667
909
|
return
|
|
668
910
|
}
|
|
@@ -672,12 +914,14 @@ export function VaultScreen() {
|
|
|
672
914
|
} catch {
|
|
673
915
|
return
|
|
674
916
|
}
|
|
917
|
+
setAdvisoryDegraded((await resolveProvisioningPolicy()).disclose)
|
|
675
918
|
setWalletCreationIntent('deposit')
|
|
676
919
|
setShowBiometricAdvisory(true)
|
|
677
|
-
}, [managers.permissionsManager, secretsReady, walletBuilding, hasStoredIdentity, router])
|
|
920
|
+
}, [managers.permissionsManager, requireBackupAttested, secretsReady, walletBuilding, hasStoredIdentity, router])
|
|
678
921
|
|
|
679
922
|
const onBeginEnrollment = useCallback(async () => {
|
|
680
923
|
if (managers.permissionsManager) {
|
|
924
|
+
if (!(await requireBackupAttested())) return
|
|
681
925
|
setWizard('enroll')
|
|
682
926
|
return
|
|
683
927
|
}
|
|
@@ -687,9 +931,10 @@ export function VaultScreen() {
|
|
|
687
931
|
} catch {
|
|
688
932
|
return
|
|
689
933
|
}
|
|
934
|
+
setAdvisoryDegraded((await resolveProvisioningPolicy()).disclose)
|
|
690
935
|
setWalletCreationIntent('enroll')
|
|
691
936
|
setShowBiometricAdvisory(true)
|
|
692
|
-
}, [managers.permissionsManager, secretsReady, walletBuilding, hasStoredIdentity])
|
|
937
|
+
}, [managers.permissionsManager, requireBackupAttested, secretsReady, walletBuilding, hasStoredIdentity])
|
|
693
938
|
|
|
694
939
|
const onAdvisoryContinue = useCallback(() => {
|
|
695
940
|
// Kept up (with a spinner in place of the label) until wallet creation
|
|
@@ -702,6 +947,9 @@ export function VaultScreen() {
|
|
|
702
947
|
const created = await ensureWalletExists()
|
|
703
948
|
setShowBiometricAdvisory(false)
|
|
704
949
|
if (created) {
|
|
950
|
+
const justCreated = justCreatedIdentityRef.current !== null
|
|
951
|
+
justCreatedIdentityRef.current = null
|
|
952
|
+
if (!(await requireBackupAttested(justCreated))) return
|
|
705
953
|
if (walletCreationIntent === 'enroll') setWizard('enroll')
|
|
706
954
|
else router.push('/vault-transfer?direction=deposit')
|
|
707
955
|
}
|
|
@@ -709,7 +957,7 @@ export function VaultScreen() {
|
|
|
709
957
|
setCreatingWallet(false)
|
|
710
958
|
}
|
|
711
959
|
})()
|
|
712
|
-
}, [ensureWalletExists, router, walletCreationIntent])
|
|
960
|
+
}, [ensureWalletExists, requireBackupAttested, router, walletCreationIntent])
|
|
713
961
|
|
|
714
962
|
// ── header ──────────────────────────────────────────────────────────
|
|
715
963
|
// While the wizard is up, back means "leave set-up" and goes through the
|
|
@@ -736,7 +984,11 @@ export function VaultScreen() {
|
|
|
736
984
|
<View style={styles.centered}>
|
|
737
985
|
<Ionicons name="alert-circle-outline" size={44} color={colors.error} />
|
|
738
986
|
<Text style={[styles.p, { color: colors.textPrimary }]}>{recoveryError}</Text>
|
|
739
|
-
<PressableScale
|
|
987
|
+
<PressableScale
|
|
988
|
+
haptic="tap"
|
|
989
|
+
onPress={retryRecovery}
|
|
990
|
+
style={[styles.primary, { backgroundColor: colors.accent }]}
|
|
991
|
+
>
|
|
740
992
|
<Text style={[styles.primaryLabel, { color: colors.textOnAccent }]}>{t('vault_retry')}</Text>
|
|
741
993
|
</PressableScale>
|
|
742
994
|
</View>
|
|
@@ -760,7 +1012,11 @@ export function VaultScreen() {
|
|
|
760
1012
|
return (
|
|
761
1013
|
<View style={[styles.container, { backgroundColor: colors.backgroundSecondary, paddingTop: insets.top }]}>
|
|
762
1014
|
{Header}
|
|
763
|
-
<EnrollWizard
|
|
1015
|
+
<EnrollWizard
|
|
1016
|
+
mode={wizard}
|
|
1017
|
+
onDone={wizard === 'enroll' ? onEnrolled : onKeyAdded}
|
|
1018
|
+
onCancel={() => void closeWizard()}
|
|
1019
|
+
/>
|
|
764
1020
|
</View>
|
|
765
1021
|
)
|
|
766
1022
|
}
|
|
@@ -792,7 +1048,11 @@ export function VaultScreen() {
|
|
|
792
1048
|
styles.primary,
|
|
793
1049
|
canEnroll
|
|
794
1050
|
? { backgroundColor: colors.accent }
|
|
795
|
-
: {
|
|
1051
|
+
: {
|
|
1052
|
+
backgroundColor: 'transparent',
|
|
1053
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
1054
|
+
borderColor: colors.separator
|
|
1055
|
+
}
|
|
796
1056
|
]}
|
|
797
1057
|
>
|
|
798
1058
|
<Text style={[styles.primaryLabel, { color: canEnroll ? colors.textOnAccent : colors.textTertiary }]}>
|
|
@@ -810,7 +1070,34 @@ export function VaultScreen() {
|
|
|
810
1070
|
{enabled && !supported && (
|
|
811
1071
|
<View style={styles.heroNotice}>
|
|
812
1072
|
<Text style={[styles.heroNoticeTitle, { color: colors.error }]}>{t('vault_unsupported_title')}</Text>
|
|
813
|
-
<Text style={[styles.heroNoticeBody, { color: colors.textSecondary }]}>
|
|
1073
|
+
<Text style={[styles.heroNoticeBody, { color: colors.textSecondary }]}>
|
|
1074
|
+
{t('vault_unsupported_body')}
|
|
1075
|
+
</Text>
|
|
1076
|
+
</View>
|
|
1077
|
+
)}
|
|
1078
|
+
{/* No local vault meta at all: a wiped device / reinstall with
|
|
1079
|
+
the same wallet identity may still have vault deposits
|
|
1080
|
+
on-chain. Needs the wallet identity (pm) but never a
|
|
1081
|
+
YubiKey — that is only needed afterward, to spend. */}
|
|
1082
|
+
{enabled && !!pm && (
|
|
1083
|
+
<View style={styles.heroNotice}>
|
|
1084
|
+
<PressableScale
|
|
1085
|
+
haptic="tap"
|
|
1086
|
+
onPress={restoringFromChain ? undefined : () => void onRestoreFromChain()}
|
|
1087
|
+
accessibilityState={{ disabled: restoringFromChain }}
|
|
1088
|
+
style={styles.secondary}
|
|
1089
|
+
>
|
|
1090
|
+
{restoringFromChain ? (
|
|
1091
|
+
<ActivityIndicator color={colors.accent} />
|
|
1092
|
+
) : (
|
|
1093
|
+
<Text style={[styles.secondaryLabel, { color: colors.accent }]}>
|
|
1094
|
+
{t('vault_restore_from_chain')}
|
|
1095
|
+
</Text>
|
|
1096
|
+
)}
|
|
1097
|
+
</PressableScale>
|
|
1098
|
+
{restoreNotice && (
|
|
1099
|
+
<Text style={[styles.heroNoticeBody, { color: colors.textSecondary }]}>{restoreNotice}</Text>
|
|
1100
|
+
)}
|
|
814
1101
|
</View>
|
|
815
1102
|
)}
|
|
816
1103
|
</View>
|
|
@@ -820,6 +1107,7 @@ export function VaultScreen() {
|
|
|
820
1107
|
<BiometricAdvisoryModal
|
|
821
1108
|
visible={showBiometricAdvisory}
|
|
822
1109
|
loading={creatingWallet}
|
|
1110
|
+
degraded={advisoryDegraded}
|
|
823
1111
|
onCancel={() => setShowBiometricAdvisory(false)}
|
|
824
1112
|
onContinue={onAdvisoryContinue}
|
|
825
1113
|
/>
|
|
@@ -828,14 +1116,20 @@ export function VaultScreen() {
|
|
|
828
1116
|
}
|
|
829
1117
|
|
|
830
1118
|
// ── enrolled ─────────────────────────────────────────────────────────
|
|
831
|
-
const canAdd = enabled && !meta.pendingRemoval && meta.keys.length <
|
|
1119
|
+
const canAdd = enabled && !meta.pendingRemoval && meta.keys.length < VAULT_MAX_ACTIVE_KEYS
|
|
1120
|
+
// Six keys: one more than a lock holds, so nothing that creates a Vault
|
|
1121
|
+
// output runs until one is removed. A full withdrawal creates none.
|
|
1122
|
+
const overLockLimit = meta.keys.length > VAULT_MAX_KEYS
|
|
832
1123
|
const adoptedSerials = new Set(meta.recovery?.adoptedSerials ?? [])
|
|
833
1124
|
const recoveryRequired = meta.recovery?.required === true
|
|
834
1125
|
const adoptedKeyCount = meta.keys.filter(key => adoptedSerials.has(key.serial)).length
|
|
835
1126
|
const hasAdoptedKey = !recoveryRequired || adoptedKeyCount > 0
|
|
836
1127
|
const hasRecoveryRedundancy = !recoveryRequired || adoptedKeyCount >= VAULT_MIN_KEYS
|
|
837
1128
|
const transfersBlocked = !!meta.pendingRemoval
|
|
838
|
-
|
|
1129
|
+
// Re-lock signed and broadcast: nothing is left to re-lock, only the
|
|
1130
|
+
// network's acceptance to wait for (the effect above re-checks).
|
|
1131
|
+
const removalAwaitingNetwork = meta.pendingRemoval?.state === 'broadcast'
|
|
1132
|
+
const canDeposit = enabled && !transfersBlocked && hasRecoveryRedundancy && !overLockLimit
|
|
839
1133
|
const canWithdraw = !transfersBlocked && hasAdoptedKey
|
|
840
1134
|
const missingNames = coverage
|
|
841
1135
|
? meta.keys
|
|
@@ -844,9 +1138,16 @@ export function VaultScreen() {
|
|
|
844
1138
|
.join(', ')
|
|
845
1139
|
: ''
|
|
846
1140
|
const relockCandidates = relock?.exclude ? meta.keys.filter(k => k.serial !== relock.exclude) : meta.keys
|
|
847
|
-
const openGenericRelock =
|
|
848
|
-
|
|
849
|
-
|
|
1141
|
+
const openGenericRelock =
|
|
1142
|
+
enabled && !overLockLimit
|
|
1143
|
+
? () => openRelock({ reason: t('vault_relock_reason_generic'), revoke: meta.pendingRemoval?.key })
|
|
1144
|
+
: undefined
|
|
1145
|
+
// The header counts the removed key while its removal is pending, but never
|
|
1146
|
+
// reads "6 of 5": over the limit it drops the "of 5".
|
|
1147
|
+
const listedKeys = meta.keys.length + (meta.pendingRemoval ? 1 : 0)
|
|
1148
|
+
const keySectionHeader = overLockLimit
|
|
1149
|
+
? t('vault_key_section_over_limit', { count: meta.keys.length })
|
|
1150
|
+
: t('vault_key_section', { count: listedKeys > VAULT_MAX_KEYS ? meta.keys.length : listedKeys })
|
|
850
1151
|
|
|
851
1152
|
return (
|
|
852
1153
|
<View style={[styles.container, { backgroundColor: colors.backgroundSecondary, paddingTop: insets.top }]}>
|
|
@@ -891,21 +1192,52 @@ export function VaultScreen() {
|
|
|
891
1192
|
accessibilityState={{ disabled: !canWithdraw }}
|
|
892
1193
|
style={[
|
|
893
1194
|
styles.actionBtn,
|
|
894
|
-
{
|
|
1195
|
+
{
|
|
1196
|
+
backgroundColor: colors.backgroundElevated,
|
|
1197
|
+
borderColor: colors.separator,
|
|
1198
|
+
borderWidth: StyleSheet.hairlineWidth
|
|
1199
|
+
}
|
|
895
1200
|
]}
|
|
896
1201
|
>
|
|
897
|
-
<Ionicons name="arrow-up" size={18} color={colors.accent} />
|
|
898
|
-
<Text style={[styles.actionLabel, { color: colors.accent }]}>
|
|
1202
|
+
<Ionicons name="arrow-up" size={18} color={canWithdraw ? colors.accent : colors.textTertiary} />
|
|
1203
|
+
<Text style={[styles.actionLabel, { color: canWithdraw ? colors.accent : colors.textTertiary }]}>
|
|
1204
|
+
{t('vault_withdraw_cta')}
|
|
1205
|
+
</Text>
|
|
899
1206
|
</PressableScale>
|
|
900
1207
|
</View>
|
|
901
1208
|
{!enabled && <Text style={[styles.notice, { color: colors.textSecondary }]}>{t(unavailableCopy)}</Text>}
|
|
902
|
-
{transfersBlocked &&
|
|
1209
|
+
{transfersBlocked && (
|
|
1210
|
+
<Text style={[styles.notice, { color: colors.warning }]}>
|
|
1211
|
+
{t(removalAwaitingNetwork ? 'vault_removal_awaiting_network' : 'vault_err_relock_required')}
|
|
1212
|
+
</Text>
|
|
1213
|
+
)}
|
|
1214
|
+
{overLockLimit && !transfersBlocked && (
|
|
1215
|
+
<Text style={[styles.notice, { color: colors.warning }]}>{t('vault_err_too_many_active_keys')}</Text>
|
|
1216
|
+
)}
|
|
903
1217
|
{recoveryRequired && !hasRecoveryRedundancy && (
|
|
904
1218
|
<Text style={[styles.notice, { color: colors.warning }]}>{t('vault_err_key_not_adopted')}</Text>
|
|
905
1219
|
)}
|
|
1220
|
+
{actionPendingNotice && (
|
|
1221
|
+
<View style={[styles.notice, styles.actionPendingBlock]}>
|
|
1222
|
+
<Text style={[styles.heroNoticeBody, { color: colors.warning }]}>{vaultErrorCopy('action-pending')}</Text>
|
|
1223
|
+
<PressableScale
|
|
1224
|
+
haptic="confirm"
|
|
1225
|
+
onPress={resolvingDeposit ? undefined : () => void onResolveHeldDeposit()}
|
|
1226
|
+
accessibilityState={{ disabled: resolvingDeposit }}
|
|
1227
|
+
>
|
|
1228
|
+
{resolvingDeposit ? (
|
|
1229
|
+
<ActivityIndicator color={colors.accent} />
|
|
1230
|
+
) : (
|
|
1231
|
+
<Text style={[typography.footnote, { color: colors.accent, fontWeight: '600', textAlign: 'center' }]}>
|
|
1232
|
+
{t('vault_resolve_held_deposit_action')}
|
|
1233
|
+
</Text>
|
|
1234
|
+
)}
|
|
1235
|
+
</PressableScale>
|
|
1236
|
+
</View>
|
|
1237
|
+
)}
|
|
906
1238
|
|
|
907
1239
|
<GroupedSection
|
|
908
|
-
header={
|
|
1240
|
+
header={keySectionHeader}
|
|
909
1241
|
footer={t('vault_footnote')}
|
|
910
1242
|
>
|
|
911
1243
|
{coverage && coverage.missingKeys.length > 0 && (
|
|
@@ -945,16 +1277,22 @@ export function VaultScreen() {
|
|
|
945
1277
|
<ListRow
|
|
946
1278
|
key={`pending-${meta.pendingRemoval.key.serial}`}
|
|
947
1279
|
label={`${meta.pendingRemoval.key.nickname} · ${formatVaultSerial(meta.pendingRemoval.key.serial)}`}
|
|
948
|
-
subtitle={t('vault_key_pending_removal')}
|
|
1280
|
+
subtitle={t(removalAwaitingNetwork ? 'vault_key_removal_awaiting_network' : 'vault_key_pending_removal')}
|
|
949
1281
|
icon="time-outline"
|
|
950
1282
|
iconColor={colors.warning}
|
|
951
1283
|
showChevron={false}
|
|
952
|
-
onPress={openGenericRelock}
|
|
1284
|
+
onPress={removalAwaitingNetwork ? undefined : openGenericRelock}
|
|
953
1285
|
isLast={!canAdd}
|
|
954
1286
|
/>
|
|
955
1287
|
)}
|
|
956
1288
|
{canAdd && (
|
|
957
|
-
<ListRow
|
|
1289
|
+
<ListRow
|
|
1290
|
+
label={t('vault_add_key_row')}
|
|
1291
|
+
icon="add-circle-outline"
|
|
1292
|
+
iconColor={colors.info}
|
|
1293
|
+
onPress={openAddKey}
|
|
1294
|
+
isLast
|
|
1295
|
+
/>
|
|
958
1296
|
)}
|
|
959
1297
|
</GroupedSection>
|
|
960
1298
|
|
|
@@ -1011,7 +1349,11 @@ export function VaultScreen() {
|
|
|
1011
1349
|
onSubmitEditing={() => void saveRename()}
|
|
1012
1350
|
autoFocus
|
|
1013
1351
|
/>
|
|
1014
|
-
<PressableScale
|
|
1352
|
+
<PressableScale
|
|
1353
|
+
haptic="confirm"
|
|
1354
|
+
onPress={() => void saveRename()}
|
|
1355
|
+
style={[styles.primary, { backgroundColor: colors.accent }]}
|
|
1356
|
+
>
|
|
1015
1357
|
<Text style={[styles.primaryLabel, { color: colors.textOnAccent }]}>{t('vault_rename_save')}</Text>
|
|
1016
1358
|
</PressableScale>
|
|
1017
1359
|
<PressableScale onPress={() => setRenaming(null)} style={styles.secondary}>
|
|
@@ -1078,7 +1420,12 @@ export function VaultScreen() {
|
|
|
1078
1420
|
</Sheet>
|
|
1079
1421
|
|
|
1080
1422
|
{/* Re-lock — choose the key, then one ceremony tap per pass. */}
|
|
1081
|
-
<Sheet
|
|
1423
|
+
<Sheet
|
|
1424
|
+
visible={relock !== null}
|
|
1425
|
+
onClose={relocking ? noop : closeRelock}
|
|
1426
|
+
title={t('vault_relock_row')}
|
|
1427
|
+
fitContent
|
|
1428
|
+
>
|
|
1082
1429
|
<View style={styles.sheetBody}>
|
|
1083
1430
|
{relock?.reason ? <Text style={[styles.p, { color: colors.textSecondary }]}>{relock.reason}</Text> : null}
|
|
1084
1431
|
<Text style={[styles.sheetLabel, { color: colors.textPrimary }]}>{t('vault_relock_choose')}</Text>
|
|
@@ -1105,6 +1452,7 @@ export function VaultScreen() {
|
|
|
1105
1452
|
<BiometricAdvisoryModal
|
|
1106
1453
|
visible={showBiometricAdvisory}
|
|
1107
1454
|
loading={creatingWallet}
|
|
1455
|
+
degraded={advisoryDegraded}
|
|
1108
1456
|
onCancel={() => setShowBiometricAdvisory(false)}
|
|
1109
1457
|
onContinue={onAdvisoryContinue}
|
|
1110
1458
|
/>
|
|
@@ -1142,6 +1490,7 @@ const styles = StyleSheet.create({
|
|
|
1142
1490
|
h1: { ...typography.title1, textAlign: 'center' },
|
|
1143
1491
|
p: { ...typography.subhead, textAlign: 'center' },
|
|
1144
1492
|
notice: { ...typography.footnote, textAlign: 'center', paddingHorizontal: spacing.xl, marginBottom: spacing.xxl },
|
|
1493
|
+
actionPendingBlock: { gap: spacing.sm },
|
|
1145
1494
|
primary: { width: '100%', borderRadius: radii.md, paddingVertical: spacing.lg, alignItems: 'center' },
|
|
1146
1495
|
primaryLabel: { ...typography.headline },
|
|
1147
1496
|
secondary: { paddingVertical: spacing.md, alignItems: 'center' },
|