lwk_node 0.8.5 → 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/README.md CHANGED
@@ -90,3 +90,16 @@ With [twiggy](https://github.com/rustwasm/twiggy) is then possible to analyze th
90
90
  ```shell
91
91
  twiggy top -n 10 pkg/lwk_wasm_bg.wasm
92
92
  ```
93
+
94
+ ### Build for nodejs
95
+
96
+ ```shell
97
+ $ cd lwk_wasm
98
+ $ RUSTFLAGS="--cfg=web_sys_unstable_apis" CARGO_PROFILE_RELEASE_OPT_LEVEL=z wasm-pack build --target nodejs --out-dir pkg_node -- --features serial
99
+ ```
100
+
101
+ Rename the package to `lwk_node` so that we can publish it to npm.
102
+
103
+ ```shell
104
+ sed -i 's/"lwk_wasm"/"lwk_node"/g' pkg_node/package.json
105
+ ```
package/lwk_wasm.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function search_ledger_device(): Promise<HIDDevice>;
4
3
  /**
5
4
  * Wallet chain
6
5
  */
@@ -116,6 +115,8 @@ export class Contract {
116
115
  */
117
116
  constructor(domain: string, issuer_pubkey: string, name: string, precision: number, ticker: string, version: number);
118
117
  toString(): string;
118
+ domain(): string;
119
+ clone(): Contract;
119
120
  }
120
121
  /**
121
122
  * Wrapper of [`asyncr::EsploraClient`]
@@ -127,6 +128,10 @@ export class EsploraClient {
127
128
  */
128
129
  constructor(network: Network, url: string, waterfalls: boolean);
129
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>;
130
135
  broadcast(pset: Pset): Promise<Txid>;
131
136
  set_waterfalls_server_recipient(recipient: string): Promise<void>;
132
137
  }
@@ -181,11 +186,6 @@ export class Jade {
181
186
  keyoriginXpub(bip: Bip): Promise<string>;
182
187
  registerDescriptor(name: string, desc: WolletDescriptor): Promise<boolean>;
183
188
  }
184
- export class LedgerWeb {
185
- free(): void;
186
- constructor(hid_device: HIDDevice);
187
- get_version(): Promise<string>;
188
- }
189
189
  /**
190
190
  * Wrapper of [`bip39::Mnemonic`]
191
191
  */
@@ -470,6 +470,10 @@ export class TxBuilder {
470
470
  * Reissue an asset, wrapper of [`lwk_wollet::TxBuilder::reissue_asset()`]
471
471
  */
472
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;
473
477
  toString(): string;
474
478
  }
475
479
  /**
@@ -540,6 +544,7 @@ export class WalletTxOut {
540
544
  unblinded(): TxOutSecrets;
541
545
  wildcardIndex(): number;
542
546
  extInt(): Chain;
547
+ address(): Address;
543
548
  }
544
549
  /**
545
550
  * Wrapper of [`lwk_wollet::Wollet`]
@@ -561,6 +566,14 @@ export class Wollet {
561
566
  applyUpdate(update: Update): void;
562
567
  balance(): any;
563
568
  transactions(): (WalletTx)[];
569
+ /**
570
+ * Get the unspent transaction outputs of the wallet
571
+ */
572
+ utxos(): (WalletTxOut)[];
573
+ /**
574
+ * Get all the transaction outputs of the wallet, both spent and unspent
575
+ */
576
+ txos(): (WalletTxOut)[];
564
577
  /**
565
578
  * Finalize and consume the given PSET, returning the finalized one
566
579
  */
package/lwk_wasm.js CHANGED
@@ -102,11 +102,6 @@ function handleError(f, args) {
102
102
  }
103
103
  }
104
104
 
105
- function getArrayU8FromWasm0(ptr, len) {
106
- ptr = ptr >>> 0;
107
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
108
- }
109
-
110
105
  function isLikeNone(x) {
111
106
  return x === undefined || x === null;
112
107
  }
@@ -213,10 +208,9 @@ function takeFromExternrefTable0(idx) {
213
208
  return value;
214
209
  }
215
210
 
