@bitgo/wasm-utxo 0.0.1 → 1.0.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.
Files changed (47) hide show
  1. package/README.md +33 -0
  2. package/dist/browser/js/address.d.ts +8 -0
  3. package/dist/browser/js/address.js +7 -0
  4. package/dist/browser/js/ast/formatNode.d.ts +88 -0
  5. package/dist/browser/js/ast/formatNode.js +36 -0
  6. package/dist/browser/js/ast/fromWasmNode.d.ts +4 -0
  7. package/dist/browser/js/ast/fromWasmNode.js +120 -0
  8. package/dist/browser/js/ast/index.d.ts +2 -0
  9. package/dist/browser/js/ast/index.js +2 -0
  10. package/dist/browser/js/coinName.d.ts +1 -0
  11. package/dist/browser/js/coinName.js +1 -0
  12. package/dist/browser/js/fixedScriptWallet.d.ts +86 -0
  13. package/dist/browser/js/fixedScriptWallet.js +61 -0
  14. package/dist/browser/js/index.d.ts +37 -0
  15. package/dist/browser/js/index.js +11 -0
  16. package/dist/browser/js/triple.d.ts +1 -0
  17. package/dist/browser/js/triple.js +1 -0
  18. package/dist/browser/js/utxolibCompat.d.ts +32 -0
  19. package/dist/browser/js/utxolibCompat.js +7 -0
  20. package/dist/browser/js/wasm/wasm_utxo.d.ts +94 -0
  21. package/dist/browser/js/wasm/wasm_utxo.js +4 -0
  22. package/dist/browser/js/wasm/wasm_utxo_bg.js +1274 -0
  23. package/dist/browser/js/wasm/wasm_utxo_bg.wasm +0 -0
  24. package/dist/browser/js/wasm/wasm_utxo_bg.wasm.d.ts +53 -0
  25. package/dist/node/js/address.d.ts +8 -0
  26. package/dist/node/js/address.js +11 -0
  27. package/dist/node/js/ast/formatNode.d.ts +88 -0
  28. package/dist/node/js/ast/formatNode.js +39 -0
  29. package/dist/node/js/ast/fromWasmNode.d.ts +4 -0
  30. package/dist/node/js/ast/fromWasmNode.js +124 -0
  31. package/dist/node/js/ast/index.d.ts +2 -0
  32. package/dist/node/js/ast/index.js +18 -0
  33. package/dist/node/js/coinName.d.ts +1 -0
  34. package/dist/node/js/coinName.js +2 -0
  35. package/dist/node/js/fixedScriptWallet.d.ts +86 -0
  36. package/dist/node/js/fixedScriptWallet.js +68 -0
  37. package/dist/node/js/index.d.ts +37 -0
  38. package/dist/node/js/index.js +50 -0
  39. package/dist/node/js/triple.d.ts +1 -0
  40. package/dist/node/js/triple.js +2 -0
  41. package/dist/node/js/utxolibCompat.d.ts +32 -0
  42. package/dist/node/js/utxolibCompat.js +11 -0
  43. package/dist/node/js/wasm/wasm_utxo.d.ts +94 -0
  44. package/dist/node/js/wasm/wasm_utxo.js +1283 -0
  45. package/dist/node/js/wasm/wasm_utxo_bg.wasm +0 -0
  46. package/dist/node/js/wasm/wasm_utxo_bg.wasm.d.ts +53 -0
  47. package/package.json +52 -5
