@buildonspark/spark-sdk 0.1.44 → 0.1.46
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 +17 -0
- package/dist/{RequestLightningSendInput-BxbCtwpV.d.cts → RequestLightningSendInput-2cSh_In4.d.cts} +1 -1
- package/dist/{RequestLightningSendInput-RGel43ks.d.ts → RequestLightningSendInput-CN6BNg_g.d.ts} +1 -1
- package/dist/address/index.cjs +2 -2
- package/dist/address/index.d.cts +2 -2
- package/dist/address/index.d.ts +2 -2
- package/dist/address/index.js +2 -2
- package/dist/{chunk-EKFD62HN.js → chunk-4EMV7HHW.js} +2 -1
- package/dist/{chunk-4Q2ZDYYU.js → chunk-BGGEVUJK.js} +1157 -208
- package/dist/{chunk-CIZNCBKE.js → chunk-C2S227QR.js} +648 -45
- package/dist/{chunk-WPTRVD2V.js → chunk-DXR2PXJU.js} +15 -15
- package/dist/{chunk-NBCNYDWJ.js → chunk-HHNQ3ZHC.js} +2 -2
- package/dist/{chunk-DAXGVPVM.js → chunk-HSCLBJEL.js} +2 -2
- package/dist/{chunk-6AFUC5M2.js → chunk-HWJWKEIU.js} +8 -2
- package/dist/{chunk-A2ZLMH6I.js → chunk-JB64OQES.js} +259 -327
- package/dist/{chunk-KEKGSH7B.js → chunk-KMUMFYFX.js} +3 -3
- package/dist/chunk-LHRD2WT6.js +2374 -0
- package/dist/{chunk-HTMXTJRK.js → chunk-N5VZVCGJ.js} +4 -4
- package/dist/{chunk-SQKXGAIR.js → chunk-NTFKFRQ2.js} +1 -1
- package/dist/{chunk-K4BJARWM.js → chunk-OBFKIEMP.js} +1 -1
- package/dist/{chunk-UBT6EDVJ.js → chunk-OFCJFZ4I.js} +1 -1
- package/dist/{chunk-XX4RRWOX.js → chunk-UXDODSDT.js} +8 -10
- package/dist/graphql/objects/index.d.cts +5 -4
- package/dist/graphql/objects/index.d.ts +5 -4
- package/dist/index-CKL5DodV.d.cts +214 -0
- package/dist/index-COm59SPw.d.ts +214 -0
- package/dist/index.cjs +4026 -1315
- package/dist/index.d.cts +764 -19
- package/dist/index.d.ts +764 -19
- package/dist/index.js +23 -27
- package/dist/index.node.cjs +4026 -1319
- package/dist/index.node.d.cts +10 -8
- package/dist/index.node.d.ts +10 -8
- package/dist/index.node.js +23 -31
- package/dist/native/index.cjs +4027 -1316
- package/dist/native/index.d.cts +281 -85
- package/dist/native/index.d.ts +281 -85
- package/dist/native/index.js +4018 -1307
- package/dist/{network-CfxLnaot.d.cts → network-Css46DAz.d.cts} +1 -1
- package/dist/{network-CroCOQ0B.d.ts → network-hynb7iTZ.d.ts} +1 -1
- package/dist/proto/lrc20.cjs +222 -19
- package/dist/proto/lrc20.d.cts +1 -1
- package/dist/proto/lrc20.d.ts +1 -1
- package/dist/proto/lrc20.js +2 -2
- package/dist/proto/spark.cjs +1154 -205
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +3 -1
- package/dist/proto/spark_token.cjs +1377 -58
- package/dist/proto/spark_token.d.cts +153 -15
- package/dist/proto/spark_token.d.ts +153 -15
- package/dist/proto/spark_token.js +40 -4
- package/dist/{sdk-types-CTbTdDbE.d.ts → sdk-types-CKBsylfW.d.ts} +1 -1
- package/dist/{sdk-types-BeCBoozO.d.cts → sdk-types-Ct8xmN7l.d.cts} +1 -1
- package/dist/services/config.cjs +2 -2
- package/dist/services/config.d.cts +5 -4
- package/dist/services/config.d.ts +5 -4
- package/dist/services/config.js +6 -6
- package/dist/services/connection.cjs +2438 -262
- package/dist/services/connection.d.cts +5 -4
- package/dist/services/connection.d.ts +5 -4
- package/dist/services/connection.js +4 -4
- package/dist/services/index.cjs +5937 -3154
- package/dist/services/index.d.cts +7 -6
- package/dist/services/index.d.ts +7 -6
- package/dist/services/index.js +17 -15
- package/dist/services/lrc-connection.cjs +223 -20
- package/dist/services/lrc-connection.d.cts +5 -4
- package/dist/services/lrc-connection.d.ts +5 -4
- package/dist/services/lrc-connection.js +4 -4
- package/dist/services/token-transactions.cjs +840 -236
- package/dist/services/token-transactions.d.cts +25 -7
- package/dist/services/token-transactions.d.ts +25 -7
- package/dist/services/token-transactions.js +5 -4
- package/dist/services/wallet-config.cjs +3 -1
- package/dist/services/wallet-config.d.cts +7 -5
- package/dist/services/wallet-config.d.ts +7 -5
- package/dist/services/wallet-config.js +3 -1
- package/dist/signer/signer.cjs +1 -1
- package/dist/signer/signer.d.cts +3 -2
- package/dist/signer/signer.d.ts +3 -2
- package/dist/signer/signer.js +2 -2
- package/dist/{signer-D7vfYik9.d.ts → signer-BP6F__oR.d.cts} +2 -6
- package/dist/{signer-DaY8c60s.d.cts → signer-BVZJXcq7.d.ts} +2 -6
- package/dist/{spark-C4ZrsgjC.d.cts → spark-DbzGfse6.d.cts} +93 -15
- package/dist/{spark-C4ZrsgjC.d.ts → spark-DbzGfse6.d.ts} +93 -15
- package/dist/spark_bindings/native/index.cjs +183 -0
- package/dist/spark_bindings/native/index.d.cts +14 -0
- package/dist/spark_bindings/native/index.d.ts +14 -0
- package/dist/spark_bindings/native/index.js +141 -0
- package/dist/spark_bindings/wasm/index.cjs +1093 -0
- package/dist/spark_bindings/wasm/index.d.cts +47 -0
- package/dist/spark_bindings/wasm/index.d.ts +47 -0
- package/dist/{chunk-K4C4W5FC.js → spark_bindings/wasm/index.js} +7 -6
- package/dist/types/index.cjs +1156 -208
- package/dist/types/index.d.cts +5 -4
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.js +2 -2
- package/dist/types-C-Rp0Oo7.d.cts +46 -0
- package/dist/types-C-Rp0Oo7.d.ts +46 -0
- package/dist/utils/index.cjs +65 -13
- package/dist/utils/index.d.cts +14 -134
- package/dist/utils/index.d.ts +14 -134
- package/dist/utils/index.js +13 -13
- package/package.json +22 -2
- package/src/index.node.ts +0 -1
- package/src/index.ts +0 -1
- package/src/native/index.ts +1 -2
- package/src/proto/common.ts +5 -5
- package/src/proto/google/protobuf/descriptor.ts +34 -34
- package/src/proto/google/protobuf/duration.ts +2 -2
- package/src/proto/google/protobuf/empty.ts +2 -2
- package/src/proto/google/protobuf/timestamp.ts +2 -2
- package/src/proto/mock.ts +4 -4
- package/src/proto/spark.ts +1452 -185
- package/src/proto/spark_authn.ts +7 -7
- package/src/proto/spark_token.ts +1668 -105
- package/src/proto/validate/validate.ts +24 -24
- package/src/services/bolt11-spark.ts +62 -187
- package/src/services/coop-exit.ts +3 -0
- package/src/services/lrc20.ts +1 -1
- package/src/services/token-transactions.ts +197 -9
- package/src/services/transfer.ts +22 -0
- package/src/services/tree-creation.ts +13 -0
- package/src/services/wallet-config.ts +2 -2
- package/src/spark-wallet/spark-wallet.node.ts +0 -4
- package/src/spark-wallet/spark-wallet.ts +76 -108
- package/src/spark-wallet/types.ts +39 -3
- package/src/tests/bolt11-spark.test.ts +7 -15
- package/src/tests/integration/ssp/coop-exit.test.ts +7 -7
- package/src/tests/integration/swap.test.ts +453 -433
- package/src/tests/integration/transfer.test.ts +261 -248
- package/src/tests/token-identifier.test.ts +54 -0
- package/src/tests/tokens.test.ts +218 -23
- package/src/utils/token-hashing.ts +320 -44
- package/src/utils/token-identifier.ts +88 -0
- package/src/utils/token-transaction-validation.ts +350 -5
- package/src/utils/token-transactions.ts +12 -8
- package/src/utils/transaction.ts +0 -6
- package/dist/chunk-B3AMIGJG.js +0 -1073
- package/dist/index-CZmDdSts.d.cts +0 -829
- package/dist/index-ClIRO_3y.d.ts +0 -829
- package/dist/wasm-7OWFHDMS.js +0 -21
package/src/tests/tokens.test.ts
CHANGED
|
@@ -7,9 +7,53 @@ import { Network, OutputWithPreviousTransactionData } from "../proto/spark.js";
|
|
|
7
7
|
import { TokenTransactionService } from "../services/token-transactions.js";
|
|
8
8
|
import { WalletConfigService } from "../services/config.js";
|
|
9
9
|
import { ConnectionManager } from "../services/connection.js";
|
|
10
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
11
|
+
|
|
12
|
+
// Test constants for consistent test data across all hash tests
|
|
13
|
+
const TEST_TOKEN_PUBLIC_KEY = new Uint8Array([
|
|
14
|
+
242, 155, 208, 90, 72, 211, 120, 244, 69, 99, 28, 101, 149, 222, 123, 50, 252,
|
|
15
|
+
63, 99, 54, 137, 226, 7, 224, 163, 122, 93, 248, 42, 159, 173, 45,
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
const TEST_IDENTITY_PUB_KEY = new Uint8Array([
|
|
19
|
+
25, 155, 208, 90, 72, 211, 120, 244, 69, 99, 28, 101, 149, 222, 123, 50, 252,
|
|
20
|
+
63, 99, 54, 137, 226, 7, 224, 163, 122, 93, 248, 42, 159, 173, 46,
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const TEST_REVOCATION_PUB_KEY = new Uint8Array([
|
|
24
|
+
100, 155, 208, 90, 72, 211, 120, 244, 69, 99, 28, 101, 149, 222, 123, 50, 252,
|
|
25
|
+
63, 99, 54, 137, 226, 7, 224, 163, 122, 93, 248, 42, 159, 173, 46,
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
const TEST_OPERATOR_PUB_KEY = new Uint8Array([
|
|
29
|
+
200, 155, 208, 90, 72, 211, 120, 244, 69, 99, 28, 101, 149, 222, 123, 50, 252,
|
|
30
|
+
63, 99, 54, 137, 226, 7, 224, 163, 122, 93, 248, 42, 159, 173, 46,
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const TEST_LEAF_ID = "db1a4e48-0fc5-4f6c-8a80-d9d6c561a436";
|
|
34
|
+
const TEST_BOND_SATS = 10000;
|
|
35
|
+
const TEST_LOCKTIME = 100;
|
|
36
|
+
const TEST_TOKEN_AMOUNT: bigint = 1000n;
|
|
37
|
+
const TEST_MAX_SUPPLY = new Uint8Array([
|
|
38
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 232,
|
|
39
|
+
]); // 1000 in BE format
|
|
40
|
+
const TEST_TOKEN_NAME = "TestToken";
|
|
41
|
+
const TEST_TOKEN_TICKER = "TEST";
|
|
42
|
+
const TEST_DECIMALS = 8;
|
|
43
|
+
const TEST_ISSUER_TIMESTAMP = 100;
|
|
44
|
+
const TEST_CLIENT_TIMESTAMP = 100;
|
|
45
|
+
const TEST_EXPIRY_TIME = 0;
|
|
46
|
+
const TEST_WITHDRAW_BOND_SATS = 10000;
|
|
47
|
+
const TEST_WITHDRAW_RELATIVE_BLOCK_LOCKTIME = 100;
|
|
48
|
+
const TEST_TOKEN_IDENTIFIER = new Uint8Array(32).fill(0x07);
|
|
49
|
+
|
|
50
|
+
// Precompute previous transaction hash to match Go test data
|
|
51
|
+
const PREV_TX_HASH = Uint8Array.from(
|
|
52
|
+
sha256(new TextEncoder().encode("previous transaction")),
|
|
53
|
+
);
|
|
10
54
|
|
|
11
55
|
describe("hash token transaction", () => {
|
|
12
|
-
it("should produce the exact same hash for v0", () => {
|
|
56
|
+
it("should produce the exact same hash for mint v0 (legacy vector)", () => {
|
|
13
57
|
const tokenAmount: bigint = 1000n;
|
|
14
58
|
|
|
15
59
|
const tokenPublicKey = new Uint8Array([
|
|
@@ -54,50 +98,201 @@ describe("hash token transaction", () => {
|
|
|
54
98
|
]);
|
|
55
99
|
});
|
|
56
100
|
|
|
57
|
-
it("should produce the exact same hash for
|
|
58
|
-
const
|
|
101
|
+
it("should produce the exact same hash for mint v0", () => {
|
|
102
|
+
const tokenTransaction = {
|
|
103
|
+
tokenInputs: {
|
|
104
|
+
$case: "mintInput" as const,
|
|
105
|
+
mintInput: {
|
|
106
|
+
issuerPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
107
|
+
issuerProvidedTimestamp: TEST_ISSUER_TIMESTAMP,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
tokenOutputs: [
|
|
111
|
+
{
|
|
112
|
+
id: TEST_LEAF_ID,
|
|
113
|
+
ownerPublicKey: TEST_IDENTITY_PUB_KEY,
|
|
114
|
+
tokenPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
115
|
+
tokenAmount: numberToBytesBE(TEST_TOKEN_AMOUNT, 16),
|
|
116
|
+
revocationCommitment: TEST_REVOCATION_PUB_KEY,
|
|
117
|
+
withdrawBondSats: TEST_WITHDRAW_BOND_SATS,
|
|
118
|
+
withdrawRelativeBlockLocktime: TEST_WITHDRAW_RELATIVE_BLOCK_LOCKTIME,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
sparkOperatorIdentityPublicKeys: [TEST_OPERATOR_PUB_KEY],
|
|
122
|
+
network: Network.REGTEST,
|
|
123
|
+
};
|
|
59
124
|
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
125
|
+
const hash = hashTokenTransactionV0(tokenTransaction, false);
|
|
126
|
+
|
|
127
|
+
expect(Array.from(hash)).toEqual([
|
|
128
|
+
56, 47, 132, 171, 2, 236, 10, 72, 214, 89, 28, 46, 171, 39, 221, 113, 162,
|
|
129
|
+
74, 170, 64, 160, 91, 11, 201, 45, 35, 67, 179, 199, 130, 116, 69,
|
|
63
130
|
]);
|
|
131
|
+
});
|
|
64
132
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
133
|
+
it("should produce the exact same hash for create v0", () => {
|
|
134
|
+
const tokenTransaction = {
|
|
135
|
+
tokenInputs: {
|
|
136
|
+
$case: "createInput" as const,
|
|
137
|
+
createInput: {
|
|
138
|
+
issuerPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
139
|
+
tokenName: TEST_TOKEN_NAME,
|
|
140
|
+
tokenTicker: TEST_TOKEN_TICKER,
|
|
141
|
+
decimals: TEST_DECIMALS,
|
|
142
|
+
maxSupply: TEST_MAX_SUPPLY,
|
|
143
|
+
isFreezable: false,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
tokenOutputs: [],
|
|
147
|
+
sparkOperatorIdentityPublicKeys: [TEST_OPERATOR_PUB_KEY],
|
|
148
|
+
network: Network.REGTEST,
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const hash = hashTokenTransactionV0(tokenTransaction, false);
|
|
152
|
+
|
|
153
|
+
expect(Array.from(hash)).toEqual([
|
|
154
|
+
35, 118, 177, 53, 49, 47, 174, 59, 123, 2, 212, 38, 217, 133, 124, 232,
|
|
155
|
+
93, 185, 248, 87, 146, 123, 157, 10, 6, 111, 79, 183, 185, 175, 45, 224,
|
|
68
156
|
]);
|
|
157
|
+
});
|
|
69
158
|
|
|
159
|
+
it("should produce the exact same hash for transfer v0", () => {
|
|
160
|
+
const tokenTransaction = {
|
|
161
|
+
tokenInputs: {
|
|
162
|
+
$case: "transferInput" as const,
|
|
163
|
+
transferInput: {
|
|
164
|
+
outputsToSpend: [
|
|
165
|
+
{
|
|
166
|
+
prevTokenTransactionHash: PREV_TX_HASH,
|
|
167
|
+
prevTokenTransactionVout: 0,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
tokenOutputs: [
|
|
173
|
+
{
|
|
174
|
+
id: TEST_LEAF_ID,
|
|
175
|
+
ownerPublicKey: TEST_IDENTITY_PUB_KEY,
|
|
176
|
+
tokenPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
177
|
+
tokenAmount: numberToBytesBE(1000n, 16),
|
|
178
|
+
revocationCommitment: TEST_REVOCATION_PUB_KEY,
|
|
179
|
+
withdrawBondSats: TEST_BOND_SATS,
|
|
180
|
+
withdrawRelativeBlockLocktime: TEST_LOCKTIME,
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
sparkOperatorIdentityPublicKeys: [TEST_OPERATOR_PUB_KEY],
|
|
184
|
+
network: Network.REGTEST,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const hash = hashTokenTransactionV0(tokenTransaction, false);
|
|
188
|
+
|
|
189
|
+
expect(Array.from(hash)).toEqual([
|
|
190
|
+
68, 88, 168, 87, 42, 251, 11, 182, 69, 202, 46, 202, 39, 234, 196, 201,
|
|
191
|
+
24, 52, 213, 56, 151, 103, 99, 110, 211, 237, 148, 78, 216, 146, 143, 131,
|
|
192
|
+
]);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("should produce the exact same hash for mint v1", () => {
|
|
70
196
|
const tokenTransaction = {
|
|
71
197
|
version: 1,
|
|
72
198
|
tokenInputs: {
|
|
73
199
|
$case: "mintInput" as const,
|
|
74
200
|
mintInput: {
|
|
75
|
-
issuerPublicKey:
|
|
76
|
-
|
|
201
|
+
issuerPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
202
|
+
tokenIdentifier: TEST_TOKEN_IDENTIFIER,
|
|
77
203
|
},
|
|
78
204
|
},
|
|
79
205
|
tokenOutputs: [
|
|
80
206
|
{
|
|
81
|
-
id:
|
|
82
|
-
ownerPublicKey:
|
|
83
|
-
withdrawBondSats:
|
|
84
|
-
withdrawRelativeBlockLocktime:
|
|
85
|
-
tokenPublicKey:
|
|
86
|
-
tokenAmount: numberToBytesBE(
|
|
87
|
-
revocationCommitment:
|
|
207
|
+
id: TEST_LEAF_ID,
|
|
208
|
+
ownerPublicKey: TEST_IDENTITY_PUB_KEY,
|
|
209
|
+
withdrawBondSats: TEST_WITHDRAW_BOND_SATS,
|
|
210
|
+
withdrawRelativeBlockLocktime: TEST_WITHDRAW_RELATIVE_BLOCK_LOCKTIME,
|
|
211
|
+
tokenPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
212
|
+
tokenAmount: numberToBytesBE(TEST_TOKEN_AMOUNT, 16),
|
|
213
|
+
revocationCommitment: TEST_REVOCATION_PUB_KEY,
|
|
88
214
|
},
|
|
89
215
|
],
|
|
90
|
-
sparkOperatorIdentityPublicKeys: [],
|
|
216
|
+
sparkOperatorIdentityPublicKeys: [TEST_OPERATOR_PUB_KEY],
|
|
217
|
+
network: Network.REGTEST,
|
|
218
|
+
expiryTime: new Date(TEST_EXPIRY_TIME),
|
|
219
|
+
clientCreatedTimestamp: new Date(TEST_CLIENT_TIMESTAMP),
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const hash = hashTokenTransactionV1(tokenTransaction, false);
|
|
223
|
+
|
|
224
|
+
expect(Array.from(hash)).toEqual([
|
|
225
|
+
9, 162, 16, 177, 20, 91, 93, 148, 158, 249, 6, 42, 59, 136, 145, 184, 202,
|
|
226
|
+
35, 243, 228, 14, 231, 132, 201, 66, 137, 201, 76, 97, 186, 149, 172,
|
|
227
|
+
]);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("should produce the exact same hash for create v1", () => {
|
|
231
|
+
const tokenTransaction = {
|
|
232
|
+
version: 1,
|
|
233
|
+
tokenInputs: {
|
|
234
|
+
$case: "createInput" as const,
|
|
235
|
+
createInput: {
|
|
236
|
+
issuerPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
237
|
+
tokenName: TEST_TOKEN_NAME,
|
|
238
|
+
tokenTicker: TEST_TOKEN_TICKER,
|
|
239
|
+
decimals: TEST_DECIMALS,
|
|
240
|
+
maxSupply: TEST_MAX_SUPPLY,
|
|
241
|
+
isFreezable: false,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
tokenOutputs: [],
|
|
245
|
+
sparkOperatorIdentityPublicKeys: [TEST_OPERATOR_PUB_KEY],
|
|
246
|
+
network: Network.REGTEST,
|
|
247
|
+
expiryTime: new Date(TEST_EXPIRY_TIME),
|
|
248
|
+
clientCreatedTimestamp: new Date(TEST_CLIENT_TIMESTAMP),
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const hash = hashTokenTransactionV1(tokenTransaction, false);
|
|
252
|
+
|
|
253
|
+
expect(Array.from(hash)).toEqual([
|
|
254
|
+
201, 249, 88, 215, 6, 7, 221, 209, 103, 153, 36, 41, 19, 60, 80, 144, 153,
|
|
255
|
+
159, 185, 61, 20, 117, 87, 196, 102, 151, 76, 4, 191, 121, 221, 182,
|
|
256
|
+
]);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("should produce the exact same hash for transfer v1", () => {
|
|
260
|
+
const tokenTransaction = {
|
|
261
|
+
version: 1,
|
|
262
|
+
tokenInputs: {
|
|
263
|
+
$case: "transferInput" as const,
|
|
264
|
+
transferInput: {
|
|
265
|
+
outputsToSpend: [
|
|
266
|
+
{
|
|
267
|
+
prevTokenTransactionHash: PREV_TX_HASH,
|
|
268
|
+
prevTokenTransactionVout: 0,
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
tokenOutputs: [
|
|
274
|
+
{
|
|
275
|
+
id: TEST_LEAF_ID,
|
|
276
|
+
ownerPublicKey: TEST_IDENTITY_PUB_KEY,
|
|
277
|
+
tokenPublicKey: TEST_TOKEN_PUBLIC_KEY,
|
|
278
|
+
tokenAmount: numberToBytesBE(TEST_TOKEN_AMOUNT, 16),
|
|
279
|
+
revocationCommitment: TEST_REVOCATION_PUB_KEY,
|
|
280
|
+
withdrawBondSats: TEST_BOND_SATS,
|
|
281
|
+
withdrawRelativeBlockLocktime: TEST_LOCKTIME,
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
sparkOperatorIdentityPublicKeys: [TEST_OPERATOR_PUB_KEY],
|
|
91
285
|
network: Network.REGTEST,
|
|
92
|
-
expiryTime: new Date(
|
|
93
|
-
clientCreatedTimestamp: new Date(
|
|
286
|
+
expiryTime: new Date(TEST_EXPIRY_TIME),
|
|
287
|
+
clientCreatedTimestamp: new Date(TEST_CLIENT_TIMESTAMP),
|
|
94
288
|
};
|
|
95
289
|
|
|
96
290
|
const hash = hashTokenTransactionV1(tokenTransaction, false);
|
|
97
291
|
|
|
98
292
|
expect(Array.from(hash)).toEqual([
|
|
99
|
-
|
|
100
|
-
|
|
293
|
+
86, 89, 220, 198, 197, 223, 236, 142, 73, 125, 112, 186, 29, 1, 26, 203,
|
|
294
|
+
126, 154, 255, 176, 237, 210, 171, 98, 211, 130, 138, 113, 128, 129, 227,
|
|
295
|
+
35,
|
|
101
296
|
]);
|
|
102
297
|
});
|
|
103
298
|
});
|