lwk_node 0.13.1 → 0.14.1

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/lwk_wasm.d.ts CHANGED
@@ -578,6 +578,21 @@ export class EsploraClient {
578
578
  * Set the waterfalls server recipient key. This is used to encrypt the descriptor when calling the waterfalls endpoint.
579
579
  */
580
580
  setWaterfallsServerRecipient(recipient: string): Promise<void>;
581
+ /**
582
+ * Query the last used derivation index for a wallet's descriptor from the waterfalls server.
583
+ *
584
+ * This method queries the waterfalls `/v1/last_used_index` endpoint to get the last used
585
+ * derivation index for both external and internal chains of the wallet's descriptor.
586
+ *
587
+ * Returns `LastUsedIndexResponse` containing the last used indexes and the tip block hash.
588
+ *
589
+ * # Errors
590
+ *
591
+ * Returns an error if this client was not configured with waterfalls support,
592
+ * if the descriptor does not contain a wildcard,
593
+ * or if the descriptor uses ELIP151 blinding.
594
+ */
595
+ lastUsedIndex(descriptor: WolletDescriptor): Promise<LastUsedIndexResponse>;
581
596
  }
582
597
  /**
583
598
  * Multiple exchange rates against BTC provided from various sources
@@ -743,6 +758,30 @@ export class JadeWebSocket {
743
758
  keyoriginXpub(bip: Bip): Promise<string>;
744
759
  registerDescriptor(name: string, desc: WolletDescriptor): Promise<boolean>;
745
760
  }
761
+ /**
762
+ * Response from the last_used_index endpoint
763
+ *
764
+ * Returns the highest derivation index that has been used (has transaction history)
765
+ * for both external and internal chains. This is useful for quickly determining
766
+ * the next unused address without downloading full transaction history.
767
+ */
768
+ export class LastUsedIndexResponse {
769
+ private constructor();
770
+ free(): void;
771
+ [Symbol.dispose](): void;
772
+ /**
773
+ * Last used index on the external (receive) chain, or undefined if no addresses have been used.
774
+ */
775
+ readonly external: number | undefined;
776
+ /**
777
+ * Last used index on the internal (change) chain, or undefined if no addresses have been used.
778
+ */
779
+ readonly internal: number | undefined;
780
+ /**
781
+ * Current blockchain tip hash for reference.
782
+ */
783
+ readonly tip: string | undefined;
784
+ }
746
785
  export class LedgerWeb {
747
786
  free(): void;
748
787
  [Symbol.dispose](): void;
package/lwk_wasm.js CHANGED
@@ -210,22 +210,23 @@ function makeMutClosure(arg0, arg1, dtor, f) {
210
210
  return real;
211
211
  }
212
212
 
213
+ function getArrayJsValueFromWasm0(ptr, len) {
214
+ ptr = ptr >>> 0;
215
+ const mem = getDataViewMemory0();
216
+ const result = [];
217
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
218
+ result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
219
+ }
220
+ wasm.__externref_drop_slice(ptr, len);
221
+ return result;
222
+ }
223
+
213
224
  function takeFromExternrefTable0(idx) {
214
225
  const value = wasm.__wbindgen_export_4.get(idx);
215
226
  wasm.__externref_table_dealloc(idx);
216
227
  return value;
217
228
  }
218
229
 
