@bsv/expo-wallet-toolbox 0.7.0 → 0.10.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 (154) hide show
  1. package/CHANGELOG.md +1790 -0
  2. package/README.md +54 -1
  3. package/core/amountFormatHelpers.ts +20 -2
  4. package/core/backup/RemoteSyncReader.ts +131 -19
  5. package/core/backup/appData.ts +157 -0
  6. package/core/backup/client.ts +15 -1
  7. package/core/backup/codec.ts +147 -9
  8. package/core/backup/constants.ts +30 -1
  9. package/core/backup/cursor.ts +31 -2
  10. package/core/backup/push.ts +70 -4
  11. package/core/backup/restore.ts +104 -16
  12. package/core/backup/restoreOnImport.ts +94 -30
  13. package/core/backup/status.ts +13 -8
  14. package/core/constants.ts +14 -1
  15. package/core/context/ExchangeRateContext.tsx +34 -27
  16. package/core/context/LocalStorageProvider.tsx +43 -40
  17. package/core/context/UserContext.tsx +18 -7
  18. package/core/context/VaultContext.tsx +49 -2
  19. package/core/context/WalletConnectionContext.tsx +203 -11
  20. package/core/context/WalletContext.tsx +653 -175
  21. package/core/headers/OfflineFirstChaintracks.ts +48 -4
  22. package/core/headers/headerStore.ts +26 -4
  23. package/core/headers/headerSyncTriggers.ts +65 -0
  24. package/core/headers/syncHeaders.ts +12 -1
  25. package/core/i18n/translations.tsx +1001 -25
  26. package/core/identity/handleRegistry/client.ts +31 -2
  27. package/core/identity/handleRegistry/keyPinStore.ts +70 -0
  28. package/core/identity/handleRegistry/resolver.ts +71 -3
  29. package/core/index.ts +33 -3
  30. package/core/localpay/build.ts +225 -24
  31. package/core/localpay/pending.ts +110 -7
  32. package/core/localpay/pendingAbortAuthority.ts +95 -0
  33. package/core/localpay/pendingAborts.ts +264 -28
  34. package/core/localpay/session.ts +42 -17
  35. package/core/localpay/settlementAck.ts +10 -1
  36. package/core/localpay/transport/socket.ts +52 -3
  37. package/core/localpay/types.ts +9 -1
  38. package/core/localpay/verify.ts +143 -16
  39. package/core/mandala/abortGuard.ts +96 -20
  40. package/core/mandala/createRuntime.ts +206 -33
  41. package/core/mandala/drain.ts +89 -11
  42. package/core/mandala/inboxPrehold.ts +186 -0
  43. package/core/mandala/permissionModule.ts +202 -20
  44. package/core/mandala/settlementStore.ts +24 -2
  45. package/core/mandala/types.ts +40 -5
  46. package/core/monitor/TaskBackupPush.ts +14 -0
  47. package/core/monitor/TaskDrainOutbox.ts +14 -0
  48. package/core/monitor/TaskSendOffline.ts +14 -0
  49. package/core/net/publicDestination.ts +91 -0
  50. package/core/net/validateArcUrl.ts +22 -0
  51. package/core/offline/cancelParked.ts +134 -13
  52. package/core/offline/payerHold.ts +100 -24
  53. package/core/offline/plan.ts +36 -7
  54. package/core/pay/beefRepair.ts +6 -2
  55. package/core/pay/damagedInbox.ts +24 -0
  56. package/core/pay/rails/address.ts +107 -12
  57. package/core/pay/rails/handle.ts +117 -22
  58. package/core/pay/rails/index.ts +45 -7
  59. package/core/pay/rails/nativeIntent.ts +61 -0
  60. package/core/pay/rails/nearby.ts +1 -0
  61. package/core/pay/receiveHistory.ts +93 -0
  62. package/core/pay/recordProof.ts +19 -1
  63. package/core/pay/refreshProofGuard.ts +42 -1
  64. package/core/pay/watchlist.ts +5 -2
  65. package/core/peerpay/control.ts +17 -18
  66. package/core/peerpay/handleResendRequests.ts +58 -4
  67. package/core/peerpay/outbox.ts +3 -1
  68. package/core/recovery/backupMaterial.ts +61 -0
  69. package/core/recovery/createWallet.ts +95 -0
  70. package/core/recovery/recoverWallet.ts +120 -0
  71. package/core/recovery/restoreWallet.ts +170 -0
  72. package/core/recovery/secret.ts +92 -0
  73. package/core/recovery/shareCollector.ts +71 -0
  74. package/core/recovery/shareParsing.ts +87 -0
  75. package/core/recovery/shares.ts +116 -0
  76. package/core/recovery/useRecoveryDeps.ts +70 -0
  77. package/core/services/arcTokenStorage.ts +52 -0
  78. package/core/services/arcadeBroadcastProvider.ts +232 -48
  79. package/core/services/autoApprovePolicy.ts +105 -0
  80. package/core/services/callbackToken.ts +19 -0
  81. package/core/services/capWalletArgs.ts +14 -2
  82. package/core/services/connectionAuthority.ts +98 -0
  83. package/core/services/exchangeRate.ts +35 -12
  84. package/core/services/externalOrigin.ts +11 -0
  85. package/core/services/secrets/kek.ts +126 -29
  86. package/core/services/secrets/migration.ts +16 -4
  87. package/core/services/secrets/store.ts +42 -14
  88. package/core/services/vault/VaultKeyService.ts +228 -45
  89. package/core/services/vault/chainRecovery.ts +483 -0
  90. package/core/services/vault/driver.ts +9 -1
  91. package/core/services/vault/enrolledSerialRegistry.ts +150 -0
  92. package/core/services/vault/guard.ts +218 -32
  93. package/core/services/vault/hardwareLease.ts +19 -0
  94. package/core/services/vault/metaAuthority.ts +210 -0
  95. package/core/services/vault/pivReset.ts +64 -23
  96. package/core/services/vault/r1comb.ts +139 -3
  97. package/core/services/vault/session.ts +25 -4
  98. package/core/services/vault/transfers.ts +866 -170
  99. package/core/services/vault/types.ts +19 -4
  100. package/core/services/vault/vaultStore.ts +256 -29
  101. package/core/services/walletArgLimits.ts +45 -2
  102. package/core/services/walletConnectionValidation.ts +76 -6
  103. package/core/services/walletServiceConfig.ts +10 -8
  104. package/core/storage/StorageExpoSQLite.ts +47 -13
  105. package/core/storage/methods/findSql.ts +21 -2
  106. package/core/storage/methods/offlineActions.ts +10 -1
  107. package/core/storage/methods/processOfflineActions.ts +116 -23
  108. package/core/storage/schema/createTables.ts +126 -2
  109. package/core/stores/ConnectionStore.ts +34 -0
  110. package/core/toolboxConfig.ts +45 -11
  111. package/core/walletDbRegistry.ts +63 -0
  112. package/core/walletMonitor.ts +17 -1
  113. package/core/walletRepair/releaseStuckReservations.ts +72 -0
  114. package/core/walletRepair/shouldMarkUnspendable.ts +20 -0
  115. package/core/walletRepair/spenderConsumesOutpoint.ts +29 -0
  116. package/package.json +2 -2
  117. package/ui/backupShares.ts +26 -169
  118. package/ui/components/pay/AddressReceive.tsx +13 -6
  119. package/ui/components/pay/AssetPicker.tsx +30 -9
  120. package/ui/components/pay/MessageBoxConfig.tsx +16 -0
  121. package/ui/components/pay/NearbyFlow.tsx +511 -251
  122. package/ui/components/pay/PaymentSuccessOverlay.tsx +39 -4
  123. package/ui/components/pay/UniversalSend.tsx +167 -73
  124. package/ui/components/ui/AlertCard.tsx +38 -5
  125. package/ui/components/ui/PermissionSheet.tsx +197 -66
  126. package/ui/components/vault/EnrollWizard.tsx +61 -13
  127. package/ui/components/vault/vaultErrorCopy.ts +3 -1
  128. package/ui/components/wallet/ActivityRow.tsx +5 -3
  129. package/ui/components/wallet/AmountInput.tsx +8 -2
  130. package/ui/components/wallet/AssetSwitcherDropdown.tsx +22 -2
  131. package/ui/components/wallet/Balance.tsx +42 -23
  132. package/ui/components/wallet/BiometricAdvisoryModal.tsx +16 -3
  133. package/ui/exportTransactions.ts +36 -4
  134. package/ui/hooks/useExportWalletData.ts +25 -2
  135. package/ui/importDatabases.ts +339 -24
  136. package/ui/index.ts +9 -3
  137. package/ui/isImageUrl.ts +6 -0
  138. package/ui/printRecoveryShares.ts +9 -10
  139. package/ui/recoveryPrompts.ts +91 -0
  140. package/ui/resolveIdentity.ts +31 -9
  141. package/ui/screens/ConnectionsScreen.tsx +86 -19
  142. package/ui/screens/IdentifierScreen.tsx +30 -8
  143. package/ui/screens/PairScreen.tsx +74 -2
  144. package/ui/screens/SettingsScreen.tsx +10 -4
  145. package/ui/screens/TrustScreen.tsx +99 -4
  146. package/ui/screens/VaultScreen.tsx +410 -61
  147. package/ui/screens/VaultTransferScreen.tsx +59 -7
  148. package/ui/screens/WalletCheckScreen.tsx +17 -6
  149. package/ui/screens/WalletConfigScreen.tsx +82 -28
  150. package/ui/screens/WalletHomeScreen.tsx +179 -88
  151. package/ui/screens/detailActionKeys.ts +55 -0
  152. package/ui/tokenFormat.ts +44 -4
  153. package/ui/txStatus.ts +5 -0
  154. package/core/storage/LocalStorageAdapter.ts +0 -58
