@bsv/expo-wallet-toolbox 0.23.0 → 0.24.1

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 (86) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +1 -4
  3. package/android/build.gradle +15 -0
  4. package/android/src/main/AndroidManifest.xml +3 -0
  5. package/android/src/main/java/org/bsv/boundedfetch/BoundedBody.java +19 -0
  6. package/android/src/main/java/org/bsv/boundedfetch/BoundedConnection.java +28 -0
  7. package/android/src/main/java/org/bsv/boundedfetch/BsvBoundedFetchModule.kt +114 -0
  8. package/core/backup/RemoteSyncReader.ts +71 -46
  9. package/core/backup/client.ts +6 -15
  10. package/core/backup/codec.ts +78 -13
  11. package/core/backup/constants.ts +3 -9
  12. package/core/backup/cursor.ts +8 -0
  13. package/core/backup/push.ts +26 -16
  14. package/core/backup/restore.ts +6 -5
  15. package/core/bridge/inbox.ts +169 -64
  16. package/core/bridge/memoryInboxStore.ts +10 -1
  17. package/core/constants.ts +7 -11
  18. package/core/context/WalletConnectionContext.tsx +85 -48
  19. package/core/context/WalletContext.tsx +30 -32
  20. package/core/context/usePairingAttempt.ts +31 -0
  21. package/core/e2e/broadcaster.ts +25 -0
  22. package/core/e2e/consentFixture.ts +46 -0
  23. package/core/e2e/mode.ts +42 -0
  24. package/core/headers/OfflineFirstChaintracks.ts +57 -107
  25. package/core/headers/headerConsensus.ts +230 -0
  26. package/core/headers/headerStore.ts +344 -122
  27. package/core/headers/prewarm.ts +4 -7
  28. package/core/headers/syncHeaders.ts +82 -12
  29. package/core/i18n/translations.tsx +47 -12
  30. package/core/identity/handleRegistry/client.ts +4 -2
  31. package/core/identity/handleRegistry/resolver.ts +7 -11
  32. package/core/index.ts +2 -0
  33. package/core/localpay/pending.ts +39 -4
  34. package/core/network/boundedFetch.ts +101 -0
  35. package/core/networks.ts +11 -13
  36. package/core/pay/rails/address.ts +5 -4
  37. package/core/pay/rails/handle.ts +3 -1
  38. package/core/pay/rails/sweep.ts +791 -0
  39. package/core/peerpay/brc29.ts +4 -0
  40. package/core/peerpay/handleResendRequests.ts +15 -2
  41. package/core/peerpay/outbox.ts +115 -2
  42. package/core/profiles/assertProfileEmpty.ts +2 -2
  43. package/core/profiles/profileStore.ts +3 -2
  44. package/core/services/arcadeBroadcastProvider.ts +260 -114
  45. package/core/services/secrets/kek.ts +5 -0
  46. package/core/services/secrets/migration.ts +27 -2
  47. package/core/services/secrets/policy.ts +6 -0
  48. package/core/services/vault/VaultKeyService.ts +5 -2
  49. package/core/services/vault/ceremony.ts +2 -2
  50. package/core/services/vault/ceremonyHost.ts +1 -1
  51. package/core/services/vault/guard.ts +10 -0
  52. package/core/services/vault/outputAuthority.ts +76 -0
  53. package/core/services/vault/transfers.ts +52 -28
  54. package/core/services/vault/vaultStore.ts +60 -14
  55. package/core/services/walletConnectionValidation.ts +13 -1
  56. package/core/services/walletServiceConfig.ts +8 -7
  57. package/core/stores/ConnectionStore.ts +17 -0
  58. package/core/toolboxConfig.ts +60 -1
  59. package/expo-module.config.json +5 -0
  60. package/ios/BoundedBody.swift +15 -0
  61. package/ios/BsvBoundedFetch.podspec +17 -0
  62. package/ios/BsvBoundedFetchModule.swift +134 -0
  63. package/package.json +7 -3
  64. package/ui/components/pay/AddressReceive.tsx +6 -2
  65. package/ui/components/pay/ImportedOutboxApproval.tsx +142 -0
  66. package/ui/components/pay/PayCellRow.tsx +3 -1
  67. package/ui/components/pay/PayForm.tsx +12 -2
  68. package/ui/components/pay/RecipientField.tsx +1 -0
  69. package/ui/components/pay/RequestHub.tsx +1 -0
  70. package/ui/components/pay/UniversalSend.tsx +110 -42
  71. package/ui/components/ui/ListRow.tsx +10 -2
  72. package/ui/components/vault/KeyChooser.tsx +1 -1
  73. package/ui/components/wallet/AmountInput.tsx +4 -1
  74. package/ui/components/wallet/BackupReminderSheet.tsx +8 -1
  75. package/ui/components/wallet/BiometricAdvisoryModal.tsx +2 -0
  76. package/ui/components/wallet/ImportFromBackupPrompt.tsx +6 -1
  77. package/ui/components/wallet/ProfileButton.tsx +1 -0
  78. package/ui/importDatabases.ts +31 -6
  79. package/ui/screens/ConnectionsScreen.tsx +12 -3
  80. package/ui/screens/PairScreen.tsx +10 -3
  81. package/ui/screens/PayScreen.tsx +1 -0
  82. package/ui/screens/TrustScreen.tsx +6 -3
  83. package/ui/screens/VaultScreen.tsx +13 -3
  84. package/ui/screens/VaultTransferScreen.tsx +6 -3
  85. package/ui/screens/WalletConfigScreen.tsx +17 -2
  86. package/ui/screens/WalletHomeScreen.tsx +7 -1