219
- function passArrayJsValueToWasm0(array, malloc) {
220
- const ptr = malloc(array.length * 4, 4) >>> 0;
221
- for (let i = 0; i < array.length; i++) {
222
- const add = addToExternrefTable0(array[i]);
223
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
224
- }
225
- WASM_VECTOR_LEN = array.length;
226
- return ptr;
227
- }
228
-
229
230
  function _assertClass(instance, klass) {
230
231
  if (!(instance instanceof klass)) {
231
232
  throw new Error(`expected instance of ${klass.name}`);
@@ -279,6 +280,15 @@ exports.stringToQr = function(str, pixel_per_module) {
279
280
  }
280
281
  };
281
282
 
283
+ function passArrayJsValueToWasm0(array, malloc) {
284
+ const ptr = malloc(array.length * 4, 4) >>> 0;
285
+ for (let i = 0; i < array.length; i++) {
286
+ const add = addToExternrefTable0(array[i]);
287
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
288
+ }
289
+ WASM_VECTOR_LEN = array.length;
290
+ return ptr;
291
+ }
282
292
  /**
283
293
  * @returns {Promise<HIDDevice>}
284
294
  */
@@ -287,17 +297,6 @@ exports.searchLedgerDevice = function() {
287
297
  return ret;
288
298
  };
289
299
 
290
- function getArrayJsValueFromWasm0(ptr, len) {
291
- ptr = ptr >>> 0;
292
- const mem = getDataViewMemory0();
293
- const result = [];
294
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
295
- result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
296
- }
297
- wasm.__externref_drop_slice(ptr, len);
298
- return result;
299
- }
300
-
301
300
  function passArray8ToWasm0(arg, malloc) {
302
301
  const ptr = malloc(arg.length * 1, 1) >>> 0;
303
302
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -309,28 +308,28 @@ function getArrayU32FromWasm0(ptr, len) {
309
308
  ptr = ptr >>> 0;
310
309
  return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
311
310
  }
312
- function __wbg_adapter_8(arg0, arg1) {
313
- wasm.wasm_bindgen__convert__closures_____invoke__h05232c3defb8be20(arg0, arg1);
311
+ function __wbg_adapter_12(arg0, arg1, arg2) {
312
+ wasm.closure1333_externref_shim(arg0, arg1, arg2);
314
313
  }
315
314
 
316
- function __wbg_adapter_11(arg0, arg1, arg2) {
317
- wasm.closure1298_externref_shim(arg0, arg1, arg2);
315
+ function __wbg_adapter_19(arg0, arg1) {
316
+ wasm.wasm_bindgen__convert__closures_____invoke__h912986096667d3cb(arg0, arg1);
318
317
  }
319
318
 
320
- function __wbg_adapter_18(arg0, arg1, arg2) {
321
- wasm.closure785_externref_shim(arg0, arg1, arg2);
319
+ function __wbg_adapter_22(arg0, arg1) {
320
+ wasm.wasm_bindgen__convert__closures_____invoke__h05232c3defb8be20(arg0, arg1);
322
321
  }
323
322
 
324
- function __wbg_adapter_27(arg0, arg1, arg2) {
325
- wasm.closure1947_externref_shim(arg0, arg1, arg2);
323
+ function __wbg_adapter_25(arg0, arg1, arg2) {
324
+ wasm.closure1963_externref_shim(arg0, arg1, arg2);
326
325
  }
327
326
 
328
- function __wbg_adapter_30(arg0, arg1) {
329
- wasm.wasm_bindgen__convert__closures_____invoke__h912986096667d3cb(arg0, arg1);
327
+ function __wbg_adapter_30(arg0, arg1, arg2) {
328
+ wasm.closure793_externref_shim(arg0, arg1, arg2);
330
329
  }
331
330
 
332
- function __wbg_adapter_641(arg0, arg1, arg2, arg3) {
333
- wasm.closure2721_externref_shim(arg0, arg1, arg2, arg3);
331
+ function __wbg_adapter_647(arg0, arg1, arg2, arg3) {
332
+ wasm.closure2737_externref_shim(arg0, arg1, arg2, arg3);
334
333
  }
335
334
 
336
335
  /**
@@ -2067,6 +2066,27 @@ class EsploraClient {
2067
2066
  const ret = wasm.esploraclient_setWaterfallsServerRecipient(this.__wbg_ptr, ptr0, len0);
2068
2067
  return ret;
2069
2068
  }
2069
+ /**
2070
+ * Query the last used derivation index for a wallet's descriptor from the waterfalls server.
2071
+ *
2072
+ * This method queries the waterfalls `/v1/last_used_index` endpoint to get the last used
2073
+ * derivation index for both external and internal chains of the wallet's descriptor.
2074
+ *
2075
+ * Returns `LastUsedIndexResponse` containing the last used indexes and the tip block hash.
2076
+ *
2077
+ * # Errors
2078
+ *
2079
+ * Returns an error if this client was not configured with waterfalls support,
2080
+ * if the descriptor does not contain a wildcard,
2081
+ * or if the descriptor uses ELIP151 blinding.
2082
+ * @param {WolletDescriptor} descriptor
2083
+ * @returns {Promise<LastUsedIndexResponse>}
2084
+ */
2085
+ lastUsedIndex(descriptor) {
2086
+ _assertClass(descriptor, WolletDescriptor);
2087
+ const ret = wasm.esploraclient_lastUsedIndex(this.__wbg_ptr, descriptor.__wbg_ptr);
2088
+ return ret;
2089
+ }
2070
2090
  }
2071
2091
  if (Symbol.dispose) EsploraClient.prototype[Symbol.dispose] = EsploraClient.prototype.free;
2072
2092
 
@@ -2652,6 +2672,71 @@ if (Symbol.dispose) JadeWebSocket.prototype[Symbol.dispose] = JadeWebSocket.prot
2652
2672
 
2653
2673
  exports.JadeWebSocket = JadeWebSocket;
2654
2674
 
2675
+ const LastUsedIndexResponseFinalization = (typeof FinalizationRegistry === 'undefined')
2676
+ ? { register: () => {}, unregister: () => {} }
2677
+ : new FinalizationRegistry(ptr => wasm.__wbg_lastusedindexresponse_free(ptr >>> 0, 1));
2678
+ /**
2679
+ * Response from the last_used_index endpoint
2680
+ *
2681
+ * Returns the highest derivation index that has been used (has transaction history)
2682
+ * for both external and internal chains. This is useful for quickly determining
2683
+ * the next unused address without downloading full transaction history.
2684
+ */
2685
+ class LastUsedIndexResponse {
2686
+
2687
+ static __wrap(ptr) {
2688
+ ptr = ptr >>> 0;
2689
+ const obj = Object.create(LastUsedIndexResponse.prototype);
2690
+ obj.__wbg_ptr = ptr;
2691
+ LastUsedIndexResponseFinalization.register(obj, obj.__wbg_ptr, obj);
2692
+ return obj;
2693
+ }
2694
+
2695
+ __destroy_into_raw() {
2696
+ const ptr = this.__wbg_ptr;
2697
+ this.__wbg_ptr = 0;
2698
+ LastUsedIndexResponseFinalization.unregister(this);
2699
+ return ptr;
2700
+ }
2701
+
2702
+ free() {
2703
+ const ptr = this.__destroy_into_raw();
2704
+ wasm.__wbg_lastusedindexresponse_free(ptr, 0);
2705
+ }
2706
+ /**
2707
+ * Last used index on the external (receive) chain, or undefined if no addresses have been used.
2708
+ * @returns {number | undefined}
2709
+ */
2710
+ get external() {
2711
+ const ret = wasm.lastusedindexresponse_external(this.__wbg_ptr);
2712
+ return ret === 0x100000001 ? undefined : ret;
2713
+ }
2714
+ /**
2715
+ * Last used index on the internal (change) chain, or undefined if no addresses have been used.
2716
+ * @returns {number | undefined}
2717
+ */
2718
+ get internal() {
2719
+ const ret = wasm.lastusedindexresponse_internal(this.__wbg_ptr);
2720
+ return ret === 0x100000001 ? undefined : ret;
2721
+ }
2722
+ /**
2723
+ * Current blockchain tip hash for reference.
2724
+ * @returns {string | undefined}
2725
+ */
2726
+ get tip() {
2727
+ const ret = wasm.lastusedindexresponse_tip(this.__wbg_ptr);
2728
+ let v1;
2729
+ if (ret[0] !== 0) {
2730
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
2731
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2732
+ }
2733
+ return v1;
2734
+ }
2735
+ }
2736
+ if (Symbol.dispose) LastUsedIndexResponse.prototype[Symbol.dispose] = LastUsedIndexResponse.prototype.free;
2737
+
2738
+ exports.LastUsedIndexResponse = LastUsedIndexResponse;
2739
+
2655
2740
  const LedgerWebFinalization = (typeof FinalizationRegistry === 'undefined')
2656
2741
  ? { register: () => {}, unregister: () => {} }
2657
2742
  : new FinalizationRegistry(ptr => wasm.__wbg_ledgerweb_free(ptr >>> 0, 1));
@@ -6748,6 +6833,11 @@ exports.__wbg_jadewebsocket_new = function(arg0) {
6748
6833
  return ret;
6749
6834
  };
6750
6835
 
6836
+ exports.__wbg_lastusedindexresponse_new = function(arg0) {
6837
+ const ret = LastUsedIndexResponse.__wrap(arg0);
6838
+ return ret;
6839
+ };
6840
+
6751
6841
  exports.__wbg_length_186546c51cd61acd = function(arg0) {
6752
6842
  const ret = arg0.length;
6753
6843
  return ret;
@@ -6758,7 +6848,7 @@ exports.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
6758
6848
  return ret;
6759
6849
  };
6760
6850
 
6761
- exports.__wbg_log_2368cdd9f0fe2010 = function(arg0, arg1) {
6851
+ exports.__wbg_log_d1e4a0ea206b998f = function(arg0, arg1) {
6762
6852
  console.log(getStringFromWasm0(arg0, arg1));
6763
6853
  };
6764
6854
 
@@ -6794,7 +6884,7 @@ exports.__wbg_new_2e3c58a15f39f5f9 = function(arg0, arg1) {
6794
6884
  const a = state0.a;
6795
6885
  state0.a = 0;
6796
6886
  try {
6797
- return __wbg_adapter_641(a, state0.b, arg0, arg1);
6887
+ return __wbg_adapter_647(a, state0.b, arg0, arg1);
6798
6888
  } finally {
6799
6889
  state0.a = a;
6800
6890
  }
@@ -7338,39 +7428,45 @@ exports.__wbg_xpub_new = function(arg0) {
7338
7428
  return ret;
7339
7429
  };
7340
7430
 
7341
- exports.__wbindgen_cast_0e6df167c5e3a9bf = function(arg0, arg1) {
7342
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1297, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1298, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7343
- const ret = makeMutClosure(arg0, arg1, 1297, __wbg_adapter_11);
7344
- return ret;
7345
- };
7346
-
7347
7431
  exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
7348
7432
  // Cast intrinsic for `Ref(String) -> Externref`.
7349
7433
  const ret = getStringFromWasm0(arg0, arg1);
7350
7434
  return ret;
7351
7435
  };
7352
7436
 
7437
+ exports.__wbindgen_cast_226189b342a397fe = function(arg0, arg1) {
7438
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1332, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 1333, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7439
+ const ret = makeMutClosure(arg0, arg1, 1332, __wbg_adapter_12);
7440
+ return ret;
7441
+ };
7442
+
7443
+ exports.__wbindgen_cast_29502e455aa89f54 = function(arg0, arg1) {
7444
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1470, function: Function { arguments: [], shim_idx: 1471, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7445
+ const ret = makeMutClosure(arg0, arg1, 1470, __wbg_adapter_19);
7446
+ return ret;
7447
+ };
7448
+
7353
7449
  exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
7354
7450
  // Cast intrinsic for `U64 -> Externref`.
7355
7451
  const ret = BigInt.asUintN(64, arg0);
7356
7452
  return ret;
7357
7453
  };
7358
7454
 
7359
- exports.__wbindgen_cast_8b268ed6c7d18412 = function(arg0, arg1) {
7360
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1297, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 1298, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7361
- const ret = makeMutClosure(arg0, arg1, 1297, __wbg_adapter_11);
7455
+ exports.__wbindgen_cast_64946e166c77d13b = function(arg0, arg1) {
7456
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1332, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1333, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7457
+ const ret = makeMutClosure(arg0, arg1, 1332, __wbg_adapter_12);
7362
7458
  return ret;
7363
7459
  };
7364
7460
 
7365
- exports.__wbindgen_cast_8b4b61caa2e0a23d = function(arg0, arg1) {
7366
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1899, function: Function { arguments: [], shim_idx: 1900, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7367
- const ret = makeMutClosure(arg0, arg1, 1899, __wbg_adapter_8);
7461
+ exports.__wbindgen_cast_8498ce9f6d02ec68 = function(arg0, arg1) {
7462
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1952, function: Function { arguments: [Externref], shim_idx: 1963, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7463
+ const ret = makeMutClosure(arg0, arg1, 1952, __wbg_adapter_25);
7368
7464
  return ret;
7369
7465
  };
7370
7466
 
7371
- exports.__wbindgen_cast_8f9558e6f0ce3420 = function(arg0, arg1) {
7372
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1936, function: Function { arguments: [Externref], shim_idx: 1947, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7373
- const ret = makeMutClosure(arg0, arg1, 1936, __wbg_adapter_27);
7467
+ exports.__wbindgen_cast_8e4b3b9f090f0e9f = function(arg0, arg1) {
7468
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 836, function: Function { arguments: [NamedExternref("HIDInputReportEvent")], shim_idx: 793, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7469
+ const ret = makeMutClosure(arg0, arg1, 836, __wbg_adapter_30);
7374
7470
  return ret;
7375
7471
  };
7376
7472
 
@@ -7380,27 +7476,27 @@ exports.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
7380
7476
  return ret;
7381
7477
  };
7382
7478
 
7383
- exports.__wbindgen_cast_9b2feb467ff52527 = function(arg0, arg1) {
7384
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1297, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 1298, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7385
- const ret = makeMutClosure(arg0, arg1, 1297, __wbg_adapter_11);
7479
+ exports.__wbindgen_cast_a5eca9837d7a56d8 = function(arg0, arg1) {
7480
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1332, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 1333, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7481
+ const ret = makeMutClosure(arg0, arg1, 1332, __wbg_adapter_12);
7386
7482
  return ret;
7387
7483
  };
7388
7484
 
7389
- exports.__wbindgen_cast_c5ee62b4aaae9530 = function(arg0, arg1) {
7390
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1445, function: Function { arguments: [], shim_idx: 1446, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7391
- const ret = makeMutClosure(arg0, arg1, 1445, __wbg_adapter_30);
7485
+ exports.__wbindgen_cast_c7181fb9120fd364 = function(arg0, arg1) {
7486
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1332, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 1333, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7487
+ const ret = makeMutClosure(arg0, arg1, 1332, __wbg_adapter_12);
7392
7488
  return ret;
7393
7489
  };
7394
7490
 
7395
- exports.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
7396
- // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
7397
- const ret = getArrayU8FromWasm0(arg0, arg1);
7491
+ exports.__wbindgen_cast_c8d7b74f3f2593d8 = function(arg0, arg1) {
7492
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1915, function: Function { arguments: [], shim_idx: 1916, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7493
+ const ret = makeMutClosure(arg0, arg1, 1915, __wbg_adapter_22);
7398
7494
  return ret;
7399
7495
  };
7400
7496
 
7401
- exports.__wbindgen_cast_cde02bc75695ac01 = function(arg0, arg1) {
7402
- // Cast intrinsic for `Closure(Closure { dtor_idx: 617, function: Function { arguments: [NamedExternref("HIDInputReportEvent")], shim_idx: 785, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7403
- const ret = makeMutClosure(arg0, arg1, 617, __wbg_adapter_18);
7497
+ exports.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
7498
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
7499
+ const ret = getArrayU8FromWasm0(arg0, arg1);
7404
7500
  return ret;
7405
7501
  };
7406
7502
 
@@ -7410,12 +7506,6 @@ exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
7410
7506
  return ret;
7411
7507
  };
7412
7508
 
7413
- exports.__wbindgen_cast_ff1a743c233958d7 = function(arg0, arg1) {
7414
- // Cast intrinsic for `Closure(Closure { dtor_idx: 1297, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 1298, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
7415
- const ret = makeMutClosure(arg0, arg1, 1297, __wbg_adapter_11);
7416
- return ret;
7417
- };
7418
-
7419
7509
  exports.__wbindgen_init_externref_table = function() {
7420
7510
  const table = wasm.__wbindgen_export_4;
7421
7511
  const offset = table.grow(4);
package/lwk_wasm_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lwk_node",
3
3
  "description": "Liquid Wallet Kit - WASM",
4
- "version": "0.13.1",
4
+ "version": "0.14.1",
5
5
  "license": "MIT OR BSD-2-Clause",
6
6
  "files": [
7
7
  "lwk_wasm_bg.wasm",