216
- function _assertClass(instance, klass) {
217
- if (!(instance instanceof klass)) {
218
- throw new Error(`expected instance of ${klass.name}`);
219
- }
211
+ function getArrayU8FromWasm0(ptr, len) {
212
+ ptr = ptr >>> 0;
213
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
220
214
  }
221
215
 
222
216
  function getArrayJsValueFromWasm0(ptr, len) {
@@ -230,6 +224,12 @@ function getArrayJsValueFromWasm0(ptr, len) {
230
224
  return result;
231
225
  }
232
226
 
227
+ function _assertClass(instance, klass) {
228
+ if (!(instance instanceof klass)) {
229
+ throw new Error(`expected instance of ${klass.name}`);
230
+ }
231
+ }
232
+
233
233
  function passArrayJsValueToWasm0(array, malloc) {
234
234
  const ptr = malloc(array.length * 4, 4) >>> 0;
235
235
  const mem = getDataViewMemory0();
@@ -267,20 +267,12 @@ function passArray32ToWasm0(arg, malloc) {
267
267
  WASM_VECTOR_LEN = arg.length;
268
268
  return ptr;
269
269
  }
270
- /**
271
- * @returns {Promise<HIDDevice>}
272
- */
273
- module.exports.search_ledger_device = function() {
274
- const ret = wasm.search_ledger_device();
275
- return ret;
276
- };
277
-
278
270
  function __wbg_adapter_36(arg0, arg1, arg2) {
279
- wasm.closure965_externref_shim(arg0, arg1, arg2);
271
+ wasm.closure1004_externref_shim(arg0, arg1, arg2);
280
272
  }
281
273
 
282
- function __wbg_adapter_379(arg0, arg1, arg2, arg3) {
283
- wasm.closure1667_externref_shim(arg0, arg1, arg2, arg3);
274
+ function __wbg_adapter_373(arg0, arg1, arg2, arg3) {
275
+ wasm.closure1703_externref_shim(arg0, arg1, arg2, arg3);
284
276
  }
285
277
 
286
278
  /**
@@ -745,6 +737,14 @@ const ContractFinalization = (typeof FinalizationRegistry === 'undefined')
745
737
  */
746
738
  class Contract {
747
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
+
748
748
  __destroy_into_raw() {
749
749
  const ptr = this.__wbg_ptr;
750
750
  this.__wbg_ptr = 0;
@@ -797,6 +797,28 @@ class Contract {
797
797
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
798
798
  }
799
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
+ }
800
822
  }
801
823
  module.exports.Contract = Contract;
802
824
 
@@ -851,6 +873,17 @@ class EsploraClient {
851
873
  const ret = wasm.esploraclient_fullScan(this.__wbg_ptr, wollet.__wbg_ptr);
852
874
  return ret;
853
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
+ }
854
887
  /**
855
888
  * @param {Pset} pset
856
889
  * @returns {Promise<Txid>}
@@ -1099,42 +1132,6 @@ class Jade {
1099
1132
  }
1100
1133
  module.exports.Jade = Jade;
1101
1134
 
1102
- const LedgerWebFinalization = (typeof FinalizationRegistry === 'undefined')
1103
- ? { register: () => {}, unregister: () => {} }
1104
- : new FinalizationRegistry(ptr => wasm.__wbg_ledgerweb_free(ptr >>> 0, 1));
1105
-
1106
- class LedgerWeb {
1107
-
1108
- __destroy_into_raw() {
1109
- const ptr = this.__wbg_ptr;
1110
- this.__wbg_ptr = 0;
1111
- LedgerWebFinalization.unregister(this);
1112
- return ptr;
1113
- }
1114
-
1115
- free() {
1116
- const ptr = this.__destroy_into_raw();
1117
- wasm.__wbg_ledgerweb_free(ptr, 0);
1118
- }
1119
- /**
1120
- * @param {HIDDevice} hid_device
1121
- */
1122
- constructor(hid_device) {
1123
- const ret = wasm.ledgerweb_new(hid_device);
1124
- this.__wbg_ptr = ret >>> 0;
1125
- LedgerWebFinalization.register(this, this.__wbg_ptr, this);
1126
- return this;
1127
- }
1128
- /**
1129
- * @returns {Promise<string>}
1130
- */
1131
- get_version() {
1132
- const ret = wasm.ledgerweb_get_version(this.__wbg_ptr);
1133
- return ret;
1134
- }
1135
- }
1136
- module.exports.LedgerWeb = LedgerWeb;
1137
-
1138
1135
  const MnemonicFinalization = (typeof FinalizationRegistry === 'undefined')
1139
1136
  ? { register: () => {}, unregister: () => {} }
1140
1137
  : new FinalizationRegistry(ptr => wasm.__wbg_mnemonic_free(ptr >>> 0, 1));
@@ -1397,6 +1394,13 @@ class OutPoint {
1397
1394
  return obj;
1398
1395
  }
1399
1396
 
1397
+ static __unwrap(jsValue) {
1398
+ if (!(jsValue instanceof OutPoint)) {
1399
+ return 0;
1400
+ }
1401
+ return jsValue.__destroy_into_raw();
1402
+ }
1403
+
1400
1404
  __destroy_into_raw() {
1401
1405
  const ptr = this.__wbg_ptr;
1402
1406
  this.__wbg_ptr = 0;
@@ -2457,6 +2461,18 @@ class TxBuilder {
2457
2461
  }
2458
2462
  return TxBuilder.__wrap(ret[0]);
2459
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
+ }
2460
2476
  /**
2461
2477
  * @returns {string}
2462
2478
  */
@@ -2915,6 +2931,13 @@ class WalletTxOut {
2915
2931
  const ret = wasm.wallettxout_extInt(this.__wbg_ptr);
2916
2932
  return ret;
2917
2933
  }
2934
+ /**
2935
+ * @returns {Address}
2936
+ */
2937
+ address() {
2938
+ const ret = wasm.wallettxout_address(this.__wbg_ptr);
2939
+ return Address.__wrap(ret);
2940
+ }
2918
2941
  }
2919
2942
  module.exports.WalletTxOut = WalletTxOut;
2920
2943
 
@@ -3013,6 +3036,32 @@ class Wollet {
3013
3036
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
3014
3037
  return v1;
3015
3038
  }
3039
+ /**
3040
+ * Get the unspent transaction outputs of the wallet
3041
+ * @returns {(WalletTxOut)[]}
3042
+ */
3043
+ utxos() {
3044
+ const ret = wasm.wollet_utxos(this.__wbg_ptr);
3045
+ if (ret[3]) {
3046
+ throw takeFromExternrefTable0(ret[2]);
3047
+ }
3048
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
3049
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
3050
+ return v1;
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
+ }
3016
3065
  /**
3017
3066
  * Finalize and consume the given PSET, returning the finalized one
3018
3067
  * @param {Pset} pset
@@ -3307,16 +3356,11 @@ module.exports.__wbg_fetch_229368eecee9d217 = function(arg0, arg1) {
3307
3356
  return ret;
3308
3357
  };
3309
3358
 
3310
- module.exports.__wbg_fetch_b335d17f45a8b5a1 = function(arg0) {
3359
+ module.exports.__wbg_fetch_4465c2b10f21a927 = function(arg0) {
3311
3360
  const ret = fetch(arg0);
3312
3361
  return ret;
3313
3362
  };
3314
3363
 
3315
- module.exports.__wbg_getDevices_e3b981f8ab3f64ca = function(arg0) {
3316
- const ret = arg0.getDevices();
3317
- return ret;
3318
- };
3319
-
3320
3364
  module.exports.__wbg_getPorts_bcbc416782ca640e = function(arg0) {
3321
3365
  const ret = arg0.getPorts();
3322
3366
  return ret;
@@ -3351,22 +3395,6 @@ module.exports.__wbg_headers_24e3e19fe3f187c0 = function(arg0) {
3351
3395
  return ret;
3352
3396
  };
3353
3397
 
3354
- module.exports.__wbg_hid_94d3748076cc70a5 = function(arg0) {
3355
- const ret = arg0.hid;
3356
- return ret;
3357
- };
3358
-
3359
- module.exports.__wbg_instanceof_HidDevice_7985a551d7ddb50b = function(arg0) {
3360
- let result;
3361
- try {
3362
- result = arg0 instanceof HIDDevice;
3363
- } catch (_) {
3364
- result = false;
3365
- }
3366
- const ret = result;
3367
- return ret;
3368
- };
3369
-
3370
3398
  module.exports.__wbg_instanceof_Response_d3453657e10c4300 = function(arg0) {
3371
3399
  let result;
3372
3400
  try {
@@ -3430,10 +3458,6 @@ module.exports.__wbg_length_d65cf0786bfc5739 = function(arg0) {
3430
3458
  return ret;
3431
3459
  };
3432
3460
 
3433
- module.exports.__wbg_log_5f82480ac7a101b6 = function(arg0, arg1) {
3434
- console.log(arg0, arg1);
3435
- };
3436
-
3437
3461
  module.exports.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
3438
3462
  const ret = arg0.msCrypto;
3439
3463
  return ret;
@@ -3466,7 +3490,7 @@ module.exports.__wbg_new_3d446df9155128ef = function(arg0, arg1) {
3466
3490
  const a = state0.a;
3467
3491
  state0.a = 0;
3468
3492
  try {
3469
- return __wbg_adapter_379(a, state0.b, arg0, arg1);
3493
+ return __wbg_adapter_373(a, state0.b, arg0, arg1);
3470
3494
  } finally {
3471
3495
  state0.a = a;
3472
3496
  }
@@ -3548,6 +3572,11 @@ module.exports.__wbg_optionwallettxout_new = function(arg0) {
3548
3572
  return ret;
3549
3573
  };
3550
3574
 
3575
+ module.exports.__wbg_outpoint_unwrap = function(arg0) {
3576
+ const ret = OutPoint.__unwrap(arg0);
3577
+ return ret;
3578
+ };
3579
+
3551
3580
  module.exports.__wbg_process_5c1d670bc53614b8 = function(arg0) {
3552
3581
  const ret = arg0.process;
3553
3582
  return ret;
@@ -3596,11 +3625,6 @@ module.exports.__wbg_recipient_new = function(arg0) {
3596
3625
  return ret;
3597
3626
  };
3598
3627
 
3599
- module.exports.__wbg_requestDevice_80cf95954319a779 = function(arg0, arg1) {
3600
- const ret = arg0.requestDevice(arg1);
3601
- return ret;
3602
- };
3603
-
3604
3628
  module.exports.__wbg_requestPort_4017b10c6ed80bc9 = function(arg0, arg1) {
3605
3629
  const ret = arg0.requestPort(arg1);
3606
3630
  return ret;
@@ -3621,11 +3645,6 @@ module.exports.__wbg_resolve_0bf7c44d641804f9 = function(arg0) {
3621
3645
  return ret;
3622
3646
  };
3623
3647
 
3624
- module.exports.__wbg_sendReport_ebe68f3fc9930b4d = function() { return handleError(function (arg0, arg1, arg2, arg3) {
3625
- const ret = arg0.sendReport(arg1, getArrayU8FromWasm0(arg2, arg3));
3626
- return ret;
3627
- }, arguments) };
3628
-
3629
3648
  module.exports.__wbg_serial_af8521e375ee4947 = function(arg0) {
3630
3649
  const ret = arg0.serial;
3631
3650
  return ret;
@@ -3665,10 +3684,6 @@ module.exports.__wbg_setcredentials_cfc15e48e3a3a535 = function(arg0, arg1) {
3665
3684
  arg0.credentials = __wbindgen_enum_RequestCredentials[arg1];
3666
3685
  };
3667
3686
 
3668
- module.exports.__wbg_setfilters_51bbf67999aa61d4 = function(arg0, arg1) {
3669
- arg0.filters = arg1;
3670
- };
3671
-
3672
3687
  module.exports.__wbg_setfilters_6826706298fde705 = function(arg0, arg1) {
3673
3688
  arg0.filters = arg1;
3674
3689
  };
@@ -3777,6 +3792,11 @@ module.exports.__wbg_wallettx_new = function(arg0) {
3777
3792
  return ret;
3778
3793
  };
3779
3794
 
3795
+ module.exports.__wbg_wallettxout_new = function(arg0) {
3796
+ const ret = WalletTxOut.__wrap(arg0);
3797
+ return ret;
3798
+ };
3799
+
3780
3800
  module.exports.__wbg_wolletdescriptor_new = function(arg0) {
3781
3801
  const ret = WolletDescriptor.__wrap(arg0);
3782
3802
  return ret;
@@ -3817,8 +3837,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
3817
3837
  return ret;
3818
3838
  };
3819
3839
 
3820
- module.exports.__wbindgen_closure_wrapper8773 = function(arg0, arg1, arg2) {
3821
- const ret = makeMutClosure(arg0, arg1, 966, __wbg_adapter_36);
3840
+ module.exports.__wbindgen_closure_wrapper9199 = function(arg0, arg1, arg2) {
3841
+ const ret = makeMutClosure(arg0, arg1, 1005, __wbg_adapter_36);
3822
3842
  return ret;
3823
3843
  };
3824
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.5",
4
+ "version": "0.8.8",
5
5
  "license": "MIT OR BSD-2-Clause",
6
6
  "files": [
7
7
  "lwk_wasm_bg.wasm",