lwk_node 0.8.6 → 0.8.8

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
@@ -115,6 +115,8 @@ export class Contract {
115
115
  */
116
116
  constructor(domain: string, issuer_pubkey: string, name: string, precision: number, ticker: string, version: number);
117
117
  toString(): string;
118
+ domain(): string;
119
+ clone(): Contract;
118
120
  }
119
121
  /**
120
122
  * Wrapper of [`asyncr::EsploraClient`]
@@ -126,6 +128,10 @@ export class EsploraClient {
126
128
  */
127
129
  constructor(network: Network, url: string, waterfalls: boolean);
128
130
  fullScan(wollet: Wollet): Promise<Update | undefined>;
131
+ /**
132
+ * Scan the blockchain for the scripts generated by a watch-only wallet up to a specified derivation index
133
+ */
134
+ fullScanToIndex(wollet: Wollet, index: number): Promise<Update | undefined>;
129
135
  broadcast(pset: Pset): Promise<Txid>;
130
136
  set_waterfalls_server_recipient(recipient: string): Promise<void>;
131
137
  }
@@ -464,6 +470,10 @@ export class TxBuilder {
464
470
  * Reissue an asset, wrapper of [`lwk_wollet::TxBuilder::reissue_asset()`]
465
471
  */
466
472
  reissueAsset(asset_to_reissue: AssetId, satoshi_to_reissue: bigint, asset_receiver?: Address, issuance_tx?: Transaction): TxBuilder;
473
+ /**
474
+ * Manual coin selection, wrapper of [`lwk_wollet::TxBuilder::set_wallet_utxos()`]
475
+ */
476
+ setWalletUtxos(outpoints: (OutPoint)[]): TxBuilder;
467
477
  toString(): string;
468
478
  }
469
479
  /**
@@ -560,6 +570,10 @@ export class Wollet {
560
570
  * Get the unspent transaction outputs of the wallet
561
571
  */
562
572
  utxos(): (WalletTxOut)[];
573
+ /**
574
+ * Get all the transaction outputs of the wallet, both spent and unspent
575
+ */
576
+ txos(): (WalletTxOut)[];
563
577
  /**
564
578
  * Finalize and consume the given PSET, returning the finalized one
565
579
  */
package/lwk_wasm.js CHANGED
@@ -208,26 +208,9 @@ function takeFromExternrefTable0(idx) {
208
208
  return value;
209
209
  }
210
210
 
