@bsv/expo-wallet-toolbox 0.2.0 → 0.3.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/README.md +26 -1
- package/core/amountFormatHelpers.ts +16 -30
- package/core/context/WalletContext.tsx +15 -3
- package/core/i18n/translations.tsx +12 -0
- package/core/index.ts +16 -5
- package/core/localpay/build.ts +4 -1
- package/core/localpay/pending.ts +5 -2
- package/core/pay/counterparty.ts +159 -0
- package/core/pay/creditInbox.ts +0 -3
- package/core/pay/patp.ts +181 -0
- package/core/pay/rails/address.ts +47 -7
- package/core/pay/rails/handle.ts +24 -14
- package/core/peerpay/handleResendRequests.ts +1 -2
- package/core/storage/StorageExpoSQLite.ts +37 -0
- package/core/storage/methods/listActionsSql.ts +9 -0
- package/core/theme/sigilPalette.ts +83 -0
- package/package.json +3 -1
- package/ui/components/pay/HandleReceive.tsx +4 -4
- package/ui/components/pay/OfflineNotice.tsx +8 -0
- package/ui/components/ui/AppLogo.tsx +9 -1
- package/ui/components/ui/Sigil.tsx +62 -0
- package/ui/components/wallet/ActivityRow.tsx +87 -24
- package/ui/isImageUrl.ts +16 -3
- package/ui/screens/TrustScreen.tsx +105 -23
- package/ui/screens/WalletCheckScreen.tsx +3 -3
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ four dozen packages beyond the four listed — Expo native modules
|
|
|
34
34
|
(camera, clipboard, secure-store, haptics, ...), state/i18n libraries
|
|
35
35
|
(mobx, i18next), and BSV SDK packages. The **[Peer dependencies](#peer-dependencies)**
|
|
36
36
|
table below is the full, audited list — `package.json`'s `peerDependencies`
|
|
37
|
-
now declares all
|
|
37
|
+
now declares all 50 entries (47 directly imported + 3 required only for
|
|
38
38
|
native linking — see the Nitro row below), so a plain `npm install
|
|
39
39
|
@bsv/expo-wallet-toolbox` surfaces the rest as peer-dependency warnings
|
|
40
40
|
instead of silently missing them.
|
|
@@ -104,6 +104,26 @@ Expo SDK line.
|
|
|
104
104
|
| `react-native-svg` | 15.15.3 |
|
|
105
105
|
| `react-native-sse` | ^1.2.1 |
|
|
106
106
|
|
|
107
|
+
### Pure JS rendering (required)
|
|
108
|
+
|
|
109
|
+
| Package | Version |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `@urbit/sigil-js` | ^2.2.0 |
|
|
112
|
+
|
|
113
|
+
Draws the counterparty avatar on activity rows. This package imports only
|
|
114
|
+
its `./core` entry: the package root pulls in a DOM renderer that touches
|
|
115
|
+
`document` at import time. `./core` ships CJS, so Jest needs neither a
|
|
116
|
+
`transformIgnorePatterns` entry nor a mock for it (see
|
|
117
|
+
[Jest configuration](#jest-configuration)).
|
|
118
|
+
|
|
119
|
+
`./core` exists only as an entry in the package's `exports` map (there is no
|
|
120
|
+
`core.js` at the package root), so Metro's package-exports resolution must stay
|
|
121
|
+
enabled (`resolver.unstable_enablePackageExports`, on by default since Expo
|
|
122
|
+
SDK 53). A host that has switched it off to work around another dual-package
|
|
123
|
+
problem gets `Unable to resolve module @urbit/sigil-js/core` at bundle time;
|
|
124
|
+
the fix is a `resolveRequest` that maps `@urbit/sigil-js/core` to
|
|
125
|
+
`@urbit/sigil-js/dist/core.js`.
|
|
126
|
+
|
|
107
127
|
### State & i18n (required)
|
|
108
128
|
|
|
109
129
|
| Package | Version |
|
|
@@ -429,6 +449,11 @@ are required — both hard-won during this package's extraction:
|
|
|
429
449
|
directly), and `@bsv/backup-cache-client` (see below) must be in
|
|
430
450
|
whatever pattern you end up with.
|
|
431
451
|
|
|
452
|
+
`@urbit/sigil-js`, the peer added with the activity-row sigil avatars,
|
|
453
|
+
needs no entry here: the `./core` entry this package imports ships CJS,
|
|
454
|
+
so Jest loads it untransformed. Install it alongside the other peers and
|
|
455
|
+
nothing else in this section changes.
|
|
456
|
+
|
|
432
457
|
2. **Native-module and ESM-only-package mocks** — anything the package
|
|
433
458
|
touches that has no pure-JS Jest-safe implementation, or that ships
|
|
434
459
|
as ESM-only with no `require` export condition, needs a
|
|
@@ -58,7 +58,8 @@ const formatCurrency = (
|
|
|
58
58
|
locale: string,
|
|
59
59
|
currency: string,
|
|
60
60
|
minDigits: number,
|
|
61
|
-
maxDigits?: number
|
|
61
|
+
maxDigits?: number,
|
|
62
|
+
showPlus = false
|
|
62
63
|
): string => {
|
|
63
64
|
const abs = Math.abs(value)
|
|
64
65
|
let formatted: string
|
|
@@ -78,9 +79,14 @@ const formatCurrency = (
|
|
|
78
79
|
} catch {
|
|
79
80
|
formatted = `${currency} ${abs.toFixed(minDigits)}`
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
// Same sign convention as the satoshi formatter, so a column of mixed
|
|
83
|
+
// currencies reads one way: minus for money out, plus for money in when the
|
|
84
|
+
// caller asks for it. Accounting parentheses were dropped because the row's
|
|
85
|
+
// direction cue lives in the sign, and "(...)" is not one.
|
|
86
|
+
return `${fiatSign(value, showPlus)}${formatted}`
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
const fiatSign = (value: number, showPlus: boolean): string => (value < 0 ? '-' : showPlus && value > 0 ? '+' : '')
|
|
84
90
|
/**
|
|
85
91
|
* Format a satoshi amount as a locale-aware integer string with grouping separators.
|
|
86
92
|
* E.g. 1234567 -> "1,234,567" (en-US) or "1.234.567" (de-DE)
|
|
@@ -113,38 +119,18 @@ const formatBsvLocale = (bsvValue: number): string => {
|
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
121
|
|
|
116
|
-
/**
|
|
117
|
-
* Format a sub-cent USD value as cents (¢).
|
|
118
|
-
* Dynamically adjusts decimal precision based on magnitude.
|
|
119
|
-
*/
|
|
120
|
-
const formatCents = (cents: number): string => {
|
|
121
|
-
const absCents = Math.abs(cents)
|
|
122
|
-
let maxDigits = 2
|
|
123
|
-
if (absCents < 0.01) maxDigits = 4
|
|
124
|
-
else if (absCents < 0.1) maxDigits = 3
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
const formatted = new Intl.NumberFormat(localeDefault, {
|
|
128
|
-
minimumFractionDigits: 0,
|
|
129
|
-
maximumFractionDigits: maxDigits,
|
|
130
|
-
useGrouping: true
|
|
131
|
-
}).format(cents)
|
|
132
|
-
return `${formatted}¢`
|
|
133
|
-
} catch {
|
|
134
|
-
return `${parseFloat(cents.toFixed(maxDigits))}¢`
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
122
|
/**
|
|
139
123
|
* Format a satoshi amount as fiat using satoshis-per-unit of that currency.
|
|
140
|
-
* Values below one minor unit (1 cent, 1 yen, …) display as "< {smallest}"
|
|
141
|
-
* Otherwise rounds up to the
|
|
124
|
+
* Values below one minor unit (1 cent, 1 yen, …) display as "< {smallest}",
|
|
125
|
+
* with the sign on the figure ("< -$0.01"). Otherwise rounds up to the
|
|
126
|
+
* currency's minor unit.
|
|
142
127
|
*/
|
|
143
128
|
export const formatSatoshisAsFiat = (
|
|
144
129
|
satoshis: number,
|
|
145
130
|
satoshisPerUnit: number,
|
|
146
131
|
showFiatAsInteger = false,
|
|
147
|
-
currency = 'USD'
|
|
132
|
+
currency = 'USD',
|
|
133
|
+
showPlus = false
|
|
148
134
|
): string => {
|
|
149
135
|
if (!Number.isInteger(Number(satoshis)) || !satoshisPerUnit || satoshisPerUnit <= 0) {
|
|
150
136
|
return '...'
|
|
@@ -160,7 +146,7 @@ export const formatSatoshisAsFiat = (
|
|
|
160
146
|
|
|
161
147
|
if (v > 0 && v < threshold && !showFiatAsInteger) {
|
|
162
148
|
const smallest = formatCurrency(threshold, localeDefault, currency, digits, digits)
|
|
163
|
-
return
|
|
149
|
+
return `< ${fiatSign(raw, showPlus)}${smallest}`
|
|
164
150
|
}
|
|
165
151
|
|
|
166
152
|
const sign = raw < 0 ? -1 : 1
|
|
@@ -169,7 +155,7 @@ export const formatSatoshisAsFiat = (
|
|
|
169
155
|
const minDigits = showFiatAsInteger ? 0 : digits
|
|
170
156
|
const maxDigits = showFiatAsInteger ? 0 : digits
|
|
171
157
|
|
|
172
|
-
return formatCurrency(rounded, localeDefault, currency, minDigits, maxDigits)
|
|
158
|
+
return formatCurrency(rounded, localeDefault, currency, minDigits, maxDigits, showPlus)
|
|
173
159
|
}
|
|
174
160
|
|
|
175
161
|
/**
|
|
@@ -212,7 +198,7 @@ export const formatAmount = (
|
|
|
212
198
|
|
|
213
199
|
if (isFiatCurrency(currency)) {
|
|
214
200
|
const per = satoshisPerFiatUnit(currency, satoshisPerUSD, usdToFiat)
|
|
215
|
-
return formatSatoshisAsFiat(satoshis, per, showFiatAsInteger, currency)
|
|
201
|
+
return formatSatoshisAsFiat(satoshis, per, showFiatAsInteger, currency, showPlus)
|
|
216
202
|
}
|
|
217
203
|
|
|
218
204
|
return formatSatoshisAsBsv(satoshis, showPlus, abbreviate)
|
|
@@ -118,6 +118,18 @@ const DEFAULT_SETTINGS: WalletSettings = {
|
|
|
118
118
|
iconUrl: 'https://whoiam.bsvblockchain.tech/whoiam.png',
|
|
119
119
|
identityKey: '02e7eeb3986273db6843b790a1595ed0ff1b2ae8f43ae2e7f1a0c9db4dd3fb9441',
|
|
120
120
|
trust: 5
|
|
121
|
+
},
|
|
122
|
+
// Values as published in https://auth.sigmaidentity.com/manifest.json
|
|
123
|
+
// (babbage.trust). Lowest trust of the shipped set: it is the newest
|
|
124
|
+
// certifier here and the list is ordered by trust on the Trust screen.
|
|
125
|
+
// The icon is an SVG; the Trust screen draws those with react-native-svg
|
|
126
|
+
// rather than the platform decoder, which mispositions its <text> glyph.
|
|
127
|
+
{
|
|
128
|
+
name: 'Sigma Identity',
|
|
129
|
+
description: 'Certifies verified identity claims',
|
|
130
|
+
iconUrl: 'https://auth.sigmaidentity.com/sigma-mark.svg',
|
|
131
|
+
identityKey: '02250905f0383085b53409876aefbf01fc8e7fd841922dc4ce55ae035b31341e6d',
|
|
132
|
+
trust: 2
|
|
121
133
|
}
|
|
122
134
|
]
|
|
123
135
|
}
|
|
@@ -168,7 +180,7 @@ import { inputTxidsFromRawTx, shouldDeferSendWaiting } from '../storage/skipQueu
|
|
|
168
180
|
import { provenTxFromBump } from '../pay/provenTxFromBump'
|
|
169
181
|
import { recordProof } from '../pay/recordProof'
|
|
170
182
|
import { makeCreditClassifier } from '../pay/creditErrors'
|
|
171
|
-
import { creditInboxOnce
|
|
183
|
+
import { creditInboxOnce } from '../pay/creditInbox'
|
|
172
184
|
import { isReceiveInboxFocused } from '../pay/receiveFocus'
|
|
173
185
|
import { sounds } from '../hooks/useConfirmationSound'
|
|
174
186
|
import i18n from '../i18n/translations'
|
|
@@ -1394,8 +1406,8 @@ export const WalletContextProvider: React.FC<WalletContextProps> = ({ children =
|
|
|
1394
1406
|
storage: phoneStorage!,
|
|
1395
1407
|
classify,
|
|
1396
1408
|
accept: payment =>
|
|
1397
|
-
acceptWithRetry(client, messageBoxUrl, payment,
|
|
1398
|
-
internalizeIncoming(permissionsManager as never, client, adminOriginator, p,
|
|
1409
|
+
acceptWithRetry(client, messageBoxUrl, payment, p =>
|
|
1410
|
+
internalizeIncoming(permissionsManager as never, client, adminOriginator, p, repairBeef)
|
|
1399
1411
|
)
|
|
1400
1412
|
})
|
|
1401
1413
|
return { accepted: r.accepted, attention: r.attentionCount, pending: r.pending }
|
|
@@ -792,6 +792,7 @@ const resources = {
|
|
|
792
792
|
pay_offline_kv_pending: '{{count}} nearby payment(s) waiting to be added to this wallet.',
|
|
793
793
|
pay_offline_kv_stuck: '{{count}} nearby payment(s) could not be added. Ask the sender to send again.',
|
|
794
794
|
pay_offline_kv_corrupt: 'Damaged payment data was found on this device.',
|
|
795
|
+
pay_offline_kv_corrupt_body: 'The affected payments were set aside on this device, not deleted. Some of them may already have been added to your balance, so only ask a sender to send again if their payment is still missing.',
|
|
795
796
|
pay_offline_show_code: 'Show code again',
|
|
796
797
|
pay_parked_cancel: 'Cancel payment',
|
|
797
798
|
pay_parked_already_sent: 'This payment was already sent',
|
|
@@ -1427,6 +1428,7 @@ const resources = {
|
|
|
1427
1428
|
pay_offline_kv_pending: '有 {{count}} 笔附近付款等待加入此钱包。',
|
|
1428
1429
|
pay_offline_kv_stuck: '有 {{count}} 笔附近付款无法添加。请让付款方重新发送。',
|
|
1429
1430
|
pay_offline_kv_corrupt: '在此设备上发现了损坏的付款数据。',
|
|
1431
|
+
pay_offline_kv_corrupt_body: '受影响的付款已被移到此设备上的一旁保存,并未删除。其中一些可能已经计入你的余额,因此只有在某笔付款仍然缺失时,才请付款方重新发送。',
|
|
1430
1432
|
pay_offline_show_code: '再次显示付款码',
|
|
1431
1433
|
pay_parked_cancel: '取消付款',
|
|
1432
1434
|
pay_parked_already_sent: '此付款已发送',
|
|
@@ -2086,6 +2088,7 @@ const resources = {
|
|
|
2086
2088
|
pay_offline_kv_pending: '{{count}} आस-पास के भुगतान इस वॉलेट में जुड़ने के इंतज़ार में हैं।',
|
|
2087
2089
|
pay_offline_kv_stuck: '{{count}} नज़दीकी भुगतान जोड़े नहीं जा सके। भेजने वाले से दोबारा भेजने को कहें।',
|
|
2088
2090
|
pay_offline_kv_corrupt: 'इस डिवाइस पर क्षतिग्रस्त भुगतान डेटा मिला।',
|
|
2091
|
+
pay_offline_kv_corrupt_body: 'प्रभावित भुगतान इस डिवाइस पर अलग रख दिए गए हैं, मिटाए नहीं गए। इनमें से कुछ पहले ही आपके बैलेंस में जुड़ चुके हो सकते हैं, इसलिए भेजने वाले से दोबारा भेजने को तभी कहें जब उनका भुगतान अब भी नहीं मिला हो।',
|
|
2089
2092
|
pay_offline_show_code: 'कोड फिर दिखाएँ',
|
|
2090
2093
|
pay_parked_cancel: 'भुगतान रद्द करें',
|
|
2091
2094
|
pay_parked_already_sent: 'यह भुगतान पहले ही भेज दिया गया है',
|
|
@@ -2755,6 +2758,7 @@ const resources = {
|
|
|
2755
2758
|
pay_offline_kv_stuck:
|
|
2756
2759
|
'No se pudieron añadir {{count}} pago(s) cercano(s). Pide a quien pagó que lo envíe otra vez.',
|
|
2757
2760
|
pay_offline_kv_corrupt: 'Se encontraron datos de pago dañados en este dispositivo.',
|
|
2761
|
+
pay_offline_kv_corrupt_body: 'Los pagos afectados se apartaron en este dispositivo, no se borraron. Puede que algunos ya se hayan sumado a tu saldo, así que pide a alguien que vuelva a enviar solo si su pago sigue sin aparecer.',
|
|
2758
2762
|
pay_offline_show_code: 'Mostrar el código otra vez',
|
|
2759
2763
|
pay_parked_cancel: 'Cancelar el pago',
|
|
2760
2764
|
pay_parked_already_sent: 'Este pago ya se envió',
|
|
@@ -3428,6 +3432,7 @@ const resources = {
|
|
|
3428
3432
|
pay_offline_kv_stuck:
|
|
3429
3433
|
'Impossible d’ajouter {{count}} paiement(s) à proximité. Demandez à l’expéditeur de renvoyer.',
|
|
3430
3434
|
pay_offline_kv_corrupt: 'Des données de paiement endommagées ont été trouvées sur cet appareil.',
|
|
3435
|
+
pay_offline_kv_corrupt_body: 'Les paiements concernés ont été mis de côté sur cet appareil, pas supprimés. Certains ont peut-être déjà été ajoutés à votre solde : ne demandez un nouvel envoi que si le paiement manque toujours.',
|
|
3431
3436
|
pay_offline_show_code: 'Réafficher le code',
|
|
3432
3437
|
pay_parked_cancel: 'Annuler le paiement',
|
|
3433
3438
|
pay_parked_already_sent: 'Ce paiement a déjà été envoyé',
|
|
@@ -4072,6 +4077,7 @@ const resources = {
|
|
|
4072
4077
|
pay_offline_kv_pending: '{{count}} دفعة قريبة في انتظار الإضافة إلى هذه المحفظة.',
|
|
4073
4078
|
pay_offline_kv_stuck: 'تعذّرت إضافة {{count}} دفعة قريبة. اطلب من المُرسِل الإرسال مرة أخرى.',
|
|
4074
4079
|
pay_offline_kv_corrupt: 'تم العثور على بيانات دفع تالفة على هذا الجهاز.',
|
|
4080
|
+
pay_offline_kv_corrupt_body: 'تم وضع المدفوعات المتأثرة جانبًا على هذا الجهاز ولم تُحذف. ربما أُضيف بعضها إلى رصيدك بالفعل، لذا اطلب من المُرسِل الإرسال مرة أخرى فقط إذا كانت دفعته ما زالت مفقودة.',
|
|
4075
4081
|
pay_offline_show_code: 'إظهار الرمز مرة أخرى',
|
|
4076
4082
|
pay_parked_cancel: 'إلغاء الدفعة',
|
|
4077
4083
|
pay_parked_already_sent: 'تم إرسال هذه الدفعة بالفعل',
|
|
@@ -4739,6 +4745,7 @@ const resources = {
|
|
|
4739
4745
|
pay_offline_kv_pending: '{{count}} pagamento(s) por proximidade à espera de serem adicionados a esta carteira.',
|
|
4740
4746
|
pay_offline_kv_stuck: 'Não foi possível adicionar {{count}} pagamento(s) próximo(s). Peça para enviarem de novo.',
|
|
4741
4747
|
pay_offline_kv_corrupt: 'Foram encontrados dados de pagamento danificados neste dispositivo.',
|
|
4748
|
+
pay_offline_kv_corrupt_body: 'Os pagamentos afetados foram guardados à parte neste dispositivo, não foram apagados. Alguns podem já ter entrado no seu saldo, por isso peça para enviarem de novo apenas se o pagamento continuar a faltar.',
|
|
4742
4749
|
pay_offline_show_code: 'Mostrar o código novamente',
|
|
4743
4750
|
pay_parked_cancel: 'Cancelar pagamento',
|
|
4744
4751
|
pay_parked_already_sent: 'Este pagamento já foi enviado',
|
|
@@ -5398,6 +5405,7 @@ const resources = {
|
|
|
5398
5405
|
pay_offline_kv_pending: '{{count}}টি কাছাকাছি পেমেন্ট এই ওয়ালেটে যুক্ত হওয়ার অপেক্ষায়।',
|
|
5399
5406
|
pay_offline_kv_stuck: '{{count}}টি কাছাকাছি পেমেন্ট যোগ করা যায়নি। প্রেরককে আবার পাঠাতে বলুন।',
|
|
5400
5407
|
pay_offline_kv_corrupt: 'এই ডিভাইসে ক্ষতিগ্রস্ত পেমেন্ট ডেটা পাওয়া গেছে।',
|
|
5408
|
+
pay_offline_kv_corrupt_body: 'ক্ষতিগ্রস্ত পেমেন্টগুলো এই ডিভাইসে আলাদা করে রাখা হয়েছে, মুছে ফেলা হয়নি। এর কিছু হয়তো ইতিমধ্যেই আপনার ব্যালেন্সে যোগ হয়ে গেছে, তাই কোনো পেমেন্ট এখনও না পেলে তবেই প্রেরককে আবার পাঠাতে বলুন।',
|
|
5401
5409
|
pay_offline_show_code: 'কোড আবার দেখান',
|
|
5402
5410
|
pay_parked_cancel: 'পেমেন্ট বাতিল করুন',
|
|
5403
5411
|
pay_parked_already_sent: 'এই পেমেন্ট ইতিমধ্যে পাঠানো হয়েছে',
|
|
@@ -6063,6 +6071,7 @@ const resources = {
|
|
|
6063
6071
|
pay_offline_kv_pending: 'Платежей поблизости, ожидающих добавления в этот кошелёк: {{count}}.',
|
|
6064
6072
|
pay_offline_kv_stuck: 'Не удалось добавить {{count}} ближайших платежей. Попросите отправителя отправить снова.',
|
|
6065
6073
|
pay_offline_kv_corrupt: 'На этом устройстве найдены повреждённые данные платежа.',
|
|
6074
|
+
pay_offline_kv_corrupt_body: 'Затронутые платежи отложены на этом устройстве, а не удалены. Некоторые из них могли уже попасть в ваш баланс, поэтому просите отправителя отправить снова только если его платёж всё ещё не пришёл.',
|
|
6066
6075
|
pay_offline_show_code: 'Показать код снова',
|
|
6067
6076
|
pay_parked_cancel: 'Отменить платёж',
|
|
6068
6077
|
pay_parked_already_sent: 'Этот платёж уже отправлен',
|
|
@@ -6728,6 +6737,7 @@ const resources = {
|
|
|
6728
6737
|
pay_offline_kv_pending: '{{count}} pembayaran terdekat menunggu untuk ditambahkan ke dompet ini.',
|
|
6729
6738
|
pay_offline_kv_stuck: '{{count}} pembayaran terdekat tidak bisa ditambahkan. Minta pengirim mengirim ulang.',
|
|
6730
6739
|
pay_offline_kv_corrupt: 'Ditemukan data pembayaran yang rusak di perangkat ini.',
|
|
6740
|
+
pay_offline_kv_corrupt_body: 'Pembayaran yang terdampak disimpan terpisah di perangkat ini, bukan dihapus. Sebagian mungkin sudah masuk ke saldo Anda, jadi minta pengirim mengirim ulang hanya jika pembayarannya masih belum ada.',
|
|
6731
6741
|
pay_offline_show_code: 'Tampilkan kode lagi',
|
|
6732
6742
|
pay_parked_cancel: 'Batalkan pembayaran',
|
|
6733
6743
|
pay_parked_already_sent: 'Pembayaran ini sudah terkirim',
|
|
@@ -7403,6 +7413,7 @@ const resources = {
|
|
|
7403
7413
|
pay_offline_kv_pending: 'このウォレットへの追加を待っている近くの支払いが {{count}} 件あります。',
|
|
7404
7414
|
pay_offline_kv_stuck: '{{count}} 件の近くの支払いを追加できませんでした。送り主に再送を依頼してください。',
|
|
7405
7415
|
pay_offline_kv_corrupt: 'この端末で破損した支払いデータが見つかりました。',
|
|
7416
|
+
pay_offline_kv_corrupt_body: '該当する支払いはこの端末に取り分けてあり、削除されていません。すでに残高に加算されているものもあるため、支払いがまだ届いていない場合にのみ、送り主に再送を依頼してください。',
|
|
7406
7417
|
pay_offline_show_code: 'コードをもう一度表示',
|
|
7407
7418
|
pay_parked_cancel: '支払いをキャンセル',
|
|
7408
7419
|
pay_parked_already_sent: 'この支払いはすでに送信されました',
|
|
@@ -8088,6 +8099,7 @@ const resources = {
|
|
|
8088
8099
|
pay_offline_kv_pending: 'Płatności w pobliżu czekające na dodanie do tego portfela: {{count}}.',
|
|
8089
8100
|
pay_offline_kv_stuck: 'Nie udało się dodać {{count}} płatności w pobliżu. Poproś nadawcę o ponowne wysłanie.',
|
|
8090
8101
|
pay_offline_kv_corrupt: 'Na tym urządzeniu znaleziono uszkodzone dane płatności.',
|
|
8102
|
+
pay_offline_kv_corrupt_body: 'Objęte tym płatności zostały odłożone na tym urządzeniu, a nie usunięte. Część z nich mogła już trafić do Twojego salda, więc poproś nadawcę o ponowne wysłanie tylko wtedy, gdy jego płatność nadal nie dotarła.',
|
|
8091
8103
|
pay_offline_show_code: 'Pokaż kod ponownie',
|
|
8092
8104
|
pay_parked_cancel: 'Anuluj płatność',
|
|
8093
8105
|
pay_parked_already_sent: 'Ta płatność została już wysłana',
|
package/core/index.ts
CHANGED
|
@@ -29,6 +29,8 @@ export {
|
|
|
29
29
|
// Theme tokens and providers
|
|
30
30
|
export { ThemeProvider, useTheme } from './theme/ThemeContext'
|
|
31
31
|
export { spacing, radii, typography, lightColors, darkColors, hitTargets } from './theme/tokens'
|
|
32
|
+
export { sigilPalette } from './theme/sigilPalette'
|
|
33
|
+
export type { SigilPalette } from './theme/sigilPalette'
|
|
32
34
|
export { easings, springs, durations } from './theme/motion'
|
|
33
35
|
export { useThemeStyles } from './theme/useThemeStyles'
|
|
34
36
|
|
|
@@ -127,15 +129,17 @@ export * from './pay/beefRepair'
|
|
|
127
129
|
export * from './pay/creditErrors'
|
|
128
130
|
export * from './pay/creditInbox'
|
|
129
131
|
export * from './pay/userError'
|
|
132
|
+
export * from './pay/patp'
|
|
133
|
+
export * from './pay/counterparty'
|
|
130
134
|
export * from './pay/rails/address'
|
|
131
135
|
export * from './pay/rails/handle'
|
|
132
136
|
// nearby.ts is a pure re-export barrel over localpay/* (already exported above)
|
|
133
137
|
// and @bsv/air-gap; only its genuinely new names are re-exported here by hand —
|
|
134
138
|
// a blanket `export *` would collide (TS2308) with the localpay/offline exports
|
|
135
139
|
// above, since most of nearby.ts's surface is itself a re-export of those.
|
|
136
|
-
// CAP_BLE is
|
|
137
|
-
//
|
|
138
|
-
//
|
|
140
|
+
// CAP_BLE is the one nearby.ts name deliberately missing from this list:
|
|
141
|
+
// `export * from './localpay/session'` above already carries the same binding,
|
|
142
|
+
// and naming it twice trips eslint's import/export rule.
|
|
139
143
|
export {
|
|
140
144
|
AIR_GAP_PREFIX,
|
|
141
145
|
AirGapDecoder,
|
|
@@ -156,7 +160,6 @@ export {
|
|
|
156
160
|
readBluetoothState,
|
|
157
161
|
prepareBle,
|
|
158
162
|
raceReceivers,
|
|
159
|
-
CAP_BLE,
|
|
160
163
|
isDeclineReason,
|
|
161
164
|
type TransportKind,
|
|
162
165
|
type FloorReason,
|
|
@@ -185,7 +188,15 @@ export {
|
|
|
185
188
|
touchWatched,
|
|
186
189
|
unwatchAddress
|
|
187
190
|
} from './pay/watchlist'
|
|
188
|
-
|
|
191
|
+
// isCompressedPublicKey is omitted here because './pay/rails' above already
|
|
192
|
+
// re-exports the same binding; naming it twice trips eslint's import/export rule.
|
|
193
|
+
export {
|
|
194
|
+
type PeerPayParams,
|
|
195
|
+
type PeerPayValidationResult,
|
|
196
|
+
parsePeerPayURI,
|
|
197
|
+
validatePeerPayURI,
|
|
198
|
+
peerPayValidationMessage
|
|
199
|
+
} from './parsePeerPayURI'
|
|
189
200
|
|
|
190
201
|
// Blockchain header sync / checkpointing
|
|
191
202
|
export * from './headers/checkpoints'
|
package/core/localpay/build.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { isRequestableAmount, type Session } from './session'
|
|
|
4
4
|
import { PEERPAY_LABEL, PEERPAY_PROTOCOL_ID } from './pending'
|
|
5
5
|
import type { Ack } from './types'
|
|
6
6
|
import { getOnline } from '../net/online'
|
|
7
|
+
import { abbreviateKey } from '../pay/counterparty'
|
|
7
8
|
|
|
8
9
|
/** The toolbox's per-txid verdict on a `sendWith` release. */
|
|
9
10
|
type SendWithStatus = 'unproven' | 'sending' | 'failed'
|
|
@@ -125,7 +126,9 @@ export async function buildPaymentFrame(
|
|
|
125
126
|
|
|
126
127
|
let result = await wallet.createAction(
|
|
127
128
|
{
|
|
128
|
-
description
|
|
129
|
+
// The activity list uses the description as the row title, so it names
|
|
130
|
+
// the payee rather than the rail: the rail is already in the label.
|
|
131
|
+
description: abbreviateKey(session.identityKey),
|
|
129
132
|
// The payee's identity key rides as a label, and the derivation data as
|
|
130
133
|
// the output's customInstructions — exactly what the handle rail writes.
|
|
131
134
|
// Both rails derive to BRC-29 (`counterparty: identityKey`, keyID
|
package/core/localpay/pending.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Beef } from '@bsv/sdk'
|
|
2
2
|
import type { PaymentFrame } from './codec'
|
|
3
|
+
import { abbreviateKey } from '../pay/counterparty'
|
|
3
4
|
|
|
4
5
|
export const PENDING_KEY = 'localpay_pending'
|
|
5
6
|
/**
|
|
@@ -11,7 +12,6 @@ export const PENDING_KEY = 'localpay_pending'
|
|
|
11
12
|
export const PENDING_SUMMARY_KEY = 'localpay_pending_summary'
|
|
12
13
|
export const PEERPAY_PROTOCOL_ID: [number, string] = [2, '3241645161d8']
|
|
13
14
|
export const PEERPAY_LABEL = 'localpay'
|
|
14
|
-
export const PEERPAY_DESCRIPTION = 'Payment received from a nearby device'
|
|
15
15
|
|
|
16
16
|
export type PendingStatus = 'pending' | 'processing' | 'completed' | 'failed'
|
|
17
17
|
|
|
@@ -310,7 +310,10 @@ export async function processPending(
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
],
|
|
313
|
-
description
|
|
313
|
+
// The activity list uses the description as the row title, so it
|
|
314
|
+
// names the payer. The counterparty itself is recovered from
|
|
315
|
+
// outputs.senderIdentityKey, which is why the label stays rail-only.
|
|
316
|
+
description: abbreviateKey(p.frame.senderIdentityKey),
|
|
314
317
|
labels: [PEERPAY_LABEL]
|
|
315
318
|
},
|
|
316
319
|
originator
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who was on the other side of a wallet action, recovered from what the rails
|
|
3
|
+
* actually persist. Each rail records its counterparty differently and only
|
|
4
|
+
* some of them record one at all, so the activity list needs one place that
|
|
5
|
+
* turns labels, senderIdentityKey and txid into a single answer it can name
|
|
6
|
+
* and draw a sigil for.
|
|
7
|
+
*/
|
|
8
|
+
import { Hash, Utils } from '@bsv/sdk'
|
|
9
|
+
import { patp } from './patp'
|
|
10
|
+
|
|
11
|
+
/** A compressed secp256k1 public key in hex: what peer rails write as a label. */
|
|
12
|
+
export const PUBKEY_LABEL = /^(02|03)[0-9a-fA-F]{64}$/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The public key of private key 1. The address sweep has no real sender
|
|
16
|
+
* identity, so it fills senderIdentityKey with this well-known key; treating it
|
|
17
|
+
* as a counterparty would give every swept payment the same face.
|
|
18
|
+
*/
|
|
19
|
+
export const SENTINEL_SENDER_KEY = '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'
|
|
20
|
+
|
|
21
|
+
/** An outbound address send labels the action 'to:' + addressLabel payload. */
|
|
22
|
+
export const TO_ADDRESS_LABEL_PREFIX = 'to:'
|
|
23
|
+
|
|
24
|
+
/** An inbound address sweep labels the action 'from:' + addressLabel payload for the payer's zeroth-input P2PKH address. */
|
|
25
|
+
export const FROM_ADDRESS_LABEL_PREFIX = 'from:'
|
|
26
|
+
|
|
27
|
+
type AddressLabelPrefix = typeof TO_ADDRESS_LABEL_PREFIX | typeof FROM_ADDRESS_LABEL_PREFIX
|
|
28
|
+
|
|
29
|
+
/** Version byte plus hash160: the 21 bytes a P2PKH address encodes. */
|
|
30
|
+
const ADDRESS_LABEL_PAYLOAD = /^[0-9a-f]{42}$/i
|
|
31
|
+
|
|
32
|
+
export type Counterparty = { kind: 'identityKey' | 'address' | 'txid'; value: string }
|
|
33
|
+
|
|
34
|
+
export type CounterpartySource = { labels?: string[]; senderIdentityKey?: string | null; txid?: string }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The label the address rail writes for an address. The wallet folds every
|
|
38
|
+
* label to lower case before storing it (@bsv/sdk's validateLabel), and base58
|
|
39
|
+
* is case-sensitive, so the address's own spelling would come back unreadable.
|
|
40
|
+
* Hex is case-insensitive and the version byte keeps the network, so the label
|
|
41
|
+
* decodes back to exactly the address that was written.
|
|
42
|
+
*/
|
|
43
|
+
export function addressLabel(prefix: AddressLabelPrefix, address: string): string {
|
|
44
|
+
const { prefix: version, data } = Utils.fromBase58Check(address)
|
|
45
|
+
return prefix + Utils.toHex([...(version as number[]), ...(data as number[])])
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The address behind a to:/from: label. A payload this package did not write
|
|
50
|
+
* (anything but 21 hex bytes) is passed through verbatim rather than dropped:
|
|
51
|
+
* it still names something, and the seed falls back to hashing the string.
|
|
52
|
+
*/
|
|
53
|
+
function addressFromLabel(label: string): string | undefined {
|
|
54
|
+
for (const prefix of [TO_ADDRESS_LABEL_PREFIX, FROM_ADDRESS_LABEL_PREFIX]) {
|
|
55
|
+
if (!label.startsWith(prefix)) continue
|
|
56
|
+
const payload = label.slice(prefix.length)
|
|
57
|
+
if (payload.length === 0) return undefined
|
|
58
|
+
if (!ADDRESS_LABEL_PAYLOAD.test(payload)) return payload
|
|
59
|
+
const bytes = Utils.toArray(payload, 'hex')
|
|
60
|
+
return Utils.toBase58Check(bytes.slice(1), bytes.slice(0, 1))
|
|
61
|
+
}
|
|
62
|
+
return undefined
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Most specific identification first: a pubkey label (outbound peer payment),
|
|
67
|
+
* then the recorded sender (inbound peer payment), then an address label
|
|
68
|
+
* (either direction of the address rail), then the txid so that every action
|
|
69
|
+
* still gets a stable, if anonymous, face.
|
|
70
|
+
*/
|
|
71
|
+
export function counterpartyOf(a: CounterpartySource): Counterparty | null {
|
|
72
|
+
const labels = a.labels ?? []
|
|
73
|
+
const keyLabel = labels.find(label => PUBKEY_LABEL.test(label))
|
|
74
|
+
if (keyLabel !== undefined) return { kind: 'identityKey', value: keyLabel }
|
|
75
|
+
const sender = a.senderIdentityKey
|
|
76
|
+
if (typeof sender === 'string' && sender.length > 0 && sender !== SENTINEL_SENDER_KEY) {
|
|
77
|
+
return { kind: 'identityKey', value: sender }
|
|
78
|
+
}
|
|
79
|
+
for (const label of labels) {
|
|
80
|
+
const address = addressFromLabel(label)
|
|
81
|
+
if (address !== undefined) return { kind: 'address', value: address }
|
|
82
|
+
}
|
|
83
|
+
if (typeof a.txid === 'string' && a.txid.length > 0) return { kind: 'txid', value: a.txid }
|
|
84
|
+
return null
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** '02abcdef…beef' style: enough of both ends to tell two keys apart at a glance. */
|
|
88
|
+
export function abbreviateKey(s: string): string {
|
|
89
|
+
return s.length <= 13 ? s : s.slice(0, 8) + '…' + s.slice(-4)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Whole bytes only: an odd digit count has no byte form and is not a key or txid. */
|
|
93
|
+
const HEX_BYTES = /^(?:[0-9a-fA-F]{2})+$/
|
|
94
|
+
|
|
95
|
+
/** @bsv/sdk types its base58 parts as `number[] | string`; only the array form is ever returned without `enc`. */
|
|
96
|
+
function asBytes(part: number[] | string): number[] {
|
|
97
|
+
return typeof part === 'string' ? Utils.toArray(part, 'hex') : part
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The bytes a counterparty is made of, which every derived property (the
|
|
102
|
+
* shape seed, the hue) reads windows from. A key or txid is its own hex; an
|
|
103
|
+
* address is the version byte followed by the hash160 it encodes, so anything
|
|
104
|
+
* derived from its tail is a property of the key behind it rather than of its
|
|
105
|
+
* base58 spelling, and the mainnet and testnet forms of one key share a face.
|
|
106
|
+
* A value that will not parse still gets 32 deterministic bytes from a hash of
|
|
107
|
+
* the raw string: a stray label must never take down an activity row.
|
|
108
|
+
*/
|
|
109
|
+
export function counterpartyBytes(cp: Counterparty): number[] {
|
|
110
|
+
try {
|
|
111
|
+
if (cp.kind === 'address') {
|
|
112
|
+
const { prefix, data } = Utils.fromBase58Check(cp.value)
|
|
113
|
+
return [...asBytes(prefix), ...asBytes(data)]
|
|
114
|
+
}
|
|
115
|
+
// Utils.toArray also rejects bad hex, but this is the contract this module
|
|
116
|
+
// relies on, so it is stated here rather than borrowed from SDK internals.
|
|
117
|
+
if (!HEX_BYTES.test(cp.value)) throw new Error('counterpartyBytes: not hex')
|
|
118
|
+
return Utils.toArray(cp.value, 'hex')
|
|
119
|
+
} catch {
|
|
120
|
+
return Hash.sha256(Utils.toArray(cp.value, 'utf8'))
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Big-endian u32 of `bytes[start .. start+4)`. The caller guarantees the window exists. */
|
|
125
|
+
function u32At(bytes: number[], start: number): number {
|
|
126
|
+
const [b0, b1, b2, b3] = bytes.slice(start, start + 4)
|
|
127
|
+
return ((b0 << 24) | (b1 << 16) | (b2 << 8) | b3) >>> 0
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A 32-bit seed for the counterparty's sigil shape: the last four bytes. Keys,
|
|
132
|
+
* txids and hash160s are uniformly distributed already, so no further mixing
|
|
133
|
+
* is needed before `patp`. Fewer than four bytes (a short but valid hex
|
|
134
|
+
* string) are hashed first so there is always a tail to read.
|
|
135
|
+
*/
|
|
136
|
+
export function counterpartySeed(cp: Counterparty): number {
|
|
137
|
+
const bytes = counterpartyBytes(cp)
|
|
138
|
+
const src = bytes.length >= 4 ? bytes : Hash.sha256(bytes)
|
|
139
|
+
return u32At(src, src.length - 4)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* A hue in degrees, 0..359, for the counterparty's sigil tile: the four bytes
|
|
144
|
+
* immediately before the seed bytes, modulo 360. Reading a different window
|
|
145
|
+
* from the seed is the point: two counterparties that happen to share a
|
|
146
|
+
* shape still get different colours, and vice versa, so the tile carries
|
|
147
|
+
* more information than either alone. Fewer than eight bytes are hashed
|
|
148
|
+
* first so there is always a window to read.
|
|
149
|
+
*/
|
|
150
|
+
export function counterpartyHue(cp: Counterparty): number {
|
|
151
|
+
const bytes = counterpartyBytes(cp)
|
|
152
|
+
const src = bytes.length >= 8 ? bytes : Hash.sha256(bytes)
|
|
153
|
+
return u32At(src, src.length - 8) % 360
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The Urbit @p name sigil-js draws for this counterparty. */
|
|
157
|
+
export function sigilPointOf(cp: Counterparty): string {
|
|
158
|
+
return patp(counterpartySeed(cp))
|
|
159
|
+
}
|
package/core/pay/creditInbox.ts
CHANGED
|
@@ -21,9 +21,6 @@ import type { CreditFailureKind } from './creditErrors'
|
|
|
21
21
|
import { sendControlMessage } from '../peerpay/control'
|
|
22
22
|
import { loadInboxAttempts, saveInboxAttempts } from '../peerpay/inboxAttempts'
|
|
23
23
|
|
|
24
|
-
/** Same default the receive screen used when the note was left blank. */
|
|
25
|
-
export const INBOX_DESCRIPTION = 'Identity Payment'
|
|
26
|
-
|
|
27
24
|
/** Placeholder token so unparseable inbox rows can share the IncomingPayment row UI. */
|
|
28
25
|
export const DAMAGED_TOKEN_PLACEHOLDER: IncomingPayment['token'] = {
|
|
29
26
|
customInstructions: { derivationPrefix: '', derivationSuffix: '' },
|