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