@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
package/dist/api.d.ts
CHANGED
|
@@ -4,115 +4,26 @@
|
|
|
4
4
|
* This module provides a high-level TypeScript API that wraps the WASM-based
|
|
5
5
|
* API client for easier use in TypeScript/JavaScript applications.
|
|
6
6
|
*/
|
|
7
|
-
import { type CreateVtxoSwapResult, type EstimateVtxoSwapResponse, type SwapParams, type VtxoSwapResponse } from "../wasm/lendaswap_wasm_sdk.js";
|
|
8
|
-
|
|
9
|
-
export { CreateVtxoSwapResult, EstimateVtxoSwapResponse, QuoteResponse, SwapParams as VtxoSwapParams, TokenId, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
7
|
+
import { type AssetPair, type BtcToArkadeSwapResponse, type BtcToEvmSwapResponse, type CreateVtxoSwapResult, type EstimateVtxoSwapResponse, type EvmToBtcSwapResponse, type ExtendedVtxoSwapStorageData, type QuoteResponse, type SwapParams, type TokenInfo, type Version, type VhtlcAmounts, type VtxoSwapResponse } from "../wasm/lendaswap_wasm_sdk.js";
|
|
8
|
+
export { AssetPair, BtcToEvmSwapResponse, BtcToArkadeSwapResponse, Chain, CreateVtxoSwapResult, EstimateVtxoSwapResponse, EvmToBtcSwapResponse, ExtendedSwapStorageData as ExtendedSwapStorageDataWasm, ExtendedVtxoSwapStorageData, Network, QuoteResponse, SwapParams as VtxoSwapParams, SwapStatus, SwapType, swapStatusToString, TokenId, TokenInfo, Version, VhtlcAmounts, VtxoSwapResponse, } from "../wasm/lendaswap_wasm_sdk.js";
|
|
10
9
|
/**
|
|
11
10
|
* Known token identifiers.
|
|
12
11
|
* Add new tokens here as they become supported.
|
|
13
12
|
* Uses (string & {}) to allow unknown tokens while preserving autocomplete.
|
|
14
13
|
*/
|
|
15
|
-
export type TokenIdString = "btc_lightning" | "btc_arkade" | "usdc_pol" | "usdt0_pol" | "usdc_eth" | "usdt_eth" | "xaut_eth" | (string & {});
|
|
16
|
-
/**
|
|
17
|
-
* Blockchain network.
|
|
18
|
-
* Uses (string & {}) to allow unknown chains while preserving autocomplete.
|
|
19
|
-
*/
|
|
20
|
-
export type Chain = "Arkade" | "Lightning" | "Polygon" | "Ethereum" | (string & {});
|
|
21
|
-
/**
|
|
22
|
-
* Token information with typed token ID.
|
|
23
|
-
*/
|
|
24
|
-
export interface TokenInfo {
|
|
25
|
-
tokenId: TokenIdString;
|
|
26
|
-
symbol: string;
|
|
27
|
-
chain: Chain;
|
|
28
|
-
name: string;
|
|
29
|
-
decimals: number;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Asset pair with typed token info.
|
|
33
|
-
*/
|
|
34
|
-
export interface AssetPair {
|
|
35
|
-
source: TokenInfo;
|
|
36
|
-
target: TokenInfo;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Swap status enumeration.
|
|
40
|
-
* These match the server-side status values.
|
|
41
|
-
*/
|
|
42
|
-
export type SwapStatus = "pending" | "clientfunded" | "clientrefunded" | "serverfunded" | "clientredeeming" | "clientredeemed" | "serverredeemed" | "clientfundedserverrefunded" | "clientrefundedserverfunded" | "clientrefundedserverrefunded" | "expired" | "clientinvalidfunded" | "clientfundedtoolate";
|
|
43
|
-
/**
|
|
44
|
-
* Common fields shared across all swap directions.
|
|
45
|
-
* These fields are flattened into the response by serde.
|
|
46
|
-
*/
|
|
47
|
-
export interface SwapCommonFields {
|
|
48
|
-
id: string;
|
|
49
|
-
status: SwapStatus;
|
|
50
|
-
hash_lock: string;
|
|
51
|
-
fee_sats: number;
|
|
52
|
-
asset_amount: number;
|
|
53
|
-
sender_pk: string;
|
|
54
|
-
receiver_pk: string;
|
|
55
|
-
server_pk: string;
|
|
56
|
-
refund_locktime: number;
|
|
57
|
-
unilateral_claim_delay: number;
|
|
58
|
-
unilateral_refund_delay: number;
|
|
59
|
-
unilateral_refund_without_receiver_delay: number;
|
|
60
|
-
network: string;
|
|
61
|
-
created_at: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* BTC to EVM swap response.
|
|
65
|
-
* Note: direction field is added by the SDK, not returned by the server.
|
|
66
|
-
*/
|
|
67
|
-
export interface BtcToEvmSwapResponse extends SwapCommonFields {
|
|
68
|
-
direction: "btc_to_evm";
|
|
69
|
-
htlc_address_evm: string;
|
|
70
|
-
htlc_address_arkade: string;
|
|
71
|
-
user_address_evm: string;
|
|
72
|
-
ln_invoice: string;
|
|
73
|
-
sats_receive: number;
|
|
74
|
-
source_token: TokenIdString;
|
|
75
|
-
target_token: TokenIdString;
|
|
76
|
-
bitcoin_htlc_claim_txid: string | null;
|
|
77
|
-
bitcoin_htlc_fund_txid: string | null;
|
|
78
|
-
evm_htlc_claim_txid: string | null;
|
|
79
|
-
evm_htlc_fund_txid: string | null;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* EVM to BTC swap response.
|
|
83
|
-
* Note: direction field is added by the SDK, not returned by the server.
|
|
84
|
-
*/
|
|
85
|
-
export interface EvmToBtcSwapResponse extends SwapCommonFields {
|
|
86
|
-
direction: "evm_to_btc";
|
|
87
|
-
htlc_address_evm: string;
|
|
88
|
-
htlc_address_arkade: string;
|
|
89
|
-
user_address_evm: string;
|
|
90
|
-
user_address_arkade: string | null;
|
|
91
|
-
ln_invoice: string;
|
|
92
|
-
source_token: TokenIdString;
|
|
93
|
-
target_token: TokenIdString;
|
|
94
|
-
sats_receive: number;
|
|
95
|
-
bitcoin_htlc_fund_txid: string | null;
|
|
96
|
-
bitcoin_htlc_claim_txid: string | null;
|
|
97
|
-
evm_htlc_claim_txid: string | null;
|
|
98
|
-
evm_htlc_fund_txid: string | null;
|
|
99
|
-
create_swap_tx: string | null;
|
|
100
|
-
approve_tx: string | null;
|
|
101
|
-
gelato_forwarder_address: string | null;
|
|
102
|
-
gelato_user_nonce: string | null;
|
|
103
|
-
gelato_user_deadline: string | null;
|
|
104
|
-
source_token_address: string;
|
|
105
|
-
}
|
|
14
|
+
export type TokenIdString = "btc_lightning" | "btc_arkade" | "btc_onchain" | "usdc_pol" | "usdt0_pol" | "usdc_eth" | "usdt_eth" | "xaut_eth" | (string & {});
|
|
106
15
|
/**
|
|
107
16
|
* Union type for swap responses based on direction.
|
|
17
|
+
* Uses WASM types directly - BtcToEvmSwapResponse and EvmToBtcSwapResponse are
|
|
18
|
+
* exported from the WASM module.
|
|
108
19
|
*/
|
|
109
|
-
export type GetSwapResponse = BtcToEvmSwapResponse | EvmToBtcSwapResponse;
|
|
20
|
+
export type GetSwapResponse = BtcToEvmSwapResponse | EvmToBtcSwapResponse | BtcToArkadeSwapResponse;
|
|
110
21
|
/**
|
|
111
|
-
* Extended swap storage data
|
|
112
|
-
* Used for
|
|
22
|
+
* Extended swap storage data combining the API response with client-side swap parameters.
|
|
23
|
+
* Used for storage providers and as a common interface for swap data.
|
|
113
24
|
*/
|
|
114
25
|
export interface ExtendedSwapStorageData {
|
|
115
|
-
response:
|
|
26
|
+
response: BtcToEvmSwapResponse | EvmToBtcSwapResponse | BtcToArkadeSwapResponse;
|
|
116
27
|
swap_params: SwapParams;
|
|
117
28
|
}
|
|
118
29
|
/**
|
|
@@ -143,6 +54,17 @@ export interface EvmToLightningSwapRequest {
|
|
|
143
54
|
user_address: string;
|
|
144
55
|
referral_code?: string;
|
|
145
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Request to create an on-chain Bitcoin to Arkade swap.
|
|
59
|
+
*/
|
|
60
|
+
export interface BtcToArkadeSwapRequest {
|
|
61
|
+
/** User's target Arkade address to receive VTXOs */
|
|
62
|
+
target_arkade_address: string;
|
|
63
|
+
/** Amount user wants to receive on Arkade in satoshis */
|
|
64
|
+
sats_receive: number;
|
|
65
|
+
/** Optional referral code */
|
|
66
|
+
referral_code?: string;
|
|
67
|
+
}
|
|
146
68
|
/**
|
|
147
69
|
* Gelato relay submit request.
|
|
148
70
|
*/
|
|
@@ -179,29 +101,6 @@ export interface QuoteRequest {
|
|
|
179
101
|
to: TokenIdString;
|
|
180
102
|
base_amount: number;
|
|
181
103
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Version information (snake_case for consistency with other API types).
|
|
184
|
-
*/
|
|
185
|
-
export interface VersionInfo {
|
|
186
|
-
tag: string;
|
|
187
|
-
commit_hash: string;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Quote response (snake_case for consistency with other API types).
|
|
191
|
-
*/
|
|
192
|
-
export interface QuoteResponseInfo {
|
|
193
|
-
exchange_rate: string;
|
|
194
|
-
network_fee: number;
|
|
195
|
-
protocol_fee: number;
|
|
196
|
-
protocol_fee_rate: number;
|
|
197
|
-
min_amount: number;
|
|
198
|
-
max_amount: number;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* VTXO swap status values.
|
|
202
|
-
* Note: WASM returns status as lowercase string (e.g., "pending", "clientfunded")
|
|
203
|
-
*/
|
|
204
|
-
export type VtxoSwapStatus = "pending" | "clientfunded" | "serverfunded" | "clientredeemed" | "serverredeemed" | "clientrefunded" | "clientfundedserverrefunded" | "expired";
|
|
205
104
|
/**
|
|
206
105
|
* Typed storage provider interface for wallet data (mnemonic, key index).
|
|
207
106
|
* Provides typed async methods for wallet credential storage.
|
|
@@ -218,8 +117,7 @@ export interface WalletStorageProvider {
|
|
|
218
117
|
}
|
|
219
118
|
/**
|
|
220
119
|
* Typed storage provider interface for swap data.
|
|
221
|
-
*
|
|
222
|
-
* to store them efficiently (e.g., as objects in IndexedDB via Dexie).
|
|
120
|
+
* Storage receives plain objects from serde serialization.
|
|
223
121
|
*/
|
|
224
122
|
export interface SwapStorageProvider {
|
|
225
123
|
/** Get swap data by swap ID. Returns null if not found. */
|
|
@@ -234,11 +132,36 @@ export interface SwapStorageProvider {
|
|
|
234
132
|
getAll: () => Promise<ExtendedSwapStorageData[]>;
|
|
235
133
|
}
|
|
236
134
|
/**
|
|
237
|
-
*
|
|
135
|
+
* Typed storage provider interface for VTXO swap data.
|
|
136
|
+
* Storage receives plain objects matching ExtendedVtxoSwapStorageData structure.
|
|
238
137
|
*/
|
|
239
|
-
export
|
|
138
|
+
export interface VtxoSwapStorageProvider {
|
|
139
|
+
/** Get VTXO swap data by swap ID. Returns null if not found. */
|
|
140
|
+
get: (swapId: string) => Promise<ExtendedVtxoSwapStorageData | null>;
|
|
141
|
+
/** Store VTXO swap data. Overwrites any existing swap with the same ID. */
|
|
142
|
+
store: (swapId: string, data: ExtendedVtxoSwapStorageData) => Promise<void>;
|
|
143
|
+
/** Delete VTXO swap data by swap ID. */
|
|
144
|
+
delete: (swapId: string) => Promise<void>;
|
|
145
|
+
/** List all stored VTXO swap IDs. */
|
|
146
|
+
list: () => Promise<string[]>;
|
|
147
|
+
/** List all stored VTXO swaps. */
|
|
148
|
+
getAll: () => Promise<ExtendedVtxoSwapStorageData[]>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Network input type for Bitcoin networks (string union for API convenience).
|
|
152
|
+
*/
|
|
153
|
+
export type NetworkInput = "bitcoin" | "testnet" | "regtest" | "mutinynet";
|
|
154
|
+
/**
|
|
155
|
+
* Extended swap storage provider with repair capabilities.
|
|
156
|
+
*/
|
|
157
|
+
export interface ExtendedSwapStorageProvider extends SwapStorageProvider {
|
|
158
|
+
/** Get raw swap_params for a potentially corrupted entry. */
|
|
159
|
+
getRawSwapParams?: (swapId: string) => Promise<Record<string, any> | null>;
|
|
160
|
+
}
|
|
240
161
|
export declare class Client {
|
|
241
162
|
private client;
|
|
163
|
+
private baseUrl;
|
|
164
|
+
private swapStorage;
|
|
242
165
|
private constructor();
|
|
243
166
|
/**
|
|
244
167
|
* Create a new Client instance.
|
|
@@ -246,45 +169,37 @@ export declare class Client {
|
|
|
246
169
|
* @param baseUrl - The base URL of the Lendaswap API
|
|
247
170
|
* @param walletStorage - Storage provider for persisting wallet data (mnemonic, key index)
|
|
248
171
|
* @param swapStorage - Storage provider for persisting swap data (uses Dexie/IndexedDB)
|
|
172
|
+
* @param vtxoSwapStorage - Storage provider for persisting VTXO swap data (uses Dexie/IndexedDB)
|
|
249
173
|
* @param network - Bitcoin network ("bitcoin", "testnet", "regtest", "mutinynet")
|
|
250
174
|
* @param arkadeUrl - Arkade's server url
|
|
251
|
-
* @param
|
|
175
|
+
* @param esploraUrl - Esplora API URL for on-chain Bitcoin operations (e.g., "https://mempool.space/api")
|
|
252
176
|
* @returns A new Client instance
|
|
253
177
|
*
|
|
254
178
|
* @example
|
|
255
179
|
* ```typescript
|
|
256
|
-
* import
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* // Swap storage using Dexie (IndexedDB)
|
|
267
|
-
* const db = new Dexie('lendaswap');
|
|
268
|
-
* db.version(1).stores({ swaps: 'id' });
|
|
269
|
-
*
|
|
270
|
-
* const swapStorage: SwapStorageProvider = {
|
|
271
|
-
* get: async (swapId) => await db.table('swaps').get(swapId) ?? null,
|
|
272
|
-
* store: async (swapId, data) => await db.table('swaps').put({ id: swapId, ...data }),
|
|
273
|
-
* delete: async (swapId) => await db.table('swaps').delete(swapId),
|
|
274
|
-
* list: async () => await db.table('swaps').toCollection().primaryKeys() as string[],
|
|
275
|
-
* getAll: async () => await db.table('swaps').toArray(),
|
|
276
|
-
* };
|
|
180
|
+
* import {
|
|
181
|
+
* Client,
|
|
182
|
+
* createDexieWalletStorage,
|
|
183
|
+
* createDexieSwapStorage,
|
|
184
|
+
* createDexieVtxoSwapStorage
|
|
185
|
+
* } from '@lendasat/lendaswap-sdk';
|
|
186
|
+
*
|
|
187
|
+
* const walletStorage = createDexieWalletStorage();
|
|
188
|
+
* const swapStorage = createDexieSwapStorage();
|
|
189
|
+
* const vtxoSwapStorage = createDexieVtxoSwapStorage();
|
|
277
190
|
*
|
|
278
191
|
* const client = await Client.create(
|
|
279
192
|
* 'https://apilendaswap.lendasat.com',
|
|
280
193
|
* walletStorage,
|
|
281
194
|
* swapStorage,
|
|
195
|
+
* vtxoSwapStorage,
|
|
282
196
|
* 'bitcoin',
|
|
283
|
-
* 'https://arkade.computer'
|
|
197
|
+
* 'https://arkade.computer',
|
|
198
|
+
* 'https://mempool.space/api'
|
|
284
199
|
* );
|
|
285
200
|
* ```
|
|
286
201
|
*/
|
|
287
|
-
static create(baseUrl: string, walletStorage: WalletStorageProvider, swapStorage:
|
|
202
|
+
static create(baseUrl: string, walletStorage: WalletStorageProvider, swapStorage: ExtendedSwapStorageProvider, vtxoSwapStorage: VtxoSwapStorageProvider, network: NetworkInput, arkadeUrl: string, esploraUrl: string): Promise<Client>;
|
|
288
203
|
init(mnemonic?: string): Promise<void>;
|
|
289
204
|
/**
|
|
290
205
|
* Create an Arkade to EVM swap (BTC → Token).
|
|
@@ -320,18 +235,18 @@ export declare class Client {
|
|
|
320
235
|
* @param baseAmount - Amount in base units (satoshis for BTC, wei for EVM)
|
|
321
236
|
* @returns Quote response with exchange rate and fees
|
|
322
237
|
*/
|
|
323
|
-
getQuote(from: TokenIdString, to: TokenIdString, baseAmount: bigint): Promise<
|
|
238
|
+
getQuote(from: TokenIdString, to: TokenIdString, baseAmount: bigint): Promise<QuoteResponse>;
|
|
324
239
|
/**
|
|
325
240
|
* Get a swap by its ID.
|
|
326
241
|
*
|
|
327
242
|
* @param id - The swap ID
|
|
328
|
-
* @returns The swap
|
|
243
|
+
* @returns The swap data, or undefined if the swap type is unknown
|
|
329
244
|
*/
|
|
330
|
-
getSwap(id: string): Promise<ExtendedSwapStorageData>;
|
|
245
|
+
getSwap(id: string): Promise<ExtendedSwapStorageData | undefined>;
|
|
331
246
|
/**
|
|
332
247
|
* Gets all stored swaps.
|
|
333
248
|
*
|
|
334
|
-
* @returns
|
|
249
|
+
* @returns Array of swaps (unknown types are filtered out)
|
|
335
250
|
*/
|
|
336
251
|
listAllSwaps(): Promise<ExtendedSwapStorageData[]>;
|
|
337
252
|
/**
|
|
@@ -366,11 +281,11 @@ export declare class Client {
|
|
|
366
281
|
*
|
|
367
282
|
* @returns Version information
|
|
368
283
|
*/
|
|
369
|
-
getVersion(): Promise<
|
|
284
|
+
getVersion(): Promise<Version>;
|
|
370
285
|
/**
|
|
371
286
|
* Recover swaps for the currently loaded mnemonic.
|
|
372
287
|
*
|
|
373
|
-
* @returns
|
|
288
|
+
* @returns Array of recovered swaps (unknown types are filtered out)
|
|
374
289
|
*/
|
|
375
290
|
recoverSwaps(): Promise<ExtendedSwapStorageData[]>;
|
|
376
291
|
/**
|
|
@@ -391,6 +306,34 @@ export declare class Client {
|
|
|
391
306
|
* Delete one particular swap by id
|
|
392
307
|
*/
|
|
393
308
|
deleteSwap(id: string): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* Get the list of swap IDs that failed to deserialize during the last listAllSwaps() call.
|
|
311
|
+
* These are "corrupted" entries that couldn't be loaded due to invalid or missing data.
|
|
312
|
+
*
|
|
313
|
+
* @returns Array of swap IDs that failed to load
|
|
314
|
+
*/
|
|
315
|
+
getCorruptedSwapIds(): string[];
|
|
316
|
+
/**
|
|
317
|
+
* Delete all corrupted swap entries from storage.
|
|
318
|
+
* Call this after listAllSwaps() to clean up entries that couldn't be deserialized.
|
|
319
|
+
*
|
|
320
|
+
* @returns The number of corrupted entries that were deleted
|
|
321
|
+
*/
|
|
322
|
+
deleteCorruptedSwaps(): Promise<number>;
|
|
323
|
+
/**
|
|
324
|
+
* Attempt to repair corrupted swap entries by fetching missing data from the server.
|
|
325
|
+
*
|
|
326
|
+
* For each corrupted swap ID:
|
|
327
|
+
* 1. Reads the raw swap_params from local storage
|
|
328
|
+
* 2. Fetches the swap response from the server via GET /swap/:id
|
|
329
|
+
* 3. Combines them and stores the repaired entry
|
|
330
|
+
*
|
|
331
|
+
* @returns Object with repaired count and any failed IDs
|
|
332
|
+
*/
|
|
333
|
+
repairCorruptedSwaps(): Promise<{
|
|
334
|
+
repaired: number;
|
|
335
|
+
failed: string[];
|
|
336
|
+
}>;
|
|
394
337
|
/**
|
|
395
338
|
* Estimate the fee for a VTXO swap.
|
|
396
339
|
*
|
|
@@ -413,9 +356,9 @@ export declare class Client {
|
|
|
413
356
|
* Get VTXO swap details by ID.
|
|
414
357
|
*
|
|
415
358
|
* @param id - The swap ID
|
|
416
|
-
* @returns The VTXO swap
|
|
359
|
+
* @returns The extended VTXO swap data
|
|
417
360
|
*/
|
|
418
|
-
getVtxoSwap(id: string): Promise<
|
|
361
|
+
getVtxoSwap(id: string): Promise<ExtendedVtxoSwapStorageData>;
|
|
419
362
|
/**
|
|
420
363
|
* Claim the server's VHTLC in a VTXO swap.
|
|
421
364
|
*
|
|
@@ -434,12 +377,47 @@ export declare class Client {
|
|
|
434
377
|
* This can be called if the swap fails (e.g., server doesn't fund)
|
|
435
378
|
* and the client's locktime has expired.
|
|
436
379
|
*
|
|
437
|
-
* @param
|
|
438
|
-
* @param swapParams - The client's swap parameters
|
|
380
|
+
* @param swapId - The swap ID
|
|
439
381
|
* @param refundAddress - The Arkade address to receive the refunded funds
|
|
440
382
|
* @returns The refund transaction ID
|
|
441
383
|
*/
|
|
442
|
-
refundVtxoSwap(
|
|
384
|
+
refundVtxoSwap(swapId: string, refundAddress: string): Promise<string>;
|
|
385
|
+
/**
|
|
386
|
+
* List all VTXO swaps from local storage.
|
|
387
|
+
*
|
|
388
|
+
* Returns all stored VTXO swaps without fetching from the API.
|
|
389
|
+
*
|
|
390
|
+
* @returns Array of all stored extended VTXO swap data
|
|
391
|
+
*/
|
|
392
|
+
listAllVtxoSwaps(): Promise<ExtendedVtxoSwapStorageData[]>;
|
|
393
|
+
/**
|
|
394
|
+
* Create an on-chain Bitcoin to Arkade swap.
|
|
395
|
+
*
|
|
396
|
+
* User sends on-chain BTC to a P2WSH HTLC address, and receives Arkade VTXOs.
|
|
397
|
+
*
|
|
398
|
+
* @param request - The swap request parameters
|
|
399
|
+
* @returns The created swap response with P2WSH address to fund
|
|
400
|
+
*/
|
|
401
|
+
createBitcoinToArkadeSwap(request: BtcToArkadeSwapRequest): Promise<BtcToArkadeSwapResponse>;
|
|
402
|
+
/**
|
|
403
|
+
* Claim the Arkade VHTLC for a BTC-to-Arkade swap.
|
|
404
|
+
*
|
|
405
|
+
* This reveals the preimage/secret to claim funds on Arkade.
|
|
406
|
+
*
|
|
407
|
+
* @param swapId - The swap ID
|
|
408
|
+
* @returns The Arkade claim transaction ID
|
|
409
|
+
*/
|
|
410
|
+
claimBtcToArkadeVhtlc(swapId: string): Promise<string>;
|
|
411
|
+
/**
|
|
412
|
+
* Refund from the on-chain Bitcoin HTLC after timeout.
|
|
413
|
+
*
|
|
414
|
+
* This spends from the P2WSH HTLC back to the user's address.
|
|
415
|
+
*
|
|
416
|
+
* @param swapId - The swap ID
|
|
417
|
+
* @param refundAddress - The Bitcoin address to receive the refund
|
|
418
|
+
* @returns The refund transaction ID
|
|
419
|
+
*/
|
|
420
|
+
refundOnchainHtlc(swapId: string, refundAddress: string): Promise<string>;
|
|
443
421
|
}
|
|
444
422
|
/**
|
|
445
423
|
* Log level type for SDK logging configuration.
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAEzB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EAEzB,KAAK,2BAA2B,EAKhC,KAAK,aAAa,EAElB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACtB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,EACL,oBAAoB,EACpB,wBA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