lwk_node 0.9.0 → 0.9.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/lwk_wasm.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ export function searchLedgerDevice(): Promise<HIDDevice>;
3
4
  /**
4
5
  * Wallet chain
5
6
  */
@@ -21,8 +22,14 @@ export class Address {
21
22
  free(): void;
22
23
  /**
23
24
  * Creates an `Address`
25
+ *
26
+ * If you know the network, you can use [`Address::parse()`] to validate that the network is consistent.
24
27
  */
25
28
  constructor(s: string);
29
+ /**
30
+ * Parses an `Address` ensuring is for the right network
31
+ */
32
+ static parse(s: string, network: Network): Address;
26
33
  scriptPubkey(): Script;
27
34
  isBlinded(): boolean;
28
35
  isMainnet(): boolean;
@@ -37,7 +44,7 @@ export class Address {
37
44
  * and use styling to scale up the image in the browser. eg
38
45
  * `style="image-rendering: pixelated; border: 20px solid white;"`
39
46
  */
40
- QRCodeUri(pixel_per_module?: number): string;
47
+ QRCodeUri(pixel_per_module?: number | null): string;
41
48
  /**
42
49
  * Returns a string of the QR code printable in a terminal environment
43
50
  */
@@ -72,6 +79,15 @@ export class Amp2Descriptor {
72
79
  descriptor(): WolletDescriptor;
73
80
  toString(): string;
74
81
  }
82
+ /**
83
+ * Wrapper of [`lwk_wollet::AssetAmount`]
84
+ */
85
+ export class AssetAmount {
86
+ private constructor();
87
+ free(): void;
88
+ amount(): bigint;
89
+ asset(): AssetId;
90
+ }
75
91
  /**
76
92
  * A valid asset identifier. wrapper of [`elements::AssetId`]
77
93
  *
@@ -85,6 +101,12 @@ export class AssetId {
85
101
  constructor(asset_id: string);
86
102
  toString(): string;
87
103
  }
104
+ export class AssetMeta {
105
+ private constructor();
106
+ free(): void;
107
+ contract(): Contract;
108
+ tx(): Transaction;
109
+ }
88
110
  /**
89
111
  * wrapper over [`lwk_common::Bip`]
90
112
  */
@@ -126,7 +148,7 @@ export class EsploraClient {
126
148
  /**
127
149
  * Creates a client, wrapper of [`asyncr::EsploraClient`]
128
150
  */
129
- constructor(network: Network, url: string, waterfalls: boolean);
151
+ constructor(network: Network, url: string, waterfalls: boolean, concurrency: number);
130
152
  fullScan(wollet: Wollet): Promise<Update | undefined>;
131
153
  /**
132
154
  * Scan the blockchain for the scripts generated by a watch-only wallet up to a specified derivation index
@@ -186,6 +208,66 @@ export class Jade {
186
208
  keyoriginXpub(bip: Bip): Promise<string>;
187
209
  registerDescriptor(name: string, desc: WolletDescriptor): Promise<boolean>;
188
210
  }
211
+ /**
212
+ * WebSocket-based Wrapper of [`asyncr::Jade`]
213
+ */
214
+ export class JadeWebSocket {
215
+ free(): void;
216
+ /**
217
+ * Creates a Jade from WebSocket for the given network
218
+ *
219
+ * The url should point to your WebSocket bridge that connects to the Docker Jade emulator
220
+ */
221
+ constructor(network: Network, url: string);
222
+ getVersion(): Promise<any>;
223
+ getMasterXpub(): Promise<Xpub>;
224
+ /**
225
+ * Return a single sig address with the given `variant` and `path` derivation
226
+ */
227
+ getReceiveAddressSingle(variant: Singlesig, path: Uint32Array): Promise<string>;
228
+ /**
229
+ * Return a multisig address of a registered `multisig_name` wallet
230
+ *
231
+ * This method accept `path` and `path_n` in place of a single `Vec<Vec<u32>>` because the
232
+ * latter is not supported by wasm_bindgen (and neither `(u32, Vec<u32>)`). `path` and `path_n`
233
+ * are converted internally to a `Vec<Vec<u32>>` with the caveat all the paths are the same,
234
+ * which is almost always the case.
235
+ */
236
+ getReceiveAddressMulti(multisig_name: string, path: Uint32Array): Promise<string>;
237
+ /**
238
+ * Sign and consume the given PSET, returning the signed one
239
+ */
240
+ sign(pset: Pset): Promise<Pset>;
241
+ wpkh(): Promise<WolletDescriptor>;
242
+ shWpkh(): Promise<WolletDescriptor>;
243
+ multi(name: string): Promise<WolletDescriptor>;
244
+ getRegisteredMultisigs(): Promise<any>;
245
+ keyoriginXpub(bip: Bip): Promise<string>;
246
+ registerDescriptor(name: string, desc: WolletDescriptor): Promise<boolean>;
247
+ }
248
+ export class LedgerWeb {
249
+ free(): void;
250
+ /**
251
+ * hid_device must be already opened
252
+ */
253
+ constructor(hid_device: HIDDevice, network: Network);
254
+ getVersion(): Promise<string>;
255
+ deriveXpub(path: string): Promise<string>;
256
+ slip77MasterBlindingKey(): Promise<string>;
257
+ fingerprint(): Promise<string>;
258
+ /**
259
+ * TODO Should use Signer::wpkh_slip77_descriptor
260
+ */
261
+ wpkhSlip77Descriptor(): Promise<WolletDescriptor>;
262
+ /**
263
+ * Sign and consume the given PSET, returning the signed one
264
+ */
265
+ sign(pset: Pset): Promise<Pset>;
266
+ /**
267
+ * Return a single sig address with the given `variant` and `index`
268
+ */
269
+ getReceiveAddressSingle(index: number): Promise<string>;
270
+ }
189
271
  /**
190
272
  * Wrapper of [`bip39::Mnemonic`]
191
273
  */
@@ -224,11 +306,13 @@ export class Network {
224
306
  */
225
307
  static regtest(policy_asset: AssetId): Network;
226
308
  /**
227
- * Creates the default regtest `Network`
309
+ * Creates the default regtest `Network` with the policy asset `5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225`
228
310
  */
229
311
  static regtestDefault(): Network;
230
312
  defaultEsploraClient(): EsploraClient;
231
313
  isMainnet(): boolean;
314
+ isTestnet(): boolean;
315
+ isRegtest(): boolean;
232
316
  toString(): string;
233
317
  policyAsset(): AssetId;
234
318
  txBuilder(): TxBuilder;
@@ -279,7 +363,8 @@ export class Pset {
279
363
  toString(): string;
280
364
  extractTx(): Transaction;
281
365
  combine(other: Pset): void;
282
- inputs(): (PsetInput)[];
366
+ inputs(): PsetInput[];
367
+ outputs(): PsetOutput[];
283
368
  }
284
369
  /**
285
370
  * PSET details from a perspective of a wallet, wrapper of [`lwk_common::PsetBalance`]
@@ -292,7 +377,7 @@ export class PsetBalance {
292
377
  * The net balance for every asset with respect of the wallet asking the pset details
293
378
  */
294
379
  balances(): any;
295
- recipients(): (Recipient)[];
380
+ recipients(): Recipient[];
296
381
  }
297
382
  /**
298
383
  * PSET details from a perspective of a wallet, wrapper of [`lwk_common::PsetDetails`]
@@ -304,13 +389,13 @@ export class PsetDetails {
304
389
  /**
305
390
  * For each input existing or missing signatures
306
391
  */
307
- signatures(): (PsetSignatures)[];
308
- fingerprintsMissing(): (string)[];
309
- fingerprintsHas(): (string)[];
392
+ signatures(): PsetSignatures[];
393
+ fingerprintsMissing(): string[];
394
+ fingerprintsHas(): string[];
310
395
  /**
311
396
  * Return an element for every input that could possibly be a issuance or a reissuance
312
397
  */
313
- inputsIssuances(): (Issuance)[];
398
+ inputsIssuances(): Issuance[];
314
399
  }
315
400
  /**
316
401
  * PSET input
@@ -335,6 +420,14 @@ export class PsetInput {
335
420
  */
336
421
  issuanceToken(): AssetId | undefined;
337
422
  }
423
+ /**
424
+ * PSET output
425
+ */
426
+ export class PsetOutput {
427
+ private constructor();
428
+ free(): void;
429
+ script_pubkey(): Script;
430
+ }
338
431
  /**
339
432
  * PSET details from a perspective of a wallet, wrapper of [`lwk_common::PsetSignatures`]
340
433
  */
@@ -358,6 +451,19 @@ export class Recipient {
358
451
  address(): Address | undefined;
359
452
  vout(): number;
360
453
  }
454
+ export class Registry {
455
+ private constructor();
456
+ free(): void;
457
+ static new(url: string): Registry;
458
+ static defaultForNetwork(network: Network): Registry;
459
+ fetchWithTx(asset_id: AssetId, client: EsploraClient): Promise<AssetMeta>;
460
+ post(data: RegistryPost): Promise<void>;
461
+ }
462
+ export class RegistryPost {
463
+ free(): void;
464
+ constructor(contract: Contract, asset_id: AssetId);
465
+ toString(): string;
466
+ }
361
467
  /**
362
468
  * Wrapper of [`elements::Script`]
363
469
  */
@@ -384,6 +490,10 @@ export class Signer {
384
490
  * Sign and consume the given PSET, returning the signed one
385
491
  */
386
492
  sign(pset: Pset): Pset;
493
+ /**
494
+ * Sign a message with the master key, return the signature as a base64 string
495
+ */
496
+ signMessage(message: string): string;
387
497
  wpkhSlip77Descriptor(): WolletDescriptor;
388
498
  getMasterXpub(): Xpub;
389
499
  keyoriginXpub(bip: Bip): string;
@@ -437,7 +547,7 @@ export class TxBuilder {
437
547
  /**
438
548
  * Set the fee rate
439
549
  */
440
- feeRate(fee_rate?: number): TxBuilder;
550
+ feeRate(fee_rate?: number | null): TxBuilder;
441
551
  /**
442
552
  * Select all available L-BTC inputs
443
553
  */
@@ -465,16 +575,18 @@ export class TxBuilder {
465
575
  /**
466
576
  * Issue an asset, wrapper of [`lwk_wollet::TxBuilder::issue_asset()`]
467
577
  */
468
- issueAsset(asset_sats: bigint, asset_receiver: Address | undefined, token_sats: bigint, token_receiver?: Address, contract?: Contract): TxBuilder;
578
+ issueAsset(asset_sats: bigint, asset_receiver: Address | null | undefined, token_sats: bigint, token_receiver?: Address | null, contract?: Contract | null): TxBuilder;
469
579
  /**
470
580
  * Reissue an asset, wrapper of [`lwk_wollet::TxBuilder::reissue_asset()`]
471
581
  */
472
- reissueAsset(asset_to_reissue: AssetId, satoshi_to_reissue: bigint, asset_receiver?: Address, issuance_tx?: Transaction): TxBuilder;
582
+ reissueAsset(asset_to_reissue: AssetId, satoshi_to_reissue: bigint, asset_receiver?: Address | null, issuance_tx?: Transaction | null): TxBuilder;
473
583
  /**
474
584
  * Manual coin selection, wrapper of [`lwk_wollet::TxBuilder::set_wallet_utxos()`]
475
585
  */
476
- setWalletUtxos(outpoints: (OutPoint)[]): TxBuilder;
586
+ setWalletUtxos(outpoints: OutPoint[]): TxBuilder;
477
587
  toString(): string;
588
+ liquidexMake(utxo: OutPoint, address: Address, satoshi: bigint, asset_id: AssetId): TxBuilder;
589
+ liquidexTake(proposals: ValidatedLiquidexProposal[]): TxBuilder;
478
590
  }
479
591
  /**
480
592
  * Wrapper of [`elements::TxOutSecrets`]
@@ -500,6 +612,18 @@ export class Txid {
500
612
  constructor(tx_id: string);
501
613
  toString(): string;
502
614
  }
615
+ /**
616
+ * Wrapper of [`lwk_wollet::LiquidexProposal<Unvalidated>`]
617
+ */
618
+ export class UnvalidatedLiquidexProposal {
619
+ private constructor();
620
+ free(): void;
621
+ static new(s: string): UnvalidatedLiquidexProposal;
622
+ static from_pset(pset: Pset): UnvalidatedLiquidexProposal;
623
+ insecure_validate(): ValidatedLiquidexProposal;
624
+ validate(tx: Transaction): ValidatedLiquidexProposal;
625
+ toString(): string;
626
+ }
503
627
  /**
504
628
  * Wrapper of [`lwk_wollet::Update`]
505
629
  */
@@ -515,6 +639,16 @@ export class Update {
515
639
  onlyTip(): boolean;
516
640
  prune(wollet: Wollet): void;
517
641
  }
642
+ /**
643
+ * Wrapper of [`lwk_wollet::LiquidexProposal<Validated>`]
644
+ */
645
+ export class ValidatedLiquidexProposal {
646
+ private constructor();
647
+ free(): void;
648
+ input(): AssetAmount;
649
+ output(): AssetAmount;
650
+ toString(): string;
651
+ }
518
652
  /**
519
653
  * Wrapper of [`lwk_wollet::WalletTx`]
520
654
  */
@@ -528,8 +662,8 @@ export class WalletTx {
528
662
  fee(): bigint;
529
663
  txType(): string;
530
664
  timestamp(): number | undefined;
531
- inputs(): (OptionWalletTxOut)[];
532
- outputs(): (OptionWalletTxOut)[];
665
+ inputs(): OptionWalletTxOut[];
666
+ outputs(): OptionWalletTxOut[];
533
667
  unblindedUrl(explorer_url: string): string;
534
668
  }
535
669
  /**
@@ -561,19 +695,19 @@ export class Wollet {
561
695
  * If Some return the address at the given index,
562
696
  * otherwise the last unused address.
563
697
  */
564
- address(index?: number): AddressResult;
698
+ address(index?: number | null): AddressResult;
565
699
  addressFullPath(index: number): Uint32Array;
566
700
  applyUpdate(update: Update): void;
567
701
  balance(): any;
568
- transactions(): (WalletTx)[];
702
+ transactions(): WalletTx[];
569
703
  /**
570
704
  * Get the unspent transaction outputs of the wallet
571
705
  */
572
- utxos(): (WalletTxOut)[];
706
+ utxos(): WalletTxOut[];
573
707
  /**
574
708
  * Get all the transaction outputs of the wallet, both spent and unspent
575
709
  */
576
- txos(): (WalletTxOut)[];
710
+ txos(): WalletTxOut[];
577
711
  /**
578
712
  * Finalize and consume the given PSET, returning the finalized one
579
713
  */
@@ -597,7 +731,7 @@ export class WolletDescriptor {
597
731
  */
598
732
  constructor(descriptor: string);
599
733
  toString(): string;
600
- static newMultiWshSlip77(threshold: number, participants: (string)[]): WolletDescriptor;
734
+ static newMultiWshSlip77(threshold: number, participants: string[]): WolletDescriptor;
601
735
  isMainnet(): boolean;
602
736
  }
603
737
  /**