lwk_node 0.9.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lwk_wasm.d.ts CHANGED
@@ -59,6 +59,67 @@ export class AddressResult {
59
59
  address(): Address;
60
60
  index(): number;
61
61
  }
62
+ /**
63
+ * Wrapper of [`lwk_wollet::amp0::Amp0`]
64
+ */
65
+ export class Amp0 {
66
+ private constructor();
67
+ free(): void;
68
+ /**
69
+ * Create a new AMP0 context for the specified network
70
+ */
71
+ static newWithNetwork(network: Network, username: string, password: string, amp_id: string): Promise<Amp0>;
72
+ /**
73
+ * Create a new AMP0 context for testnet
74
+ */
75
+ static netTestnet(username: string, password: string, amp_id: string): Promise<Amp0>;
76
+ /**
77
+ * Create a new AMP0 context for mainnet
78
+ */
79
+ static newMainnet(username: string, password: string, amp_id: string): Promise<Amp0>;
80
+ /**
81
+ * Index of the last returned address
82
+ *
83
+ * Use this and [`crate::EsploraClient::full_scan_to_index()`] to sync the `Wollet`
84
+ */
85
+ lastIndex(): number;
86
+ /**
87
+ * AMP ID
88
+ */
89
+ ampId(): string;
90
+ /**
91
+ * Get an address
92
+ *
93
+ * If `index` is None, a new address is returned.
94
+ */
95
+ address(index?: number | null): Promise<AddressResult>;
96
+ /**
97
+ * The LWK watch-only wallet corresponding to the AMP0 (sub)account.
98
+ */
99
+ wollet(): Wollet;
100
+ /**
101
+ * Ask AMP0 server to cosign
102
+ */
103
+ sign(amp0pset: Amp0Pset): Promise<Transaction>;
104
+ }
105
+ /**
106
+ * Wrapper of [`lwk_wollet::amp0::Amp0Pset`]
107
+ */
108
+ export class Amp0Pset {
109
+ free(): void;
110
+ /**
111
+ * Creates a `Amp0Pset`
112
+ */
113
+ constructor(pset: Pset, blinding_nonces: string[]);
114
+ /**
115
+ * Get the PSET
116
+ */
117
+ pset(): Pset;
118
+ /**
119
+ * Get the blinding nonces
120
+ */
121
+ blindingNonces(): string[];
122
+ }
62
123
  /**
63
124
  * Wrapper of [`lwk_wollet::amp2::Amp2`]
64
125
  */
@@ -101,6 +162,15 @@ export class AssetId {
101
162
  constructor(asset_id: string);
102
163
  toString(): string;
103
164
  }