package/CHANGELOG.md CHANGED
@@ -1,5 +1,1795 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### `verifyFramePayment` takes its chain tracker separately (breaking)
6
+
7
+ `verifyFramePayment(wallet, frame, originator, opts)` becomes
8
+ `verifyFramePayment({ wallet, chainTracker }, frame, originator, opts)`
9
+ (new `FrameVerifyDeps`), and `DerivingWallet` is back to `getPublicKey` only.
10
+ The 0.8.0 shape asked one "wallet" object for both key derivation and
11
+ `getServices().getChainTracker()`; the permissions manager has only the first,
12
+ and that mismatch is the bug below. A host calling `verifyFramePayment`
13
+ itself passes its permissions manager as `wallet` unchanged and
14
+ `await storage.getServices().getChainTracker()` as `chainTracker`. The
15
+ tracker is used only for BSV frames.
16
+
17
+ ### Nearby receive: BSV frames verify again; the header window keeps up (#25)
18
+
19
+ - **Every Nearby BSV payment was declined on receive** (`NearbyFlow`).
20
+ `settleReceived` handed the permissions manager to `verifyFramePayment` as
21
+ the `DerivingWallet`, but the permissions manager has no `getServices()`,
22
+ so the SPV check threw a `TypeError` that went out as `decode_failed`.
23
+ NearbyFlow now passes the permissions manager unchanged, with the chain
24
+ tracker from `storage.getServices()`; if storage cannot supply one it
25
+ declines `save_failed` having queued nothing.
26
+ - **New decline kind `root_unverified`** (`core/localpay/verify.ts`,
27
+ `types.ts`). `tx.verify` returns false for a bad script or value and for a
28
+ merkle root the device cannot confirm alike, so an offline payee whose
29
+ header window did not reach the payment's block looked like a malformed
30
+ payment. The chain tracker is now observed during verification; a refused
31
+ root raises `FrameVerifyError('root_unverified')`, the payer is told
32
+ `root_unverified` (new `DeclineReason`), the request stays live, and the
33
+ payee sees `local_pay_root_unverified` (go online briefly, then retry).
34
+ Payers on older builds show the code verbatim. `FrameVerifyKind` and
35
+ `DeclineReason` gain the member, so a host switching exhaustively on either
36
+ needs a case for it.
37
+ - **The local header window is topped up while online, not only on
38
+ reconnect** (`core/headers/headerSyncTriggers.ts`,
39
+ `startHeaderSyncTriggers`). A phone that stayed on one network, or whose
40
+ NetInfo was silent while suspended, never saw a reconnect, so its window
41
+ trailed the chain by hours and it refused any coin mined since. The sync
42
+ now also runs on returning to the foreground and every
43
+ `HEADER_SYNC_INTERVAL_MS` (10 minutes) while online; each pass fetches only
44
+ the headers above the local tip.
45
+ - Copy: `local_pay_declined_root_unverified` and `local_pay_root_unverified`,
46
+ 12 languages.
47
+
48
+ ## 0.9.0
49
+
50
+ 0.8.0 has release notes below but was never published to npm. Hosts upgrading
51
+ from 0.7.0 should read both sections.
52
+
53
+ ### Upgrading from 0.7.0
54
+
55
+ - **Peer range `@bsv/wallet-toolbox-mobile` ^2.14.3** (was ^2.14.0). Replace
56
+ `patches/@bsv+wallet-toolbox-mobile+2.14.0.patch` with this repo's
57
+ `patches/@bsv+wallet-toolbox-mobile+2.14.3.patch`; the old file does not
58
+ apply to 2.14.3. `patches/@bsv+sdk+2.8.2.patch` is unchanged.
59
+ - **`useWallet().logout` returns `Promise<boolean>`** (was `() => void`). It
60
+ resolves once teardown finishes (monitor stop, database purge, secret
61
+ erasure, cache sweeps), and to `false` if the secrets layer could not
62
+ confirm erasure (XR-107). Await it before treating Delete Wallet or sign-out
63
+ as complete, and before navigating or rebuilding.
64
+ - **Already breaking in 0.8.0** (see that section): `LocalStorageAdapter` and
65
+ its exports are removed; `configureToolbox` rejects a non-https,
66
+ non-local backup, Mandala or MessageBox origin (XR-064/XR-065); a host's own
67
+ `RestorePrompts` must implement `confirmReplace()`.
68
+ - **SQLite:** new nullable `transactions.noSendExpiry*` columns and
69
+ `token_settlements.relevantVout` are added in place on open. No host action,
70
+ unless external tooling reads the database file.
71
+
72
+ ### Vault v7: chain-published recovery, no salt at rest (INT-01/02/03/04/06/10, XQ-012, XR-005/006)
73
+
74
+ Closes the availability and exclusion gaps the external security review's
75
+ ledger tracked under these rows: a clean device (mnemonic + one enrolled
76
+ YubiKey + its PIN) could not locate or spend an existing Vault output
77
+ without the old SQLite database or an encrypted backup, and the only copy
78
+ of a v6 output's salt lived in plaintext in that same local
79
+ `customInstructions` — a stolen DB/export/device-backup, plus a stolen
80
+ committed key and its PIN, could spend without the mnemonic.
81
+
82
+ - **v7 recovery metadata** (`r1comb.ts`): the v6 shape minus `salt` — 8
83
+ exact fields, `v===7`, no legacy reinterpretation, structurally unable to
84
+ carry a salt at rest. `decodeVaultInstructions` is now the union decoder
85
+ (v6 ?? v7); the v6 decoder/encoder are unchanged and still the only path
86
+ for existing outputs. Salt derivation itself is unchanged (same
87
+ `createHmac`, same `[2,'vault salt']` domain, same serial framing) — for
88
+ v7 it is re-derived in memory whenever needed and never persisted.
89
+ - **On-chain marker + descriptor**: every v7 vault output is now followed by
90
+ two explicit outputs — a 1-sat P2PKH **marker**
91
+ (`wallet.getPublicKey([2,'vault marker'], keyID` `` `${chain}:${k}` ``
92
+ `, counterparty:'self')`, an ordinary indexer can answer) and a 0-sat
93
+ `OP_FALSE OP_RETURN 'r1c7' <ciphertext>` **descriptor** carrying the exact
94
+ v7 record, BRC-2 (AES-256-GCM) encrypted under
95
+ `[2,'vault descriptor']` at the same chain-scoped keyID. Neither goes in
96
+ any basket. `guard.ts`'s `VAULT_PROTOCOL_NAMES` reserves both new protocol
97
+ names in the same change that starts creating them, so a paired
98
+ non-admin BRC-100 caller can never derive a marker key or decrypt a
99
+ descriptor. `validateDepositPlan` and the re-lock/withdraw-remainder path
100
+ now pin all three outputs (vault, marker, descriptor) byte-exact, the
101
+ same discipline the vault output alone used to get; `estimateRelockFee`
102
+ reserves their byte cost too. Crash-recovery reconciliation
103
+ (`isValidHeldVaultDeposit`) recognizes the new 3-4-output shape so a v7
104
+ deposit interrupted mid-flight does not wedge every later vault
105
+ operation behind `action-pending`.
106
+ - **`core/services/vault/chainRecovery.ts`** (new): `recoverVaultFromChain`
107
+ scans for the marker at index `k=1,2,…`, and for every candidate
108
+ transaction it finds, locates the `[vault, marker, descriptor]` triple by
109
+ the marker's exact position, decrypts the descriptor, hard-requires its
110
+ claimed index and chain match the scan position, re-derives the salt,
111
+ rebuilds the lock byte-exactly and compares it to the real output,
112
+ requires it unspent, and internalizes it into the `admin vault` basket —
113
+ before finally calling the existing `recoverVaultMetaFromOutputs`
114
+ unchanged. A found-but-unusable record at one index is reported
115
+ distinctly and never stops the scan; an unconfirmed candidate is
116
+ reported as pending rather than thrown. The injected `VaultChainLookup`
117
+ interface keeps the module network-agnostic and unit-testable;
118
+ `wocChainLookup` is the production WhatsOnChain implementation. The
119
+ YubiKey is never needed to restore — only to spend afterward, through
120
+ the completely unchanged withdraw path.
121
+ - **UI**: VaultScreen's not-enrolled hero gains "Restore vault from the
122
+ blockchain", offered whenever a wallet identity exists and the vault is
123
+ available (never gated on YubiKey support). New i18n keys in all 12
124
+ languages; non-English copy is machine-drafted and awaits
125
+ native-speaker review, same as every previous translation batch in this
126
+ changelog.
127
+
128
+ **Residuals, disclosed rather than silently left open:**
129
+
130
+ - Existing v6 outputs are unaffected and still need the local DB or an
131
+ encrypted backup until they are re-locked (which converts them to v7).
132
+ No migration rewrites old rows, and this release adds no nudge to do so.
133
+ - Recovery claims **confirmed** deposits. `internalizeAction`'s own SPV
134
+ gate requires a BUMP or a present raw-input ancestor chain; assembling
135
+ arbitrary-depth unconfirmed ancestor BEEF was considered and rejected as
136
+ open-ended complexity for a narrow confirmation-window edge case, not
137
+ required by the availability guarantee's core promise (surviving loss of
138
+ a *settled* deposit). An unconfirmed candidate is surfaced as "pending
139
+ confirmation," never silently dropped.
140
+ - ARC/indexer acceptance of a transaction carrying a ~45 KB R1C lock plus a
141
+ 1-sat P2PKH plus a ~1.5 KB `OP_RETURN` in one broadcast has not been
142
+ verified against a live network in this change; likewise `wocChainLookup`'s
143
+ exact WhatsOnChain response-shape assumptions (history endpoint, spent-output
144
+ endpoint) were not exercised against the live API. Both need a network
145
+ smoke test before this is fully relied upon in production;
146
+ `recoverVaultFromChain`'s own scan/authentication logic does not depend
147
+ on either being exactly right and is unit-tested against an in-memory
148
+ chain double.
149
+ - A basketless marker output is not tracked by `guard.ts`'s vault
150
+ inventory. Read-only verification of the real `WalletPermissionsManager`
151
+ confirms a non-admin originator can name its outpoint in `createAction`
152
+ without any basket or protocol permission (spending it still requires a
153
+ signature from its key, which is reserved the same way the descriptor
154
+ key is) — financial exposure is 1 satoshi, and a stranger spending or
155
+ reserving it does not remove the marker transaction or its address's
156
+ history from any indexer, so it cannot defeat recovery. Accepted, not
157
+ fixed.
158
+ - The physical-hardware run (a real, previously-enrolled YubiKey signing
159
+ through the full chain-recovered-lock-to-withdraw path on a wiped
160
+ device) remains the standing hardware gate this repository already
161
+ treats as unrun for the Vault generally; it is proven here only with
162
+ `MockYubiKey`'s real P-256 math.
163
+
164
+ ### Payments and export: device report fixes (2026-09-25)
165
+
166
+ - **@bsv/wallet-toolbox-mobile 2.14.0 → 2.14.3.** 2.14.3 ships both toolbox
167
+ fixes below upstream (bsv-blockchain/ts-stack#638), so their patch-package
168
+ hunks are gone; the patch file is now
169
+ `patches/@bsv+wallet-toolbox-mobile+2.14.3.patch` and carries the earlier
170
+ hunks unchanged. Also in 2.14.1–2.14.3: `discoverByAttributes` re-filters
171
+ overlay results the way the overlay searched them. In 2.14.0 an `any`
172
+ search compared a certificate field literally named `any`, so ContactsScreen
173
+ network search and the Pay recipient search never showed a network result;
174
+ they now match whole words (stopwords ignored, no stemming), `userName`
175
+ exactly. The exact-spend amount moved from a symbol on the createAction
176
+ result to a shared WeakMap (no app code reads it).
177
+ - **Nearby payments failed with "generateChangeSdk error: required fee
178
+ error 23 !== 33"** (toolbox, fixed in 2.14.3). In 2.14.0,
179
+ `shapeSurplusChangeOutputs` split the change into outputs of exactly
180
+ `changeInitialSatoshis` — the basket's `minimumDesiredUTXOValue`, still the
181
+ legacy 32 in every wallet created before the bump — below the 40-sat dust
182
+ floor at 100 sat/kB. `removeDustOutputs` then stripped them without
183
+ returning the fee paid for their bytes, and the final check rejected the
184
+ plan. Split outputs are now floored at the dust floor. Hit most payments
185
+ funded from one coin with a small surplus, on every wallet-funded rail.
186
+ Regression: `__tests__/localpay/nearbyOneCoinChangeShaping.test.ts` (real
187
+ Wallet + StorageExpoSQLite; reproduces the exact error on 2.14.0).
188
+ - **"Cancel payment" refused with "The action reference was not issued by
189
+ this permissions manager"** (toolbox, owner-approved; fixed in 2.14.3).
190
+ `WalletPermissionsManager.abortAction` accepted only a reference still in
191
+ its in-memory map, which `signAction` and every restart empty, so a signed
192
+ noSend payment could never be cancelled, and `replayPendingAborts` could
193
+ never release one either. The wallet's own admin originator may now abort
194
+ any of its actions; every other originator keeps the issued-reference and
195
+ same-originator checks. The app's token-settlement and Vault abort guards
196
+ still run first. Regression:
197
+ `__tests__/context/permissionsManagerAdminAbort.test.ts`.
198
+ - **Cancel only while a payment never left the device**
199
+ (`detailActionKeys.ts`, `ActivityRow`): plain Cancel is offered only when
200
+ there is no offline record for the payment; a parked one keeps its
201
+ chain-checked cancel, and any recorded hand-over (queued, posting, sent,
202
+ acknowledged, rejected, import_hold) offers none, since the payee may hold
203
+ it.
204
+ - **"Request confirmation from recipient"** (`tx_action_request_confirmation`,
205
+ 12 languages): the transaction details menu re-delivers an outgoing
206
+ message-box, Nearby or token payment over the message box (the existing
207
+ `onSendPaymentDetails`, which also releases a parked payment on success).
208
+ - **Export Wallet Data hung on iOS** (`AlertCard`, `useExportWalletData`).
209
+ Since the unencrypted-export warning (XR-086), `showAlert` resolved on the
210
+ tap while the alert's native modal was still presented, so the share sheet
211
+ was presented on that modal and dismissed with it, and `shareAsync` never
212
+ settled. `showAlert` now resolves once the modal is dismissed (iOS
213
+ `onDismiss`; after the fade on Android; a fallback timer so a modal that
214
+ never presented cannot hold the queue), and the export spinner starts only
215
+ after the warning is confirmed.
216
+
217
+ ### Vault: replace a key by adding first; locks hold 2 to 5 keys (owner rule, 2026-09-25)
218
+
219
+ - **Remove needs three keys.** VaultScreen's key menu offers Remove only when
220
+ the vault has more than `VAULT_MIN_KEYS` active keys and no removal is
221
+ pending; before, it always offered Remove and refused afterwards. The
222
+ service and store refusals (`last-keys`) are unchanged.
223
+ - **A sixth key, never locked to.** New `VAULT_MAX_ACTIVE_KEYS` = 6
224
+ (`VaultKeyService.ts`, mirrored in `vaultStore.ts`): a full vault can add
225
+ the replacement key before removing the key it replaces, and one re-lock at
226
+ five covers both. `isVaultMeta`, `vaultStore.addKey` and `addVaultKey`
227
+ accept six; a seventh is still `too-many-keys`. `VAULT_MAX_KEYS` (5, the
228
+ R1C lock ceiling) is unchanged.
229
+ - **Nothing locks to six, or to one.** New `too-many-active-keys` error:
230
+ `newVaultOutput` (deposit, re-lock, partial-withdrawal remainder) and
231
+ `relockVault` (before its fee estimate) refuse unless the key list is 2..5.
232
+ A full withdrawal creates no Vault output and stays allowed.
233
+ - **Removing a key no output commits finishes at once** (`beginVaultKeyRemoval`):
234
+ it used to return `complete: false` whenever the vault held any output, so
235
+ removing a key added but not yet re-locked to (the add-then-remove flow)
236
+ opened a re-lock that could only fail with `vault-empty`. It now checks
237
+ whether any output commits that key; if none does, the removal completes
238
+ with no re-lock. A held deposit (which may still commit the key) makes
239
+ that case wait with `action-pending`, and an output committing the key
240
+ that appears between the two scans cancels the removal as before.
241
+ - **UI at six keys**: no Add; Deposit disabled with
242
+ `vault_err_too_many_active_keys`; a partial withdrawal is refused (before
243
+ any card tap) only when its remainder would go back into the vault, so a
244
+ remainder under the floor still offers withdrawing everything; the
245
+ coverage badge does not open a re-lock; the header drops "of 5" (`vault_key_section_over_limit`); after
246
+ adding the sixth, no automatic re-lock sheet, and the wizard's done step
247
+ says to remove the replaced key (`vault_add_key_done_over_limit`, button
248
+ "Done"). Three new strings in 12 languages.
249
+
250
+ ### Vault: key removal finishes on network acceptance (physical-device report, 2026-09-25)
251
+
252
+ - **Finalize on acceptance** (`transfers.ts`, owner decision): a key removal
253
+ used to stay pending — deposits and withdrawals blocked, the removed key
254
+ listed as "re-lock to finish" — until its re-lock was mined and proven
255
+ (`completed`). `finalizeVaultKeyRemoval` now clears the tombstone once the
256
+ re-lock is accepted by the network (`unproven`: ARC returned an accepted
257
+ status). New `ACCEPTED_ACTION_STATUSES` = `unproven`, `completed`; any
258
+ other Vault action status (`sending` included) still blocks, and a failed
259
+ withdrawal or re-lock still blocks. Should an accepted re-lock still be
260
+ dropped, its sources return as outputs committed to a key the vault no
261
+ longer lists, and the removed-key badge offers the re-lock again.
262
+ - **Untagged broadcast write** (`transfers.ts`): `relockVault` marked a
263
+ removal's tombstone `broadcast` without re-tagging the meta. The tag
264
+ covers `pendingRemoval.state`, so the stored meta stopped verifying and
265
+ every later check fell back to a full chain re-authentication (failing
266
+ closed whenever that scan could not see the re-lock output). It is now
267
+ tagged like every other meta write.
268
+ - **VaultScreen / VaultTransferScreen**: a removal whose re-lock is broadcast
269
+ but not yet accepted said "Re-lock the vault first", and the removed key's
270
+ row opened a second re-lock sheet (which would have been refused as
271
+ `vault-empty`, since no output still commits that key). The screens now
272
+ say the re-lock was sent and deposits and withdrawals open again once the
273
+ network accepts it (`vault_removal_awaiting_network`,
274
+ `vault_key_removal_awaiting_network`, 12 languages); the row is inert in
275
+ that state. The screen re-runs `finalizeVaultKeyRemoval` every 30 s and on
276
+ return to the foreground while it waits. Withdraw is drawn disabled when
277
+ it is.
278
+
279
+ ### Vault: forged-state, session, and chain-recovery hardening (external security review)
280
+
281
+ - **Enrollment and meta forgery (XR-001, XR-002).** A `ready` enrollment draft
282
+ and the local `VaultMeta` record were previously trusted by shape alone — a
283
+ SecureStore-only attacker (no YubiKey, no wallet root) could inject a forged
284
+ draft, or inflate `VaultMeta`'s revision and key set, and have it committed
285
+ as spend authority with zero possession or hardware check.
286
+ `enrollKey`/`resumeEnrollmentDraft` now tag a `ready` draft with a wallet-
287
+ root HMAC the instant they write it (`computeVaultDraftAuthorityTag`, reusing
288
+ the `vault meta` protocol namespace `guard.ts` reserves), and
289
+ `requireReadyEnrollmentDrafts` verifies that tag before trusting a draft as
290
+ authority. Every meta-writing path (create, add/remove key, rename, restore)
291
+ now tags the record with a wallet-root HMAC over the fields that confer spend
292
+ authority, and `requireAuthenticatedMeta` re-derives the true key set from
293
+ chain history whenever a tag is missing or invalid before any deposit, re-
294
+ lock, or re-vaulted withdrawal remainder proceeds. `addVaultKey` additionally
295
+ re-verifies an existing meta's own tag before appending to it, closing a
296
+ laundering path where a forged meta could gain a valid tag merely because the
297
+ legitimate user's next action happened to add a key. Separately,
298
+ `EnrollWizard`'s add-key mode no longer auto-commits the first `ready` draft
299
+ it finds on mount — it now requires an explicit, named confirmation (new keys
300
+ `vault_resume_draft_confirm_title`/`_body`/`_use`/`_discard`) before use, and
301
+ discards a declined draft.
302
+ - **Backup-attestation gate before enroll/deposit (XR-003).** Creating a wallet
303
+ from the Vault entry point used to route straight to enrollment or deposit
304
+ with no requirement that the auto-generated mnemonic was ever written down.
305
+ `VaultScreen` and `VaultTransferScreen` now block deposit and enrollment
306
+ behind `requireBackupAttested()`, routing to the existing backup ceremony
307
+ first whenever the current identity has no attestation record. New keys
308
+ `vault_seed_not_preserved_title`/`_body`/`_cta`.
309
+ - **Superseded hardware session (XR-004).** `hardwareLease.ts` now tracks a
310
+ monotonic generation; `enrollKey` and `resetPivApplication` — the only
311
+ `withKeySession` callers that mutate vault state from inside the session
312
+ closure — check a `VaultSessionGuard` before writing, so a stalled native
313
+ call that eventually resumes after a retry has already taken over the lease
314
+ can no longer race a mutation in behind it. The existing "an abandoned call
315
+ frees the lease for a retry" availability behavior is unchanged.
316
+ - **Slot-replacement and reset guards (XR-008, XQ-014).** Replacing an occupied
317
+ Vault slot now also checks `vaultStore.enrolledSerialsAcrossChains` and
318
+ `meta.pendingRemoval`, not just the current chain's key list, so an explicit
319
+ slot-replacement consent can no longer erase a signer still live under
320
+ another chain or mid-removal — mirroring the guard `pivReset` already
321
+ applied. A new device-wide, non-secret `enrolledSerialRegistry.ts` (bare
322
+ serials only, never pubkeys or keys) closes `pivReset`'s remaining cross-
323
+ identity blind spot: a serial recorded as enrolled anywhere on the device —
324
+ even under a different wallet identity SecureStore can't enumerate — now
325
+ refuses a PIV reset unconditionally, with no override. The reset-consent copy
326
+ that overclaimed "no vault on this device claims" this key is corrected to
327
+ disclose the actual uncertainty instead.
328
+ - **Held signed withdraw/relock reconciliation (XR-006/INT-03).** The existing
329
+ "Finish the interrupted deposit" recovery (0.8.0) only recognized a held
330
+ deposit shape; a crash between `signAction` and `sendWith` on a withdrawal or
331
+ re-lock instead froze every later Vault operation with no vault-specific way
332
+ to clear it, and the resolve button treated any non-`'failed'` result —
333
+ including "nothing held" — as success. `resolveHeldVaultDeposit` now also
334
+ recognizes a held, signed vault-withdraw/vault-relock action and resends the
335
+ exact already-signed bytes (never a new transaction, never `abortAction`);
336
+ `VaultScreen` now surfaces "nothing held" as its own message rather than a
337
+ false success toast. New key `vault_resolve_held_deposit_none`.
338
+ - **Reload reconciles on every mount, not only an empty cache
339
+ (INT-07/XR-007).** `VaultScreen.reload()` previously called the chain-
340
+ authenticated `recoverVaultMetaFromOutputs` only when no local record existed
341
+ at all, so a stale-but-present cached record (e.g. surviving a reinstall)
342
+ could permanently wedge every later Vault action. It now always reconciles,
343
+ relying on the existing revision/key-set ratchet to keep the cache whenever
344
+ the scan doesn't supersede it, and falls back to the last-read cache (rather
345
+ than a hard error) when the scan itself fails or is offline.
346
+ - **`hasVaultMeta` race on cold start (INT-08).** `VaultContext` recomputed its
347
+ device-local `hasVaultMeta` flag only on ceremony-phase transitions, which on
348
+ a cold start settled to `false` before `WalletContext`'s async wallet-build
349
+ chain ever configured the vault scope — hiding an already-funded vault from
350
+ Home/Settings for the rest of the session. `vaultStore` gains an
351
+ `onScopeChange` subscription so the check re-fires the moment the scope
352
+ actually configures, not only at mount.
353
+ - **Chain-recovery integrity (Availability review; INT-01/INT-06/XQ-012).**
354
+ `wocChainLookup`'s output-status check previously failed open — any response
355
+ shape it didn't recognize, including a schema mismatch, was read as "unspent"
356
+ rather than "unknown," and "unknown" is the one answer
357
+ `recoverVaultFromChain` must never treat as spendable; it now requires an
358
+ explicit `spentTxId: null` before reporting unspent. Its address-history
359
+ lookup likewise silently mapped a rate limit, a 5xx, or a thrown exception to
360
+ an empty "no marker here" result, which could stop a scan short of a real,
361
+ higher-index deposit; it now throws on any non-2xx response or exception so
362
+ the scan's own problem-reporting (not a silent miss) handles it. The scan
363
+ loop itself had no bound on consecutive lookup/derivation failures — a
364
+ reproducible livelock, confirmed by a hung 2+ minute run against the unfixed
365
+ code — and is now bounded by `VAULT_RECOVERY_MAX_CONSECUTIVE_PROBLEMS`, with
366
+ a second cap (`VAULT_RECOVERY_MAX_CANDIDATES_PER_INDEX`) limiting how many
367
+ candidate transactions per index one scan will inspect (a marker address's
368
+ history is public, so a stranger could otherwise force unbounded decrypt-and-
369
+ discard work by dusting it). The bounded-scan abort now throws a
370
+ `VaultError('chain-scan-failed', ...)` with translated copy in every locale,
371
+ instead of a plain `Error` that fell through to generic fallback text. The
372
+ lookup's base58check encoding now uses `@bsv/sdk`'s own public
373
+ `Utils.toBase58Check` instead of an unaudited hand-rolled implementation.
374
+ - **RPC-boundary hardening (XR-019, XR-020, XR-102).** A non-admin (paired)
375
+ caller's `listOutputs` had no bound at all in `guardVaultAccess`; it is now
376
+ capped at 200 rows (25 when `includeTransactions` is set, since each such row
377
+ carries a full BEEF) and an existing offset ceiling, refused before the call
378
+ reaches the underlying wallet — a host whose connected app calls
379
+ `listOutputs` with a larger limit now gets `VaultAccessDenied` instead of a
380
+ large response. The address-rail, PeerPay, and Mandala/FT protocol namespaces
381
+ were never reserved the way Vault's own namespaces are, so a paired origin
382
+ could call the allowlisted `createSignature`/`getPublicKey` RPC methods
383
+ directly against them and receive a spend-ready signature for those rails
384
+ with no prompt at all; they are now denied the same way. A forged
385
+ `pending_aborts` entry naming the public `ADMIN_ORIGINATOR` could ride the
386
+ admin bypass straight past the vault-inventory check on replay; `guard.ts`
387
+ now opts a replayed admin abort into the same inventory check a non-admin
388
+ caller gets (`VAULT_ABORT_REPLAY_MARKER`), leaving a live interactive admin
389
+ abort unaffected.
390
+ - **Proof bar.** Six standing regression proofs now run as a single suite:
391
+ script acceptance for N=1..5 with an independent P-256 check, the CRT-forgery
392
+ harness, a clean-device I1 recovery proof, the I2 exclusion matrix (mnemonic-
393
+ only, stolen-DB-and-key, wrong PIN, unenrolled key, DB-without-mnemonic,
394
+ external caller), an I3 rail-isolation proof against every rail with a real
395
+ wallet/storage, and a no-production-mock proof that the mock YubiKey driver
396
+ is unreachable outside `__DEV__` at the runtime, source, build-profile, and
397
+ UI layers. `scripts/run-proof-bar.cjs` runs all six in order and prints a
398
+ pass/fail summary.
399
+ - **Production build gate.** `EXPO_PUBLIC_VAULT_ENABLED` is off again in the
400
+ production EAS build profile — Vault output creation stays disabled in
401
+ production until a v7 lock has actually been broadcast/mined and run once
402
+ against a physical YubiKey; development and dev-physical profiles keep it on.
403
+ An already-funded vault is not stranded by this: the entry point stays
404
+ visible whenever local Vault meta exists, and a full withdrawal is not gated
405
+ by the flag — only new deposits, re-locks, and withdrawal remainders are.
406
+
407
+ - **A held Vault transaction is never reported resolved on a bare status
408
+ claim (NEW-07).** `resolveHeldVaultDeposit` used to skip releasing a held,
409
+ already-signed Vault transaction when a chain service answered 'mined' or
410
+ 'known', so a wrong or malicious service made the app report success while
411
+ the signed bytes were never broadcast. It now always releases the wallet's
412
+ own signed bytes through the existing `sendWith` path and derives success
413
+ (and the broadcast vs already-known distinction) only from the toolbox's
414
+ confirmed release result.
415
+
416
+ ### Secrets and biometrics
417
+
418
+ - **Delete Wallet now actually erases everything, and fails closed if it can't
419
+ verify that (XQ-008, XR-107).** "Delete Wallet" closed the SQLite connection
420
+ but never deleted the underlying `.db` file(s) or the `walletDbRegistry`
421
+ entry — rebuilding with the same mnemonic silently reattached the "deleted"
422
+ wallet's full local history. `logout()` now purges every registered filename
423
+ for the identity/chain via `walletDbRegistry.purgeRegisteredDbFiles`, and
424
+ also sweeps the legacy plaintext secrets namespace
425
+ (mnemonic/recoveredKey/password) that lived outside the envelope scheme. Both
426
+ the legacy sweep's and the envelope KEK's deletions are now verified rather
427
+ than trusted blind: `deleteAllSecrets()`/`logout()`/`WalletConfigScreen` all
428
+ propagate a real success/failure result end to end, and a failed erasure now
429
+ shows a dedicated alert (new keys
430
+ `delete_wallet_failed_title`/`delete_wallet_failed_body`) and leaves the row
431
+ enabled for retry instead of reporting a clean deletion that didn't happen.
432
+ - **KEK provisioning can no longer be silently downgraded or hijacked (XR-108,
433
+ XR-109, XR-111, XR-116).** A self-consistent but forged `{policy:'degraded',
434
+ kekId}` sentinel could previously ride the app's own automatic degraded-to-
435
+ biometric upgrade and silently overwrite the real biometric KEK with an
436
+ attacker's key; `upgradeToBiometric()` now reads the existing authenticated
437
+ KEK first and refuses the upgrade outright if one is already there, and
438
+ `doUnlock()` no longer treats a failed/refused mandatory upgrade as a
439
+ successful unlock. A parseable-but-wrong-shape sentinel (a truncated write, a
440
+ future/rolled-back version) used to read as "no wallet ever provisioned" and
441
+ trigger a full KEK re-provision that orphans any other already-sealed secret;
442
+ it's now treated as corrupt, not absent. `destroyKek()` and the migration's
443
+ final legacy sweep now read back and retry a delete before reporting success,
444
+ rather than trusting an unauthenticated SecureStore delete that iOS silently
445
+ no-ops; `upgradeToBiometric()`'s own delete-then-trust step gets the same
446
+ read-back-and-refuse-on-survival treatment.
447
+ - **Legacy plaintext can no longer be served after a failed migration
448
+ (XR-112).** A cancelled or failed biometric-provisioning ceremony during
449
+ legacy-secret migration used to fall through to reading the raw,
450
+ unauthenticated pre-envelope mnemonic/recoveredKey directly — a fully
451
+ signing-capable wallet built from one declined OS prompt, no cryptographic
452
+ control involved. The migration-failure branch no longer special-cases a
453
+ plaintext read; a failed migration now correctly reports no secret at all and
454
+ retries on the next launch.
455
+ - **Custom ARC API token moved off plaintext storage (XR-106).** The optional
456
+ custom ARC endpoint's bearer token — sent on every broadcast to that endpoint
457
+ — was persisted in plain `AsyncStorage` and shown unmasked. It now lives in
458
+ the platform SecureStore (`core/services/arcTokenStorage.ts`), with a one-
459
+ time migration of any existing plaintext value; `WalletConfigScreen`'s token
460
+ field is now `secureTextEntry`.
461
+ - **Degraded (non-biometric) KEK provisioning is now disclosed (XR-114).** A
462
+ release device with no strong biometrics enrolled got an unauthenticated KEK
463
+ with the same "Protect your assets with Face ID or your fingerprint" promise
464
+ as a fully protected device. `BiometricAdvisoryModal` takes a `degraded` prop
465
+ that swaps in an honest disclosure (new key
466
+ `biometric_advisory_body_degraded`); `resolveProvisioningPolicy` is now re-
467
+ exported from the package root so a host screen can check it without a new
468
+ context method.
469
+ - Documented, not code-fixed: `kek.ts`'s delete-then-add rotation comment
470
+ overclaimed a guarantee that does not hold on Android — `deleteItemImpl`
471
+ there never calls `keyStore.deleteEntry`, so a rotation cycle silently reuses
472
+ the existing hardware key (XQ-013). Not exploitable on its own (the KEK value
473
+ is still fresh-random and still biometric-gated); fixing it needs a native-
474
+ module patch, recorded as an open assurance gap rather than fixed here.
475
+
476
+ ### Pairing and paired RPC
477
+
478
+ - **Superseded sockets are actually torn down (XR-018).**
479
+ `connect()`/`reconnect()` used to overwrite the live socket reference without
480
+ closing or detaching the one it replaced, so approving a second pairing (or
481
+ reconnecting a saved session) while one was already live left the first
482
+ socket's `onmessage` closure — still holding a valid `WalletClient`, topic,
483
+ and identity — decrypting and dispatching RPC for as long as the relay kept
484
+ it open. A `connectionGenerationRef` now gates every handler (`onopen`,
485
+ `onmessage`, `onerror`, `onclose`) so a superseded socket's already-in-flight
486
+ decrypt can no longer reach `handleRpc`. Disconnect and logout now actually
487
+ tear down the live paired socket too: `WalletConnectionContext` exports
488
+ `disconnectActivePairedSession()` so `WalletContext.logout()` (a React
489
+ ancestor of the connection provider) can call it directly, and
490
+ `ConnectionsScreen`'s Disconnect action calls the context's `disconnect()`
491
+ first rather than only flipping stored status and sending a best-effort
492
+ revoke message a non-cooperative peer can ignore.
493
+ - **Replay-watermark durability (XR-021).** The anti-replay sequence watermark
494
+ advanced in memory immediately before dispatching a mutating RPC call, with
495
+ its only durable write a fire-and-forget one in `disconnect()`/`onclose` — a
496
+ crash in between let a retained relay message be replayed and re-executed on
497
+ reconnect. The accepted sequence is now durably written and awaited before
498
+ dispatch, with the message dropped (never dispatched) if that write itself
499
+ fails; a follow-up serializes the check-write-advance sequence per connection
500
+ so two concurrent messages can't each pass a stale check and land their
501
+ durable writes out of order.
502
+ - **Origin display matches what gets approved (XR-023).** `PairScreen`'s
503
+ approval card used to render the raw, uncanonicalized origin with default
504
+ tail-truncation, so a long attacker-signed origin could show a trustworthy
505
+ prefix while clipping the real registrable-domain suffix — and
506
+ canonicalization only ran after the user had already looked and pressed
507
+ Approve. The card now canonicalizes on mount (showing the error state instead
508
+ of Approve/Reject if that fails) and truncates from the middle, so the domain
509
+ suffix always survives.
510
+ - **Private-network destinations refused (XR-024).** Neither the pairing origin
511
+ parser nor the relay-URL validator checked what class of address a hostname
512
+ named — a self-signed pairing payload could point straight at a
513
+ loopback/RFC1918/link-local/`.internal` address with no DNS trickery needed.
514
+ Both now refuse via a shared `isPrivateNetworkHost` check (a floor, not a
515
+ firewall — a public hostname that only resolves to a private address via DNS
516
+ rebinding is not caught).
517
+ - **Bounded relay discovery reads (XR-025).** A length-less, non-streaming
518
+ relay response could be buffered in full before its size was ever checked;
519
+ that one specific shape (no `Content-Length`, no stream reader) now fails
520
+ closed instead.
521
+ - **Aggregate RPC byte budget and a crypto-call size cap (XR-026).**
522
+ `MAX_IN_FLIGHT_RPC` only bounded message count — several concurrently in-
523
+ flight messages could each be near the 5 MiB per-message ceiling, multiplying
524
+ peak memory. Concurrent messages on one connection now also share a
525
+ `MAX_IN_FLIGHT_RPC_BYTES` budget equal to the existing single-message
526
+ ceiling. Separately, `encrypt`/`decrypt`/`createHmac`/`verifyHmac`/`createSig
527
+ nature`/`verifySignature` had no per-call size cap at all beyond the
528
+ transport ceiling; they now share a 1 MiB `cryptoPayload` ceiling (halved on
529
+ low-tier devices). A connected app sending an oversized crypto-call payload,
530
+ or enough concurrent large messages to cross the shared budget, now has the
531
+ call/message dropped or refused where it previously went through.
532
+ - **Saved-connection authenticity (XR-027).** A saved pairing record was plain,
533
+ unauthenticated `AsyncStorage` JSON, checked only against the wallet's own
534
+ public identity key on reconnect — insufficient to prove the record wasn't
535
+ substituted. Approval now stages a wallet-root HMAC over the connection tuple
536
+ (`connection authority` protocol namespace) that `add()` attaches to the
537
+ record; reconnect verifies it and treats a missing/failed tag as "needs re-
538
+ approval" (new key `reconnect_needs_reapproval`) rather than silently
539
+ trusting it. A companion, more limited hardening requires an explicit
540
+ confirmation naming the canonicalized origin before any reconnect at all (new
541
+ keys `reconnect_confirm_title`/`reconnect_confirm_message`) — full binding
542
+ would need an admin-scoped wallet threaded into `connect()`/`reconnect()`,
543
+ left as a larger follow-up.
544
+ - **Auto-approve authority disclosed at pairing time (XR-028).** Approving a
545
+ pairing silently grants that origin standing auto-spend authority (up to the
546
+ persisted per-request threshold and the shared rolling 24h cap added in
547
+ 0.8.0). The approval card now names both before Approve is tapped; the
548
+ underlying policy itself (a non-zero default threshold, and a cap shared
549
+ across all origins rather than per-origin) is unchanged and still flagged as
550
+ provisional pending product sign-off.
551
+
552
+ ### Backup and restore
553
+
554
+ - **Wallet Check no longer reads a different identity's backup cursor as this
555
+ wallet's own (XR-009).** `getBackupUploadState()` filtered by a bare,
556
+ unscoped key prefix, so a same-device wallet swap (logout, then a new
557
+ identity on the same install) could report the new wallet "backed up" using
558
+ the old one's leftover cursor. It now takes `(chain, pseudonym)` and filters
559
+ by the fully-scoped key; `logout()` sweeps `backupCursor-*` alongside the
560
+ existing balance-cache sweep; `WalletContext` exposes a new
561
+ `getBackupPseudonym(chain)` getter so the UI never needs the primary key
562
+ itself.
563
+ - **LocalPay and PeerPay in-flight state now survives encrypted backup (XR-011,
564
+ XR-012, XR-055).** `key_value_store` — and so a receiver's acknowledged-but-
565
+ not-yet-internalized Nearby/QR payment, an outbound PeerPay delivery
566
+ checkpoint, and every issued conventional-receive-address date — was entirely
567
+ outside the twelve toolbox-table `CHUNK_ENTITIES` the backup codec knew
568
+ about; a device loss before internalize/delivery completed could permanently
569
+ strand real money even with a perfect seed-plus-backup restore of everything
570
+ else. A new additive `appData` field on the existing per-chunk envelope
571
+ (dropped by any reader that predates it, so mixed builds keep working) now
572
+ carries `localpay_pending`, `peerpay_outbox`, and a new durable, count-capped
573
+ issued-receive-date history (`core/pay/receiveHistory.ts`) through push,
574
+ restore, and cross-device merge, applied through the same `setKeyValue` path
575
+ — never `internalizeAction`, broadcast, or abort — so a replayed row is
576
+ picked up by this device's own existing consumers exactly as if it had
577
+ written it itself. `WalletCheckScreen`'s repair loop now scans every recorded
578
+ issued-receive date instead of a fixed 30-day window, and the manual receive-
579
+ screen stepper widens to roughly ten years. Disclosed, not fixed: an
580
+ `appData`-only chunk can still never be sent alone (the toolbox's own sync
581
+ protocol treats an all-empty chunk as end-of-log), so isolated
582
+ LocalPay/PeerPay/receive-address activity in a window with no other wallet-
583
+ entity change can still miss a push — pinned end-to-end by a new test and
584
+ documented at each call site; `offline_actions` and `token_linkage_payloads`
585
+ remain out of scope for this pass.
586
+ - **Restore-side resource bounds (XR-013).** Neither the remote sync index
587
+ (`RemoteSyncReader.ensureIndex()`) nor the restore-side body reader had any
588
+ cap beyond a server-supplied page-size hint and a time deadline. A
589
+ `MAX_INDEX_ENTRIES` ceiling (50,000) and a `MAX_RESTORE_RESPONSE_BYTES` check
590
+ against `Content-Length` (checked before any body reader is invoked) now
591
+ bound both — partial, since a response that omits `Content-Length` entirely
592
+ still can't be bounded on this platform's `fetch`.
593
+ - **A restored chunk must match its own index entry (XR-014).**
594
+ `RemoteSyncReader.fetchAndDecode()` decrypted whatever bytes were returned
595
+ for a sequence without checking them against that sequence's own indexed
596
+ size/hash, so a malicious or compromised backup host could serve one
597
+ sequence's genuinely-authentic ciphertext back under a different sequence
598
+ number. Restore now rejects a length/sha256 mismatch. Documented as not a
599
+ full fix: the envelope still doesn't bind device/generation/sequence into
600
+ what it authenticates, and there's no persisted rollback checkpoint — both
601
+ need a broader format change.
602
+ - **Every device in a multi-device manifest is now replayed on import
603
+ (XR-015).** `restoreOnImport` used to replay only the single highest-ranked
604
+ device's log; each device's log is an independent, non-overlapping history,
605
+ so a second device's unique records (a change output, a BRC-29 receipt) could
606
+ be permanently unreplayed after restore. It now replays every device present
607
+ in the manifest into the same storage, merging by record identity exactly as
608
+ ordinary live multi-device sync already does.
609
+ - **Clock-rollback recovery (XR-016).** An incremental push window only ever
610
+ advances forward; a device clock moving backward could permanently orphan a
611
+ record stamped below an already-closed window. `PushCursor` now tracks the
612
+ highest wall-clock time ever observed and forces a full-snapshot rotation
613
+ whenever the current time falls behind it.
614
+ - Locked, not changed: Android's `expo.android.allowBackup: false` (shipped in
615
+ 0.8.0) now has a regression test guarding it (XQ-005); the iOS backup-
616
+ exclusion question and the malformed-but-SQLite-magic-passing import question
617
+ remain open, needing a real device build to exercise.
618
+
619
+ ### Mandala tokens
620
+
621
+ - **Legacy settlement rows can no longer hide from the abort guard (XR-033).**
622
+ `token_settlements.reference` shipped later than the table itself, added by a
623
+ bare nullable `ALTER` with no backfill — every pre-migration row reads
624
+ `reference: undefined` forever, making it invisible to the abort guard's
625
+ lookup regardless of which action is later aborted. The same migration step
626
+ now backfills a blocked legacy row's reference from the `transactions` table
627
+ (the same mapping `abortAction` itself matches against); anything the
628
+ backfill can't resolve is covered by a coarser
629
+ `hasUnresolvedLegacyBlockedRows()` check that refuses every abort while any
630
+ such row exists, rather than risk releasing inputs a legacy row still has a
631
+ claim on.
632
+ - **Token-abort guard fails closed (XR-034, XR-035).** A settlement-lookup
633
+ fault or a not-yet-built runtime previously read as "no blocking row, abort
634
+ is safe" — a transient DB error is not evidence a payment is safe to release.
635
+ The guard now distinguishes "no Mandala endpoints configured for this chain"
636
+ (provably no token action) from "the runtime hasn't built yet" or "a lookup
637
+ faulted" (real rows may be unreadable), refusing in the latter two cases. The
638
+ handle rail's settlement-journal write after a hand-over — the only durable
639
+ evidence a transfer happened — is now retried on a transient fault
640
+ (`upsertSettlementDurably`) rather than best-effort, closing the same root
641
+ cause XR-035's regression test locks. `abortPeerPayNosend` also now checks
642
+ its own `abortAction` result instead of assuming success.
643
+ - **Token-bearing offline holds aren't drainable until their journal lands
644
+ (XR-036).** A token payment's offline-queue row used to go straight to
645
+ `'queued'` (drainable) before its settlement journal write was confirmed; a
646
+ process kill or transient write fault in that window let the automatic drain
647
+ post a token transaction the overlay never admitted.
648
+ `holdSentPaymentOffline`, `parkSentPaymentOffline`, and
649
+ `releaseParkedPayment` now keep a token-bearing row at `'parked'` until the
650
+ journal write is confirmed.
651
+ - **Cached admissions are scoped to the vout that actually needs them
652
+ (XR-038).** A genuine, verified admission for any output of a multi-output
653
+ token transaction previously stood in for the whole transaction's submission
654
+ — a payer's own admitted change output could carry an unrelated, never-
655
+ admitted output along with it. Admission caching now requires every vout the
656
+ current walk actually needs to be inside the admission's own
657
+ `outputsToAdmit`, backed by a new `TokenSettlementRow.relevantVout` column
658
+ and the existing (previously unused) parent-vout edge data.
659
+ - **Fail closed on an unreliable token-input classification (XR-039).** A
660
+ `listTokenOutpoints()` failure used to forward a `createAction` unchanged
661
+ instead of forcing Mandala's own consent review — a transient listing fault
662
+ or a basket over 10,000 outputs silently skipped the one thing that routes a
663
+ token spend's inputs to a token-aware review. It now forces the Mandala label
664
+ on any listing failure, and the listing itself paginates to completion
665
+ instead of reading one capped page.
666
+ - **Every asset of a multi-asset approval is now shown (XR-040).**
667
+ `PermissionSheet` rendered only the primary asset/amount fields of what could
668
+ be a multi-asset `createAction`/`internalizeAction` — a connected app could
669
+ place an innocuous asset first and an unshown transfer right behind it in the
670
+ same approval. Every line is now rendered (numbered when more than one), and
671
+ a malformed or oversized `lines` payload now blocks approval outright instead
672
+ of falling back to the old primary-only view.
673
+ - **Relinquish consent now names what's being removed (XR-041).** "Wants to
674
+ remove a Mandala token holding" named no asset, amount, or outpoint. The
675
+ prompt now resolves the target against this device's own current basket
676
+ listing (never the caller's claim) and names asset, amount, and outpoint —
677
+ refusing the whole call if it can't be conclusively resolved.
678
+ - **A verified admission can't be undone by a later unsigned refusal
679
+ (XR-042).** An overlay's positive verdicts are signature-verified; its
680
+ negative (`refused`/`evicted`) verdicts are raw, unauthenticated HTTP — but
681
+ both were fed to settlement state unconditionally. A row already carrying a
682
+ verified admission for a txid is now left alone (or treated as a stall)
683
+ rather than downgraded by a later unsigned refusal.
684
+ - **Token decimals bounded everywhere one is read (XR-043).** An extreme
685
+ `decimals` value from a session QR or a registry entry had no upper bound;
686
+ `formatTokenAmount(500, Number.MAX_SAFE_INTEGER)` reliably threw `RangeError:
687
+ Invalid string length`, and the crash re-triggered on every later render
688
+ since the metadata persists. Decode, registry resolution, formatting/parsing,
689
+ and the input mask now all clamp or reject outside `[0, 18]` — a host calling
690
+ `formatTokenAmount`/`parseTokenAmount` directly with an out-of-range value
691
+ now gets `null` back instead of a thrown exception.
692
+ - **Issuer and asset fingerprint shown before send (XR-044).** Two assets
693
+ sharing a ticker (a look-alike distributed by a malicious issuer) were
694
+ visually indistinguishable through the whole select-to-send flow. The asset
695
+ switcher, asset picker, and the Send review step now all show `issuerName ·
696
+ fingerprint` alongside the ticker.
697
+ - **Real token actions now reach the consent gate (XR-037).** Two different
698
+ constants both named `MANDALA_ACTION_LABEL` — one for home-screen
699
+ recognition, one for the P-routed `listActions` consent gate — and only the
700
+ former was ever applied to a nearby build or a handle-rail credit, so a real
701
+ Mandala action's metadata (txid, satoshis, description) was visible to a
702
+ paired caller's `listActions` with no consent prompt of any kind. Both labels
703
+ are now applied at every write site; `guard.ts`'s external-facing
704
+ `sanitizeAction` also now strips `customInstructions` directly as defense in
705
+ depth, rather than relying solely on a vendored patch doing it one layer
706
+ down.
707
+ - **Token conservation enforced before crediting a nearby tip (XR-099).**
708
+ `verifyFramePayment`'s token branch checked ownership, asset, and ancestry-
709
+ admission, but never that token input value covers token output value —
710
+ Mandala's own COVER walk has no notion of amount at all. A payer could spend
711
+ a small admitted coin into an output naming any larger amount and have it
712
+ credited. A new `tokenConservationHolds` check sums the tip's own direct
713
+ token inputs against its outputs for the frame's asset and refuses
714
+ (`not_covered`) if they don't cover it.
715
+ - A held withdraw/relock now resolves cleanly for tokens too, and
716
+ `wrapAbortActionForSettlements`/`processAction` fail the whole batch closed
717
+ rather than report an indeterminate held/not-held classification when
718
+ `token_settlements` can't be read for a broadcast decision (XR-045) — see
719
+ Wallet repair, proofs, headers, and broadcast below for the shared broadcast-
720
+ guard change.
721
+
722
+ ### Nearby / LocalPay
723
+
724
+ - **Pending-abort queue integrity and authenticated replay (XR-088, XR-102).**
725
+ A read/parse failure against the local pending-abort queue collapsed to
726
+ "empty," so the next queue write silently erased every other durable, not-
727
+ yet-replayed abort reference; a fault now refuses the write instead of
728
+ overwriting. Every queued abort reference is now HMAC-tagged at write time
729
+ (`pending abort authority` protocol namespace) and re-verified before replay
730
+ — a forged or untagged `pending_aborts` KV entry naming a live action
731
+ reference is now dropped rather than replayed, surfaced to the user via a new
732
+ notice (keys `local_pay_pending_abort_dropped_title`/`_body`) pointing at
733
+ Activity's manual per-row cancel.
734
+ - **Bounded inbound frame/ack decode (XR-090).** The shared base64-decode-then-
735
+ AES-GCM-decrypt-then-parse layer every transport (AWDL, Nearby, BLE) funnels
736
+ through had no size ceiling of its own. It now rejects an oversized encoded
737
+ or decoded payload before `atob()`/decrypt/parse ever runs (reusing
738
+ `@bsv/air-gap`'s existing 64 KiB frame ceiling; a much smaller ceiling for
739
+ acks); the Android Nearby native receive path is mirrored for the same gap
740
+ but is unverified without a device build.
741
+ - **Never trust the payee's QR ticker/decimals for a real, unresolved holding
742
+ (XR-091).** A local ticker-resolution failure for a real, spendable holding
743
+ used to fall back to the payee's own unauthenticated session ticker/decimals.
744
+ It now fails closed to an "asset unidentified" state that disables Send,
745
+ rather than adopting the QR's claim — a brand-new, never-before-seen offline
746
+ asset (no local holding at all) is unaffected, since it has no known figure
747
+ to override.
748
+ - **A malformed pending queue is quarantined, not read as empty (XR-092).** Any
749
+ syntactically valid non-array JSON under the LocalPay pending key used to
750
+ silently become an empty queue — and the very next save then destructively
751
+ overwrote whatever it actually held. It now takes the same quarantine-and-
752
+ notify path a JSON parse failure already does.
753
+ - **Settlement-ack verification is bound to the payee's own output (XR-093).**
754
+ A verified admission for a sibling output on the same transaction (e.g. the
755
+ payer's own change) previously counted as proof of the payee's own
756
+ settlement. Verification now requires a matching output index too.
757
+ - **Two remaining unconditional-release paths on a decline are closed (XR-095,
758
+ XR-103).** WalletHomeScreen's generic Activity "Abort" action could release a
759
+ parked nearby payment's inputs with no chain-status check, bypassing the
760
+ dedicated cancel-parked flow's gate; it now respects the same `!parked` guard
761
+ the row's own action chip already applied. A decline whose chain status is
762
+ genuinely unresolved — or whose txid the chain already shows — is now parked
763
+ (or refused) rather than released, closing the remaining window where a lying
764
+ or merely-early decline could race a real payment.
765
+ - **Ambiguous send outcomes are now parked, not dead-ended (XR-096).** A screen
766
+ unmount mid-`radio.send()`, or a radio failure whose frame is too large to
767
+ fall back to a QR, previously left a signed reservation with no durable
768
+ trace. Both now park the payment (the oversized case gets a real recovery
769
+ path too, since a message-box resend has no QR size limit).
770
+ - **Single-flight guards on Send and on session settlement (XR-097, XR-098).**
771
+ Nearby Send lacked a synchronous re-entrancy guard, so two overlapping
772
+ presses could each build and reserve their own noSend action with only one
773
+ recoverable; the session claim itself (check, persist, burn) was three
774
+ separate operations that a radio delivery could race against a QR scan for
775
+ the same session. Both are now atomic — a single synchronous latch on Send,
776
+ and a single locked `claimAndSavePending` for the settlement claim.
777
+ - **Overlay unreachability is no longer read as "not admitted" (XR-100).**
778
+ `cancelParkedPayment`'s token check only special-cased a definite
779
+ `'admitted'` verdict; a genuinely unreachable overlay fell through to the
780
+ same-as-offline BSV check with no verification at all. It now routes an
781
+ unreachable/unavailable overlay through the same "unverifiable" confirmation
782
+ gate the BSV-rail check already uses, once a settlement row proves the
783
+ payment was genuinely handed over.
784
+ - **Oversized notes can no longer strand a payment (XR-101).** A received peer
785
+ note has no wire-level length cap; `internalizeAction`'s real 2000-byte
786
+ description limit throws rather than truncating, so a hand-crafted oversized
787
+ note could make every retry fail until the pending-attempts ceiling
788
+ permanently stranded an already-accepted payment. The constructed description
789
+ is now truncated on a UTF-8 byte boundary before `internalizeAction` is
790
+ called (display-only; the payment itself is unaffected).
791
+ - **Overlay identity anchored to device config (XR-104).**
792
+ `buildTokenPaymentFrame`'s exported, documented entry point read the payee's
793
+ session-claimed overlay identity/URL directly, which could redirect this
794
+ device's `SpecificKeyLinkage` disclosure to a verifier of the payee's
795
+ choosing; the app's own single caller already guarded against this ad hoc,
796
+ but the exported function itself did not. It's now read from device config,
797
+ never the session.
798
+ - **Stale offline-queue bookkeeping is reconciled (XQ-009).** A
799
+ `networkAlreadyHas` check trusted a bare `'mined'/'known'` status string with
800
+ no proof — now also requires a validated Merkle proof
801
+ (`EntityProvenTx.fromTxid`) against this device's own chain tracker before
802
+ treating that as confirmation the network already has a transaction.
803
+ Separately, a row legitimately marked `'sent'` had no path back to
804
+ reconciliation if its backing request later moved to `'invalid'` (a reorg, a
805
+ proof timeout); `reconcileStaleSentActions()` now revisits and reclassifies
806
+ such rows.
807
+
808
+ ### PeerPay / handle rail
809
+
810
+ - **Duplicate-delivery detection narrowed to the structured code (XR-046).**
811
+ `isDuplicateMessageError` matched free prose in a thrown error's message,
812
+ entirely attacker/host-controlled; it now requires `@bsv/message-box-
813
+ client`'s own structured `ERR_DUPLICATE_MESSAGE` code, which the client
814
+ validates before embedding.
815
+ - **Inbox shape-check bounded (XR-047).** An unbounded
816
+ `transaction`/derivation-string length in a poisoned inbox message re-
817
+ triggered a full scan on every poll and background credit pass; both are now
818
+ capped against the existing shared `walletArgLimits` ceilings before the scan
819
+ runs.
820
+ - **Retried entries are re-verified before broadcast (XR-048).** A retried
821
+ outbox entry's persisted `txid` was handed to `broadcastNoSend` with no check
822
+ that it actually corresponded to the entry's own token; a tampered store or
823
+ restore could point it at an unrelated pending action. The txid is now re-
824
+ derived from the entry's own token and required to match before broadcasting.
825
+ - **Abandon no longer releases inputs the recipient may already hold
826
+ (XR-049).** Abandoning a delivered/delivering handle payment used to call
827
+ `abortAction` whenever it happened to succeed — never safe once a signed
828
+ token may already be with the recipient. Abandon now never calls
829
+ `abortAction`; it only drops the local tracking row. A companion fix keeps
830
+ the row (with the error recorded) rather than removing it unconditionally
831
+ when an abort attempt during abandon fails or throws.
832
+ - **Broadcast confirmation requires a positive result (XR-050).** Any
833
+ `sendWith` result shape other than an explicit matching `'failed'` entry was
834
+ previously read as success; it now requires an explicit match with
835
+ `'sending'`/`'unproven'` status, failing closed on
836
+ missing/empty/unrelated/duplicate/unknown-status results.
837
+ - **Resend requests are authenticated against the recorded recipient
838
+ (XR-051).** A `resend_request` control message from any authenticated sender
839
+ with a guessed real txid could force the full resend workflow repeatedly,
840
+ forever. It's now checked against the payment's actual recorded/resolved
841
+ recipient before any work happens.
842
+ - **Retry side effects re-read the row first (XR-052).** A retry's network
843
+ calls could complete anyway even after a concurrent user-triggered
844
+ abandon/cancel removed the outbox row mid-flight. The row is now re-fetched
845
+ immediately before each side-effecting call, and the retry stops cleanly if
846
+ it's gone.
847
+ - **Overridden delivery host shown before send (XR-053).** A `peerpay:` link's
848
+ `url` extension can silently redirect delivery to a different MessageBox host
849
+ with no identity binding; the review screen now shows the host whenever one
850
+ is link-supplied (new key `pay_review_delivery_host`) — the underlying trust
851
+ gap (no signed delivery receipt) is unchanged and not claimed as closed.
852
+ - **Generic Activity abort refuses an unaccounted-for send (XR-012).** The
853
+ Activity screen's generic Abort button had no PeerPay awareness at all; a
854
+ restored wallet with no outbox row for an already-delivered/delivering send
855
+ could have its inputs released on a payment the recipient may already hold. A
856
+ new `isAbortSafe` check (also used internally by the existing cancel flow)
857
+ now refuses it (new key `tx_abort_maybe_delivered`).
858
+
859
+ ### Address rail and the Pay screen
860
+
861
+ - **Bounded sweep work (XR-054).** A dusted receive address's sweep re-fetched,
862
+ verified, and internalized every distinct-txid UTXO on every 30-second pass
863
+ with an O(n^2) grouping step; sweeps are now capped at 200 distinct
864
+ transactions per pass (anything left over is picked up on the next pass —
865
+ nothing is lost or double-credited) with the grouping made linear.
866
+ - **Sweep receipt amount comes from the verified transaction (XR-056).** The
867
+ "Received" overlay and background notification summed the untrusted indexer
868
+ listing's claimed value rather than the cryptographically-committed output
869
+ amount on the already-parsed, already-verified transaction; the wallet's
870
+ actual balance was never affected, but the displayed figure could be wrong.
871
+ It now sums from the parsed transaction's own output.
872
+ - **`sendToAddress` rejects non-P2PKH addresses itself (XR-057).** The P2SH-
873
+ rejection guarantee this rail relies on lived entirely inside `@bsv/sdk`'s
874
+ internals with no repo-owned check; `sendToAddress` now rejects any non-
875
+ mainnet/testnet-P2PKH version byte before building a locking script,
876
+ independent of the SDK.
877
+ - **Bounded UTXO listings and BEEF/hex response sizes (XR-059).** An oversized
878
+ indexer response could force unbounded per-txid network fanout and unbounded
879
+ hex-decode/merge work; `getUtxosForAddress` is now capped at
880
+ `MAX_UTXO_LISTING_ROWS` (2000) and hex bodies at `MAX_HEX_RESPONSE_CHARS`
881
+ (8,000,000) on both the address-sweep and PeerPay reorg-repair paths, and
882
+ later extended to `WalletContext.refreshProof`'s own merkle-BUMP and raw-tx
883
+ hex reads.
884
+ - **Every conventional-receive date is scanned for recovery, not a fixed window
885
+ (XR-055)** — see Backup and restore above; the address-rail side of that fix
886
+ widens `recoveryDatesToScan` and the manual receive-screen stepper.
887
+ - **Synchronous send latches (XR-061, XR-097).** `UniversalSend.handleSend` and
888
+ Nearby's own send path each relied only on async React state for mutual
889
+ exclusion, so two press activations landing in the same JS turn could
890
+ independently invoke a value-moving rail call. Both now set a synchronous
891
+ ref-backed latch as their first statement, before any `await`.
892
+
893
+ ### Wallet repair, proofs, headers, and broadcast
894
+
895
+ - **Verify the alleged spender before marking a UTXO unspendable (XR-031).**
896
+ Wallet Check committed `spendable:false` as soon as two chain-service sources
897
+ agreed an output was spent, before ever checking that the alleged spender's
898
+ own inputs referenced that outpoint. It now fetches and verifies the
899
+ spender's BEEF first and requires an actual matching input.
900
+ - **Stuck-reservation release is corroborated (XR-032).**
901
+ `releaseStuckReservations` restored every input reserved by a locally
902
+ `'failed'` transaction unconditionally, with no check against the safer
903
+ `proven_tx_reqs` status set the sibling repair path already uses; it now only
904
+ releases a reservation whose spender's proof-request rows are all in the
905
+ safe/terminal set.
906
+ - **Header-sync and broadcast-log bounds (XR-060).** A `getHeaders` response
907
+ could return far more than was requested with no check on the returned
908
+ length; header sync now truncates to exactly what was asked for. Broadcast
909
+ response bodies logged in full with no size cap; logging is now capped at
910
+ 2000 characters (classification still runs over the full body).
911
+ - **Orphan-mempool is no longer treated as a double spend (XR-062).** ARC's
912
+ `SEEN_IN_ORPHAN_MEMPOOL` status — an ordinary propagation-timing condition,
913
+ not a proven conflict — was classified identically to a real double-spend and
914
+ triggered the same terminal rejection cascade for a chained/offline payment.
915
+ It now sets a retryable service-error instead.
916
+ - **Broadcast body reads are bounded by time and size (XR-063, and the XR-060
917
+ remainder).** The ARC/WhatsOnChain broadcast providers cleared their timeout
918
+ as soon as headers arrived, before reading a potentially stalling or
919
+ oversized body — hanging the whole broadcast attempt with no fallback ever
920
+ tried. The body read is now raced against the same deadline as the
921
+ connection, and capped at `MAX_BROADCAST_BODY_BYTES` (1,000,000 bytes).
922
+ - **Custom ARC endpoint policy (XR-064).** A custom ARC URL was persisted with
923
+ no scheme/origin validation, and a saved API token could silently carry over
924
+ to a newly entered, unrelated host. It now requires https (with a loopback
925
+ dev exception, new key `arc_url_https_required`), clears a token when the
926
+ origin changes, and requires an explicit accepted ARC status or matching txid
927
+ before treating a broadcast response as successful (closing a bare `200 {}`
928
+ response that previously suppressed the real HTTPS fallback chain).
929
+ - **Backup/Mandala/MessageBox origin policy (XR-065).** These three
930
+ configurable origins had no scheme policy at all (unlike the handle
931
+ registry's own); they now share the same https-required
932
+ (loopback/RFC1918-dev-exception) check.
933
+ - **`taalApiKey` no longer aliases `whatsOnChainApiKey` (XR-066).** A key
934
+ scoped to WhatsOnChain was silently sent to TAAL's own broadcast origin too.
935
+ A host that relied on the old fallback must now set
936
+ `EXPO_PUBLIC_TAAL_API_KEY` explicitly (README updated); no wallet funds were
937
+ ever at risk from this, only quota/credential exposure.
938
+ - **Unknown chain string fails safe to testnet, not mainnet (XQ-011).** A
939
+ corrupted or garbage persisted network value resolved broadcast to the live
940
+ mainnet endpoint, the most privileged branch — every sibling consumer of the
941
+ same value already collapsed safely. It now matches them.
942
+ - **`recordProof`'s directly-fetched raw tx is hash-checked (XR-029).** The
943
+ BUMP/root check only proves the requested txid is confirmed; nothing checked
944
+ that a separately-fetched raw-tx response actually hashed to that txid before
945
+ completing a transaction on it. It now requires `doubleSha256(rawTx) ===
946
+ txid`.
947
+ - **Only an authoritative 404 proves chain absence (XR-030).** A manual proof
948
+ refresh treated any non-2xx response (a rate limit, a 5xx, an auth error)
949
+ identically to a definitive 404 and released reserved inputs on a stale row;
950
+ now only a 404 counts as proof of absence.
951
+ - **Proof-of-work required outside the validated header window (XR-068).** A
952
+ miss or reorg-tail chaintracks answer was trusted on a bare, unauthenticated
953
+ `merkleRoot` with no PoW/linkage check at all; it's now required to satisfy
954
+ its own declared target before being trusted or cached (partial — no chain-
955
+ of-custody to a trusted checkpoint yet, so a forger who could actually mine a
956
+ low-difficulty historical header is still out of scope of this fix).
957
+ - **Token broadcast guard fails closed on a read fault (XR-045).**
958
+ `tokenSettlementTxids()` collapsed a genuine `token_settlements` read failure
959
+ to the same empty result as "no token requests in this batch," so a transient
960
+ fault could let an unadmitted token request post straight past overlay
961
+ admission. It now throws on a read failure, and the one caller that can
962
+ actually broadcast holds the whole batch rather than deciding off an
963
+ incomplete answer.
964
+ - **No overlapping background task passes (XR-105).** `TaskSendOffline` and
965
+ `TaskBackupPush` had no dedup guard against a watchdog restart racing a hung
966
+ pass, unlike two sibling tasks already protected; both now share the same in-
967
+ flight guard.
968
+
969
+ ### Database import and export
970
+
971
+ - **CSV export can no longer carry a live spreadsheet formula (XR-078).** A
972
+ remote-supplied note beginning with `=`, `+`, `-`, `@`, a tab, or a CR became
973
+ a live formula on open in a spreadsheet application. Untrusted free-text
974
+ columns (description/tags/labels) are now formula-neutralized (OWASP leading-
975
+ apostrophe mitigation); a follow-up fix scoped that neutralization away from
976
+ the trusted, app-derived numeric/txid/status/blockHeight columns it had
977
+ initially been applied to as well, which it had been corrupting (e.g. turning
978
+ every outgoing amount into text).
979
+ - **Unencrypted export now warns first (XR-086).** `exportAllWalletDatabases()`
980
+ hands a raw, unencrypted SQLite image to the OS share sheet with no
981
+ passphrase step; a warning naming what the file contains, with a real cancel,
982
+ now appears first (new keys
983
+ `export_unencrypted_title`/`export_unencrypted_message`). Full at-rest
984
+ encryption is a larger, deferred product decision (the importing device would
985
+ need a way to get the key back).
986
+ - **Import file size ceiling (XR-087).** A picked backup was read into memory
987
+ with no size check at all. A 256 MiB ceiling is now enforced against both the
988
+ picker-reported size and the actual read length before any deserialization
989
+ (new keys `import_oversized_file`/`import_oversized_file_detail`).
990
+ - **Raw database imports are authenticated before becoming active (XR-079, and
991
+ the narrower XR-080/XR-084 variants it also closes).** Identity, chain, and
992
+ freshness were derived purely from the picked filename, never the file's
993
+ contents — a same-filename import could overwrite the live database, a same-
994
+ suffix foreign database could win the next build's file selection, and the
995
+ spendability-reconciliation pass an encrypted restore always runs was skipped
996
+ entirely. An import now requires the deserialized image's own settings row to
997
+ match the currently unlocked wallet's identity and chain, rejects a filename
998
+ timestamp more than 5 minutes in the future, always synthesizes a destination
999
+ filename distinct from every live or registered one (never reusing the picked
1000
+ name), and routes through the same `reviewSpendableOutputs` reconciliation
1001
+ pass an encrypted restore uses.
1002
+ - **Imported queues and caches are quarantined at the import boundary, never
1003
+ trusted as live state (XR-081, XR-083, XR-085).** A wholesale-imported
1004
+ database could seed the live LocalPay pending queue with a frame that never
1005
+ passed ownership/session/asset verification (now stripped on import), plant a
1006
+ forged `proven_txs` row that could later let a forged proof pass as chain-
1007
+ proven (now stripped), or silently auto-rebroadcast an already-aborted
1008
+ `queued`/`posting` `offline_actions` row the instant the app goes online (now
1009
+ rewritten to a new `'import_hold'` status the automatic drain never selects,
1010
+ surfaced in Activity as "Held (imported)" — new key `tx_status_import_hold` —
1011
+ with no UI yet to promote a held row back to queued, a deliberate, disclosed
1012
+ gap). `refreshProof` and the WalletHomeScreen activity query both recognize
1013
+ `'import_hold'` so a stale imported row can't be mistaken for a failed one
1014
+ and have its inputs released via the manual Refresh action.
1015
+ - **Weakened or extra schema objects are rejected, not silently kept forever
1016
+ (XR-082).** A crafted image could keep an allowed table/index's name while
1017
+ dropping a `UNIQUE`/`NOT NULL` constraint, or smuggle in an extra
1018
+ trigger/view/virtual table/table — `CREATE ... IF NOT EXISTS` never repairs
1019
+ an existing weakened definition. Import now compares each allowed object's
1020
+ actual definition (as an order-independent, whitespace-normalized
1021
+ column/constraint set, so a genuine additive migration's reordered columns
1022
+ are still tolerated) against a disposable in-memory reference schema, and
1023
+ rejects anything outside the allow-list entirely.
1024
+
1025
+ ### Identity, registry, trust, and network destination policy
1026
+
1027
+ - **A shared public-destination check closes several SSRF-shaped gaps
1028
+ (XR-073).** Nothing previously bound a foreign paymail domain's advertised
1029
+ capability templates or SRV target, a user-typed trust-provider domain, a
1030
+ trust manifest's icon URL, a search-result avatar, or the identity-avatar
1031
+ resolver's http(s)/UHRP fallback to an actual public internet destination —
1032
+ each could be pointed at a loopback/RFC1918/link-local address with no DNS
1033
+ trickery needed. A shared `isPublicHttpsUrl`
1034
+ (`core/net/publicDestination.ts`) — a floor, not a firewall, since there's no
1035
+ synchronous DNS resolution on this runtime to catch rebinding — is now
1036
+ applied at all of them: handle-registry discovery, `TrustScreen`'s manifest
1037
+ fetch and icon prefetch, `searchIdentities()`'s avatar mapping, and
1038
+ `resolveAvatarURL`'s http(s)/UHRP branches.
1039
+ - **Trust-manifest fetch bounded and its deadline covers the body (XR-074,
1040
+ XR-075).** The manifest fetch had no byte cap at all, and its timeout was
1041
+ disarmed as soon as headers arrived — a slow or dripping body could hang the
1042
+ loading state forever. It's now capped at 64 KiB with the same deadline
1043
+ racing the body read, not just the connection.
1044
+ - **Downgraded trust-provider imports refused (XR-076).** An explicit `http://`
1045
+ domain was accepted verbatim, and a manifest fetch followed redirects with no
1046
+ origin check. Both are now refused outright — an explicit `http://` domain
1047
+ fails before any request, and the manifest fetch fails closed on any
1048
+ redirect.
1049
+ - **Handle-registry bodies bounded by byte count (XR-077).** Every handle-
1050
+ registry read shared one timeout-only body reader; a foreign or compromised
1051
+ registry could pace an unbounded body just under the deadline. A 256 KiB
1052
+ ceiling now applies before any JSON parse.
1053
+ - **Deep-linked identity keys are never rendered as "Your Identifier"
1054
+ (XR-070).** A crafted `bsv-wallet://identifier?identityKey=...` deep link
1055
+ could render an attacker's key as the user's own QR/copy/share target. The
1056
+ screen now always fetches and displays only the wallet's own key; a route-
1057
+ supplied key is only ever compared against it, never rendered.
1058
+ - **Trust-on-first-use key pinning for paymails (XR-071).** A compromised or
1059
+ malicious registry — including the pinned one — could mint a fresh
1060
+ certificate redirecting an already-resolved paymail to a different key. The
1061
+ first key ever resolved for a paymail is now pinned; a later certificate
1062
+ under a different key for the same paymail is dropped regardless of which
1063
+ registry served it (a from-scratch resolution of a paymail never seen before
1064
+ is inherently unprotected by TOFU, and is out of scope).
1065
+
1066
+ ### Vendored toolbox patch
1067
+
1068
+ - **`abortAction` fails closed on an unresolved chain status (XQ-016).**
1069
+ `@bsv/wallet-toolbox-mobile` 2.14.0's `StorageProvider.abortAction` treated a
1070
+ thrown/timed-out/non-success chain-status lookup as safe to invalidate and
1071
+ release a `nosend` action's reserved inputs — including one already handed to
1072
+ a counterparty over PeerPay or LocalPay, turning a chain-status outage into a
1073
+ payer-side double-spend race. The patch (`patches/@bsv+wallet-toolbox-
1074
+ mobile+2.14.0.patch`) now retries the chain-status check once and, if still
1075
+ unresolved, throws instead of invalidating — every in-app `abortAction`
1076
+ caller already handles a thrown result sensibly, and Vault's own abort calls
1077
+ (strictly unsigned-only) are unaffected. Verified end to end through Vault's
1078
+ own retry-heal path, not only in isolation.
1079
+
1080
+ ### Storage schema
1081
+
1082
+ - **`transactions` table gains the vendor's BRC-177 `noSendExpiry*` columns
1083
+ (NEW-01).** `@bsv/wallet-toolbox-mobile` 2.14.0 reads and writes
1084
+ `noSendExpiryState`/`noSendExpiryReclaimTxid` and related columns this
1085
+ package's schema never added — every `'failed'` transition of a signed
1086
+ `nosend` transaction (an aborted action, a failed broadcast, a proof-check
1087
+ timeout, or the periodic invalid-request sweep) threw "no such column"
1088
+ instead of completing, wedging state inconsistently app-wide. A new
1089
+ idempotent `ensureTransactionsColumns` migration (called from `createTables`,
1090
+ so both a fresh and an existing database pick it up) adds the columns, and
1091
+ `findSql.ts`'s column lists are updated so a `noRawTx`-projected read doesn't
1092
+ silently drop them.
1093
+
1094
+ ### Copy and translations
1095
+
1096
+ 24 new keys across the sections above, in all 12 languages:
1097
+ `delete_wallet_failed_title`, `delete_wallet_failed_body`,
1098
+ `vault_resume_draft_confirm_title`, `vault_resume_draft_confirm_body`,
1099
+ `vault_resume_draft_confirm_use`, `vault_resume_draft_confirm_discard`,
1100
+ `vault_seed_not_preserved_title`, `vault_seed_not_preserved_body`,
1101
+ `vault_seed_not_preserved_cta`, `vault_resolve_held_deposit_none`,
1102
+ `reconnect_needs_reapproval`, `reconnect_confirm_title`,
1103
+ `reconnect_confirm_message`, `arc_url_https_required`,
1104
+ `export_unencrypted_title`, `export_unencrypted_message`,
1105
+ `import_oversized_file`, `import_oversized_file_detail`,
1106
+ `tx_abort_maybe_delivered`, `tx_status_import_hold`,
1107
+ `local_pay_pending_abort_dropped_title`,
1108
+ `local_pay_pending_abort_dropped_body`, `biometric_advisory_body_degraded`,
1109
+ `pay_review_delivery_host`. `vault_reset_unknown_ack` is also corrected in
1110
+ every locale: it previously told the user a physically-occupied, locally-
1111
+ unrecognized YubiKey slot definitely belonged to no vault on this device, a
1112
+ certainty SecureStore's per-identity isolation cannot actually support; it now
1113
+ discloses the uncertainty instead of overclaiming it. Non-English copy is
1114
+ machine-drafted and awaits native-speaker review, same as every previous
1115
+ translation batch in this changelog.
1116
+
1117
+ ### Known residuals
1118
+
1119
+ Full disposition of every ledger row (fixed, already-fixed, invalid, needs-
1120
+ hardware-or-network, out-of-scope, or partial-with-a-recorded-blocker) and its
1121
+ proof artifacts are in `docs/security/external-review-closure.md`. Residuals
1122
+ surfaced above, collected here for visibility:
1123
+
1124
+ - The physical-hardware run (a real, previously-enrolled YubiKey through a full
1125
+ chain-recovered-lock-to-withdraw path) is still unrun for the Vault
1126
+ generally, and production keeps Vault output creation disabled until a v7
1127
+ lock has actually been broadcast, mined, and exercised on physical hardware.
1128
+ - Backup's `appData` channel still can't carry an isolated, single-entity
1129
+ change on its own (an all-empty chunk is the sync protocol's own end-of-log
1130
+ signal), and `offline_actions`/`token_linkage_payloads` are still outside
1131
+ encrypted backup; the restore path still can't bound a response with no
1132
+ declared `Content-Length`, and the chunk envelope still doesn't bind
1133
+ device/generation/sequence into what it authenticates.
1134
+ - Full saved-connection binding still needs an admin-scoped wallet threaded
1135
+ into `connect()`/`reconnect()`; the auto-approve default threshold and shared
1136
+ daily cap remain provisional pending product sign-off.
1137
+ - PeerPay and LocalPay still have no signed delivery/non-delivery receipt
1138
+ protocol — a dishonest decline made while the payee is genuinely offline, or
1139
+ one that reaches the chain only after this device's own check runs, is
1140
+ handled by detect-and-warn, not prevention.
1141
+ - Header validation outside the locally-validated window still has no chain-of-
1142
+ custody back to a trusted checkpoint, so a forger capable of mining a valid
1143
+ low-difficulty historical header is not excluded by this pass alone.
1144
+ - The iOS backup-exclusion question and the malformed-but-SQLite-magic-passing
1145
+ import question both need a real device build to close; an imported,
1146
+ quarantined `'import_hold'` offline-action row still has no in-app path to be
1147
+ reviewed and re-promoted to `'queued'`.
1148
+ - Android's KEK delete-then-add cycle still does not rotate the underlying
1149
+ hardware key (a vendored `expo-secure-store` limitation, not exploitable on
1150
+ its own).
1151
+
1152
+ ### Also in this release
1153
+
1154
+ - **TAAL and GorillaPool fallback broadcasts failed on every attempt.**
1155
+ `createTaalBroadcastService`/`createGorillaPoolBroadcastService`
1156
+ (`arcadeBroadcastProvider.ts`) posted to `${arcUrl}/tx`; both are standard
1157
+ ARC and serve `POST /v1/tx`, so every call 404'd and neither ever worked as
1158
+ a fallback when Arcade was down or rejected a transaction. Arcade (which
1159
+ serves `/tx` at its root) is unchanged. The dead teratest TAAL host
1160
+ (`arc-teratest.taal.com`) is dropped; `WalletContext` adds TAAL only on
1161
+ `main` and `test`.
1162
+ - **Pairing QR signatures verify in the `@bsv/wallet-relay` 0.5.x format.**
1163
+ `buildPairingSignatureMessage` (`walletConnectionValidation.ts`) had drifted
1164
+ to a domained `bsv-wallet-pairing-v1|topic|backendIdentityKey|protocolID|
1165
+ origin|expiry` transcript, while wallet-relay backends sign
1166
+ `topic|backendIdentityKey|origin|expiry`, so every real pairing QR failed
1167
+ with "Signature is not valid". Any future transcript change must be
1168
+ coordinated with wallet-relay and its backends.
1169
+ - **Recovery shares print as separate jobs (XR-110, partial).**
1170
+ `printRecoveryShares()` sent every share in one `Print.printAsync` job, so
1171
+ one retained job (spooler, print service, printer memory) could hold enough
1172
+ shares to rebuild the wallet. `generatePrintHTML()` takes an optional
1173
+ `only` index, and each share is now its own one-page job. Still open (a
1174
+ product decision): no paced, confirmed per-share flow or "1 of N"
1175
+ disclosure, so someone watching the whole print session still sees every
1176
+ share.
1177
+ - **A failed restore no longer leaves a reusable, partly replayed database
1178
+ (XR-017).** The restore picked and registered its SQLite file before replay,
1179
+ and on failure only closed it, so a later build that skipped replay could
1180
+ reselect it and publish it as a working wallet with missing history, proofs
1181
+ or BRC-29 receipts. `walletDbRegistry` gains `unregisterDb`; the failure
1182
+ path unregisters and deletes the file, but only when this build created
1183
+ it, never an existing identity's live database.
1184
+ - **A failed build-time release is retried durably, and pending-abort writes
1185
+ no longer race (XR-088).** When `releasingOnFailure()`'s own `abortAction`
1186
+ failed after a post-sign build error it only logged. `buildPaymentFrame`/
1187
+ `buildTokenPaymentFrame` take an optional `queueFailedAbort`, which
1188
+ `NearbyFlow` wires to `queuePendingAbort` as the decline path already did.
1189
+ `queuePendingAbort` and `replayPendingAborts` now share one
1190
+ `withPendingAbortsLock` chain, so a queue write during a replay can no
1191
+ longer drop a new reference or resurrect one that just aborted.
1192
+ - **Vault withdrawal retry no longer treats a refused input release as
1193
+ freed.** `abortActions`/`abortReservingOutpoints` counted an orphan as freed
1194
+ as soon as `abortAction` was called, so `createSignableVaultTx` retried
1195
+ against an input that was never released instead of surfacing the original
1196
+ error. An orphan now counts only once its abort resolves.
1197
+ - **Imported held rows no longer count as queued payments (XR-085
1198
+ follow-up).** `WalletHomeScreen`'s queued count excluded only `rejected`
1199
+ and `parked`, so an `import_hold` row reached `<OfflineNotice>` with "Send
1200
+ now" and "Show code". It is now excluded; Activity still shows it as "Held
1201
+ (imported)".
1202
+ - **The legacy `Balance` component no longer shows another context's cached
1203
+ balance (XR-058).** It cached under one global AsyncStorage key
1204
+ (`cached_wallet_balance`) and painted it on mount before checking for an
1205
+ active wallet. The cache is now per network
1206
+ (`cached_wallet_balance_${selectedNetwork}`), nothing paints until a wallet
1207
+ on that network is active, and logout also removes the old unscoped key.
1208
+
1209
+ ## 0.8.0
1210
+
1211
+ ### Wallet recovery and creation module
1212
+
1213
+ Everything the host's mnemonic and scan-shares screens used to decide inline
1214
+ — classify the import, store the secret, drop the other secret kind, build
1215
+ or rebuild, read the backup-replay outcome, attest — now lives in
1216
+ `core/recovery/` as plain functions over an injected deps object, unit-tested
1217
+ without rendering a screen. The screens keep only rendering, haptics,
1218
+ navigation and the small state machine that picks which view is shown; they
1219
+ supply prompts and translate outcome codes.
1220
+
1221
+ New `core` exports (all re-exported from the package root, and, for the
1222
+ share primitives, still reachable through `ui/backupShares.ts`):
1223
+
1224
+ - `secret.ts` — `WalletSecret` (`{kind:'mnemonic', mnemonic, identityKey}` or
1225
+ `{kind:'wif', wif, identityKey}`), `classifyImportInput(text)` (64-hex →
1226
+ wif, valid BIP39 phrase → mnemonic, anything else → `null`), and
1227
+ `secretFromShares(shareStrings)` (recombines shares into a `WalletSecret`,
1228
+ throwing exactly when the underlying Shamir recombination does).
1229
+ - `restoreWallet.ts` — `RestoreWalletDeps`, `RestoreHistory`,
1230
+ `RestoreOutcome` and `restoreWallet(deps, secret, opts)`: one attempt at
1231
+ storing a secret, dropping the other kind, building or rebuilding, and
1232
+ attesting. Never throws — anything a dep throws comes back as
1233
+ `{kind:'failed'}`.
1234
+ - `recoverWallet.ts` — `RestorePrompts`, `RecoveryOutcome` and
1235
+ `recoverWallet(deps, secret, opts)`: the retry/skip policy around
1236
+ `restoreWallet` (a refused biometric retries or cancels; a failed backup
1237
+ replay returns control to the caller's input or, on skip, re-attempts
1238
+ without asking for history replay).
1239
+ - `createWallet.ts` — `CreateWalletDeps`, `CreateOutcome` and
1240
+ `createNewWallet(deps, opts?)`: the "generate a brand new wallet" path,
1241
+ guarding first against an already-built wallet or already-stored identity
1242
+ (`{kind:'exists'}`) before generating anything.
1243
+ - `backupMaterial.ts` — `BackupMaterial` and `readBackupMaterial(deps)`, what
1244
+ the "view/export my recovery material" screen shows (mnemonic wins over a
1245
+ stored WIF; throws if neither is present).
1246
+ - `useRecoveryDeps.ts` — the React hook (`useRecoveryDeps()`) wiring the
1247
+ above to `useWallet()`, `useLocalStorage()` and `backupAttestation`.
1248
+ - `shares.ts` gains `ShareCompatibilityIssue` and
1249
+ `checkShareCompatibility(newShare, existing)`, returning a code
1250
+ (`'threshold-mismatch' | 'integrity-mismatch' | 'duplicate'`) instead of
1251
+ English prose; `shareCollector.ts` is a new pure reducer
1252
+ (`collectShare(collection, raw)`) for the scan screen's
1253
+ accumulate/dedupe/threshold logic, unit-testable without a camera.
1254
+
1255
+ `core/context/WalletContext.tsx`'s `WalletContextValue` gains
1256
+ `getWalletBuilt(): boolean`, a ref-backed twin of `walletBuilt` for callers
1257
+ that await a build across `recoverWallet`'s retry loop, where a captured
1258
+ React state snapshot would go stale.
1259
+
1260
+ `ui/` gains `recoveryPrompts.ts` — `restorePrompts(t): RestorePrompts`, the
1261
+ one copy of the biometric-refused and backup-replay-failed dialogs, exported
1262
+ from the `ui` barrel next to `showAlert`.
1263
+
1264
+ ### Share primitives moved to `core/` (deprecates `validateShareCompatibility`)
1265
+
1266
+ `ui/backupShares.ts`'s framing/padding/classification/split/recombine logic
1267
+ (everything except `generatePrintHTML`, which stays in `ui/` as
1268
+ presentation) moved to `core/recovery/shares.ts`, so the headless recovery
1269
+ module can reach it without crossing the `core` → `ui` boundary (`core`
1270
+ still never imports `ui/`). `ui/backupShares.ts` is now a re-export shim
1271
+ (`export * from '../core/recovery/shares'`) plus `generatePrintHTML`, so
1272
+ existing `@bsv/expo-wallet-toolbox/ui` consumers of the moved names are
1273
+ unaffected. `validateShareCompatibility(newShare, existing)` is kept for
1274
+ compatibility but **deprecated** in favour of `checkShareCompatibility`,
1275
+ which returns a code the caller translates instead of English prose.
1276
+
1277
+ ### Deep links: `resolveNativeIntent` and a wider `legacyRedirectTarget`
1278
+
1279
+ `core/pay/rails/nativeIntent.ts` adds `resolveNativeIntent(path, opts)`,
1280
+ moved out of the host's `+native-intent` route resolution: it recognises the
1281
+ toolbox's own `peerpay:` scheme and the host's own custom URL schemes, now
1282
+ passed in as `opts.walletSchemes` instead of hard-coded, so a second wallet
1283
+ app can reuse it with its own scheme names. `legacyRedirectTarget`'s `params`
1284
+ widen from `Record<string, string | undefined>` to
1285
+ `Record<string, string | string[] | undefined>`, so the three retired pay
1286
+ routes can forward `useLocalSearchParams` straight through instead of
1287
+ flattening array-valued query params themselves.
1288
+
1289
+ ### `NativeHandlers.onDownloadFile` optional
1290
+
1291
+ `UserContext`'s `NativeHandlers.onDownloadFile` is now optional, backed by a
1292
+ new `mergeNativeHandlers(partial?)` helper that fills in the no-op default
1293
+ per field. A host that omits it no longer has to supply an all-or-nothing
1294
+ `nativeHandlers` override just to skip that one handler.
1295
+
1296
+ ### Copy and translations
1297
+
1298
+ - 8 new keys, in all 12 languages: `scan_shares_threshold_mismatch`,
1299
+ `scan_shares_integrity_mismatch`, `scan_shares_duplicate` (the
1300
+ `checkShareCompatibility` issue codes, translated by the scan screen),
1301
+ `import_invalid_input_title`, `import_invalid_input_message`,
1302
+ `import_setup_failed`, `create_wallet_refused`, `create_wallet_failed`
1303
+ (the mnemonic screen's import/generate failure copy). Non-English copy is
1304
+ machine-drafted and awaits native-speaker review, same as every previous
1305
+ translation batch in this changelog.
1306
+
1307
+ ### Behaviour changes (breaking for hosts that relied on the old behaviour)
1308
+
1309
+ - Recovering or importing over an already-built wallet (e.g. onboarding's
1310
+ auto-created wallet) now **rebuilds** the wallet instead of silently
1311
+ no-op'ing. Previously `buildWalletFromMnemonic`/`buildWalletFromRecoveredKey`
1312
+ no-op when a wallet is already built, so recovering over one looked like a
1313
+ success while nothing changed; `restoreWallet` now calls `rebuildWallet`
1314
+ in that case.
1315
+ - Storing one secret kind now **deletes the other**: after a successful
1316
+ restore, exactly one of the mnemonic or the WIF survives in storage.
1317
+ Previously, importing a WIF while a mnemonic was already stored left the
1318
+ mnemonic in place, and an auto-rebuild's "mnemonic wins" fallback would
1319
+ build from the stale mnemonic instead of the key just imported.
1320
+ - A failed backup replay's "skip" now works for **hex (WIF) imports**, not
1321
+ only phrase imports — the old skip path was phrase-only, so a failed
1322
+ restore on a hex import previously left the user with no way forward.
1323
+ - Attestation failure after an already-successful build is now
1324
+ **non-fatal**: a throw from `attest` is caught and reported as
1325
+ `attested: false` rather than turning the whole recovery attempt into a
1326
+ failure. The wallet is already built and usable at that point; the only
1327
+ consequence of an unrecorded attestation is that the backup reminder nags
1328
+ again later.
1329
+ - Retrying after a failed backup replay now **returns to the input screen**
1330
+ on both the mnemonic and scan-shares screens, rather than looping on the
1331
+ same restore attempt — a server-side failure does not get better by
1332
+ retrying it in a tight loop in place.
1333
+
1334
+ ### Nearby/QR payment verification (breaking: `DerivingWallet` gains `getServices`)
1335
+
1336
+ `core/localpay/verify.ts`'s `verifyFramePayment` BSV branch checked only that
1337
+ the named output pays this device's derived key and carries a usable
1338
+ satoshi value — never that the transaction's (or its ancestors') unlocking
1339
+ scripts are valid, or that `sum(inputs) >= sum(outputs)`.
1340
+ `internalizeAction`'s own gate is a pure AtomicBEEF-structure/SPV check with
1341
+ no script interpreter, so a payer could spend a real mined UTXO it does not
1342
+ own, with a garbage `unlockingScript`, into an output that locks to the
1343
+ payee, for any amount, and have it credited offline. `verifyFramePayment`
1344
+ now calls `tx.verify(chainTracker)` — the SDK's own end-to-end verifier —
1345
+ against the same chain tracker `internalizeAction` itself consults
1346
+ (`wallet.getServices().getChainTracker()`). It fails closed: an ancestor
1347
+ present only as a txid throws rather than being silently skipped.
1348
+
1349
+ The `DerivingWallet` interface this module accepts gains a required
1350
+ `getServices(): { getChainTracker(): Promise<ChainTracker> | ChainTracker }`.
1351
+ The real `Wallet`/`WalletStorageManager` object `NearbyFlow` already passes
1352
+ in satisfies this, so the app's own wiring needed no change — but **a host
1353
+ that built its own object against the old, narrower `DerivingWallet` shape
1354
+ (just `getPublicKey`) must add `getServices` or its build will fail to
1355
+ typecheck.**
1356
+
1357
+ ### Offline drain: an invalid foreign ancestor now cascades, not stalls forever
1358
+
1359
+ `core/offline/plan.ts`'s `outcomeOfForeignPost` only ever classified a
1360
+ foreign-ancestor post as `'success'`, `'doubleSpend'` or `'serviceError'` —
1361
+ never `'invalidTx'` — so an ancestor the network explicitly rejects as
1362
+ invalid stalled the outbox drain forever instead of cascading the rejection
1363
+ to the descendant that credited off of it. `PostedTxidResult` gains an
1364
+ optional `serviceError` field (already set by the ARC adapter: exactly
1365
+ `false` for an INVALID/MALFORMED/REJECTED verdict, `true` for a
1366
+ transport/rate-limit/timeout issue), and `outcomeOfForeignPost` now returns
1367
+ `'invalidTx'` exactly when `status==='error' && doubleSpend!==true &&
1368
+ serviceError===false`. Absent or `true` — including a provider that never
1369
+ sets the field — stays retryable, so the fix fails closed. `'invalidTx'` was
1370
+ already a valid `PostOutcome` used by the owned-post path; this is what
1371
+ makes a foreign ancestor reach it too, wiring up the existing
1372
+ cascade-to-descendant handling rather than adding new machinery.
1373
+
1374
+ ### Declined-payment watch and a safer parked cancel
1375
+
1376
+ Two related fixes in the local-pay/offline path, both detect-and-warn, never
1377
+ block:
1378
+
1379
+ - `finalizeDelivery` (`core/localpay/build.ts`) treated a negative ack as
1380
+ trustworthy and unconditionally released the payer's inputs — true even
1381
+ when the decline happened offline, since the existing mandala abort guard
1382
+ only blocks an abort once the payer's own settlement row has already
1383
+ advanced to handed-over, which never happens on a decline. It now accepts
1384
+ an optional `watchDeclinedAbort?: (entry: { txid: string; reference:
1385
+ string }) => Promise<void>` dependency, called after every decline (BSV or
1386
+ token) it has a txid for, whether or not the abort itself succeeded.
1387
+ `core/localpay/pendingAborts.ts` gains a durable watch list
1388
+ (`queueDeclinedAbortWatch` / `verifyDeclinedAborts`, backed by a new
1389
+ `DECLINED_ABORT_WATCH_KEY` entry): it asks the network the same question
1390
+ `processOfflineActions.ts`'s `networkAlreadyHas` already asks, surfaces
1391
+ (and drops) a watched txid that reaches the chain anyway, and gives up
1392
+ unsurfaced after 7 days. `WalletContext` runs `verifyDeclinedAborts` at
1393
+ build time and on every reconnect, alongside the existing
1394
+ `replayPendingAborts`, and raises a background notice
1395
+ (`local_pay_decline_broadcast_title` / `_body`) if anything surfaces —
1396
+ never blocking.
1397
+ - `cancelParkedPayment` (`core/offline/cancelParked.ts`) refused a parked
1398
+ cancel only via a token-only settlement-row check, so a parked BSV
1399
+ payment — or a token txid with no settlement row yet — could be cancelled
1400
+ and its inputs respent while the payee's own scanned copy might already
1401
+ be in flight. It now runs a chain-status check independent of any
1402
+ settlement row: online+known refuses as `'already-sent'`, online+unknown
1403
+ proceeds to `'cancelled'`, and genuinely offline refuses with a new
1404
+ `'unverifiable-offline'` outcome unless the caller passes
1405
+ `acknowledgedUnverifiable: true`. A new `runCancelParkedFlow` helper
1406
+ drives the confirm-and-retry UX, wired into `WalletHomeScreen`'s cancel
1407
+ action with the new `local_pay_cancel_unverifiable_*` keys and a
1408
+ destructive confirm.
1409
+
1410
+ `CancelParkedOutcome` gains a fourth member — **a host matching
1411
+ exhaustively over the previous `'cancelled' | 'already-sent' | 'not-found'`
1412
+ should add `'unverifiable-offline'`.**
1413
+
1414
+ ### Received-payment overlay: a `verification` prop gates the green claim
1415
+
1416
+ `NearbyFlow` set the payee's success overlay to its green "Added to your
1417
+ wallet" state as soon as the payment was durably queued, before
1418
+ `internalizeAction` had necessarily run — if internalization later failed,
1419
+ the overlay never retracted or recoloured, claiming a credit the device
1420
+ could not back yet. `PaymentSuccessOverlay` gains an optional
1421
+ `verification?: 'pending' | 'verified' | 'not-credited'` prop, defaulting to
1422
+ `'verified'` so every existing caller is unaffected. The overlay's *timing*
1423
+ is unchanged — still shown the instant the payment is durably queued; only
1424
+ the claim is gated: `'pending'` shows a neutral "Confirming with your
1425
+ wallet…" (`local_pay_received_confirming`) the moment it appears, resolving
1426
+ to today's unchanged green copy on a genuine credit or a neutral "Not added
1427
+ to your wallet yet" (`local_pay_received_not_credited`) otherwise. Ignored
1428
+ on the payer side, where there is nothing left to confirm.
1429
+
1430
+ ### Recovery: confirm before replacing an existing wallet (breaking)
1431
+
1432
+ Defense in depth against a deep link, or any other entry point, silently
1433
+ overwriting a wallet whose phrase may be unsaved: `recoverWallet` now asks a
1434
+ new `confirmReplace` prompt once, before the first `restoreWallet` attempt,
1435
+ whenever `deps.hasStoredIdentity()` reports an existing secret already on
1436
+ the device. Declining returns `{kind:'cancelled'}` before anything is
1437
+ written; a biometric retry within the same call never re-prompts. This also
1438
+ means the onboarding "replace an auto-created wallet" path sees the same
1439
+ confirm, deliberately — any caller reaching this point already has a stored
1440
+ identity to protect, in-app or not.
1441
+
1442
+ `RestoreWalletDeps` gains a required `hasStoredIdentity(): Promise<boolean>`,
1443
+ and `RestorePrompts` gains a required `confirmReplace(): Promise<'replace' |
1444
+ 'keep'>`. **A host supplying its own `RestoreWalletDeps`, or building its
1445
+ own `RestorePrompts` instead of using `ui/recoveryPrompts.ts`'s
1446
+ `restorePrompts(t)`, must implement both** — the toolbox's own
1447
+ `restorePrompts(t)` already does, wired to the new
1448
+ `recovery_replace_wallet_title` / `_body` / `_confirm` keys, and treats a
1449
+ dismissal as `'keep'` (never `'replace'`), matching the existing
1450
+ dismiss-is-always-safe convention the biometric-refused and
1451
+ backup-replay-failed prompts already follow.
1452
+
1453
+ Also in this pass: `createNewWallet` accepts an optional
1454
+ `opts.cancelled?: () => boolean`, re-checked right after the identity guard
1455
+ so a caller whose screen state changed mid-await (e.g. its route flipped to
1456
+ the backup flow) does not generate or store anything against stale state;
1457
+ `CreateOutcome` gains a `{kind:'cancelled'}` member for when it fires.
1458
+ `classifyImportInput`'s hex branch now catches an SDK parse failure and
1459
+ returns `null` instead of throwing, matching the mnemonic branch's existing
1460
+ behaviour.
1461
+
1462
+ ### Deep links: destructive recovery routes refused, pairing now requires approval
1463
+
1464
+ `resolveNativeIntent` (`core/pay/rails/nativeIntent.ts`) closes two related
1465
+ gaps:
1466
+
1467
+ - An external `bsv-wallet://auth/scan-shares` or
1468
+ `bsv-wallet://auth/mnemonic?flow=import` link redirected straight into the
1469
+ destructive import screens with no confirmation. Both now redirect to `/`
1470
+ instead of passing through; `flow=backup` and every other route are
1471
+ unaffected. This is layer 1 of two — layer 2 is the confirm-replace guard
1472
+ above, which also refuses an in-app entry point.
1473
+ - An external `pair` link used to be rewritten to `/connections`, whose own
1474
+ deep-link effect called straight into `connect()` with no user gesture in
1475
+ between. It is no longer rewritten: it now passes straight through to
1476
+ `/pair` (`PairScreen`), which already renders the same origin/permissions
1477
+ Approve/Reject card a scanned or pasted URI gets. `ConnectionsScreen`'s
1478
+ corresponding auto-connect `useEffect` was deleted — that screen now only
1479
+ ever connects from its own explicit scan/paste buttons.
1480
+
1481
+ No API surface changed, but **a host relying on an external pairing link
1482
+ auto-connecting from Connections needs to account for it now landing on
1483
+ `/pair` and requiring an explicit approval tap instead.**
1484
+
1485
+ ### Secrets: a sentinel read failure no longer re-provisions the KEK
1486
+
1487
+ `putSecret` used a `null` sentinel read as its sole signal that no wallet
1488
+ was ever stored, taking that straight into `provisionKek()`, which
1489
+ unconditionally deletes both KEK keychain items before minting a new one —
1490
+ so a transient sentinel read failure on an otherwise-existing sentinel could
1491
+ orphan an already-sealed backup envelope beyond recovery. `readSentinel`
1492
+ gains an `options?: { strict?: boolean }` parameter that rethrows instead of
1493
+ swallowing to `null`; `putSecret` now reads it strictly and refuses the
1494
+ write (returns `false` — the same externally-visible shape as a declined
1495
+ biometric prompt) rather than re-provisioning on a thrown read. A genuinely
1496
+ missing sentinel still provisions normally.
1497
+
1498
+ ### Headers: the validated window is authoritative over a remote answer
1499
+
1500
+ `HeaderStore.rootForHeight` let a remote chaintracks answer permanently
1501
+ overwrite an already PoW-validated window root on any disagreement —
1502
+ reachable by a MITM absent TLS pinning, not only a compromised chaintracks
1503
+ deployment. `HeaderStore` gains `isWindowBody(height)` and now treats the
1504
+ window's own root as authoritative for its validated body
1505
+ (`[baseHeight, tipHeight-6]`), ignoring any `extra`-cache entry there
1506
+ outright. `OfflineFirstChaintracks.isValidRootForHeight` refuses a
1507
+ body-covered mismatch outright — no remote lookup, no caching. The last-6
1508
+ reorg tail, and any height outside the window entirely, are unchanged: a
1509
+ mismatch there still falls through to the remote self-heal path exactly as
1510
+ before.
1511
+
1512
+ ### Wallet context: bounded auto-approve, private callback token, corroborated checks
1513
+
1514
+ Three fixes sharing `WalletContext.tsx`'s wiring:
1515
+
1516
+ - **Auto-approve** was a single global cooldown with no cumulative cap, so
1517
+ multiple paired origins could accidentally throttle each other while a
1518
+ single origin alone could still auto-approve up to the per-request
1519
+ threshold every cooldown window, forever. `core/services/autoApprovePolicy.ts`
1520
+ (`createAutoApprovePolicy`) replaces it: the cooldown is now keyed **per
1521
+ originator**, plus a global rolling 24h cumulative cap across every
1522
+ originator combined, `AUTO_APPROVE_DAILY_CAP_SATS` — **provisional**, set
1523
+ to 10x the default per-request threshold (1,000,000 sats at the shipped
1524
+ defaults) purely so it cannot bind in ordinary single-payment use, pending
1525
+ product sign-off on the real number. The ledger is persisted best-effort
1526
+ to `AsyncStorage` so an app restart does not reset the cap.
1527
+ - **Broadcast callback token**: the Arcade `X-CallbackToken` was
1528
+ `keyDeriver.identityKey.substring(0, 32)` — the first 32 hex chars of the
1529
+ wallet's own *public* identity key, a value any past counterparty already
1530
+ has. `core/services/callbackToken.ts`'s `deriveCallbackToken` derives it
1531
+ from a BRC-42 *private* key instead (fixed protocol/keyID, counterparty
1532
+ `'self'`, then hashed) — deterministic per wallet, but only this wallet's
1533
+ root key can compute it. The token is recomputed on every wallet build and
1534
+ used for both the Arcade broadcast service and the Monitor's
1535
+ `callbackToken` option, so an existing server-side SSE subscription keyed
1536
+ to the old, public-key-derived value re-registers under the new one
1537
+ automatically the next time the wallet builds — no separate migration
1538
+ step, but it is a genuine value change a host should be aware of if it
1539
+ reads or reproduces this token itself.
1540
+ - **Wallet check**: a coin used to be marked permanently unspendable off a
1541
+ single WhatsOnChain "spent" response — WoC can be wrong, stale, or
1542
+ answering for the wrong network, and this path never writes `spentBy`, so
1543
+ nothing could ever undo a wrong call. `core/walletRepair/shouldMarkUnspendable.ts`
1544
+ now requires the toolbox's own configured `getUtxoStatus` provider to
1545
+ *also* report the output as no longer a UTXO before committing to
1546
+ `spendable: false`; either way, the claimed spender is now recorded in
1547
+ `outputs.spendingDescription` as a paper trail (a free-text column
1548
+ nothing else in this app reads or writes).
1549
+
1550
+ ### Exchange rate: one fetch, one fallback, and a live refresh within the session
1551
+
1552
+ `ExchangeRateContext` used to run its own independent fetch/cache/fallback
1553
+ logic that disagreed with `core/services/exchangeRate.ts`'s (16 vs 16.75)
1554
+ while sharing the same `AsyncStorage` cache key. `FALLBACK_RATE`/`CACHE_KEY`
1555
+ are now exported from `exchangeRate.ts`, and `ExchangeRateContext` calls its
1556
+ single timeout-guarded `getExchangeRate()` instead of re-implementing an
1557
+ untimed fetch and its own cache/fallback.
1558
+
1559
+ Separately, that background refresh used to be fire-and-forget — its result
1560
+ only ever reached the UI on the *next* cold start, so a session that opened
1561
+ with a stale cached/fallback rate stayed stale until closed and reopened.
1562
+ `getExchangeRate()` now returns an additional `refreshed: Promise<number |
1563
+ undefined>` field (never rejects — every failure mode is still caught and
1564
+ reported as `undefined`) alongside the existing `rate`; a caller that
1565
+ ignores it (the wallet-build seed) sees no change at all, but
1566
+ `ExchangeRateContext` awaits it and raises the displayed rate once the live
1567
+ fetch actually lands, within the same session.
1568
+
1569
+ ### Pay: cross-network address warning, an honest foreign-domain trust badge
1570
+
1571
+ `core/pay/rails/index.ts` gains `addressNetwork(address): 'main' | 'test' |
1572
+ undefined`, reading a base58check address's version byte, and
1573
+ `classifyRecipientInput` / `classifyScan` / `PayTarget`'s address variant
1574
+ carry an optional `network` field alongside it. `UniversalSend` now shows a
1575
+ non-blocking `pay_address_network_mismatch` note when the recipient's
1576
+ detected network disagrees with the wallet's currently selected one — a
1577
+ warning, not a refusal, since the same key redeems on either chain.
1578
+
1579
+ Separately, a handle-registry search hit from a foreign domain used to get
1580
+ the same "Registered" badge as a match from the wallet's own pinned
1581
+ registry, overstating its trust level — a foreign domain's is only
1582
+ paymail-equivalent (its own DNS+TLS), not the pinned registry's actual
1583
+ vetting. A foreign-domain match now gets `pay_trust_handle_domain_attested`
1584
+ ("Verified by {{domain}}") instead of `pay_trust_handle_attested`.
1585
+
1586
+ ### Vault: interrupted-deposit recovery, a safer preview, stale-meta supersession
1587
+
1588
+ - **Interrupted deposit.** A crash between `signAction` and the `sendWith`
1589
+ release of a Vault deposit used to freeze every subsequent vault
1590
+ operation behind `reconcileHeldVaultDeposits`'s `action-pending` refusal,
1591
+ with no in-app way to resolve it. `core/services/vault/transfers.ts` gains
1592
+ `resolveHeldVaultDeposit(w, adminOriginator, meta, scopeToken?)`: it asks
1593
+ the network for the held txid's status first (`already-known` if the
1594
+ network already has it, otherwise re-broadcasts the *exact*
1595
+ already-signed bytes via the same `sendWith` call the normal release
1596
+ uses — never a second transaction, never `abortAction`). `VaultScreen`
1597
+ shows a "Finish the interrupted deposit" notice and button
1598
+ (`vault_resolve_held_deposit_action` / `_done` / `_failed`) whenever a
1599
+ relock or key-removal call surfaces `action-pending`.
1600
+ - **Preview mutex.** `previewVaultWithdrawal` could call `abortAction` on a
1601
+ live, in-flight unsigned reservation through `selectVaultInputs`'s
1602
+ automatic stale-reservation repair — a read-only preview must not do
1603
+ that. `selectVaultInputs` gains a `repair` parameter (default `true`);
1604
+ `previewVaultWithdrawal` now passes `repair: false` and runs inside the
1605
+ vault mutation mutex, failing closed with `action-pending` instead.
1606
+ `withdrawFromVault` / `relockVault` keep `repair: true`, so a genuinely
1607
+ stale reservation from a past crash is still cleaned up.
1608
+ - **Stale local meta.** `recoverVaultMetaFromOutputs` used to trust an
1609
+ existing local record unconditionally, so a stale post-reinstall
1610
+ SecureStore snapshot could permanently hide a newer on-chain revision. It
1611
+ now always runs the authenticated on-chain output scan and keeps the
1612
+ existing record only when it is not superseded by the scan (a strictly
1613
+ higher revision, or a same-revision strict key-set superset) — a one-way
1614
+ ratchet, never a merge or an overwrite by a same-revision disagreement.
1615
+ - **Allocation-gate scope.** `reconcileHeldVaultDeposits`'s gate now runs
1616
+ only for the sub-cases that actually allocate a new salt index — a
1617
+ deposit, a partial withdrawal's re-vaulted remainder, and `relockVault` —
1618
+ so a full-balance withdrawal and `beginVaultKeyRemoval` (neither of which
1619
+ creates a new vault output) no longer block on an unrelated held deposit.
1620
+ - **Reachable while funded.** `VaultContext` gains a device-local
1621
+ `hasVaultMeta` flag, backed by the existing `vaultStore.isEnrolled()`
1622
+ read (no new network call). `WalletHomeScreen` and `SettingsScreen` now
1623
+ show their Vault entry point when `isVaultAvailable(selectedNetwork) ||
1624
+ hasVaultMeta`, so an already-funded vault stays reachable even with
1625
+ `EXPO_PUBLIC_VAULT_ENABLED` off or the network switched away from
1626
+ mainnet. `VaultScreen`'s own withdraw/deposit gating is unchanged.
1627
+ - **Vendored patch.** The `@bsv+wallet-toolbox-mobile+2.14.0.patch` funding
1628
+ plan's UTXO-pool-growth/surplus-shaping/migration-input exemptions were
1629
+ keyed off a `'vault-deposit'` label, so a vault withdrawal or re-lock was
1630
+ not exempted and could have extra migration inputs folded in, which
1631
+ `validateSignableVaultPlan`'s strict input-count check then rejected
1632
+ outright — spuriously failing an otherwise-legitimate withdraw or relock.
1633
+ Re-keyed to the already-computed `vargs.__bsvVaultAdminAuthorized ===
1634
+ true` flag, which covers deposit, withdraw and relock alike.
1635
+
1636
+ ### Mandala: a handle-rail token is held before it is internalized
1637
+
1638
+ `@bsv/mandala`'s own `receiveTokens` calls `wallet.internalizeAction()`
1639
+ *before* it calls the settle hook that finally writes a `token_settlements`
1640
+ row — on a handle-rail token's first credit, that row does not exist yet, so
1641
+ `StorageExpoSQLite.attemptToPostReqsToNetwork`'s guard (which looks up
1642
+ exactly that row) finds nothing and lets an unmediated broadcast through
1643
+ before the issuer's overlay ever got to admit or refuse the transfer.
1644
+ `core/mandala/inboxPrehold.ts` adds a pre-hold pass, wired into
1645
+ `createRuntime.ts`'s `receiveFromInbox` ahead of the real `receiveTokens`
1646
+ call: it lists the inbox first, decodes each v2 hand-over message using only
1647
+ the mechanical shape of the library's own unexported decoder, and — for
1648
+ every message the library's own `cover()` verdict accepts — writes its
1649
+ settlement row through the same `settleThroughDrain` hook the real receive
1650
+ already uses. No trust logic is reimplemented; the verdict is entirely
1651
+ `cover()`'s own. A message whose pre-hold write fails is excluded from that
1652
+ one `receiveTokens` call and un-excluded immediately after, so it retries
1653
+ whole on the next drain tick instead of being credited with no guard row. A
1654
+ failure of the whole pre-hold pass skips the entire receive rather than
1655
+ running `receiveTokens` unguarded. One documented, inherent gap: this lists
1656
+ the inbox once and `receiveTokens` lists it again moments later — a message
1657
+ arriving in that narrow window is credited with the library's original,
1658
+ unguarded ordering, exactly as before this pass existed.
1659
+
1660
+ ### Backup: a sealed generation, and a verified snapshot preferred on restore
1661
+
1662
+ Restore target selection had no notion of "complete" — a manifest carries no
1663
+ completeness flag, so a restore landing mid-rotation could pass the
1664
+ existing contiguity check and silently report success on a partial
1665
+ snapshot. The fix is a **seal carried inside ordinary chunks**, never a new
1666
+ kind of log entry: `PushCursor` (`cursor.ts`) gains `initialChunkCount`,
1667
+ recorded the first time a generation's `since` window closes (and
1668
+ back-filled in memory for a pre-existing cursor whose window had already
1669
+ closed under an older build), and every chunk `pushOnce` appends from then
1670
+ on carries `seal: { generation, initialChunkCount }` in the same
1671
+ `{chain, chunk}` envelope (`encodeChunk`'s optional fourth argument;
1672
+ `decodeEntry` returns `{kind:'chunk', chunk, seal?}`; `decodeChunk` is an
1673
+ unchanged wrapper). An unsealed chunk is byte-identical to the old format,
1674
+ and an **older app build** reading a sealed chunk simply ignores the extra
1675
+ field — its `decodeChunk` only ever reads `envelope.chunk` — so mixed
1676
+ builds against one backup account keep working. (An earlier iteration of
1677
+ this fix on the branch wrote the seal as a separate marker entry; that
1678
+ would have crashed older readers and was replaced before release.)
1679
+
1680
+ `RemoteSyncReader.verifiedComplete()` decodes only the newest entry and
1681
+ reports true when its seal names this generation and `initialChunkCount`
1682
+ is no larger than the number of entries present — the initial snapshot is
1683
+ fully there, and later deltas keep it verified. `restore.ts`'s `pickTarget`
1684
+ ranks every candidate by `updatedAt` and picks the first one whose reader
1685
+ reports `verifiedComplete` — an older but sealed generation beats a newer
1686
+ one still mid-rotation — falling back to the previous newest-only heuristic
1687
+ (`verified: false`) only when nothing in the manifest is sealed, so a fully
1688
+ legacy manifest still restores exactly as before. `RestoreResult` /
1689
+ `RestoreOnImportResult` gain `verified: boolean`; `restoreOnImport.ts`'s
1690
+ own `newestTarget()` was dropped in favour of the shared `pickTarget`.
1691
+
1692
+ The signal now reaches the user: `BackupRestoreState` gains
1693
+ `verified?: boolean`, `RestoreOutcome` / `RecoveryOutcome`'s `ok` variant
1694
+ gains `verified: boolean`, and `restorePrompts(t)` gains
1695
+ `restoreUnverified()` — a single-button alert (new keys
1696
+ `restore_backup_unverified_title` / `restore_backup_unverified_body`, all 12
1697
+ locales) that the mnemonic and scan-shares screens show before celebrating
1698
+ when a restore succeeded but could not be confirmed complete. An idle wallet
1699
+ whose generation never received a delta after its initial window stays
1700
+ unsealed until it does; that only ever costs the "may be incomplete" notice,
1701
+ never a refused restore.
1702
+
1703
+ ### Monitor: no overlapping outbox drains, and long-gap skips are recorded
1704
+
1705
+ - `TaskDrainOutbox` had no dedup guard: a `MonitorSupervisor` watchdog
1706
+ restart can leave an old generation's in-flight `runOnce()` executing
1707
+ concurrently with a newly-started generation's own `runOnce()` (the old
1708
+ call is not cancelled, only stopped from looping again once it resolves),
1709
+ which could retry the same outbox entry twice. It gains a static
1710
+ `running` flag, set at the top of `runTask` and cleared in a `finally` so
1711
+ a throw cannot wedge it; a concurrent call now returns `''` immediately
1712
+ without draining.
1713
+ - `reviewProvenTxsStartHeight` jumps ahead to the last 100 eligible heights
1714
+ when last-reviewed falls further behind the tip than that — an
1715
+ intentional tradeoff against an unbounded chain-crawl — but nothing
1716
+ recorded which heights were permanently skipped, so a rare missed reorg
1717
+ in that range could never be surfaced. `core/walletMonitor.ts` exports a
1718
+ new `skippedReviewRanges: { fromHeight: number; toHeight: number }[]`
1719
+ array (and `resetSkippedReviewRanges()`), pushed to and `console.warn`'d
1720
+ with a tagged `[walletMonitor]` line whenever a skip actually happens, so
1721
+ diagnostics or a future slow background sweep can read it.
1722
+
1723
+ ### `AmountInput` accepts the locale's own decimal separator
1724
+
1725
+ Fiat-mode input hardcoded `.` as the decimal separator in both the input
1726
+ mask and `parseDisplayToSatoshis`, so a comma-decimal locale (e.g. de-DE)
1727
+ could not type a fractional fiat amount at all — every comma keystroke
1728
+ failed the mask and was silently dropped, and `parseFloat` only ever
1729
+ recognises `.` besides. `core/amountFormatHelpers.ts` gains
1730
+ `decimalSeparator()` (re-exported from the package root), derived from
1731
+ `Intl.NumberFormat(locale).formatToParts(1.1)` rather than hardcoded;
1732
+ `AmountInput`'s input mask and `parseDisplayToSatoshis` both use it to build
1733
+ the allowed pattern and to normalize typed text to `.` before `parseFloat`.
1734
+ BSV's integer mode (`fractionDigits === 0`) is untouched — it has no decimal
1735
+ point to begin with.
1736
+
1737
+ ### `setMockDriver` refuses outside `__DEV__`
1738
+
1739
+ `setMockDriver` had no gate of its own — only its `devMock.ts` wrapper
1740
+ checked `__DEV__` before calling it — so any code with JS execution in a
1741
+ nominally-production bundle could call it directly and make
1742
+ `getVaultDriver()` prefer a software mock over real hardware, skipping all
1743
+ native attestation. It is now a no-op outside `__DEV__`. `jest-expo` sets
1744
+ `__DEV__=true`, so the existing mock-driver test suites are unaffected.
1745
+
1746
+ ### `LocalStorageAdapter` removed (breaking)
1747
+
1748
+ `core/storage/LocalStorageAdapter.ts` and its `core/index.ts` exports —
1749
+ `initializeLocalStorage`, `isLocalStorage`, `getStorageDisplayName`, and the
1750
+ `LocalStorageConfig` type — are deleted. It never passed `identityKey` into
1751
+ the `StorageExpoSQLite` constructor it wrapped, so every identity would have
1752
+ collided on `wallet-default-<chain>net.db` had it ever been used, and a
1753
+ repo-wide search found no real caller: the live `WalletContext` path already
1754
+ passes both `identityKey` and an explicit `databaseName` directly to
1755
+ `StorageExpoSQLite`. **Breaking only for a host that imported these names
1756
+ directly** — nothing in this app's own code depended on them.
1757
+
1758
+ ### New i18n keys, and a corrected export explainer
1759
+
1760
+ 15 new keys, in all 12 languages: `local_pay_received_confirming`,
1761
+ `local_pay_received_not_credited`, `local_pay_decline_broadcast_title`,
1762
+ `local_pay_decline_broadcast_body`, `local_pay_cancel_unverifiable_title`,
1763
+ `local_pay_cancel_unverifiable_body`, `local_pay_cancel_unverifiable_confirm`,
1764
+ `recovery_replace_wallet_title`, `recovery_replace_wallet_body`,
1765
+ `recovery_replace_wallet_confirm`, `pay_address_network_mismatch`,
1766
+ `pay_trust_handle_domain_attested`, `vault_resolve_held_deposit_action`,
1767
+ `vault_resolve_held_deposit_done`, `vault_resolve_held_deposit_failed`.
1768
+ Non-English copy is machine-drafted and awaits native-speaker review, same
1769
+ as every previous translation batch in this changelog.
1770
+
1771
+ `vault_export_explainer` is also corrected in all 12 locales: it claimed the
1772
+ vault salt lives in the locking script, which is false (the script commits
1773
+ only to `HASH160(salt||table)`; the salt itself is witness-only) and
1774
+ directly contradicted `vault_first_deposit_body` five keys later in the same
1775
+ file.
1776
+
1777
+ ### App-side notes for a host
1778
+
1779
+ - `app.json`'s `expo.android.allowBackup` is now explicitly `false`. Expo's
1780
+ own default (`true`) let Android's Auto-Backup-for-Apps copy the
1781
+ plaintext SQLite database — which holds every vault output's salt in
1782
+ `customInstructions` — off-device on an OS-initiated backup with no user
1783
+ action. The app's own encrypted backup system is unaffected by this; a
1784
+ host forking this `app.json` should carry the same setting.
1785
+ - The vendored `patches/@bsv+wallet-toolbox-mobile+2.14.0.patch` changed
1786
+ (see the Vault section above): three funding-plan exemption conditions in
1787
+ `makeFundingParams` moved from a `'vault-deposit'` label check to
1788
+ `vargs.__bsvVaultAdminAuthorized === true`. `npm install` picks up the
1789
+ regenerated patch automatically via `patch-package` for anyone installing
1790
+ this package fresh; a host that vendors its own copy of this patch
1791
+ outside the normal install path needs to regenerate it the same way.
1792
+
3
1793
  ## 0.7.0
4
1794
 
5
1795
  0.6.0 was tagged in this file but never published to npm. Hosts upgrading from