@bsv/expo-wallet-toolbox 0.5.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2000 -0
- package/README.md +66 -1
- package/core/amountFormatHelpers.ts +258 -36
- package/core/backup/RemoteSyncReader.ts +133 -24
- package/core/backup/appData.ts +157 -0
- package/core/backup/client.ts +15 -1
- package/core/backup/codec.ts +149 -11
- package/core/backup/constants.ts +30 -1
- package/core/backup/cursor.ts +31 -2
- package/core/backup/push.ts +71 -5
- package/core/backup/restore.ts +104 -16
- package/core/backup/restoreOnImport.ts +94 -30
- package/core/backup/status.ts +13 -8
- package/core/config.tsx +12 -5
- package/core/constants.ts +14 -1
- package/core/contacts/contactActivity.ts +153 -0
- package/core/contacts/contactCache.ts +41 -0
- package/core/contacts/contactsStore.ts +183 -0
- package/core/context/ExchangeRateContext.tsx +34 -27
- package/core/context/LocalStorageProvider.tsx +43 -40
- package/core/context/UserContext.tsx +18 -7
- package/core/context/VaultContext.tsx +49 -2
- package/core/context/WalletConnectionContext.tsx +203 -11
- package/core/context/WalletContext.tsx +685 -171
- package/core/demo/demoAssets.ts +60 -0
- package/core/demo/demoLedger.ts +240 -0
- package/core/demo/demoMandalaRuntime.ts +96 -0
- package/core/demo/demoMode.ts +38 -0
- package/core/demo/demoWallet.ts +25 -0
- package/core/demo/index.ts +26 -0
- package/core/demo/useDemo.ts +59 -0
- package/core/headers/OfflineFirstChaintracks.ts +99 -17
- package/core/headers/headerStore.ts +33 -14
- package/core/headers/syncHeaders.ts +12 -1
- package/core/i18n/translations.tsx +2186 -98
- package/core/identity/contactLink.ts +36 -0
- package/core/identity/handleRegistry/client.ts +314 -0
- package/core/identity/handleRegistry/keyPinStore.ts +70 -0
- package/core/identity/handleRegistry/profileCert.ts +254 -0
- package/core/identity/handleRegistry/registration.ts +559 -0
- package/core/identity/handleRegistry/resolver.ts +315 -0
- package/core/identity/handleRegistry/rules.ts +104 -0
- package/core/index.ts +53 -5
- package/core/localpay/build.ts +225 -24
- package/core/localpay/pending.ts +110 -7
- package/core/localpay/pendingAbortAuthority.ts +95 -0
- package/core/localpay/pendingAborts.ts +266 -26
- package/core/localpay/session.ts +42 -17
- package/core/localpay/settlementAck.ts +10 -1
- package/core/localpay/transport/socket.ts +52 -3
- package/core/localpay/verify.ts +100 -10
- package/core/mandala/abortGuard.ts +96 -20
- package/core/mandala/createRuntime.ts +206 -33
- package/core/mandala/drain.ts +89 -11
- package/core/mandala/inboxPrehold.ts +186 -0
- package/core/mandala/permissionModule.ts +202 -20
- package/core/mandala/settlementStore.ts +24 -2
- package/core/mandala/types.ts +40 -5
- package/core/monitor/MonitorSupervisor.ts +121 -0
- package/core/monitor/TaskBackupPush.ts +15 -1
- package/core/monitor/TaskCreditInbox.ts +1 -1
- package/core/monitor/TaskDrainOutbox.ts +15 -1
- package/core/monitor/TaskSendOffline.ts +15 -1
- package/core/net/online.ts +49 -0
- package/core/net/publicDestination.ts +91 -0
- package/core/net/validateArcUrl.ts +22 -0
- package/core/numberFormat.ts +19 -0
- package/core/offline/cancelParked.ts +134 -13
- package/core/offline/payerHold.ts +100 -24
- package/core/offline/plan.ts +37 -8
- package/core/pay/beefRepair.ts +6 -2
- package/core/pay/damagedInbox.ts +24 -0
- package/core/pay/rails/address.ts +107 -12
- package/core/pay/rails/handle.ts +117 -22
- package/core/pay/rails/index.ts +45 -7
- package/core/pay/rails/nativeIntent.ts +61 -0
- package/core/pay/receiveHistory.ts +93 -0
- package/core/pay/recordProof.ts +21 -7
- package/core/pay/refreshProofGuard.ts +42 -1
- package/core/pay/watchlist.ts +5 -2
- package/core/peerpay/control.ts +17 -18
- package/core/peerpay/handleResendRequests.ts +58 -4
- package/core/peerpay/outbox.ts +3 -1
- package/core/recovery/backupMaterial.ts +61 -0
- package/core/recovery/createWallet.ts +95 -0
- package/core/recovery/recoverWallet.ts +120 -0
- package/core/recovery/restoreWallet.ts +170 -0
- package/core/recovery/secret.ts +92 -0
- package/core/recovery/shareCollector.ts +71 -0
- package/core/recovery/shareParsing.ts +87 -0
- package/core/recovery/shares.ts +116 -0
- package/core/recovery/useRecoveryDeps.ts +70 -0
- package/core/services/arcTokenStorage.ts +52 -0
- package/core/services/arcadeBroadcastProvider.ts +233 -52
- package/core/services/autoApprovePolicy.ts +105 -0
- package/core/services/callbackToken.ts +19 -0
- package/core/services/capWalletArgs.ts +14 -2
- package/core/services/connectionAuthority.ts +98 -0
- package/core/services/exchangeRate.ts +36 -13
- package/core/services/externalOrigin.ts +16 -2
- package/core/services/secrets/kek.ts +126 -29
- package/core/services/secrets/migration.ts +16 -4
- package/core/services/secrets/store.ts +42 -14
- package/core/services/vault/VaultKeyService.ts +228 -45
- package/core/services/vault/chainRecovery.ts +483 -0
- package/core/services/vault/driver.ts +9 -1
- package/core/services/vault/enrolledSerialRegistry.ts +150 -0
- package/core/services/vault/guard.ts +218 -32
- package/core/services/vault/hardwareLease.ts +19 -0
- package/core/services/vault/metaAuthority.ts +210 -0
- package/core/services/vault/pivReset.ts +64 -23
- package/core/services/vault/r1comb.ts +139 -3
- package/core/services/vault/session.ts +25 -4
- package/core/services/vault/transfers.ts +868 -172
- package/core/services/vault/types.ts +19 -4
- package/core/services/vault/vaultStore.ts +256 -29
- package/core/services/walletArgLimits.ts +45 -2
- package/core/services/walletConnectionValidation.ts +76 -6
- package/core/services/walletServiceConfig.ts +40 -27
- package/core/storage/StorageExpoSQLite.ts +88 -47
- package/core/storage/methods/findSql.ts +24 -2
- package/core/storage/methods/listActionsSql.ts +8 -5
- package/core/storage/methods/listOutputsSql.ts +2 -2
- package/core/storage/methods/offlineActions.ts +10 -1
- package/core/storage/methods/processOfflineActions.ts +117 -25
- package/core/storage/methods/reviewStatusSql.ts +7 -2
- package/core/storage/schema/createTables.ts +155 -2
- package/core/stores/ConnectionStore.ts +34 -0
- package/core/toolboxConfig.ts +104 -0
- package/core/toolboxTypes.ts +40 -0
- package/core/userAvatar.ts +79 -0
- package/core/walletDbRegistry.ts +63 -0
- package/core/walletMonitor.ts +25 -4
- package/core/walletRepair/releaseStuckReservations.ts +72 -0
- package/core/walletRepair/shouldMarkUnspendable.ts +20 -0
- package/core/walletRepair/spenderConsumesOutpoint.ts +29 -0
- package/package.json +7 -7
- package/ui/activityFilter.ts +115 -0
- package/ui/backupShares.ts +26 -169
- package/ui/components/pay/AddressReceive.tsx +13 -6
- package/ui/components/pay/AssetPicker.tsx +30 -9
- package/ui/components/pay/MessageBoxConfig.tsx +16 -0
- package/ui/components/pay/NearbyFlow.tsx +480 -243
- package/ui/components/pay/PaymentSuccessOverlay.tsx +85 -10
- package/ui/components/pay/RecipientField.tsx +84 -70
- package/ui/components/pay/StepBar.tsx +32 -0
- package/ui/components/pay/UniversalSend.tsx +827 -205
- package/ui/components/ui/AlertCard.tsx +38 -5
- package/ui/components/ui/PencilEditField.tsx +109 -0
- package/ui/components/ui/PermissionSheet.tsx +197 -66
- package/ui/components/ui/SlideOverFromRight.tsx +86 -0
- package/ui/components/vault/EnrollWizard.tsx +61 -13
- package/ui/components/vault/vaultErrorCopy.ts +3 -1
- package/ui/components/wallet/ActivityRow.tsx +227 -123
- package/ui/components/wallet/AmountInput.tsx +26 -8
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +22 -2
- package/ui/components/wallet/Balance.tsx +42 -23
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +16 -3
- package/ui/components/wallet/ContactActivityList.tsx +149 -0
- package/ui/components/wallet/ContactSigil.tsx +49 -0
- package/ui/components/wallet/EditPictureSheet.tsx +99 -0
- package/ui/components/wallet/FitAmount.tsx +148 -0
- package/ui/components/wallet/IconPickerSheet.tsx +168 -0
- package/ui/components/wallet/IdentifierRow.tsx +69 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +35 -13
- package/ui/components/wallet/ProfileButton.tsx +62 -0
- package/ui/components/wallet/UserAvatar.tsx +85 -0
- package/ui/components/wallet/avatarIcons.ts +122 -0
- package/ui/exportTransactions.ts +36 -4
- package/ui/hooks/useContactsStore.ts +10 -0
- package/ui/hooks/useExportWalletData.ts +25 -2
- package/ui/hooks/useMandala.ts +18 -1
- package/ui/hooks/useOnline.ts +65 -20
- package/ui/importDatabases.ts +339 -24
- package/ui/index.ts +33 -2
- package/ui/isImageUrl.ts +6 -0
- package/ui/printRecoveryShares.ts +9 -10
- package/ui/recoveryPrompts.ts +91 -0
- package/ui/resolveIdentity.ts +31 -9
- package/ui/screens/ConnectionsScreen.tsx +86 -19
- package/ui/screens/ContactScreen.tsx +289 -0
- package/ui/screens/ContactsScreen.tsx +373 -0
- package/ui/screens/IdentifierScreen.tsx +256 -0
- package/ui/screens/NewContactScreen.tsx +362 -0
- package/ui/screens/PairScreen.tsx +74 -2
- package/ui/screens/PayScreen.tsx +20 -7
- package/ui/screens/ProfileScreen.tsx +783 -0
- package/ui/screens/SettingsScreen.tsx +10 -4
- package/ui/screens/TransactionDetailScreen.tsx +419 -0
- package/ui/screens/TrustScreen.tsx +100 -5
- package/ui/screens/VaultScreen.tsx +410 -61
- package/ui/screens/VaultTransferScreen.tsx +59 -7
- package/ui/screens/WalletCheckScreen.tsx +17 -6
- package/ui/screens/WalletConfigScreen.tsx +124 -28
- package/ui/screens/WalletHomeScreen.tsx +640 -104
- package/ui/screens/detailActionKeys.ts +55 -0
- package/ui/tokenFormat.ts +44 -4
- package/ui/tokenStatus.ts +21 -0
- package/ui/txStatus.ts +48 -5
- package/core/storage/LocalStorageAdapter.ts +0 -58
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PublicKey, type WalletProtocol } from '@bsv/sdk'
|
|
2
2
|
import { parseExternalOrigin, type ExternalOrigin } from './externalOrigin'
|
|
3
|
+
import { isPrivateNetworkHost } from '../net/publicDestination'
|
|
3
4
|
|
|
4
5
|
const KB = 1024
|
|
5
6
|
const MB = 1024 * KB
|
|
@@ -25,6 +26,20 @@ export const MAX_RPC_CIPHERTEXT_BYTES = MAX_RPC_PLAINTEXT_BYTES + 256
|
|
|
25
26
|
export const MAX_RPC_CIPHERTEXT_CHARS = Math.ceil(MAX_RPC_CIPHERTEXT_BYTES * 4 / 3)
|
|
26
27
|
export const MAX_RPC_WIRE_CHARS = MAX_RPC_CIPHERTEXT_CHARS + 1024
|
|
27
28
|
export const MAX_IN_FLIGHT_RPC = 4
|
|
29
|
+
/**
|
|
30
|
+
* XR-026: MAX_IN_FLIGHT_RPC bounds the COUNT of concurrent messages, but each
|
|
31
|
+
* can independently be up to MAX_RPC_PLAINTEXT_BYTES — so up to
|
|
32
|
+
* MAX_IN_FLIGHT_RPC of them decrypting at once multiplies that ceiling by up
|
|
33
|
+
* to 4x before the ~20-30x native amplification documented in
|
|
34
|
+
* walletArgLimits.ts (a single ~5 MiB call is already ~100-150 MB of peak
|
|
35
|
+
* RSS). This bounds the SUM of estimated plaintext bytes across every
|
|
36
|
+
* message currently being decrypted or dispatched on one connection, to no
|
|
37
|
+
* worse than today's already-accepted single-message ceiling — a message
|
|
38
|
+
* that would push the running total over it is dropped, exactly like the
|
|
39
|
+
* existing MAX_IN_FLIGHT_RPC count gate, rather than allowed to add to an
|
|
40
|
+
* unbounded concurrent total.
|
|
41
|
+
*/
|
|
42
|
+
export const MAX_IN_FLIGHT_RPC_BYTES = MAX_RPC_PLAINTEXT_BYTES
|
|
28
43
|
|
|
29
44
|
export interface ConnectParams {
|
|
30
45
|
topic: string
|
|
@@ -42,18 +57,48 @@ export interface ValidatedConnectParams {
|
|
|
42
57
|
expiry: number
|
|
43
58
|
}
|
|
44
59
|
|
|
45
|
-
|
|
60
|
+
/** XR-027: the protocol namespace an admin-scoped wallet derives the saved-
|
|
61
|
+
* pairing authority tag under (reserved in core/services/vault/guard.ts so a
|
|
62
|
+
* paired peer's own, site-scoped WalletClient can never mint or verify it),
|
|
63
|
+
* and the versioned transcript that tag is computed over. `expiry`/`sig` are
|
|
64
|
+
* the QR's own one-time proof and are not part of what a saved, reusable
|
|
65
|
+
* connection record needs to keep authentic. */
|
|
66
|
+
export const CONNECTION_AUTHORITY_PROTOCOL_ID: WalletProtocol = [2, 'connection authority']
|
|
67
|
+
export const CONNECTION_AUTHORITY_SIGNATURE_DOMAIN = 'bsv-wallet-connection-authority-v1'
|
|
68
|
+
/** HMAC-SHA256 output, base64url-encoded without padding (32 bytes -> 43 chars). */
|
|
69
|
+
export const CONNECTION_AUTHORITY_TAG_CHARS = 43
|
|
46
70
|
|
|
47
|
-
|
|
48
|
-
|
|
71
|
+
export interface ConnectionAuthorityTuple {
|
|
72
|
+
origin: string
|
|
73
|
+
topic: string
|
|
74
|
+
protocolID: string
|
|
75
|
+
backendIdentityKey: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Exact transcript MAC'd over the tuple a user approved. Every field that
|
|
79
|
+
* chooses the transport endpoint, its BRC-42 key namespace, or which backend
|
|
80
|
+
* it talks to is included -- an attacker who can flip any one of them without
|
|
81
|
+
* knowing the admin wallet's key can no longer produce a tag that verifies. */
|
|
82
|
+
export function buildConnectionAuthorityMessage(tuple: ConnectionAuthorityTuple): string {
|
|
83
|
+
return [
|
|
84
|
+
CONNECTION_AUTHORITY_SIGNATURE_DOMAIN,
|
|
85
|
+
tuple.origin,
|
|
86
|
+
tuple.topic,
|
|
87
|
+
tuple.protocolID,
|
|
88
|
+
tuple.backendIdentityKey
|
|
89
|
+
].join('|')
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Exact transcript signed by the desktop pairing peer, matching
|
|
93
|
+
* @bsv/wallet-relay 0.5.x (`topic|backendIdentityKey|origin|expiry`).
|
|
94
|
+
* protocolID is not signed by the library; changing this format must be
|
|
95
|
+
* coordinated with wallet-relay and every backend that uses it. */
|
|
49
96
|
export function buildPairingSignatureMessage(
|
|
50
|
-
params: Pick<Required<ConnectParams>, 'topic' | 'backendIdentityKey' | '
|
|
97
|
+
params: Pick<Required<ConnectParams>, 'topic' | 'backendIdentityKey' | 'origin' | 'expiry'>
|
|
51
98
|
): string {
|
|
52
99
|
return [
|
|
53
|
-
PAIRING_SIGNATURE_DOMAIN,
|
|
54
100
|
params.topic,
|
|
55
101
|
params.backendIdentityKey,
|
|
56
|
-
params.protocolID,
|
|
57
102
|
params.origin,
|
|
58
103
|
params.expiry
|
|
59
104
|
].join('|')
|
|
@@ -193,6 +238,24 @@ export function validateStoredConnectionFields(raw: {
|
|
|
193
238
|
return { topic, backendIdentityKey, mobileIdentityKey, protocolIDRaw: protocol.raw, protocolID: protocol.value, external }
|
|
194
239
|
}
|
|
195
240
|
|
|
241
|
+
/** XR-027: a stored connection's authority tag is untrusted AsyncStorage data
|
|
242
|
+
* like every other field above -- absent (undefined/null) means a legacy or
|
|
243
|
+
* never-tagged record, which callers must treat as "needs re-approval", the
|
|
244
|
+
* same outcome as a tag that fails verification. Anything present but not a
|
|
245
|
+
* canonical, correctly-sized base64url string is rejected outright rather
|
|
246
|
+
* than handed to verifyHmac. */
|
|
247
|
+
export function validateStoredConnectionAuthorityTag(raw: unknown): string | undefined {
|
|
248
|
+
if (raw === undefined || raw === null) return undefined
|
|
249
|
+
if (
|
|
250
|
+
typeof raw !== 'string' ||
|
|
251
|
+
raw.length !== CONNECTION_AUTHORITY_TAG_CHARS ||
|
|
252
|
+
!/^[A-Za-z0-9_-]+$/.test(raw)
|
|
253
|
+
) {
|
|
254
|
+
throw new Error('Stored connection authority tag is invalid')
|
|
255
|
+
}
|
|
256
|
+
return raw
|
|
257
|
+
}
|
|
258
|
+
|
|
196
259
|
/** SecureStore data can be corrupted or restored independently of the
|
|
197
260
|
* connection database. Only canonical sequence values that can be incremented
|
|
198
261
|
* safely for the next authenticated message are accepted. */
|
|
@@ -221,6 +284,13 @@ export function validateRelayUrl(raw: unknown): string {
|
|
|
221
284
|
if (url.pathname !== '/' || url.search || url.hash) {
|
|
222
285
|
throw new Error('Relay URL must be a bare WSS origin')
|
|
223
286
|
}
|
|
287
|
+
// XR-024 (SEC2-055): the origin server's relay URL is exactly as untrusted
|
|
288
|
+
// as the pairing origin it came from (see parseExternalOrigin) -- nothing
|
|
289
|
+
// stopped it from naming a loopback/private/link-local literal and sending
|
|
290
|
+
// the device's WebSocket connection into its own local network.
|
|
291
|
+
if (isPrivateNetworkHost(url.hostname)) {
|
|
292
|
+
throw new Error('Relay URL must not name a loopback or private-network destination')
|
|
293
|
+
}
|
|
224
294
|
return url.origin
|
|
225
295
|
}
|
|
226
296
|
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import type { AppChain } from '../config'
|
|
2
2
|
import { toWalletChain } from '../config'
|
|
3
3
|
import { getServiceConfig } from '../toolboxConfig'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
Services
|
|
7
|
-
} from '@bsv/wallet-toolbox-mobile'
|
|
8
|
-
import type {
|
|
9
|
-
BsvExchangeRate,
|
|
10
|
-
WalletServicesOptions
|
|
11
|
-
} from '@bsv/wallet-toolbox-mobile/out/src/sdk'
|
|
12
|
-
import type { ChaintracksClientApi } from '@bsv/wallet-toolbox-mobile/out/src/services/chaintracker/chaintracks/Api/ChaintracksClientApi'
|
|
4
|
+
import { ChaintracksServiceClient, Services } from '@bsv/wallet-toolbox-mobile'
|
|
5
|
+
import type { ChaintracksClientApi } from '@bsv/wallet-toolbox-mobile'
|
|
13
6
|
import type { ChainTracker } from '@bsv/sdk'
|
|
7
|
+
import type { BsvExchangeRate, WalletServicesOptions } from '../toolboxTypes'
|
|
14
8
|
|
|
15
9
|
/**
|
|
16
10
|
* The chaintracks URL for a network — the one place this table is defined.
|
|
@@ -80,18 +74,45 @@ export function createServiceOptions(
|
|
|
80
74
|
}
|
|
81
75
|
}
|
|
82
76
|
|
|
77
|
+
// One resolved Arcade endpoint feeds BOTH option slots. `arcUrl` is the
|
|
78
|
+
// toolbox's generic ARC slot (broadcast fallback, `services.arcTaal`).
|
|
79
|
+
// `arcadeUrl` is what makes `Services` construct its `Arcade` provider —
|
|
80
|
+
// and that provider is the only `getMerklePath` source that can answer for
|
|
81
|
+
// a transaction the moment Arcade sees it mined (GET /tx/{txid} carries
|
|
82
|
+
// the BUMP), and the only thing `TaskArcadeSSE` will subscribe to. Without
|
|
83
|
+
// it every proof lookup went straight to WhatsOnChain/Bitails, and the
|
|
84
|
+
// monitor logged "no arcadeUrl configured; SSE disabled" on every start —
|
|
85
|
+
// a nosend received while online sat unrecognised for 12 h on 2026-09-18
|
|
86
|
+
// while the explorer showed it with 6 confirmations.
|
|
87
|
+
const arcadeUrl =
|
|
88
|
+
arcUrlOverride ??
|
|
89
|
+
svc.arcUrl ??
|
|
90
|
+
(network === 'main'
|
|
91
|
+
? 'https://arcade-v2-us-1.bsvblockchain.tech'
|
|
92
|
+
: network === 'test'
|
|
93
|
+
? 'https://arcade-v2-testnet-us-1.bsvblockchain.tech'
|
|
94
|
+
: 'https://arcade-v2-ttn-us-1.bsvblockchain.tech')
|
|
95
|
+
const arcConfig = {
|
|
96
|
+
apiKey: arcApiKeyOverride ?? svc.arcApiKey ?? '',
|
|
97
|
+
// Must equal the Monitor's callbackToken so Arcade routes this wallet's
|
|
98
|
+
// status events to its SSE subscription (WalletServicesOptions.arcadeConfig).
|
|
99
|
+
callbackToken
|
|
100
|
+
}
|
|
101
|
+
const arcade = { arcUrl: arcadeUrl, arcConfig, arcadeUrl, arcadeConfig: arcConfig }
|
|
102
|
+
|
|
103
|
+
// XR-066: taalApiKey must never fall back to whatsOnChainApiKey. TAAL and
|
|
104
|
+
// WhatsOnChain are different origins (createTaalBroadcastService sends
|
|
105
|
+
// this key as a Bearer token to arc.taal.com et al. on every ordinary
|
|
106
|
+
// broadcast) — a host that scoped a key to WhatsOnChain must not have it
|
|
107
|
+
// silently disclosed to TAAL just because it left taalApiKey unset.
|
|
83
108
|
if (network === 'main') {
|
|
84
109
|
return {
|
|
85
110
|
...base,
|
|
86
|
-
|
|
87
|
-
arcConfig: {
|
|
88
|
-
apiKey: arcApiKeyOverride ?? svc.arcApiKey ?? '',
|
|
89
|
-
callbackToken
|
|
90
|
-
},
|
|
111
|
+
...arcade,
|
|
91
112
|
bsvUpdateMsecs: 60 * 60 * 1000,
|
|
92
113
|
fiatUpdateMsecs: 60 * 60 * 1000,
|
|
93
114
|
whatsOnChainApiKey: svc.whatsOnChainApiKey ?? '',
|
|
94
|
-
taalApiKey: svc.taalApiKey ??
|
|
115
|
+
taalApiKey: svc.taalApiKey ?? '',
|
|
95
116
|
chaintracks: chaintracksOverride ?? new ChaintracksServiceClient(walletChain, chaintracksUrlFor(network))
|
|
96
117
|
}
|
|
97
118
|
}
|
|
@@ -99,15 +120,11 @@ export function createServiceOptions(
|
|
|
99
120
|
if (network === 'test') {
|
|
100
121
|
return {
|
|
101
122
|
...base,
|
|
102
|
-
|
|
103
|
-
arcConfig: {
|
|
104
|
-
apiKey: arcApiKeyOverride ?? svc.arcApiKey ?? '',
|
|
105
|
-
callbackToken
|
|
106
|
-
},
|
|
123
|
+
...arcade,
|
|
107
124
|
bsvUpdateMsecs: 60 * 60 * 1000000,
|
|
108
125
|
fiatUpdateMsecs: 60 * 60 * 1000000,
|
|
109
126
|
whatsOnChainApiKey: svc.whatsOnChainApiKey ?? '',
|
|
110
|
-
taalApiKey: svc.taalApiKey ??
|
|
127
|
+
taalApiKey: svc.taalApiKey ?? '',
|
|
111
128
|
chaintracks: chaintracksOverride ?? new ChaintracksServiceClient(walletChain, chaintracksUrlFor(network))
|
|
112
129
|
}
|
|
113
130
|
}
|
|
@@ -115,15 +132,11 @@ export function createServiceOptions(
|
|
|
115
132
|
// teratest
|
|
116
133
|
return {
|
|
117
134
|
...base,
|
|
118
|
-
|
|
119
|
-
arcConfig: {
|
|
120
|
-
apiKey: arcApiKeyOverride ?? svc.arcApiKey ?? '',
|
|
121
|
-
callbackToken
|
|
122
|
-
},
|
|
135
|
+
...arcade,
|
|
123
136
|
bsvUpdateMsecs: 60 * 60 * 1000000,
|
|
124
137
|
fiatUpdateMsecs: 60 * 60 * 1000000,
|
|
125
138
|
whatsOnChainApiKey: svc.whatsOnChainApiKey ?? '',
|
|
126
|
-
taalApiKey: svc.taalApiKey ??
|
|
139
|
+
taalApiKey: svc.taalApiKey ?? '',
|
|
127
140
|
chaintracks: chaintracksOverride ?? new ChaintracksServiceClient(walletChain, chaintracksUrlFor(network))
|
|
128
141
|
}
|
|
129
142
|
}
|
|
@@ -3,6 +3,7 @@ import type { SQLiteDatabase } from 'expo-sqlite'
|
|
|
3
3
|
import { createTables, ensureOfflineActionsColumns } from './schema/createTables'
|
|
4
4
|
import {
|
|
5
5
|
PROVEN_HEIGHTS_SQL,
|
|
6
|
+
PROVEN_HEIGHT_SQL,
|
|
6
7
|
buildFindSql,
|
|
7
8
|
columnsExcluding,
|
|
8
9
|
rangeReadSql,
|
|
@@ -21,38 +22,11 @@ import {
|
|
|
21
22
|
} from './methods/reclaim'
|
|
22
23
|
import { availableDiskBytes, diskPressure } from '../diskSpace'
|
|
23
24
|
import { devLog } from '../logging'
|
|
24
|
-
import { StorageProvider } from '@bsv/wallet-toolbox-mobile'
|
|
25
|
-
import type { StorageProviderOptions } from '@bsv/wallet-toolbox-mobile'
|
|
26
|
-
import type {
|
|
27
|
-
AuthId,
|
|
28
|
-
FindCertificateFieldsArgs,
|
|
29
|
-
FindCertificatesArgs,
|
|
30
|
-
FindCommissionsArgs,
|
|
31
|
-
FindMonitorEventsArgs,
|
|
32
|
-
FindOutputBasketsArgs,
|
|
33
|
-
FindOutputsArgs,
|
|
34
|
-
FindOutputTagsArgs,
|
|
35
|
-
FindOutputTagMapsArgs,
|
|
36
|
-
FindProvenTxReqsArgs,
|
|
37
|
-
FindProvenTxsArgs,
|
|
38
|
-
FindSyncStatesArgs,
|
|
39
|
-
FindTransactionsArgs,
|
|
40
|
-
FindTxLabelsArgs,
|
|
41
|
-
FindTxLabelMapsArgs,
|
|
42
|
-
FindUsersArgs,
|
|
43
|
-
FindForUserSincePagedArgs,
|
|
44
|
-
ProcessSyncChunkResult,
|
|
45
|
-
ProvenOrRawTx,
|
|
46
|
-
PurgeParams,
|
|
47
|
-
PurgeResults,
|
|
48
|
-
RequestSyncChunkArgs,
|
|
49
|
-
StorageProcessActionArgs,
|
|
50
|
-
StorageProcessActionResults,
|
|
51
|
-
SyncChunk,
|
|
52
|
-
TrxToken
|
|
53
|
-
} from '@bsv/wallet-toolbox-mobile/out/src/sdk/WalletStorage.interfaces'
|
|
54
|
-
import type { AdminStatsResult } from '@bsv/wallet-toolbox-mobile/out/src/storage/StorageProvider'
|
|
25
|
+
import { EntityProvenTxReq, StorageProvider } from '@bsv/wallet-toolbox-mobile'
|
|
55
26
|
import type {
|
|
27
|
+
AdminStatsResult,
|
|
28
|
+
PostReqsToNetworkResult,
|
|
29
|
+
StorageProviderOptions,
|
|
56
30
|
TableCertificate,
|
|
57
31
|
TableCertificateField,
|
|
58
32
|
TableCertificateX,
|
|
@@ -70,11 +44,9 @@ import type {
|
|
|
70
44
|
TableTxLabel,
|
|
71
45
|
TableTxLabelMap,
|
|
72
46
|
TableUser
|
|
73
|
-
} from '@bsv/wallet-toolbox-mobile
|
|
47
|
+
} from '@bsv/wallet-toolbox-mobile'
|
|
74
48
|
import type { ListActionsResult, ListOutputsResult, Validation, WalletLoggerInterface } from '@bsv/sdk'
|
|
75
49
|
import { Beef, Transaction } from '@bsv/sdk'
|
|
76
|
-
import { EntityProvenTxReq } from '@bsv/wallet-toolbox-mobile/out/src/storage/schema/entities'
|
|
77
|
-
import type { PostReqsToNetworkResult } from '@bsv/wallet-toolbox-mobile/out/src/storage/methods/attemptToPostReqsToNetwork'
|
|
78
50
|
import { listActionsSql } from './methods/listActionsSql'
|
|
79
51
|
import { listOutputsSql } from './methods/listOutputsSql'
|
|
80
52
|
import { findUnprovenTxidsWithoutReq } from './methods/unprovenWithoutReqSql'
|
|
@@ -95,6 +67,34 @@ import { buildOfflineHoldResult, groupOfflineHolds } from '../offline/hold'
|
|
|
95
67
|
import { getOnline } from '../net/online'
|
|
96
68
|
import { TaskSendOffline } from '../monitor/TaskSendOffline'
|
|
97
69
|
import { isR1CLockingScript } from '../services/vault/guard'
|
|
70
|
+
import type {
|
|
71
|
+
AuthId,
|
|
72
|
+
FindCertificateFieldsArgs,
|
|
73
|
+
FindCertificatesArgs,
|
|
74
|
+
FindCommissionsArgs,
|
|
75
|
+
FindMonitorEventsArgs,
|
|
76
|
+
FindOutputBasketsArgs,
|
|
77
|
+
FindOutputsArgs,
|
|
78
|
+
FindOutputTagsArgs,
|
|
79
|
+
FindOutputTagMapsArgs,
|
|
80
|
+
FindProvenTxReqsArgs,
|
|
81
|
+
FindProvenTxsArgs,
|
|
82
|
+
FindSyncStatesArgs,
|
|
83
|
+
FindTransactionsArgs,
|
|
84
|
+
FindTxLabelsArgs,
|
|
85
|
+
FindTxLabelMapsArgs,
|
|
86
|
+
FindUsersArgs,
|
|
87
|
+
FindForUserSincePagedArgs,
|
|
88
|
+
ProcessSyncChunkResult,
|
|
89
|
+
ProvenOrRawTx,
|
|
90
|
+
PurgeParams,
|
|
91
|
+
PurgeResults,
|
|
92
|
+
RequestSyncChunkArgs,
|
|
93
|
+
StorageProcessActionArgs,
|
|
94
|
+
StorageProcessActionResults,
|
|
95
|
+
SyncChunk,
|
|
96
|
+
TrxToken
|
|
97
|
+
} from '../toolboxTypes'
|
|
98
98
|
|
|
99
99
|
export interface StorageExpoSQLiteOptions extends StorageProviderOptions {
|
|
100
100
|
databaseName?: string
|
|
@@ -1166,7 +1166,9 @@ export class StorageExpoSQLite extends StorageProvider {
|
|
|
1166
1166
|
args,
|
|
1167
1167
|
'transactionId',
|
|
1168
1168
|
extraConditions.length > 0 ? { conditions: extraConditions, params: extraParams } : undefined,
|
|
1169
|
-
|
|
1169
|
+
// NEW-01: noSendExpiryReclaimRawTx is the other large blob TABLE_COLUMNS
|
|
1170
|
+
// now lists for this table — exclude it too, or noRawTx stops being cheap.
|
|
1171
|
+
args.noRawTx ? columnsExcluding('transactions', ['rawTx', 'inputBEEF', 'noSendExpiryReclaimRawTx']) : undefined
|
|
1170
1172
|
)
|
|
1171
1173
|
|
|
1172
1174
|
const results = this.validateEntities(rows, undefined, ['isOutgoing'])
|
|
@@ -1653,6 +1655,13 @@ export class StorageExpoSQLite extends StorageProvider {
|
|
|
1653
1655
|
return map
|
|
1654
1656
|
}
|
|
1655
1657
|
|
|
1658
|
+
/** The block height of a proven transaction, or null while it is unproven. */
|
|
1659
|
+
async getProvenTxHeight(txid: string): Promise<number | null> {
|
|
1660
|
+
if (!this.isAvailable()) await this.makeAvailable()
|
|
1661
|
+
const row = (await this.getDB().getFirstAsync(PROVEN_HEIGHT_SQL, [txid])) as { height?: number } | null
|
|
1662
|
+
return typeof row?.height === 'number' ? row.height : null
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1656
1665
|
async getRawTxOfKnownValidTransaction(
|
|
1657
1666
|
txid?: string,
|
|
1658
1667
|
offset?: number,
|
|
@@ -2097,12 +2106,21 @@ export class StorageExpoSQLite extends StorageProvider {
|
|
|
2097
2106
|
}
|
|
2098
2107
|
|
|
2099
2108
|
/**
|
|
2100
|
-
* Which of these txids the Mandala settlement drain owns
|
|
2109
|
+
* Which of these txids the Mandala settlement drain owns — THROWS if the
|
|
2110
|
+
* read itself could not be answered.
|
|
2101
2111
|
*
|
|
2102
|
-
*
|
|
2103
|
-
*
|
|
2104
|
-
*
|
|
2105
|
-
*
|
|
2112
|
+
* XR-045: this used to collapse "the read failed" into the same empty set as
|
|
2113
|
+
* "no token requests here", which is exactly what "treat it as plain BSV"
|
|
2114
|
+
* means to every caller — so a transient SQLite fault (busy/locked, a
|
|
2115
|
+
* corrupt page) on a table that had just been written to successfully
|
|
2116
|
+
* looked identical to "this feature does not apply", and an unadmitted token
|
|
2117
|
+
* request went straight to broadcast. Never swallowed here any more: each
|
|
2118
|
+
* caller already decides what a failure costs it — `holdTokenReqsForDrain`
|
|
2119
|
+
* withholds its whole batch on any exception, and `attemptToPostReqsToNetwork`
|
|
2120
|
+
* (guard #2, the one that can actually broadcast) does the same rather than
|
|
2121
|
+
* deciding off an incomplete answer. `heldTokenTxidsIn` (guard #2's result
|
|
2122
|
+
* half, reporting only) already documented "read failures propagate; the one
|
|
2123
|
+
* caller decides" — this is what makes that true.
|
|
2106
2124
|
*/
|
|
2107
2125
|
private async tokenSettlementTxids(txids: string[]): Promise<Set<string>> {
|
|
2108
2126
|
if (txids.length === 0 || !this.db) return new Set()
|
|
@@ -2113,8 +2131,8 @@ export class StorageExpoSQLite extends StorageProvider {
|
|
|
2113
2131
|
)) as { txid: string }[]
|
|
2114
2132
|
return new Set(rows.map(r => r.txid))
|
|
2115
2133
|
} catch (e) {
|
|
2116
|
-
devLog('[StorageExpoSQLite] could not read token_settlements
|
|
2117
|
-
|
|
2134
|
+
devLog('[StorageExpoSQLite] could not read token_settlements:', e)
|
|
2135
|
+
throw e
|
|
2118
2136
|
}
|
|
2119
2137
|
}
|
|
2120
2138
|
|
|
@@ -2221,10 +2239,20 @@ export class StorageExpoSQLite extends StorageProvider {
|
|
|
2221
2239
|
try {
|
|
2222
2240
|
heldTokenTxids = await this.heldTokenTxidsIn(swr.map(s => s.txid))
|
|
2223
2241
|
} catch (e) {
|
|
2224
|
-
//
|
|
2225
|
-
//
|
|
2226
|
-
|
|
2227
|
-
|
|
2242
|
+
// XR-045/SEC2-070: a read fault here means this call cannot tell which of
|
|
2243
|
+
// these txids are held token requests — "could not determine" must not
|
|
2244
|
+
// resolve to "report as delivered", which is exactly the false 'unproven'
|
|
2245
|
+
// signal that let @bsv/mandala's broadcastAcceptedTx clear an 'accepted'
|
|
2246
|
+
// journal entry for a transaction nothing had broadcast on 2026-09-15.
|
|
2247
|
+
// Mirror the fail-closed policy already applied to the broadcast guard
|
|
2248
|
+
// (attemptToPostReqsToNetwork holds the WHOLE batch on this identical
|
|
2249
|
+
// fault): treat every txid here as if it were held, so every entry is
|
|
2250
|
+
// omitted below rather than any of them being reported as sent.
|
|
2251
|
+
devLog(
|
|
2252
|
+
'[StorageExpoSQLite] could not check held token reqs for sendWithResults; omitting all rather than reporting a possibly-false delivery:',
|
|
2253
|
+
e
|
|
2254
|
+
)
|
|
2255
|
+
heldTokenTxids = new Set(swr.map(s => s.txid))
|
|
2228
2256
|
}
|
|
2229
2257
|
if (heldTokenTxids.size === 0) return r
|
|
2230
2258
|
|
|
@@ -2259,7 +2287,20 @@ export class StorageExpoSQLite extends StorageProvider {
|
|
|
2259
2287
|
): Promise<PostReqsToNetworkResult> {
|
|
2260
2288
|
if (reqs.length === 0) return await super.attemptToPostReqsToNetwork(reqs, trx, logger)
|
|
2261
2289
|
|
|
2262
|
-
|
|
2290
|
+
let tokenTxids: Set<string>
|
|
2291
|
+
try {
|
|
2292
|
+
tokenTxids = await this.tokenSettlementTxids(reqs.map(r => r.txid))
|
|
2293
|
+
} catch (e) {
|
|
2294
|
+
// XR-045: the read could not be answered, so this call does not know
|
|
2295
|
+
// which of `reqs` are token requests — and "I could not tell" must never
|
|
2296
|
+
// resolve to "post them", the exact fail-open this guard exists to
|
|
2297
|
+
// prevent. Hold the WHOLE batch, as if every txid in it needed the
|
|
2298
|
+
// drain: a plain BSV req held this way is not lost, only delayed until
|
|
2299
|
+
// `processOfflineActions` (or a later, healthy read) finds no settlement
|
|
2300
|
+
// row for it and posts it normally.
|
|
2301
|
+
devLog('[StorageExpoSQLite] could not read token_settlements; holding the whole batch rather than guessing:', e)
|
|
2302
|
+
tokenTxids = new Set(reqs.map(r => r.txid))
|
|
2303
|
+
}
|
|
2263
2304
|
const tokenReqs = tokenTxids.size > 0 ? reqs.filter(r => tokenTxids.has(r.txid)) : []
|
|
2264
2305
|
const rest = tokenTxids.size > 0 ? reqs.filter(r => !tokenTxids.has(r.txid)) : reqs
|
|
2265
2306
|
|
|
@@ -67,7 +67,23 @@ export const TABLE_COLUMNS: Record<string, string[]> = {
|
|
|
67
67
|
'txid',
|
|
68
68
|
'inputBEEF',
|
|
69
69
|
'rawTx',
|
|
70
|
-
'provenTxId'
|
|
70
|
+
'provenTxId',
|
|
71
|
+
// NEW-01: BRC-177 lifecycle columns (core/storage/schema/createTables.ts's
|
|
72
|
+
// ensureTransactionsColumns) — without these here, a noRawTx-projected
|
|
73
|
+
// findTransactions() silently drops them even though the table has them.
|
|
74
|
+
'noSendExpiryMode',
|
|
75
|
+
'noSendExpiryValue',
|
|
76
|
+
'noSendExpiryDeadline',
|
|
77
|
+
'noSendExpiryState',
|
|
78
|
+
'noSendExpiryAnchorTxid',
|
|
79
|
+
'noSendExpiryAnchorVout',
|
|
80
|
+
'noSendExpiryReleasedAt',
|
|
81
|
+
'noSendExpiryObservedAt',
|
|
82
|
+
'noSendExpiryReclaimTxid',
|
|
83
|
+
'noSendExpiryReclaimRawTx',
|
|
84
|
+
'noSendExpiryReclaimDerivationPrefix',
|
|
85
|
+
'noSendExpiryReclaimDerivationSuffix',
|
|
86
|
+
'noSendExpiryReclaimSatoshis'
|
|
71
87
|
],
|
|
72
88
|
outputs: [
|
|
73
89
|
'outputId',
|
|
@@ -113,7 +129,10 @@ export const TABLE_COLUMNS: Record<string, string[]> = {
|
|
|
113
129
|
export const BLOB_COLUMNS: Record<string, string[]> = {
|
|
114
130
|
proven_txs: ['merklePath', 'rawTx'],
|
|
115
131
|
proven_tx_reqs: ['rawTx', 'inputBEEF'],
|
|
116
|
-
|
|
132
|
+
// NEW-01: noSendExpiryReclaimRawTx is a BLOB (the signed reclaim tx bytes)
|
|
133
|
+
// exactly like rawTx/inputBEEF — declared here so writes go through the same
|
|
134
|
+
// explicit bytesForColumn() path as every other blob column.
|
|
135
|
+
transactions: ['inputBEEF', 'rawTx', 'noSendExpiryReclaimRawTx'],
|
|
117
136
|
outputs: ['lockingScript'],
|
|
118
137
|
commissions: ['lockingScript']
|
|
119
138
|
}
|
|
@@ -204,6 +223,9 @@ export function rangeReadSql(table: 'proven_txs' | 'proven_tx_reqs'): string {
|
|
|
204
223
|
*/
|
|
205
224
|
export const PROVEN_HEIGHTS_SQL = 'SELECT txid, height FROM proven_txs'
|
|
206
225
|
|
|
226
|
+
/** One transaction's block height, without reading its rawTx or merklePath. */
|
|
227
|
+
export const PROVEN_HEIGHT_SQL = 'SELECT height FROM proven_txs WHERE txid = ? LIMIT 1'
|
|
228
|
+
|
|
207
229
|
/**
|
|
208
230
|
* The transactions that have reserved the given outpoints, by `reference`.
|
|
209
231
|
*
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
* Handles specOp patterns (noSend actions, failed actions, etc.)
|
|
5
5
|
*/
|
|
6
6
|
import type { ListActionsResult, Validation } from '@bsv/sdk'
|
|
7
|
-
import type { AuthId } from '@bsv/wallet-toolbox-mobile/out/src/sdk/WalletStorage.interfaces'
|
|
8
7
|
import type { StorageExpoSQLite } from '../StorageExpoSQLite'
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import {
|
|
9
|
+
getLabelToSpecOp,
|
|
10
|
+
makeBrc114ActionTimeLabel,
|
|
11
|
+
parseBrc114ActionTimeLabels,
|
|
12
|
+
sdk as toolboxSdk
|
|
13
|
+
} from '@bsv/wallet-toolbox-mobile'
|
|
14
|
+
import type { AuthId } from '../../toolboxTypes'
|
|
12
15
|
|
|
13
16
|
export async function listActionsSql(
|
|
14
17
|
storage: StorageExpoSQLite,
|
|
@@ -32,7 +35,7 @@ export async function listActionsSql(
|
|
|
32
35
|
let specOpLabels: string[] = []
|
|
33
36
|
let labels: string[] = []
|
|
34
37
|
for (const label of ordinaryLabelsPreSpecOp) {
|
|
35
|
-
if (isListActionsSpecOp(label)) {
|
|
38
|
+
if (toolboxSdk.isListActionsSpecOp(label)) {
|
|
36
39
|
specOp = getLabelToSpecOp()[label]
|
|
37
40
|
} else {
|
|
38
41
|
labels.push(label)
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Handles specOp patterns (wallet balance, invalid change, etc.)
|
|
5
5
|
*/
|
|
6
6
|
import type { ListOutputsResult, Validation } from '@bsv/sdk'
|
|
7
|
-
import type { AuthId } from '@bsv/wallet-toolbox-mobile/out/src/sdk/WalletStorage.interfaces'
|
|
8
7
|
import type { StorageExpoSQLite } from '../StorageExpoSQLite'
|
|
9
|
-
import { getListOutputsSpecOp } from '@bsv/wallet-toolbox-mobile
|
|
8
|
+
import { getListOutputsSpecOp } from '@bsv/wallet-toolbox-mobile'
|
|
10
9
|
import { devLog, isLoggingEnabled } from '../../logging'
|
|
11
10
|
import { BALANCE_TX_STATUS } from './walletBalanceSql'
|
|
11
|
+
import type { AuthId } from '../../toolboxTypes'
|
|
12
12
|
|
|
13
13
|
export async function listOutputsSql(
|
|
14
14
|
storage: StorageExpoSQLite,
|
|
@@ -11,8 +11,17 @@
|
|
|
11
11
|
* 'queued'/'posting', so a parked row is inert by construction — it exists to
|
|
12
12
|
* keep the frame (for re-showing the code) and to keep the transaction
|
|
13
13
|
* cancellable.
|
|
14
|
+
*
|
|
15
|
+
* `import_hold` is the same kind of deliberately-inert status, written only by
|
|
16
|
+
* ui/importDatabases.ts: a raw database import downgrades every 'queued'/
|
|
17
|
+
* 'posting' row it copies in to this status so the automatic post-build drain
|
|
18
|
+
* (WalletContext's TaskSendOffline) cannot rebroadcast an already-signed
|
|
19
|
+
* payment the user may have aborted, without a renewed review (XR-085). No
|
|
20
|
+
* query anywhere promotes a row out of 'import_hold' — until that review UI
|
|
21
|
+
* exists, an imported queue row stays held rather than being silently dropped
|
|
22
|
+
* or silently resumed.
|
|
14
23
|
*/
|
|
15
|
-
export type OfflineActionStatus = 'queued' | 'posting' | 'sent' | 'rejected' | 'acknowledged' | 'parked'
|
|
24
|
+
export type OfflineActionStatus = 'queued' | 'posting' | 'sent' | 'rejected' | 'acknowledged' | 'parked' | 'import_hold'
|
|
16
25
|
export type OfflineActionRole = 'received' | 'sent'
|
|
17
26
|
|
|
18
27
|
export interface OfflineActionRow {
|