@bsv/expo-wallet-toolbox 0.20.0 → 0.22.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 +147 -0
- package/README.md +78 -13
- package/core/contacts/contactActivity.ts +48 -28
- package/core/contacts/contactsStore.ts +2 -2
- package/core/context/WalletContext.tsx +166 -219
- package/core/demo/demoAssets.ts +8 -10
- package/core/demo/demoLedger.ts +32 -38
- package/core/demo/demoMandalaRuntime.ts +67 -49
- package/core/demo/index.ts +1 -1
- package/core/directpay/DirectPayManager.ts +148 -29
- package/core/directpay/DirectPayProvider.tsx +11 -2
- package/core/directpay/payFlow.ts +10 -1
- package/core/directpay/settings.ts +56 -9
- package/core/directpay/types.ts +11 -2
- package/core/directpay/webrtpay.ts +4 -0
- package/core/i18n/translations.tsx +185 -84
- package/core/index.ts +55 -37
- package/core/localpay/build.ts +110 -569
- package/core/localpay/codec.ts +190 -93
- package/core/localpay/pending.ts +217 -202
- package/core/localpay/session.ts +99 -25
- package/core/localpay/types.ts +6 -5
- package/core/localpay/verify.ts +118 -173
- package/core/mandala/abortGuard.ts +97 -120
- package/core/mandala/accessPolicy.ts +133 -0
- package/core/mandala/assets.ts +370 -0
- package/core/mandala/colorGuard.ts +178 -0
- package/core/mandala/colorModule.ts +82 -0
- package/core/mandala/createRuntime.ts +483 -2392
- package/core/mandala/handle.ts +694 -0
- package/core/mandala/kvStore.ts +105 -0
- package/core/mandala/nearby.ts +185 -0
- package/core/mandala/receipt.ts +121 -0
- package/core/mandala/runtime.ts +166 -312
- package/core/mandala/settle.ts +540 -0
- package/core/mandala/transferJournal.ts +395 -0
- package/core/mandala/types.ts +61 -311
- package/core/networks.ts +5 -5
- package/core/offline/cancelParked.ts +80 -63
- package/core/offline/payerHold.ts +52 -118
- package/core/parsePeerPayURI.ts +25 -12
- package/core/pay/rails/direct.ts +6 -2
- package/core/pay/rails/handle.ts +15 -14
- package/core/pay/rails/index.ts +5 -3
- package/core/pay/rails/nearby.ts +25 -87
- package/core/profiles/assertProfileEmpty.ts +19 -10
- package/core/services/vault/guard.ts +5 -4
- package/core/storage/StorageExpoSQLite.ts +93 -229
- package/core/storage/methods/processOfflineActions.ts +86 -136
- package/core/storage/schema/createTables.ts +9 -184
- package/package.json +6 -5
- package/ui/components/pay/AssetPicker.tsx +2 -2
- package/ui/components/pay/HandleReceive.tsx +10 -4
- package/ui/components/pay/NearbyFlow.tsx +324 -239
- package/ui/components/pay/RequestHub.tsx +10 -0
- package/ui/components/pay/UniversalSend.tsx +31 -28
- package/ui/components/pay/useRecipientInput.ts +2 -2
- package/ui/components/ui/PermissionSheet.tsx +94 -160
- package/ui/components/ui/colorPrompt.ts +236 -0
- package/ui/components/wallet/AmountInput.tsx +9 -6
- package/ui/components/wallet/AssetAmount.tsx +6 -6
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +26 -7
- package/ui/components/wallet/Balance.tsx +3 -1
- package/ui/components/wallet/ContactActivityList.tsx +10 -13
- package/ui/components/wallet/tokenEviction.ts +9 -9
- package/ui/hooks/useMandala.ts +6 -6
- package/ui/hooks/useSpendableBalance.ts +3 -1
- package/ui/importDatabases.ts +1 -1
- package/ui/screens/PayScreen.tsx +14 -20
- package/ui/screens/SettingsScreen.tsx +3 -1
- package/ui/screens/WalletCheckScreen.tsx +7 -2
- package/ui/screens/WalletHomeScreen.tsx +40 -14
- package/ui/screens/tokenRowTitle.ts +28 -15
- package/ui/tokenFormat.ts +133 -69
- package/ui/tokenStatus.ts +5 -8
- package/core/localpay/settlementAck.ts +0 -155
- package/core/mandala/basketMigration.ts +0 -166
- package/core/mandala/bundle.ts +0 -244
- package/core/mandala/drain.ts +0 -754
- package/core/mandala/inboxPrehold.ts +0 -193
- package/core/mandala/permissionModule.ts +0 -931
- package/core/mandala/resendTransfer.ts +0 -178
- package/core/mandala/settlementStore.ts +0 -434
- package/core/mandala/token.ts +0 -45
- package/core/offline/tokenFrames.ts +0 -197
|
@@ -87,6 +87,10 @@ export async function payIdentity(o: {
|
|
|
87
87
|
case 'unknown':
|
|
88
88
|
if (o.messageBox) return { kind: 'ask_fallback', reason: 'link_failed' }
|
|
89
89
|
return failed('no', 'direct_pay_failed_link', { name: o.name })
|
|
90
|
+
case 'too_large':
|
|
91
|
+
// Released before anything was spent: the message box carries any size.
|
|
92
|
+
if (o.messageBox) return { kind: 'ask_fallback', reason: 'too_large' }
|
|
93
|
+
return stopped(error, o.name)
|
|
90
94
|
case 'unavailable':
|
|
91
95
|
return failed('no', 'direct_pay_failed_network')
|
|
92
96
|
case 'wrong_network':
|
|
@@ -111,7 +115,12 @@ export async function payIdentity(o: {
|
|
|
111
115
|
/** The fallback prompt for `reason`, naming the recipient. */
|
|
112
116
|
export function fallbackPrompt(reason: FallbackReason, name: string): Required<DirectPayMessage> {
|
|
113
117
|
return {
|
|
114
|
-
key:
|
|
118
|
+
key:
|
|
119
|
+
reason === 'offline'
|
|
120
|
+
? 'direct_pay_fallback_offline'
|
|
121
|
+
: reason === 'too_large'
|
|
122
|
+
? 'direct_pay_fallback_too_large'
|
|
123
|
+
: 'direct_pay_fallback_link_failed',
|
|
115
124
|
params: { name }
|
|
116
125
|
}
|
|
117
126
|
}
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* not the wallet's key/value table, which is per wallet and cleared with it).
|
|
7
7
|
*
|
|
8
8
|
* Receiving is on by default, and wallets find each other through the public WebRTPay relay by
|
|
9
|
-
* default, with the message box as the other choice.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* default, with the message box as the other choice. A stored value that is missing or no
|
|
10
|
+
* longer valid falls back to the default field by field; a stored STUN list that is exactly
|
|
11
|
+
* the previous default ({@link PREVIOUS_DEFAULT_STUN_URLS}) is read as the current default.
|
|
12
|
+
* Receiving answers live payments only while the Receive screen is showing (see
|
|
13
|
+
* DirectPayManager.openReceiveScreen).
|
|
12
14
|
*
|
|
13
15
|
* Addresses are checked with regexes, not `URL`: `URL.hostname` is unreliable on Hermes. A relay
|
|
14
16
|
* must be `wss://` (desktop also allows `ws://` for localhost; a phone has no local relay, so
|
|
@@ -33,11 +35,54 @@ export const DEFAULT_DIRECT_PAY_SETTINGS: Readonly<Omit<DirectPaySettings, 'stun
|
|
|
33
35
|
receiveEnabled: true,
|
|
34
36
|
signaling: 'relay',
|
|
35
37
|
relayUrl: DEFAULT_RELAY_URL,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
// BSVA's own STUN server only (2026-10-21): every STUN server learns this device's address
|
|
39
|
+
// and when it connects.
|
|
40
|
+
stunUrls: Object.freeze(['stun:stun-us-1.bsvb.tech:3478'])
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The STUN list that was the default until 2026-10-21. A stored list that is exactly this
|
|
45
|
+
* (saved before, never edited) is read as the current default; any other list is the user's.
|
|
46
|
+
*/
|
|
47
|
+
export const PREVIOUS_DEFAULT_STUN_URLS: readonly string[] = Object.freeze([
|
|
48
|
+
'stun:stun-us-1.bsvb.tech:3478',
|
|
49
|
+
'stun:stun.l.google.com:19302',
|
|
50
|
+
'stun:stun.cloudflare.com:3478'
|
|
51
|
+
])
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Largest transaction (Atomic BEEF) sent or taken live: 1 MB (2026-10-21). A larger payment
|
|
55
|
+
* is refused before anything is spent and the message box is offered; a payee refuses larger
|
|
56
|
+
* live messages and closes the session.
|
|
57
|
+
*/
|
|
58
|
+
export const MAX_LIVE_TRANSACTION_BYTES = 1_000_000
|
|
59
|
+
/**
|
|
60
|
+
* The largest message an authenticated live session may send this wallet: a `payment` with a
|
|
61
|
+
* {@link MAX_LIVE_TRANSACTION_BYTES} transaction in base64 (a third larger), plus 4096 bytes for
|
|
62
|
+
* the rest of the message, as @bsv/webrtpay counts it (MAX_DIRECT_TRANSACTION_BYTES).
|
|
63
|
+
*/
|
|
64
|
+
export const MAX_LIVE_MESSAGE_BYTES = 4 * Math.ceil(MAX_LIVE_TRANSACTION_BYTES / 3) + 4096
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* `servers` (the relay's TURN answer) without its STUN entries: the relay passes on the TURN
|
|
68
|
+
* provider's STUN urls (Cloudflare's), and only the settings' STUN list is asked.
|
|
69
|
+
*/
|
|
70
|
+
export function onlyOwnStun<T extends { urls: string | string[] }>(servers: T[]): T[] {
|
|
71
|
+
const out: T[] = []
|
|
72
|
+
for (const server of servers) {
|
|
73
|
+
const urls = (typeof server.urls === 'string' ? [server.urls] : [...server.urls]).filter(u => !/^stuns?:/i.test(u))
|
|
74
|
+
if (urls.length > 0) out.push({ ...server, urls })
|
|
75
|
+
}
|
|
76
|
+
return out
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** True for a stored STUN list that is exactly {@link PREVIOUS_DEFAULT_STUN_URLS}. */
|
|
80
|
+
function previousDefaultStun(value: unknown): boolean {
|
|
81
|
+
return (
|
|
82
|
+
Array.isArray(value) &&
|
|
83
|
+
value.length === PREVIOUS_DEFAULT_STUN_URLS.length &&
|
|
84
|
+
value.every((u, i) => u === PREVIOUS_DEFAULT_STUN_URLS[i])
|
|
85
|
+
)
|
|
41
86
|
}
|
|
42
87
|
|
|
43
88
|
// A host is a name or IPv4 address that starts and ends with a letter or digit, or a bracketed
|
|
@@ -208,7 +253,9 @@ export async function loadDirectPaySettings(
|
|
|
208
253
|
receiveEnabled: field(checkReceiveEnabled, stored.receiveEnabled, defaults.receiveEnabled),
|
|
209
254
|
signaling: field(checkSignaling, stored.signaling, defaults.signaling),
|
|
210
255
|
relayUrl: field(checkRelayUrl, stored.relayUrl, defaults.relayUrl),
|
|
211
|
-
stunUrls: field(checkStunUrls, stored.stunUrls
|
|
256
|
+
stunUrls: field(checkStunUrls, previousDefaultStun(stored.stunUrls) ? [...defaults.stunUrls] : stored.stunUrls, [
|
|
257
|
+
...defaults.stunUrls
|
|
258
|
+
])
|
|
212
259
|
},
|
|
213
260
|
field(checkTurn, stored.turn, undefined)
|
|
214
261
|
)
|
package/core/directpay/types.ts
CHANGED
|
@@ -52,7 +52,16 @@ export interface DirectPaySettings {
|
|
|
52
52
|
* - `aborted`: the dial was cancelled.
|
|
53
53
|
* - `unknown`: anything else (a refusal with some other reason, a closed link, a bad handshake).
|
|
54
54
|
*/
|
|
55
|
-
export type DialFailure =
|
|
55
|
+
export type DialFailure =
|
|
56
|
+
| 'offline'
|
|
57
|
+
| 'rejected'
|
|
58
|
+
| 'unavailable'
|
|
59
|
+
| 'timeout'
|
|
60
|
+
| 'wrong_network'
|
|
61
|
+
| 'aborted'
|
|
62
|
+
| 'unknown'
|
|
63
|
+
/** Not a dial failure: the recipient was reached, but the payment is over the 1 MB live limit (released). */
|
|
64
|
+
| 'too_large'
|
|
56
65
|
|
|
57
66
|
/** Some wording for the user, as an i18n key and its parameters (core modules never return English). */
|
|
58
67
|
export interface DirectPayMessage {
|
|
@@ -61,7 +70,7 @@ export interface DirectPayMessage {
|
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
/** Why a live attempt is offering the message box: the recipient is not there, or the link failed. */
|
|
64
|
-
export type FallbackReason = 'offline' | 'link_failed'
|
|
73
|
+
export type FallbackReason = 'offline' | 'link_failed' | 'too_large'
|
|
65
74
|
|
|
66
75
|
/** Paying stopped, and nothing more is offered. */
|
|
67
76
|
export interface PayFailure extends DirectPayMessage {
|
|
@@ -147,6 +147,10 @@ export interface DirectPayClientOptions {
|
|
|
147
147
|
onIceServersProviderError?: (e: unknown) => void
|
|
148
148
|
chain?: string
|
|
149
149
|
timeouts?: { connectMs?: number; ackMs?: number; presenceMs?: number; dialMs?: number }
|
|
150
|
+
/** Largest message a peer may send once authenticated, while this client dials. */
|
|
151
|
+
maxMessageBytes?: number
|
|
152
|
+
/** What a payee allows from peers that dial it (the package's `InboundLimits`, in part). */
|
|
153
|
+
limits?: { maxMessageBytes?: number }
|
|
150
154
|
}
|
|
151
155
|
|
|
152
156
|
export interface RelaySignalerOptions {
|