sats-connect 4.3.0-b449ffd → 4.3.0-c73581e
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/dist/index.mjs +5 -39
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -19,8 +19,10 @@ import {
|
|
|
19
19
|
export * from "@sats-connect/core";
|
|
20
20
|
|
|
21
21
|
// src/decodeAddressPsbtData.ts
|
|
22
|
+
import { unlockDefinitionSchema } from "@sats-connect/core";
|
|
22
23
|
import { hex } from "@scure/base";
|
|
23
24
|
import { TaprootControlBlock } from "@scure/btc-signer";
|
|
25
|
+
import * as v from "valibot";
|
|
24
26
|
var DecodeAddressPsbtDataError = class extends Error {
|
|
25
27
|
name = "DecodeAddressPsbtDataError";
|
|
26
28
|
};
|
|
@@ -36,45 +38,9 @@ var decodeHex = (value, field) => {
|
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
var parseUnlockDefinition = (value) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const definition = value;
|
|
43
|
-
switch (definition.type) {
|
|
44
|
-
case "p2wpkh":
|
|
45
|
-
return { type: "p2wpkh" };
|
|
46
|
-
case "p2sh-p2wpkh":
|
|
47
|
-
decodeHex(definition.redeemScript, "redeemScript");
|
|
48
|
-
return definition;
|
|
49
|
-
case "p2tr-key-path":
|
|
50
|
-
if (decodeHex(definition.tapInternalKey, "tapInternalKey").length !== 32) {
|
|
51
|
-
throw malformed("tapInternalKey");
|
|
52
|
-
}
|
|
53
|
-
return definition;
|
|
54
|
-
case "p2wsh":
|
|
55
|
-
decodeHex(definition.witnessScript, "witnessScript");
|
|
56
|
-
return definition;
|
|
57
|
-
case "p2tr-script-path": {
|
|
58
|
-
if (!Array.isArray(definition.tapLeafScript) || definition.tapLeafScript.length === 0) {
|
|
59
|
-
throw malformed("tapLeafScript");
|
|
60
|
-
}
|
|
61
|
-
for (const leaf of definition.tapLeafScript) {
|
|
62
|
-
if (!leaf || typeof leaf !== "object") throw malformed("tapLeafScript");
|
|
63
|
-
const { controlBlock, script } = leaf;
|
|
64
|
-
const controlBlockBytes = decodeHex(controlBlock, "controlBlock");
|
|
65
|
-
const scriptBytes = decodeHex(script, "script");
|
|
66
|
-
if (controlBlockBytes.length < 33 || controlBlockBytes.length > 33 + 32 * 128 || (controlBlockBytes.length - 33) % 32 !== 0) {
|
|
67
|
-
throw malformed("controlBlock");
|
|
68
|
-
}
|
|
69
|
-
if (scriptBytes.at(-1) !== (controlBlockBytes[0] & 254)) {
|
|
70
|
-
throw malformed("tapLeafScript");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return definition;
|
|
74
|
-
}
|
|
75
|
-
default:
|
|
76
|
-
throw malformed("unlockDefinition");
|
|
77
|
-
}
|
|
41
|
+
const result = v.safeParse(unlockDefinitionSchema, value);
|
|
42
|
+
if (!result.success) throw malformed("unlockDefinition", result.issues);
|
|
43
|
+
return result.output;
|
|
78
44
|
};
|
|
79
45
|
var decodeAddressPsbtData = (address) => {
|
|
80
46
|
if (!address || typeof address !== "object") throw malformed("address");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sats-connect",
|
|
3
|
-
"version": "4.3.0-
|
|
3
|
+
"version": "4.3.0-c73581e",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
]
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@sats-connect/core": "0.
|
|
27
|
+
"@sats-connect/core": "0.19.0-6dc1656",
|
|
28
28
|
"@sats-connect/make-default-provider-config": "0.0.10",
|
|
29
29
|
"@sats-connect/ui": "0.0.7",
|
|
30
30
|
"@scure/base": "2.4.0",
|