@bsv/expo-wallet-toolbox 0.24.2 → 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 CHANGED
@@ -2,6 +2,24 @@
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
+
5
23
  ## 0.24.2
6
24
 
7
25
  Progress events for the sweep rail. No native change: hosts do not rebuild.
package/LICENSE.txt CHANGED
@@ -1,28 +1,202 @@
1
- Open BSV License version 4
2
-
3
- Copyright (c) 2023 BSV Blockchain Association ("Bitcoin Association")
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- 1 - The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- 2 - The Software, and any software that is derived from the Software or parts thereof,
16
- can only be used on the Bitcoin SV blockchains. The Bitcoin SV blockchains are defined,
17
- for purposes of this license, as the Bitcoin blockchain containing block height #556767
18
- with the hash "000000000000000001d956714215d96ffc00e0afda4cd0a96c96f8d802b1662b" and
19
- that contains the longest persistent chain of blocks accepted by this Software and which are valid under the rules set forth in the Bitcoin white paper (S. Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System, posted online October 2008) and the latest version of this Software available in this repository or another repository designated by Bitcoin Association,
20
- as well as the test blockchains that contain the longest persistent chains of blocks accepted by this Software and which are valid under the rules set forth in the Bitcoin whitepaper (S. Nakamoto, Bitcoin: A Peer-to-Peer Electronic Cash System, posted online October 2008) and the latest version of this Software available in this repository, or another repository designated by Bitcoin Association
21
-
22
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
- THE SOFTWARE.
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
@@ -0,0 +1,2 @@
1
+ bsv-wallet
2
+ Copyright 2025-2026 BSV Association
@@ -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.',
@@ -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
 
@@ -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,
@@ -388,4 +388,4 @@ Potential areas for improvement:
388
388
 
389
389
  ## License
390
390
 
391
- Open BSV License
391
+ Apache License 2.0
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@bsv/expo-wallet-toolbox",
3
- "version": "0.24.2",
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": "SEE LICENSE IN LICENSE.txt",
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((session: Session) => {
1700
- setScannedSession(session)
1701
- // Prompt-free read of this device's Bluetooth state for describeFloor.
1702
- // Never prepare() here: a payer who lands on QR must never be prompted.
1703
- setBleState(readBluetoothState())
1704
- // Who is being paid. Best-effort lookup for the presence row and the
1705
- // recipient card; nothing waits on it.
1706
- setPeerKey(session.identityKey)
1707
- setSendAmount('')
1708
- setNote('')
1709
- setRole('payer')
1710
- setPhase('send_confirm')
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) => {