package/core/networks.ts CHANGED
@@ -52,15 +52,13 @@ export interface NetworkProfile {
52
52
  * place, but no new wallet can be put on it.
53
53
  */
54
54
  available: boolean
55
- /** Default Arcade origin (broadcast, SSE, and `/chaintracks/v1`). */
55
+ /** Default BSV Broadcaster origin (broadcast, SSE, and `/chaintracks/v1`). */
56
56
  arcadeUrl: string
57
57
  /** Default MessageBox origin. Each network has its own server. */
58
58
  messageBoxUrl: string
59
59
  /** Undefined on a network with no WhatsOnChain: address rails, WoC proofs and explorer links are off. */
60
60
  woc?: WocEndpoints
61
- /** TAAL ARC broadcast fallback, where TAAL runs one. */
62
- taalArcUrl?: string
63
- /** GorillaPool ARC broadcast fallback, where GorillaPool runs one. */
61
+ /** GorillaPool's BSV Broadcaster root (posts to `/tx`), where GorillaPool runs one. */
64
62
  gorillaPoolArcUrl?: string
65
63
  /** Whether Bitails (the toolbox's built-in provider) serves this network. */
66
64
  bitails: boolean
@@ -80,11 +78,10 @@ export const NETWORKS: Record<AppChain, NetworkProfile> = {
80
78
  main: {
81
79
  available: true,
82
80
  walletChain: 'main',
83
- arcadeUrl: 'https://arcade-v2-us-1.bsvblockchain.tech',
81
+ arcadeUrl: 'https://broadcast.bsvblockchain.tech',
84
82
  messageBoxUrl: 'https://messagebox.bsvblockchain.tech',
85
83
  woc: { apiBase: 'https://api.whatsonchain.com', segment: 'main', explorerBase: 'https://whatsonchain.com' },
86
- taalArcUrl: 'https://arc.taal.com',
87
- gorillaPoolArcUrl: 'https://arc.gorillapool.io',
84
+ gorillaPoolArcUrl: 'https://arcade.gorillapool.io',
88
85
  bitails: true,
89
86
  overlayPreset: 'mainnet',
90
87
  push: true
@@ -92,10 +89,10 @@ export const NETWORKS: Record<AppChain, NetworkProfile> = {
92
89
  test: {
93
90
  available: true,
94
91
  walletChain: 'test',
95
- arcadeUrl: 'https://arcade-v2-testnet-us-1.bsvblockchain.tech',
92
+ arcadeUrl: 'https://broadcast.bsvblockchain.tech/testnet',
96
93
  messageBoxUrl: 'https://messagebox-testnet.bsvblockchain.tech',
97
94
  woc: { apiBase: 'https://api.whatsonchain.com', segment: 'test', explorerBase: 'https://test.whatsonchain.com' },
98
- taalArcUrl: 'https://arc-test.taal.com',
95
+ gorillaPoolArcUrl: 'https://testnet.arcade.gorillapool.io',
99
96
  bitails: true,
100
97
  overlayPreset: 'testnet',
101
98
  push: false
@@ -103,7 +100,7 @@ export const NETWORKS: Record<AppChain, NetworkProfile> = {
103
100
  teratest: {
104
101
  available: true,
105
102
  walletChain: 'ttn',
106
- arcadeUrl: 'https://arcade-v2-ttn-us-1.bsvblockchain.tech',
103
+ arcadeUrl: 'https://broadcast.bsvblockchain.tech/ttn',
107
104
  messageBoxUrl: 'https://messagebox-ttn.bsvblockchain.tech',
108
105
  woc: {
109
106
  apiBase: 'https://api.woc-ttn.bsvblockchain.tech',
@@ -114,8 +111,9 @@ export const NETWORKS: Record<AppChain, NetworkProfile> = {
114
111
  overlayPreset: 'teratestnet',
115
112
  push: false
116
113
  },
117
- // The scaling teratestnet. Arcade, chaintracks and MessageBox only: there is
118
- // no WhatsOnChain, explorer or overlay for it.
114
+ // The scaling teratestnet. BSV Broadcaster, chaintracks and MessageBox only:
115
+ // there is no WhatsOnChain, explorer or overlay for it. The `/tstn`
116
+ // chaintracks now reports `tstn`; `available` stays false.
119
117
  //
120
118
  // Not available yet. The deployed chain runs Teranode regtest parameters
121
119
  // (regtest genesis 0f9188f1…, bits 0x207fffff; its chaintracks reports
@@ -127,7 +125,7 @@ export const NETWORKS: Record<AppChain, NetworkProfile> = {
127
125
  scaletest: {
128
126
  walletChain: 'regtest',
129
127
  available: false,
130
- arcadeUrl: 'https://arcade-tstn-us-1.bsvblockchain.tech',
128
+ arcadeUrl: 'https://broadcast.bsvblockchain.tech/tstn',
131
129
  messageBoxUrl: 'https://messagebox-tstn.bsvblockchain.tech',
132
130
  bitails: false,
133
131
  overlayPreset: 'local',
@@ -18,15 +18,15 @@ import {
18
18
  Transaction,
19
19
  Utils,
20
20
  type InternalizeActionArgs,
21
- type InternalizeOutput,
22
- type WalletProtocol
21
+ type InternalizeOutput
23
22
  } from '@bsv/sdk'
24
23
  import type { AppChain } from '../../config'
25
24
  import { NETWORKS } from '../../networks'
26
25
  import { abbreviateKey, addressLabel, FROM_ADDRESS_LABEL_PREFIX, TO_ADDRESS_LABEL_PREFIX } from '../counterparty'
27
26
  import { addressNetwork, isValidBsvAddress } from './index'
28
27
 
29
- export const BRC29_PROTOCOL_ID: WalletProtocol = [2, '3241645161d8']
28
+ import { BRC29_PROTOCOL_ID } from '../../peerpay/brc29'
29
+ export { BRC29_PROTOCOL_ID } from '../../peerpay/brc29'
30
30
 
31
31
  /** Whether the address rail can carry a particular payment, and why not when it cannot. */
32
32
  export type AddressRailAvailability = { kind: 'available' } | { kind: 'unavailable'; reason: string }
@@ -181,7 +181,8 @@ export function wocRequestInit(woc: WocConfig): { headers: Record<string, string
181
181
  return woc.apiKey ? { headers: { 'woc-api-key': woc.apiKey } } : undefined
182
182
  }
183
183
 
184
- async function wocFetch(woc: WocConfig, url: string): Promise<Response> {
184
+ /** A WhatsOnChain GET that turns a 429 into WocRateLimited. Shared with pay/rails/sweep.ts. */
185
+ export async function wocFetch(woc: WocConfig, url: string): Promise<Response> {
185
186
  const init = wocRequestInit(woc)
186
187
  const response = init ? await fetch(url, init) : await fetch(url)
187
188
  if (response.status === 429) throw new WocRateLimited()
@@ -923,6 +923,7 @@ export async function retryDelivery(args: {
923
923
  entry: OutboxEntry
924
924
  }): Promise<void> {
925
925
  const { wallet, adminOriginator, client, storage, entry } = args
926
+ if (entry.status !== 'unsent') return
926
927
  await updateOutboxEntry(storage, entry.id, { lastAttemptAt: new Date().toISOString() })
927
928
  // XR-052: a concurrent UI abandon (cancelOutboxPayment) can remove this same
928
929
  // row between awaits — it shares no lock with the background drain beyond
@@ -931,7 +932,8 @@ export async function retryDelivery(args: {
931
932
  // (mirrors cancelOutboxPayment's own re-read for its 'undelivered' mode) and
932
933
  // stop cleanly if the row is gone, so an in-flight retry cannot still
933
934
  // deliver or broadcast a payment the user just cancelled.
934
- const stillPending = async (): Promise<boolean> => (await getOutboxEntries(storage)).some(e => e.id === entry.id)
935
+ const stillPending = async (): Promise<boolean> =>
936
+ (await getOutboxEntries(storage)).some(e => e.id === entry.id && e.status === 'unsent')
935
937
  try {
936
938
  if (entry.delivered !== true) {
937
939
  if (!(await stillPending())) return