165
+ /**
166
+ * A collection of asset identifiers. wrapper of [`Vec<elements::AssetId>`]
167
+ */
168
+ export class AssetIds {
169
+ private constructor();
170
+ free(): void;
171
+ static empty(): AssetIds;
172
+ toString(): string;
173
+ }
104
174
  export class AssetMeta {
105
175
  private constructor();
106
176
  free(): void;
@@ -148,12 +218,13 @@ export class EsploraClient {
148
218
  /**
149
219
  * Creates a client, wrapper of [`asyncr::EsploraClient`]
150
220
  */
151
- constructor(network: Network, url: string, waterfalls: boolean, concurrency: number);
221
+ constructor(network: Network, url: string, waterfalls: boolean, concurrency: number, utxo_only: boolean);
152
222
  fullScan(wollet: Wollet): Promise<Update | undefined>;
153
223
  /**
154
224
  * Scan the blockchain for the scripts generated by a watch-only wallet up to a specified derivation index
155
225
  */
156
226
  fullScanToIndex(wollet: Wollet, index: number): Promise<Update | undefined>;
227
+ broadcastTx(tx: Transaction): Promise<Txid>;
157
228
  broadcast(pset: Pset): Promise<Txid>;
158
229
  set_waterfalls_server_recipient(recipient: string): Promise<void>;
159
230
  }
@@ -454,10 +525,22 @@ export class Recipient {
454
525
  export class Registry {
455
526
  private constructor();
456
527
  free(): void;
457
- static new(url: string): Registry;
458
- static defaultForNetwork(network: Network): Registry;
528
+ static new(url: string, asset_ids: AssetIds): Promise<Registry>;
529
+ static defaultForNetwork(network: Network, asset_ids: AssetIds): Promise<Registry>;
530
+ static defaultHardcodedForNetwork(network: Network): Registry;
459
531
  fetchWithTx(asset_id: AssetId, client: EsploraClient): Promise<AssetMeta>;
460
532
  post(data: RegistryPost): Promise<void>;
533
+ get(asset_id: AssetId): RegistryData | undefined;
534
+ getAssetOfToken(token_id: AssetId): RegistryData | undefined;
535
+ addContracts(pset: Pset): Pset;
536
+ }
537
+ export class RegistryData {
538
+ private constructor();
539
+ free(): void;
540
+ precision(): number;
541
+ ticker(): string;
542
+ name(): string;
543
+ domain(): string;
461
544
  }
462
545
  export class RegistryPost {
463
546
  free(): void;
@@ -544,6 +627,10 @@ export class TxBuilder {
544
627
  * Build the transaction
545
628
  */
546
629
  finish(wollet: Wollet): Pset;
630
+ /**
631
+ * Build the transaction for AMP0
632
+ */
633
+ finishForAmp0(wollet: Wollet): Amp0Pset;
547
634
  /**
548
635
  * Set the fee rate
549
636
  */
@@ -572,6 +659,10 @@ export class TxBuilder {
572
659
  * Burn satoshi units of the given asset
573
660
  */
574
661
  addBurn(satoshi: bigint, asset: AssetId): TxBuilder;
662
+ /**
663
+ * Add explicit recipient
664
+ */
665
+ addExplicitRecipient(address: Address, satoshi: bigint, asset: AssetId): TxBuilder;
575
666
  /**
576
667
  * Issue an asset, wrapper of [`lwk_wollet::TxBuilder::issue_asset()`]
577
668
  */
@@ -598,6 +689,19 @@ export class TxOutSecrets {
598
689
  assetBlindingFactor(): string;
599
690
  value(): bigint;
600
691
  valueBlindingFactor(): string;
692
+ isExplicit(): boolean;
693
+ /**
694
+ * Get the asset commitment
695
+ *
696
+ * If the output is explicit, returns the empty string
697
+ */
698
+ assetCommitment(): string;
699
+ /**
700
+ * Get the value commitment
701
+ *
702
+ * If the output is explicit, returns the empty string
703
+ */
704
+ valueCommitment(): string;
601
705
  }
602
706
  /**
603
707
  * A valid transaction identifier.
@@ -698,7 +802,9 @@ export class Wollet {
698
802
  address(index?: number | null): AddressResult;
699
803
  addressFullPath(index: number): Uint32Array;
700
804
  applyUpdate(update: Update): void;
805
+ applyTransaction(tx: Transaction): void;
701
806
  balance(): any;
807
+ assetsOwned(): AssetIds;
702
808
  transactions(): WalletTx[];
703
809
  /**
704
810
  * Get the unspent transaction outputs of the wallet
@@ -720,6 +826,10 @@ export class Wollet {
720
826
  * wraps [lwk_wollet::Wollet::never_scanned()]
721
827
  */
722
828
  neverScanned(): boolean;
829
+ /**
830
+ * Whether the wallet is AMP0
831
+ */
832
+ isAmp0(): boolean;
723
833
  }
724
834
  /**
725
835
  * Wrapper of [`lwk_wollet::WolletDescriptor`]
@@ -733,6 +843,10 @@ export class WolletDescriptor {
733
843
  toString(): string;
734
844
  static newMultiWshSlip77(threshold: number, participants: string[]): WolletDescriptor;
735
845
  isMainnet(): boolean;
846
+ /**
847
+ * Whether the descriptor is AMP0
848
+ */
849
+ isAmp0(): boolean;
736
850
  }
737
851
  /**
738
852
  * Wrapper of [`bip32::Xpub`]
package/lwk_wasm.js CHANGED
@@ -219,13 +219,6 @@ function _assertClass(instance, klass) {
219
219
  }
220
220
  }
221
221
 
222
- function passArray8ToWasm0(arg, malloc) {
223
- const ptr = malloc(arg.length * 1, 1) >>> 0;
224
- getUint8ArrayMemory0().set(arg, ptr / 1);
225
- WASM_VECTOR_LEN = arg.length;
226
- return ptr;
227
- }
228
-
229
222
  function passArrayJsValueToWasm0(array, malloc) {
230
223
  const ptr = malloc(array.length * 4, 4) >>> 0;
231
224
  for (let i = 0; i < array.length; i++) {
@@ -235,6 +228,13 @@ function passArrayJsValueToWasm0(array, malloc) {
235
228
  WASM_VECTOR_LEN = array.length;
236
229
  return ptr;
237
230
  }
231
+ /**
232
+ * @returns {Promise<HIDDevice>}
233
+ */
234
+ module.exports.searchLedgerDevice = function() {
235
+ const ret = wasm.searchLedgerDevice();
236
+ return ret;
237
+ };
238
238
 
239
239
  let cachedUint32ArrayMemory0 = null;
240
240
 
@@ -263,28 +263,27 @@ function getArrayJsValueFromWasm0(ptr, len) {
263
263
  return result;
264
264
  }
265
265
 
266
+ function passArray8ToWasm0(arg, malloc) {
267
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
268
+ getUint8ArrayMemory0().set(arg, ptr / 1);
269
+ WASM_VECTOR_LEN = arg.length;
270
+ return ptr;
271
+ }
272
+
266
273
  function getArrayU32FromWasm0(ptr, len) {
267
274
  ptr = ptr >>> 0;
268
275
  return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
269
276
  }
270
- /**
271
- * @returns {Promise<HIDDevice>}
272
- */
273
- module.exports.searchLedgerDevice = function() {
274
- const ret = wasm.searchLedgerDevice();
275
- return ret;
276
- };
277
-
278
277
  function __wbg_adapter_36(arg0, arg1, arg2) {
279
- wasm.closure285_externref_shim(arg0, arg1, arg2);
278
+ wasm.closure451_externref_shim(arg0, arg1, arg2);
280
279
  }
281
280
 
282
281
  function __wbg_adapter_43(arg0, arg1, arg2) {
283
- wasm.closure1166_externref_shim(arg0, arg1, arg2);
282
+ wasm.closure1348_externref_shim(arg0, arg1, arg2);
284
283
  }
285
284
 
286
- function __wbg_adapter_481(arg0, arg1, arg2, arg3) {
287
- wasm.closure1915_externref_shim(arg0, arg1, arg2, arg3);
285
+ function __wbg_adapter_526(arg0, arg1, arg2, arg3) {
286
+ wasm.closure2120_externref_shim(arg0, arg1, arg2, arg3);
288
287
  }
289
288
 
290
289
  /**
@@ -510,6 +509,214 @@ class AddressResult {
510
509
  }
511
510
  module.exports.AddressResult = AddressResult;
512
511
 
512
+ const Amp0Finalization = (typeof FinalizationRegistry === 'undefined')
513
+ ? { register: () => {}, unregister: () => {} }
514
+ : new FinalizationRegistry(ptr => wasm.__wbg_amp0_free(ptr >>> 0, 1));
515
+ /**
516
+ * Wrapper of [`lwk_wollet::amp0::Amp0`]
517
+ */
518
+ class Amp0 {
519
+
520
+ static __wrap(ptr) {
521
+ ptr = ptr >>> 0;
522
+ const obj = Object.create(Amp0.prototype);
523
+ obj.__wbg_ptr = ptr;
524
+ Amp0Finalization.register(obj, obj.__wbg_ptr, obj);
525
+ return obj;
526
+ }
527
+
528
+ __destroy_into_raw() {
529
+ const ptr = this.__wbg_ptr;
530
+ this.__wbg_ptr = 0;
531
+ Amp0Finalization.unregister(this);
532
+ return ptr;
533
+ }
534
+
535
+ free() {
536
+ const ptr = this.__destroy_into_raw();
537
+ wasm.__wbg_amp0_free(ptr, 0);
538
+ }
539
+ /**
540
+ * Create a new AMP0 context for the specified network
541
+ * @param {Network} network
542
+ * @param {string} username
543
+ * @param {string} password
544
+ * @param {string} amp_id
545
+ * @returns {Promise<Amp0>}
546
+ */
547
+ static newWithNetwork(network, username, password, amp_id) {
548
+ _assertClass(network, Network);
549
+ var ptr0 = network.__destroy_into_raw();
550
+ const ptr1 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
551
+ const len1 = WASM_VECTOR_LEN;
552
+ const ptr2 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
553
+ const len2 = WASM_VECTOR_LEN;
554
+ const ptr3 = passStringToWasm0(amp_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
555
+ const len3 = WASM_VECTOR_LEN;
556
+ const ret = wasm.amp0_newWithNetwork(ptr0, ptr1, len1, ptr2, len2, ptr3, len3);
557
+ return ret;
558
+ }
559
+ /**
560
+ * Create a new AMP0 context for testnet
561
+ * @param {string} username
562
+ * @param {string} password
563
+ * @param {string} amp_id
564
+ * @returns {Promise<Amp0>}
565
+ */
566
+ static netTestnet(username, password, amp_id) {
567
+ const ptr0 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
568
+ const len0 = WASM_VECTOR_LEN;
569
+ const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
570
+ const len1 = WASM_VECTOR_LEN;
571
+ const ptr2 = passStringToWasm0(amp_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
572
+ const len2 = WASM_VECTOR_LEN;
573
+ const ret = wasm.amp0_netTestnet(ptr0, len0, ptr1, len1, ptr2, len2);
574
+ return ret;
575
+ }
576
+ /**
577
+ * Create a new AMP0 context for mainnet
578
+ * @param {string} username
579
+ * @param {string} password
580
+ * @param {string} amp_id
581
+ * @returns {Promise<Amp0>}
582
+ */
583
+ static newMainnet(username, password, amp_id) {
584
+ const ptr0 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
585
+ const len0 = WASM_VECTOR_LEN;
586
+ const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
587
+ const len1 = WASM_VECTOR_LEN;
588
+ const ptr2 = passStringToWasm0(amp_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
589
+ const len2 = WASM_VECTOR_LEN;
590
+ const ret = wasm.amp0_newMainnet(ptr0, len0, ptr1, len1, ptr2, len2);
591
+ return ret;
592
+ }
593
+ /**
594
+ * Index of the last returned address
595
+ *
596
+ * Use this and [`crate::EsploraClient::full_scan_to_index()`] to sync the `Wollet`
597
+ * @returns {number}
598
+ */
599
+ lastIndex() {
600
+ const ret = wasm.amp0_lastIndex(this.__wbg_ptr);
601
+ return ret >>> 0;
602
+ }
603
+ /**
604
+ * AMP ID
605
+ * @returns {string}
606
+ */
607
+ ampId() {
608
+ let deferred1_0;
609
+ let deferred1_1;
610
+ try {
611
+ const ret = wasm.amp0_ampId(this.__wbg_ptr);
612
+ deferred1_0 = ret[0];
613
+ deferred1_1 = ret[1];
614
+ return getStringFromWasm0(ret[0], ret[1]);
615
+ } finally {
616
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
617
+ }
618
+ }
619
+ /**
620
+ * Get an address
621
+ *
622
+ * If `index` is None, a new address is returned.
623
+ * @param {number | null} [index]
624
+ * @returns {Promise<AddressResult>}
625
+ */
626
+ address(index) {
627
+ const ret = wasm.amp0_address(this.__wbg_ptr, isLikeNone(index) ? 0x100000001 : (index) >>> 0);
628
+ return ret;
629
+ }
630
+ /**
631
+ * The LWK watch-only wallet corresponding to the AMP0 (sub)account.
632
+ * @returns {Wollet}
633
+ */
634
+ wollet() {
635
+ const ret = wasm.amp0_wollet(this.__wbg_ptr);
636
+ if (ret[2]) {
637
+ throw takeFromExternrefTable0(ret[1]);
638
+ }
639
+ return Wollet.__wrap(ret[0]);
640
+ }
641
+ /**
642
+ * Ask AMP0 server to cosign
643
+ * @param {Amp0Pset} amp0pset
644
+ * @returns {Promise<Transaction>}
645
+ */
646
+ sign(amp0pset) {
647
+ _assertClass(amp0pset, Amp0Pset);
648
+ const ret = wasm.amp0_sign(this.__wbg_ptr, amp0pset.__wbg_ptr);
649
+ return ret;
650
+ }
651
+ }
652
+ module.exports.Amp0 = Amp0;
653
+
654
+ const Amp0PsetFinalization = (typeof FinalizationRegistry === 'undefined')
655
+ ? { register: () => {}, unregister: () => {} }
656
+ : new FinalizationRegistry(ptr => wasm.__wbg_amp0pset_free(ptr >>> 0, 1));
657
+ /**
658
+ * Wrapper of [`lwk_wollet::amp0::Amp0Pset`]
659
+ */
660
+ class Amp0Pset {
661
+
662
+ static __wrap(ptr) {
663
+ ptr = ptr >>> 0;
664
+ const obj = Object.create(Amp0Pset.prototype);
665
+ obj.__wbg_ptr = ptr;
666
+ Amp0PsetFinalization.register(obj, obj.__wbg_ptr, obj);
667
+ return obj;
668
+ }
669
+
670
+ __destroy_into_raw() {
671
+ const ptr = this.__wbg_ptr;
672
+ this.__wbg_ptr = 0;
673
+ Amp0PsetFinalization.unregister(this);
674
+ return ptr;
675
+ }
676
+
677
+ free() {
678
+ const ptr = this.__destroy_into_raw();
679
+ wasm.__wbg_amp0pset_free(ptr, 0);
680
+ }
681
+ /**
682
+ * Creates a `Amp0Pset`
683
+ * @param {Pset} pset
684
+ * @param {string[]} blinding_nonces
685
+ */
686
+ constructor(pset, blinding_nonces) {
687
+ _assertClass(pset, Pset);
688
+ var ptr0 = pset.__destroy_into_raw();
689
+ const ptr1 = passArrayJsValueToWasm0(blinding_nonces, wasm.__wbindgen_malloc);
690
+ const len1 = WASM_VECTOR_LEN;
691
+ const ret = wasm.amp0pset_new(ptr0, ptr1, len1);
692
+ if (ret[2]) {
693
+ throw takeFromExternrefTable0(ret[1]);
694
+ }
695
+ this.__wbg_ptr = ret[0] >>> 0;
696
+ Amp0PsetFinalization.register(this, this.__wbg_ptr, this);
697
+ return this;
698
+ }
699
+ /**
700
+ * Get the PSET
701
+ * @returns {Pset}
702
+ */
703
+ pset() {
704
+ const ret = wasm.amp0pset_pset(this.__wbg_ptr);
705
+ return Pset.__wrap(ret);
706
+ }
707
+ /**
708
+ * Get the blinding nonces
709
+ * @returns {string[]}
710
+ */
711
+ blindingNonces() {
712
+ const ret = wasm.amp0pset_blindingNonces(this.__wbg_ptr);
713
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
714
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
715
+ return v1;
716
+ }
717
+ }
718
+ module.exports.Amp0Pset = Amp0Pset;
719
+
513
720
  const Amp2Finalization = (typeof FinalizationRegistry === 'undefined')
514
721
  ? { register: () => {}, unregister: () => {} }
515
722
  : new FinalizationRegistry(ptr => wasm.__wbg_amp2_free(ptr >>> 0, 1));
@@ -736,6 +943,61 @@ class AssetId {
736
943
  }
737
944
  module.exports.AssetId = AssetId;
738
945
 
946
+ const AssetIdsFinalization = (typeof FinalizationRegistry === 'undefined')
947
+ ? { register: () => {}, unregister: () => {} }
948
+ : new FinalizationRegistry(ptr => wasm.__wbg_assetids_free(ptr >>> 0, 1));
949
+ /**
950
+ * A collection of asset identifiers. wrapper of [`Vec<elements::AssetId>`]
951
+ */
952
+ class AssetIds {
953
+
954
+ static __wrap(ptr) {
955
+ ptr = ptr >>> 0;
956
+ const obj = Object.create(AssetIds.prototype);
957
+ obj.__wbg_ptr = ptr;
958
+ AssetIdsFinalization.register(obj, obj.__wbg_ptr, obj);
959
+ return obj;
960
+ }
961
+
962
+ __destroy_into_raw() {
963
+ const ptr = this.__wbg_ptr;
964
+ this.__wbg_ptr = 0;
965
+ AssetIdsFinalization.unregister(this);
966
+ return ptr;
967
+ }
968
+
969
+ free() {
970
+ const ptr = this.__destroy_into_raw();
971
+ wasm.__wbg_assetids_free(ptr, 0);
972
+ }
973
+ /**
974
+ * @returns {AssetIds}
975
+ */
976
+ static empty() {
977
+ const ret = wasm.assetids_empty();
978
+ if (ret[2]) {
979
+ throw takeFromExternrefTable0(ret[1]);
980
+ }
981
+ return AssetIds.__wrap(ret[0]);
982
+ }
983
+ /**
984
+ * @returns {string}
985
+ */
986
+ toString() {
987
+ let deferred1_0;
988
+ let deferred1_1;
989
+ try {
990
+ const ret = wasm.assetids_toString(this.__wbg_ptr);
991
+ deferred1_0 = ret[0];
992
+ deferred1_1 = ret[1];
993
+ return getStringFromWasm0(ret[0], ret[1]);
994
+ } finally {
995
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
996
+ }
997
+ }
998
+ }
999
+ module.exports.AssetIds = AssetIds;
1000
+
739
1001
  const AssetMetaFinalization = (typeof FinalizationRegistry === 'undefined')
740
1002
  ? { register: () => {}, unregister: () => {} }
741
1003
  : new FinalizationRegistry(ptr => wasm.__wbg_assetmeta_free(ptr >>> 0, 1));
@@ -973,13 +1235,17 @@ class EsploraClient {
973
1235
  * @param {string} url
974
1236
  * @param {boolean} waterfalls
975
1237
  * @param {number} concurrency
1238
+ * @param {boolean} utxo_only
976
1239
  */
977
- constructor(network, url, waterfalls, concurrency) {
1240
+ constructor(network, url, waterfalls, concurrency, utxo_only) {
978
1241
  _assertClass(network, Network);
979
1242
  const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
980
1243
  const len0 = WASM_VECTOR_LEN;
981
- const ret = wasm.esploraclient_new(network.__wbg_ptr, ptr0, len0, waterfalls, concurrency);
982
- this.__wbg_ptr = ret >>> 0;
1244
+ const ret = wasm.esploraclient_new(network.__wbg_ptr, ptr0, len0, waterfalls, concurrency, utxo_only);
1245
+ if (ret[2]) {
1246
+ throw takeFromExternrefTable0(ret[1]);
1247
+ }
1248
+ this.__wbg_ptr = ret[0] >>> 0;
983
1249
  EsploraClientFinalization.register(this, this.__wbg_ptr, this);
984
1250
  return this;
985
1251
  }
@@ -1003,6 +1269,15 @@ class EsploraClient {
1003
1269
  const ret = wasm.esploraclient_fullScanToIndex(this.__wbg_ptr, wollet.__wbg_ptr, index);
1004
1270
  return ret;
1005
1271
  }
1272
+ /**
1273
+ * @param {Transaction} tx
1274
+ * @returns {Promise<Txid>}
1275
+ */
1276
+ broadcastTx(tx) {
1277
+ _assertClass(tx, Transaction);
1278
+ const ret = wasm.esploraclient_broadcastTx(this.__wbg_ptr, tx.__wbg_ptr);
1279
+ return ret;
1280
+ }
1006
1281
  /**
1007
1282
  * @param {Pset} pset
1008
1283
  * @returns {Promise<Txid>}
@@ -2345,24 +2620,34 @@ class Registry {
2345
2620
  }
2346
2621
  /**
2347
2622
  * @param {string} url
2348
- * @returns {Registry}
2623
+ * @param {AssetIds} asset_ids
2624
+ * @returns {Promise<Registry>}
2349
2625
  */
2350
- static new(url) {
2626
+ static new(url, asset_ids) {
2351
2627
  const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2352
2628
  const len0 = WASM_VECTOR_LEN;
2353
- const ret = wasm.registry_new(ptr0, len0);
2354
- if (ret[2]) {
2355
- throw takeFromExternrefTable0(ret[1]);
2356
- }
2357
- return Registry.__wrap(ret[0]);
2629
+ _assertClass(asset_ids, AssetIds);
2630
+ const ret = wasm.registry_new(ptr0, len0, asset_ids.__wbg_ptr);
2631
+ return ret;
2632
+ }
2633
+ /**
2634
+ * @param {Network} network
2635
+ * @param {AssetIds} asset_ids
2636
+ * @returns {Promise<Registry>}
2637
+ */
2638
+ static defaultForNetwork(network, asset_ids) {
2639
+ _assertClass(network, Network);
2640
+ _assertClass(asset_ids, AssetIds);
2641
+ const ret = wasm.registry_defaultForNetwork(network.__wbg_ptr, asset_ids.__wbg_ptr);
2642
+ return ret;
2358
2643
  }
2359
2644
  /**
2360
2645
  * @param {Network} network
2361
2646
  * @returns {Registry}
2362
2647
  */
2363
- static defaultForNetwork(network) {
2648
+ static defaultHardcodedForNetwork(network) {
2364
2649
  _assertClass(network, Network);
2365
- const ret = wasm.registry_defaultForNetwork(network.__wbg_ptr);
2650
+ const ret = wasm.registry_defaultHardcodedForNetwork(network.__wbg_ptr);
2366
2651
  if (ret[2]) {
2367
2652
  throw takeFromExternrefTable0(ret[1]);
2368
2653
  }
@@ -2388,9 +2673,120 @@ class Registry {
2388
2673
  const ret = wasm.registry_post(this.__wbg_ptr, data.__wbg_ptr);
2389
2674
  return ret;
2390
2675
  }
2676
+ /**
2677
+ * @param {AssetId} asset_id
2678
+ * @returns {RegistryData | undefined}
2679
+ */
2680
+ get(asset_id) {
2681
+ _assertClass(asset_id, AssetId);
2682
+ const ret = wasm.registry_get(this.__wbg_ptr, asset_id.__wbg_ptr);
2683
+ return ret === 0 ? undefined : RegistryData.__wrap(ret);
2684
+ }
2685
+ /**
2686
+ * @param {AssetId} token_id
2687
+ * @returns {RegistryData | undefined}
2688
+ */
2689
+ getAssetOfToken(token_id) {
2690
+ _assertClass(token_id, AssetId);
2691
+ const ret = wasm.registry_getAssetOfToken(this.__wbg_ptr, token_id.__wbg_ptr);
2692
+ return ret === 0 ? undefined : RegistryData.__wrap(ret);
2693
+ }
2694
+ /**
2695
+ * @param {Pset} pset
2696
+ * @returns {Pset}
2697
+ */
2698
+ addContracts(pset) {
2699
+ _assertClass(pset, Pset);
2700
+ var ptr0 = pset.__destroy_into_raw();
2701
+ const ret = wasm.registry_addContracts(this.__wbg_ptr, ptr0);
2702
+ if (ret[2]) {
2703
+ throw takeFromExternrefTable0(ret[1]);
2704
+ }
2705
+ return Pset.__wrap(ret[0]);
2706
+ }
2391
2707
  }
2392
2708
  module.exports.Registry = Registry;
2393
2709
 
2710
+ const RegistryDataFinalization = (typeof FinalizationRegistry === 'undefined')
2711
+ ? { register: () => {}, unregister: () => {} }
2712
+ : new FinalizationRegistry(ptr => wasm.__wbg_registrydata_free(ptr >>> 0, 1));
2713
+
2714
+ class RegistryData {
2715
+
2716
+ static __wrap(ptr) {
2717
+ ptr = ptr >>> 0;
2718
+ const obj = Object.create(RegistryData.prototype);
2719
+ obj.__wbg_ptr = ptr;
2720
+ RegistryDataFinalization.register(obj, obj.__wbg_ptr, obj);
2721
+ return obj;
2722
+ }
2723
+
2724
+ __destroy_into_raw() {
2725
+ const ptr = this.__wbg_ptr;
2726
+ this.__wbg_ptr = 0;
2727
+ RegistryDataFinalization.unregister(this);
2728
+ return ptr;
2729
+ }
2730
+
2731
+ free() {
2732
+ const ptr = this.__destroy_into_raw();
2733
+ wasm.__wbg_registrydata_free(ptr, 0);
2734
+ }
2735
+ /**
2736
+ * @returns {number}
2737
+ */
2738
+ precision() {
2739
+ const ret = wasm.registrydata_precision(this.__wbg_ptr);
2740
+ return ret;
2741
+ }
2742
+ /**
2743
+ * @returns {string}
2744
+ */
2745
+ ticker() {
2746
+ let deferred1_0;
2747
+ let deferred1_1;
2748
+ try {
2749
+ const ret = wasm.registrydata_ticker(this.__wbg_ptr);
2750
+ deferred1_0 = ret[0];
2751
+ deferred1_1 = ret[1];
2752
+ return getStringFromWasm0(ret[0], ret[1]);
2753
+ } finally {
2754
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2755
+ }
2756
+ }
2757
+ /**
2758
+ * @returns {string}
2759
+ */
2760
+ name() {
2761
+ let deferred1_0;
2762
+ let deferred1_1;
2763
+ try {
2764
+ const ret = wasm.registrydata_name(this.__wbg_ptr);
2765
+ deferred1_0 = ret[0];
2766
+ deferred1_1 = ret[1];
2767
+ return getStringFromWasm0(ret[0], ret[1]);
2768
+ } finally {
2769
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2770
+ }
2771
+ }
2772
+ /**
2773
+ * @returns {string}
2774
+ */
2775
+ domain() {
2776
+ let deferred1_0;
2777
+ let deferred1_1;
2778
+ try {
2779
+ const ret = wasm.registrydata_domain(this.__wbg_ptr);
2780
+ deferred1_0 = ret[0];
2781
+ deferred1_1 = ret[1];
2782
+ return getStringFromWasm0(ret[0], ret[1]);
2783
+ } finally {
2784
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2785
+ }
2786
+ }
2787
+ }
2788
+ module.exports.RegistryData = RegistryData;
2789
+
2394
2790
  const RegistryPostFinalization = (typeof FinalizationRegistry === 'undefined')
2395
2791
  ? { register: () => {}, unregister: () => {} }
2396
2792
  : new FinalizationRegistry(ptr => wasm.__wbg_registrypost_free(ptr >>> 0, 1));
@@ -2872,7 +3268,7 @@ class TxBuilder {
2872
3268
  */
2873
3269
  constructor(network) {
2874
3270
  _assertClass(network, Network);
2875
- const ret = wasm.txbuilder_new(network.__wbg_ptr);
3271
+ const ret = wasm.network_txBuilder(network.__wbg_ptr);
2876
3272
  this.__wbg_ptr = ret >>> 0;
2877
3273
  TxBuilderFinalization.register(this, this.__wbg_ptr, this);
2878
3274
  return this;
@@ -2891,6 +3287,20 @@ class TxBuilder {
2891
3287
  }
2892
3288
  return Pset.__wrap(ret[0]);
2893
3289
  }
3290
+ /**
3291
+ * Build the transaction for AMP0
3292
+ * @param {Wollet} wollet
3293
+ * @returns {Amp0Pset}
3294
+ */
3295
+ finishForAmp0(wollet) {
3296
+ const ptr = this.__destroy_into_raw();
3297
+ _assertClass(wollet, Wollet);
3298
+ const ret = wasm.txbuilder_finishForAmp0(ptr, wollet.__wbg_ptr);
3299
+ if (ret[2]) {
3300
+ throw takeFromExternrefTable0(ret[1]);
3301
+ }
3302
+ return Amp0Pset.__wrap(ret[0]);
3303
+ }
2894
3304
  /**
2895
3305
  * Set the fee rate
2896
3306
  * @param {number | null} [fee_rate]
@@ -2970,6 +3380,24 @@ class TxBuilder {
2970
3380
  const ret = wasm.txbuilder_addBurn(ptr, satoshi, asset.__wbg_ptr);
2971
3381
  return TxBuilder.__wrap(ret);
2972
3382
  }
3383
+ /**
3384
+ * Add explicit recipient
3385
+ * @param {Address} address
3386
+ * @param {bigint} satoshi
3387
+ * @param {AssetId} asset
3388
+ * @returns {TxBuilder}
3389
+ */
3390
+ addExplicitRecipient(address, satoshi, asset) {
3391
+ const ptr = this.__destroy_into_raw();
3392
+ _assertClass(address, Address);
3393
+ var ptr0 = address.__destroy_into_raw();
3394
+ _assertClass(asset, AssetId);
3395
+ const ret = wasm.txbuilder_addExplicitRecipient(ptr, ptr0, satoshi, asset.__wbg_ptr);
3396
+ if (ret[2]) {
3397
+ throw takeFromExternrefTable0(ret[1]);
3398
+ }
3399
+ return TxBuilder.__wrap(ret[0]);
3400
+ }
2973
3401
  /**
2974
3402
  * Issue an asset, wrapper of [`lwk_wollet::TxBuilder::issue_asset()`]
2975
3403
  * @param {bigint} asset_sats
@@ -3166,6 +3594,49 @@ class TxOutSecrets {
3166
3594
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3167
3595
  }
3168
3596
  }
3597
+ /**
3598
+ * @returns {boolean}
3599
+ */
3600
+ isExplicit() {
3601
+ const ret = wasm.txoutsecrets_isExplicit(this.__wbg_ptr);
3602
+ return ret !== 0;
3603
+ }
3604
+ /**
3605
+ * Get the asset commitment
3606
+ *
3607
+ * If the output is explicit, returns the empty string
3608
+ * @returns {string}
3609
+ */
3610
+ assetCommitment() {
3611
+ let deferred1_0;
3612
+ let deferred1_1;
3613
+ try {
3614
+ const ret = wasm.txoutsecrets_assetCommitment(this.__wbg_ptr);
3615
+ deferred1_0 = ret[0];
3616
+ deferred1_1 = ret[1];
3617
+ return getStringFromWasm0(ret[0], ret[1]);
3618
+ } finally {
3619
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3620
+ }
3621
+ }
3622
+ /**
3623
+ * Get the value commitment
3624
+ *
3625
+ * If the output is explicit, returns the empty string
3626
+ * @returns {string}
3627
+ */
3628
+ valueCommitment() {
3629
+ let deferred1_0;
3630
+ let deferred1_1;
3631
+ try {
3632
+ const ret = wasm.txoutsecrets_valueCommitment(this.__wbg_ptr);
3633
+ deferred1_0 = ret[0];
3634
+ deferred1_1 = ret[1];
3635
+ return getStringFromWasm0(ret[0], ret[1]);
3636
+ } finally {
3637
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3638
+ }
3639
+ }
3169
3640
  }
3170
3641
  module.exports.TxOutSecrets = TxOutSecrets;
3171
3642
 
@@ -3715,6 +4186,14 @@ const WolletFinalization = (typeof FinalizationRegistry === 'undefined')
3715
4186
  */
3716
4187
  class Wollet {
3717
4188
 
4189
+ static __wrap(ptr) {
4190
+ ptr = ptr >>> 0;
4191
+ const obj = Object.create(Wollet.prototype);
4192
+ obj.__wbg_ptr = ptr;
4193
+ WolletFinalization.register(obj, obj.__wbg_ptr, obj);
4194
+ return obj;
4195
+ }
4196
+
3718
4197
  __destroy_into_raw() {
3719
4198
  const ptr = this.__wbg_ptr;
3720
4199
  this.__wbg_ptr = 0;
@@ -3780,6 +4259,16 @@ class Wollet {
3780
4259
  throw takeFromExternrefTable0(ret[0]);
3781
4260
  }
3782
4261
  }
4262
+ /**
4263
+ * @param {Transaction} tx
4264
+ */
4265
+ applyTransaction(tx) {
4266
+ _assertClass(tx, Transaction);
4267
+ const ret = wasm.wollet_applyTransaction(this.__wbg_ptr, tx.__wbg_ptr);
4268
+ if (ret[1]) {
4269
+ throw takeFromExternrefTable0(ret[0]);
4270
+ }
4271
+ }
3783
4272
  /**
3784
4273
  * @returns {any}
3785
4274
  */
@@ -3790,6 +4279,16 @@ class Wollet {
3790
4279
  }
3791
4280
  return takeFromExternrefTable0(ret[0]);
3792
4281
  }
4282
+ /**
4283
+ * @returns {AssetIds}
4284
+ */
4285
+ assetsOwned() {
4286
+ const ret = wasm.wollet_assetsOwned(this.__wbg_ptr);
4287
+ if (ret[2]) {
4288
+ throw takeFromExternrefTable0(ret[1]);
4289
+ }
4290
+ return AssetIds.__wrap(ret[0]);
4291
+ }
3793
4292
  /**
3794
4293
  * @returns {WalletTx[]}
3795
4294
  */
@@ -3886,6 +4385,14 @@ class Wollet {
3886
4385
  const ret = wasm.wollet_neverScanned(this.__wbg_ptr);
3887
4386
  return ret !== 0;
3888
4387
  }
4388
+ /**
4389
+ * Whether the wallet is AMP0
4390
+ * @returns {boolean}
4391
+ */
4392
+ isAmp0() {
4393
+ const ret = wasm.wollet_isAmp0(this.__wbg_ptr);
4394
+ return ret !== 0;
4395
+ }
3889
4396
  }
3890
4397
  module.exports.Wollet = Wollet;
3891
4398
 
@@ -3967,6 +4474,14 @@ class WolletDescriptor {
3967
4474
  const ret = wasm.wolletdescriptor_isMainnet(this.__wbg_ptr);
3968
4475
  return ret !== 0;
3969
4476
  }
4477
+ /**
4478
+ * Whether the descriptor is AMP0
4479
+ * @returns {boolean}
4480
+ */
4481
+ isAmp0() {
4482
+ const ret = wasm.wolletdescriptor_isAmp0(this.__wbg_ptr);
4483
+ return ret !== 0;
4484
+ }
3970
4485
  }
3971
4486
  module.exports.WolletDescriptor = WolletDescriptor;
3972
4487
 
@@ -4083,6 +4598,16 @@ module.exports.__wbg_abort_775ef1d17fc65868 = function(arg0) {
4083
4598
  arg0.abort();
4084
4599
  };
4085
4600
 
4601
+ module.exports.__wbg_addressresult_new = function(arg0) {
4602
+ const ret = AddressResult.__wrap(arg0);
4603
+ return ret;
4604
+ };
4605
+
4606
+ module.exports.__wbg_amp0_new = function(arg0) {
4607
+ const ret = Amp0.__wrap(arg0);
4608
+ return ret;
4609
+ };
4610
+
4086
4611
  module.exports.__wbg_append_8c7dd8d641a5f01b = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4087
4612
  arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
4088
4613
  }, arguments) };
@@ -4296,7 +4821,7 @@ module.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
4296
4821
  return ret;
4297
4822
  };
4298
4823
 
4299
- module.exports.__wbg_log_a059746199e3a950 = function(arg0, arg1) {
4824
+ module.exports.__wbg_log_1c0673da475f4734 = function(arg0, arg1) {
4300
4825
  console.log(getStringFromWasm0(arg0, arg1));
4301
4826
  };
4302
4827
 
@@ -4327,7 +4852,7 @@ module.exports.__wbg_new_23a2665fac83c611 = function(arg0, arg1) {
4327
4852
  const a = state0.a;
4328
4853
  state0.a = 0;
4329
4854
  try {
4330
- return __wbg_adapter_481(a, state0.b, arg0, arg1);
4855
+ return __wbg_adapter_526(a, state0.b, arg0, arg1);
4331
4856
  } finally {
4332
4857
  state0.a = a;
4333
4858
  }
@@ -4389,6 +4914,11 @@ module.exports.__wbg_newwithstrandinit_06c535e0a867c635 = function() { return ha
4389
4914
  return ret;
4390
4915
  }, arguments) };
4391
4916
 
4917
+ module.exports.__wbg_newwithstrsequence_6e9d6479e1cf978d = function() { return handleError(function (arg0, arg1, arg2) {
4918
+ const ret = new WebSocket(getStringFromWasm0(arg0, arg1), arg2);
4919
+ return ret;
4920
+ }, arguments) };
4921
+
4392
4922
  module.exports.__wbg_next_25feadfc0913fea9 = function(arg0) {
4393
4923
  const ret = arg0.next;
4394
4924
  return ret;
@@ -4469,6 +4999,11 @@ module.exports.__wbg_psetsignatures_new = function(arg0) {
4469
4999
  return ret;
4470
5000
  };
4471
5001
 
5002
+ module.exports.__wbg_push_737cfc8c1432c2c6 = function(arg0, arg1) {
5003
+ const ret = arg0.push(arg1);
5004
+ return ret;
5005
+ };
5006
+
4472
5007
  module.exports.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function(arg0) {
4473
5008
  queueMicrotask(arg0);
4474
5009
  };
@@ -4497,6 +5032,11 @@ module.exports.__wbg_recipient_new = function(arg0) {
4497
5032
  return ret;
4498
5033
  };
4499
5034
 
5035
+ module.exports.__wbg_registry_new = function(arg0) {
5036
+ const ret = Registry.__wrap(arg0);
5037
+ return ret;
5038
+ };
5039
+
4500
5040
  module.exports.__wbg_requestDevice_b9904d52d001d64d = function(arg0, arg1) {
4501
5041
  const ret = arg0.requestDevice(arg1);
4502
5042
  return ret;
@@ -4527,6 +5067,10 @@ module.exports.__wbg_sendReport_4d1024566077f413 = function() { return handleErr
4527
5067
  return ret;
4528
5068
  }, arguments) };
4529
5069
 
5070
+ module.exports.__wbg_send_0293179ba074ffb4 = function() { return handleError(function (arg0, arg1, arg2) {
5071
+ arg0.send(getStringFromWasm0(arg1, arg2));
5072
+ }, arguments) };
5073
+
4530
5074
  module.exports.__wbg_send_7c4769e24cf1d784 = function() { return handleError(function (arg0, arg1) {
4531
5075
  arg0.send(arg1);
4532
5076
  }, arguments) };
@@ -4665,6 +5209,11 @@ module.exports.__wbg_then_48b406749878a531 = function(arg0, arg1, arg2) {
4665
5209
  return ret;
4666
5210
  };
4667
5211
 
5212
+ module.exports.__wbg_transaction_new = function(arg0) {
5213
+ const ret = Transaction.__wrap(arg0);
5214
+ return ret;
5215
+ };
5216
+
4668
5217
  module.exports.__wbg_txid_new = function(arg0) {
4669
5218
  const ret = Txid.__wrap(arg0);
4670
5219
  return ret;
@@ -4748,23 +5297,23 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
4748
5297
  return ret;
4749
5298
  };
4750
5299
 
4751
- module.exports.__wbindgen_closure_wrapper10168 = function(arg0, arg1, arg2) {
4752
- const ret = makeMutClosure(arg0, arg1, 1167, __wbg_adapter_43);
5300
+ module.exports.__wbindgen_closure_wrapper12419 = function(arg0, arg1, arg2) {
5301
+ const ret = makeMutClosure(arg0, arg1, 1349, __wbg_adapter_43);
4753
5302
  return ret;
4754
5303
  };
4755
5304
 
4756
- module.exports.__wbindgen_closure_wrapper5011 = function(arg0, arg1, arg2) {
4757
- const ret = makeMutClosure(arg0, arg1, 287, __wbg_adapter_36);
5305
+ module.exports.__wbindgen_closure_wrapper4731 = function(arg0, arg1, arg2) {
5306
+ const ret = makeMutClosure(arg0, arg1, 452, __wbg_adapter_36);
4758
5307
  return ret;
4759
5308
  };
4760
5309
 
4761
- module.exports.__wbindgen_closure_wrapper5013 = function(arg0, arg1, arg2) {
4762
- const ret = makeMutClosure(arg0, arg1, 286, __wbg_adapter_36);
5310
+ module.exports.__wbindgen_closure_wrapper4733 = function(arg0, arg1, arg2) {
5311
+ const ret = makeMutClosure(arg0, arg1, 453, __wbg_adapter_36);
4763
5312
  return ret;
4764
5313
  };
4765
5314
 
4766
- module.exports.__wbindgen_closure_wrapper5015 = function(arg0, arg1, arg2) {
4767
- const ret = makeMutClosure(arg0, arg1, 287, __wbg_adapter_36);
5315
+ module.exports.__wbindgen_closure_wrapper4735 = function(arg0, arg1, arg2) {
5316
+ const ret = makeMutClosure(arg0, arg1, 452, __wbg_adapter_36);
4768
5317
  return ret;
4769
5318
  };
4770
5319
 
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.9.3",
4
+ "version": "0.11.0",
5
5
  "license": "MIT OR BSD-2-Clause",
6
6
  "files": [
7
7
  "lwk_wasm_bg.wasm",