@buildonspark/spark-sdk 0.0.9 → 0.0.11
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/services/config.d.ts +20 -16
- package/dist/services/config.js +26 -18
- package/dist/services/config.js.map +1 -1
- package/dist/services/connection.js +1 -1
- package/dist/services/connection.js.map +1 -1
- package/dist/services/deposit.js +2 -2
- package/dist/services/deposit.js.map +1 -1
- package/dist/services/lightning.js +4 -4
- package/dist/services/lightning.js.map +1 -1
- package/dist/services/token-transactions.js +8 -7
- package/dist/services/token-transactions.js.map +1 -1
- package/dist/services/transfer.js +12 -10
- package/dist/services/transfer.js.map +1 -1
- package/dist/spark-sdk.d.ts +2 -3
- package/dist/spark-sdk.js +2 -7
- package/dist/spark-sdk.js.map +1 -1
- package/dist/tests/coop-exit.test.js +8 -5
- package/dist/tests/coop-exit.test.js.map +1 -1
- package/dist/tests/deposit.test.js +8 -10
- package/dist/tests/deposit.test.js.map +1 -1
- package/dist/tests/keys.test.js +0 -1
- package/dist/tests/keys.test.js.map +1 -1
- package/dist/tests/lightning.test.js +10 -7
- package/dist/tests/lightning.test.js.map +1 -1
- package/dist/tests/swap.test.js +8 -5
- package/dist/tests/swap.test.js.map +1 -1
- package/dist/tests/test-util.d.ts +8 -44
- package/dist/tests/test-util.js +10 -7
- package/dist/tests/test-util.js.map +1 -1
- package/dist/tests/transfer.test.js +30 -19
- package/dist/tests/transfer.test.js.map +1 -1
- package/package.json +2 -2
- package/dist/LightningSendRequest-CNJFhLVc.d.cts +0 -374
- package/dist/LightningSendRequest-CNJFhLVc.d.ts +0 -374
- package/dist/auto-bind.d.ts +0 -7
- package/dist/auto-bind.js +0 -41
- package/dist/auto-bind.js.map +0 -1
- package/dist/chunk-5SAJ52IV.js +0 -10309
- package/dist/chunk-COXVABEU.js +0 -1524
- package/dist/chunk-F4JW24C4.js +0 -78
- package/dist/chunk-H4A2WXR3.js +0 -331
- package/dist/chunk-HTNOFUHX.js +0 -1547
- package/dist/chunk-JQFHUW4I.js +0 -21
- package/dist/chunk-K3Y7DVLD.js +0 -19
- package/dist/chunk-NDKNVHGP.js +0 -127
- package/dist/chunk-PMVJGQCP.js +0 -627
- package/dist/chunk-QX3ZJH2S.js +0 -527
- package/dist/chunk-SL2YOBVM.js +0 -127
- package/dist/chunk-SWCOMKD6.js +0 -333
- package/dist/chunk-SWFFNBSR.js +0 -1244
- package/dist/chunk-WLK5POBV.js +0 -527
- package/dist/chunk-WZ74TD7N.js +0 -660
- package/dist/chunk-WZYVI3M3.js +0 -1244
- package/dist/chunk-ZGU3XW7W.js +0 -78
- package/dist/connection-BgWj7Hnd.d.cts +0 -77
- package/dist/connection-BgbVJtzh.d.ts +0 -77
- package/dist/connection-DX-9yFl8.d.ts +0 -77
- package/dist/connection-hITj9Mgk.d.cts +0 -77
- package/dist/graphql/objects/index.cjs +0 -626
- package/dist/graphql/objects/index.d.cts +0 -140
- package/dist/index.cjs +0 -17202
- package/dist/index.d.cts +0 -413
- package/dist/index.d.ts +0 -413
- package/dist/index.js +0 -3390
- package/dist/proto/spark.cjs +0 -10451
- package/dist/proto/spark.d.cts +0 -3
- package/dist/services/index.cjs +0 -12503
- package/dist/services/index.d.cts +0 -23
- package/dist/services/index.d.ts +0 -23
- package/dist/services/index.js +0 -17
- package/dist/signer/signer.cjs +0 -894
- package/dist/signer/signer.d.cts +0 -5
- package/dist/signer-BaC_ZP1g.d.ts +0 -138
- package/dist/signer-C6h1OnSQ.d.cts +0 -138
- package/dist/signer-CO4owhHI.d.ts +0 -154
- package/dist/signer-DDkpXvNZ.d.cts +0 -154
- package/dist/spark-BUTdOtMz.d.cts +0 -1170
- package/dist/spark-BUTdOtMz.d.ts +0 -1170
- package/dist/tests/test-util.cjs +0 -12269
- package/dist/tests/test-util.d.cts +0 -90
- package/dist/utils/index.cjs +0 -1825
- package/dist/utils/index.d.cts +0 -280
package/dist/chunk-JQFHUW4I.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// src/utils/response-validation.ts
|
|
2
|
-
function validateResponses(responses) {
|
|
3
|
-
const successfulResponses = responses.filter(
|
|
4
|
-
(result) => result.status === "fulfilled"
|
|
5
|
-
).map((result) => result.value);
|
|
6
|
-
if (successfulResponses.length === 0) {
|
|
7
|
-
const errors = responses.filter(
|
|
8
|
-
(result) => result.status === "rejected"
|
|
9
|
-
).map((result) => result.reason).join("\n");
|
|
10
|
-
throw new Error(
|
|
11
|
-
`All requests failed.
|
|
12
|
-
Errors:
|
|
13
|
-
${errors}`
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
return successfulResponses;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
validateResponses
|
|
21
|
-
};
|
package/dist/chunk-K3Y7DVLD.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// src/utils/response-validation.ts
|
|
2
|
-
function validateResponses(responses) {
|
|
3
|
-
const successfulResponses = responses.filter(
|
|
4
|
-
(result) => result.status === "fulfilled"
|
|
5
|
-
).map((result) => result.value);
|
|
6
|
-
if (successfulResponses.length === 0) {
|
|
7
|
-
const errors = responses.filter(
|
|
8
|
-
(result) => result.status === "rejected"
|
|
9
|
-
).map((result) => result.reason).join("\n");
|
|
10
|
-
throw new Error(`All requests failed.
|
|
11
|
-
Errors:
|
|
12
|
-
${errors}`);
|
|
13
|
-
}
|
|
14
|
-
return successfulResponses;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
validateResponses
|
|
19
|
-
};
|
package/dist/chunk-NDKNVHGP.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getNetwork
|
|
3
|
-
} from "./chunk-COXVABEU.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/bitcoin.ts
|
|
6
|
-
import {
|
|
7
|
-
bytesToHex,
|
|
8
|
-
bytesToNumberBE,
|
|
9
|
-
hexToBytes
|
|
10
|
-
} from "@noble/curves/abstract/utils";
|
|
11
|
-
import { schnorr, secp256k1 } from "@noble/curves/secp256k1";
|
|
12
|
-
import * as btc from "@scure/btc-signer";
|
|
13
|
-
import { sha256 } from "@scure/btc-signer/utils";
|
|
14
|
-
function computeTaprootKeyNoScript(pubkey) {
|
|
15
|
-
if (pubkey.length !== 32) {
|
|
16
|
-
throw new Error("Public key must be 32 bytes");
|
|
17
|
-
}
|
|
18
|
-
const taggedHash = schnorr.utils.taggedHash("TapTweak", pubkey);
|
|
19
|
-
const tweak = bytesToNumberBE(taggedHash);
|
|
20
|
-
const P = schnorr.utils.lift_x(schnorr.utils.bytesToNumberBE(pubkey));
|
|
21
|
-
const Q = P.add(secp256k1.ProjectivePoint.fromPrivateKey(tweak));
|
|
22
|
-
return Q.toRawBytes();
|
|
23
|
-
}
|
|
24
|
-
function getP2TRScriptFromPublicKey(pubKey, network) {
|
|
25
|
-
if (pubKey.length !== 33) {
|
|
26
|
-
throw new Error("Public key must be 33 bytes");
|
|
27
|
-
}
|
|
28
|
-
const internalKey = secp256k1.ProjectivePoint.fromHex(pubKey);
|
|
29
|
-
const script = btc.p2tr(
|
|
30
|
-
internalKey.toRawBytes().slice(1, 33),
|
|
31
|
-
void 0,
|
|
32
|
-
getNetwork(network)
|
|
33
|
-
).script;
|
|
34
|
-
if (!script) {
|
|
35
|
-
throw new Error("Failed to get P2TR address");
|
|
36
|
-
}
|
|
37
|
-
return script;
|
|
38
|
-
}
|
|
39
|
-
function getP2TRAddressFromPublicKey(pubKey, network) {
|
|
40
|
-
if (pubKey.length !== 33) {
|
|
41
|
-
throw new Error("Public key must be 33 bytes");
|
|
42
|
-
}
|
|
43
|
-
const internalKey = secp256k1.ProjectivePoint.fromHex(pubKey);
|
|
44
|
-
const address = btc.p2tr(
|
|
45
|
-
internalKey.toRawBytes().slice(1, 33),
|
|
46
|
-
void 0,
|
|
47
|
-
getNetwork(network)
|
|
48
|
-
).address;
|
|
49
|
-
if (!address) {
|
|
50
|
-
throw new Error("Failed to get P2TR address");
|
|
51
|
-
}
|
|
52
|
-
return address;
|
|
53
|
-
}
|
|
54
|
-
function getP2TRAddressFromPkScript(pkScript, network) {
|
|
55
|
-
if (pkScript.length !== 34 || pkScript[0] !== 81 || pkScript[1] !== 32) {
|
|
56
|
-
throw new Error("Invalid pkscript");
|
|
57
|
-
}
|
|
58
|
-
const parsedScript = btc.OutScript.decode(pkScript);
|
|
59
|
-
return btc.Address(getNetwork(network)).encode(parsedScript);
|
|
60
|
-
}
|
|
61
|
-
function getTxFromRawTxHex(rawTxHex) {
|
|
62
|
-
const txBytes = hexToBytes(rawTxHex);
|
|
63
|
-
const tx = btc.Transaction.fromRaw(txBytes, {
|
|
64
|
-
allowUnknownOutputs: true
|
|
65
|
-
});
|
|
66
|
-
if (!tx) {
|
|
67
|
-
throw new Error("Failed to parse transaction");
|
|
68
|
-
}
|
|
69
|
-
return tx;
|
|
70
|
-
}
|
|
71
|
-
function getTxFromRawTxBytes(rawTxBytes) {
|
|
72
|
-
const tx = btc.Transaction.fromRaw(rawTxBytes, {
|
|
73
|
-
allowUnknownOutputs: true
|
|
74
|
-
});
|
|
75
|
-
if (!tx) {
|
|
76
|
-
throw new Error("Failed to parse transaction");
|
|
77
|
-
}
|
|
78
|
-
return tx;
|
|
79
|
-
}
|
|
80
|
-
function getSigHashFromTx(tx, inputIndex, prevOutput) {
|
|
81
|
-
const prevScript = prevOutput.script;
|
|
82
|
-
if (!prevScript) {
|
|
83
|
-
throw new Error("No script found in prevOutput");
|
|
84
|
-
}
|
|
85
|
-
const amount = prevOutput.amount;
|
|
86
|
-
if (!amount) {
|
|
87
|
-
throw new Error("No amount found in prevOutput");
|
|
88
|
-
}
|
|
89
|
-
return tx.preimageWitnessV1(
|
|
90
|
-
inputIndex,
|
|
91
|
-
new Array(tx.inputsLength).fill(prevScript),
|
|
92
|
-
btc.SigHash.DEFAULT,
|
|
93
|
-
new Array(tx.inputsLength).fill(amount)
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
function getTxId(tx) {
|
|
97
|
-
return bytesToHex(sha256(sha256(tx.unsignedTx)).reverse());
|
|
98
|
-
}
|
|
99
|
-
function getTxIdNoReverse(tx) {
|
|
100
|
-
return bytesToHex(sha256(sha256(tx.unsignedTx)));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/utils/proof.ts
|
|
104
|
-
import { sha256 as sha2562 } from "@scure/btc-signer/utils";
|
|
105
|
-
function proofOfPossessionMessageHashForDepositAddress(userPubkey, operatorPubkey, depositAddress) {
|
|
106
|
-
const encoder = new TextEncoder();
|
|
107
|
-
const depositAddressBytes = encoder.encode(depositAddress);
|
|
108
|
-
const proofMsg = new Uint8Array([
|
|
109
|
-
...userPubkey,
|
|
110
|
-
...operatorPubkey,
|
|
111
|
-
...depositAddressBytes
|
|
112
|
-
]);
|
|
113
|
-
return sha2562(proofMsg);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export {
|
|
117
|
-
computeTaprootKeyNoScript,
|
|
118
|
-
getP2TRScriptFromPublicKey,
|
|
119
|
-
getP2TRAddressFromPublicKey,
|
|
120
|
-
getP2TRAddressFromPkScript,
|
|
121
|
-
getTxFromRawTxHex,
|
|
122
|
-
getTxFromRawTxBytes,
|
|
123
|
-
getSigHashFromTx,
|
|
124
|
-
getTxId,
|
|
125
|
-
getTxIdNoReverse,
|
|
126
|
-
proofOfPossessionMessageHashForDepositAddress
|
|
127
|
-
};
|