@lendasat/lendaswap-sdk 0.1.7 → 0.1.65
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/dist/api.d.ts +138 -160
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +174 -113
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/price-calculations.d.ts +135 -0
- package/dist/price-calculations.d.ts.map +1 -0
- package/dist/price-calculations.js +171 -0
- package/dist/price-calculations.js.map +1 -0
- package/dist/price-calculations.test.d.ts +2 -0
- package/dist/price-calculations.test.d.ts.map +1 -0
- package/dist/price-calculations.test.js +173 -0
- package/dist/price-calculations.test.js.map +1 -0
- package/dist/price-feed.d.ts +3 -0
- package/dist/price-feed.d.ts.map +1 -1
- package/dist/price-feed.js.map +1 -1
- package/dist/storage/dexieSwapStorage.d.ts +12 -10
- package/dist/storage/dexieSwapStorage.d.ts.map +1 -1
- package/dist/storage/dexieSwapStorage.js +63 -2
- package/dist/storage/dexieSwapStorage.js.map +1 -1
- package/dist/storage/dexieVtxoSwapStorage.d.ts +105 -0
- package/dist/storage/dexieVtxoSwapStorage.d.ts.map +1 -0
- package/dist/storage/dexieVtxoSwapStorage.js +149 -0
- package/dist/storage/dexieVtxoSwapStorage.js.map +1 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -1
- package/dist/usd-price.d.ts.map +1 -1
- package/dist/usd-price.js +1 -0
- package/dist/usd-price.js.map +1 -1
- package/package.json +1 -1
- package/wasm/lendaswap_wasm_sdk.d.ts +361 -43
- package/wasm/lendaswap_wasm_sdk_bg.js +2499 -483
- package/wasm/lendaswap_wasm_sdk_bg.wasm +0 -0
- package/wasm/lendaswap_wasm_sdk_bg.wasm.d.ts +259 -65
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Returns a human-readable string representation of the swap status.
|
|
5
|
+
*/
|
|
6
|
+
export function swapStatusToString(status: SwapStatus): string;
|
|
3
7
|
/**
|
|
4
8
|
* Initialize the WASM module.
|
|
5
9
|
*
|
|
@@ -26,8 +30,46 @@ export function getLogLevel(): string;
|
|
|
26
30
|
export enum Chain {
|
|
27
31
|
Arkade = 0,
|
|
28
32
|
Lightning = 1,
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
Bitcoin = 2,
|
|
34
|
+
Polygon = 3,
|
|
35
|
+
Ethereum = 4,
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Bitcoin network type.
|
|
39
|
+
*/
|
|
40
|
+
export enum Network {
|
|
41
|
+
Bitcoin = 0,
|
|
42
|
+
Testnet = 1,
|
|
43
|
+
Regtest = 2,
|
|
44
|
+
Mutinynet = 3,
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Swap status for BTC/EVM swaps.
|
|
48
|
+
*/
|
|
49
|
+
export enum SwapStatus {
|
|
50
|
+
Pending = 0,
|
|
51
|
+
ClientFundingSeen = 1,
|
|
52
|
+
ClientFunded = 2,
|
|
53
|
+
ClientRefunded = 3,
|
|
54
|
+
ServerFunded = 4,
|
|
55
|
+
ClientRedeeming = 5,
|
|
56
|
+
ClientRedeemed = 6,
|
|
57
|
+
ServerRedeemed = 7,
|
|
58
|
+
ClientFundedServerRefunded = 8,
|
|
59
|
+
ClientRefundedServerFunded = 9,
|
|
60
|
+
ClientRefundedServerRefunded = 10,
|
|
61
|
+
Expired = 11,
|
|
62
|
+
ClientInvalidFunded = 12,
|
|
63
|
+
ClientFundedTooLate = 13,
|
|
64
|
+
ClientRedeemedAndClientRefunded = 14,
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Swap type discriminator.
|
|
68
|
+
*/
|
|
69
|
+
export enum SwapType {
|
|
70
|
+
BtcToEvm = 0,
|
|
71
|
+
EvmToBtc = 1,
|
|
72
|
+
BtcToArkade = 2,
|
|
31
73
|
}
|
|
32
74
|
/**
|
|
33
75
|
* The `ReadableStreamType` enum.
|
|
@@ -45,6 +87,80 @@ export class AssetPair {
|
|
|
45
87
|
source: TokenInfo;
|
|
46
88
|
target: TokenInfo;
|
|
47
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Fields from SwapCommonFields are flattened.
|
|
92
|
+
*/
|
|
93
|
+
export class BtcToArkadeSwapResponse {
|
|
94
|
+
private constructor();
|
|
95
|
+
free(): void;
|
|
96
|
+
[Symbol.dispose](): void;
|
|
97
|
+
id: string;
|
|
98
|
+
status: SwapStatus;
|
|
99
|
+
btc_htlc_address: string;
|
|
100
|
+
asset_amount: bigint;
|
|
101
|
+
sats_receive: bigint;
|
|
102
|
+
fee_sats: bigint;
|
|
103
|
+
hash_lock: string;
|
|
104
|
+
btc_refund_locktime: bigint;
|
|
105
|
+
arkade_vhtlc_address: string;
|
|
106
|
+
target_arkade_address: string;
|
|
107
|
+
get btc_fund_txid(): string | undefined;
|
|
108
|
+
set btc_fund_txid(value: string | null | undefined);
|
|
109
|
+
get btc_claim_txid(): string | undefined;
|
|
110
|
+
set btc_claim_txid(value: string | null | undefined);
|
|
111
|
+
get arkade_fund_txid(): string | undefined;
|
|
112
|
+
set arkade_fund_txid(value: string | null | undefined);
|
|
113
|
+
get arkade_claim_txid(): string | undefined;
|
|
114
|
+
set arkade_claim_txid(value: string | null | undefined);
|
|
115
|
+
network: string;
|
|
116
|
+
created_at: string;
|
|
117
|
+
server_vhtlc_pk: string;
|
|
118
|
+
arkade_server_pk: string;
|
|
119
|
+
vhtlc_refund_locktime: bigint;
|
|
120
|
+
unilateral_claim_delay: bigint;
|
|
121
|
+
unilateral_refund_delay: bigint;
|
|
122
|
+
unilateral_refund_without_receiver_delay: bigint;
|
|
123
|
+
source_token: TokenId;
|
|
124
|
+
target_token: TokenId;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* BTC to EVM swap response.
|
|
128
|
+
* Fields from SwapCommonFields are flattened.
|
|
129
|
+
*/
|
|
130
|
+
export class BtcToEvmSwapResponse {
|
|
131
|
+
private constructor();
|
|
132
|
+
free(): void;
|
|
133
|
+
[Symbol.dispose](): void;
|
|
134
|
+
id: string;
|
|
135
|
+
status: SwapStatus;
|
|
136
|
+
hash_lock: string;
|
|
137
|
+
fee_sats: bigint;
|
|
138
|
+
asset_amount: number;
|
|
139
|
+
sender_pk: string;
|
|
140
|
+
receiver_pk: string;
|
|
141
|
+
server_pk: string;
|
|
142
|
+
refund_locktime: number;
|
|
143
|
+
unilateral_claim_delay: bigint;
|
|
144
|
+
unilateral_refund_delay: bigint;
|
|
145
|
+
unilateral_refund_without_receiver_delay: bigint;
|
|
146
|
+
network: Network;
|
|
147
|
+
created_at: string;
|
|
148
|
+
htlc_address_evm: string;
|
|
149
|
+
htlc_address_arkade: string;
|
|
150
|
+
user_address_evm: string;
|
|
151
|
+
ln_invoice: string;
|
|
152
|
+
sats_receive: bigint;
|
|
153
|
+
source_token: TokenId;
|
|
154
|
+
target_token: TokenId;
|
|
155
|
+
get bitcoin_htlc_claim_txid(): string | undefined;
|
|
156
|
+
set bitcoin_htlc_claim_txid(value: string | null | undefined);
|
|
157
|
+
get bitcoin_htlc_fund_txid(): string | undefined;
|
|
158
|
+
set bitcoin_htlc_fund_txid(value: string | null | undefined);
|
|
159
|
+
get evm_htlc_claim_txid(): string | undefined;
|
|
160
|
+
set evm_htlc_claim_txid(value: string | null | undefined);
|
|
161
|
+
get evm_htlc_fund_txid(): string | undefined;
|
|
162
|
+
set evm_htlc_fund_txid(value: string | null | undefined);
|
|
163
|
+
}
|
|
48
164
|
/**
|
|
49
165
|
* Lendaswap client.
|
|
50
166
|
*/
|
|
@@ -52,29 +168,31 @@ export class Client {
|
|
|
52
168
|
free(): void;
|
|
53
169
|
[Symbol.dispose](): void;
|
|
54
170
|
/**
|
|
55
|
-
* Create a new client with separate wallet and swap storage.
|
|
171
|
+
* Create a new client with separate wallet, swap, and VTXO swap storage.
|
|
56
172
|
*
|
|
57
173
|
* # Arguments
|
|
58
174
|
* * `base_url` - The Lendaswap API URL
|
|
59
175
|
* * `wallet_storage` - Storage provider for wallet data (mnemonic, key index)
|
|
60
176
|
* * `swap_storage` - Storage provider for swap data
|
|
177
|
+
* * `vtxo_swap_storage` - Storage provider for VTXO swap data
|
|
61
178
|
* * `network` - The Bitcoin network ("bitcoin" or "testnet")
|
|
62
179
|
* * `arkade_url` - The Arkade server URL
|
|
180
|
+
* * `esplora_url` - The Esplora API URL for on-chain Bitcoin operations
|
|
63
181
|
*/
|
|
64
|
-
constructor(base_url: string, wallet_storage: JsWalletStorageProvider, swap_storage: JsSwapStorageProvider, network: string, arkade_url: string);
|
|
182
|
+
constructor(base_url: string, wallet_storage: JsWalletStorageProvider, swap_storage: JsSwapStorageProvider, vtxo_swap_storage: JsVtxoSwapStorageProvider, network: string, arkade_url: string, esplora_url: string);
|
|
65
183
|
init(mnemonic?: string | null): Promise<void>;
|
|
66
184
|
/**
|
|
67
185
|
* Create an Arkade to EVM swap.
|
|
68
186
|
*/
|
|
69
|
-
createArkadeToEvmSwap(target_address: string, target_amount: number, target_token: string, target_chain: string, referral_code?: string | null): Promise<
|
|
187
|
+
createArkadeToEvmSwap(target_address: string, target_amount: number, target_token: string, target_chain: string, referral_code?: string | null): Promise<BtcToEvmSwapResponse>;
|
|
70
188
|
/**
|
|
71
189
|
* Create an EVM to Arkade swap.
|
|
72
190
|
*/
|
|
73
|
-
createEvmToArkadeSwap(target_address: string, user_address: string, source_amount: number, source_token: string, source_chain: string, referral_code?: string | null): Promise<
|
|
191
|
+
createEvmToArkadeSwap(target_address: string, user_address: string, source_amount: number, source_token: string, source_chain: string, referral_code?: string | null): Promise<EvmToBtcSwapResponse>;
|
|
74
192
|
/**
|
|
75
193
|
* Create an EVM to Lightning swap.
|
|
76
194
|
*/
|
|
77
|
-
createEvmToLightningSwap(bolt11_invoice: string, user_address: string, source_token: string, source_chain: string, referral_code?: string | null): Promise<
|
|
195
|
+
createEvmToLightningSwap(bolt11_invoice: string, user_address: string, source_token: string, source_chain: string, referral_code?: string | null): Promise<EvmToBtcSwapResponse>;
|
|
78
196
|
getAssetPairs(): Promise<AssetPair[]>;
|
|
79
197
|
getTokens(): Promise<TokenInfo[]>;
|
|
80
198
|
/**
|
|
@@ -83,20 +201,28 @@ export class Client {
|
|
|
83
201
|
getQuote(from: string, to: string, base_amount: bigint): Promise<QuoteResponse>;
|
|
84
202
|
/**
|
|
85
203
|
* Get swap by ID.
|
|
86
|
-
*
|
|
87
|
-
* This function returns `[ExtendedSwapResponse]`. It's too complex for Wasm to handle.
|
|
88
204
|
*/
|
|
89
|
-
getSwap(id: string): Promise<
|
|
205
|
+
getSwap(id: string): Promise<ExtendedSwapStorageData>;
|
|
90
206
|
/**
|
|
91
207
|
* Get all swaps.
|
|
92
|
-
*
|
|
93
|
-
* This function returns `[ExtendedSwapResponse[]]`. It's too complex for Wasm to handle.
|
|
94
208
|
*/
|
|
95
|
-
listAll(): Promise<
|
|
209
|
+
listAll(): Promise<ExtendedSwapStorageData[]>;
|
|
96
210
|
claimGelato(swap_id: string, secret?: string | null): Promise<void>;
|
|
97
211
|
amountsForSwap(swap_id: string): Promise<any>;
|
|
98
212
|
claimVhtlc(swap_id: string): Promise<void>;
|
|
99
213
|
refundVhtlc(swap_id: string, refund_address: string): Promise<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Create an on-chain Bitcoin to Arkade swap.
|
|
216
|
+
*/
|
|
217
|
+
createBitcoinToArkadeSwap(target_arkade_address: string, sats_receive: bigint, referral_code?: string | null): Promise<BtcToArkadeSwapResponse>;
|
|
218
|
+
/**
|
|
219
|
+
* Claim the Arkade VHTLC for a BTC-to-Arkade swap.
|
|
220
|
+
*/
|
|
221
|
+
claimBtcToArkadeVhtlc(swap_id: string): Promise<string>;
|
|
222
|
+
/**
|
|
223
|
+
* Refund from the on-chain Bitcoin HTLC after timeout.
|
|
224
|
+
*/
|
|
225
|
+
refundOnchainHtlc(swap_id: string, refund_address: string): Promise<string>;
|
|
100
226
|
/**
|
|
101
227
|
* Get API version.
|
|
102
228
|
*/
|
|
@@ -104,7 +230,7 @@ export class Client {
|
|
|
104
230
|
/**
|
|
105
231
|
* Recover swaps using xpub.
|
|
106
232
|
*/
|
|
107
|
-
recoverSwaps(): Promise<
|
|
233
|
+
recoverSwaps(): Promise<ExtendedSwapStorageData[]>;
|
|
108
234
|
/**
|
|
109
235
|
* Get mnemonic
|
|
110
236
|
*/
|
|
@@ -121,6 +247,16 @@ export class Client {
|
|
|
121
247
|
* Delete specific swap
|
|
122
248
|
*/
|
|
123
249
|
deleteSwap(id: string): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Get the list of swap IDs that failed to deserialize during the last listAll() call.
|
|
252
|
+
* These are "corrupted" entries that couldn't be loaded.
|
|
253
|
+
*/
|
|
254
|
+
getCorruptedSwapIds(): string[];
|
|
255
|
+
/**
|
|
256
|
+
* Delete all corrupted swap entries from storage.
|
|
257
|
+
* Returns the number of entries deleted.
|
|
258
|
+
*/
|
|
259
|
+
deleteCorruptedSwaps(): Promise<number>;
|
|
124
260
|
/**
|
|
125
261
|
* Estimate the fee for a VTXO swap.
|
|
126
262
|
*
|
|
@@ -140,7 +276,7 @@ export class Client {
|
|
|
140
276
|
/**
|
|
141
277
|
* Get VTXO swap details by ID.
|
|
142
278
|
*/
|
|
143
|
-
getVtxoSwap(id: string): Promise<
|
|
279
|
+
getVtxoSwap(id: string): Promise<ExtendedVtxoSwapStorageData>;
|
|
144
280
|
/**
|
|
145
281
|
* Claim the server's VHTLC in a VTXO swap.
|
|
146
282
|
*
|
|
@@ -154,11 +290,16 @@ export class Client {
|
|
|
154
290
|
* Refund the client's VHTLC in a VTXO swap.
|
|
155
291
|
*
|
|
156
292
|
* # Arguments
|
|
157
|
-
* * `
|
|
158
|
-
* * `swap_params` - The client's swap parameters
|
|
293
|
+
* * `swap_id` - The swap ID
|
|
159
294
|
* * `refund_address` - The Arkade address to receive the refunded funds
|
|
160
295
|
*/
|
|
161
|
-
refundVtxoSwap(
|
|
296
|
+
refundVtxoSwap(swap_id: string, refund_address: string): Promise<string>;
|
|
297
|
+
/**
|
|
298
|
+
* List all VTXO swaps from local storage.
|
|
299
|
+
*
|
|
300
|
+
* Returns all stored VTXO swaps without fetching from the API.
|
|
301
|
+
*/
|
|
302
|
+
listAllVtxoSwaps(): Promise<ExtendedVtxoSwapStorageData[]>;
|
|
162
303
|
}
|
|
163
304
|
/**
|
|
164
305
|
* Result from creating a VTXO swap.
|
|
@@ -174,7 +315,7 @@ export class CreateVtxoSwapResult {
|
|
|
174
315
|
/**
|
|
175
316
|
* The swap parameters (needed for claim/refund)
|
|
176
317
|
*/
|
|
177
|
-
|
|
318
|
+
swap_params: SwapParams;
|
|
178
319
|
}
|
|
179
320
|
/**
|
|
180
321
|
* Estimate response for a VTXO swap.
|
|
@@ -186,23 +327,126 @@ export class EstimateVtxoSwapResponse {
|
|
|
186
327
|
/**
|
|
187
328
|
* Total fee in satoshis
|
|
188
329
|
*/
|
|
189
|
-
|
|
330
|
+
fee_sats: bigint;
|
|
190
331
|
/**
|
|
191
332
|
* Total input amount in satoshis
|
|
192
333
|
*/
|
|
193
|
-
|
|
334
|
+
total_input_sats: bigint;
|
|
194
335
|
/**
|
|
195
336
|
* Amount user will receive (total_input_sats - fee_sats)
|
|
196
337
|
*/
|
|
197
|
-
|
|
338
|
+
output_sats: bigint;
|
|
198
339
|
/**
|
|
199
340
|
* Number of VTXOs being refreshed
|
|
200
341
|
*/
|
|
201
|
-
|
|
342
|
+
vtxo_count: number;
|
|
202
343
|
/**
|
|
203
344
|
* Expected expiry timestamp (Unix) of the resulting VTXOs
|
|
204
345
|
*/
|
|
205
|
-
|
|
346
|
+
expected_vtxo_expiry: bigint;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* EVM to BTC swap response.
|
|
350
|
+
* Fields from SwapCommonFields are flattened.
|
|
351
|
+
*/
|
|
352
|
+
export class EvmToBtcSwapResponse {
|
|
353
|
+
private constructor();
|
|
354
|
+
free(): void;
|
|
355
|
+
[Symbol.dispose](): void;
|
|
356
|
+
id: string;
|
|
357
|
+
status: SwapStatus;
|
|
358
|
+
hash_lock: string;
|
|
359
|
+
fee_sats: bigint;
|
|
360
|
+
asset_amount: number;
|
|
361
|
+
sender_pk: string;
|
|
362
|
+
receiver_pk: string;
|
|
363
|
+
server_pk: string;
|
|
364
|
+
refund_locktime: number;
|
|
365
|
+
unilateral_claim_delay: bigint;
|
|
366
|
+
unilateral_refund_delay: bigint;
|
|
367
|
+
unilateral_refund_without_receiver_delay: bigint;
|
|
368
|
+
network: Network;
|
|
369
|
+
created_at: string;
|
|
370
|
+
htlc_address_evm: string;
|
|
371
|
+
htlc_address_arkade: string;
|
|
372
|
+
user_address_evm: string;
|
|
373
|
+
get user_address_arkade(): string | undefined;
|
|
374
|
+
set user_address_arkade(value: string | null | undefined);
|
|
375
|
+
ln_invoice: string;
|
|
376
|
+
source_token: TokenId;
|
|
377
|
+
target_token: TokenId;
|
|
378
|
+
sats_receive: bigint;
|
|
379
|
+
get bitcoin_htlc_fund_txid(): string | undefined;
|
|
380
|
+
set bitcoin_htlc_fund_txid(value: string | null | undefined);
|
|
381
|
+
get bitcoin_htlc_claim_txid(): string | undefined;
|
|
382
|
+
set bitcoin_htlc_claim_txid(value: string | null | undefined);
|
|
383
|
+
get evm_htlc_claim_txid(): string | undefined;
|
|
384
|
+
set evm_htlc_claim_txid(value: string | null | undefined);
|
|
385
|
+
get evm_htlc_fund_txid(): string | undefined;
|
|
386
|
+
set evm_htlc_fund_txid(value: string | null | undefined);
|
|
387
|
+
get create_swap_tx(): string | undefined;
|
|
388
|
+
set create_swap_tx(value: string | null | undefined);
|
|
389
|
+
get approve_tx(): string | undefined;
|
|
390
|
+
set approve_tx(value: string | null | undefined);
|
|
391
|
+
get gelato_forwarder_address(): string | undefined;
|
|
392
|
+
set gelato_forwarder_address(value: string | null | undefined);
|
|
393
|
+
get gelato_user_nonce(): string | undefined;
|
|
394
|
+
set gelato_user_nonce(value: string | null | undefined);
|
|
395
|
+
get gelato_user_deadline(): string | undefined;
|
|
396
|
+
set gelato_user_deadline(value: string | null | undefined);
|
|
397
|
+
source_token_address: string;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Extended swap storage data that combines the API response with client-side swap parameters.
|
|
401
|
+
* This is the data structure stored for each swap.
|
|
402
|
+
*
|
|
403
|
+
* Note: The `response` field contains a `GetSwapResponse` enum which cannot be directly
|
|
404
|
+
* exposed via wasm-bindgen. It is serialized to a plain JS object via serde.
|
|
405
|
+
*/
|
|
406
|
+
export class ExtendedSwapStorageData {
|
|
407
|
+
private constructor();
|
|
408
|
+
free(): void;
|
|
409
|
+
[Symbol.dispose](): void;
|
|
410
|
+
/**
|
|
411
|
+
* Get the swap type.
|
|
412
|
+
*/
|
|
413
|
+
readonly swapType: SwapType;
|
|
414
|
+
/**
|
|
415
|
+
* Get the BTC to EVM swap response, if this is a BTC to EVM swap.
|
|
416
|
+
* Returns undefined if this is an EVM to BTC swap.
|
|
417
|
+
*/
|
|
418
|
+
readonly btcToEvmResponse: BtcToEvmSwapResponse | undefined;
|
|
419
|
+
/**
|
|
420
|
+
* Get the EVM to BTC swap response, if this is an EVM to BTC swap.
|
|
421
|
+
* Returns undefined if this is a BTC to EVM swap.
|
|
422
|
+
*/
|
|
423
|
+
readonly evmToBtcResponse: EvmToBtcSwapResponse | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* Get the Onchain to Arkade swap response, if this is an Onchian to Arkade swap.
|
|
426
|
+
* Returns undefined if not.
|
|
427
|
+
*/
|
|
428
|
+
readonly btcToArkadeResponse: BtcToArkadeSwapResponse | undefined;
|
|
429
|
+
/**
|
|
430
|
+
* Get the swap parameters.
|
|
431
|
+
*/
|
|
432
|
+
readonly swapParams: SwapParams;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Extended VTXO swap data that combines the API response with client-side swap parameters.
|
|
436
|
+
* This is the data structure stored for each VTXO swap.
|
|
437
|
+
*/
|
|
438
|
+
export class ExtendedVtxoSwapStorageData {
|
|
439
|
+
private constructor();
|
|
440
|
+
free(): void;
|
|
441
|
+
[Symbol.dispose](): void;
|
|
442
|
+
/**
|
|
443
|
+
* The VTXO swap response from the API
|
|
444
|
+
*/
|
|
445
|
+
response: VtxoSwapResponse;
|
|
446
|
+
/**
|
|
447
|
+
* The client-side swap parameters (keys, preimage, etc.)
|
|
448
|
+
*/
|
|
449
|
+
swap_params: SwapParams;
|
|
206
450
|
}
|
|
207
451
|
export class IntoUnderlyingByteSource {
|
|
208
452
|
private constructor();
|
|
@@ -266,6 +510,44 @@ export class JsSwapStorageProvider {
|
|
|
266
510
|
*/
|
|
267
511
|
constructor(get_fn: Function, store_fn: Function, delete_fn: Function, list_fn: Function, get_all_fn: Function);
|
|
268
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* JavaScript VTXO swap storage provider passed from TypeScript.
|
|
515
|
+
*
|
|
516
|
+
* This struct wraps JavaScript callback functions that implement
|
|
517
|
+
* typed VTXO swap storage operations. Each function should return a Promise.
|
|
518
|
+
*
|
|
519
|
+
* # Example (TypeScript with Dexie)
|
|
520
|
+
*
|
|
521
|
+
* ```typescript
|
|
522
|
+
* import Dexie from 'dexie';
|
|
523
|
+
*
|
|
524
|
+
* const db = new Dexie('lendaswap');
|
|
525
|
+
* db.version(1).stores({ vtxoSwaps: 'id' });
|
|
526
|
+
*
|
|
527
|
+
* const vtxoSwapStorage = new JsVtxoSwapStorageProvider(
|
|
528
|
+
* async (swapId) => await db.vtxoSwaps.get(swapId) ?? null,
|
|
529
|
+
* async (swapId, data) => { await db.vtxoSwaps.put({ id: swapId, ...data }); },
|
|
530
|
+
* async (swapId) => { await db.vtxoSwaps.delete(swapId); },
|
|
531
|
+
* async () => await db.vtxoSwaps.toCollection().primaryKeys(),
|
|
532
|
+
* async () => await db.vtxoSwaps.toArray()
|
|
533
|
+
* );
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
export class JsVtxoSwapStorageProvider {
|
|
537
|
+
free(): void;
|
|
538
|
+
[Symbol.dispose](): void;
|
|
539
|
+
/**
|
|
540
|
+
* Create a new JsVtxoSwapStorageProvider from JavaScript callbacks.
|
|
541
|
+
*
|
|
542
|
+
* # Arguments
|
|
543
|
+
* * `get_fn` - Function: `(swapId: string) => Promise<ExtendedVtxoSwapStorageData | null>`
|
|
544
|
+
* * `store_fn` - Function: `(swapId: string, data: ExtendedVtxoSwapStorageData) => Promise<void>`
|
|
545
|
+
* * `delete_fn` - Function: `(swapId: string) => Promise<void>`
|
|
546
|
+
* * `list_fn` - Function: `() => Promise<string[]>`
|
|
547
|
+
* * `get_all_fn` - Function: `() => Promise<ExtendedVtxoSwapStorageData[]>`
|
|
548
|
+
*/
|
|
549
|
+
constructor(get_fn: Function, store_fn: Function, delete_fn: Function, list_fn: Function, get_all_fn: Function);
|
|
550
|
+
}
|
|
269
551
|
/**
|
|
270
552
|
* JavaScript wallet storage provider passed from TypeScript.
|
|
271
553
|
*
|
|
@@ -350,8 +632,44 @@ export class TokenId {
|
|
|
350
632
|
private constructor();
|
|
351
633
|
free(): void;
|
|
352
634
|
[Symbol.dispose](): void;
|
|
635
|
+
/**
|
|
636
|
+
* Static constructor for BTC Lightning token
|
|
637
|
+
*/
|
|
638
|
+
static btcLightning(): TokenId;
|
|
639
|
+
/**
|
|
640
|
+
* Static constructor for BTC onchain token
|
|
641
|
+
*/
|
|
642
|
+
static btcOnchain(): TokenId;
|
|
643
|
+
/**
|
|
644
|
+
* Static constructor for BTC Arkade token
|
|
645
|
+
*/
|
|
646
|
+
static btcArkade(): TokenId;
|
|
353
647
|
toString(): string;
|
|
354
648
|
static fromString(s: string): TokenId;
|
|
649
|
+
/**
|
|
650
|
+
* Returns true if this token equals another token
|
|
651
|
+
*/
|
|
652
|
+
equals(other: TokenId): boolean;
|
|
653
|
+
/**
|
|
654
|
+
* Returns true if the token is Arkade
|
|
655
|
+
*/
|
|
656
|
+
isArkade(): boolean;
|
|
657
|
+
/**
|
|
658
|
+
* Returns true if the token is Lightning
|
|
659
|
+
*/
|
|
660
|
+
isLightning(): boolean;
|
|
661
|
+
/**
|
|
662
|
+
* Returns true if the token is onchain btc
|
|
663
|
+
*/
|
|
664
|
+
isBtcOnchain(): boolean;
|
|
665
|
+
/**
|
|
666
|
+
* Returns true if the token is either Arkade or Lightning
|
|
667
|
+
*/
|
|
668
|
+
isBtc(): boolean;
|
|
669
|
+
/**
|
|
670
|
+
* Returns true if the token is not BTC on Arkade and not BTC on Lightning
|
|
671
|
+
*/
|
|
672
|
+
isEvmToken(): boolean;
|
|
355
673
|
}
|
|
356
674
|
/**
|
|
357
675
|
* Token information.
|
|
@@ -360,7 +678,7 @@ export class TokenInfo {
|
|
|
360
678
|
private constructor();
|
|
361
679
|
free(): void;
|
|
362
680
|
[Symbol.dispose](): void;
|
|
363
|
-
|
|
681
|
+
token_id: TokenId;
|
|
364
682
|
symbol: string;
|
|
365
683
|
chain: Chain;
|
|
366
684
|
name: string;
|
|
@@ -414,75 +732,75 @@ export class VtxoSwapResponse {
|
|
|
414
732
|
/**
|
|
415
733
|
* Creation timestamp (RFC3339)
|
|
416
734
|
*/
|
|
417
|
-
|
|
735
|
+
created_at: string;
|
|
418
736
|
/**
|
|
419
737
|
* Client's VHTLC address
|
|
420
738
|
*/
|
|
421
|
-
|
|
739
|
+
client_vhtlc_address: string;
|
|
422
740
|
/**
|
|
423
741
|
* Amount client should fund in satoshis
|
|
424
742
|
*/
|
|
425
|
-
|
|
743
|
+
client_fund_amount_sats: bigint;
|
|
426
744
|
/**
|
|
427
745
|
* Client's public key
|
|
428
746
|
*/
|
|
429
|
-
|
|
747
|
+
client_pk: string;
|
|
430
748
|
/**
|
|
431
749
|
* Client VHTLC locktime (Unix timestamp)
|
|
432
750
|
*/
|
|
433
|
-
|
|
751
|
+
client_locktime: bigint;
|
|
434
752
|
/**
|
|
435
753
|
* Client claim delay in seconds
|
|
436
754
|
*/
|
|
437
|
-
|
|
755
|
+
client_unilateral_claim_delay: bigint;
|
|
438
756
|
/**
|
|
439
757
|
* Client refund delay in seconds
|
|
440
758
|
*/
|
|
441
|
-
|
|
759
|
+
client_unilateral_refund_delay: bigint;
|
|
442
760
|
/**
|
|
443
761
|
* Client refund without receiver delay in seconds
|
|
444
762
|
*/
|
|
445
|
-
|
|
763
|
+
client_unilateral_refund_without_receiver_delay: bigint;
|
|
446
764
|
/**
|
|
447
765
|
* Server's VHTLC address
|
|
448
766
|
*/
|
|
449
|
-
|
|
767
|
+
server_vhtlc_address: string;
|
|
450
768
|
/**
|
|
451
769
|
* Amount server will fund in satoshis
|
|
452
770
|
*/
|
|
453
|
-
|
|
771
|
+
server_fund_amount_sats: bigint;
|
|
454
772
|
/**
|
|
455
773
|
* Server's public key
|
|
456
774
|
*/
|
|
457
|
-
|
|
775
|
+
server_pk: string;
|
|
458
776
|
/**
|
|
459
777
|
* Server VHTLC locktime (Unix timestamp)
|
|
460
778
|
*/
|
|
461
|
-
|
|
779
|
+
server_locktime: bigint;
|
|
462
780
|
/**
|
|
463
781
|
* Server claim delay in seconds
|
|
464
782
|
*/
|
|
465
|
-
|
|
783
|
+
server_unilateral_claim_delay: bigint;
|
|
466
784
|
/**
|
|
467
785
|
* Server refund delay in seconds
|
|
468
786
|
*/
|
|
469
|
-
|
|
787
|
+
server_unilateral_refund_delay: bigint;
|
|
470
788
|
/**
|
|
471
789
|
* Server refund without receiver delay in seconds
|
|
472
790
|
*/
|
|
473
|
-
|
|
791
|
+
server_unilateral_refund_without_receiver_delay: bigint;
|
|
474
792
|
/**
|
|
475
793
|
* Arkade server's public key
|
|
476
794
|
*/
|
|
477
|
-
|
|
795
|
+
arkade_server_pk: string;
|
|
478
796
|
/**
|
|
479
797
|
* The preimage hash (SHA256)
|
|
480
798
|
*/
|
|
481
|
-
|
|
799
|
+
preimage_hash: string;
|
|
482
800
|
/**
|
|
483
801
|
* Fee in satoshis
|
|
484
802
|
*/
|
|
485
|
-
|
|
803
|
+
fee_sats: bigint;
|
|
486
804
|
/**
|
|
487
805
|
* Bitcoin network
|
|
488
806
|
*/
|