@atomiqlabs/sdk 8.4.3 → 8.4.4
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/swaps/ISwap.d.ts +14 -0
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +5 -1
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +10 -0
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +4 -0
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +9 -0
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +4 -0
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +7 -0
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +9 -0
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +13 -0
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +4 -0
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +8 -0
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +8 -0
- package/dist/swaps/trusted/ln/LnForGasSwap.js +12 -0
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +8 -0
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +13 -0
- package/dist/types/lnurl/LNURLPay.d.ts +0 -1
- package/dist/types/lnurl/LNURLPay.js +0 -1
- package/dist/types/lnurl/LNURLWithdraw.d.ts +0 -1
- package/dist/types/lnurl/LNURLWithdraw.js +0 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/swaps/ISwap.ts +16 -0
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +13 -1
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +10 -0
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +8 -0
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +15 -0
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +9 -0
- package/src/swaps/trusted/ln/LnForGasSwap.ts +15 -1
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +15 -0
- package/src/types/lnurl/LNURLPay.ts +0 -1
- package/src/types/lnurl/LNURLWithdraw.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export * from "./types/lnurl/LNURLWithdraw";
|
|
|
73
73
|
export * from "./types/wallets/MinimalBitcoinWalletInterface";
|
|
74
74
|
export * from "./types/wallets/MinimalLightningNetworkWalletInterface";
|
|
75
75
|
export * from "./types/wallets/LightningInvoiceCreateService";
|
|
76
|
+
export * from "./types/SwapStateInfo";
|
|
76
77
|
export * from "./types/AmountData";
|
|
77
78
|
export * from "./types/CustomPriceFunction";
|
|
78
79
|
export * from "./types/SwapExecutionAction";
|
package/dist/index.js
CHANGED
|
@@ -146,6 +146,7 @@ __exportStar(require("./types/lnurl/LNURLWithdraw"), exports);
|
|
|
146
146
|
__exportStar(require("./types/wallets/MinimalBitcoinWalletInterface"), exports);
|
|
147
147
|
__exportStar(require("./types/wallets/MinimalLightningNetworkWalletInterface"), exports);
|
|
148
148
|
__exportStar(require("./types/wallets/LightningInvoiceCreateService"), exports);
|
|
149
|
+
__exportStar(require("./types/SwapStateInfo"), exports);
|
|
149
150
|
__exportStar(require("./types/AmountData"), exports);
|
|
150
151
|
__exportStar(require("./types/CustomPriceFunction"), exports);
|
|
151
152
|
__exportStar(require("./types/SwapExecutionAction"), exports);
|
package/dist/swaps/ISwap.d.ts
CHANGED
|
@@ -156,6 +156,16 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
156
156
|
* @param options Additional options for executing the swap
|
|
157
157
|
*/
|
|
158
158
|
abstract txsExecute(options?: any): Promise<SwapExecutionAction<T>[]>;
|
|
159
|
+
/**
|
|
160
|
+
* Executes the swap with the provided wallet, the exact arguments for this functions differ for various swap
|
|
161
|
+
* types. Check the `execute()` function signature in the respective swap class to see the required arguments.
|
|
162
|
+
*
|
|
163
|
+
* @param args Execution arguments, usually contains a source wallet object, callbacks and options, for exact
|
|
164
|
+
* syntax check the respective swap class.
|
|
165
|
+
*
|
|
166
|
+
* @returns Whether a swap was successfully executed or not, if it wasn't the user can refund or claim manually
|
|
167
|
+
*/
|
|
168
|
+
abstract execute(...args: any[]): Promise<boolean>;
|
|
159
169
|
/**
|
|
160
170
|
* This attempts to populate missing fields in the pricing info based on the swap amounts
|
|
161
171
|
*
|
|
@@ -257,6 +267,10 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
257
267
|
* Returns whether the swap failed (e.g. was refunded)
|
|
258
268
|
*/
|
|
259
269
|
abstract isFailed(): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Returns whether the swap is currently being processed
|
|
272
|
+
*/
|
|
273
|
+
abstract isInProgress(): boolean;
|
|
260
274
|
/**
|
|
261
275
|
* Whether a swap was initialized, a swap is considered initialized on first interaction with it, i.e.
|
|
262
276
|
* calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other
|
|
@@ -208,6 +208,10 @@ export declare class FromBTCLNSwap<T extends ChainType = ChainType> extends IFro
|
|
|
208
208
|
* @inheritDoc
|
|
209
209
|
*/
|
|
210
210
|
isFailed(): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* @inheritDoc
|
|
213
|
+
*/
|
|
214
|
+
isInProgress(): boolean;
|
|
211
215
|
/**
|
|
212
216
|
* @inheritDoc
|
|
213
217
|
*/
|
|
@@ -282,7 +286,7 @@ export declare class FromBTCLNSwap<T extends ChainType = ChainType> extends IFro
|
|
|
282
286
|
secret?: string;
|
|
283
287
|
lightningTxCheckIntervalSeconds?: number;
|
|
284
288
|
delayBetweenCommitAndClaimSeconds?: number;
|
|
285
|
-
}): Promise<
|
|
289
|
+
}): Promise<boolean>;
|
|
286
290
|
/**
|
|
287
291
|
* @inheritDoc
|
|
288
292
|
*
|
|
@@ -321,6 +321,15 @@ class FromBTCLNSwap extends IFromBTCSelfInitSwap_1.IFromBTCSelfInitSwap {
|
|
|
321
321
|
isFailed() {
|
|
322
322
|
return this._state === FromBTCLNSwapState.FAILED || this._state === FromBTCLNSwapState.EXPIRED;
|
|
323
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* @inheritDoc
|
|
326
|
+
*/
|
|
327
|
+
isInProgress() {
|
|
328
|
+
return (this._state === FromBTCLNSwapState.PR_CREATED && this.initiated) ||
|
|
329
|
+
(this._state === FromBTCLNSwapState.QUOTE_SOFT_EXPIRED && this.initiated) ||
|
|
330
|
+
this._state === FromBTCLNSwapState.PR_PAID ||
|
|
331
|
+
this._state === FromBTCLNSwapState.CLAIM_COMMITED;
|
|
332
|
+
}
|
|
324
333
|
/**
|
|
325
334
|
* @inheritDoc
|
|
326
335
|
*/
|
|
@@ -485,6 +494,7 @@ class FromBTCLNSwap extends IFromBTCSelfInitSwap_1.IFromBTCSelfInitSwap {
|
|
|
485
494
|
if (callbacks?.onSwapSettled != null)
|
|
486
495
|
callbacks.onSwapSettled(this.getOutputTxId());
|
|
487
496
|
}
|
|
497
|
+
return true;
|
|
488
498
|
}
|
|
489
499
|
/**
|
|
490
500
|
* @inheritDoc
|
|
@@ -352,6 +352,15 @@ class FromBTCLNAutoSwap extends IEscrowSwap_1.IEscrowSwap {
|
|
|
352
352
|
isFailed() {
|
|
353
353
|
return this._state === FromBTCLNAutoSwapState.FAILED || this._state === FromBTCLNAutoSwapState.EXPIRED;
|
|
354
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* @inheritDoc
|
|
357
|
+
*/
|
|
358
|
+
isInProgress() {
|
|
359
|
+
return (this._state === FromBTCLNAutoSwapState.PR_CREATED && this.initiated) ||
|
|
360
|
+
(this._state === FromBTCLNAutoSwapState.QUOTE_SOFT_EXPIRED && this.initiated) ||
|
|
361
|
+
this._state === FromBTCLNAutoSwapState.PR_PAID ||
|
|
362
|
+
this._state === FromBTCLNAutoSwapState.CLAIM_COMMITED;
|
|
363
|
+
}
|
|
355
364
|
/**
|
|
356
365
|
* @inheritDoc
|
|
357
366
|
*/
|
|
@@ -237,6 +237,13 @@ class FromBTCSwap extends IFromBTCSelfInitSwap_1.IFromBTCSelfInitSwap {
|
|
|
237
237
|
isFailed() {
|
|
238
238
|
return this._state === FromBTCSwapState.FAILED || this._state === FromBTCSwapState.EXPIRED;
|
|
239
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* @inheritDoc
|
|
242
|
+
*/
|
|
243
|
+
isInProgress() {
|
|
244
|
+
return this._state === FromBTCSwapState.CLAIM_COMMITED ||
|
|
245
|
+
this._state === FromBTCSwapState.BTC_TX_CONFIRMED;
|
|
246
|
+
}
|
|
240
247
|
/**
|
|
241
248
|
* @inheritDoc
|
|
242
249
|
*/
|
|
@@ -172,6 +172,15 @@ export declare abstract class IToBTCSwap<T extends ChainType = ChainType, D exte
|
|
|
172
172
|
* @inheritDoc
|
|
173
173
|
*/
|
|
174
174
|
isFailed(): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* @inheritDoc
|
|
177
|
+
*/
|
|
178
|
+
isInProgress(): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Returns the time (in UNIX milliseconds) at which the swap expires and the user is able to unilaterally
|
|
181
|
+
* refund it with the {@link refund} or {@link txsRefund} function.
|
|
182
|
+
*/
|
|
183
|
+
getExpiry(): number;
|
|
175
184
|
/**
|
|
176
185
|
* @inheritDoc
|
|
177
186
|
* @internal
|
|
@@ -221,6 +221,19 @@ class IToBTCSwap extends IEscrowSelfInitSwap_1.IEscrowSelfInitSwap {
|
|
|
221
221
|
isFailed() {
|
|
222
222
|
return this._state === ToBTCSwapState.REFUNDED;
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* @inheritDoc
|
|
226
|
+
*/
|
|
227
|
+
isInProgress() {
|
|
228
|
+
return this._state === ToBTCSwapState.COMMITED || this._state === ToBTCSwapState.SOFT_CLAIMED;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Returns the time (in UNIX milliseconds) at which the swap expires and the user is able to unilaterally
|
|
232
|
+
* refund it with the {@link refund} or {@link txsRefund} function.
|
|
233
|
+
*/
|
|
234
|
+
getExpiry() {
|
|
235
|
+
return Number(this._data.getExpiry()) * 1000;
|
|
236
|
+
}
|
|
224
237
|
/**
|
|
225
238
|
* @inheritDoc
|
|
226
239
|
* @internal
|
|
@@ -346,6 +346,14 @@ class SpvFromBTCSwap extends ISwap_1.ISwap {
|
|
|
346
346
|
isFailed() {
|
|
347
347
|
return this._state === SpvFromBTCSwapState.FAILED || this._state === SpvFromBTCSwapState.DECLINED || this._state === SpvFromBTCSwapState.CLOSED;
|
|
348
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* @inheritDoc
|
|
351
|
+
*/
|
|
352
|
+
isInProgress() {
|
|
353
|
+
return this._state === SpvFromBTCSwapState.POSTED ||
|
|
354
|
+
this._state === SpvFromBTCSwapState.BROADCASTED ||
|
|
355
|
+
this._state === SpvFromBTCSwapState.BTC_TX_CONFIRMED;
|
|
356
|
+
}
|
|
349
357
|
/**
|
|
350
358
|
* @inheritDoc
|
|
351
359
|
*/
|
|
@@ -151,6 +151,10 @@ export declare class LnForGasSwap<T extends ChainType = ChainType> extends ISwap
|
|
|
151
151
|
* @inheritDoc
|
|
152
152
|
*/
|
|
153
153
|
isSuccessful(): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* @inheritDoc
|
|
156
|
+
*/
|
|
157
|
+
isInProgress(): boolean;
|
|
154
158
|
/**
|
|
155
159
|
* @inheritDoc
|
|
156
160
|
* @internal
|
|
@@ -209,6 +213,10 @@ export declare class LnForGasSwap<T extends ChainType = ChainType> extends ISwap
|
|
|
209
213
|
* @inheritDoc
|
|
210
214
|
*/
|
|
211
215
|
txsExecute(): Promise<[SwapExecutionActionLightning]>;
|
|
216
|
+
/**
|
|
217
|
+
* @remark Not supported
|
|
218
|
+
*/
|
|
219
|
+
execute(): Promise<boolean>;
|
|
212
220
|
/**
|
|
213
221
|
* @inheritDoc
|
|
214
222
|
*/
|
|
@@ -218,6 +218,12 @@ class LnForGasSwap extends ISwap_1.ISwap {
|
|
|
218
218
|
isSuccessful() {
|
|
219
219
|
return this._state === LnForGasSwapState.FINISHED;
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* @inheritDoc
|
|
223
|
+
*/
|
|
224
|
+
isInProgress() {
|
|
225
|
+
return (this._state === LnForGasSwapState.PR_CREATED && this.initiated) || this._state === LnForGasSwapState.PR_PAID;
|
|
226
|
+
}
|
|
221
227
|
/**
|
|
222
228
|
* @inheritDoc
|
|
223
229
|
* @internal
|
|
@@ -347,6 +353,12 @@ class LnForGasSwap extends ISwap_1.ISwap {
|
|
|
347
353
|
}
|
|
348
354
|
throw new Error("Invalid swap state to obtain execution txns, required PR_CREATED");
|
|
349
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* @remark Not supported
|
|
358
|
+
*/
|
|
359
|
+
async execute() {
|
|
360
|
+
throw new Error("Not supported");
|
|
361
|
+
}
|
|
350
362
|
/**
|
|
351
363
|
* @inheritDoc
|
|
352
364
|
*/
|
|
@@ -171,6 +171,10 @@ export declare class OnchainForGasSwap<T extends ChainType = ChainType> extends
|
|
|
171
171
|
* @inheritDoc
|
|
172
172
|
*/
|
|
173
173
|
isSuccessful(): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* @inheritDoc
|
|
176
|
+
*/
|
|
177
|
+
isInProgress(): boolean;
|
|
174
178
|
/**
|
|
175
179
|
* @inheritDoc
|
|
176
180
|
* @internal
|
|
@@ -267,6 +271,10 @@ export declare class OnchainForGasSwap<T extends ChainType = ChainType> extends
|
|
|
267
271
|
}): Promise<[
|
|
268
272
|
SwapExecutionActionBitcoin<"ADDRESS" | "FUNDED_PSBT">
|
|
269
273
|
]>;
|
|
274
|
+
/**
|
|
275
|
+
* @remark Not supported
|
|
276
|
+
*/
|
|
277
|
+
execute(): Promise<boolean>;
|
|
270
278
|
/**
|
|
271
279
|
* @inheritDoc
|
|
272
280
|
*
|
|
@@ -225,6 +225,13 @@ class OnchainForGasSwap extends ISwap_1.ISwap {
|
|
|
225
225
|
isSuccessful() {
|
|
226
226
|
return this._state === OnchainForGasSwapState.FINISHED;
|
|
227
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* @inheritDoc
|
|
230
|
+
*/
|
|
231
|
+
isInProgress() {
|
|
232
|
+
return (this._state === OnchainForGasSwapState.PR_CREATED && this.txId != null) ||
|
|
233
|
+
(this._state === OnchainForGasSwapState.REFUNDABLE && this.refundAddress != null);
|
|
234
|
+
}
|
|
228
235
|
/**
|
|
229
236
|
* @inheritDoc
|
|
230
237
|
* @internal
|
|
@@ -453,6 +460,12 @@ class OnchainForGasSwap extends ISwap_1.ISwap {
|
|
|
453
460
|
}
|
|
454
461
|
throw new Error("Invalid swap state to obtain execution txns, required PR_CREATED or CLAIM_COMMITED");
|
|
455
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* @remark Not supported
|
|
465
|
+
*/
|
|
466
|
+
async execute() {
|
|
467
|
+
throw new Error("Not supported");
|
|
468
|
+
}
|
|
456
469
|
/**
|
|
457
470
|
* @inheritDoc
|
|
458
471
|
*
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -127,6 +127,7 @@ export * from "./types/wallets/MinimalBitcoinWalletInterface";
|
|
|
127
127
|
export * from "./types/wallets/MinimalLightningNetworkWalletInterface";
|
|
128
128
|
export * from "./types/wallets/LightningInvoiceCreateService";
|
|
129
129
|
|
|
130
|
+
export * from "./types/SwapStateInfo";
|
|
130
131
|
export * from "./types/AmountData";
|
|
131
132
|
export * from "./types/CustomPriceFunction";
|
|
132
133
|
export * from "./types/SwapExecutionAction";
|
package/src/swaps/ISwap.ts
CHANGED
|
@@ -249,6 +249,17 @@ export abstract class ISwap<
|
|
|
249
249
|
*/
|
|
250
250
|
public abstract txsExecute(options?: any): Promise<SwapExecutionAction<T>[]>;
|
|
251
251
|
|
|
252
|
+
/**
|
|
253
|
+
* Executes the swap with the provided wallet, the exact arguments for this functions differ for various swap
|
|
254
|
+
* types. Check the `execute()` function signature in the respective swap class to see the required arguments.
|
|
255
|
+
*
|
|
256
|
+
* @param args Execution arguments, usually contains a source wallet object, callbacks and options, for exact
|
|
257
|
+
* syntax check the respective swap class.
|
|
258
|
+
*
|
|
259
|
+
* @returns Whether a swap was successfully executed or not, if it wasn't the user can refund or claim manually
|
|
260
|
+
*/
|
|
261
|
+
public abstract execute(...args: any[]): Promise<boolean>;
|
|
262
|
+
|
|
252
263
|
//////////////////////////////
|
|
253
264
|
//// Pricing
|
|
254
265
|
|
|
@@ -460,6 +471,11 @@ export abstract class ISwap<
|
|
|
460
471
|
*/
|
|
461
472
|
public abstract isFailed(): boolean;
|
|
462
473
|
|
|
474
|
+
/**
|
|
475
|
+
* Returns whether the swap is currently being processed
|
|
476
|
+
*/
|
|
477
|
+
public abstract isInProgress(): boolean;
|
|
478
|
+
|
|
463
479
|
/**
|
|
464
480
|
* Whether a swap was initialized, a swap is considered initialized on first interaction with it, i.e.
|
|
465
481
|
* calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other
|
|
@@ -385,6 +385,16 @@ export class FromBTCLNSwap<T extends ChainType = ChainType>
|
|
|
385
385
|
return this._state===FromBTCLNSwapState.FAILED || this._state===FromBTCLNSwapState.EXPIRED;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
/**
|
|
389
|
+
* @inheritDoc
|
|
390
|
+
*/
|
|
391
|
+
isInProgress(): boolean {
|
|
392
|
+
return (this._state===FromBTCLNSwapState.PR_CREATED && this.initiated) ||
|
|
393
|
+
(this._state===FromBTCLNSwapState.QUOTE_SOFT_EXPIRED && this.initiated) ||
|
|
394
|
+
this._state===FromBTCLNSwapState.PR_PAID ||
|
|
395
|
+
this._state===FromBTCLNSwapState.CLAIM_COMMITED;
|
|
396
|
+
}
|
|
397
|
+
|
|
388
398
|
/**
|
|
389
399
|
* @inheritDoc
|
|
390
400
|
*/
|
|
@@ -539,7 +549,7 @@ export class FromBTCLNSwap<T extends ChainType = ChainType>
|
|
|
539
549
|
lightningTxCheckIntervalSeconds?: number,
|
|
540
550
|
delayBetweenCommitAndClaimSeconds?: number
|
|
541
551
|
}
|
|
542
|
-
): Promise<
|
|
552
|
+
): Promise<boolean> {
|
|
543
553
|
if(this._state===FromBTCLNSwapState.FAILED) throw new Error("Swap failed!");
|
|
544
554
|
if(this._state===FromBTCLNSwapState.EXPIRED) throw new Error("Swap HTLC expired!");
|
|
545
555
|
if(this._state===FromBTCLNSwapState.QUOTE_EXPIRED || this._state===FromBTCLNSwapState.QUOTE_SOFT_EXPIRED) throw new Error("Swap quote expired!");
|
|
@@ -585,6 +595,8 @@ export class FromBTCLNSwap<T extends ChainType = ChainType>
|
|
|
585
595
|
if(this._state===FromBTCLNSwapState.CLAIM_CLAIMED) {
|
|
586
596
|
if(callbacks?.onSwapSettled!=null) callbacks.onSwapSettled(this.getOutputTxId()!);
|
|
587
597
|
}
|
|
598
|
+
|
|
599
|
+
return true;
|
|
588
600
|
}
|
|
589
601
|
|
|
590
602
|
/**
|
|
@@ -470,6 +470,16 @@ export class FromBTCLNAutoSwap<T extends ChainType = ChainType>
|
|
|
470
470
|
return this._state===FromBTCLNAutoSwapState.FAILED || this._state===FromBTCLNAutoSwapState.EXPIRED;
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
+
/**
|
|
474
|
+
* @inheritDoc
|
|
475
|
+
*/
|
|
476
|
+
isInProgress(): boolean {
|
|
477
|
+
return (this._state===FromBTCLNAutoSwapState.PR_CREATED && this.initiated) ||
|
|
478
|
+
(this._state===FromBTCLNAutoSwapState.QUOTE_SOFT_EXPIRED && this.initiated) ||
|
|
479
|
+
this._state===FromBTCLNAutoSwapState.PR_PAID ||
|
|
480
|
+
this._state===FromBTCLNAutoSwapState.CLAIM_COMMITED;
|
|
481
|
+
}
|
|
482
|
+
|
|
473
483
|
/**
|
|
474
484
|
* @inheritDoc
|
|
475
485
|
*/
|
|
@@ -307,6 +307,14 @@ export class FromBTCSwap<T extends ChainType = ChainType>
|
|
|
307
307
|
return this._state===FromBTCSwapState.FAILED || this._state===FromBTCSwapState.EXPIRED;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
/**
|
|
311
|
+
* @inheritDoc
|
|
312
|
+
*/
|
|
313
|
+
isInProgress(): boolean {
|
|
314
|
+
return this._state===FromBTCSwapState.CLAIM_COMMITED ||
|
|
315
|
+
this._state===FromBTCSwapState.BTC_TX_CONFIRMED;
|
|
316
|
+
}
|
|
317
|
+
|
|
310
318
|
/**
|
|
311
319
|
* @inheritDoc
|
|
312
320
|
*/
|
|
@@ -300,6 +300,21 @@ export abstract class IToBTCSwap<
|
|
|
300
300
|
return this._state===ToBTCSwapState.REFUNDED;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
/**
|
|
304
|
+
* @inheritDoc
|
|
305
|
+
*/
|
|
306
|
+
isInProgress(): boolean {
|
|
307
|
+
return this._state===ToBTCSwapState.COMMITED || this._state===ToBTCSwapState.SOFT_CLAIMED;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Returns the time (in UNIX milliseconds) at which the swap expires and the user is able to unilaterally
|
|
312
|
+
* refund it with the {@link refund} or {@link txsRefund} function.
|
|
313
|
+
*/
|
|
314
|
+
getExpiry(): number {
|
|
315
|
+
return Number(this._data.getExpiry())*1000;
|
|
316
|
+
}
|
|
317
|
+
|
|
303
318
|
/**
|
|
304
319
|
* @inheritDoc
|
|
305
320
|
* @internal
|
|
@@ -506,6 +506,15 @@ export class SpvFromBTCSwap<T extends ChainType>
|
|
|
506
506
|
return this._state===SpvFromBTCSwapState.FAILED || this._state===SpvFromBTCSwapState.DECLINED || this._state===SpvFromBTCSwapState.CLOSED;
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
/**
|
|
510
|
+
* @inheritDoc
|
|
511
|
+
*/
|
|
512
|
+
isInProgress(): boolean {
|
|
513
|
+
return this._state===SpvFromBTCSwapState.POSTED ||
|
|
514
|
+
this._state===SpvFromBTCSwapState.BROADCASTED ||
|
|
515
|
+
this._state===SpvFromBTCSwapState.BTC_TX_CONFIRMED;
|
|
516
|
+
}
|
|
517
|
+
|
|
509
518
|
/**
|
|
510
519
|
* @inheritDoc
|
|
511
520
|
*/
|
|
@@ -272,6 +272,13 @@ export class LnForGasSwap<T extends ChainType = ChainType> extends ISwap<T, LnFo
|
|
|
272
272
|
return this._state===LnForGasSwapState.FINISHED;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
/**
|
|
276
|
+
* @inheritDoc
|
|
277
|
+
*/
|
|
278
|
+
isInProgress(): boolean {
|
|
279
|
+
return (this._state===LnForGasSwapState.PR_CREATED && this.initiated) || this._state===LnForGasSwapState.PR_PAID;
|
|
280
|
+
}
|
|
281
|
+
|
|
275
282
|
/**
|
|
276
283
|
* @inheritDoc
|
|
277
284
|
* @internal
|
|
@@ -420,6 +427,13 @@ export class LnForGasSwap<T extends ChainType = ChainType> extends ISwap<T, LnFo
|
|
|
420
427
|
throw new Error("Invalid swap state to obtain execution txns, required PR_CREATED");
|
|
421
428
|
}
|
|
422
429
|
|
|
430
|
+
/**
|
|
431
|
+
* @remark Not supported
|
|
432
|
+
*/
|
|
433
|
+
async execute(): Promise<boolean> {
|
|
434
|
+
throw new Error("Not supported");
|
|
435
|
+
}
|
|
436
|
+
|
|
423
437
|
/**
|
|
424
438
|
* @inheritDoc
|
|
425
439
|
*/
|
|
@@ -572,4 +586,4 @@ export class LnForGasSwap<T extends ChainType = ChainType> extends ISwap<T, LnFo
|
|
|
572
586
|
return Promise.resolve(false);
|
|
573
587
|
}
|
|
574
588
|
|
|
575
|
-
}
|
|
589
|
+
}
|
|
@@ -314,6 +314,14 @@ export class OnchainForGasSwap<T extends ChainType = ChainType> extends ISwap<T,
|
|
|
314
314
|
return this._state===OnchainForGasSwapState.FINISHED;
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
/**
|
|
318
|
+
* @inheritDoc
|
|
319
|
+
*/
|
|
320
|
+
isInProgress(): boolean {
|
|
321
|
+
return (this._state===OnchainForGasSwapState.PR_CREATED && this.txId!=null) ||
|
|
322
|
+
(this._state===OnchainForGasSwapState.REFUNDABLE && this.refundAddress!=null);
|
|
323
|
+
}
|
|
324
|
+
|
|
317
325
|
/**
|
|
318
326
|
* @inheritDoc
|
|
319
327
|
* @internal
|
|
@@ -584,6 +592,13 @@ export class OnchainForGasSwap<T extends ChainType = ChainType> extends ISwap<T,
|
|
|
584
592
|
throw new Error("Invalid swap state to obtain execution txns, required PR_CREATED or CLAIM_COMMITED");
|
|
585
593
|
}
|
|
586
594
|
|
|
595
|
+
/**
|
|
596
|
+
* @remark Not supported
|
|
597
|
+
*/
|
|
598
|
+
async execute(): Promise<boolean> {
|
|
599
|
+
throw new Error("Not supported");
|
|
600
|
+
}
|
|
601
|
+
|
|
587
602
|
/**
|
|
588
603
|
* @inheritDoc
|
|
589
604
|
*
|