@bsv/expo-wallet-toolbox 0.1.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/LICENSE.txt +28 -0
- package/README.md +512 -0
- package/assets/sounds/payment-receive.wav +0 -0
- package/assets/sounds/payment-send.wav +0 -0
- package/assets/sounds/vault-close.wav +0 -0
- package/assets/sounds/vault-open.wav +0 -0
- package/core/amountFormatHelpers.ts +330 -0
- package/core/backup/RemoteSyncReader.ts +94 -0
- package/core/backup/client.ts +111 -0
- package/core/backup/codec.ts +218 -0
- package/core/backup/constants.ts +88 -0
- package/core/backup/cursor.ts +138 -0
- package/core/backup/derive.ts +46 -0
- package/core/backup/deviceId.ts +33 -0
- package/core/backup/erase.ts +67 -0
- package/core/backup/preference.ts +33 -0
- package/core/backup/push.ts +295 -0
- package/core/backup/restore.ts +152 -0
- package/core/backup/restoreOnImport.ts +119 -0
- package/core/backup/status.ts +46 -0
- package/core/config.tsx +47 -0
- package/core/constants.ts +35 -0
- package/core/context/ExchangeRateContext.tsx +69 -0
- package/core/context/LocalStorageProvider.tsx +225 -0
- package/core/context/UserContext.tsx +129 -0
- package/core/context/VaultContext.tsx +79 -0
- package/core/context/WalletConnectionContext.tsx +454 -0
- package/core/context/WalletContext.tsx +2938 -0
- package/core/context/buildGeneration.ts +37 -0
- package/core/deviceTier.ts +89 -0
- package/core/diskSpace.ts +62 -0
- package/core/displayCurrencies.ts +56 -0
- package/core/headers/OfflineFirstChaintracks.ts +176 -0
- package/core/headers/checkpoints.ts +39 -0
- package/core/headers/fs.ts +119 -0
- package/core/headers/headerStore.ts +333 -0
- package/core/headers/prewarm.ts +36 -0
- package/core/headers/syncHeaders.ts +73 -0
- package/core/hooks/useConfirmationSound.ts +135 -0
- package/core/hooks/useHaptics.ts +51 -0
- package/core/hooks/usePermissionQueue.ts +69 -0
- package/core/i18n/translations.tsx +6692 -0
- package/core/index.ts +295 -0
- package/core/localpay/blePermissions.ts +32 -0
- package/core/localpay/build.ts +392 -0
- package/core/localpay/codec.ts +338 -0
- package/core/localpay/deviceCaps.ts +175 -0
- package/core/localpay/nearbyAdvisory.ts +32 -0
- package/core/localpay/nearbyPermissions.ts +34 -0
- package/core/localpay/pending.ts +385 -0
- package/core/localpay/pendingAborts.ts +67 -0
- package/core/localpay/qr.ts +16 -0
- package/core/localpay/session.ts +277 -0
- package/core/localpay/sessionPolicy.ts +5 -0
- package/core/localpay/transport/awdl.ts +11 -0
- package/core/localpay/transport/ble.ts +159 -0
- package/core/localpay/transport/nearby.ts +12 -0
- package/core/localpay/transport/race.ts +110 -0
- package/core/localpay/transport/select.ts +128 -0
- package/core/localpay/transport/socket.ts +244 -0
- package/core/localpay/types.ts +82 -0
- package/core/localpay/verify.ts +204 -0
- package/core/logging.config.ts +10 -0
- package/core/logging.ts +77 -0
- package/core/mnemonicWallet.ts +180 -0
- package/core/monitor/TaskBackupPush.ts +168 -0
- package/core/monitor/TaskCreditInbox.ts +116 -0
- package/core/monitor/TaskDrainOutbox.ts +122 -0
- package/core/monitor/TaskSendOffline.ts +123 -0
- package/core/monitor/unfailRetry.ts +116 -0
- package/core/net/chainMatch.ts +34 -0
- package/core/net/online.ts +34 -0
- package/core/offline/cancelParked.ts +56 -0
- package/core/offline/hold.ts +127 -0
- package/core/offline/order.ts +109 -0
- package/core/offline/payerHold.ts +144 -0
- package/core/offline/plan.ts +264 -0
- package/core/offline/queueGrace.ts +52 -0
- package/core/parsePeerPayURI.ts +119 -0
- package/core/pay/beefRepair.ts +106 -0
- package/core/pay/creditErrors.ts +46 -0
- package/core/pay/creditInbox.ts +202 -0
- package/core/pay/damagedInbox.ts +64 -0
- package/core/pay/proofNudge.ts +23 -0
- package/core/pay/provenTxFromBump.ts +31 -0
- package/core/pay/rails/address.ts +329 -0
- package/core/pay/rails/handle.ts +617 -0
- package/core/pay/rails/index.ts +197 -0
- package/core/pay/rails/nearby.ts +79 -0
- package/core/pay/receiveFocus.ts +13 -0
- package/core/pay/recordProof.ts +91 -0
- package/core/pay/refreshProofGuard.ts +34 -0
- package/core/pay/sweeper.ts +75 -0
- package/core/pay/tokenAmount.ts +18 -0
- package/core/pay/userError.ts +18 -0
- package/core/pay/watchlist.ts +126 -0
- package/core/peerpay/control.ts +122 -0
- package/core/peerpay/handleResendRequests.ts +475 -0
- package/core/peerpay/inboxAttempts.ts +33 -0
- package/core/peerpay/metadataDecryptor.ts +42 -0
- package/core/peerpay/offlineNacks.ts +96 -0
- package/core/peerpay/outbox.ts +209 -0
- package/core/peerpay/rebuildToken.ts +76 -0
- package/core/peerpay/resendBeef.ts +115 -0
- package/core/services/arcadeBroadcastProvider.ts +214 -0
- package/core/services/capWalletArgs.ts +99 -0
- package/core/services/exchangeRate.ts +63 -0
- package/core/services/secrets/envelope.ts +102 -0
- package/core/services/secrets/hkdf.ts +37 -0
- package/core/services/secrets/index.ts +63 -0
- package/core/services/secrets/kek.ts +274 -0
- package/core/services/secrets/migration.ts +188 -0
- package/core/services/secrets/policy.ts +120 -0
- package/core/services/secrets/storage.ts +54 -0
- package/core/services/secrets/store.ts +125 -0
- package/core/services/secrets/types.ts +85 -0
- package/core/services/usdFxRates.ts +101 -0
- package/core/services/vault/VaultKeyService.ts +312 -0
- package/core/services/vault/backupAttestation.ts +136 -0
- package/core/services/vault/ceremony.ts +972 -0
- package/core/services/vault/ceremonyHost.ts +46 -0
- package/core/services/vault/devMock.ts +22 -0
- package/core/services/vault/driver.ts +197 -0
- package/core/services/vault/guard.ts +90 -0
- package/core/services/vault/k1.ts +75 -0
- package/core/services/vault/mockYubiKey.ts +217 -0
- package/core/services/vault/random.ts +20 -0
- package/core/services/vault/sealing.ts +84 -0
- package/core/services/vault/session.ts +59 -0
- package/core/services/vault/transfers.ts +1151 -0
- package/core/services/vault/types.ts +109 -0
- package/core/services/vault/vaultDerivation.ts +152 -0
- package/core/services/vault/vaultPassphrase.ts +287 -0
- package/core/services/vault/vaultStore.ts +104 -0
- package/core/services/walletArgLimits.ts +234 -0
- package/core/services/walletServiceConfig.ts +170 -0
- package/core/storage/LocalStorageAdapter.ts +58 -0
- package/core/storage/README.md +391 -0
- package/core/storage/StorageExpoSQLite.ts +2008 -0
- package/core/storage/errors.ts +73 -0
- package/core/storage/index.ts +3 -0
- package/core/storage/methods/findSql.ts +286 -0
- package/core/storage/methods/historyNotes.ts +61 -0
- package/core/storage/methods/listActionsSql.ts +212 -0
- package/core/storage/methods/listOutputsSql.ts +211 -0
- package/core/storage/methods/offlineActions.ts +156 -0
- package/core/storage/methods/processOfflineActions.ts +503 -0
- package/core/storage/methods/reclaim.ts +135 -0
- package/core/storage/methods/reviewStatusSql.ts +167 -0
- package/core/storage/methods/unprovenWithoutReqSql.ts +26 -0
- package/core/storage/methods/walletBalanceSql.ts +55 -0
- package/core/storage/schema/createTables.ts +385 -0
- package/core/storage/skipQueuedAncestors.ts +29 -0
- package/core/storage/sqlUpdateValue.ts +12 -0
- package/core/stores/ConnectionStore.ts +71 -0
- package/core/theme/ThemeContext.tsx +182 -0
- package/core/theme/assertThemeContrast.ts +109 -0
- package/core/theme/motion.ts +50 -0
- package/core/theme/tokens.ts +232 -0
- package/core/theme/useThemeStyles.tsx +156 -0
- package/core/walletDbRegistry.ts +110 -0
- package/core/walletMonitor.ts +149 -0
- package/core/walletRepair/runWalletCheck.ts +195 -0
- package/core/walletRepair/shouldReleaseUtxo.ts +18 -0
- package/package.json +86 -0
- package/ui/backupShares.ts +367 -0
- package/ui/components/QRScanner.tsx +353 -0
- package/ui/components/pay/AddressReceive.tsx +507 -0
- package/ui/components/pay/AvailableBalance.tsx +61 -0
- package/ui/components/pay/HandleReceive.tsx +896 -0
- package/ui/components/pay/MessageBoxConfig.tsx +256 -0
- package/ui/components/pay/NearbyAdvisoryModal.tsx +111 -0
- package/ui/components/pay/NearbyFlow.tsx +2542 -0
- package/ui/components/pay/OfflineNotice.tsx +337 -0
- package/ui/components/pay/PayCellRow.tsx +101 -0
- package/ui/components/pay/PayForm.tsx +223 -0
- package/ui/components/pay/PaymentQrDisplay.tsx +105 -0
- package/ui/components/pay/PaymentSuccessOverlay.tsx +266 -0
- package/ui/components/pay/RecipientField.tsx +308 -0
- package/ui/components/pay/RequestHub.tsx +75 -0
- package/ui/components/pay/ResultBanner.tsx +69 -0
- package/ui/components/pay/UniversalSend.tsx +687 -0
- package/ui/components/pay/useRecipientInput.ts +270 -0
- package/ui/components/security/WalletLockNotice.tsx +138 -0
- package/ui/components/ui/AlertCard.tsx +223 -0
- package/ui/components/ui/AppLogo.tsx +166 -0
- package/ui/components/ui/BlurChrome.tsx +72 -0
- package/ui/components/ui/Celebration.tsx +84 -0
- package/ui/components/ui/ChoiceSheet.ts +69 -0
- package/ui/components/ui/CustomSafeArea.tsx +74 -0
- package/ui/components/ui/ErrorBoundary.tsx +154 -0
- package/ui/components/ui/GroupedList.tsx +125 -0
- package/ui/components/ui/IconButton.tsx +105 -0
- package/ui/components/ui/ListRow.tsx +197 -0
- package/ui/components/ui/PermissionSheet.tsx +920 -0
- package/ui/components/ui/PresenceRow.tsx +215 -0
- package/ui/components/ui/PressableScale.tsx +105 -0
- package/ui/components/ui/ScreenGradient.tsx +47 -0
- package/ui/components/ui/ScrollFade.tsx +76 -0
- package/ui/components/ui/Sheet.tsx +342 -0
- package/ui/components/ui/Toast.tsx +142 -0
- package/ui/components/ui/index.ts +8 -0
- package/ui/components/vault/EnrollWizard.tsx +627 -0
- package/ui/components/vault/PassphraseField.tsx +306 -0
- package/ui/components/vault/PhraseBackupSheet.tsx +227 -0
- package/ui/components/vault/VaultBackdrop.tsx +354 -0
- package/ui/components/vault/VaultCeremonySheet.tsx +327 -0
- package/ui/components/wallet/ActivityRow.tsx +408 -0
- package/ui/components/wallet/AmountDisplay.tsx +48 -0
- package/ui/components/wallet/AmountInput.tsx +256 -0
- package/ui/components/wallet/BackupReminderSheet.tsx +168 -0
- package/ui/components/wallet/Balance.tsx +144 -0
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +133 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +93 -0
- package/ui/exportDatabases.ts +122 -0
- package/ui/exportTransactions.ts +129 -0
- package/ui/hooks/useOfflineNoticeActions.ts +136 -0
- package/ui/hooks/useOnline.ts +70 -0
- package/ui/hooks/useSpendableBalance.ts +58 -0
- package/ui/hooks/useVaultBalance.ts +50 -0
- package/ui/importDatabases.ts +170 -0
- package/ui/index.ts +136 -0
- package/ui/isImageUrl.ts +10 -0
- package/ui/printRecoveryShares.ts +93 -0
- package/ui/resolveIdentity.ts +125 -0
- package/ui/screens/ConnectionsScreen.tsx +438 -0
- package/ui/screens/LogsScreen.tsx +432 -0
- package/ui/screens/PairScreen.tsx +288 -0
- package/ui/screens/PayScreen.tsx +479 -0
- package/ui/screens/SettingsScreen.tsx +180 -0
- package/ui/screens/TrustScreen.tsx +831 -0
- package/ui/screens/VaultRecoverScreen.tsx +226 -0
- package/ui/screens/VaultScreen.tsx +423 -0
- package/ui/screens/VaultTransferScreen.tsx +293 -0
- package/ui/screens/WalletCheckScreen.tsx +539 -0
- package/ui/screens/WalletConfigScreen.tsx +1095 -0
- package/ui/screens/WalletHomeScreen.tsx +1597 -0
- package/ui/screens/homeBadges.ts +18 -0
- package/ui/txStatus.ts +79 -0
- package/ui/validateTrust.ts +44 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get paid — the amount first, then how.
|
|
3
|
+
*
|
|
4
|
+
* The figure (or its absence: blank means the payer decides) is the one thing
|
|
5
|
+
* every receive method shares, so it is asked once, here, and carried into
|
|
6
|
+
* whichever code is shown next. The three rows are the methods; nothing on
|
|
7
|
+
* this screen is gated on the amount, because an open request is a real
|
|
8
|
+
* request.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react'
|
|
11
|
+
import { ScrollView, StyleSheet, View } from 'react-native'
|
|
12
|
+
import { useTranslation } from 'react-i18next'
|
|
13
|
+
|
|
14
|
+
import PayCellRow from './PayCellRow'
|
|
15
|
+
import { PayAmountField, PayField } from './PayForm'
|
|
16
|
+
import { spacing } from '@bsv/expo-wallet-toolbox'
|
|
17
|
+
|
|
18
|
+
export type RequestMethod = 'get-nearby' | 'get-handle' | 'get-address'
|
|
19
|
+
|
|
20
|
+
export interface RequestHubProps {
|
|
21
|
+
/** Raw satoshi string from the amount field. '' is an open request. */
|
|
22
|
+
requestSats: string
|
|
23
|
+
onChangeRequestSats: (v: string) => void
|
|
24
|
+
onPick: (method: RequestMethod) => void
|
|
25
|
+
online: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Satoshis from the hub's raw field, or undefined for an open request. */
|
|
29
|
+
export function requestSatsFrom(text: string): number | undefined {
|
|
30
|
+
const n = Math.round(Number(text))
|
|
31
|
+
return Number.isFinite(n) && n > 0 ? n : undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default function RequestHub({ requestSats, onChangeRequestSats, onPick, online }: RequestHubProps) {
|
|
35
|
+
const { t } = useTranslation()
|
|
36
|
+
return (
|
|
37
|
+
<ScrollView contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled">
|
|
38
|
+
{/* No max button and no balance line: this asks the PAYER for money, so
|
|
39
|
+
the requester's own balance is meaningless here. */}
|
|
40
|
+
<PayAmountField value={requestSats} onChangeText={onChangeRequestSats} showMax={false} showBalance={false} />
|
|
41
|
+
|
|
42
|
+
<PayField labelKey="pay_method">
|
|
43
|
+
<View style={styles.rows}>
|
|
44
|
+
<PayCellRow
|
|
45
|
+
title={t('pay_method_nearby')}
|
|
46
|
+
subtitle={t('pay_cell_nearby_get_sub')}
|
|
47
|
+
icon="qr-code-outline"
|
|
48
|
+
onPress={() => onPick('get-nearby')}
|
|
49
|
+
/>
|
|
50
|
+
{/* Remote and address both need the network: a message-box round-trip
|
|
51
|
+
and an overlay lookup respectively. Nearby is the offline rail. */}
|
|
52
|
+
<PayCellRow
|
|
53
|
+
title={t('pay_method_remote_link')}
|
|
54
|
+
subtitle={online ? t('pay_cell_handle_get_sub') : t('pay_offline_needs_internet')}
|
|
55
|
+
icon="share-outline"
|
|
56
|
+
disabled={!online}
|
|
57
|
+
onPress={() => onPick('get-handle')}
|
|
58
|
+
/>
|
|
59
|
+
<PayCellRow
|
|
60
|
+
title={t('pay_method_address')}
|
|
61
|
+
subtitle={online ? t('pay_cell_address_get_sub') : t('pay_offline_needs_internet')}
|
|
62
|
+
icon="wallet-outline"
|
|
63
|
+
disabled={!online}
|
|
64
|
+
onPress={() => onPick('get-address')}
|
|
65
|
+
/>
|
|
66
|
+
</View>
|
|
67
|
+
</PayField>
|
|
68
|
+
</ScrollView>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
content: { paddingHorizontal: spacing.lg, paddingTop: spacing.lg },
|
|
74
|
+
rows: { gap: spacing.md }
|
|
75
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inline success / error banner both handle cells use.
|
|
3
|
+
*
|
|
4
|
+
* Copied verbatim out of app/payments.tsx so the two cells report results the
|
|
5
|
+
* same way the old screen did.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react'
|
|
8
|
+
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
|
9
|
+
import { spacing, typography, radii } from '@bsv/expo-wallet-toolbox'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
|
|
13
|
+
* etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
|
|
14
|
+
* that Jest cannot parse when eagerly pulled in via the `ui` package barrel.
|
|
15
|
+
* Ionicons is loaded lazily, only when actually rendering, same pattern as
|
|
16
|
+
* this package's other native-module-boundary fixes (expo-router, expo-blur).
|
|
17
|
+
*/
|
|
18
|
+
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
19
|
+
let ioniconsComponent: IoniconsComponent | undefined
|
|
20
|
+
function loadIonicons(): IoniconsComponent {
|
|
21
|
+
if (!ioniconsComponent) {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
23
|
+
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
24
|
+
}
|
|
25
|
+
return ioniconsComponent
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ResultBannerProps {
|
|
29
|
+
readonly result: { type: 'success' | 'error'; message: string }
|
|
30
|
+
readonly onDismiss: () => void
|
|
31
|
+
readonly colors: ReturnType<typeof import('@bsv/expo-wallet-toolbox').useTheme>['colors']
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default function ResultBanner({ result, onDismiss, colors }: ResultBannerProps) {
|
|
35
|
+
const Ionicons = loadIonicons()
|
|
36
|
+
const isSuccess = result.type === 'success'
|
|
37
|
+
const color = isSuccess ? colors.success : colors.error
|
|
38
|
+
return (
|
|
39
|
+
<View style={[styles.resultBanner, { backgroundColor: color + '15', borderColor: color }]}>
|
|
40
|
+
<Ionicons name={isSuccess ? 'checkmark-circle' : 'alert-circle'} size={20} color={color} />
|
|
41
|
+
<Text style={[styles.resultText, { color }]}>{result.message}</Text>
|
|
42
|
+
<TouchableOpacity onPress={onDismiss} style={styles.resultDismiss}>
|
|
43
|
+
<Ionicons name="close" size={18} color={color} />
|
|
44
|
+
</TouchableOpacity>
|
|
45
|
+
</View>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const styles = StyleSheet.create({
|
|
50
|
+
resultBanner: {
|
|
51
|
+
flexDirection: 'row',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
gap: spacing.sm,
|
|
54
|
+
paddingHorizontal: spacing.md,
|
|
55
|
+
paddingVertical: spacing.md,
|
|
56
|
+
borderRadius: radii.md,
|
|
57
|
+
borderWidth: 1,
|
|
58
|
+
marginTop: spacing.lg,
|
|
59
|
+
marginBottom: spacing.lg
|
|
60
|
+
},
|
|
61
|
+
resultText: {
|
|
62
|
+
...typography.subhead,
|
|
63
|
+
fontWeight: '500',
|
|
64
|
+
flex: 1
|
|
65
|
+
},
|
|
66
|
+
resultDismiss: {
|
|
67
|
+
padding: spacing.xs
|
|
68
|
+
}
|
|
69
|
+
})
|