@@ -0,0 +1,1283 @@
1
+
2
+ let imports = {};
3
+ imports['__wbindgen_placeholder__'] = module.exports;
4
+
5
+ let cachedUint8ArrayMemory0 = null;
6
+
7
+ function getUint8ArrayMemory0() {
8
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
9
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
10
+ }
11
+ return cachedUint8ArrayMemory0;
12
+ }
13
+
14
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
15
+
16
+ cachedTextDecoder.decode();
17
+
18
+ function decodeText(ptr, len) {
19
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
20
+ }
21
+
22
+ function getStringFromWasm0(ptr, len) {
23
+ ptr = ptr >>> 0;
24
+ return decodeText(ptr, len);
25
+ }
26
+
27
+ let heap = new Array(128).fill(undefined);
28
+
29
+ heap.push(undefined, null, true, false);
30
+
31
+ let heap_next = heap.length;
32
+
33
+ function addHeapObject(obj) {
34
+ if (heap_next === heap.length) heap.push(heap.length + 1);
35
+ const idx = heap_next;
36
+ heap_next = heap[idx];
37
+
38
+ heap[idx] = obj;
39
+ return idx;
40
+ }
41
+
42
+ function getObject(idx) { return heap[idx]; }
43
+
44
+ function handleError(f, args) {
45
+ try {
46
+ return f.apply(this, args);
47
+ } catch (e) {
48
+ wasm.__wbindgen_export_0(addHeapObject(e));
49
+ }
50
+ }
51
+
52
+ function getArrayU8FromWasm0(ptr, len) {
53
+ ptr = ptr >>> 0;
54
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
55
+ }
56
+
57
+ function isLikeNone(x) {
58
+ return x === undefined || x === null;
59
+ }
60
+
61
+ let cachedDataViewMemory0 = null;
62
+
63
+ function getDataViewMemory0() {
64
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
65
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
66
+ }
67
+ return cachedDataViewMemory0;
68
+ }
69
+
70
+ let WASM_VECTOR_LEN = 0;
71
+
72
+ const cachedTextEncoder = new TextEncoder();
73
+
74
+ if (!('encodeInto' in cachedTextEncoder)) {
75
+ cachedTextEncoder.encodeInto = function (arg, view) {
76
+ const buf = cachedTextEncoder.encode(arg);
77
+ view.set(buf);
78
+ return {
79
+ read: arg.length,
80
+ written: buf.length
81
+ };
82
+ }
83
+ }
84
+
85
+ function passStringToWasm0(arg, malloc, realloc) {
86
+
87
+ if (realloc === undefined) {
88
+ const buf = cachedTextEncoder.encode(arg);
89
+ const ptr = malloc(buf.length, 1) >>> 0;
90
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
91
+ WASM_VECTOR_LEN = buf.length;
92
+ return ptr;
93
+ }
94
+
95
+ let len = arg.length;
96
+ let ptr = malloc(len, 1) >>> 0;
97
+
98
+ const mem = getUint8ArrayMemory0();
99
+
100
+ let offset = 0;
101
+
102
+ for (; offset < len; offset++) {
103
+ const code = arg.charCodeAt(offset);
104
+ if (code > 0x7F) break;
105
+ mem[ptr + offset] = code;
106
+ }
107
+
108
+ if (offset !== len) {
109
+ if (offset !== 0) {
110
+ arg = arg.slice(offset);
111
+ }
112
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
113
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
114
+ const ret = cachedTextEncoder.encodeInto(arg, view);
115
+
116
+ offset += ret.written;
117
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
118
+ }
119
+
120
+ WASM_VECTOR_LEN = offset;
121
+ return ptr;
122
+ }
123
+
124
+ function dropObject(idx) {
125
+ if (idx < 132) return;
126
+ heap[idx] = heap_next;
127
+ heap_next = idx;
128
+ }
129
+
130
+ function takeObject(idx) {
131
+ const ret = getObject(idx);
132
+ dropObject(idx);
133
+ return ret;
134
+ }
135
+
136
+ function passArray8ToWasm0(arg, malloc) {
137
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
138
+ getUint8ArrayMemory0().set(arg, ptr / 1);
139
+ WASM_VECTOR_LEN = arg.length;
140
+ return ptr;
141
+ }
142
+
143
+ function _assertClass(instance, klass) {
144
+ if (!(instance instanceof klass)) {
145
+ throw new Error(`expected instance of ${klass.name}`);
146
+ }
147
+ }
148
+
149
+ const AddressNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
150
+ ? { register: () => {}, unregister: () => {} }
151
+ : new FinalizationRegistry(ptr => wasm.__wbg_addressnamespace_free(ptr >>> 0, 1));
152
+
153
+ class AddressNamespace {
154
+
155
+ __destroy_into_raw() {
156
+ const ptr = this.__wbg_ptr;
157
+ this.__wbg_ptr = 0;
158
+ AddressNamespaceFinalization.unregister(this);
159
+ return ptr;
160
+ }
161
+
162
+ free() {
163
+ const ptr = this.__destroy_into_raw();
164
+ wasm.__wbg_addressnamespace_free(ptr, 0);
165
+ }
166
+ /**
167
+ * @param {string} address
168
+ * @param {string} coin
169
+ * @returns {Uint8Array}
170
+ */
171
+ static to_output_script_with_coin(address, coin) {
172
+ try {
173
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
174
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
175
+ const len0 = WASM_VECTOR_LEN;
176
+ const ptr1 = passStringToWasm0(coin, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
177
+ const len1 = WASM_VECTOR_LEN;
178
+ wasm.addressnamespace_to_output_script_with_coin(retptr, ptr0, len0, ptr1, len1);
179
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
180
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
181
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
182
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
183
+ if (r3) {
184
+ throw takeObject(r2);
185
+ }
186
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
187
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
188
+ return v3;
189
+ } finally {
190
+ wasm.__wbindgen_add_to_stack_pointer(16);
191
+ }
192
+ }
193
+ /**
194
+ * @param {Uint8Array} script
195
+ * @param {string} coin
196
+ * @param {string | null} [format]
197
+ * @returns {string}
198
+ */
199
+ static from_output_script_with_coin(script, coin, format) {
200
+ let deferred5_0;
201
+ let deferred5_1;
202
+ try {
203
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
204
+ const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
205
+ const len0 = WASM_VECTOR_LEN;
206
+ const ptr1 = passStringToWasm0(coin, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
207
+ const len1 = WASM_VECTOR_LEN;
208
+ var ptr2 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
209
+ var len2 = WASM_VECTOR_LEN;
210
+ wasm.addressnamespace_from_output_script_with_coin(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
211
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
212
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
213
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
214
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
215
+ var ptr4 = r0;
216
+ var len4 = r1;
217
+ if (r3) {
218
+ ptr4 = 0; len4 = 0;
219
+ throw takeObject(r2);
220
+ }
221
+ deferred5_0 = ptr4;
222
+ deferred5_1 = len4;
223
+ return getStringFromWasm0(ptr4, len4);
224
+ } finally {
225
+ wasm.__wbindgen_add_to_stack_pointer(16);
226
+ wasm.__wbindgen_export_3(deferred5_0, deferred5_1, 1);
227
+ }
228
+ }
229
+ }
230
+ if (Symbol.dispose) AddressNamespace.prototype[Symbol.dispose] = AddressNamespace.prototype.free;
231
+
232
+ exports.AddressNamespace = AddressNamespace;
233
+
234
+ const BitGoPsbtFinalization = (typeof FinalizationRegistry === 'undefined')
235
+ ? { register: () => {}, unregister: () => {} }
236
+ : new FinalizationRegistry(ptr => wasm.__wbg_bitgopsbt_free(ptr >>> 0, 1));
237
+
238
+ class BitGoPsbt {
239
+
240
+ static __wrap(ptr) {
241
+ ptr = ptr >>> 0;
242
+ const obj = Object.create(BitGoPsbt.prototype);
243
+ obj.__wbg_ptr = ptr;
244
+ BitGoPsbtFinalization.register(obj, obj.__wbg_ptr, obj);
245
+ return obj;
246
+ }
247
+
248
+ __destroy_into_raw() {
249
+ const ptr = this.__wbg_ptr;
250
+ this.__wbg_ptr = 0;
251
+ BitGoPsbtFinalization.unregister(this);
252
+ return ptr;
253
+ }
254
+
255
+ free() {
256
+ const ptr = this.__destroy_into_raw();
257
+ wasm.__wbg_bitgopsbt_free(ptr, 0);
258
+ }
259
+ /**
260
+ * Deserialize a PSBT from bytes with network-specific logic
261
+ * @param {Uint8Array} bytes
262
+ * @param {string} network
263
+ * @returns {BitGoPsbt}
264
+ */
265
+ static from_bytes(bytes, network) {
266
+ try {
267
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
268
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export_1);
269
+ const len0 = WASM_VECTOR_LEN;
270
+ const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
271
+ const len1 = WASM_VECTOR_LEN;
272
+ wasm.bitgopsbt_from_bytes(retptr, ptr0, len0, ptr1, len1);
273
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
274
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
275
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
276
+ if (r2) {
277
+ throw takeObject(r1);
278
+ }
279
+ return BitGoPsbt.__wrap(r0);
280
+ } finally {
281
+ wasm.__wbindgen_add_to_stack_pointer(16);
282
+ }
283
+ }
284
+ /**
285
+ * Parse outputs with wallet keys to identify which outputs belong to a wallet
286
+ *
287
+ * Note: This method does NOT validate wallet inputs. It only parses outputs.
288
+ * @param {any} wallet_keys
289
+ * @returns {any}
290
+ */
291
+ parse_outputs_with_wallet_keys(wallet_keys) {
292
+ try {
293
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
294
+ wasm.bitgopsbt_parse_outputs_with_wallet_keys(retptr, this.__wbg_ptr, addHeapObject(wallet_keys));
295
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
296
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
297
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
298
+ if (r2) {
299
+ throw takeObject(r1);
300
+ }
301
+ return takeObject(r0);
302
+ } finally {
303
+ wasm.__wbindgen_add_to_stack_pointer(16);
304
+ }
305
+ }
306
+ /**
307
+ * Parse transaction with wallet keys to identify wallet inputs/outputs
308
+ * @param {any} wallet_keys
309
+ * @param {any} replay_protection
310
+ * @returns {any}
311
+ */
312
+ parse_transaction_with_wallet_keys(wallet_keys, replay_protection) {
313
+ try {
314
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
315
+ wasm.bitgopsbt_parse_transaction_with_wallet_keys(retptr, this.__wbg_ptr, addHeapObject(wallet_keys), addHeapObject(replay_protection));
316
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
317
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
318
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
319
+ if (r2) {
320
+ throw takeObject(r1);
321
+ }
322
+ return takeObject(r0);
323
+ } finally {
324
+ wasm.__wbindgen_add_to_stack_pointer(16);
325
+ }
326
+ }
327
+ }
328
+ if (Symbol.dispose) BitGoPsbt.prototype[Symbol.dispose] = BitGoPsbt.prototype.free;
329
+
330
+ exports.BitGoPsbt = BitGoPsbt;
331
+
332
+ const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
333
+ ? { register: () => {}, unregister: () => {} }
334
+ : new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
335
+
336
+ class FixedScriptWalletNamespace {
337
+
338
+ __destroy_into_raw() {
339
+ const ptr = this.__wbg_ptr;
340
+ this.__wbg_ptr = 0;
341
+ FixedScriptWalletNamespaceFinalization.unregister(this);
342
+ return ptr;
343
+ }
344
+
345
+ free() {
346
+ const ptr = this.__destroy_into_raw();
347
+ wasm.__wbg_fixedscriptwalletnamespace_free(ptr, 0);
348
+ }
349
+ /**
350
+ * @param {any} keys
351
+ * @param {number} chain
352
+ * @param {number} index
353
+ * @param {any} network
354
+ * @returns {Uint8Array}
355
+ */
356
+ static output_script(keys, chain, index, network) {
357
+ try {
358
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
359
+ wasm.fixedscriptwalletnamespace_output_script(retptr, addHeapObject(keys), chain, index, addHeapObject(network));
360
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
361
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
362
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
363
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
364
+ if (r3) {
365
+ throw takeObject(r2);
366
+ }
367
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
368
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
369
+ return v1;
370
+ } finally {
371
+ wasm.__wbindgen_add_to_stack_pointer(16);
372
+ }
373
+ }
374
+ /**
375
+ * @param {any} keys
376
+ * @param {number} chain
377
+ * @param {number} index
378
+ * @param {any} network
379
+ * @param {string | null} [address_format]
380
+ * @returns {string}
381
+ */
382
+ static address(keys, chain, index, network, address_format) {
383
+ let deferred3_0;
384
+ let deferred3_1;
385
+ try {
386
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
387
+ var ptr0 = isLikeNone(address_format) ? 0 : passStringToWasm0(address_format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
388
+ var len0 = WASM_VECTOR_LEN;
389
+ wasm.fixedscriptwalletnamespace_address(retptr, addHeapObject(keys), chain, index, addHeapObject(network), ptr0, len0);
390
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
391
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
392
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
393
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
394
+ var ptr2 = r0;
395
+ var len2 = r1;
396
+ if (r3) {
397
+ ptr2 = 0; len2 = 0;
398
+ throw takeObject(r2);
399
+ }
400
+ deferred3_0 = ptr2;
401
+ deferred3_1 = len2;
402
+ return getStringFromWasm0(ptr2, len2);
403
+ } finally {
404
+ wasm.__wbindgen_add_to_stack_pointer(16);
405
+ wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
406
+ }
407
+ }
408
+ }
409
+ if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
410
+
411
+ exports.FixedScriptWalletNamespace = FixedScriptWalletNamespace;
412
+
413
+ const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
414
+ ? { register: () => {}, unregister: () => {} }
415
+ : new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
416
+
417
+ class UtxolibCompatNamespace {
418
+
419
+ __destroy_into_raw() {
420
+ const ptr = this.__wbg_ptr;
421
+ this.__wbg_ptr = 0;
422
+ UtxolibCompatNamespaceFinalization.unregister(this);
423
+ return ptr;
424
+ }
425
+
426
+ free() {
427
+ const ptr = this.__destroy_into_raw();
428
+ wasm.__wbg_utxolibcompatnamespace_free(ptr, 0);
429
+ }
430
+ /**
431
+ * Convert address string to output script
432
+ *
433
+ * # Arguments
434
+ * * `address` - The address string
435
+ * * `network` - The UtxolibNetwork object from JavaScript
436
+ * * `format` - Optional address format (currently unused for decoding as all formats are accepted)
437
+ * @param {string} address
438
+ * @param {any} network
439
+ * @param {string | null} [format]
440
+ * @returns {Uint8Array}
441
+ */
442
+ static to_output_script(address, network, format) {
443
+ try {
444
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
445
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
446
+ const len0 = WASM_VECTOR_LEN;
447
+ var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
448
+ var len1 = WASM_VECTOR_LEN;
449
+ wasm.utxolibcompatnamespace_to_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
450
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
451
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
452
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
453
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
454
+ if (r3) {
455
+ throw takeObject(r2);
456
+ }
457
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
458
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
459
+ return v3;
460
+ } finally {
461
+ wasm.__wbindgen_add_to_stack_pointer(16);
462
+ }
463
+ }
464
+ /**
465
+ * Convert output script to address string
466
+ *
467
+ * # Arguments
468
+ * * `script` - The output script as a byte array
469
+ * * `network` - The UtxolibNetwork object from JavaScript
470
+ * * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
471
+ * @param {Uint8Array} script
472
+ * @param {any} network
473
+ * @param {string | null} [format]
474
+ * @returns {string}
475
+ */
476
+ static from_output_script(script, network, format) {
477
+ let deferred4_0;
478
+ let deferred4_1;
479
+ try {
480
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
481
+ const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
482
+ const len0 = WASM_VECTOR_LEN;
483
+ var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
484
+ var len1 = WASM_VECTOR_LEN;
485
+ wasm.utxolibcompatnamespace_from_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
486
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
487
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
488
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
489
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
490
+ var ptr3 = r0;
491
+ var len3 = r1;
492
+ if (r3) {
493
+ ptr3 = 0; len3 = 0;
494
+ throw takeObject(r2);
495
+ }
496
+ deferred4_0 = ptr3;
497
+ deferred4_1 = len3;
498
+ return getStringFromWasm0(ptr3, len3);
499
+ } finally {
500
+ wasm.__wbindgen_add_to_stack_pointer(16);
501
+ wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
502
+ }
503
+ }
504
+ }
505
+ if (Symbol.dispose) UtxolibCompatNamespace.prototype[Symbol.dispose] = UtxolibCompatNamespace.prototype.free;
506
+
507
+ exports.UtxolibCompatNamespace = UtxolibCompatNamespace;
508
+
509
+ const WrapDescriptorFinalization = (typeof FinalizationRegistry === 'undefined')
510
+ ? { register: () => {}, unregister: () => {} }
511
+ : new FinalizationRegistry(ptr => wasm.__wbg_wrapdescriptor_free(ptr >>> 0, 1));
512
+
513
+ class WrapDescriptor {
514
+
515
+ static __wrap(ptr) {
516
+ ptr = ptr >>> 0;
517
+ const obj = Object.create(WrapDescriptor.prototype);
518
+ obj.__wbg_ptr = ptr;
519
+ WrapDescriptorFinalization.register(obj, obj.__wbg_ptr, obj);
520
+ return obj;
521
+ }
522
+
523
+ __destroy_into_raw() {
524
+ const ptr = this.__wbg_ptr;
525
+ this.__wbg_ptr = 0;
526
+ WrapDescriptorFinalization.unregister(this);
527
+ return ptr;
528
+ }
529
+
530
+ free() {
531
+ const ptr = this.__destroy_into_raw();
532
+ wasm.__wbg_wrapdescriptor_free(ptr, 0);
533
+ }
534
+ /**
535
+ * Parse a descriptor string with an explicit public key type.
536
+ *
537
+ * Note that this function permits parsing a non-derivable descriptor with a derivable key type.
538
+ * Use `from_string_detect_type` to automatically detect the key type.
539
+ *
540
+ * # Arguments
541
+ * * `descriptor` - A string containing the descriptor to parse
542
+ * * `pk_type` - The type of public key to expect:
543
+ * - "derivable": For descriptors containing derivation paths (eg. xpubs)
544
+ * - "definite": For descriptors with fully specified keys
545
+ * - "string": For descriptors with string placeholders
546
+ *
547
+ * # Returns
548
+ * * `Result<WrapDescriptor, WasmUtxoError>` - The parsed descriptor or an error
549
+ *
550
+ * # Example
551
+ * ```
552
+ * use wasm_utxo::WrapDescriptor;
553
+ * let desc = WrapDescriptor::from_string(
554
+ * "pk(xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*)",
555
+ * "derivable"
556
+ * );
557
+ * ```
558
+ * @param {string} descriptor
559
+ * @param {string} pk_type
560
+ * @returns {WrapDescriptor}
561
+ */
562
+ static fromString(descriptor, pk_type) {
563
+ try {
564
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
565
+ const ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
566
+ const len0 = WASM_VECTOR_LEN;
567
+ const ptr1 = passStringToWasm0(pk_type, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
568
+ const len1 = WASM_VECTOR_LEN;
569
+ wasm.wrapdescriptor_fromString(retptr, ptr0, len0, ptr1, len1);
570
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
571
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
572
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
573
+ if (r2) {
574
+ throw takeObject(r1);
575
+ }
576
+ return WrapDescriptor.__wrap(r0);
577
+ } finally {
578
+ wasm.__wbindgen_add_to_stack_pointer(16);
579
+ }
580
+ }
581
+ /**
582
+ * @returns {boolean}
583
+ */
584
+ hasWildcard() {
585
+ const ret = wasm.wrapdescriptor_hasWildcard(this.__wbg_ptr);
586
+ return ret !== 0;
587
+ }
588
+ /**
589
+ * @returns {Uint8Array}
590
+ */
591
+ scriptPubkey() {
592
+ try {
593
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
594
+ wasm.wrapdescriptor_scriptPubkey(retptr, this.__wbg_ptr);
595
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
596
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
597
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
598
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
599
+ if (r3) {
600
+ throw takeObject(r2);
601
+ }
602
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
603
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
604
+ return v1;
605
+ } finally {
606
+ wasm.__wbindgen_add_to_stack_pointer(16);
607
+ }
608
+ }
609
+ /**
610
+ * @returns {string}
611
+ */
612
+ toAsmString() {
613
+ let deferred2_0;
614
+ let deferred2_1;
615
+ try {
616
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
617
+ wasm.wrapdescriptor_toAsmString(retptr, this.__wbg_ptr);
618
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
619
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
620
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
621
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
622
+ var ptr1 = r0;
623
+ var len1 = r1;
624
+ if (r3) {
625
+ ptr1 = 0; len1 = 0;
626
+ throw takeObject(r2);
627
+ }
628
+ deferred2_0 = ptr1;
629
+ deferred2_1 = len1;
630
+ return getStringFromWasm0(ptr1, len1);
631
+ } finally {
632
+ wasm.__wbindgen_add_to_stack_pointer(16);
633
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
634
+ }
635
+ }
636
+ /**
637
+ * @param {number} index
638
+ * @returns {WrapDescriptor}
639
+ */
640
+ atDerivationIndex(index) {
641
+ try {
642
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
643
+ wasm.wrapdescriptor_atDerivationIndex(retptr, this.__wbg_ptr, index);
644
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
645
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
646
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
647
+ if (r2) {
648
+ throw takeObject(r1);
649
+ }
650
+ return WrapDescriptor.__wrap(r0);
651
+ } finally {
652
+ wasm.__wbindgen_add_to_stack_pointer(16);
653
+ }
654
+ }
655
+ /**
656
+ * @returns {number}
657
+ */
658
+ maxWeightToSatisfy() {
659
+ try {
660
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
661
+ wasm.wrapdescriptor_maxWeightToSatisfy(retptr, this.__wbg_ptr);
662
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
663
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
664
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
665
+ if (r2) {
666
+ throw takeObject(r1);
667
+ }
668
+ return r0 >>> 0;
669
+ } finally {
670
+ wasm.__wbindgen_add_to_stack_pointer(16);
671
+ }
672
+ }
673
+ /**
674
+ * Parse a descriptor string, automatically detecting the appropriate public key type.
675
+ * This will check if the descriptor contains wildcards to determine if it should be
676
+ * parsed as derivable or definite.
677
+ *
678
+ * # Arguments
679
+ * * `descriptor` - A string containing the descriptor to parse
680
+ *
681
+ * # Returns
682
+ * * `Result<WrapDescriptor, WasmUtxoError>` - The parsed descriptor or an error
683
+ *
684
+ * # Example
685
+ * ```
686
+ * use wasm_utxo::WrapDescriptor;
687
+ * // Will be parsed as definite since it has no wildcards
688
+ * let desc = WrapDescriptor::from_string_detect_type(
689
+ * "pk(02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5)"
690
+ * );
691
+ *
692
+ * // Will be parsed as derivable since it contains a wildcard (*)
693
+ * let desc = WrapDescriptor::from_string_detect_type(
694
+ * "pk(xpub.../0/*)"
695
+ * );
696
+ * ```
697
+ * @param {string} descriptor
698
+ * @returns {WrapDescriptor}
699
+ */
700
+ static fromStringDetectType(descriptor) {
701
+ try {
702
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
703
+ const ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
704
+ const len0 = WASM_VECTOR_LEN;
705
+ wasm.wrapdescriptor_fromStringDetectType(retptr, ptr0, len0);
706
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
707
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
708
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
709
+ if (r2) {
710
+ throw takeObject(r1);
711
+ }
712
+ return WrapDescriptor.__wrap(r0);
713
+ } finally {
714
+ wasm.__wbindgen_add_to_stack_pointer(16);
715
+ }
716
+ }
717
+ /**
718
+ * @returns {any}
719
+ */
720
+ node() {
721
+ try {
722
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
723
+ wasm.wrapdescriptor_node(retptr, this.__wbg_ptr);
724
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
725
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
726
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
727
+ if (r2) {
728
+ throw takeObject(r1);
729
+ }
730
+ return takeObject(r0);
731
+ } finally {
732
+ wasm.__wbindgen_add_to_stack_pointer(16);
733
+ }
734
+ }
735
+ /**
736
+ * @returns {Uint8Array}
737
+ */
738
+ encode() {
739
+ try {
740
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
741
+ wasm.wrapdescriptor_encode(retptr, this.__wbg_ptr);
742
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
743
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
744
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
745
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
746
+ if (r3) {
747
+ throw takeObject(r2);
748
+ }
749
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
750
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
751
+ return v1;
752
+ } finally {
753
+ wasm.__wbindgen_add_to_stack_pointer(16);
754
+ }
755
+ }
756
+ /**
757
+ * @returns {any}
758
+ */
759
+ descType() {
760
+ try {
761
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
762
+ wasm.wrapdescriptor_descType(retptr, this.__wbg_ptr);
763
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
764
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
765
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
766
+ if (r2) {
767
+ throw takeObject(r1);
768
+ }
769
+ return takeObject(r0);
770
+ } finally {
771
+ wasm.__wbindgen_add_to_stack_pointer(16);
772
+ }
773
+ }
774
+ /**
775
+ * @returns {string}
776
+ */
777
+ toString() {
778
+ let deferred1_0;
779
+ let deferred1_1;
780
+ try {
781
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
782
+ wasm.wrapdescriptor_toString(retptr, this.__wbg_ptr);
783
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
784
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
785
+ deferred1_0 = r0;
786
+ deferred1_1 = r1;
787
+ return getStringFromWasm0(r0, r1);
788
+ } finally {
789
+ wasm.__wbindgen_add_to_stack_pointer(16);
790
+ wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
791
+ }
792
+ }
793
+ }
794
+ if (Symbol.dispose) WrapDescriptor.prototype[Symbol.dispose] = WrapDescriptor.prototype.free;
795
+
796
+ exports.WrapDescriptor = WrapDescriptor;
797
+
798
+ const WrapMiniscriptFinalization = (typeof FinalizationRegistry === 'undefined')
799
+ ? { register: () => {}, unregister: () => {} }
800
+ : new FinalizationRegistry(ptr => wasm.__wbg_wrapminiscript_free(ptr >>> 0, 1));
801
+
802
+ class WrapMiniscript {
803
+
804
+ static __wrap(ptr) {
805
+ ptr = ptr >>> 0;
806
+ const obj = Object.create(WrapMiniscript.prototype);
807
+ obj.__wbg_ptr = ptr;
808
+ WrapMiniscriptFinalization.register(obj, obj.__wbg_ptr, obj);
809
+ return obj;
810
+ }
811
+
812
+ __destroy_into_raw() {
813
+ const ptr = this.__wbg_ptr;
814
+ this.__wbg_ptr = 0;
815
+ WrapMiniscriptFinalization.unregister(this);
816
+ return ptr;
817
+ }
818
+
819
+ free() {
820
+ const ptr = this.__destroy_into_raw();
821
+ wasm.__wbg_wrapminiscript_free(ptr, 0);
822
+ }
823
+ /**
824
+ * @param {string} script
825
+ * @param {string} context_type
826
+ * @returns {WrapMiniscript}
827
+ */
828
+ static fromString(script, context_type) {
829
+ try {
830
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
831
+ const ptr0 = passStringToWasm0(script, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
832
+ const len0 = WASM_VECTOR_LEN;
833
+ const ptr1 = passStringToWasm0(context_type, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
834
+ const len1 = WASM_VECTOR_LEN;
835
+ wasm.wrapminiscript_fromString(retptr, ptr0, len0, ptr1, len1);
836
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
837
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
838
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
839
+ if (r2) {
840
+ throw takeObject(r1);
841
+ }
842
+ return WrapMiniscript.__wrap(r0);
843
+ } finally {
844
+ wasm.__wbindgen_add_to_stack_pointer(16);
845
+ }
846
+ }
847
+ /**
848
+ * @returns {string}
849
+ */
850
+ toAsmString() {
851
+ let deferred2_0;
852
+ let deferred2_1;
853
+ try {
854
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
855
+ wasm.wrapminiscript_toAsmString(retptr, this.__wbg_ptr);
856
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
857
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
858
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
859
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
860
+ var ptr1 = r0;
861
+ var len1 = r1;
862
+ if (r3) {
863
+ ptr1 = 0; len1 = 0;
864
+ throw takeObject(r2);
865
+ }
866
+ deferred2_0 = ptr1;
867
+ deferred2_1 = len1;
868
+ return getStringFromWasm0(ptr1, len1);
869
+ } finally {
870
+ wasm.__wbindgen_add_to_stack_pointer(16);
871
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
872
+ }
873
+ }
874
+ /**
875
+ * @param {Uint8Array} script
876
+ * @param {string} context_type
877
+ * @returns {WrapMiniscript}
878
+ */
879
+ static fromBitcoinScript(script, context_type) {
880
+ try {
881
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
882
+ const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
883
+ const len0 = WASM_VECTOR_LEN;
884
+ const ptr1 = passStringToWasm0(context_type, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
885
+ const len1 = WASM_VECTOR_LEN;
886
+ wasm.wrapminiscript_fromBitcoinScript(retptr, ptr0, len0, ptr1, len1);
887
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
888
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
889
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
890
+ if (r2) {
891
+ throw takeObject(r1);
892
+ }
893
+ return WrapMiniscript.__wrap(r0);
894
+ } finally {
895
+ wasm.__wbindgen_add_to_stack_pointer(16);
896
+ }
897
+ }
898
+ /**
899
+ * @returns {any}
900
+ */
901
+ node() {
902
+ try {
903
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
904
+ wasm.wrapminiscript_node(retptr, this.__wbg_ptr);
905
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
906
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
907
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
908
+ if (r2) {
909
+ throw takeObject(r1);
910
+ }
911
+ return takeObject(r0);
912
+ } finally {
913
+ wasm.__wbindgen_add_to_stack_pointer(16);
914
+ }
915
+ }
916
+ /**
917
+ * @returns {Uint8Array}
918
+ */
919
+ encode() {
920
+ try {
921
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
922
+ wasm.wrapminiscript_encode(retptr, this.__wbg_ptr);
923
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
924
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
925
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
926
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
927
+ return v1;
928
+ } finally {
929
+ wasm.__wbindgen_add_to_stack_pointer(16);
930
+ }
931
+ }
932
+ /**
933
+ * @returns {string}
934
+ */
935
+ toString() {
936
+ let deferred1_0;
937
+ let deferred1_1;
938
+ try {
939
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
940
+ wasm.wrapminiscript_toString(retptr, this.__wbg_ptr);
941
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
942
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
943
+ deferred1_0 = r0;
944
+ deferred1_1 = r1;
945
+ return getStringFromWasm0(r0, r1);
946
+ } finally {
947
+ wasm.__wbindgen_add_to_stack_pointer(16);
948
+ wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
949
+ }
950
+ }
951
+ }
952
+ if (Symbol.dispose) WrapMiniscript.prototype[Symbol.dispose] = WrapMiniscript.prototype.free;
953
+
954
+ exports.WrapMiniscript = WrapMiniscript;
955
+
956
+ const WrapPsbtFinalization = (typeof FinalizationRegistry === 'undefined')
957
+ ? { register: () => {}, unregister: () => {} }
958
+ : new FinalizationRegistry(ptr => wasm.__wbg_wrappsbt_free(ptr >>> 0, 1));
959
+
960
+ class WrapPsbt {
961
+
962
+ static __wrap(ptr) {
963
+ ptr = ptr >>> 0;
964
+ const obj = Object.create(WrapPsbt.prototype);
965
+ obj.__wbg_ptr = ptr;
966
+ WrapPsbtFinalization.register(obj, obj.__wbg_ptr, obj);
967
+ return obj;
968
+ }
969
+
970
+ __destroy_into_raw() {
971
+ const ptr = this.__wbg_ptr;
972
+ this.__wbg_ptr = 0;
973
+ WrapPsbtFinalization.unregister(this);
974
+ return ptr;
975
+ }
976
+
977
+ free() {
978
+ const ptr = this.__destroy_into_raw();
979
+ wasm.__wbg_wrappsbt_free(ptr, 0);
980
+ }
981
+ /**
982
+ * @param {Uint8Array} psbt
983
+ * @returns {WrapPsbt}
984
+ */
985
+ static deserialize(psbt) {
986
+ try {
987
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
988
+ const ptr0 = passArray8ToWasm0(psbt, wasm.__wbindgen_export_1);
989
+ const len0 = WASM_VECTOR_LEN;
990
+ wasm.wrappsbt_deserialize(retptr, ptr0, len0);
991
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
992
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
993
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
994
+ if (r2) {
995
+ throw takeObject(r1);
996
+ }
997
+ return WrapPsbt.__wrap(r0);
998
+ } finally {
999
+ wasm.__wbindgen_add_to_stack_pointer(16);
1000
+ }
1001
+ }
1002
+ finalize() {
1003
+ try {
1004
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1005
+ wasm.wrappsbt_finalize(retptr, this.__wbg_ptr);
1006
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1007
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1008
+ if (r1) {
1009
+ throw takeObject(r0);
1010
+ }
1011
+ } finally {
1012
+ wasm.__wbindgen_add_to_stack_pointer(16);
1013
+ }
1014
+ }
1015
+ /**
1016
+ * @param {Uint8Array} prv
1017
+ * @returns {any}
1018
+ */
1019
+ signWithPrv(prv) {
1020
+ try {
1021
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1022
+ const ptr0 = passArray8ToWasm0(prv, wasm.__wbindgen_export_1);
1023
+ const len0 = WASM_VECTOR_LEN;
1024
+ wasm.wrappsbt_signWithPrv(retptr, this.__wbg_ptr, ptr0, len0);
1025
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1026
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1027
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1028
+ if (r2) {
1029
+ throw takeObject(r1);
1030
+ }
1031
+ return takeObject(r0);
1032
+ } finally {
1033
+ wasm.__wbindgen_add_to_stack_pointer(16);
1034
+ }
1035
+ }
1036
+ /**
1037
+ * @param {string} xprv
1038
+ * @returns {any}
1039
+ */
1040
+ signWithXprv(xprv) {
1041
+ try {
1042
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1043
+ const ptr0 = passStringToWasm0(xprv, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1044
+ const len0 = WASM_VECTOR_LEN;
1045
+ wasm.wrappsbt_signWithXprv(retptr, this.__wbg_ptr, ptr0, len0);
1046
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1047
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1048
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1049
+ if (r2) {
1050
+ throw takeObject(r1);
1051
+ }
1052
+ return takeObject(r0);
1053
+ } finally {
1054
+ wasm.__wbindgen_add_to_stack_pointer(16);
1055
+ }
1056
+ }
1057
+ /**
1058
+ * @param {number} input_index
1059
+ * @param {WrapDescriptor} descriptor
1060
+ */
1061
+ updateInputWithDescriptor(input_index, descriptor) {
1062
+ try {
1063
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1064
+ _assertClass(descriptor, WrapDescriptor);
1065
+ wasm.wrappsbt_updateInputWithDescriptor(retptr, this.__wbg_ptr, input_index, descriptor.__wbg_ptr);
1066
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1067
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1068
+ if (r1) {
1069
+ throw takeObject(r0);
1070
+ }
1071
+ } finally {
1072
+ wasm.__wbindgen_add_to_stack_pointer(16);
1073
+ }
1074
+ }
1075
+ /**
1076
+ * @param {number} output_index
1077
+ * @param {WrapDescriptor} descriptor
1078
+ */
1079
+ updateOutputWithDescriptor(output_index, descriptor) {
1080
+ try {
1081
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1082
+ _assertClass(descriptor, WrapDescriptor);
1083
+ wasm.wrappsbt_updateOutputWithDescriptor(retptr, this.__wbg_ptr, output_index, descriptor.__wbg_ptr);
1084
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1085
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1086
+ if (r1) {
1087
+ throw takeObject(r0);
1088
+ }
1089
+ } finally {
1090
+ wasm.__wbindgen_add_to_stack_pointer(16);
1091
+ }
1092
+ }
1093
+ /**
1094
+ * @returns {WrapPsbt}
1095
+ */
1096
+ clone() {
1097
+ const ret = wasm.wrappsbt_clone(this.__wbg_ptr);
1098
+ return WrapPsbt.__wrap(ret);
1099
+ }
1100
+ /**
1101
+ * @returns {Uint8Array}
1102
+ */
1103
+ serialize() {
1104
+ try {
1105
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1106
+ wasm.wrappsbt_serialize(retptr, this.__wbg_ptr);
1107
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1108
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1109
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1110
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
1111
+ return v1;
1112
+ } finally {
1113
+ wasm.__wbindgen_add_to_stack_pointer(16);
1114
+ }
1115
+ }
1116
+ }
1117
+ if (Symbol.dispose) WrapPsbt.prototype[Symbol.dispose] = WrapPsbt.prototype.free;
1118
+
1119
+ exports.WrapPsbt = WrapPsbt;
1120
+
1121
+ exports.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
1122
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1123
+ return addHeapObject(ret);
1124
+ };
1125
+
1126
+ exports.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
1127
+ const ret = getObject(arg0).call(getObject(arg1));
1128
+ return addHeapObject(ret);
1129
+ }, arguments) };
1130
+
1131
+ exports.__wbg_from_88bc52ce20ba6318 = function(arg0) {
1132
+ const ret = Array.from(getObject(arg0));
1133
+ return addHeapObject(ret);
1134
+ };
1135
+
1136
+ exports.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
1137
+ const ret = getObject(arg0)[arg1 >>> 0];
1138
+ return addHeapObject(ret);
1139
+ };
1140
+
1141
+ exports.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
1142
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1143
+ return addHeapObject(ret);
1144
+ }, arguments) };
1145
+
1146
+ exports.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
1147
+ let result;
1148
+ try {
1149
+ result = getObject(arg0) instanceof Uint8Array;
1150
+ } catch (_) {
1151
+ result = false;
1152
+ }
1153
+ const ret = result;
1154
+ return ret;
1155
+ };
1156
+
1157
+ exports.__wbg_isArray_030cce220591fb41 = function(arg0) {
1158
+ const ret = Array.isArray(getObject(arg0));
1159
+ return ret;
1160
+ };
1161
+
1162
+ exports.__wbg_length_186546c51cd61acd = function(arg0) {
1163
+ const ret = getObject(arg0).length;
1164
+ return ret;
1165
+ };
1166
+
1167
+ exports.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
1168
+ const ret = getObject(arg0).length;
1169
+ return ret;
1170
+ };
1171
+
1172
+ exports.__wbg_new_19c25a3f2fa63a02 = function() {
1173
+ const ret = new Object();
1174
+ return addHeapObject(ret);
1175
+ };
1176
+
1177
+ exports.__wbg_new_1f3a344cf3123716 = function() {
1178
+ const ret = new Array();
1179
+ return addHeapObject(ret);
1180
+ };
1181
+
1182
+ exports.__wbg_new_638ebfaedbf32a5e = function(arg0) {
1183
+ const ret = new Uint8Array(getObject(arg0));
1184
+ return addHeapObject(ret);
1185
+ };
1186
+
1187
+ exports.__wbg_new_da9dc54c5db29dfa = function(arg0, arg1) {
1188
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1189
+ return addHeapObject(ret);
1190
+ };
1191
+
1192
+ exports.__wbg_newfromslice_074c56947bd43469 = function(arg0, arg1) {
1193
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1194
+ return addHeapObject(ret);
1195
+ };
1196
+
1197
+ exports.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
1198
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1199
+ };
1200
+
1201
+ exports.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
1202
+ const ret = getObject(arg0).push(getObject(arg1));
1203
+ return ret;
1204
+ };
1205
+
1206
+ exports.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
1207
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1208
+ return ret;
1209
+ }, arguments) };
1210
+
1211
+ exports.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
1212
+ const ret = typeof(getObject(arg0)) === 'function';
1213
+ return ret;
1214
+ };
1215
+
1216
+ exports.__wbg_wbindgenisnull_f3037694abe4d97a = function(arg0) {
1217
+ const ret = getObject(arg0) === null;
1218
+ return ret;
1219
+ };
1220
+
1221
+ exports.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
1222
+ const val = getObject(arg0);
1223
+ const ret = typeof(val) === 'object' && val !== null;
1224
+ return ret;
1225
+ };
1226
+
1227
+ exports.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
1228
+ const ret = getObject(arg0) === undefined;
1229
+ return ret;
1230
+ };
1231
+
1232
+ exports.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
1233
+ const obj = getObject(arg1);
1234
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1235
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1236
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1237
+ };
1238
+
1239
+ exports.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
1240
+ const obj = getObject(arg1);
1241
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1242
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1243
+ var len1 = WASM_VECTOR_LEN;
1244
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1245
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1246
+ };
1247
+
1248
+ exports.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
1249
+ throw new Error(getStringFromWasm0(arg0, arg1));
1250
+ };
1251
+
1252
+ exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1253
+ // Cast intrinsic for `Ref(String) -> Externref`.
1254
+ const ret = getStringFromWasm0(arg0, arg1);
1255
+ return addHeapObject(ret);
1256
+ };
1257
+
1258
+ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1259
+ // Cast intrinsic for `U64 -> Externref`.
1260
+ const ret = BigInt.asUintN(64, arg0);
1261
+ return addHeapObject(ret);
1262
+ };
1263
+
1264
+ exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1265
+ // Cast intrinsic for `F64 -> Externref`.
1266
+ const ret = arg0;
1267
+ return addHeapObject(ret);
1268
+ };
1269
+
1270
+ exports.__wbindgen_object_clone_ref = function(arg0) {
1271
+ const ret = getObject(arg0);
1272
+ return addHeapObject(ret);
1273
+ };
1274
+
1275
+ exports.__wbindgen_object_drop_ref = function(arg0) {
1276
+ takeObject(arg0);
1277
+ };
1278
+
1279
+ const wasmPath = `${__dirname}/wasm_utxo_bg.wasm`;
1280
+ const wasmBytes = require('fs').readFileSync(wasmPath);
1281
+ const wasmModule = new WebAssembly.Module(wasmBytes);
1282
+ const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
1283
+