@bsv/expo-wallet-toolbox 0.15.1 → 0.15.2
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 +16 -0
- package/core/mandala/permissionModule.ts +19 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.2
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Sending Mandala tokens to yourself works.** Requires `@bsv/mandala`
|
|
8
|
+
0.4.1, which no longer blinds a send to the wallet's own identity key (the
|
|
9
|
+
wallet refuses the root shared secret with itself, so these sends failed
|
|
10
|
+
before `createAction`). The output is locked like change and kept in the
|
|
11
|
+
token basket; no MessageBox message is sent. This covers the in-app handle
|
|
12
|
+
rail as well as connected apps.
|
|
13
|
+
- **The spend prompt shows a send to yourself as sent.** `MandalaTokenModule`
|
|
14
|
+
counted every `'p mandala'`-basketed output as change, so a send to yourself
|
|
15
|
+
read "wants to spend 0". A basketed output whose `customInstructions` mark
|
|
16
|
+
it `direction: 'sent'` now counts as sent. An unbasketed output always
|
|
17
|
+
counts as sent, so an app can only make the prompt show more, never less.
|
|
18
|
+
|
|
3
19
|
## 0.15.1
|
|
4
20
|
|
|
5
21
|
### Fixed
|
|
@@ -221,6 +221,19 @@ export interface MandalaTokenModuleDeps {
|
|
|
221
221
|
interface MandalaCreateActionOutputLike {
|
|
222
222
|
lockingScript?: string
|
|
223
223
|
basket?: string
|
|
224
|
+
customInstructions?: string
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** True for an output the Mandala lib marks as the payment itself
|
|
228
|
+
* (customInstructions `direction: 'sent'`). In a send to yourself that
|
|
229
|
+
* output stays in the basket, so the basket alone would show it as change. */
|
|
230
|
+
function isMarkedSent(output: MandalaCreateActionOutputLike): boolean {
|
|
231
|
+
if (typeof output?.customInstructions !== 'string') return false
|
|
232
|
+
try {
|
|
233
|
+
return (JSON.parse(output.customInstructions) as { direction?: unknown })?.direction === 'sent'
|
|
234
|
+
} catch {
|
|
235
|
+
return false
|
|
236
|
+
}
|
|
224
237
|
}
|
|
225
238
|
/** The slice of `RelinquishOutputArgs` this module reads. */
|
|
226
239
|
interface MandalaRelinquishOutputArgsLike {
|
|
@@ -714,8 +727,9 @@ export class MandalaTokenModule implements PermissionsModule {
|
|
|
714
727
|
* assetId (adversarial-review finding 4 — a createAction touching more
|
|
715
728
|
* than one asset previously collapsed every asset's amounts into one
|
|
716
729
|
* running total under whichever assetId was seen first). An output that
|
|
717
|
-
* carries the `'p mandala'` basket is change (stays with us)
|
|
718
|
-
*
|
|
730
|
+
* carries the `'p mandala'` basket is change (stays with us) unless the lib
|
|
731
|
+
* marks it as the payment (a send to yourself); one that does not is the
|
|
732
|
+
* recipient's (Mandala payer outputs are otherwise never basketed).
|
|
719
733
|
* A script that fails to decode is silently skipped, not fatal —
|
|
720
734
|
* `tryDecodeMandalaOutput` never throws.
|
|
721
735
|
*/
|
|
@@ -728,7 +742,9 @@ export class MandalaTokenModule implements PermissionsModule {
|
|
|
728
742
|
const decoded = tryDecodeMandalaOutput(output?.lockingScript)
|
|
729
743
|
if (!decoded) continue
|
|
730
744
|
const entry = totals.get(decoded.assetId) ?? { sendAmount: 0, changeAmount: 0 }
|
|
731
|
-
|
|
745
|
+
// An app can only make the prompt show MORE as sent this way, never less:
|
|
746
|
+
// an unbasketed output always counts as sent.
|
|
747
|
+
if (output.basket === MANDALA_BASKET && !isMarkedSent(output)) {
|
|
732
748
|
entry.changeAmount += decoded.amount
|
|
733
749
|
} else {
|
|
734
750
|
entry.sendAmount += decoded.amount
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/expo-wallet-toolbox",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Wallet screens and P2P local-payment backend for Expo/React Native apps, extracted from BSV Wallet.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@bsv/air-gap": "^0.1.3",
|
|
33
33
|
"@bsv/backup-cache-client": "^0.1.0",
|
|
34
34
|
"@bsv/btms-permission-module": "^1.2.1",
|
|
35
|
-
"@bsv/mandala": "^0.4.
|
|
35
|
+
"@bsv/mandala": "^0.4.1",
|
|
36
36
|
"@bsv/message-box-client": "^2.5.3",
|
|
37
37
|
"@bsv/react-native-localpay-transport": "*",
|
|
38
38
|
"@bsv/sdk": "^2.8.11",
|