@bsv/expo-wallet-toolbox 0.17.0 → 0.18.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 +41 -0
- package/core/context/WalletContext.tsx +5 -1
- package/core/directpay/DirectPayManager.ts +844 -0
- package/core/directpay/DirectPayProvider.tsx +321 -0
- package/core/directpay/deviceStore.ts +19 -0
- package/core/directpay/index.ts +6 -1
- package/core/directpay/reactNativeRtc.ts +81 -0
- package/core/directpay/receive.ts +544 -0
- package/core/directpay/settings.ts +33 -8
- package/core/directpay/types.ts +3 -2
- package/core/directpay/webrtpay.ts +208 -0
- package/core/i18n/translations.tsx +34 -12
- package/core/index.ts +8 -2
- package/core/pay/creditInbox.ts +5 -12
- package/core/pay/rails/direct.ts +287 -0
- package/core/pay/rails/handle.ts +155 -62
- package/core/peerpay/outbox.ts +11 -2
- package/package.json +5 -1
- package/ui/components/pay/HandleReceive.tsx +19 -6
- package/ui/screens/WalletCheckScreen.tsx +8 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@bsv/webrtpay` as the toolbox uses it. It is an optional peer dependency: a host that offers
|
|
3
|
+
* direct payments installs it (with react-native-webrtc), and every other host has none.
|
|
4
|
+
*
|
|
5
|
+
* So nothing in the toolbox imports it, not even for types. The package ships as TypeScript
|
|
6
|
+
* source, and a type import of a module a host does not have fails that host's type check. The
|
|
7
|
+
* shapes below are the slices the toolbox calls, written out by hand;
|
|
8
|
+
* `__tests__/directpay/webrtpayShape.test.ts` checks at type level that the real package fits
|
|
9
|
+
* them, so a release that changes one fails there rather than on a phone.
|
|
10
|
+
*
|
|
11
|
+
* The package is required lazily, inside a `try`, the way `services/vault/driver.ts` requires
|
|
12
|
+
* react-native-yubikey: Metro skips a missing module there because Expo's Metro config turns on
|
|
13
|
+
* `allowOptionalDependencies`, and requiring it only on first use keeps the barrel import free
|
|
14
|
+
* of it. `loadWebRTPay()` is null when it is not installed (or will not load).
|
|
15
|
+
*/
|
|
16
|
+
import type { WalletInterface } from '@bsv/sdk'
|
|
17
|
+
import type { IceServer } from './settings'
|
|
18
|
+
|
|
19
|
+
/** The slice of a BRC-100 wallet `@bsv/webrtpay` uses (its `WalletLike`). */
|
|
20
|
+
export type WebRTPayWallet = Pick<
|
|
21
|
+
WalletInterface,
|
|
22
|
+
| 'getPublicKey'
|
|
23
|
+
| 'createSignature'
|
|
24
|
+
| 'verifySignature'
|
|
25
|
+
| 'encrypt'
|
|
26
|
+
| 'decrypt'
|
|
27
|
+
| 'createHmac'
|
|
28
|
+
| 'verifyHmac'
|
|
29
|
+
| 'internalizeAction'
|
|
30
|
+
>
|
|
31
|
+
|
|
32
|
+
/** `WebRTPayError`: `code` says what failed; `reason` is a refusal's reason (`busy`, …). */
|
|
33
|
+
export interface WebRTPayErrorLike extends Error {
|
|
34
|
+
readonly code: string
|
|
35
|
+
readonly reason?: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A payment token as it goes over the link (PeerPay's `PaymentToken`). */
|
|
39
|
+
export interface DirectPaymentToken {
|
|
40
|
+
customInstructions: { derivationPrefix: string; derivationSuffix: string }
|
|
41
|
+
transaction: number[]
|
|
42
|
+
amount: number
|
|
43
|
+
outputIndex?: number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A payment from an authenticated peer: `sender` is the peer's proven identity key. */
|
|
47
|
+
export interface IncomingDirectPayment {
|
|
48
|
+
messageId: string
|
|
49
|
+
sender: string
|
|
50
|
+
token: DirectPaymentToken
|
|
51
|
+
outputIndex?: number
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** What this wallet answers a payment with: in the wallet, kept for a retry, or refused. */
|
|
55
|
+
export type DirectPaymentDecision = 'accepted' | 'received' | { status: 'rejected'; reason: string }
|
|
56
|
+
|
|
57
|
+
/** The payee's answer to a payment. */
|
|
58
|
+
export interface DirectPaymentAck {
|
|
59
|
+
status: 'accepted' | 'received' | 'rejected'
|
|
60
|
+
txid?: string
|
|
61
|
+
reason?: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** An authenticated link to one peer. */
|
|
65
|
+
export interface DirectPeer {
|
|
66
|
+
readonly peerIdentityKey: string
|
|
67
|
+
readonly isOpen: boolean
|
|
68
|
+
close(): void
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface DirectReceiveHandlers {
|
|
72
|
+
onPayment(p: IncomingDirectPayment, ctx: { note?: string; txid: string }): Promise<DirectPaymentDecision>
|
|
73
|
+
onError?(e: unknown): void
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** `DirectPayClient`: dials, sends, and receives while listening. */
|
|
77
|
+
export interface DirectPayClientLike {
|
|
78
|
+
startReceiving(h: DirectReceiveHandlers): Promise<void>
|
|
79
|
+
stopReceiving(): Promise<void>
|
|
80
|
+
connect(recipient: string, o?: { signal?: AbortSignal }): Promise<DirectPeer>
|
|
81
|
+
sendPayment(peer: DirectPeer, token: DirectPaymentToken, o?: { note?: string }): Promise<DirectPaymentAck>
|
|
82
|
+
close(): Promise<void>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** An encrypted signal as a carrier moves it; the toolbox never opens one. */
|
|
86
|
+
export interface SignalEnvelopeLike {
|
|
87
|
+
v: 1
|
|
88
|
+
sid: string
|
|
89
|
+
ciphertext: string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A carrier for signals: the message box or a relay. */
|
|
93
|
+
export interface SignalerLike {
|
|
94
|
+
send(to: string, e: SignalEnvelopeLike): Promise<void>
|
|
95
|
+
listen(fn: (from: string, e: SignalEnvelopeLike) => void): Promise<() => Promise<void>>
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** `connecting` while it opens, `online` once the relay accepted this wallet, else `offline`. */
|
|
99
|
+
export type RelayState = 'connecting' | 'online' | 'offline'
|
|
100
|
+
|
|
101
|
+
export interface RelaySignalerLike extends SignalerLike {
|
|
102
|
+
close(): Promise<void>
|
|
103
|
+
/** The relay's short-lived TURN servers, for `iceServersProvider`. */
|
|
104
|
+
turnProvider(): () => Promise<IceServer[]>
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The message box client as the signaler uses it. message-box-client's `PeerPayClient` is one
|
|
109
|
+
* (pinned at type level in `__tests__/directpay/webrtpayShape.test.ts`); its live websocket
|
|
110
|
+
* calls make the signaler fast enough for the dial's presence window.
|
|
111
|
+
*/
|
|
112
|
+
export interface MessageBoxLike {
|
|
113
|
+
sendMessage(a: { recipient: string; messageBox: string; body: string }, overrideHost?: string): Promise<unknown>
|
|
114
|
+
listMessages(a: {
|
|
115
|
+
messageBox: string
|
|
116
|
+
host?: string
|
|
117
|
+
limit?: number
|
|
118
|
+
pageSize?: number
|
|
119
|
+
maxPages?: number
|
|
120
|
+
acceptPayments?: boolean
|
|
121
|
+
}): Promise<{ messageId: string; sender: string; body: string | Record<string, unknown> }[]>
|
|
122
|
+
acknowledgeMessage(a: { messageIds: string[]; host?: string }): Promise<unknown>
|
|
123
|
+
resolveHostForRecipient?(identityKey: string): Promise<string>
|
|
124
|
+
sendLiveMessage?(a: { recipient: string; messageBox: string; body: string }, overrideHost?: string): Promise<unknown>
|
|
125
|
+
listenForLiveMessages?(a: {
|
|
126
|
+
messageBox: string
|
|
127
|
+
overrideHost?: string
|
|
128
|
+
onMessage: (m: { messageId: string; sender: string; body: string | Record<string, unknown> }) => void
|
|
129
|
+
}): Promise<void>
|
|
130
|
+
joinRoom?(messageBox: string, overrideHost?: string): Promise<void>
|
|
131
|
+
leaveRoom?(messageBox: string): Promise<void>
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface DirectPayClientOptions {
|
|
135
|
+
wallet: WebRTPayWallet
|
|
136
|
+
originator?: string
|
|
137
|
+
signaler?: SignalerLike
|
|
138
|
+
rtc?: {
|
|
139
|
+
iceServers?: IceServer[]
|
|
140
|
+
/**
|
|
141
|
+
* The host's constructor (react-native-webrtc's on a phone). `any` because the package
|
|
142
|
+
* wants the DOM's `typeof RTCPeerConnection`, and the toolbox has no WebRTC types.
|
|
143
|
+
*/
|
|
144
|
+
RTCPeerConnection?: any
|
|
145
|
+
}
|
|
146
|
+
iceServersProvider?: () => Promise<IceServer[]>
|
|
147
|
+
onIceServersProviderError?: (e: unknown) => void
|
|
148
|
+
chain?: string
|
|
149
|
+
timeouts?: { connectMs?: number; ackMs?: number; presenceMs?: number; dialMs?: number }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface RelaySignalerOptions {
|
|
153
|
+
url: string
|
|
154
|
+
wallet: Pick<WebRTPayWallet, 'getPublicKey' | 'createSignature'>
|
|
155
|
+
originator?: string
|
|
156
|
+
onStateChange?: (state: RelayState, error?: WebRTPayErrorLike) => void
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** A seen store: which payments were already taken (`paymentKey`). */
|
|
160
|
+
export interface DirectPaySeenStore {
|
|
161
|
+
has(key: string): boolean | Promise<boolean>
|
|
162
|
+
add(key: string): void | Promise<void>
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The module, as far as the toolbox calls it. */
|
|
166
|
+
export interface WebRTPayModule {
|
|
167
|
+
DirectPayClient: new (o: DirectPayClientOptions) => DirectPayClientLike
|
|
168
|
+
MessageBoxSignaler: new (client: MessageBoxLike, o?: { messageBox?: string; host?: string }) => SignalerLike
|
|
169
|
+
RelaySignaler: new (o: RelaySignalerOptions) => RelaySignalerLike
|
|
170
|
+
WebRTPayError: new (
|
|
171
|
+
code: 'rejected' | 'invalid_payment',
|
|
172
|
+
message?: string,
|
|
173
|
+
o?: { cause?: unknown; reason?: string }
|
|
174
|
+
) => WebRTPayErrorLike
|
|
175
|
+
acceptDirectPayment(
|
|
176
|
+
wallet: WebRTPayWallet,
|
|
177
|
+
p: IncomingDirectPayment,
|
|
178
|
+
o?: { originator?: string; seen?: DirectPaySeenStore; labels?: string[]; description?: string }
|
|
179
|
+
): Promise<{ txid: string; status: 'accepted' | 'duplicate' }>
|
|
180
|
+
validatePaymentToken(token: DirectPaymentToken, note?: string): void
|
|
181
|
+
readonly MAX_DIRECT_TRANSACTION_BYTES: number
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let loaded: WebRTPayModule | null | undefined
|
|
185
|
+
|
|
186
|
+
/** `@bsv/webrtpay`, or null when this host does not have it. Required once, on first use. */
|
|
187
|
+
export function loadWebRTPay(): WebRTPayModule | null {
|
|
188
|
+
if (loaded !== undefined) return loaded
|
|
189
|
+
try {
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
191
|
+
loaded = require('@bsv/webrtpay') as WebRTPayModule
|
|
192
|
+
} catch (e) {
|
|
193
|
+
console.warn('[directpay] @bsv/webrtpay is not available:', e instanceof Error ? e.message : String(e))
|
|
194
|
+
loaded = null
|
|
195
|
+
}
|
|
196
|
+
return loaded
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Replaces what {@link loadWebRTPay} returns; `undefined` loads the package again. Tests only. */
|
|
200
|
+
export function setWebRTPayForTests(m: WebRTPayModule | null | undefined): void {
|
|
201
|
+
loaded = m
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Whether `e` is a `WebRTPayError` of `mod`, or one that lost its prototype on the way (duck-typed). */
|
|
205
|
+
export function isWebRTPayError(mod: Pick<WebRTPayModule, 'WebRTPayError'>, e: unknown): e is WebRTPayErrorLike {
|
|
206
|
+
if (e instanceof mod.WebRTPayError) return true
|
|
207
|
+
return typeof e === 'object' && e !== null && (e as { name?: unknown }).name === 'WebRTPayError'
|
|
208
|
+
}
|
|
@@ -1237,7 +1237,9 @@ const resources = {
|
|
|
1237
1237
|
direct_pay_failed_maybe_sent:
|
|
1238
1238
|
'Your payment to {{name}} may already have been sent. Check Activity before paying again.',
|
|
1239
1239
|
direct_pay_failed_not_sent: 'The payment could not be sent. Nothing was spent.',
|
|
1240
|
-
direct_pay_failed_no_message_box: 'Connect your message box in Settings to pay a wallet identity.'
|
|
1240
|
+
direct_pay_failed_no_message_box: 'Connect your message box in Settings to pay a wallet identity.',
|
|
1241
|
+
direct_pay_kept_needs_attention:
|
|
1242
|
+
'A direct payment of {{amount}} sats from {{name}} needs attention: your wallet could not add it. It stays on this device.'
|
|
1241
1243
|
}
|
|
1242
1244
|
},
|
|
1243
1245
|
zh: {
|
|
@@ -2279,7 +2281,8 @@ const resources = {
|
|
|
2279
2281
|
direct_pay_failed_cancelled: '已取消。未花费任何款项。',
|
|
2280
2282
|
direct_pay_failed_maybe_sent: '你向 {{name}} 的付款可能已经发出。再次付款前,请先查看“活动”。',
|
|
2281
2283
|
direct_pay_failed_not_sent: '无法发送付款。未花费任何款项。',
|
|
2282
|
-
direct_pay_failed_no_message_box: '请在设置中连接消息箱,以便向钱包身份付款。'
|
|
2284
|
+
direct_pay_failed_no_message_box: '请在设置中连接消息箱,以便向钱包身份付款。',
|
|
2285
|
+
direct_pay_kept_needs_attention: '来自 {{name}} 的 {{amount}} sats 直接付款需要处理:你的钱包无法添加它。它仍保存在此设备上。'
|
|
2283
2286
|
}
|
|
2284
2287
|
},
|
|
2285
2288
|
hi: {
|
|
@@ -3400,7 +3403,9 @@ const resources = {
|
|
|
3400
3403
|
'{{name}} को आपका भुगतान शायद पहले ही भेजा जा चुका है। दोबारा भुगतान करने से पहले गतिविधि देखें।',
|
|
3401
3404
|
direct_pay_failed_not_sent: 'भुगतान भेजा नहीं जा सका। कुछ भी खर्च नहीं हुआ।',
|
|
3402
3405
|
direct_pay_failed_no_message_box:
|
|
3403
|
-
'किसी वॉलेट आइडेंटिटी को भुगतान करने के लिए सेटिंग्स में अपना मैसेज बॉक्स जोड़ें।'
|
|
3406
|
+
'किसी वॉलेट आइडेंटिटी को भुगतान करने के लिए सेटिंग्स में अपना मैसेज बॉक्स जोड़ें।',
|
|
3407
|
+
direct_pay_kept_needs_attention:
|
|
3408
|
+
'{{name}} से {{amount}} sats के सीधे भुगतान पर ध्यान देना ज़रूरी है: आपका वॉलेट इसे जोड़ नहीं सका। यह इसी डिवाइस पर रखा है।'
|
|
3404
3409
|
}
|
|
3405
3410
|
},
|
|
3406
3411
|
es: {
|
|
@@ -4538,7 +4543,9 @@ const resources = {
|
|
|
4538
4543
|
'Es posible que tu pago a {{name}} ya se haya enviado. Revisa Actividad antes de volver a pagar.',
|
|
4539
4544
|
direct_pay_failed_not_sent: 'No se pudo enviar el pago. No se gastó nada.',
|
|
4540
4545
|
direct_pay_failed_no_message_box:
|
|
4541
|
-
'Conecta tu buzón de mensajes en Ajustes para pagar a una identidad de billetera.'
|
|
4546
|
+
'Conecta tu buzón de mensajes en Ajustes para pagar a una identidad de billetera.',
|
|
4547
|
+
direct_pay_kept_needs_attention:
|
|
4548
|
+
'Un pago directo de {{amount}} sats de {{name}} necesita atención: tu billetera no pudo añadirlo. Se conserva en este dispositivo.'
|
|
4542
4549
|
}
|
|
4543
4550
|
},
|
|
4544
4551
|
fr: {
|
|
@@ -5690,7 +5697,9 @@ const resources = {
|
|
|
5690
5697
|
'Votre paiement à {{name}} a peut-être déjà été envoyé. Consultez Activité avant de payer à nouveau.',
|
|
5691
5698
|
direct_pay_failed_not_sent: "Le paiement n'a pas pu être envoyé. Rien n'a été dépensé.",
|
|
5692
5699
|
direct_pay_failed_no_message_box:
|
|
5693
|
-
'Connectez votre boîte aux lettres dans les réglages pour payer une identité de portefeuille.'
|
|
5700
|
+
'Connectez votre boîte aux lettres dans les réglages pour payer une identité de portefeuille.',
|
|
5701
|
+
direct_pay_kept_needs_attention:
|
|
5702
|
+
"Un paiement direct de {{amount}} sats de {{name}} demande votre attention : votre portefeuille n'a pas pu l'ajouter. Il reste sur cet appareil."
|
|
5694
5703
|
}
|
|
5695
5704
|
},
|
|
5696
5705
|
ar: {
|
|
@@ -6768,7 +6777,9 @@ const resources = {
|
|
|
6768
6777
|
direct_pay_failed_cancelled: 'تم الإلغاء. لم يتم إنفاق أي مبلغ.',
|
|
6769
6778
|
direct_pay_failed_maybe_sent: 'ربما تم إرسال دفعتك إلى {{name}} بالفعل. تحقق من النشاط قبل الدفع مرة أخرى.',
|
|
6770
6779
|
direct_pay_failed_not_sent: 'تعذّر إرسال الدفعة. لم يتم إنفاق أي مبلغ.',
|
|
6771
|
-
direct_pay_failed_no_message_box: 'اربط صندوق رسائلك من الإعدادات للدفع إلى هوية محفظة.'
|
|
6780
|
+
direct_pay_failed_no_message_box: 'اربط صندوق رسائلك من الإعدادات للدفع إلى هوية محفظة.',
|
|
6781
|
+
direct_pay_kept_needs_attention:
|
|
6782
|
+
'دفعة مباشرة بقيمة {{amount}} sats من {{name}} تحتاج إلى انتباهك: لم تتمكن محفظتك من إضافتها. تبقى محفوظة على هذا الجهاز.'
|
|
6772
6783
|
}
|
|
6773
6784
|
},
|
|
6774
6785
|
pt: {
|
|
@@ -7905,7 +7916,9 @@ const resources = {
|
|
|
7905
7916
|
'Seu pagamento para {{name}} pode já ter sido enviado. Confira Atividade antes de pagar novamente.',
|
|
7906
7917
|
direct_pay_failed_not_sent: 'Não foi possível enviar o pagamento. Nada foi gasto.',
|
|
7907
7918
|
direct_pay_failed_no_message_box:
|
|
7908
|
-
'Conecte sua caixa de mensagens em Configurações para pagar uma identidade de carteira.'
|
|
7919
|
+
'Conecte sua caixa de mensagens em Configurações para pagar uma identidade de carteira.',
|
|
7920
|
+
direct_pay_kept_needs_attention:
|
|
7921
|
+
'Um pagamento direto de {{amount}} sats de {{name}} precisa de atenção: sua carteira não conseguiu adicioná-lo. Ele continua neste dispositivo.'
|
|
7909
7922
|
}
|
|
7910
7923
|
},
|
|
7911
7924
|
bn: {
|
|
@@ -9020,7 +9033,9 @@ const resources = {
|
|
|
9020
9033
|
direct_pay_failed_maybe_sent:
|
|
9021
9034
|
'{{name}}-এর কাছে আপনার পেমেন্ট হয়তো ইতিমধ্যে পাঠানো হয়ে গেছে। আবার পেমেন্ট করার আগে কার্যকলাপ দেখুন।',
|
|
9022
9035
|
direct_pay_failed_not_sent: 'পেমেন্ট পাঠানো যায়নি। কিছুই খরচ হয়নি।',
|
|
9023
|
-
direct_pay_failed_no_message_box: 'ওয়ালেট আইডেন্টিটিকে পেমেন্ট করতে সেটিংসে আপনার মেসেজ বক্স যুক্ত করুন।'
|
|
9036
|
+
direct_pay_failed_no_message_box: 'ওয়ালেট আইডেন্টিটিকে পেমেন্ট করতে সেটিংসে আপনার মেসেজ বক্স যুক্ত করুন।',
|
|
9037
|
+
direct_pay_kept_needs_attention:
|
|
9038
|
+
'{{name}}-এর কাছ থেকে {{amount}} sats-এর একটি সরাসরি পেমেন্টে মনোযোগ প্রয়োজন: আপনার ওয়ালেট এটি যোগ করতে পারেনি। এটি এই ডিভাইসেই রাখা আছে।'
|
|
9024
9039
|
}
|
|
9025
9040
|
},
|
|
9026
9041
|
ru: {
|
|
@@ -10153,7 +10168,9 @@ const resources = {
|
|
|
10153
10168
|
'Ваш платёж для {{name}}, возможно, уже отправлен. Проверьте «Активность», прежде чем платить снова.',
|
|
10154
10169
|
direct_pay_failed_not_sent: 'Не удалось отправить платёж. Ничего не потрачено.',
|
|
10155
10170
|
direct_pay_failed_no_message_box:
|
|
10156
|
-
'Подключите почтовый ящик в настройках, чтобы платить по идентификатору кошелька.'
|
|
10171
|
+
'Подключите почтовый ящик в настройках, чтобы платить по идентификатору кошелька.',
|
|
10172
|
+
direct_pay_kept_needs_attention:
|
|
10173
|
+
'Прямой платёж на {{amount}} sats от {{name}} требует внимания: кошелёк не смог его добавить. Он сохранён на этом устройстве.'
|
|
10157
10174
|
}
|
|
10158
10175
|
},
|
|
10159
10176
|
id: {
|
|
@@ -11283,7 +11300,9 @@ const resources = {
|
|
|
11283
11300
|
direct_pay_failed_maybe_sent:
|
|
11284
11301
|
'Pembayaran Anda ke {{name}} mungkin sudah terkirim. Periksa Aktivitas sebelum membayar lagi.',
|
|
11285
11302
|
direct_pay_failed_not_sent: 'Pembayaran tidak dapat dikirim. Tidak ada dana yang terpakai.',
|
|
11286
|
-
direct_pay_failed_no_message_box: 'Hubungkan kotak pesan Anda di Pengaturan untuk membayar identitas dompet.'
|
|
11303
|
+
direct_pay_failed_no_message_box: 'Hubungkan kotak pesan Anda di Pengaturan untuk membayar identitas dompet.',
|
|
11304
|
+
direct_pay_kept_needs_attention:
|
|
11305
|
+
'Pembayaran langsung {{amount}} sats dari {{name}} perlu perhatian: dompet Anda tidak dapat menambahkannya. Pembayaran ini tetap tersimpan di perangkat ini.'
|
|
11287
11306
|
}
|
|
11288
11307
|
},
|
|
11289
11308
|
ja: {
|
|
@@ -12412,7 +12431,8 @@ const resources = {
|
|
|
12412
12431
|
direct_pay_failed_maybe_sent:
|
|
12413
12432
|
'{{name}}への支払いはすでに送信されている可能性があります。もう一度支払う前に、アクティビティを確認してください。',
|
|
12414
12433
|
direct_pay_failed_not_sent: '支払いを送信できませんでした。何も使われていません。',
|
|
12415
|
-
direct_pay_failed_no_message_box: 'ウォレットIDに支払うには、設定でメッセージボックスを接続してください。'
|
|
12434
|
+
direct_pay_failed_no_message_box: 'ウォレットIDに支払うには、設定でメッセージボックスを接続してください。',
|
|
12435
|
+
direct_pay_kept_needs_attention: '{{name}} からの {{amount}} sats のダイレクト支払いに対応が必要です。ウォレットに追加できませんでした。この端末に保存されています。'
|
|
12416
12436
|
}
|
|
12417
12437
|
},
|
|
12418
12438
|
pl: {
|
|
@@ -13568,7 +13588,9 @@ const resources = {
|
|
|
13568
13588
|
'Twoja płatność dla {{name}} mogła już zostać wysłana. Sprawdź Aktywność, zanim zapłacisz ponownie.',
|
|
13569
13589
|
direct_pay_failed_not_sent: 'Nie udało się wysłać płatności. Nic nie wydano.',
|
|
13570
13590
|
direct_pay_failed_no_message_box:
|
|
13571
|
-
'Połącz swoją skrzynkę wiadomości w ustawieniach, aby płacić tożsamości portfela.'
|
|
13591
|
+
'Połącz swoją skrzynkę wiadomości w ustawieniach, aby płacić tożsamości portfela.',
|
|
13592
|
+
direct_pay_kept_needs_attention:
|
|
13593
|
+
'Płatność bezpośrednia {{amount}} sats od {{name}} wymaga uwagi: portfel nie mógł jej dodać. Pozostaje na tym urządzeniu.'
|
|
13572
13594
|
}
|
|
13573
13595
|
}
|
|
13574
13596
|
}
|
package/core/index.ts
CHANGED
|
@@ -122,9 +122,14 @@ export * from './localpay/nearbyPermissions'
|
|
|
122
122
|
// callers need to tell an AckError (radio failure → fountain) from a decline.
|
|
123
123
|
export { AckError, QrHandoffRequired, type Ack, type LocalPaymentTransport, type ReceivedFrame } from './localpay/types'
|
|
124
124
|
export { selectTransport, fallbackRadio, failedBeforeConnect } from './localpay/transport/select'
|
|
125
|
-
// Direct (push) payments: settings, pay flow and status
|
|
126
|
-
//
|
|
125
|
+
// Direct (push) payments: settings, pay flow and status as pure functions, and the
|
|
126
|
+
// @bsv/webrtpay shapes with its lazy loader. The screens that use them are a separate change.
|
|
127
127
|
export * from './directpay'
|
|
128
|
+
// The runtime half of direct payments: see the note in './directpay/index'.
|
|
129
|
+
export * from './directpay/deviceStore'
|
|
130
|
+
export * from './directpay/receive'
|
|
131
|
+
export * from './directpay/DirectPayManager'
|
|
132
|
+
export * from './directpay/DirectPayProvider'
|
|
128
133
|
export * from './peerpay/outbox'
|
|
129
134
|
export * from './peerpay/control'
|
|
130
135
|
export * from './peerpay/handleResendRequests'
|
|
@@ -266,6 +271,7 @@ export * from './pay/patp'
|
|
|
266
271
|
export * from './pay/counterparty'
|
|
267
272
|
export * from './pay/rails/address'
|
|
268
273
|
export * from './pay/rails/handle'
|
|
274
|
+
export * from './pay/rails/direct'
|
|
269
275
|
// nearby.ts is a pure re-export barrel over localpay/* (already exported above)
|
|
270
276
|
// and @bsv/air-gap; only its genuinely new names are re-exported here by hand —
|
|
271
277
|
// a blanket `export *` would collide (TS2308) with the localpay/offline exports
|
package/core/pay/creditInbox.ts
CHANGED
|
@@ -7,16 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Beef } from '@bsv/sdk'
|
|
9
9
|
import { type IncomingPayment, type PeerPayClient } from '@bsv/message-box-client'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
listDamagedInboxMessages,
|
|
13
|
-
type DamagedInboxMessage
|
|
14
|
-
} from './damagedInbox'
|
|
15
|
-
import {
|
|
16
|
-
autoAcceptInbox,
|
|
17
|
-
needsAttention,
|
|
18
|
-
type InboxAttempt
|
|
19
|
-
} from './rails/handle'
|
|
10
|
+
import { isPaymentTokenShape, listDamagedInboxMessages, type DamagedInboxMessage } from './damagedInbox'
|
|
11
|
+
import { autoAcceptInbox, needsAttention, type CreditOutcome, type InboxAttempt } from './rails/handle'
|
|
20
12
|
import type { CreditFailureKind } from './creditErrors'
|
|
21
13
|
import { sendControlMessage } from '../peerpay/control'
|
|
22
14
|
import { loadInboxAttempts, saveInboxAttempts } from '../peerpay/inboxAttempts'
|
|
@@ -144,7 +136,7 @@ async function runCreditInbox(args: {
|
|
|
144
136
|
storage?: StorageLike
|
|
145
137
|
force?: string[]
|
|
146
138
|
classify?: (e: unknown) => CreditFailureKind
|
|
147
|
-
accept: (payment: IncomingPayment) => Promise<void>
|
|
139
|
+
accept: (payment: IncomingPayment) => Promise<void | CreditOutcome>
|
|
148
140
|
}): Promise<CreditInboxResult> {
|
|
149
141
|
const { client, messageBoxUrl, storage, force, classify, accept } = args
|
|
150
142
|
const raw = await listRawInbox(client, messageBoxUrl)
|
|
@@ -214,7 +206,8 @@ export async function creditInboxOnce(args: {
|
|
|
214
206
|
storage?: StorageLike
|
|
215
207
|
force?: string[]
|
|
216
208
|
classify?: (e: unknown) => CreditFailureKind
|
|
217
|
-
|
|
209
|
+
/** See `autoAcceptInbox`: `'duplicate'` leaves the box but is not counted as accepted. */
|
|
210
|
+
accept: (payment: IncomingPayment) => Promise<void | CreditOutcome>
|
|
218
211
|
}): Promise<CreditInboxResult> {
|
|
219
212
|
const force = args.force ?? []
|
|
220
213
|
if (inFlight && force.length === 0) return inFlight
|