lwk_node 0.15.0 → 0.17.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
@@ -164,9 +164,9 @@ export class Amp0Connected {
164
164
  free(): void;
165
165
  [Symbol.dispose](): void;
166
166
  /**
167
- * Connect and register to AMP0
167
+ * Connect and register to AMP0.
168
168
  */
169
- constructor(network: Network, signer_data: Amp0SignerData);
169
+ static connect(network: Network, signer_data: Amp0SignerData): Promise<Amp0Connected>;
170
170
  /**
171
171
  * Obtain a login challenge
172
172
  *
@@ -247,6 +247,13 @@ export class Amp2 {
247
247
  private constructor();
248
248
  free(): void;
249
249
  [Symbol.dispose](): void;
250
+ /**
251
+ * Create a new AMP2 client
252
+ *
253
+ * * `server_key` - The keyorigin xpub of the AMP2 server key
254
+ * * `url` - The URL of the AMP2 server
255
+ */
256
+ static new(server_key: string, url: string): Amp2;
250
257
  /**
251
258
  * Create a new AMP2 client with the default url and server key for the testnet network.
252
259
  */
@@ -254,7 +261,7 @@ export class Amp2 {
254
261
  /**
255
262
  * Get an AMP2 wallet descriptor from the keyorigin xpub string obtained from a signer
256
263
  */
257
- descriptorFromStr(keyorigin_xpub: string): Amp2Descriptor;
264
+ descriptorFromStr(keyorigin_xpub: string, descriptor_blinding_key: string): Amp2Descriptor;
258
265
  /**
259
266
  * Register an AMP2 wallet with the AMP2 server
260
267
  */
@@ -290,6 +297,38 @@ export class AssetAmount {
290
297
  amount(): bigint;
291
298
  asset(): AssetId;
292
299
  }
300
+ /**
301
+ * A blinding factor for asset commitments.
302
+ */
303
+ export class AssetBlindingFactor {
304
+ private constructor();
305
+ free(): void;
306
+ [Symbol.dispose](): void;
307
+ /**
308
+ * Creates an `AssetBlindingFactor` from a string.
309
+ */
310
+ static fromString(s: string): AssetBlindingFactor;
311
+ /**
312
+ * Creates an `AssetBlindingFactor` from a byte slice.
313
+ */
314
+ static fromBytes(bytes: Uint8Array): AssetBlindingFactor;
315
+ /**
316
+ * Returns a zero asset blinding factor.
317
+ */
318
+ static zero(): AssetBlindingFactor;
319
+ /**
320
+ * Returns the bytes (32 bytes) in little-endian byte order.
321
+ *
322
+ * This is the internal representation used by secp256k1. The byte order is
323
+ * reversed compared to the hex string representation (which uses big-endian,
324
+ * following Bitcoin display conventions).
325
+ */
326
+ toBytes(): Uint8Array;
327
+ /**
328
+ * Returns string representation of the ABF
329
+ */
330
+ toString(): string;
331
+ }
293
332
  /**
294
333
  * A valid asset identifier.
295
334
  *
@@ -300,11 +339,25 @@ export class AssetId {
300
339
  [Symbol.dispose](): void;
301
340
  /**
302
341
  * Creates an `AssetId`
342
+ *
343
+ * Deprecated: use `from_string()` instead
303
344
  */
304
345
  constructor(asset_id: string);
346
+ /**
347
+ * Creates an `AssetId` from hex string
348
+ */
349
+ static fromString(s: string): AssetId;
350
+ /**
351
+ * Creates an `AssetId` from a bytes.
352
+ */
353
+ static fromBytes(bytes: Uint8Array): AssetId;
354
+ /**
355
+ * Returns the `AssetId` bytes in little-endian byte order.
356
+ */
357
+ toBytes(): Uint8Array;
305
358
  /**
306
359
  * Return the string representation of the asset identifier (64 hex characters).
307
- * This representation can be used to recreate the asset identifier via `new()`
360
+ * This representation can be used to recreate the asset identifier via `fromString()`
308
361
  */
309
362
  toString(): string;
310
363
  }
@@ -699,12 +752,12 @@ export class Jade {
699
752
  free(): void;
700
753
  [Symbol.dispose](): void;
701
754
  /**
702
- * Creates a Jade from Web Serial for the given network
755
+ * Creates a Jade from Web Serial for the given network.
703
756
  *
704
757
  * When filter is true, it will filter available serial with Blockstream released chips, use
705
758
  * false if you don't see your DYI jade
706
759
  */
707
- constructor(network: Network, filter: boolean);
760
+ static fromSerial(network: Network, filter: boolean): Promise<Jade>;
708
761
  getVersion(): Promise<any>;
709
762
  getMasterXpub(): Promise<Xpub>;
710
763
  /**
@@ -742,7 +795,7 @@ export class JadeWebSocket {
742
795
  *
743
796
  * The url should point to your WebSocket bridge that connects to the Docker Jade emulator
744
797
  */
745
- constructor(network: Network, url: string);
798
+ static fromWebSocket(network: Network, url: string): Promise<JadeWebSocket>;
746
799
  getVersion(): Promise<any>;
747
800
  getMasterXpub(): Promise<Xpub>;
748
801
  /**
@@ -778,7 +831,8 @@ export class JsStoreLink {
778
831
  /**
779
832
  * Create a new `JsStoreLink` from a JavaScript storage object.
780
833
  *
781
- * The JS object must have `get(key)`, `put(key, value)`, and `remove(key)` methods.
834
+ * The JS object must have `get(key)`, `put(key, value)`, `remove(key)`,
835
+ * and `isPersisted()` methods.
782
836
  */
783
837
  constructor(storage: any);
784
838
  }
@@ -1449,6 +1503,18 @@ export class Script {
1449
1503
  export class Signer {
1450
1504
  free(): void;
1451
1505
  [Symbol.dispose](): void;
1506
+ /**
1507
+ * AMP0 signer data for login
1508
+ */
1509
+ amp0SignerData(): Amp0SignerData;
1510
+ /**
1511
+ * AMP0 sign login challenge
1512
+ */
1513
+ amp0SignChallenge(challenge: string): string;
1514
+ /**
1515
+ * AMP0 account xpub
1516
+ */
1517
+ amp0AccountXpub(account: number): string;
1452
1518
  /**
1453
1519
  * Creates a `Signer`
1454
1520
  */
@@ -1485,18 +1551,6 @@ export class Signer {
1485
1551
  * Return the derived BIP85 mnemonic
1486
1552
  */
1487
1553
  derive_bip85_mnemonic(index: number, word_count: number): Mnemonic;
1488
- /**
1489
- * AMP0 signer data for login
1490
- */
1491
- amp0SignerData(): Amp0SignerData;
1492
- /**
1493
- * AMP0 sign login challenge
1494
- */
1495
- amp0SignChallenge(challenge: string): string;
1496
- /**
1497
- * AMP0 account xpub
1498
- */
1499
- amp0AccountXpub(account: number): string;
1500
1554
  }
1501
1555
  export class Singlesig {
1502
1556
  private constructor();
@@ -1526,8 +1580,18 @@ export class Transaction {
1526
1580
  [Symbol.dispose](): void;
1527
1581
  /**
1528
1582
  * Creates a `Transaction`
1583
+ *
1584
+ * Deprecated: use `fromString()` instead.
1529
1585
  */
1530
1586
  constructor(tx_hex: string);
1587
+ /**
1588
+ * Creates a `Transaction` from hex-encoded consensus bytes.
1589
+ */
1590
+ static fromString(s: string): Transaction;
1591
+ /**
1592
+ * Creates a `Transaction` from consensus-encoded bytes.
1593
+ */
1594
+ static fromBytes(bytes: Uint8Array): Transaction;
1531
1595
  /**
1532
1596
  * Return the transaction identifier.
1533
1597
  */
@@ -1535,6 +1599,12 @@ export class Transaction {
1535
1599
  /**
1536
1600
  * Return the consensus encoded bytes of the transaction.
1537
1601
  */
1602
+ toBytes(): Uint8Array;
1603
+ /**
1604
+ * Return the consensus encoded bytes of the transaction.
1605
+ *
1606
+ * Deprecated: use `toBytes()` instead.
1607
+ */
1538
1608
  bytes(): Uint8Array;
1539
1609
  /**
1540
1610
  * Return the fee of the transaction in the given asset.
@@ -1657,6 +1727,115 @@ export class TxBuilder {
1657
1727
  */
1658
1728
  addInputRangeproofs(add_rangeproofs: boolean): TxBuilder;
1659
1729
  }
1730
+ /**
1731
+ * Transaction details
1732
+ */
1733
+ export class TxDetails {
1734
+ private constructor();
1735
+ free(): void;
1736
+ [Symbol.dispose](): void;
1737
+ /**
1738
+ * Transaction
1739
+ */
1740
+ tx(): Transaction | undefined;
1741
+ /**
1742
+ * Txid
1743
+ */
1744
+ txid(): Txid;
1745
+ /**
1746
+ * Blockchain height
1747
+ */
1748
+ height(): number | undefined;
1749
+ /**
1750
+ * Timestamp
1751
+ *
1752
+ * A reasonable timestamp, that however can be inaccurate.
1753
+ * If you need a precise timestamp, do not use this value.
1754
+ */
1755
+ timestamp(): number | undefined;
1756
+ /**
1757
+ * Transaction type
1758
+ *
1759
+ * A tentative description of the transaction type, which
1760
+ * however might be inaccurate. Use this if you want a simple
1761
+ * description of what this transaction is doing, but do
1762
+ * not rely on the value returned.
1763
+ */
1764
+ txType(): string;
1765
+ /**
1766
+ * Balance
1767
+ *
1768
+ * Net balance from the `Wollet` perspective
1769
+ */
1770
+ balance(): Balance;
1771
+ /**
1772
+ * Asset fees
1773
+ */
1774
+ feesAsset(asset: AssetId): bigint;
1775
+ /**
1776
+ * Unblinded URL
1777
+ */
1778
+ unblindedUrl(explorer_url: string): string;
1779
+ /**
1780
+ * Inputs
1781
+ */
1782
+ inputs(): TxOutDetails[];
1783
+ /**
1784
+ * Outputs
1785
+ */
1786
+ outputs(): TxOutDetails[];
1787
+ }
1788
+ /**
1789
+ * Options for transaction details
1790
+ */
1791
+ export class TxOpt {
1792
+ private constructor();
1793
+ free(): void;
1794
+ [Symbol.dispose](): void;
1795
+ static default(): TxOpt;
1796
+ }
1797
+ /**
1798
+ * Transaction output details
1799
+ */
1800
+ export class TxOutDetails {
1801
+ private constructor();
1802
+ free(): void;
1803
+ [Symbol.dispose](): void;
1804
+ /**
1805
+ * Outpoint
1806
+ */
1807
+ outpoint(): OutPoint;
1808
+ /**
1809
+ * Scriptpubkey
1810
+ */
1811
+ script_pubkey(): Script | undefined;
1812
+ /**
1813
+ * Height
1814
+ */
1815
+ height(): number | undefined;
1816
+ /**
1817
+ * Address
1818
+ */
1819
+ address(): Address | undefined;
1820
+ /**
1821
+ * Unblinded values (asset, amount, blinders)
1822
+ */
1823
+ unblinded(): TxOutSecrets | undefined;
1824
+ /**
1825
+ * Whether the transaction output is explicit
1826
+ */
1827
+ is_explicit(): boolean;
1828
+ /**
1829
+ * Whether the output is spent by a previously downloaded transaction
1830
+ *
1831
+ * Note: this value might be inaccurate. We compute this from downloaded
1832
+ * transactions, however we only download transactions relevant for the
1833
+ * wallet (i.e. if they include inputs or outputs that belong to the
1834
+ * wallet), thus for non-wallet outputs we might set this value
1835
+ * incorrectly. For wallet outputs, it can be outdated.
1836
+ */
1837
+ is_spent(): boolean;
1838
+ }
1660
1839
  /**
1661
1840
  * Contains unblinded information such as the asset and the value of a transaction output
1662
1841
  */
@@ -1675,17 +1854,17 @@ export class TxOutSecrets {
1675
1854
  */
1676
1855
  asset(): AssetId;
1677
1856
  /**
1678
- * Return the asset blinding factor as a hex string.
1857
+ * Return the asset blinding factor as a typed object.
1679
1858
  */
1680
- assetBlindingFactor(): string;
1859
+ assetBlindingFactor(): AssetBlindingFactor;
1681
1860
  /**
1682
1861
  * Return the value of the output.
1683
1862
  */
1684
1863
  value(): bigint;
1685
1864
  /**
1686
- * Return the value blinding factor as a hex string.
1865
+ * Return the value blinding factor as a typed object.
1687
1866
  */
1688
- valueBlindingFactor(): string;
1867
+ valueBlindingFactor(): ValueBlindingFactor;
1689
1868
  /**
1690
1869
  * Return true if the output is explicit (no blinding factors).
1691
1870
  */
@@ -1721,6 +1900,16 @@ export class Txid {
1721
1900
  */
1722
1901
  toString(): string;
1723
1902
  }
1903
+ /**
1904
+ * Options for transaction details
1905
+ */
1906
+ export class TxsOpt {
1907
+ private constructor();
1908
+ free(): void;
1909
+ [Symbol.dispose](): void;
1910
+ static default(): TxsOpt;
1911
+ static withPagination(offset: number, limit: number): TxsOpt;
1912
+ }
1724
1913
  /**
1725
1914
  * LiquiDEX swap proposal
1726
1915
  *
@@ -1790,6 +1979,38 @@ export class ValidatedLiquidexProposal {
1790
1979
  output(): AssetAmount;
1791
1980
  toString(): string;
1792
1981
  }
1982
+ /**
1983
+ * A blinding factor for value commitments.
1984
+ */
1985
+ export class ValueBlindingFactor {
1986
+ private constructor();
1987
+ free(): void;
1988
+ [Symbol.dispose](): void;
1989
+ /**
1990
+ * Creates a `ValueBlindingFactor` from a string.
1991
+ */
1992
+ static fromString(s: string): ValueBlindingFactor;
1993
+ /**
1994
+ * Creates a `ValueBlindingFactor` from a byte slice.
1995
+ */
1996
+ static fromBytes(bytes: Uint8Array): ValueBlindingFactor;
1997
+ /**
1998
+ * Returns a zero value blinding factor.
1999
+ */
2000
+ static zero(): ValueBlindingFactor;
2001
+ /**
2002
+ * Returns the bytes (32 bytes) in little-endian byte order.
2003
+ *
2004
+ * This is the internal representation used by secp256k1. The byte order is
2005
+ * reversed compared to the hex string representation (which uses big-endian,
2006
+ * following Bitcoin display conventions).
2007
+ */
2008
+ toBytes(): Uint8Array;
2009
+ /**
2010
+ * Returns string representation of the VBF
2011
+ */
2012
+ toString(): string;
2013
+ }
1793
2014
  /**
1794
2015
  * Value returned by asking transactions to the wallet. Contains details about a transaction
1795
2016
  * from the perspective of the wallet, for example the net-balance of the transaction for the
@@ -1887,6 +2108,22 @@ export class WalletTxOut {
1887
2108
  export class Wollet {
1888
2109
  free(): void;
1889
2110
  [Symbol.dispose](): void;
2111
+ /**
2112
+ * Get the transaction list
2113
+ *
2114
+ * **Experimental**: This API may change without notice.
2115
+ */
2116
+ txs(opt: TxsOpt): TxDetails[];
2117
+ /**
2118
+ * Number of transactions
2119
+ */
2120
+ numTxs(): number;
2121
+ /**
2122
+ * Get the details of a transaction
2123
+ *
2124
+ * **Experimental**: This API may change without notice.
2125
+ */
2126
+ txDetails(txid: Txid, opt: TxOpt): TxDetails | undefined;
1890
2127
  /**
1891
2128
  * Create a `Wollet`
1892
2129
  */
@@ -1953,9 +2190,13 @@ export class Wollet {
1953
2190
  */
1954
2191
  assetsOwned(): AssetIds;
1955
2192
  /**
1956
- * Get the wallet transactions
2193
+ * Get the wallet transactions, sorted by height descending, then txid descending with unconfirmed first
1957
2194
  */
1958
2195
  transactions(): WalletTx[];
2196
+ /**
2197
+ * Get the wallet transactions with pagination sorted by height descending, then txid descending with unconfirmed first
2198
+ */
2199
+ transactionsPaginated(offset: number, limit: number): WalletTx[];
1959
2200
  /**
1960
2201
  * Get the unspent transaction outputs of the wallet
1961
2202
  */
@@ -1998,6 +2239,62 @@ export class Wollet {
1998
2239
  */
1999
2240
  isAmp0(): boolean;
2000
2241
  }
2242
+ /**
2243
+ * A builder for constructing [`Wollet`] instances.
2244
+ */
2245
+ export class WolletBuilder {
2246
+ free(): void;
2247
+ [Symbol.dispose](): void;
2248
+ /**
2249
+ * Create a builder for a watch-only wallet.
2250
+ */
2251
+ constructor(network: Network, descriptor: WolletDescriptor);
2252
+ /**
2253
+ * Set the threshold used to merge persisted updates during build.
2254
+ *
2255
+ * **Experimental**: This API may change without notice.
2256
+ *
2257
+ * `None` disables merging (default behavior).
2258
+ */
2259
+ withMergeThreshold(merge_threshold?: number | null): WolletBuilder;
2260
+ /**
2261
+ * Set the wallet as "utxo only".
2262
+ *
2263
+ * **Experimental**: This API may change without notice.
2264
+ */
2265
+ utxoOnly(utxo_only: boolean): WolletBuilder;
2266
+ /**
2267
+ * Persist wallet updates in the given JavaScript storage object.
2268
+ *
2269
+ * **Experimental**: This API may change without notice.
2270
+ *
2271
+ * Wallet data is persisted in clear.
2272
+ *
2273
+ * The JS object must have `get(key)`, `put(key, value)`, and `remove(key)` methods.
2274
+ */
2275
+ withExperimentalStore(storage: any): WolletBuilder;
2276
+ /**
2277
+ * Persist wallet transactions in the given JavaScript
2278
+ * storage object.
2279
+ *
2280
+ * **Experimental**: This API may change without notice.
2281
+ *
2282
+ * The JS object must have `get(key)`, `put(key, value)`, and `remove(key)` methods.
2283
+ */
2284
+ withTxsStore(storage: any): WolletBuilder;
2285
+ /**
2286
+ * Set encryption for the transactions store.
2287
+ *
2288
+ * **Experimental**: This API may change without notice.
2289
+ *
2290
+ * Default: encrypted if the store is persisted.
2291
+ */
2292
+ setEncryptionTxsStore(encrypt: boolean): WolletBuilder;
2293
+ /**
2294
+ * Build the wallet from this builder.
2295
+ */
2296
+ build(): Wollet;
2297
+ }
2001
2298
  /**
2002
2299
  * A wrapper that contains only the subset of CT descriptors handled by wollet
2003
2300
  */