@bsv/expo-wallet-toolbox 0.24.1 → 0.24.3
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 +33 -0
- package/LICENSE.txt +202 -28
- package/NOTICE +2 -0
- package/core/i18n/translations.tsx +24 -0
- package/core/localpay/session.ts +47 -4
- package/core/pay/rails/nearby.ts +1 -1
- package/core/pay/rails/sweep.ts +92 -5
- package/core/storage/README.md +1 -1
- package/package.json +7 -2
- package/ui/components/pay/NearbyFlow.tsx +65 -15
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.24.3
|
|
6
|
+
|
|
7
|
+
The nearby session QR names the payee's network. No native change: hosts do not rebuild.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`n` in the `bsvpay1:` session QR, and `sessionNetworkMismatch`.** Two phones
|
|
12
|
+
on different networks (mainnet and testnet) paired with no warning, and the
|
|
13
|
+
payment failed with nothing on either screen to say why. The payee now mints
|
|
14
|
+
its network (an AppChain name, as a till's code carries) into the session.
|
|
15
|
+
`NearbyFlow` checks it on the payer before the confirm screen and fails with
|
|
16
|
+
`local_pay_wrong_network`, which names both networks (12 locales). The key is
|
|
17
|
+
additive: `SESSION_VERSION` stays at 2, an older decoder ignores it, and a
|
|
18
|
+
code without it is read as unknown, never as a mismatch. Both sides use the
|
|
19
|
+
network only once the mounted storage belongs to it, so a network switch in
|
|
20
|
+
progress never tags or refuses wrongly. Only the payer sees the warning, and
|
|
21
|
+
only when both phones run this version or later.
|
|
22
|
+
|
|
23
|
+
## 0.24.2
|
|
24
|
+
|
|
25
|
+
Progress events for the sweep rail. No native change: hosts do not rebuild.
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **`onProgress` on `scanMnemonic`, `decideMnemonicImport`, `sweepWif` and
|
|
30
|
+
`sweepMnemonic`.** A scan of a recovery phrase takes a request or two per
|
|
31
|
+
address, paced, so a host had nothing to show for a long time. The listener
|
|
32
|
+
gets a `SweepProgress` event for the backup check, for each address about to
|
|
33
|
+
be checked (path name, chain path and index), for coins found, for each
|
|
34
|
+
finished path, and before and after each sweep transaction. Events carry
|
|
35
|
+
derivation paths and totals, never an address or a key. A listener that
|
|
36
|
+
throws does not stop the scan or the sweep.
|
|
37
|
+
|
|
5
38
|
## 0.24.1
|
|
6
39
|
|
|
7
40
|
One fix: the iOS native fetch. Hosts must rebuild their native apps.
|
package/LICENSE.txt
CHANGED
|
@@ -1,28 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
with the
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -1038,6 +1038,8 @@ const resources = {
|
|
|
1038
1038
|
local_pay_queued: 'Saved — it will be added to your wallet automatically.',
|
|
1039
1039
|
local_pay_already_paid: 'This request has already been paid.',
|
|
1040
1040
|
local_pay_failed: 'Payment failed',
|
|
1041
|
+
local_pay_wrong_network:
|
|
1042
|
+
'This code is for a wallet on {{theirs}}. Your wallet is on {{mine}}, so this payment cannot go through. Switch networks, or ask them to.',
|
|
1041
1043
|
local_pay_network_denied: 'Local Network access is off. Enable it in Settings to pay nearby devices.',
|
|
1042
1044
|
local_pay_radio_fallback: 'Wireless link unavailable — show this code to the other device instead.',
|
|
1043
1045
|
local_pay_floor_peer_bt_off: 'Their Bluetooth is off, so this payment will go by code.',
|
|
@@ -2200,6 +2202,8 @@ const resources = {
|
|
|
2200
2202
|
local_pay_queued: '已保存 — 稍后会自动添加到您的钱包。',
|
|
2201
2203
|
local_pay_already_paid: '此请求已经支付过了。',
|
|
2202
2204
|
local_pay_failed: '付款失败',
|
|
2205
|
+
local_pay_wrong_network:
|
|
2206
|
+
'此付款码属于{{theirs}}上的钱包。您的钱包在{{mine}}上,因此无法完成此付款。请切换网络,或请对方切换。',
|
|
2203
2207
|
local_pay_network_denied: '本地网络访问已关闭。请在“设置”中开启,才能向附近的设备付款。',
|
|
2204
2208
|
local_pay_radio_fallback: '无线连接不可用——请改为向对方出示此码。',
|
|
2205
2209
|
local_pay_floor_peer_bt_off: '对方的蓝牙已关闭,此付款将通过二维码完成。',
|
|
@@ -3402,6 +3406,8 @@ const resources = {
|
|
|
3402
3406
|
local_pay_queued: 'सहेज लिया गया — यह अपने आप आपके वॉलेट में जुड़ जाएगा।',
|
|
3403
3407
|
local_pay_already_paid: 'इस अनुरोध का भुगतान पहले ही हो चुका है।',
|
|
3404
3408
|
local_pay_failed: 'भुगतान विफल',
|
|
3409
|
+
local_pay_wrong_network:
|
|
3410
|
+
'यह कोड {{theirs}} पर एक वॉलेट का है। आपका वॉलेट {{mine}} पर है, इसलिए यह भुगतान नहीं हो सकता। नेटवर्क बदलें, या उनसे बदलने को कहें।',
|
|
3405
3411
|
local_pay_network_denied:
|
|
3406
3412
|
'लोकल नेटवर्क एक्सेस बंद है। नज़दीकी डिवाइस को भुगतान करने के लिए इसे सेटिंग्स में चालू करें।',
|
|
3407
3413
|
local_pay_radio_fallback: 'वायरलेस लिंक उपलब्ध नहीं — इसके बजाय यह कोड दूसरे डिवाइस को दिखाएँ।',
|
|
@@ -4637,6 +4643,8 @@ const resources = {
|
|
|
4637
4643
|
local_pay_queued: 'Guardado: se añadirá a tu billetera automáticamente.',
|
|
4638
4644
|
local_pay_already_paid: 'Esta solicitud ya fue pagada.',
|
|
4639
4645
|
local_pay_failed: 'El pago falló',
|
|
4646
|
+
local_pay_wrong_network:
|
|
4647
|
+
'Este código es de una billetera en {{theirs}}. Tu billetera está en {{mine}}, así que este pago no puede realizarse. Cambia de red o pídeles que lo hagan.',
|
|
4640
4648
|
local_pay_network_denied:
|
|
4641
4649
|
'El acceso a la red local está desactivado. Actívalo en Configuración para pagar a dispositivos cercanos.',
|
|
4642
4650
|
local_pay_radio_fallback: 'Enlace inalámbrico no disponible: muestra este código al otro dispositivo.',
|
|
@@ -5891,6 +5899,8 @@ const resources = {
|
|
|
5891
5899
|
local_pay_queued: 'Enregistré — il sera ajouté automatiquement à votre portefeuille.',
|
|
5892
5900
|
local_pay_already_paid: 'Cette demande a déjà été payée.',
|
|
5893
5901
|
local_pay_failed: 'Échec du paiement',
|
|
5902
|
+
local_pay_wrong_network:
|
|
5903
|
+
'Ce code est destiné à un portefeuille sur {{theirs}}. Votre portefeuille est sur {{mine}}, ce paiement ne peut donc pas aboutir. Changez de réseau, ou demandez-leur de le faire.',
|
|
5894
5904
|
local_pay_network_denied:
|
|
5895
5905
|
'L’accès au réseau local est désactivé. Activez-le dans Réglages pour payer les appareils à proximité.',
|
|
5896
5906
|
local_pay_radio_fallback: 'Liaison sans fil indisponible — présentez plutôt ce code à l’autre appareil.',
|
|
@@ -7093,6 +7103,8 @@ const resources = {
|
|
|
7093
7103
|
local_pay_queued: 'تم الحفظ — ستُضاف إلى محفظتك تلقائيًا.',
|
|
7094
7104
|
local_pay_already_paid: 'تم دفع هذا الطلب بالفعل.',
|
|
7095
7105
|
local_pay_failed: 'فشلت عملية الدفع',
|
|
7106
|
+
local_pay_wrong_network:
|
|
7107
|
+
'هذا الرمز لمحفظة على {{theirs}}. محفظتك على {{mine}}، لذا لا يمكن إتمام هذه الدفعة. غيّر الشبكة، أو اطلب منهم ذلك.',
|
|
7096
7108
|
local_pay_network_denied: 'الوصول إلى الشبكة المحلية مُعطَّل. فعّله من الإعدادات للدفع إلى الأجهزة القريبة.',
|
|
7097
7109
|
local_pay_radio_fallback: 'الاتصال اللاسلكي غير متاح — اعرض هذا الرمز على الجهاز الآخر بدلاً من ذلك.',
|
|
7098
7110
|
local_pay_floor_peer_bt_off: 'بلوتوث الجهاز الآخر مُغلق، لذا ستتم هذه الدفعة عبر الرمز.',
|
|
@@ -8316,6 +8328,8 @@ const resources = {
|
|
|
8316
8328
|
local_pay_queued: 'Salvo — será adicionado à sua carteira automaticamente.',
|
|
8317
8329
|
local_pay_already_paid: 'Esta solicitação já foi paga.',
|
|
8318
8330
|
local_pay_failed: 'Falha no pagamento',
|
|
8331
|
+
local_pay_wrong_network:
|
|
8332
|
+
'Este código é de uma carteira na {{theirs}}. Sua carteira está na {{mine}}, então este pagamento não pode ser concluído. Troque de rede ou peça que a outra pessoa troque.',
|
|
8319
8333
|
local_pay_network_denied:
|
|
8320
8334
|
'O acesso à rede local está desativado. Ative-o em Ajustes para pagar dispositivos por perto.',
|
|
8321
8335
|
local_pay_radio_fallback: 'Link sem fio indisponível — mostre este código ao outro aparelho.',
|
|
@@ -9540,6 +9554,8 @@ const resources = {
|
|
|
9540
9554
|
local_pay_queued: 'সংরক্ষিত হয়েছে — এটি স্বয়ংক্রিয়ভাবে আপনার ওয়ালেটে যোগ হবে।',
|
|
9541
9555
|
local_pay_already_paid: 'এই অনুরোধের পেমেন্ট আগেই হয়ে গেছে।',
|
|
9542
9556
|
local_pay_failed: 'পেমেন্ট ব্যর্থ হয়েছে',
|
|
9557
|
+
local_pay_wrong_network:
|
|
9558
|
+
'এই কোডটি {{theirs}}-এর একটি ওয়ালেটের জন্য। আপনার ওয়ালেট {{mine}}-এ আছে, তাই এই পেমেন্ট সম্ভব নয়। নেটওয়ার্ক বদলান, অথবা তাদের বদলাতে বলুন।',
|
|
9543
9559
|
local_pay_network_denied:
|
|
9544
9560
|
'লোকাল নেটওয়ার্ক অ্যাক্সেস বন্ধ আছে। কাছের ডিভাইসে পেমেন্ট করতে সেটিংসে এটি চালু করুন।',
|
|
9545
9561
|
local_pay_radio_fallback: 'ওয়্যারলেস লিঙ্ক অনুপলব্ধ — এর পরিবর্তে অন্য ডিভাইসে এই কোডটি দেখান।',
|
|
@@ -10770,6 +10786,8 @@ const resources = {
|
|
|
10770
10786
|
local_pay_queued: 'Сохранено — платёж будет добавлен в кошелёк автоматически.',
|
|
10771
10787
|
local_pay_already_paid: 'Этот запрос уже оплачен.',
|
|
10772
10788
|
local_pay_failed: 'Платёж не прошёл',
|
|
10789
|
+
local_pay_wrong_network:
|
|
10790
|
+
'Этот код для кошелька в сети {{theirs}}. Ваш кошелёк в сети {{mine}}, поэтому платёж не пройдёт. Смените сеть или попросите об этом получателя.',
|
|
10773
10791
|
local_pay_network_denied:
|
|
10774
10792
|
'Доступ к локальной сети выключен. Включите его в «Настройках», чтобы платить устройствам поблизости.',
|
|
10775
10793
|
local_pay_radio_fallback: 'Беспроводное соединение недоступно — покажите этот код другому устройству.',
|
|
@@ -12005,6 +12023,8 @@ const resources = {
|
|
|
12005
12023
|
local_pay_queued: 'Tersimpan — akan ditambahkan ke dompet Anda secara otomatis.',
|
|
12006
12024
|
local_pay_already_paid: 'Permintaan ini sudah dibayar.',
|
|
12007
12025
|
local_pay_failed: 'Pembayaran gagal',
|
|
12026
|
+
local_pay_wrong_network:
|
|
12027
|
+
'Kode ini untuk dompet di {{theirs}}. Dompet Anda di {{mine}}, jadi pembayaran ini tidak bisa dilakukan. Ganti jaringan, atau minta mereka menggantinya.',
|
|
12008
12028
|
local_pay_network_denied:
|
|
12009
12029
|
'Akses Jaringan Lokal nonaktif. Aktifkan di Pengaturan untuk membayar perangkat di dekat Anda.',
|
|
12010
12030
|
local_pay_radio_fallback:
|
|
@@ -13249,6 +13269,8 @@ const resources = {
|
|
|
13249
13269
|
local_pay_queued: '保存しました — 自動的にウォレットへ追加されます。',
|
|
13250
13270
|
local_pay_already_paid: 'このリクエストはすでに支払われています。',
|
|
13251
13271
|
local_pay_failed: '支払いに失敗しました',
|
|
13272
|
+
local_pay_wrong_network:
|
|
13273
|
+
'このコードは{{theirs}}のウォレット用です。あなたのウォレットは{{mine}}にあるため、この支払いはできません。ネットワークを切り替えるか、相手に切り替えてもらってください。',
|
|
13252
13274
|
local_pay_network_denied:
|
|
13253
13275
|
'ローカルネットワークへのアクセスがオフです。近くの端末に支払うには「設定」でオンにしてください。',
|
|
13254
13276
|
local_pay_radio_fallback: '無線リンクが利用できません — 代わりにこのコードを相手の端末に表示してください。',
|
|
@@ -14498,6 +14520,8 @@ const resources = {
|
|
|
14498
14520
|
local_pay_queued: 'Zapisano — zostanie automatycznie dodane do portfela.',
|
|
14499
14521
|
local_pay_already_paid: 'Ta prośba została już opłacona.',
|
|
14500
14522
|
local_pay_failed: 'Płatność nie powiodła się',
|
|
14523
|
+
local_pay_wrong_network:
|
|
14524
|
+
'Ten kod jest dla portfela w sieci {{theirs}}. Twój portfel jest w sieci {{mine}}, więc ta płatność nie przejdzie. Zmień sieć albo poproś o to odbiorcę.',
|
|
14501
14525
|
local_pay_network_denied:
|
|
14502
14526
|
'Dostęp do sieci lokalnej jest wyłączony. Włącz go w Ustawieniach, aby płacić urządzeniom w pobliżu.',
|
|
14503
14527
|
local_pay_radio_fallback: 'Połączenie bezprzewodowe niedostępne — pokaż ten kod drugiemu urządzeniu.',
|
package/core/localpay/session.ts
CHANGED
|
@@ -118,6 +118,35 @@ export interface Session {
|
|
|
118
118
|
* instead would break the moment either platform grows a second transport.
|
|
119
119
|
*/
|
|
120
120
|
os?: SessionOs
|
|
121
|
+
/**
|
|
122
|
+
* The network the payee's wallet is on: an AppChain name ('main', 'test',
|
|
123
|
+
* 'teratest', …), the same names a till's code carries. Undefined from a
|
|
124
|
+
* payee whose build predates the field — unknown, not a mismatch.
|
|
125
|
+
*
|
|
126
|
+
* A string, not AppChain, on purpose: a name this build does not know (a
|
|
127
|
+
* newer network) is kept, so the payer still sees a mismatch rather than
|
|
128
|
+
* paying into it. Without this, a testnet code decodes cleanly on a mainnet
|
|
129
|
+
* phone and the payment fails with nothing on either screen to say why.
|
|
130
|
+
* Read it through `sessionNetworkMismatch`.
|
|
131
|
+
*/
|
|
132
|
+
network?: string
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** A network name on the wire: short, lowercase, so a QR cannot carry copy into the payer's screen. */
|
|
136
|
+
const NETWORK_RE = /^[a-z0-9-]{1,32}$/
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Whether a scanned session is for another network than this wallet's.
|
|
140
|
+
* Null when they match, or when the payee did not say (an older build): an
|
|
141
|
+
* absent field is never read as a mismatch, or every pre-field payee would
|
|
142
|
+
* be refused.
|
|
143
|
+
*/
|
|
144
|
+
export function sessionNetworkMismatch(
|
|
145
|
+
session: Pick<Session, 'network'>,
|
|
146
|
+
mine: string
|
|
147
|
+
): { theirs: string; mine: string } | null {
|
|
148
|
+
if (session.network === undefined || session.network === mine) return null
|
|
149
|
+
return { theirs: session.network, mine }
|
|
121
150
|
}
|
|
122
151
|
|
|
123
152
|
export function mintSession(args: {
|
|
@@ -141,8 +170,11 @@ export function mintSession(args: {
|
|
|
141
170
|
*/
|
|
142
171
|
hints?: number
|
|
143
172
|
os?: SessionOs
|
|
173
|
+
/** The AppChain this payee's wallet is on. Every minting screen should pass it; see Session.network. */
|
|
174
|
+
network?: string
|
|
144
175
|
}): Session {
|
|
145
176
|
if (args.identityKey.length !== 66) throw new CodecError('identityKey must be 66 hex chars')
|
|
177
|
+
if (args.network !== undefined && !NETWORK_RE.test(args.network)) throw new CodecError('bad network')
|
|
146
178
|
// Validated at the mint too, not only at decode: an invalid figure minted
|
|
147
179
|
// here would render on the payee's own screen and be echoed to the payer as
|
|
148
180
|
// an authentic request before any decoder ever saw it.
|
|
@@ -193,7 +225,8 @@ export function mintSession(args: {
|
|
|
193
225
|
...(args.asset === undefined ? {} : { asset: assetOf(args.asset) }),
|
|
194
226
|
derivationPrefix: args.derivationPrefix,
|
|
195
227
|
derivationSuffix: args.derivationSuffix,
|
|
196
|
-
...(args.os === undefined ? {} : { os: args.os })
|
|
228
|
+
...(args.os === undefined ? {} : { os: args.os }),
|
|
229
|
+
...(args.network === undefined ? {} : { network: args.network })
|
|
197
230
|
}
|
|
198
231
|
}
|
|
199
232
|
|
|
@@ -278,7 +311,10 @@ export function encodeSession(s: Session): string {
|
|
|
278
311
|
}
|
|
279
312
|
}),
|
|
280
313
|
p: s.derivationPrefix,
|
|
281
|
-
x: s.derivationSuffix
|
|
314
|
+
x: s.derivationSuffix,
|
|
315
|
+
// Additive, so no version bump: a v2 decoder that predates `n` ignores
|
|
316
|
+
// unknown keys, and one that knows it reads an absent `n` as unknown.
|
|
317
|
+
...(s.network === undefined ? {} : { n: s.network })
|
|
282
318
|
})
|
|
283
319
|
return 'bsvpay1:' + toB64url(new TextEncoder().encode(body))
|
|
284
320
|
}
|
|
@@ -292,7 +328,7 @@ export function decodeSession(text: string): Session {
|
|
|
292
328
|
if (e instanceof CodecError) throw e
|
|
293
329
|
throw new CodecError('malformed session payload')
|
|
294
330
|
}
|
|
295
|
-
const { v, c, s, k, i, a, p, x, o, t } = parsed as Record<string, unknown>
|
|
331
|
+
const { v, c, s, k, i, a, p, x, o, t, n } = parsed as Record<string, unknown>
|
|
296
332
|
if (v !== SESSION_VERSION) throw new CodecError(`unsupported session version ${String(v)}`)
|
|
297
333
|
if (typeof i !== 'string' || i.length !== 66) throw new CodecError('bad identityKey')
|
|
298
334
|
// An ABSENT `a` is an OPEN request: the payer chooses.
|
|
@@ -331,6 +367,12 @@ export function decodeSession(text: string): Session {
|
|
|
331
367
|
if (psk.length !== 32) throw new CodecError('bad psk length')
|
|
332
368
|
// Tolerant on purpose: 'o' is advisory, from possibly-newer builds.
|
|
333
369
|
const os: SessionOs | undefined = o === 'i' ? 'ios' : o === 'a' ? 'android' : undefined
|
|
370
|
+
// Not tolerant like 'o': a malformed name refuses the whole code, never
|
|
371
|
+
// drops to "unknown" — that would let the payment through to the silent
|
|
372
|
+
// failure this field exists to stop. Only a peer that breaks the codec
|
|
373
|
+
// writes one. An unfamiliar but well-formed name is kept, and flagged as a
|
|
374
|
+
// mismatch.
|
|
375
|
+
if (n !== undefined && (typeof n !== 'string' || !NETWORK_RE.test(n))) throw new CodecError('bad network')
|
|
334
376
|
let asset: SessionAsset | undefined
|
|
335
377
|
if (t !== undefined) {
|
|
336
378
|
if (typeof t !== 'object' || t === null) throw new CodecError('bad asset block')
|
|
@@ -358,7 +400,8 @@ export function decodeSession(text: string): Session {
|
|
|
358
400
|
...(asset === undefined ? {} : { asset }),
|
|
359
401
|
derivationPrefix: p,
|
|
360
402
|
derivationSuffix: x,
|
|
361
|
-
...(os === undefined ? {} : { os })
|
|
403
|
+
...(os === undefined ? {} : { os }),
|
|
404
|
+
...(n === undefined ? {} : { network: n as string })
|
|
362
405
|
}
|
|
363
406
|
}
|
|
364
407
|
|
package/core/pay/rails/nearby.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* If you find yourself wanting to add a function here, add it to the caller
|
|
11
11
|
* instead.
|
|
12
12
|
*/
|
|
13
|
-
export { decodeSession, encodeSession, mintSession, type Session } from '../../localpay/session'
|
|
13
|
+
export { decodeSession, encodeSession, mintSession, sessionNetworkMismatch, type Session } from '../../localpay/session'
|
|
14
14
|
export {
|
|
15
15
|
FRAME_BLOCK_BYTES,
|
|
16
16
|
SEAL_VERSION,
|
package/core/pay/rails/sweep.ts
CHANGED
|
@@ -357,6 +357,48 @@ export async function planWifSweep(args: { wif: string; woc: WocConfig } & FeeOp
|
|
|
357
357
|
)
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
/**
|
|
361
|
+
* What a scan or a sweep is doing right now, for a screen that shows it.
|
|
362
|
+
* Events carry derivation paths and totals, never an address or a key.
|
|
363
|
+
*
|
|
364
|
+
* - `backup`: the backup cache is asked about the phrase (decideMnemonicImport).
|
|
365
|
+
* - `address`: one address is about to be checked. `chainPath` is the chain
|
|
366
|
+
* (receive or change) and `index` the child under it.
|
|
367
|
+
* - `found`: an address has coins. Raw figures, before tokens and dust are
|
|
368
|
+
* taken out; the plan has the figures the sweep will spend.
|
|
369
|
+
* - `path-done`: both chains of one path are finished.
|
|
370
|
+
* - `batch`: one sweep transaction is about to be built. `index` counts from 0.
|
|
371
|
+
* - `batch-done`: that transaction went through (`txid`), failed (`error`),
|
|
372
|
+
* or had nothing to spend (neither).
|
|
373
|
+
*/
|
|
374
|
+
export type SweepProgress =
|
|
375
|
+
| { stage: 'backup' }
|
|
376
|
+
| {
|
|
377
|
+
stage: 'address'
|
|
378
|
+
name: string
|
|
379
|
+
pathIndex: number
|
|
380
|
+
pathCount: number
|
|
381
|
+
chain: 'receive' | 'change'
|
|
382
|
+
chainPath: string
|
|
383
|
+
index: number
|
|
384
|
+
}
|
|
385
|
+
| { stage: 'found'; name: string; pathIndex: number; path: string; utxoCount: number; satoshis: number }
|
|
386
|
+
| { stage: 'path-done'; name: string; pathIndex: number; usedAddresses: number; utxoCount: number; satoshis: number }
|
|
387
|
+
| { stage: 'batch'; index: number; count: number; inputCount: number }
|
|
388
|
+
| { stage: 'batch-done'; index: number; count: number; txid?: string; error?: string }
|
|
389
|
+
|
|
390
|
+
export type SweepProgressListener = (progress: SweepProgress) => void
|
|
391
|
+
|
|
392
|
+
/** A listener is for display only: one that throws must not stop a scan or a sweep. */
|
|
393
|
+
function report(listener: SweepProgressListener | undefined, progress: SweepProgress): void {
|
|
394
|
+
if (!listener) return
|
|
395
|
+
try {
|
|
396
|
+
listener(progress)
|
|
397
|
+
} catch {
|
|
398
|
+
// Display only.
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
360
402
|
export interface SweepBatchResult {
|
|
361
403
|
txid?: string
|
|
362
404
|
inputCount: number
|
|
@@ -393,6 +435,8 @@ interface ExecuteArgs {
|
|
|
393
435
|
maxInputsPerTx?: number
|
|
394
436
|
maxFeeRate?: number
|
|
395
437
|
minRequestIntervalMs?: number
|
|
438
|
+
/** Called before and after each sweep transaction. */
|
|
439
|
+
onProgress?: SweepProgressListener
|
|
396
440
|
}
|
|
397
441
|
|
|
398
442
|
/**
|
|
@@ -443,6 +487,8 @@ export interface MnemonicScanArgs extends FeeOptions {
|
|
|
443
487
|
paths?: readonly SweepPathSpec[]
|
|
444
488
|
gapLimit?: number
|
|
445
489
|
minRequestIntervalMs?: number
|
|
490
|
+
/** Called as the scan moves from address to address, and when it finds coins. */
|
|
491
|
+
onProgress?: SweepProgressListener
|
|
446
492
|
}
|
|
447
493
|
|
|
448
494
|
/**
|
|
@@ -490,12 +536,17 @@ export async function scanMnemonic(args: MnemonicScanArgs): Promise<MnemonicScan
|
|
|
490
536
|
const found: SweepInput[] = []
|
|
491
537
|
const summaries: PathScanSummary[] = []
|
|
492
538
|
|
|
493
|
-
const walk = async (
|
|
539
|
+
const walk = async (
|
|
540
|
+
node: HD,
|
|
541
|
+
prefix: string,
|
|
542
|
+
at: { name: string; pathIndex: number; chain: 'receive' | 'change' }
|
|
543
|
+
): Promise<{ used: number; inputs: SweepInput[] }> => {
|
|
494
544
|
let used = 0
|
|
495
545
|
let unusedRun = 0
|
|
496
546
|
const inputs: SweepInput[] = []
|
|
497
547
|
for (let i = 0; i < MAX_SCAN_INDEX && unusedRun < gapLimit; i++) {
|
|
498
548
|
const address = addressForKey(node.deriveChild(i).privKey, true, network)
|
|
549
|
+
report(args.onProgress, { stage: 'address', ...at, pathCount: chains.length, chainPath: prefix, index: i })
|
|
499
550
|
await pace()
|
|
500
551
|
if (!(await addressHasHistory(args.woc, address))) {
|
|
501
552
|
unusedRun++
|
|
@@ -506,16 +557,35 @@ export async function scanMnemonic(args: MnemonicScanArgs): Promise<MnemonicScan
|
|
|
506
557
|
await pace()
|
|
507
558
|
const utxos = await getUtxosForAddress(args.woc, address)
|
|
508
559
|
inputs.push(...utxos.map(u => ({ ...u, address, path: `${prefix}/${i}` })))
|
|
560
|
+
if (utxos.length > 0) {
|
|
561
|
+
report(args.onProgress, {
|
|
562
|
+
stage: 'found',
|
|
563
|
+
name: at.name,
|
|
564
|
+
pathIndex: at.pathIndex,
|
|
565
|
+
path: `${prefix}/${i}`,
|
|
566
|
+
utxoCount: utxos.length,
|
|
567
|
+
satoshis: utxos.reduce((n, u) => n + u.satoshis, 0)
|
|
568
|
+
})
|
|
569
|
+
}
|
|
509
570
|
}
|
|
510
571
|
return { used, inputs }
|
|
511
572
|
}
|
|
512
573
|
|
|
513
|
-
for (const chain of chains) {
|
|
514
|
-
const
|
|
574
|
+
for (const [pathIndex, chain] of chains.entries()) {
|
|
575
|
+
const at = { name: chain.spec.name, pathIndex }
|
|
576
|
+
const receive = await walk(chain.receive, chain.spec.receive, { ...at, chain: 'receive' })
|
|
515
577
|
let change = { used: 0, inputs: [] as SweepInput[] }
|
|
516
578
|
const changeScanned = receive.used > 0 && chain.change !== undefined
|
|
517
|
-
if (changeScanned) change = await walk(chain.change!, chain.spec.change
|
|
579
|
+
if (changeScanned) change = await walk(chain.change!, chain.spec.change!, { ...at, chain: 'change' })
|
|
518
580
|
found.push(...receive.inputs, ...change.inputs)
|
|
581
|
+
const all = [...receive.inputs, ...change.inputs]
|
|
582
|
+
report(args.onProgress, {
|
|
583
|
+
stage: 'path-done',
|
|
584
|
+
...at,
|
|
585
|
+
usedAddresses: receive.used + change.used,
|
|
586
|
+
utxoCount: all.length,
|
|
587
|
+
satoshis: all.reduce((n, u) => n + u.satoshis, 0)
|
|
588
|
+
})
|
|
519
589
|
summaries.push({
|
|
520
590
|
name: chain.spec.name,
|
|
521
591
|
receive: chain.spec.receive,
|
|
@@ -623,6 +693,7 @@ export async function decideMnemonicImport(
|
|
|
623
693
|
}
|
|
624
694
|
): Promise<MnemonicImportDecision> {
|
|
625
695
|
if (args.probe) {
|
|
696
|
+
report(args.onProgress, { stage: 'backup' })
|
|
626
697
|
// Profile 0 of the phrase, derived exactly as the wallet derives it (deriveProfileKeys).
|
|
627
698
|
const primaryKey = withSeed(args.mnemonic, args.passphrase ?? '', root => deriveProfileKeys(root, 0).primaryKey)
|
|
628
699
|
try {
|
|
@@ -664,9 +735,20 @@ async function executeSweep(
|
|
|
664
735
|
const keyed = plan.inputs.map(input => ({ input, ...args.keyFor(input) }))
|
|
665
736
|
const sources = new Map<string, Beef>()
|
|
666
737
|
|
|
738
|
+
const batchCount = Math.ceil(keyed.length / maxInputs)
|
|
667
739
|
for (let start = 0; start < keyed.length; start += maxInputs) {
|
|
668
740
|
const candidates = keyed.slice(start, start + maxInputs)
|
|
669
741
|
const batch: SweepBatchResult = { inputCount: 0, inputSatoshis: 0, importedSatoshis: 0, feeSatoshis: 0 }
|
|
742
|
+
const index = start / maxInputs
|
|
743
|
+
const finished = (): void =>
|
|
744
|
+
report(args.onProgress, {
|
|
745
|
+
stage: 'batch-done',
|
|
746
|
+
index,
|
|
747
|
+
count: batchCount,
|
|
748
|
+
...(batch.txid ? { txid: batch.txid } : {}),
|
|
749
|
+
...(batch.error ? { error: batch.error } : {})
|
|
750
|
+
})
|
|
751
|
+
report(args.onProgress, { stage: 'batch', index, count: batchCount, inputCount: candidates.length })
|
|
670
752
|
let reference: string | undefined
|
|
671
753
|
try {
|
|
672
754
|
// Verify each input against the real source transaction: its real value
|
|
@@ -694,7 +776,10 @@ async function executeSweep(
|
|
|
694
776
|
inputBeef.mergeBeef(source.toBinaryAtomic(k.input.txid))
|
|
695
777
|
spend.set(`${k.input.txid}.${k.input.vout}`, { ...k, satoshis })
|
|
696
778
|
}
|
|
697
|
-
if (spend.size === 0)
|
|
779
|
+
if (spend.size === 0) {
|
|
780
|
+
finished()
|
|
781
|
+
continue
|
|
782
|
+
}
|
|
698
783
|
batches.push(batch)
|
|
699
784
|
|
|
700
785
|
const created = await wallet.createAction(
|
|
@@ -759,9 +844,11 @@ async function executeSweep(
|
|
|
759
844
|
feeSatoshis: fee
|
|
760
845
|
})
|
|
761
846
|
for (const k of spend.values()) spent.push({ ...k.input, satoshis: k.satoshis })
|
|
847
|
+
finished()
|
|
762
848
|
} catch (error) {
|
|
763
849
|
if (!batches.includes(batch)) batches.push(batch)
|
|
764
850
|
batch.error = error instanceof Error ? error.message : String(error)
|
|
851
|
+
finished()
|
|
765
852
|
if (reference) {
|
|
766
853
|
try {
|
|
767
854
|
await wallet.abortAction({ reference }, adminOriginator)
|
package/core/storage/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/expo-wallet-toolbox",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Wallet screens and P2P local-payment backend for Expo/React Native apps, extracted from BSV Wallet.",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
7
|
"author": "BSV Association",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
],
|
|
23
23
|
"main": "core/index.ts",
|
|
24
24
|
"types": "core/index.ts",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepack": "node -e \"const fs=require('fs');for(const f of ['NOTICE'])fs.copyFileSync('../../'+f,f)\""
|
|
27
|
+
},
|
|
25
28
|
"files": [
|
|
29
|
+
"LICENSE",
|
|
30
|
+
"NOTICE",
|
|
26
31
|
"core",
|
|
27
32
|
"ui",
|
|
28
33
|
"assets",
|
|
@@ -133,6 +133,7 @@ import {
|
|
|
133
133
|
durations,
|
|
134
134
|
springs,
|
|
135
135
|
useWalletManagers,
|
|
136
|
+
useWalletStatus,
|
|
136
137
|
sounds,
|
|
137
138
|
updateOfflineAction,
|
|
138
139
|
AirGapDecoder,
|
|
@@ -168,6 +169,7 @@ import {
|
|
|
168
169
|
requestBlePermissions,
|
|
169
170
|
requestNearbyPermissions,
|
|
170
171
|
sealedToQr,
|
|
172
|
+
sessionNetworkMismatch,
|
|
171
173
|
sealFrame,
|
|
172
174
|
selectTransport,
|
|
173
175
|
unsealFrame,
|
|
@@ -188,6 +190,7 @@ import {
|
|
|
188
190
|
type SessionAsset
|
|
189
191
|
} from '@bsv/expo-wallet-toolbox'
|
|
190
192
|
import { useMandala } from '../../hooks/useMandala'
|
|
193
|
+
import { storageMatchesNetwork } from '../../../core/net/chainMatch'
|
|
191
194
|
import { formatTokenAmount, formatTokenAmountWithUnit } from '../../tokenFormat'
|
|
192
195
|
import type { AmountInputAsset } from '../wallet/AmountInput'
|
|
193
196
|
import type { DismissTarget } from '../../dismissTarget'
|
|
@@ -393,6 +396,22 @@ function looksLikeLocalNetworkDenial(message: string): boolean {
|
|
|
393
396
|
)
|
|
394
397
|
}
|
|
395
398
|
|
|
399
|
+
/**
|
|
400
|
+
* A network's name as the settings screen shows it. A name this build does
|
|
401
|
+
* not know (from a newer payee) is shown as it came: it is already checked
|
|
402
|
+
* to be a short lowercase word, so it cannot carry copy into the screen.
|
|
403
|
+
*/
|
|
404
|
+
const NETWORK_LABEL_KEYS: Record<string, string> = {
|
|
405
|
+
main: 'mainnet',
|
|
406
|
+
test: 'testnet',
|
|
407
|
+
teratest: 'teratest',
|
|
408
|
+
scaletest: 'scaletest'
|
|
409
|
+
}
|
|
410
|
+
function networkName(chain: string, t: (key: string) => string): string {
|
|
411
|
+
const key = NETWORK_LABEL_KEYS[chain]
|
|
412
|
+
return key ? t(key) : chain
|
|
413
|
+
}
|
|
414
|
+
|
|
396
415
|
function abbreviateKey(key: string): string {
|
|
397
416
|
return key.length > 16 ? `${key.slice(0, 10)}…${key.slice(-6)}` : key
|
|
398
417
|
}
|
|
@@ -658,6 +677,19 @@ function NearbyFlow({
|
|
|
658
677
|
const reducedMotion = useReducedMotion()
|
|
659
678
|
const { managers, adminOriginator, storage } = useWalletManagers()
|
|
660
679
|
const wallet = managers?.permissionsManager ?? null
|
|
680
|
+
/**
|
|
681
|
+
* The network this wallet is on, as an AppChain name. The payee writes it
|
|
682
|
+
* into the session QR; the payer compares it in adoptSession, so two phones
|
|
683
|
+
* on different networks are told so before the confirm screen rather than
|
|
684
|
+
* failing in silence.
|
|
685
|
+
*
|
|
686
|
+
* Only once the mounted storage is that network's: across a network switch
|
|
687
|
+
* the picker moves before the wallet is rebuilt, and a wrong tag would
|
|
688
|
+
* refuse a payment that works. Undefined means "not known": no tag is
|
|
689
|
+
* minted and no comparison is made.
|
|
690
|
+
*/
|
|
691
|
+
const { selectedNetwork } = useWalletStatus()
|
|
692
|
+
const walletNetwork = storageMatchesNetwork(storage, selectedNetwork) ? selectedNetwork : undefined
|
|
661
693
|
/**
|
|
662
694
|
* The only door to stablecoins this screen has. Everything token-shaped
|
|
663
695
|
* below is gated on it: with no runtime there is no token session to mint,
|
|
@@ -1634,7 +1666,8 @@ function NearbyFlow({
|
|
|
1634
1666
|
// read as 'unknown' a moment earlier, so where it ran it overrides the
|
|
1635
1667
|
// probe's field. The hint bits are copy for the payer, not dispatch.
|
|
1636
1668
|
hints: capsFromProbe({ ...probe, bluetooth: bleHere ? bleNow : probe.bluetooth }),
|
|
1637
|
-
os: Platform.OS === 'ios' ? 'ios' : 'android'
|
|
1669
|
+
os: Platform.OS === 'ios' ? 'ios' : 'android',
|
|
1670
|
+
network: walletNetwork
|
|
1638
1671
|
})
|
|
1639
1672
|
setRole('payee')
|
|
1640
1673
|
setHostedSession(session)
|
|
@@ -1643,7 +1676,7 @@ function NearbyFlow({
|
|
|
1643
1676
|
fail('generic', messageOf(e))
|
|
1644
1677
|
}
|
|
1645
1678
|
},
|
|
1646
|
-
[wallet, storage, adminOriginator, supportsAwdl, nearbyReady, blePermitted, fail, t]
|
|
1679
|
+
[wallet, storage, adminOriginator, supportsAwdl, nearbyReady, blePermitted, walletNetwork, fail, t]
|
|
1647
1680
|
)
|
|
1648
1681
|
|
|
1649
1682
|
// ── Receive: scan the payer's frame ──
|
|
@@ -1696,19 +1729,36 @@ function NearbyFlow({
|
|
|
1696
1729
|
// ── Send: scan the payee's session ──
|
|
1697
1730
|
|
|
1698
1731
|
/** The state moves that follow a valid session, whether scanned here or handed in. */
|
|
1699
|
-
const adoptSession = useCallback(
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1732
|
+
const adoptSession = useCallback(
|
|
1733
|
+
(session: Session) => {
|
|
1734
|
+
// Before anything is shown as payable: a payee on another network can
|
|
1735
|
+
// never receive this payment, and nothing later in the flow would say
|
|
1736
|
+
// why. A payee too old to name its network is let through, as before.
|
|
1737
|
+
const mismatch = walletNetwork === undefined ? null : sessionNetworkMismatch(session, walletNetwork)
|
|
1738
|
+
if (mismatch) {
|
|
1739
|
+
fail(
|
|
1740
|
+
'generic',
|
|
1741
|
+
t('local_pay_wrong_network', {
|
|
1742
|
+
theirs: networkName(mismatch.theirs, t),
|
|
1743
|
+
mine: networkName(mismatch.mine, t)
|
|
1744
|
+
})
|
|
1745
|
+
)
|
|
1746
|
+
return
|
|
1747
|
+
}
|
|
1748
|
+
setScannedSession(session)
|
|
1749
|
+
// Prompt-free read of this device's Bluetooth state for describeFloor.
|
|
1750
|
+
// Never prepare() here: a payer who lands on QR must never be prompted.
|
|
1751
|
+
setBleState(readBluetoothState())
|
|
1752
|
+
// Who is being paid. Best-effort lookup for the presence row and the
|
|
1753
|
+
// recipient card; nothing waits on it.
|
|
1754
|
+
setPeerKey(session.identityKey)
|
|
1755
|
+
setSendAmount('')
|
|
1756
|
+
setNote('')
|
|
1757
|
+
setRole('payer')
|
|
1758
|
+
setPhase('send_confirm')
|
|
1759
|
+
},
|
|
1760
|
+
[walletNetwork, fail, t]
|
|
1761
|
+
)
|
|
1712
1762
|
|
|
1713
1763
|
const onSessionScanned = useCallback(
|
|
1714
1764
|
(data: string) => {
|