@bitgo/wasm-utxo 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/browser/js/ast/formatNode.d.ts +88 -0
- package/dist/browser/js/ast/formatNode.js +36 -0
- package/dist/browser/js/ast/fromWasmNode.d.ts +4 -0
- package/dist/browser/js/ast/fromWasmNode.js +120 -0
- package/dist/browser/js/ast/index.d.ts +2 -0
- package/dist/browser/js/ast/index.js +2 -0
- package/dist/browser/js/index.d.ts +37 -0
- package/dist/browser/js/index.js +11 -0
- package/dist/browser/js/wasm/wasm_utxo.d.ts +75 -0
- package/dist/browser/js/wasm/wasm_utxo.js +4 -0
- package/dist/browser/js/wasm/wasm_utxo_bg.js +1156 -0
- package/dist/browser/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/browser/js/wasm/wasm_utxo_bg.wasm.d.ts +49 -0
- package/dist/node/js/ast/formatNode.d.ts +88 -0
- package/dist/node/js/ast/formatNode.js +39 -0
- package/dist/node/js/ast/fromWasmNode.d.ts +4 -0
- package/dist/node/js/ast/fromWasmNode.js +124 -0
- package/dist/node/js/ast/index.d.ts +2 -0
- package/dist/node/js/ast/index.js +18 -0
- package/dist/node/js/index.d.ts +37 -0
- package/dist/node/js/index.js +50 -0
- package/dist/node/js/wasm/wasm_utxo.d.ts +75 -0
- package/dist/node/js/wasm/wasm_utxo.js +1163 -0
- package/dist/node/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/node/js/wasm/wasm_utxo_bg.wasm.d.ts +49 -0
- package/package.json +47 -5
|
@@ -0,0 +1,1163 @@
|
|
|
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 FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
235
|
+
? { register: () => {}, unregister: () => {} }
|
|
236
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
|
|
237
|
+
|
|
238
|
+
class FixedScriptWalletNamespace {
|
|
239
|
+
|
|
240
|
+
__destroy_into_raw() {
|
|
241
|
+
const ptr = this.__wbg_ptr;
|
|
242
|
+
this.__wbg_ptr = 0;
|
|
243
|
+
FixedScriptWalletNamespaceFinalization.unregister(this);
|
|
244
|
+
return ptr;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
free() {
|
|
248
|
+
const ptr = this.__destroy_into_raw();
|
|
249
|
+
wasm.__wbg_fixedscriptwalletnamespace_free(ptr, 0);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* @param {any} keys
|
|
253
|
+
* @param {number} chain
|
|
254
|
+
* @param {number} index
|
|
255
|
+
* @param {any} network
|
|
256
|
+
* @returns {Uint8Array}
|
|
257
|
+
*/
|
|
258
|
+
static output_script(keys, chain, index, network) {
|
|
259
|
+
try {
|
|
260
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
261
|
+
wasm.fixedscriptwalletnamespace_output_script(retptr, addHeapObject(keys), chain, index, addHeapObject(network));
|
|
262
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
263
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
264
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
265
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
266
|
+
if (r3) {
|
|
267
|
+
throw takeObject(r2);
|
|
268
|
+
}
|
|
269
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
270
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
271
|
+
return v1;
|
|
272
|
+
} finally {
|
|
273
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* @param {any} keys
|
|
278
|
+
* @param {number} chain
|
|
279
|
+
* @param {number} index
|
|
280
|
+
* @param {any} network
|
|
281
|
+
* @param {string | null} [address_format]
|
|
282
|
+
* @returns {string}
|
|
283
|
+
*/
|
|
284
|
+
static address(keys, chain, index, network, address_format) {
|
|
285
|
+
let deferred3_0;
|
|
286
|
+
let deferred3_1;
|
|
287
|
+
try {
|
|
288
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
289
|
+
var ptr0 = isLikeNone(address_format) ? 0 : passStringToWasm0(address_format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
290
|
+
var len0 = WASM_VECTOR_LEN;
|
|
291
|
+
wasm.fixedscriptwalletnamespace_address(retptr, addHeapObject(keys), chain, index, addHeapObject(network), ptr0, len0);
|
|
292
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
293
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
294
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
295
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
296
|
+
var ptr2 = r0;
|
|
297
|
+
var len2 = r1;
|
|
298
|
+
if (r3) {
|
|
299
|
+
ptr2 = 0; len2 = 0;
|
|
300
|
+
throw takeObject(r2);
|
|
301
|
+
}
|
|
302
|
+
deferred3_0 = ptr2;
|
|
303
|
+
deferred3_1 = len2;
|
|
304
|
+
return getStringFromWasm0(ptr2, len2);
|
|
305
|
+
} finally {
|
|
306
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
307
|
+
wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
|
|
312
|
+
|
|
313
|
+
exports.FixedScriptWalletNamespace = FixedScriptWalletNamespace;
|
|
314
|
+
|
|
315
|
+
const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
316
|
+
? { register: () => {}, unregister: () => {} }
|
|
317
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
|
|
318
|
+
|
|
319
|
+
class UtxolibCompatNamespace {
|
|
320
|
+
|
|
321
|
+
__destroy_into_raw() {
|
|
322
|
+
const ptr = this.__wbg_ptr;
|
|
323
|
+
this.__wbg_ptr = 0;
|
|
324
|
+
UtxolibCompatNamespaceFinalization.unregister(this);
|
|
325
|
+
return ptr;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
free() {
|
|
329
|
+
const ptr = this.__destroy_into_raw();
|
|
330
|
+
wasm.__wbg_utxolibcompatnamespace_free(ptr, 0);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Convert address string to output script
|
|
334
|
+
*
|
|
335
|
+
* # Arguments
|
|
336
|
+
* * `address` - The address string
|
|
337
|
+
* * `network` - The UtxolibNetwork object from JavaScript
|
|
338
|
+
* * `format` - Optional address format (currently unused for decoding as all formats are accepted)
|
|
339
|
+
* @param {string} address
|
|
340
|
+
* @param {any} network
|
|
341
|
+
* @param {string | null} [format]
|
|
342
|
+
* @returns {Uint8Array}
|
|
343
|
+
*/
|
|
344
|
+
static to_output_script(address, network, format) {
|
|
345
|
+
try {
|
|
346
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
347
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
348
|
+
const len0 = WASM_VECTOR_LEN;
|
|
349
|
+
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
350
|
+
var len1 = WASM_VECTOR_LEN;
|
|
351
|
+
wasm.utxolibcompatnamespace_to_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
|
|
352
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
353
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
354
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
355
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
356
|
+
if (r3) {
|
|
357
|
+
throw takeObject(r2);
|
|
358
|
+
}
|
|
359
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
360
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
361
|
+
return v3;
|
|
362
|
+
} finally {
|
|
363
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Convert output script to address string
|
|
368
|
+
*
|
|
369
|
+
* # Arguments
|
|
370
|
+
* * `script` - The output script as a byte array
|
|
371
|
+
* * `network` - The UtxolibNetwork object from JavaScript
|
|
372
|
+
* * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
|
|
373
|
+
* @param {Uint8Array} script
|
|
374
|
+
* @param {any} network
|
|
375
|
+
* @param {string | null} [format]
|
|
376
|
+
* @returns {string}
|
|
377
|
+
*/
|
|
378
|
+
static from_output_script(script, network, format) {
|
|
379
|
+
let deferred4_0;
|
|
380
|
+
let deferred4_1;
|
|
381
|
+
try {
|
|
382
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
383
|
+
const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
|
|
384
|
+
const len0 = WASM_VECTOR_LEN;
|
|
385
|
+
var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
386
|
+
var len1 = WASM_VECTOR_LEN;
|
|
387
|
+
wasm.utxolibcompatnamespace_from_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
|
|
388
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
389
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
390
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
391
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
392
|
+
var ptr3 = r0;
|
|
393
|
+
var len3 = r1;
|
|
394
|
+
if (r3) {
|
|
395
|
+
ptr3 = 0; len3 = 0;
|
|
396
|
+
throw takeObject(r2);
|
|
397
|
+
}
|
|
398
|
+
deferred4_0 = ptr3;
|
|
399
|
+
deferred4_1 = len3;
|
|
400
|
+
return getStringFromWasm0(ptr3, len3);
|
|
401
|
+
} finally {
|
|
402
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
403
|
+
wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (Symbol.dispose) UtxolibCompatNamespace.prototype[Symbol.dispose] = UtxolibCompatNamespace.prototype.free;
|
|
408
|
+
|
|
409
|
+
exports.UtxolibCompatNamespace = UtxolibCompatNamespace;
|
|
410
|
+
|
|
411
|
+
const WrapDescriptorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
412
|
+
? { register: () => {}, unregister: () => {} }
|
|
413
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wrapdescriptor_free(ptr >>> 0, 1));
|
|
414
|
+
|
|
415
|
+
class WrapDescriptor {
|
|
416
|
+
|
|
417
|
+
static __wrap(ptr) {
|
|
418
|
+
ptr = ptr >>> 0;
|
|
419
|
+
const obj = Object.create(WrapDescriptor.prototype);
|
|
420
|
+
obj.__wbg_ptr = ptr;
|
|
421
|
+
WrapDescriptorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
422
|
+
return obj;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
__destroy_into_raw() {
|
|
426
|
+
const ptr = this.__wbg_ptr;
|
|
427
|
+
this.__wbg_ptr = 0;
|
|
428
|
+
WrapDescriptorFinalization.unregister(this);
|
|
429
|
+
return ptr;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
free() {
|
|
433
|
+
const ptr = this.__destroy_into_raw();
|
|
434
|
+
wasm.__wbg_wrapdescriptor_free(ptr, 0);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Parse a descriptor string with an explicit public key type.
|
|
438
|
+
*
|
|
439
|
+
* Note that this function permits parsing a non-derivable descriptor with a derivable key type.
|
|
440
|
+
* Use `from_string_detect_type` to automatically detect the key type.
|
|
441
|
+
*
|
|
442
|
+
* # Arguments
|
|
443
|
+
* * `descriptor` - A string containing the descriptor to parse
|
|
444
|
+
* * `pk_type` - The type of public key to expect:
|
|
445
|
+
* - "derivable": For descriptors containing derivation paths (eg. xpubs)
|
|
446
|
+
* - "definite": For descriptors with fully specified keys
|
|
447
|
+
* - "string": For descriptors with string placeholders
|
|
448
|
+
*
|
|
449
|
+
* # Returns
|
|
450
|
+
* * `Result<WrapDescriptor, WasmUtxoError>` - The parsed descriptor or an error
|
|
451
|
+
*
|
|
452
|
+
* # Example
|
|
453
|
+
* ```
|
|
454
|
+
* use wasm_utxo::WrapDescriptor;
|
|
455
|
+
* let desc = WrapDescriptor::from_string(
|
|
456
|
+
* "pk(xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*)",
|
|
457
|
+
* "derivable"
|
|
458
|
+
* );
|
|
459
|
+
* ```
|
|
460
|
+
* @param {string} descriptor
|
|
461
|
+
* @param {string} pk_type
|
|
462
|
+
* @returns {WrapDescriptor}
|
|
463
|
+
*/
|
|
464
|
+
static fromString(descriptor, pk_type) {
|
|
465
|
+
try {
|
|
466
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
467
|
+
const ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
468
|
+
const len0 = WASM_VECTOR_LEN;
|
|
469
|
+
const ptr1 = passStringToWasm0(pk_type, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
470
|
+
const len1 = WASM_VECTOR_LEN;
|
|
471
|
+
wasm.wrapdescriptor_fromString(retptr, ptr0, len0, ptr1, len1);
|
|
472
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
473
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
474
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
475
|
+
if (r2) {
|
|
476
|
+
throw takeObject(r1);
|
|
477
|
+
}
|
|
478
|
+
return WrapDescriptor.__wrap(r0);
|
|
479
|
+
} finally {
|
|
480
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* @returns {boolean}
|
|
485
|
+
*/
|
|
486
|
+
hasWildcard() {
|
|
487
|
+
const ret = wasm.wrapdescriptor_hasWildcard(this.__wbg_ptr);
|
|
488
|
+
return ret !== 0;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* @returns {Uint8Array}
|
|
492
|
+
*/
|
|
493
|
+
scriptPubkey() {
|
|
494
|
+
try {
|
|
495
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
496
|
+
wasm.wrapdescriptor_scriptPubkey(retptr, this.__wbg_ptr);
|
|
497
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
498
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
499
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
500
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
501
|
+
if (r3) {
|
|
502
|
+
throw takeObject(r2);
|
|
503
|
+
}
|
|
504
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
505
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
506
|
+
return v1;
|
|
507
|
+
} finally {
|
|
508
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* @returns {string}
|
|
513
|
+
*/
|
|
514
|
+
toAsmString() {
|
|
515
|
+
let deferred2_0;
|
|
516
|
+
let deferred2_1;
|
|
517
|
+
try {
|
|
518
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
519
|
+
wasm.wrapdescriptor_toAsmString(retptr, this.__wbg_ptr);
|
|
520
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
521
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
522
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
523
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
524
|
+
var ptr1 = r0;
|
|
525
|
+
var len1 = r1;
|
|
526
|
+
if (r3) {
|
|
527
|
+
ptr1 = 0; len1 = 0;
|
|
528
|
+
throw takeObject(r2);
|
|
529
|
+
}
|
|
530
|
+
deferred2_0 = ptr1;
|
|
531
|
+
deferred2_1 = len1;
|
|
532
|
+
return getStringFromWasm0(ptr1, len1);
|
|
533
|
+
} finally {
|
|
534
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
535
|
+
wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* @param {number} index
|
|
540
|
+
* @returns {WrapDescriptor}
|
|
541
|
+
*/
|
|
542
|
+
atDerivationIndex(index) {
|
|
543
|
+
try {
|
|
544
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
545
|
+
wasm.wrapdescriptor_atDerivationIndex(retptr, this.__wbg_ptr, index);
|
|
546
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
547
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
548
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
549
|
+
if (r2) {
|
|
550
|
+
throw takeObject(r1);
|
|
551
|
+
}
|
|
552
|
+
return WrapDescriptor.__wrap(r0);
|
|
553
|
+
} finally {
|
|
554
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* @returns {number}
|
|
559
|
+
*/
|
|
560
|
+
maxWeightToSatisfy() {
|
|
561
|
+
try {
|
|
562
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
563
|
+
wasm.wrapdescriptor_maxWeightToSatisfy(retptr, this.__wbg_ptr);
|
|
564
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
565
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
566
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
567
|
+
if (r2) {
|
|
568
|
+
throw takeObject(r1);
|
|
569
|
+
}
|
|
570
|
+
return r0 >>> 0;
|
|
571
|
+
} finally {
|
|
572
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Parse a descriptor string, automatically detecting the appropriate public key type.
|
|
577
|
+
* This will check if the descriptor contains wildcards to determine if it should be
|
|
578
|
+
* parsed as derivable or definite.
|
|
579
|
+
*
|
|
580
|
+
* # Arguments
|
|
581
|
+
* * `descriptor` - A string containing the descriptor to parse
|
|
582
|
+
*
|
|
583
|
+
* # Returns
|
|
584
|
+
* * `Result<WrapDescriptor, WasmUtxoError>` - The parsed descriptor or an error
|
|
585
|
+
*
|
|
586
|
+
* # Example
|
|
587
|
+
* ```
|
|
588
|
+
* use wasm_utxo::WrapDescriptor;
|
|
589
|
+
* // Will be parsed as definite since it has no wildcards
|
|
590
|
+
* let desc = WrapDescriptor::from_string_detect_type(
|
|
591
|
+
* "pk(02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5)"
|
|
592
|
+
* );
|
|
593
|
+
*
|
|
594
|
+
* // Will be parsed as derivable since it contains a wildcard (*)
|
|
595
|
+
* let desc = WrapDescriptor::from_string_detect_type(
|
|
596
|
+
* "pk(xpub.../0/*)"
|
|
597
|
+
* );
|
|
598
|
+
* ```
|
|
599
|
+
* @param {string} descriptor
|
|
600
|
+
* @returns {WrapDescriptor}
|
|
601
|
+
*/
|
|
602
|
+
static fromStringDetectType(descriptor) {
|
|
603
|
+
try {
|
|
604
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
605
|
+
const ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
606
|
+
const len0 = WASM_VECTOR_LEN;
|
|
607
|
+
wasm.wrapdescriptor_fromStringDetectType(retptr, ptr0, len0);
|
|
608
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
609
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
610
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
611
|
+
if (r2) {
|
|
612
|
+
throw takeObject(r1);
|
|
613
|
+
}
|
|
614
|
+
return WrapDescriptor.__wrap(r0);
|
|
615
|
+
} finally {
|
|
616
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* @returns {any}
|
|
621
|
+
*/
|
|
622
|
+
node() {
|
|
623
|
+
try {
|
|
624
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
625
|
+
wasm.wrapdescriptor_node(retptr, this.__wbg_ptr);
|
|
626
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
627
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
628
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
629
|
+
if (r2) {
|
|
630
|
+
throw takeObject(r1);
|
|
631
|
+
}
|
|
632
|
+
return takeObject(r0);
|
|
633
|
+
} finally {
|
|
634
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* @returns {Uint8Array}
|
|
639
|
+
*/
|
|
640
|
+
encode() {
|
|
641
|
+
try {
|
|
642
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
643
|
+
wasm.wrapdescriptor_encode(retptr, this.__wbg_ptr);
|
|
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
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
648
|
+
if (r3) {
|
|
649
|
+
throw takeObject(r2);
|
|
650
|
+
}
|
|
651
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
652
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
653
|
+
return v1;
|
|
654
|
+
} finally {
|
|
655
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* @returns {any}
|
|
660
|
+
*/
|
|
661
|
+
descType() {
|
|
662
|
+
try {
|
|
663
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
664
|
+
wasm.wrapdescriptor_descType(retptr, this.__wbg_ptr);
|
|
665
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
666
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
667
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
668
|
+
if (r2) {
|
|
669
|
+
throw takeObject(r1);
|
|
670
|
+
}
|
|
671
|
+
return takeObject(r0);
|
|
672
|
+
} finally {
|
|
673
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* @returns {string}
|
|
678
|
+
*/
|
|
679
|
+
toString() {
|
|
680
|
+
let deferred1_0;
|
|
681
|
+
let deferred1_1;
|
|
682
|
+
try {
|
|
683
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
684
|
+
wasm.wrapdescriptor_toString(retptr, this.__wbg_ptr);
|
|
685
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
686
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
687
|
+
deferred1_0 = r0;
|
|
688
|
+
deferred1_1 = r1;
|
|
689
|
+
return getStringFromWasm0(r0, r1);
|
|
690
|
+
} finally {
|
|
691
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
692
|
+
wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (Symbol.dispose) WrapDescriptor.prototype[Symbol.dispose] = WrapDescriptor.prototype.free;
|
|
697
|
+
|
|
698
|
+
exports.WrapDescriptor = WrapDescriptor;
|
|
699
|
+
|
|
700
|
+
const WrapMiniscriptFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
701
|
+
? { register: () => {}, unregister: () => {} }
|
|
702
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wrapminiscript_free(ptr >>> 0, 1));
|
|
703
|
+
|
|
704
|
+
class WrapMiniscript {
|
|
705
|
+
|
|
706
|
+
static __wrap(ptr) {
|
|
707
|
+
ptr = ptr >>> 0;
|
|
708
|
+
const obj = Object.create(WrapMiniscript.prototype);
|
|
709
|
+
obj.__wbg_ptr = ptr;
|
|
710
|
+
WrapMiniscriptFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
711
|
+
return obj;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
__destroy_into_raw() {
|
|
715
|
+
const ptr = this.__wbg_ptr;
|
|
716
|
+
this.__wbg_ptr = 0;
|
|
717
|
+
WrapMiniscriptFinalization.unregister(this);
|
|
718
|
+
return ptr;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
free() {
|
|
722
|
+
const ptr = this.__destroy_into_raw();
|
|
723
|
+
wasm.__wbg_wrapminiscript_free(ptr, 0);
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* @param {string} script
|
|
727
|
+
* @param {string} context_type
|
|
728
|
+
* @returns {WrapMiniscript}
|
|
729
|
+
*/
|
|
730
|
+
static fromString(script, context_type) {
|
|
731
|
+
try {
|
|
732
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
733
|
+
const ptr0 = passStringToWasm0(script, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
734
|
+
const len0 = WASM_VECTOR_LEN;
|
|
735
|
+
const ptr1 = passStringToWasm0(context_type, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
736
|
+
const len1 = WASM_VECTOR_LEN;
|
|
737
|
+
wasm.wrapminiscript_fromString(retptr, ptr0, len0, ptr1, len1);
|
|
738
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
739
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
740
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
741
|
+
if (r2) {
|
|
742
|
+
throw takeObject(r1);
|
|
743
|
+
}
|
|
744
|
+
return WrapMiniscript.__wrap(r0);
|
|
745
|
+
} finally {
|
|
746
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* @returns {string}
|
|
751
|
+
*/
|
|
752
|
+
toAsmString() {
|
|
753
|
+
let deferred2_0;
|
|
754
|
+
let deferred2_1;
|
|
755
|
+
try {
|
|
756
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
757
|
+
wasm.wrapminiscript_toAsmString(retptr, this.__wbg_ptr);
|
|
758
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
759
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
760
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
761
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
762
|
+
var ptr1 = r0;
|
|
763
|
+
var len1 = r1;
|
|
764
|
+
if (r3) {
|
|
765
|
+
ptr1 = 0; len1 = 0;
|
|
766
|
+
throw takeObject(r2);
|
|
767
|
+
}
|
|
768
|
+
deferred2_0 = ptr1;
|
|
769
|
+
deferred2_1 = len1;
|
|
770
|
+
return getStringFromWasm0(ptr1, len1);
|
|
771
|
+
} finally {
|
|
772
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
773
|
+
wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* @param {Uint8Array} script
|
|
778
|
+
* @param {string} context_type
|
|
779
|
+
* @returns {WrapMiniscript}
|
|
780
|
+
*/
|
|
781
|
+
static fromBitcoinScript(script, context_type) {
|
|
782
|
+
try {
|
|
783
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
784
|
+
const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
|
|
785
|
+
const len0 = WASM_VECTOR_LEN;
|
|
786
|
+
const ptr1 = passStringToWasm0(context_type, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
787
|
+
const len1 = WASM_VECTOR_LEN;
|
|
788
|
+
wasm.wrapminiscript_fromBitcoinScript(retptr, ptr0, len0, ptr1, len1);
|
|
789
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
790
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
791
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
792
|
+
if (r2) {
|
|
793
|
+
throw takeObject(r1);
|
|
794
|
+
}
|
|
795
|
+
return WrapMiniscript.__wrap(r0);
|
|
796
|
+
} finally {
|
|
797
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* @returns {any}
|
|
802
|
+
*/
|
|
803
|
+
node() {
|
|
804
|
+
try {
|
|
805
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
806
|
+
wasm.wrapminiscript_node(retptr, this.__wbg_ptr);
|
|
807
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
808
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
809
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
810
|
+
if (r2) {
|
|
811
|
+
throw takeObject(r1);
|
|
812
|
+
}
|
|
813
|
+
return takeObject(r0);
|
|
814
|
+
} finally {
|
|
815
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* @returns {Uint8Array}
|
|
820
|
+
*/
|
|
821
|
+
encode() {
|
|
822
|
+
try {
|
|
823
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
824
|
+
wasm.wrapminiscript_encode(retptr, this.__wbg_ptr);
|
|
825
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
826
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
827
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
828
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
829
|
+
return v1;
|
|
830
|
+
} finally {
|
|
831
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* @returns {string}
|
|
836
|
+
*/
|
|
837
|
+
toString() {
|
|
838
|
+
let deferred1_0;
|
|
839
|
+
let deferred1_1;
|
|
840
|
+
try {
|
|
841
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
842
|
+
wasm.wrapminiscript_toString(retptr, this.__wbg_ptr);
|
|
843
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
844
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
845
|
+
deferred1_0 = r0;
|
|
846
|
+
deferred1_1 = r1;
|
|
847
|
+
return getStringFromWasm0(r0, r1);
|
|
848
|
+
} finally {
|
|
849
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
850
|
+
wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
if (Symbol.dispose) WrapMiniscript.prototype[Symbol.dispose] = WrapMiniscript.prototype.free;
|
|
855
|
+
|
|
856
|
+
exports.WrapMiniscript = WrapMiniscript;
|
|
857
|
+
|
|
858
|
+
const WrapPsbtFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
859
|
+
? { register: () => {}, unregister: () => {} }
|
|
860
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wrappsbt_free(ptr >>> 0, 1));
|
|
861
|
+
|
|
862
|
+
class WrapPsbt {
|
|
863
|
+
|
|
864
|
+
static __wrap(ptr) {
|
|
865
|
+
ptr = ptr >>> 0;
|
|
866
|
+
const obj = Object.create(WrapPsbt.prototype);
|
|
867
|
+
obj.__wbg_ptr = ptr;
|
|
868
|
+
WrapPsbtFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
869
|
+
return obj;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
__destroy_into_raw() {
|
|
873
|
+
const ptr = this.__wbg_ptr;
|
|
874
|
+
this.__wbg_ptr = 0;
|
|
875
|
+
WrapPsbtFinalization.unregister(this);
|
|
876
|
+
return ptr;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
free() {
|
|
880
|
+
const ptr = this.__destroy_into_raw();
|
|
881
|
+
wasm.__wbg_wrappsbt_free(ptr, 0);
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* @param {Uint8Array} psbt
|
|
885
|
+
* @returns {WrapPsbt}
|
|
886
|
+
*/
|
|
887
|
+
static deserialize(psbt) {
|
|
888
|
+
try {
|
|
889
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
890
|
+
const ptr0 = passArray8ToWasm0(psbt, wasm.__wbindgen_export_1);
|
|
891
|
+
const len0 = WASM_VECTOR_LEN;
|
|
892
|
+
wasm.wrappsbt_deserialize(retptr, ptr0, len0);
|
|
893
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
894
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
895
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
896
|
+
if (r2) {
|
|
897
|
+
throw takeObject(r1);
|
|
898
|
+
}
|
|
899
|
+
return WrapPsbt.__wrap(r0);
|
|
900
|
+
} finally {
|
|
901
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
finalize() {
|
|
905
|
+
try {
|
|
906
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
907
|
+
wasm.wrappsbt_finalize(retptr, this.__wbg_ptr);
|
|
908
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
909
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
910
|
+
if (r1) {
|
|
911
|
+
throw takeObject(r0);
|
|
912
|
+
}
|
|
913
|
+
} finally {
|
|
914
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* @param {Uint8Array} prv
|
|
919
|
+
* @returns {any}
|
|
920
|
+
*/
|
|
921
|
+
signWithPrv(prv) {
|
|
922
|
+
try {
|
|
923
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
924
|
+
const ptr0 = passArray8ToWasm0(prv, wasm.__wbindgen_export_1);
|
|
925
|
+
const len0 = WASM_VECTOR_LEN;
|
|
926
|
+
wasm.wrappsbt_signWithPrv(retptr, this.__wbg_ptr, ptr0, len0);
|
|
927
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
928
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
929
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
930
|
+
if (r2) {
|
|
931
|
+
throw takeObject(r1);
|
|
932
|
+
}
|
|
933
|
+
return takeObject(r0);
|
|
934
|
+
} finally {
|
|
935
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* @param {string} xprv
|
|
940
|
+
* @returns {any}
|
|
941
|
+
*/
|
|
942
|
+
signWithXprv(xprv) {
|
|
943
|
+
try {
|
|
944
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
945
|
+
const ptr0 = passStringToWasm0(xprv, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
946
|
+
const len0 = WASM_VECTOR_LEN;
|
|
947
|
+
wasm.wrappsbt_signWithXprv(retptr, this.__wbg_ptr, ptr0, len0);
|
|
948
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
949
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
950
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
951
|
+
if (r2) {
|
|
952
|
+
throw takeObject(r1);
|
|
953
|
+
}
|
|
954
|
+
return takeObject(r0);
|
|
955
|
+
} finally {
|
|
956
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* @param {number} input_index
|
|
961
|
+
* @param {WrapDescriptor} descriptor
|
|
962
|
+
*/
|
|
963
|
+
updateInputWithDescriptor(input_index, descriptor) {
|
|
964
|
+
try {
|
|
965
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
966
|
+
_assertClass(descriptor, WrapDescriptor);
|
|
967
|
+
wasm.wrappsbt_updateInputWithDescriptor(retptr, this.__wbg_ptr, input_index, descriptor.__wbg_ptr);
|
|
968
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
969
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
970
|
+
if (r1) {
|
|
971
|
+
throw takeObject(r0);
|
|
972
|
+
}
|
|
973
|
+
} finally {
|
|
974
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* @param {number} output_index
|
|
979
|
+
* @param {WrapDescriptor} descriptor
|
|
980
|
+
*/
|
|
981
|
+
updateOutputWithDescriptor(output_index, descriptor) {
|
|
982
|
+
try {
|
|
983
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
984
|
+
_assertClass(descriptor, WrapDescriptor);
|
|
985
|
+
wasm.wrappsbt_updateOutputWithDescriptor(retptr, this.__wbg_ptr, output_index, descriptor.__wbg_ptr);
|
|
986
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
987
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
988
|
+
if (r1) {
|
|
989
|
+
throw takeObject(r0);
|
|
990
|
+
}
|
|
991
|
+
} finally {
|
|
992
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* @returns {WrapPsbt}
|
|
997
|
+
*/
|
|
998
|
+
clone() {
|
|
999
|
+
const ret = wasm.wrappsbt_clone(this.__wbg_ptr);
|
|
1000
|
+
return WrapPsbt.__wrap(ret);
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* @returns {Uint8Array}
|
|
1004
|
+
*/
|
|
1005
|
+
serialize() {
|
|
1006
|
+
try {
|
|
1007
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1008
|
+
wasm.wrappsbt_serialize(retptr, this.__wbg_ptr);
|
|
1009
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1010
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1011
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1012
|
+
wasm.__wbindgen_export_3(r0, r1 * 1, 1);
|
|
1013
|
+
return v1;
|
|
1014
|
+
} finally {
|
|
1015
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
if (Symbol.dispose) WrapPsbt.prototype[Symbol.dispose] = WrapPsbt.prototype.free;
|
|
1020
|
+
|
|
1021
|
+
exports.WrapPsbt = WrapPsbt;
|
|
1022
|
+
|
|
1023
|
+
exports.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
|
|
1024
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1025
|
+
return addHeapObject(ret);
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
exports.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
|
|
1029
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
1030
|
+
return addHeapObject(ret);
|
|
1031
|
+
}, arguments) };
|
|
1032
|
+
|
|
1033
|
+
exports.__wbg_from_88bc52ce20ba6318 = function(arg0) {
|
|
1034
|
+
const ret = Array.from(getObject(arg0));
|
|
1035
|
+
return addHeapObject(ret);
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
exports.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
|
|
1039
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
1040
|
+
return addHeapObject(ret);
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
exports.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
|
|
1044
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
1045
|
+
return addHeapObject(ret);
|
|
1046
|
+
}, arguments) };
|
|
1047
|
+
|
|
1048
|
+
exports.__wbg_isArray_030cce220591fb41 = function(arg0) {
|
|
1049
|
+
const ret = Array.isArray(getObject(arg0));
|
|
1050
|
+
return ret;
|
|
1051
|
+
};
|
|
1052
|
+
|
|
1053
|
+
exports.__wbg_length_186546c51cd61acd = function(arg0) {
|
|
1054
|
+
const ret = getObject(arg0).length;
|
|
1055
|
+
return ret;
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
exports.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
|
|
1059
|
+
const ret = getObject(arg0).length;
|
|
1060
|
+
return ret;
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
exports.__wbg_new_19c25a3f2fa63a02 = function() {
|
|
1064
|
+
const ret = new Object();
|
|
1065
|
+
return addHeapObject(ret);
|
|
1066
|
+
};
|
|
1067
|
+
|
|
1068
|
+
exports.__wbg_new_1f3a344cf3123716 = function() {
|
|
1069
|
+
const ret = new Array();
|
|
1070
|
+
return addHeapObject(ret);
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
exports.__wbg_new_638ebfaedbf32a5e = function(arg0) {
|
|
1074
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
1075
|
+
return addHeapObject(ret);
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
exports.__wbg_new_da9dc54c5db29dfa = function(arg0, arg1) {
|
|
1079
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
1080
|
+
return addHeapObject(ret);
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
exports.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
|
|
1084
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
exports.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
|
|
1088
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
1089
|
+
return ret;
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
exports.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1093
|
+
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
1094
|
+
return ret;
|
|
1095
|
+
}, arguments) };
|
|
1096
|
+
|
|
1097
|
+
exports.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
|
|
1098
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
1099
|
+
return ret;
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
exports.__wbg_wbindgenisnull_f3037694abe4d97a = function(arg0) {
|
|
1103
|
+
const ret = getObject(arg0) === null;
|
|
1104
|
+
return ret;
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
exports.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
|
|
1108
|
+
const val = getObject(arg0);
|
|
1109
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
1110
|
+
return ret;
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
exports.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
|
|
1114
|
+
const ret = getObject(arg0) === undefined;
|
|
1115
|
+
return ret;
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
exports.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
|
|
1119
|
+
const obj = getObject(arg1);
|
|
1120
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1121
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1122
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
exports.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
|
|
1126
|
+
const obj = getObject(arg1);
|
|
1127
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1128
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
1129
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1130
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1131
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1132
|
+
};
|
|
1133
|
+
|
|
1134
|
+
exports.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
1135
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1136
|
+
};
|
|
1137
|
+
|
|
1138
|
+
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
1139
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1140
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1141
|
+
return addHeapObject(ret);
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
1145
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1146
|
+
const ret = arg0;
|
|
1147
|
+
return addHeapObject(ret);
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
1151
|
+
const ret = getObject(arg0);
|
|
1152
|
+
return addHeapObject(ret);
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
1156
|
+
takeObject(arg0);
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
const wasmPath = `${__dirname}/wasm_utxo_bg.wasm`;
|
|
1160
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
1161
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
1162
|
+
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
1163
|
+
|