lwk_node 0.11.0 → 0.12.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/README.md +56 -1
- package/lwk_wasm.d.ts +720 -63
- package/lwk_wasm.js +771 -136
- package/lwk_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/lwk_wasm.d.ts
CHANGED
|
@@ -16,24 +16,40 @@ export enum Chain {
|
|
|
16
16
|
Internal = 1,
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* An Elements (Liquid) address
|
|
20
20
|
*/
|
|
21
21
|
export class Address {
|
|
22
22
|
free(): void;
|
|
23
23
|
/**
|
|
24
24
|
* Creates an `Address`
|
|
25
25
|
*
|
|
26
|
-
* If you know the network, you can use
|
|
26
|
+
* If you know the network, you can use `parse()` to validate that the network is consistent.
|
|
27
27
|
*/
|
|
28
28
|
constructor(s: string);
|
|
29
29
|
/**
|
|
30
30
|
* Parses an `Address` ensuring is for the right network
|
|
31
31
|
*/
|
|
32
32
|
static parse(s: string, network: Network): Address;
|
|
33
|
+
/**
|
|
34
|
+
* Return the script pubkey of the address.
|
|
35
|
+
*/
|
|
33
36
|
scriptPubkey(): Script;
|
|
37
|
+
/**
|
|
38
|
+
* Return true if the address is blinded, in other words, if it has a blinding key.
|
|
39
|
+
*/
|
|
34
40
|
isBlinded(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Return true if the address is for mainnet.
|
|
43
|
+
*/
|
|
35
44
|
isMainnet(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Return the unconfidential address, in other words, the address without the blinding key.
|
|
47
|
+
*/
|
|
36
48
|
toUnconfidential(): Address;
|
|
49
|
+
/**
|
|
50
|
+
* Return the string representation of the address.
|
|
51
|
+
* This representation can be used to recreate the address via `new()`
|
|
52
|
+
*/
|
|
37
53
|
toString(): string;
|
|
38
54
|
/**
|
|
39
55
|
* Returns a string encoding an image in a uri
|
|
@@ -51,16 +67,43 @@ export class Address {
|
|
|
51
67
|
QRCodeText(): string;
|
|
52
68
|
}
|
|
53
69
|
/**
|
|
54
|
-
*
|
|
70
|
+
* Value returned from asking an address to the wallet.
|
|
71
|
+
* Containing the confidential address and its
|
|
72
|
+
* derivation index (the last element in the derivation path)
|
|
55
73
|
*/
|
|
56
74
|
export class AddressResult {
|
|
57
75
|
private constructor();
|
|
58
76
|
free(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Return the address.
|
|
79
|
+
*/
|
|
59
80
|
address(): Address;
|
|
81
|
+
/**
|
|
82
|
+
* Return the derivation index of the address.
|
|
83
|
+
*/
|
|
60
84
|
index(): number;
|
|
61
85
|
}
|
|
62
86
|
/**
|
|
63
|
-
*
|
|
87
|
+
* Context for actions related to an AMP0 (sub)account
|
|
88
|
+
*
|
|
89
|
+
* <div class="warning">
|
|
90
|
+
* <b>WARNING:</b>
|
|
91
|
+
*
|
|
92
|
+
* AMP0 is based on a legacy system, and some things do not fit precisely the way LWK allows to do
|
|
93
|
+
* things.
|
|
94
|
+
*
|
|
95
|
+
* Callers must be careful with the following:
|
|
96
|
+
* * <b>Addresses: </b>
|
|
97
|
+
* to get addresses use [`Amp0::address()`]. This ensures
|
|
98
|
+
* that all addresses used are correctly monitored by the AMP0 server.
|
|
99
|
+
* * <b>Syncing: </b>
|
|
100
|
+
* to sync the AMP0 [`crate::Wollet`], use [`Amp0::last_index()`] and [`crate::clients::blocking::BlockchainBackend::full_scan_to_index()`]. This ensures that all utxos are synced, even if there are gaps between higher than the GAP LIMIT.
|
|
101
|
+
*
|
|
102
|
+
* <i>
|
|
103
|
+
* Failing to do the above might lead to inconsistent states, where funds are not shown or they
|
|
104
|
+
* cannot be spent!
|
|
105
|
+
* </i>
|
|
106
|
+
* </div>
|
|
64
107
|
*/
|
|
65
108
|
export class Amp0 {
|
|
66
109
|
private constructor();
|
|
@@ -72,7 +115,7 @@ export class Amp0 {
|
|
|
72
115
|
/**
|
|
73
116
|
* Create a new AMP0 context for testnet
|
|
74
117
|
*/
|
|
75
|
-
static
|
|
118
|
+
static newTestnet(username: string, password: string, amp_id: string): Promise<Amp0>;
|
|
76
119
|
/**
|
|
77
120
|
* Create a new AMP0 context for mainnet
|
|
78
121
|
*/
|
|
@@ -103,7 +146,64 @@ export class Amp0 {
|
|
|
103
146
|
sign(amp0pset: Amp0Pset): Promise<Transaction>;
|
|
104
147
|
}
|
|
105
148
|
/**
|
|
106
|
-
*
|
|
149
|
+
* Session connecting to AMP0
|
|
150
|
+
*/
|
|
151
|
+
export class Amp0Connected {
|
|
152
|
+
free(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Connect and register to AMP0
|
|
155
|
+
*/
|
|
156
|
+
constructor(network: Network, signer_data: Amp0SignerData);
|
|
157
|
+
/**
|
|
158
|
+
* Obtain a login challenge
|
|
159
|
+
*
|
|
160
|
+
* This must be signed with [`amp0_sign_challenge()`].
|
|
161
|
+
*/
|
|
162
|
+
get_challenge(): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Log in
|
|
165
|
+
*
|
|
166
|
+
* `sig` must be obtained from [`amp0_sign_challenge()`] called with the value returned
|
|
167
|
+
* by [`Amp0Connected::get_challenge()`]
|
|
168
|
+
*/
|
|
169
|
+
login(sig: string): Promise<Amp0LoggedIn>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Session logged in AMP0
|
|
173
|
+
*/
|
|
174
|
+
export class Amp0LoggedIn {
|
|
175
|
+
private constructor();
|
|
176
|
+
free(): void;
|
|
177
|
+
/**
|
|
178
|
+
* List of AMP IDs.
|
|
179
|
+
*/
|
|
180
|
+
get_amp_ids(): string[];
|
|
181
|
+
/**
|
|
182
|
+
* Get the next account for AMP0 account creation
|
|
183
|
+
*
|
|
184
|
+
* This must be given to [`amp0_account_xpub()`] to obtain the xpub to pass to
|
|
185
|
+
* [`Amp0LoggedIn::create_amp0_account()`]
|
|
186
|
+
*/
|
|
187
|
+
next_account(): number;
|
|
188
|
+
/**
|
|
189
|
+
* Create a new AMP0 account
|
|
190
|
+
*
|
|
191
|
+
* `account_xpub` must be obtained from [`amp0_account_xpub()`] called with the value obtained from
|
|
192
|
+
* [`Amp0LoggedIn::next_account()`]
|
|
193
|
+
*/
|
|
194
|
+
create_amp0_account(pointer: number, account_xpub: string): Promise<string>;
|
|
195
|
+
/**
|
|
196
|
+
* Create a new Watch-Only entry for this wallet
|
|
197
|
+
*/
|
|
198
|
+
create_watch_only(username: string, password: string): Promise<void>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A PSET to use with AMP0
|
|
202
|
+
*
|
|
203
|
+
* When asking AMP0 to cosign, the caller must pass some extra data that does not belong to the
|
|
204
|
+
* PSET. This struct holds and manage the necessary data.
|
|
205
|
+
*
|
|
206
|
+
* If you're not dealing with AMP0, do not use this struct.
|
|
107
207
|
*/
|
|
108
208
|
export class Amp0Pset {
|
|
109
209
|
free(): void;
|
|
@@ -120,28 +220,50 @@ export class Amp0Pset {
|
|
|
120
220
|
*/
|
|
121
221
|
blindingNonces(): string[];
|
|
122
222
|
}
|
|
223
|
+
export class Amp0SignerData {
|
|
224
|
+
private constructor();
|
|
225
|
+
free(): void;
|
|
226
|
+
}
|
|
123
227
|
/**
|
|
124
|
-
*
|
|
228
|
+
* Context for actions interacting with Asset Management Platform version 2
|
|
125
229
|
*/
|
|
126
230
|
export class Amp2 {
|
|
127
231
|
private constructor();
|
|
128
232
|
free(): void;
|
|
129
|
-
|
|
130
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Create a new AMP2 client with the default url and server key for the testnet network.
|
|
235
|
+
*/
|
|
236
|
+
static newTestnet(): Amp2;
|
|
237
|
+
/**
|
|
238
|
+
* Get an AMP2 wallet descriptor from the keyorigin xpub string obtained from a signer
|
|
239
|
+
*/
|
|
240
|
+
descriptorFromStr(keyorigin_xpub: string): Amp2Descriptor;
|
|
241
|
+
/**
|
|
242
|
+
* Register an AMP2 wallet with the AMP2 server
|
|
243
|
+
*/
|
|
131
244
|
register(desc: Amp2Descriptor): Promise<string>;
|
|
245
|
+
/**
|
|
246
|
+
* Ask the AMP2 server to cosign a PSET
|
|
247
|
+
*/
|
|
132
248
|
cosign(pset: Pset): Promise<Pset>;
|
|
133
249
|
}
|
|
134
250
|
/**
|
|
135
|
-
*
|
|
251
|
+
* An Asset Management Platform version 2 descriptor
|
|
136
252
|
*/
|
|
137
253
|
export class Amp2Descriptor {
|
|
138
254
|
private constructor();
|
|
139
255
|
free(): void;
|
|
256
|
+
/**
|
|
257
|
+
* Return the descriptor as a `WolletDescriptor`
|
|
258
|
+
*/
|
|
140
259
|
descriptor(): WolletDescriptor;
|
|
260
|
+
/**
|
|
261
|
+
* Return the string representation of the descriptor.
|
|
262
|
+
*/
|
|
141
263
|
toString(): string;
|
|
142
264
|
}
|
|
143
265
|
/**
|
|
144
|
-
*
|
|
266
|
+
* An asset identifier and an amount in satoshi units
|
|
145
267
|
*/
|
|
146
268
|
export class AssetAmount {
|
|
147
269
|
private constructor();
|
|
@@ -150,7 +272,7 @@ export class AssetAmount {
|
|
|
150
272
|
asset(): AssetId;
|
|
151
273
|
}
|
|
152
274
|
/**
|
|
153
|
-
* A valid asset identifier.
|
|
275
|
+
* A valid asset identifier.
|
|
154
276
|
*
|
|
155
277
|
* 32 bytes encoded as hex string.
|
|
156
278
|
*/
|
|
@@ -160,25 +282,69 @@ export class AssetId {
|
|
|
160
282
|
* Creates an `AssetId`
|
|
161
283
|
*/
|
|
162
284
|
constructor(asset_id: string);
|
|
285
|
+
/**
|
|
286
|
+
* Return the string representation of the asset identifier (64 hex characters).
|
|
287
|
+
* This representation can be used to recreate the asset identifier via `new()`
|
|
288
|
+
*/
|
|
163
289
|
toString(): string;
|
|
164
290
|
}
|
|
165
291
|
/**
|
|
166
|
-
*
|
|
292
|
+
* An ordered collection of asset identifiers.
|
|
167
293
|
*/
|
|
168
294
|
export class AssetIds {
|
|
169
295
|
private constructor();
|
|
170
296
|
free(): void;
|
|
297
|
+
/**
|
|
298
|
+
* Return an empty list of asset identifiers.
|
|
299
|
+
*/
|
|
171
300
|
static empty(): AssetIds;
|
|
301
|
+
/**
|
|
302
|
+
* Return the string representation of this list of asset identifiers.
|
|
303
|
+
*/
|
|
172
304
|
toString(): string;
|
|
173
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Data related to an asset in the registry:
|
|
308
|
+
* - contract: the contract of the asset
|
|
309
|
+
* - tx: the issuance transaction of the asset
|
|
310
|
+
*/
|
|
174
311
|
export class AssetMeta {
|
|
175
312
|
private constructor();
|
|
176
313
|
free(): void;
|
|
314
|
+
/**
|
|
315
|
+
* Return the contract of the asset.
|
|
316
|
+
*/
|
|
177
317
|
contract(): Contract;
|
|
318
|
+
/**
|
|
319
|
+
* Return the issuance transaction of the asset.
|
|
320
|
+
*/
|
|
178
321
|
tx(): Transaction;
|
|
179
322
|
}
|
|
180
323
|
/**
|
|
181
|
-
*
|
|
324
|
+
* A signed balance of assets, to represent a balance with negative values such
|
|
325
|
+
* as the results of a transaction from the perspective of a wallet.
|
|
326
|
+
*/
|
|
327
|
+
export class Balance {
|
|
328
|
+
private constructor();
|
|
329
|
+
free(): void;
|
|
330
|
+
/**
|
|
331
|
+
* Convert the balance to a JsValue for serialization
|
|
332
|
+
*
|
|
333
|
+
* Note: the amounts are strings since `JSON.stringify` cannot handle `BigInt`s.
|
|
334
|
+
* Use `entries()` to get the raw data.
|
|
335
|
+
*/
|
|
336
|
+
toJSON(): any;
|
|
337
|
+
/**
|
|
338
|
+
* Returns the balance as an array of [key, value] pairs.
|
|
339
|
+
*/
|
|
340
|
+
entries(): any;
|
|
341
|
+
/**
|
|
342
|
+
* Return the string representation of the balance.
|
|
343
|
+
*/
|
|
344
|
+
toString(): string;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The bip variant for a descriptor like specified in the bips (49, 84, 87)
|
|
182
348
|
*/
|
|
183
349
|
export class Bip {
|
|
184
350
|
private constructor();
|
|
@@ -195,10 +361,13 @@ export class Bip {
|
|
|
195
361
|
* Creates a bip87 variant
|
|
196
362
|
*/
|
|
197
363
|
static bip87(): Bip;
|
|
364
|
+
/**
|
|
365
|
+
* Return the string representation of the bip variant, such as "bip49", "bip84" or "bip87"
|
|
366
|
+
*/
|
|
198
367
|
toString(): string;
|
|
199
368
|
}
|
|
200
369
|
/**
|
|
201
|
-
*
|
|
370
|
+
* A contract defining metadata of an asset such the name and the ticker
|
|
202
371
|
*/
|
|
203
372
|
export class Contract {
|
|
204
373
|
free(): void;
|
|
@@ -206,43 +375,110 @@ export class Contract {
|
|
|
206
375
|
* Creates a `Contract`
|
|
207
376
|
*/
|
|
208
377
|
constructor(domain: string, issuer_pubkey: string, name: string, precision: number, ticker: string, version: number);
|
|
378
|
+
/**
|
|
379
|
+
* Return the string representation of the contract.
|
|
380
|
+
*/
|
|
209
381
|
toString(): string;
|
|
382
|
+
/**
|
|
383
|
+
* Return the domain of the issuer of the contract.
|
|
384
|
+
*/
|
|
210
385
|
domain(): string;
|
|
386
|
+
/**
|
|
387
|
+
* Make a copy of the contract.
|
|
388
|
+
*
|
|
389
|
+
* This is needed to pass it to a function that requires a `Contract` (without borrowing)
|
|
390
|
+
* but you need the same contract after that call.
|
|
391
|
+
*/
|
|
211
392
|
clone(): Contract;
|
|
212
393
|
}
|
|
213
394
|
/**
|
|
214
|
-
*
|
|
395
|
+
* A blockchain backend implementation based on the
|
|
396
|
+
* [esplora HTTP API](https://github.com/blockstream/esplora/blob/master/API.md).
|
|
397
|
+
* But can also use the [waterfalls](https://github.com/RCasatta/waterfalls)
|
|
398
|
+
* endpoint to speed up the scan if supported by the server.
|
|
215
399
|
*/
|
|
216
400
|
export class EsploraClient {
|
|
217
401
|
free(): void;
|
|
218
402
|
/**
|
|
219
|
-
* Creates
|
|
403
|
+
* Creates an Esplora client with the given options
|
|
220
404
|
*/
|
|
221
405
|
constructor(network: Network, url: string, waterfalls: boolean, concurrency: number, utxo_only: boolean);
|
|
406
|
+
/**
|
|
407
|
+
* Scan the blockchain for the scripts generated by a watch-only wallet
|
|
408
|
+
*
|
|
409
|
+
* This method scans both external and internal address chains, stopping after finding
|
|
410
|
+
* 20 consecutive unused addresses (the gap limit) as recommended by
|
|
411
|
+
* [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#address-gap-limit).
|
|
412
|
+
*
|
|
413
|
+
* Returns `Some(Update)` if any changes were found during scanning, or `None` if no changes
|
|
414
|
+
* were detected.
|
|
415
|
+
*
|
|
416
|
+
* To scan beyond the gap limit use `full_scan_to_index()` instead.
|
|
417
|
+
*/
|
|
222
418
|
fullScan(wollet: Wollet): Promise<Update | undefined>;
|
|
223
419
|
/**
|
|
224
420
|
* Scan the blockchain for the scripts generated by a watch-only wallet up to a specified derivation index
|
|
421
|
+
*
|
|
422
|
+
* While `full_scan()` stops after finding 20 consecutive unused addresses (the gap limit),
|
|
423
|
+
* this method will scan at least up to the given derivation index. This is useful to prevent
|
|
424
|
+
* missing funds in cases where outputs exist beyond the gap limit.
|
|
425
|
+
*
|
|
426
|
+
* Will scan both external and internal address chains up to the given index for maximum safety,
|
|
427
|
+
* even though internal addresses may not need such deep scanning.
|
|
428
|
+
*
|
|
429
|
+
* If transactions are found beyond the gap limit during this scan, subsequent calls to
|
|
430
|
+
* `full_scan()` will automatically scan up to the highest used index, preventing any
|
|
431
|
+
* previously-found transactions from being missed.
|
|
432
|
+
*
|
|
433
|
+
* See `full_scan_to_index()` for a blocking version of this method.
|
|
225
434
|
*/
|
|
226
435
|
fullScanToIndex(wollet: Wollet, index: number): Promise<Update | undefined>;
|
|
436
|
+
/**
|
|
437
|
+
* Broadcast a transaction to the network so that a miner can include it in a block.
|
|
438
|
+
*/
|
|
227
439
|
broadcastTx(tx: Transaction): Promise<Txid>;
|
|
440
|
+
/**
|
|
441
|
+
* Broadcast a PSET by extracting the transaction from the PSET and broadcasting it.
|
|
442
|
+
*/
|
|
228
443
|
broadcast(pset: Pset): Promise<Txid>;
|
|
229
|
-
|
|
444
|
+
/**
|
|
445
|
+
* Set the waterfalls server recipient key. This is used to encrypt the descriptor when calling the waterfalls endpoint.
|
|
446
|
+
*/
|
|
447
|
+
setWaterfallsServerRecipient(recipient: string): Promise<void>;
|
|
230
448
|
}
|
|
231
449
|
/**
|
|
232
|
-
*
|
|
450
|
+
* The details of an issuance or reissuance.
|
|
233
451
|
*/
|
|
234
452
|
export class Issuance {
|
|
235
453
|
private constructor();
|
|
236
454
|
free(): void;
|
|
455
|
+
/**
|
|
456
|
+
* Return the asset id or None if it's a null issuance
|
|
457
|
+
*/
|
|
237
458
|
asset(): AssetId | undefined;
|
|
459
|
+
/**
|
|
460
|
+
* Return the token id or None if it's a null issuance
|
|
461
|
+
*/
|
|
238
462
|
token(): AssetId | undefined;
|
|
463
|
+
/**
|
|
464
|
+
* Return the previous output index or None if it's a null issuance
|
|
465
|
+
*/
|
|
239
466
|
prevVout(): number | undefined;
|
|
467
|
+
/**
|
|
468
|
+
* Return the previous transaction id or None if it's a null issuance
|
|
469
|
+
*/
|
|
240
470
|
prevTxid(): Txid | undefined;
|
|
471
|
+
/**
|
|
472
|
+
* Return true if this is effectively an issuance
|
|
473
|
+
*/
|
|
241
474
|
isIssuance(): boolean;
|
|
475
|
+
/**
|
|
476
|
+
* Return true if this is effectively a reissuance
|
|
477
|
+
*/
|
|
242
478
|
isReissuance(): boolean;
|
|
243
479
|
}
|
|
244
480
|
/**
|
|
245
|
-
*
|
|
481
|
+
* A Jade hardware wallet usable via Web Serial
|
|
246
482
|
*/
|
|
247
483
|
export class Jade {
|
|
248
484
|
free(): void;
|
|
@@ -280,7 +516,7 @@ export class Jade {
|
|
|
280
516
|
registerDescriptor(name: string, desc: WolletDescriptor): Promise<boolean>;
|
|
281
517
|
}
|
|
282
518
|
/**
|
|
283
|
-
* WebSocket-based
|
|
519
|
+
* WebSocket-based `Jade` useful for testing in the browser with the Jade emulator.
|
|
284
520
|
*/
|
|
285
521
|
export class JadeWebSocket {
|
|
286
522
|
free(): void;
|
|
@@ -340,7 +576,9 @@ export class LedgerWeb {
|
|
|
340
576
|
getReceiveAddressSingle(index: number): Promise<string>;
|
|
341
577
|
}
|
|
342
578
|
/**
|
|
343
|
-
*
|
|
579
|
+
* A mnemonic secret code used as a master secret for a bip39 wallet.
|
|
580
|
+
*
|
|
581
|
+
* Supported number of words are 12, 15, 18, 21, and 24.
|
|
344
582
|
*/
|
|
345
583
|
export class Mnemonic {
|
|
346
584
|
free(): void;
|
|
@@ -348,6 +586,12 @@ export class Mnemonic {
|
|
|
348
586
|
* Creates a Mnemonic
|
|
349
587
|
*/
|
|
350
588
|
constructor(s: string);
|
|
589
|
+
/**
|
|
590
|
+
* Return the string representation of the Mnemonic.
|
|
591
|
+
* This representation can be used to recreate the Mnemonic via `new()`
|
|
592
|
+
*
|
|
593
|
+
* Note this is secret information, do not log it.
|
|
594
|
+
*/
|
|
351
595
|
toString(): string;
|
|
352
596
|
/**
|
|
353
597
|
* Creates a Mnemonic from entropy, at least 16 bytes are needed.
|
|
@@ -359,7 +603,7 @@ export class Mnemonic {
|
|
|
359
603
|
static fromRandom(word_count: number): Mnemonic;
|
|
360
604
|
}
|
|
361
605
|
/**
|
|
362
|
-
*
|
|
606
|
+
* The network of the elements blockchain such as mainnet, testnet or regtest.
|
|
363
607
|
*/
|
|
364
608
|
export class Network {
|
|
365
609
|
private constructor();
|
|
@@ -380,13 +624,37 @@ export class Network {
|
|
|
380
624
|
* Creates the default regtest `Network` with the policy asset `5ac9f65c0efcc4775e0baec4ec03abdde22473cd3cf33c0419ca290e0751b225`
|
|
381
625
|
*/
|
|
382
626
|
static regtestDefault(): Network;
|
|
627
|
+
/**
|
|
628
|
+
* Return the default esplora client for this network
|
|
629
|
+
*/
|
|
383
630
|
defaultEsploraClient(): EsploraClient;
|
|
631
|
+
/**
|
|
632
|
+
* Return true if the network is a mainnet network
|
|
633
|
+
*/
|
|
384
634
|
isMainnet(): boolean;
|
|
635
|
+
/**
|
|
636
|
+
* Return true if the network is a testnet network
|
|
637
|
+
*/
|
|
385
638
|
isTestnet(): boolean;
|
|
639
|
+
/**
|
|
640
|
+
* Return true if the network is a regtest network
|
|
641
|
+
*/
|
|
386
642
|
isRegtest(): boolean;
|
|
643
|
+
/**
|
|
644
|
+
* Return a string representation of the network, like "liquid", "liquid-testnet" or "liquid-regtest"
|
|
645
|
+
*/
|
|
387
646
|
toString(): string;
|
|
647
|
+
/**
|
|
648
|
+
* Return the policy asset for this network
|
|
649
|
+
*/
|
|
388
650
|
policyAsset(): AssetId;
|
|
651
|
+
/**
|
|
652
|
+
* Return the transaction builder for this network
|
|
653
|
+
*/
|
|
389
654
|
txBuilder(): TxBuilder;
|
|
655
|
+
/**
|
|
656
|
+
* Return the default explorer URL for this network
|
|
657
|
+
*/
|
|
390
658
|
defaultExplorerUrl(): string;
|
|
391
659
|
}
|
|
392
660
|
/**
|
|
@@ -396,10 +664,13 @@ export class Network {
|
|
|
396
664
|
export class OptionWalletTxOut {
|
|
397
665
|
private constructor();
|
|
398
666
|
free(): void;
|
|
667
|
+
/**
|
|
668
|
+
* Return a copy of the WalletTxOut if it exists, otherwise None
|
|
669
|
+
*/
|
|
399
670
|
get(): WalletTxOut | undefined;
|
|
400
671
|
}
|
|
401
672
|
/**
|
|
402
|
-
*
|
|
673
|
+
* A reference to a transaction output
|
|
403
674
|
*/
|
|
404
675
|
export class OutPoint {
|
|
405
676
|
free(): void;
|
|
@@ -407,38 +678,78 @@ export class OutPoint {
|
|
|
407
678
|
* Creates an `OutPoint`
|
|
408
679
|
*/
|
|
409
680
|
constructor(s: string);
|
|
681
|
+
/**
|
|
682
|
+
* Return the transaction identifier.
|
|
683
|
+
*/
|
|
410
684
|
txid(): Txid;
|
|
685
|
+
/**
|
|
686
|
+
* Return the output index.
|
|
687
|
+
*/
|
|
411
688
|
vout(): number;
|
|
412
689
|
}
|
|
413
690
|
/**
|
|
414
|
-
*
|
|
691
|
+
* Helper to convert satoshi values of an asset to the value with the given precision and viceversa.
|
|
692
|
+
*
|
|
693
|
+
* For example 100 satoshi with precision 2 is "1.00"
|
|
415
694
|
*/
|
|
416
695
|
export class Precision {
|
|
417
696
|
free(): void;
|
|
418
697
|
/**
|
|
419
|
-
*
|
|
698
|
+
* Create a new Precision, useful to encode e decode values for assets with precision.
|
|
699
|
+
* erroring if the given precision is greater than the allowed maximum (8)
|
|
420
700
|
*/
|
|
421
701
|
constructor(precision: number);
|
|
702
|
+
/**
|
|
703
|
+
* Convert the given satoshi value to the formatted value according to our precision
|
|
704
|
+
*
|
|
705
|
+
* For example 100 satoshi with precision 2 is "1.00"
|
|
706
|
+
*/
|
|
422
707
|
satsToString(sats: bigint): string;
|
|
708
|
+
/**
|
|
709
|
+
* Convert the given string with precision to satoshi units.
|
|
710
|
+
*
|
|
711
|
+
* For example the string "1.00" of an asset with precision 2 is 100 satoshi.
|
|
712
|
+
*/
|
|
423
713
|
stringToSats(sats: string): bigint;
|
|
424
714
|
}
|
|
425
715
|
/**
|
|
426
|
-
* Partially Signed Elements Transaction
|
|
716
|
+
* Partially Signed Elements Transaction
|
|
427
717
|
*/
|
|
428
718
|
export class Pset {
|
|
429
719
|
free(): void;
|
|
430
720
|
/**
|
|
431
|
-
* Creates a `Pset`
|
|
721
|
+
* Creates a `Pset` from its base64 string representation.
|
|
432
722
|
*/
|
|
433
723
|
constructor(base64: string);
|
|
724
|
+
/**
|
|
725
|
+
* Return a base64 string representation of the Pset.
|
|
726
|
+
* The string can be used to re-create the Pset via `new()`
|
|
727
|
+
*/
|
|
434
728
|
toString(): string;
|
|
729
|
+
/**
|
|
730
|
+
* Extract the Transaction from a Pset by filling in
|
|
731
|
+
* the available signature information in place.
|
|
732
|
+
*/
|
|
435
733
|
extractTx(): Transaction;
|
|
734
|
+
/**
|
|
735
|
+
* Attempt to merge with another `Pset`.
|
|
736
|
+
*/
|
|
436
737
|
combine(other: Pset): void;
|
|
738
|
+
/**
|
|
739
|
+
* Return a copy of the inputs of this PSET
|
|
740
|
+
*/
|
|
437
741
|
inputs(): PsetInput[];
|
|
742
|
+
/**
|
|
743
|
+
* Return a copy of the outputs of this PSET
|
|
744
|
+
*/
|
|
438
745
|
outputs(): PsetOutput[];
|
|
439
746
|
}
|
|
440
747
|
/**
|
|
441
|
-
*
|
|
748
|
+
* The details regarding balance and amounts in a PSET:
|
|
749
|
+
*
|
|
750
|
+
* - The fee of the transaction in the PSET
|
|
751
|
+
* - The net balance of the assets in the PSET from the point of view of the wallet
|
|
752
|
+
* - The outputs going out of the wallet
|
|
442
753
|
*/
|
|
443
754
|
export class PsetBalance {
|
|
444
755
|
private constructor();
|
|
@@ -447,21 +758,35 @@ export class PsetBalance {
|
|
|
447
758
|
/**
|
|
448
759
|
* The net balance for every asset with respect of the wallet asking the pset details
|
|
449
760
|
*/
|
|
450
|
-
balances():
|
|
761
|
+
balances(): Balance;
|
|
451
762
|
recipients(): Recipient[];
|
|
452
763
|
}
|
|
453
764
|
/**
|
|
454
|
-
*
|
|
765
|
+
* The details of a Partially Signed Elements Transaction:
|
|
766
|
+
*
|
|
767
|
+
* - the net balance from the point of view of the wallet
|
|
768
|
+
* - the available and missing signatures for each input
|
|
769
|
+
* - for issuances and reissuances transactions contains the issuance or reissuance details
|
|
455
770
|
*/
|
|
456
771
|
export class PsetDetails {
|
|
457
772
|
private constructor();
|
|
458
773
|
free(): void;
|
|
774
|
+
/**
|
|
775
|
+
* Return the balance of the PSET from the point of view of the wallet
|
|
776
|
+
* that generated this via `psetDetails()`
|
|
777
|
+
*/
|
|
459
778
|
balance(): PsetBalance;
|
|
460
779
|
/**
|
|
461
780
|
* For each input existing or missing signatures
|
|
462
781
|
*/
|
|
463
782
|
signatures(): PsetSignatures[];
|
|
783
|
+
/**
|
|
784
|
+
* Set of fingerprints for which the PSET is missing a signature
|
|
785
|
+
*/
|
|
464
786
|
fingerprintsMissing(): string[];
|
|
787
|
+
/**
|
|
788
|
+
* List of fingerprints for which the PSET has a signature
|
|
789
|
+
*/
|
|
465
790
|
fingerprintsHas(): string[];
|
|
466
791
|
/**
|
|
467
792
|
* Return an element for every input that could possibly be a issuance or a reissuance
|
|
@@ -477,11 +802,11 @@ export class PsetInput {
|
|
|
477
802
|
/**
|
|
478
803
|
* Prevout TXID of the input
|
|
479
804
|
*/
|
|
480
|
-
|
|
805
|
+
previousTxid(): Txid;
|
|
481
806
|
/**
|
|
482
807
|
* Prevout vout of the input
|
|
483
808
|
*/
|
|
484
|
-
|
|
809
|
+
previousVout(): number;
|
|
485
810
|
/**
|
|
486
811
|
* If the input has an issuance, the asset id
|
|
487
812
|
*/
|
|
@@ -497,10 +822,10 @@ export class PsetInput {
|
|
|
497
822
|
export class PsetOutput {
|
|
498
823
|
private constructor();
|
|
499
824
|
free(): void;
|
|
500
|
-
|
|
825
|
+
scriptPubkey(): Script;
|
|
501
826
|
}
|
|
502
827
|
/**
|
|
503
|
-
*
|
|
828
|
+
* The details of the signatures in a PSET, divided in available and missing signatures.
|
|
504
829
|
*/
|
|
505
830
|
export class PsetSignatures {
|
|
506
831
|
private constructor();
|
|
@@ -522,16 +847,53 @@ export class Recipient {
|
|
|
522
847
|
address(): Address | undefined;
|
|
523
848
|
vout(): number;
|
|
524
849
|
}
|
|
850
|
+
/**
|
|
851
|
+
* A Registry, a repository to store and retrieve asset metadata, like the name or the ticker of an asset.
|
|
852
|
+
*/
|
|
525
853
|
export class Registry {
|
|
526
854
|
private constructor();
|
|
527
855
|
free(): void;
|
|
856
|
+
/**
|
|
857
|
+
* Create a new registry cache specifying the URL of the registry,
|
|
858
|
+
* fetch the assets metadata identified by the given asset ids and cache them for later local retrieval.
|
|
859
|
+
* Use `default_for_network()` to get the default registry for the given network.
|
|
860
|
+
*/
|
|
528
861
|
static new(url: string, asset_ids: AssetIds): Promise<Registry>;
|
|
862
|
+
/**
|
|
863
|
+
* Return the default registry for the given network,
|
|
864
|
+
* fetch the assets metadata identified by the given asset ids and cache them for later local retrieval.
|
|
865
|
+
* Use `new()` to specify a custom URL
|
|
866
|
+
*/
|
|
529
867
|
static defaultForNetwork(network: Network, asset_ids: AssetIds): Promise<Registry>;
|
|
868
|
+
/**
|
|
869
|
+
* Create a new registry cache, using only the hardcoded assets.
|
|
870
|
+
*
|
|
871
|
+
* Hardcoded assets are the policy assets (LBTC, tLBTC, rLBTC) and the USDT asset on mainnet.
|
|
872
|
+
*/
|
|
530
873
|
static defaultHardcodedForNetwork(network: Network): Registry;
|
|
874
|
+
/**
|
|
875
|
+
* Fetch the contract and the issuance transaction of the given asset id from the registry
|
|
876
|
+
*/
|
|
531
877
|
fetchWithTx(asset_id: AssetId, client: EsploraClient): Promise<AssetMeta>;
|
|
878
|
+
/**
|
|
879
|
+
* Post a contract to the registry for registration.
|
|
880
|
+
*/
|
|
532
881
|
post(data: RegistryPost): Promise<void>;
|
|
882
|
+
/**
|
|
883
|
+
* Return the asset metadata related to the given asset id if it exists in this registry.
|
|
884
|
+
*/
|
|
533
885
|
get(asset_id: AssetId): RegistryData | undefined;
|
|
886
|
+
/**
|
|
887
|
+
* Return the asset metadata related to the given token id,
|
|
888
|
+
* in other words `token_id` is the reissuance token of the returned asset
|
|
889
|
+
*/
|
|
534
890
|
getAssetOfToken(token_id: AssetId): RegistryData | undefined;
|
|
891
|
+
/**
|
|
892
|
+
* Add the contracts information of the assets used in the Pset
|
|
893
|
+
* if available in this registry.
|
|
894
|
+
* Without the contract information, the partially signed transaction
|
|
895
|
+
* is valid but will not show asset information when signed with an hardware wallet.
|
|
896
|
+
*/
|
|
535
897
|
addContracts(pset: Pset): Pset;
|
|
536
898
|
}
|
|
537
899
|
export class RegistryData {
|
|
@@ -542,29 +904,62 @@ export class RegistryData {
|
|
|
542
904
|
name(): string;
|
|
543
905
|
domain(): string;
|
|
544
906
|
}
|
|
907
|
+
/**
|
|
908
|
+
* The data to post to the registry to publish a contract for an asset id
|
|
909
|
+
*/
|
|
545
910
|
export class RegistryPost {
|
|
546
911
|
free(): void;
|
|
912
|
+
/**
|
|
913
|
+
* Create a new registry post object to be used to publish a contract for an asset id in the registry.
|
|
914
|
+
*/
|
|
547
915
|
constructor(contract: Contract, asset_id: AssetId);
|
|
916
|
+
/**
|
|
917
|
+
* Return a string representation of the registry post (mostly for debugging).
|
|
918
|
+
*/
|
|
548
919
|
toString(): string;
|
|
549
920
|
}
|
|
550
921
|
/**
|
|
551
|
-
*
|
|
922
|
+
* An Elements (Liquid) script
|
|
552
923
|
*/
|
|
553
924
|
export class Script {
|
|
554
925
|
free(): void;
|
|
555
926
|
/**
|
|
556
|
-
* Creates a `Script`
|
|
927
|
+
* Creates a `Script` from its hex string representation.
|
|
557
928
|
*/
|
|
558
929
|
constructor(s: string);
|
|
930
|
+
/**
|
|
931
|
+
* Return the consensus encoded bytes of the script.
|
|
932
|
+
*/
|
|
559
933
|
bytes(): Uint8Array;
|
|
934
|
+
/**
|
|
935
|
+
* Return the string of the script showing op codes and their arguments.
|
|
936
|
+
*
|
|
937
|
+
* For example: "OP_DUP OP_HASH160 OP_PUSHBYTES_20 088ac47276d105b91cf9aa27a00112421dd5f23c OP_EQUALVERIFY OP_CHECKSIG"
|
|
938
|
+
*/
|
|
560
939
|
asm(): string;
|
|
940
|
+
/**
|
|
941
|
+
* Return the string representation of the script (hex encoding of its consensus encoded bytes).
|
|
942
|
+
* This representation can be used to recreate the script via `new()`
|
|
943
|
+
*/
|
|
561
944
|
toString(): string;
|
|
562
945
|
}
|
|
563
946
|
/**
|
|
564
|
-
* A Software signer
|
|
947
|
+
* A Software signer.
|
|
565
948
|
*/
|
|
566
949
|
export class Signer {
|
|
567
950
|
free(): void;
|
|
951
|
+
/**
|
|
952
|
+
* AMP0 signer data for login
|
|
953
|
+
*/
|
|
954
|
+
amp0SignerData(): Amp0SignerData;
|
|
955
|
+
/**
|
|
956
|
+
* AMP0 sign login challenge
|
|
957
|
+
*/
|
|
958
|
+
amp0SignChallenge(challenge: string): string;
|
|
959
|
+
/**
|
|
960
|
+
* AMP0 account xpub
|
|
961
|
+
*/
|
|
962
|
+
amp0AccountXpub(account: number): string;
|
|
568
963
|
/**
|
|
569
964
|
* Creates a `Signer`
|
|
570
965
|
*/
|
|
@@ -577,9 +972,21 @@ export class Signer {
|
|
|
577
972
|
* Sign a message with the master key, return the signature as a base64 string
|
|
578
973
|
*/
|
|
579
974
|
signMessage(message: string): string;
|
|
975
|
+
/**
|
|
976
|
+
* Return the witness public key hash, slip77 descriptor of this signer
|
|
977
|
+
*/
|
|
580
978
|
wpkhSlip77Descriptor(): WolletDescriptor;
|
|
979
|
+
/**
|
|
980
|
+
* Return the extended public key of the signer
|
|
981
|
+
*/
|
|
581
982
|
getMasterXpub(): Xpub;
|
|
983
|
+
/**
|
|
984
|
+
* Return keyorigin and xpub, like "[73c5da0a/84h/1h/0h]tpub..."
|
|
985
|
+
*/
|
|
582
986
|
keyoriginXpub(bip: Bip): string;
|
|
987
|
+
/**
|
|
988
|
+
* Return the mnemonic of the signer
|
|
989
|
+
*/
|
|
583
990
|
mnemonic(): Mnemonic;
|
|
584
991
|
}
|
|
585
992
|
export class Singlesig {
|
|
@@ -588,7 +995,7 @@ export class Singlesig {
|
|
|
588
995
|
static from(variant: string): Singlesig;
|
|
589
996
|
}
|
|
590
997
|
/**
|
|
591
|
-
*
|
|
998
|
+
* Blockchain tip, the highest valid block in the blockchain
|
|
592
999
|
*/
|
|
593
1000
|
export class Tip {
|
|
594
1001
|
private constructor();
|
|
@@ -598,9 +1005,9 @@ export class Tip {
|
|
|
598
1005
|
timestamp(): number | undefined;
|
|
599
1006
|
}
|
|
600
1007
|
/**
|
|
601
|
-
* A Liquid transaction
|
|
1008
|
+
* A Liquid transaction
|
|
602
1009
|
*
|
|
603
|
-
* See
|
|
1010
|
+
* See `WalletTx` for the transaction as seen from the perspective of the wallet
|
|
604
1011
|
* where you can actually see unblinded amounts and tx net-balance.
|
|
605
1012
|
*/
|
|
606
1013
|
export class Transaction {
|
|
@@ -609,13 +1016,26 @@ export class Transaction {
|
|
|
609
1016
|
* Creates a `Transaction`
|
|
610
1017
|
*/
|
|
611
1018
|
constructor(tx_hex: string);
|
|
1019
|
+
/**
|
|
1020
|
+
* Return the transaction identifier.
|
|
1021
|
+
*/
|
|
612
1022
|
txid(): Txid;
|
|
1023
|
+
/**
|
|
1024
|
+
* Return the consensus encoded bytes of the transaction.
|
|
1025
|
+
*/
|
|
613
1026
|
bytes(): Uint8Array;
|
|
1027
|
+
/**
|
|
1028
|
+
* Return the fee of the transaction in the given asset.
|
|
1029
|
+
* At the moment the only asset that can be used as fee is the policy asset (LBTC for mainnet).
|
|
1030
|
+
*/
|
|
614
1031
|
fee(policy_asset: AssetId): bigint;
|
|
1032
|
+
/**
|
|
1033
|
+
* Return the hex representation of the transaction. More precisely, they are the consensus encoded bytes of the transaction converted in hex.
|
|
1034
|
+
*/
|
|
615
1035
|
toString(): string;
|
|
616
1036
|
}
|
|
617
1037
|
/**
|
|
618
|
-
*
|
|
1038
|
+
* A transaction builder
|
|
619
1039
|
*/
|
|
620
1040
|
export class TxBuilder {
|
|
621
1041
|
free(): void;
|
|
@@ -664,31 +1084,87 @@ export class TxBuilder {
|
|
|
664
1084
|
*/
|
|
665
1085
|
addExplicitRecipient(address: Address, satoshi: bigint, asset: AssetId): TxBuilder;
|
|
666
1086
|
/**
|
|
667
|
-
* Issue an asset
|
|
1087
|
+
* Issue an asset
|
|
1088
|
+
*
|
|
1089
|
+
* There will be `asset_sats` units of this asset that will be received by
|
|
1090
|
+
* `asset_receiver` if it's set, otherwise to an address of the wallet generating the issuance.
|
|
1091
|
+
*
|
|
1092
|
+
* There will be `token_sats` reissuance tokens that allow token holder to reissue the created
|
|
1093
|
+
* asset. Reissuance token will be received by `token_receiver` if it's some, or to an
|
|
1094
|
+
* address of the wallet generating the issuance if none.
|
|
1095
|
+
*
|
|
1096
|
+
* If a `contract` is provided, it's metadata will be committed in the generated asset id.
|
|
1097
|
+
*
|
|
1098
|
+
* Can't be used if `reissue_asset` has been called
|
|
668
1099
|
*/
|
|
669
1100
|
issueAsset(asset_sats: bigint, asset_receiver: Address | null | undefined, token_sats: bigint, token_receiver?: Address | null, contract?: Contract | null): TxBuilder;
|
|
670
1101
|
/**
|
|
671
|
-
* Reissue an asset
|
|
1102
|
+
* Reissue an asset
|
|
1103
|
+
*
|
|
1104
|
+
* reissue the asset defined by `asset_to_reissue`, provided the reissuance token is owned
|
|
1105
|
+
* by the wallet generating te reissuance.
|
|
1106
|
+
*
|
|
1107
|
+
* Generated transaction will create `satoshi_to_reissue` new asset units, and they will be
|
|
1108
|
+
* sent to the provided `asset_receiver` address if some, or to an address from the wallet
|
|
1109
|
+
* generating the reissuance transaction if none.
|
|
1110
|
+
*
|
|
1111
|
+
* If the issuance transaction does not involve this wallet,
|
|
1112
|
+
* pass the issuance transaction in `issuance_tx`.
|
|
672
1113
|
*/
|
|
673
1114
|
reissueAsset(asset_to_reissue: AssetId, satoshi_to_reissue: bigint, asset_receiver?: Address | null, issuance_tx?: Transaction | null): TxBuilder;
|
|
674
1115
|
/**
|
|
675
|
-
*
|
|
1116
|
+
* Switch to manual coin selection by giving a list of internal UTXOs to use.
|
|
1117
|
+
*
|
|
1118
|
+
* All passed UTXOs are added to the transaction.
|
|
1119
|
+
* No other wallet UTXO is added to the transaction, caller is supposed to add enough UTXOs to
|
|
1120
|
+
* cover for all recipients and fees.
|
|
1121
|
+
*
|
|
1122
|
+
* This method never fails, any error will be raised in [`TxBuilder::finish`].
|
|
1123
|
+
*
|
|
1124
|
+
* Possible errors:
|
|
1125
|
+
* * OutPoint doesn't belong to the wallet
|
|
1126
|
+
* * Insufficient funds (remember to include L-BTC utxos for fees)
|
|
676
1127
|
*/
|
|
677
1128
|
setWalletUtxos(outpoints: OutPoint[]): TxBuilder;
|
|
1129
|
+
/**
|
|
1130
|
+
* Return a string representation of the transaction builder (mostly for debugging)
|
|
1131
|
+
*/
|
|
678
1132
|
toString(): string;
|
|
1133
|
+
/**
|
|
1134
|
+
* Set data to create a PSET from which you
|
|
1135
|
+
* can create a LiquiDEX proposal
|
|
1136
|
+
*/
|
|
679
1137
|
liquidexMake(utxo: OutPoint, address: Address, satoshi: bigint, asset_id: AssetId): TxBuilder;
|
|
1138
|
+
/**
|
|
1139
|
+
* Set data to take LiquiDEX proposals
|
|
1140
|
+
*/
|
|
680
1141
|
liquidexTake(proposals: ValidatedLiquidexProposal[]): TxBuilder;
|
|
681
1142
|
}
|
|
682
1143
|
/**
|
|
683
|
-
*
|
|
1144
|
+
* Contains unblinded information such as the asset and the value of a transaction output
|
|
684
1145
|
*/
|
|
685
1146
|
export class TxOutSecrets {
|
|
686
1147
|
private constructor();
|
|
687
1148
|
free(): void;
|
|
1149
|
+
/**
|
|
1150
|
+
* Return the asset of the output.
|
|
1151
|
+
*/
|
|
688
1152
|
asset(): AssetId;
|
|
1153
|
+
/**
|
|
1154
|
+
* Return the asset blinding factor as a hex string.
|
|
1155
|
+
*/
|
|
689
1156
|
assetBlindingFactor(): string;
|
|
1157
|
+
/**
|
|
1158
|
+
* Return the value of the output.
|
|
1159
|
+
*/
|
|
690
1160
|
value(): bigint;
|
|
1161
|
+
/**
|
|
1162
|
+
* Return the value blinding factor as a hex string.
|
|
1163
|
+
*/
|
|
691
1164
|
valueBlindingFactor(): string;
|
|
1165
|
+
/**
|
|
1166
|
+
* Return true if the output is explicit (no blinding factors).
|
|
1167
|
+
*/
|
|
692
1168
|
isExplicit(): boolean;
|
|
693
1169
|
/**
|
|
694
1170
|
* Get the asset commitment
|
|
@@ -711,25 +1187,39 @@ export class TxOutSecrets {
|
|
|
711
1187
|
export class Txid {
|
|
712
1188
|
free(): void;
|
|
713
1189
|
/**
|
|
714
|
-
* Creates a `Txid`
|
|
1190
|
+
* Creates a `Txid` from its hex string representation (64 characters).
|
|
715
1191
|
*/
|
|
716
1192
|
constructor(tx_id: string);
|
|
1193
|
+
/**
|
|
1194
|
+
* Return the string representation of the transaction identifier as shown in the explorer.
|
|
1195
|
+
* This representation can be used to recreate the transaction identifier via `new()`
|
|
1196
|
+
*/
|
|
717
1197
|
toString(): string;
|
|
718
1198
|
}
|
|
719
1199
|
/**
|
|
720
|
-
*
|
|
1200
|
+
* LiquiDEX swap proposal
|
|
1201
|
+
*
|
|
1202
|
+
* A LiquiDEX swap proposal is a transaction with one input and one output created by the "maker".
|
|
1203
|
+
* The transaction "swaps" the input for the output, meaning that the "maker" sends the input and
|
|
1204
|
+
* receives the output.
|
|
1205
|
+
* However the transaction is incomplete (unbalanced and without a fee output), thus it cannot be
|
|
1206
|
+
* broadcast.
|
|
1207
|
+
* The "taker" can "complete" the transaction (using [`crate::TxBuilder::liquidex_take()`]) by
|
|
1208
|
+
* adding more inputs and more outputs to balance the amounts, meaning that the "taker" sends the
|
|
1209
|
+
* output and receives the input.
|
|
721
1210
|
*/
|
|
722
1211
|
export class UnvalidatedLiquidexProposal {
|
|
723
1212
|
private constructor();
|
|
724
1213
|
free(): void;
|
|
725
1214
|
static new(s: string): UnvalidatedLiquidexProposal;
|
|
726
|
-
static
|
|
727
|
-
|
|
1215
|
+
static fromPset(pset: Pset): UnvalidatedLiquidexProposal;
|
|
1216
|
+
insecureValidate(): ValidatedLiquidexProposal;
|
|
728
1217
|
validate(tx: Transaction): ValidatedLiquidexProposal;
|
|
729
1218
|
toString(): string;
|
|
730
1219
|
}
|
|
731
1220
|
/**
|
|
732
|
-
*
|
|
1221
|
+
* An Update contains the delta of information to be applied to the wallet to reach the latest status.
|
|
1222
|
+
* It's created passing a reference to the wallet to the blockchain client
|
|
733
1223
|
*/
|
|
734
1224
|
export class Update {
|
|
735
1225
|
free(): void;
|
|
@@ -737,14 +1227,33 @@ export class Update {
|
|
|
737
1227
|
* Creates an `Update`
|
|
738
1228
|
*/
|
|
739
1229
|
constructor(bytes: Uint8Array);
|
|
1230
|
+
/**
|
|
1231
|
+
* Serialize an update to a byte array
|
|
1232
|
+
*/
|
|
740
1233
|
serialize(): Uint8Array;
|
|
1234
|
+
/**
|
|
1235
|
+
* Serialize an update to a base64 encoded string,
|
|
1236
|
+
* encrypted with a key derived from the descriptor.
|
|
1237
|
+
* Decrypt using `deserialize_decrypted_base64()`
|
|
1238
|
+
*/
|
|
741
1239
|
serializeEncryptedBase64(desc: WolletDescriptor): string;
|
|
1240
|
+
/**
|
|
1241
|
+
* Deserialize an update from a base64 encoded string,
|
|
1242
|
+
* decrypted with a key derived from the descriptor.
|
|
1243
|
+
* Create the base64 using `serialize_encrypted_base64()`
|
|
1244
|
+
*/
|
|
742
1245
|
static deserializeDecryptedBase64(base64: string, desc: WolletDescriptor): Update;
|
|
1246
|
+
/**
|
|
1247
|
+
* Whether this update only changes the tip
|
|
1248
|
+
*/
|
|
743
1249
|
onlyTip(): boolean;
|
|
1250
|
+
/**
|
|
1251
|
+
* Prune the update, removing unneeded data from transactions.
|
|
1252
|
+
*/
|
|
744
1253
|
prune(wollet: Wollet): void;
|
|
745
1254
|
}
|
|
746
1255
|
/**
|
|
747
|
-
*
|
|
1256
|
+
* Created by validating `UnvalidatedLiquidexProposal` via `validate()` or `insecure_validate()`
|
|
748
1257
|
*/
|
|
749
1258
|
export class ValidatedLiquidexProposal {
|
|
750
1259
|
private constructor();
|
|
@@ -754,38 +1263,96 @@ export class ValidatedLiquidexProposal {
|
|
|
754
1263
|
toString(): string;
|
|
755
1264
|
}
|
|
756
1265
|
/**
|
|
757
|
-
*
|
|
1266
|
+
* Value returned by asking transactions to the wallet. Contains details about a transaction
|
|
1267
|
+
* from the perspective of the wallet, for example the net-balance of the transaction for the
|
|
1268
|
+
* wallet.
|
|
758
1269
|
*/
|
|
759
1270
|
export class WalletTx {
|
|
760
1271
|
private constructor();
|
|
761
1272
|
free(): void;
|
|
1273
|
+
/**
|
|
1274
|
+
* Return a copy of the transaction.
|
|
1275
|
+
*/
|
|
762
1276
|
tx(): Transaction;
|
|
1277
|
+
/**
|
|
1278
|
+
* Return the height of the block containing the transaction if it's confirmed.
|
|
1279
|
+
*/
|
|
763
1280
|
height(): number | undefined;
|
|
764
|
-
|
|
1281
|
+
/**
|
|
1282
|
+
* Return the net balance of the transaction for the wallet.
|
|
1283
|
+
*/
|
|
1284
|
+
balance(): Balance;
|
|
1285
|
+
/**
|
|
1286
|
+
* Return the transaction identifier.
|
|
1287
|
+
*/
|
|
765
1288
|
txid(): Txid;
|
|
1289
|
+
/**
|
|
1290
|
+
* Return the fee of the transaction.
|
|
1291
|
+
*/
|
|
766
1292
|
fee(): bigint;
|
|
1293
|
+
/**
|
|
1294
|
+
* Return the type of the transaction. Can be "issuance", "reissuance", "burn", "redeposit", "incoming", "outgoing" or "unknown".
|
|
1295
|
+
*/
|
|
767
1296
|
txType(): string;
|
|
1297
|
+
/**
|
|
1298
|
+
* Return the timestamp of the block containing the transaction if it's confirmed.
|
|
1299
|
+
*/
|
|
768
1300
|
timestamp(): number | undefined;
|
|
1301
|
+
/**
|
|
1302
|
+
* Return a list with the same number of elements as the inputs of the transaction.
|
|
1303
|
+
* The element in the list is a `WalletTxOut` (the output spent to create the input)
|
|
1304
|
+
* if it belongs to the wallet, while it is None for inputs owned by others
|
|
1305
|
+
*/
|
|
769
1306
|
inputs(): OptionWalletTxOut[];
|
|
1307
|
+
/**
|
|
1308
|
+
* Return a list with the same number of elements as the outputs of the transaction.
|
|
1309
|
+
* The element in the list is a `WalletTxOut` if it belongs to the wallet,
|
|
1310
|
+
* while it is None for inputs owned by others
|
|
1311
|
+
*/
|
|
770
1312
|
outputs(): OptionWalletTxOut[];
|
|
1313
|
+
/**
|
|
1314
|
+
* Return the URL to the transaction on the given explorer including the information
|
|
1315
|
+
* needed to unblind the transaction in the explorer UI.
|
|
1316
|
+
*/
|
|
771
1317
|
unblindedUrl(explorer_url: string): string;
|
|
772
1318
|
}
|
|
773
1319
|
/**
|
|
774
|
-
*
|
|
1320
|
+
* Details of a wallet transaction output used in `WalletTx`
|
|
775
1321
|
*/
|
|
776
1322
|
export class WalletTxOut {
|
|
777
1323
|
private constructor();
|
|
778
1324
|
free(): void;
|
|
1325
|
+
/**
|
|
1326
|
+
* Return the outpoint (txid and vout) of this `WalletTxOut`.
|
|
1327
|
+
*/
|
|
779
1328
|
outpoint(): OutPoint;
|
|
1329
|
+
/**
|
|
1330
|
+
* Return the script pubkey of the address of this `WalletTxOut`.
|
|
1331
|
+
*/
|
|
780
1332
|
scriptPubkey(): Script;
|
|
1333
|
+
/**
|
|
1334
|
+
* Return the height of the block containing this output if it's confirmed.
|
|
1335
|
+
*/
|
|
781
1336
|
height(): number | undefined;
|
|
1337
|
+
/**
|
|
1338
|
+
* Return the unblinded values of this `WalletTxOut`.
|
|
1339
|
+
*/
|
|
782
1340
|
unblinded(): TxOutSecrets;
|
|
1341
|
+
/**
|
|
1342
|
+
* Return the wildcard index used to derive the address of this `WalletTxOut`.
|
|
1343
|
+
*/
|
|
783
1344
|
wildcardIndex(): number;
|
|
1345
|
+
/**
|
|
1346
|
+
* Return the chain of this `WalletTxOut`. Can be "Chain::External" or "Chain::Internal" (change).
|
|
1347
|
+
*/
|
|
784
1348
|
extInt(): Chain;
|
|
1349
|
+
/**
|
|
1350
|
+
* Return the address of this `WalletTxOut`.
|
|
1351
|
+
*/
|
|
785
1352
|
address(): Address;
|
|
786
1353
|
}
|
|
787
1354
|
/**
|
|
788
|
-
*
|
|
1355
|
+
* A watch-only wallet defined by a CT descriptor.
|
|
789
1356
|
*/
|
|
790
1357
|
export class Wollet {
|
|
791
1358
|
free(): void;
|
|
@@ -800,11 +1367,59 @@ export class Wollet {
|
|
|
800
1367
|
* otherwise the last unused address.
|
|
801
1368
|
*/
|
|
802
1369
|
address(index?: number | null): AddressResult;
|
|
1370
|
+
/**
|
|
1371
|
+
* Get the full derivation path for an address
|
|
1372
|
+
*
|
|
1373
|
+
* Note: will be removed once we add the full path to lwk_wollet::AddressResult
|
|
1374
|
+
*/
|
|
803
1375
|
addressFullPath(index: number): Uint32Array;
|
|
1376
|
+
/**
|
|
1377
|
+
* Apply an update containing blockchain data
|
|
1378
|
+
*
|
|
1379
|
+
* To update the wallet you need to first obtain the blockchain data relevant for the wallet.
|
|
1380
|
+
* This can be done using a `full_scan()`, which
|
|
1381
|
+
* returns an `Update` that contains new transaction and other data relevant for the
|
|
1382
|
+
* wallet.
|
|
1383
|
+
* The update must then be applied to the `Wollet` so that wollet methods such as
|
|
1384
|
+
* `balance()` or `transactions()` include the new data.
|
|
1385
|
+
*
|
|
1386
|
+
* However getting blockchain data involves network calls, so between the full scan start and
|
|
1387
|
+
* when the update is applied it might elapse a significant amount of time.
|
|
1388
|
+
* In that interval, applying any update, or any transaction using `apply_transaction()`,
|
|
1389
|
+
* will cause this function to return a `Error::UpdateOnDifferentStatus`.
|
|
1390
|
+
* Callers should either avoid applying updates and transactions, or they can catch the error
|
|
1391
|
+
* and wait for a new full scan to be completed and applied.
|
|
1392
|
+
*/
|
|
804
1393
|
applyUpdate(update: Update): void;
|
|
805
|
-
|
|
806
|
-
|
|
1394
|
+
/**
|
|
1395
|
+
* Apply a transaction to the wallet state
|
|
1396
|
+
*
|
|
1397
|
+
* Wallet transactions are normally obtained using a `full_scan()`
|
|
1398
|
+
* and applying the result with `apply_update()`. However a
|
|
1399
|
+
* full scan involves network calls and it can take a significant amount of time.
|
|
1400
|
+
*
|
|
1401
|
+
* If the caller does not want to wait for a full scan containing the transaction, it can
|
|
1402
|
+
* apply the transaction to the wallet state using this function.
|
|
1403
|
+
*
|
|
1404
|
+
* Note: if this transaction is *not* returned by a next full scan, after `apply_update()` it will disappear from the
|
|
1405
|
+
* transactions list, will not be included in balance computations, and by the remaining
|
|
1406
|
+
* wollet methods.
|
|
1407
|
+
*
|
|
1408
|
+
* Calling this method, might cause `apply_update()` to fail with a
|
|
1409
|
+
* `Error::UpdateOnDifferentStatus`, make sure to either avoid it or handle the error properly.
|
|
1410
|
+
*/
|
|
1411
|
+
applyTransaction(tx: Transaction): Balance;
|
|
1412
|
+
/**
|
|
1413
|
+
* Get the wallet balance for each assets
|
|
1414
|
+
*/
|
|
1415
|
+
balance(): Balance;
|
|
1416
|
+
/**
|
|
1417
|
+
* Get the asset identifiers owned by the wallet
|
|
1418
|
+
*/
|
|
807
1419
|
assetsOwned(): AssetIds;
|
|
1420
|
+
/**
|
|
1421
|
+
* Get the wallet transactions
|
|
1422
|
+
*/
|
|
808
1423
|
transactions(): WalletTx[];
|
|
809
1424
|
/**
|
|
810
1425
|
* Get the unspent transaction outputs of the wallet
|
|
@@ -818,12 +1433,29 @@ export class Wollet {
|
|
|
818
1433
|
* Finalize and consume the given PSET, returning the finalized one
|
|
819
1434
|
*/
|
|
820
1435
|
finalize(pset: Pset): Pset;
|
|
1436
|
+
/**
|
|
1437
|
+
* Get the PSET details with respect to the wallet
|
|
1438
|
+
*/
|
|
821
1439
|
psetDetails(pset: Pset): PsetDetails;
|
|
1440
|
+
/**
|
|
1441
|
+
* Get a copy of the wallet descriptor of this wallet.
|
|
1442
|
+
*/
|
|
822
1443
|
descriptor(): WolletDescriptor;
|
|
1444
|
+
/**
|
|
1445
|
+
* A deterministic value derived from the descriptor, the config and the content of this wollet,
|
|
1446
|
+
* including what's in the wallet store (transactions etc)
|
|
1447
|
+
*
|
|
1448
|
+
* In this case, we don't need cryptographic assurance guaranteed by the std default hasher (siphash)
|
|
1449
|
+
* And we can use a much faster hasher, which is used also in the rust compiler.
|
|
1450
|
+
* ([source](https://nnethercote.github.io/2021/12/08/a-brutally-effective-hash-function-in-rust.html))
|
|
1451
|
+
*/
|
|
823
1452
|
status(): bigint;
|
|
1453
|
+
/**
|
|
1454
|
+
* Get the blockchain tip at the time of the last update of this wollet.
|
|
1455
|
+
*/
|
|
824
1456
|
tip(): Tip;
|
|
825
1457
|
/**
|
|
826
|
-
*
|
|
1458
|
+
* Returns true if this wollet has never received an updated applyed to it
|
|
827
1459
|
*/
|
|
828
1460
|
neverScanned(): boolean;
|
|
829
1461
|
/**
|
|
@@ -832,7 +1464,7 @@ export class Wollet {
|
|
|
832
1464
|
isAmp0(): boolean;
|
|
833
1465
|
}
|
|
834
1466
|
/**
|
|
835
|
-
*
|
|
1467
|
+
* A wrapper that contains only the subset of CT descriptors handled by wollet
|
|
836
1468
|
*/
|
|
837
1469
|
export class WolletDescriptor {
|
|
838
1470
|
free(): void;
|
|
@@ -840,8 +1472,20 @@ export class WolletDescriptor {
|
|
|
840
1472
|
* Creates a `WolletDescriptor`
|
|
841
1473
|
*/
|
|
842
1474
|
constructor(descriptor: string);
|
|
1475
|
+
/**
|
|
1476
|
+
* Return the string representation of the descriptor, including the checksum.
|
|
1477
|
+
* This representation can be used to recreate the descriptor via `new()`
|
|
1478
|
+
*/
|
|
843
1479
|
toString(): string;
|
|
1480
|
+
/**
|
|
1481
|
+
* Create a new multisig descriptor, where each participant is a keyorigin_xpub and it requires at least threshold signatures to spend.
|
|
1482
|
+
* Errors if the threshold is 0 or greater than the number of participants.
|
|
1483
|
+
* Uses slip77 for the blinding key.
|
|
1484
|
+
*/
|
|
844
1485
|
static newMultiWshSlip77(threshold: number, participants: string[]): WolletDescriptor;
|
|
1486
|
+
/**
|
|
1487
|
+
* Whether the descriptor is for mainnet
|
|
1488
|
+
*/
|
|
845
1489
|
isMainnet(): boolean;
|
|
846
1490
|
/**
|
|
847
1491
|
* Whether the descriptor is AMP0
|
|
@@ -849,19 +1493,32 @@ export class WolletDescriptor {
|
|
|
849
1493
|
isAmp0(): boolean;
|
|
850
1494
|
}
|
|
851
1495
|
/**
|
|
852
|
-
*
|
|
1496
|
+
* An extended public key
|
|
853
1497
|
*/
|
|
854
1498
|
export class Xpub {
|
|
855
1499
|
free(): void;
|
|
856
1500
|
/**
|
|
857
|
-
* Creates a
|
|
1501
|
+
* Creates a Xpub
|
|
858
1502
|
*/
|
|
859
1503
|
constructor(s: string);
|
|
1504
|
+
/**
|
|
1505
|
+
* Return the string representation of the Xpub.
|
|
1506
|
+
* This representation can be used to recreate the Xpub via `new()`
|
|
1507
|
+
*/
|
|
860
1508
|
toString(): string;
|
|
1509
|
+
/**
|
|
1510
|
+
* Return the identifier of the Xpub.
|
|
1511
|
+
* This is a 40 hex characters string (20 bytes).
|
|
1512
|
+
*/
|
|
861
1513
|
identifier(): string;
|
|
1514
|
+
/**
|
|
1515
|
+
* Return the first four bytes of the identifier as hex string
|
|
1516
|
+
* This is a 8 hex characters string (4 bytes).
|
|
1517
|
+
*/
|
|
862
1518
|
fingerprint(): string;
|
|
863
1519
|
/**
|
|
864
|
-
* Returns true if the passed string is a valid xpub with a valid keyorigin if present
|
|
1520
|
+
* Returns true if the passed string is a valid xpub with a valid keyorigin if present.
|
|
1521
|
+
* For example: "[73c5da0a/84h/1h/0h]tpub..."
|
|
865
1522
|
*/
|
|
866
1523
|
static isValidWithKeyOrigin(s: string): boolean;
|
|
867
1524
|
}
|