211
- function _assertClass(instance, klass) {
212
- if (!(instance instanceof klass)) {
213
- throw new Error(`expected instance of ${klass.name}`);
214
- }
215
- }
216
-
217
- let cachedUint32ArrayMemory0 = null;
218
-
219
- function getUint32ArrayMemory0() {
220
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
221
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
222
- }
223
- return cachedUint32ArrayMemory0;
224
- }
225
-
226
- function passArray32ToWasm0(arg, malloc) {
227
- const ptr = malloc(arg.length * 4, 4) >>> 0;
228
- getUint32ArrayMemory0().set(arg, ptr / 4);
229
- WASM_VECTOR_LEN = arg.length;
230
- return ptr;
211
+ function getArrayU8FromWasm0(ptr, len) {
212
+ ptr = ptr >>> 0;
213
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
231
214
  }
232
215
 
233
216
  function getArrayJsValueFromWasm0(ptr, len) {
@@ -241,9 +224,20 @@ function getArrayJsValueFromWasm0(ptr, len) {
241
224
  return result;
242
225
  }
243
226
 
244
- function getArrayU8FromWasm0(ptr, len) {
245
- ptr = ptr >>> 0;
246
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
227
+ function _assertClass(instance, klass) {
228
+ if (!(instance instanceof klass)) {
229
+ throw new Error(`expected instance of ${klass.name}`);
230
+ }
231
+ }
232
+
233
+ function passArrayJsValueToWasm0(array, malloc) {
234
+ const ptr = malloc(array.length * 4, 4) >>> 0;
235
+ const mem = getDataViewMemory0();
236
+ for (let i = 0; i < array.length; i++) {
237
+ mem.setUint32(ptr + 4 * i, addToExternrefTable0(array[i]), true);
238
+ }
239
+ WASM_VECTOR_LEN = array.length;
240
+ return ptr;
247
241
  }
248
242
 
249
243
  function passArray8ToWasm0(arg, malloc) {
@@ -253,26 +247,32 @@ function passArray8ToWasm0(arg, malloc) {
253
247
  return ptr;
254
248
  }
255
249
 
250
+ let cachedUint32ArrayMemory0 = null;
251
+
252
+ function getUint32ArrayMemory0() {
253
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
254
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
255
+ }
256
+ return cachedUint32ArrayMemory0;
257
+ }
258
+
256
259
  function getArrayU32FromWasm0(ptr, len) {
257
260
  ptr = ptr >>> 0;
258
261
  return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
259
262
  }
260
263
 
261
- function passArrayJsValueToWasm0(array, malloc) {
262
- const ptr = malloc(array.length * 4, 4) >>> 0;
263
- const mem = getDataViewMemory0();
264
- for (let i = 0; i < array.length; i++) {
265
- mem.setUint32(ptr + 4 * i, addToExternrefTable0(array[i]), true);
266
- }
267
- WASM_VECTOR_LEN = array.length;
264
+ function passArray32ToWasm0(arg, malloc) {
265
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
266
+ getUint32ArrayMemory0().set(arg, ptr / 4);
267
+ WASM_VECTOR_LEN = arg.length;
268
268
  return ptr;
269
269
  }
270
270
  function __wbg_adapter_36(arg0, arg1, arg2) {
271
- wasm.closure952_externref_shim(arg0, arg1, arg2);
271
+ wasm.closure1004_externref_shim(arg0, arg1, arg2);
272
272
  }
273
273
 
274
- function __wbg_adapter_366(arg0, arg1, arg2, arg3) {
275
- wasm.closure1654_externref_shim(arg0, arg1, arg2, arg3);
274
+ function __wbg_adapter_373(arg0, arg1, arg2, arg3) {
275
+ wasm.closure1703_externref_shim(arg0, arg1, arg2, arg3);
276
276
  }
277
277
 
278
278
  /**
@@ -737,6 +737,14 @@ const ContractFinalization = (typeof FinalizationRegistry === 'undefined')
737
737
  */
738
738
  class Contract {
739
739
 
740
+ static __wrap(ptr) {
741
+ ptr = ptr >>> 0;
742
+ const obj = Object.create(Contract.prototype);
743
+ obj.__wbg_ptr = ptr;
744
+ ContractFinalization.register(obj, obj.__wbg_ptr, obj);
745
+ return obj;
746
+ }
747
+
740
748
  __destroy_into_raw() {
741
749
  const ptr = this.__wbg_ptr;
742
750
  this.__wbg_ptr = 0;
@@ -789,6 +797,28 @@ class Contract {
789
797
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
790
798
  }
791
799
  }
800
+ /**
801
+ * @returns {string}
802
+ */
803
+ domain() {
804
+ let deferred1_0;
805
+ let deferred1_1;
806
+ try {
807
+ const ret = wasm.contract_domain(this.__wbg_ptr);
808
+ deferred1_0 = ret[0];
809
+ deferred1_1 = ret[1];
810
+ return getStringFromWasm0(ret[0], ret[1]);
811
+ } finally {
812
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
813
+ }
814
+ }
815
+ /**
816
+ * @returns {Contract}
817
+ */
818
+ clone() {
819
+ const ret = wasm.contract_clone(this.__wbg_ptr);
820
+ return Contract.__wrap(ret);
821
+ }
792
822
  }
793
823
  module.exports.Contract = Contract;
794
824
 
@@ -843,6 +873,17 @@ class EsploraClient {
843
873
  const ret = wasm.esploraclient_fullScan(this.__wbg_ptr, wollet.__wbg_ptr);
844
874
  return ret;
845
875
  }
876
+ /**
877
+ * Scan the blockchain for the scripts generated by a watch-only wallet up to a specified derivation index
878
+ * @param {Wollet} wollet
879
+ * @param {number} index
880
+ * @returns {Promise<Update | undefined>}
881
+ */
882
+ fullScanToIndex(wollet, index) {
883
+ _assertClass(wollet, Wollet);
884
+ const ret = wasm.esploraclient_fullScanToIndex(this.__wbg_ptr, wollet.__wbg_ptr, index);
885
+ return ret;
886
+ }
846
887
  /**
847
888
  * @param {Pset} pset
848
889
  * @returns {Promise<Txid>}
@@ -1353,6 +1394,13 @@ class OutPoint {
1353
1394
  return obj;
1354
1395
  }
1355
1396
 
1397
+ static __unwrap(jsValue) {
1398
+ if (!(jsValue instanceof OutPoint)) {
1399
+ return 0;
1400
+ }
1401
+ return jsValue.__destroy_into_raw();
1402
+ }
1403
+
1356
1404
  __destroy_into_raw() {
1357
1405
  const ptr = this.__wbg_ptr;
1358
1406
  this.__wbg_ptr = 0;
@@ -2413,6 +2461,18 @@ class TxBuilder {
2413
2461
  }
2414
2462
  return TxBuilder.__wrap(ret[0]);
2415
2463
  }
2464
+ /**
2465
+ * Manual coin selection, wrapper of [`lwk_wollet::TxBuilder::set_wallet_utxos()`]
2466
+ * @param {(OutPoint)[]} outpoints
2467
+ * @returns {TxBuilder}
2468
+ */
2469
+ setWalletUtxos(outpoints) {
2470
+ const ptr = this.__destroy_into_raw();
2471
+ const ptr0 = passArrayJsValueToWasm0(outpoints, wasm.__wbindgen_malloc);
2472
+ const len0 = WASM_VECTOR_LEN;
2473
+ const ret = wasm.txbuilder_setWalletUtxos(ptr, ptr0, len0);
2474
+ return TxBuilder.__wrap(ret);
2475
+ }
2416
2476
  /**
2417
2477
  * @returns {string}
2418
2478
  */
@@ -2989,6 +3049,19 @@ class Wollet {
2989
3049
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2990
3050
  return v1;
2991
3051
  }
3052
+ /**
3053
+ * Get all the transaction outputs of the wallet, both spent and unspent
3054
+ * @returns {(WalletTxOut)[]}
3055
+ */
3056
+ txos() {
3057
+ const ret = wasm.wollet_txos(this.__wbg_ptr);
3058
+ if (ret[3]) {
3059
+ throw takeFromExternrefTable0(ret[2]);
3060
+ }
3061
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3062
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
3063
+ return v1;
3064
+ }
2992
3065
  /**
2993
3066
  * Finalize and consume the given PSET, returning the finalized one
2994
3067
  * @param {Pset} pset
@@ -3417,7 +3490,7 @@ module.exports.__wbg_new_3d446df9155128ef = function(arg0, arg1) {
3417
3490
  const a = state0.a;
3418
3491
  state0.a = 0;
3419
3492
  try {
3420
- return __wbg_adapter_366(a, state0.b, arg0, arg1);
3493
+ return __wbg_adapter_373(a, state0.b, arg0, arg1);
3421
3494
  } finally {
3422
3495
  state0.a = a;
3423
3496
  }
@@ -3499,6 +3572,11 @@ module.exports.__wbg_optionwallettxout_new = function(arg0) {
3499
3572
  return ret;
3500
3573
  };
3501
3574
 
3575
+ module.exports.__wbg_outpoint_unwrap = function(arg0) {
3576
+ const ret = OutPoint.__unwrap(arg0);
3577
+ return ret;
3578
+ };
3579
+
3502
3580
  module.exports.__wbg_process_5c1d670bc53614b8 = function(arg0) {
3503
3581
  const ret = arg0.process;
3504
3582
  return ret;
@@ -3759,8 +3837,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
3759
3837
  return ret;
3760
3838
  };
3761
3839
 
3762
- module.exports.__wbindgen_closure_wrapper8715 = function(arg0, arg1, arg2) {
3763
- const ret = makeMutClosure(arg0, arg1, 953, __wbg_adapter_36);
3840
+ module.exports.__wbindgen_closure_wrapper9199 = function(arg0, arg1, arg2) {
3841
+ const ret = makeMutClosure(arg0, arg1, 1005, __wbg_adapter_36);
3764
3842
  return ret;
3765
3843
  };
3766
3844
 
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.8.6",
4
+ "version": "0.8.8",
5
5
  "license": "MIT OR BSD-2-Clause",
6
6
  "files": [
7
7
  "lwk_wasm_bg.wasm",
@@ -10,4 +10,4 @@
10
10
  ],
11
11
  "main": "lwk_wasm.js",
12
12
  "types": "lwk_wasm.d.ts"
13
- }
13
+ }