@arkade-os/boltz-swap 0.3.15 → 0.3.16
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/{arkade-swaps-DkM_5yuv.d.cts → arkade-swaps-BlK0ASlg.d.cts} +1 -1
- package/dist/{arkade-swaps-DRMB_apa.d.ts → arkade-swaps-CM-UQ9-5.d.ts} +1 -1
- package/dist/{background-646NBLSK.js → background-DX6SZGGJ.js} +2 -2
- package/dist/{chunk-DPGNWPDB.js → chunk-CNH5DDKV.js} +1 -1
- package/dist/{chunk-Y6GPJDXY.js → chunk-RL4PDED5.js} +183 -47
- package/dist/expo/index.cjs +184 -48
- package/dist/expo/index.d.cts +2 -2
- package/dist/expo/index.d.ts +2 -2
- package/dist/expo/index.js +4 -4
- package/dist/index.cjs +184 -47
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +3 -1
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/{types-C-2sBQWJ.d.cts → types-CKxFfdEH.d.cts} +2 -0
- package/dist/{types-C-2sBQWJ.d.ts → types-CKxFfdEH.d.ts} +2 -0
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
33
|
// src/errors.ts
|
|
34
|
-
var SwapError, InvoiceExpiredError, InvoiceFailedToPayError, NetworkError, SchemaError, SwapExpiredError, TransactionFailedError, TransactionLockupFailedError, TransactionRefundedError;
|
|
34
|
+
var SwapError, InvoiceExpiredError, InvoiceFailedToPayError, NetworkError, SchemaError, SwapExpiredError, TransactionFailedError, TransactionLockupFailedError, TransactionRefundedError, BoltzRefundError;
|
|
35
35
|
var init_errors = __esm({
|
|
36
36
|
"src/errors.ts"() {
|
|
37
37
|
"use strict";
|
|
@@ -107,6 +107,13 @@ var init_errors = __esm({
|
|
|
107
107
|
this.name = "TransactionRefundedError";
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
+
BoltzRefundError = class extends Error {
|
|
111
|
+
constructor(message, cause) {
|
|
112
|
+
super(message);
|
|
113
|
+
this.cause = cause;
|
|
114
|
+
this.name = "BoltzRefundError";
|
|
115
|
+
}
|
|
116
|
+
};
|
|
110
117
|
}
|
|
111
118
|
});
|
|
112
119
|
|
|
@@ -330,6 +337,18 @@ var init_boltz_swap_provider = __esm({
|
|
|
330
337
|
max: response.ARK.BTC.limits.maximal
|
|
331
338
|
};
|
|
332
339
|
}
|
|
340
|
+
/** Returns the current BTC chain tip height from Boltz. */
|
|
341
|
+
async getChainHeight() {
|
|
342
|
+
const response = await this.request(
|
|
343
|
+
"/v2/chain/heights",
|
|
344
|
+
"GET"
|
|
345
|
+
);
|
|
346
|
+
if (typeof response?.BTC !== "number")
|
|
347
|
+
throw new SchemaError({
|
|
348
|
+
message: "error fetching chain heights"
|
|
349
|
+
});
|
|
350
|
+
return response.BTC;
|
|
351
|
+
}
|
|
333
352
|
/** Gets the lockup transaction ID for a reverse swap. */
|
|
334
353
|
async getReverseSwapTxId(id) {
|
|
335
354
|
const res = await this.request(
|
|
@@ -2659,6 +2678,7 @@ var init_vhtlc = __esm({
|
|
|
2659
2678
|
"use strict";
|
|
2660
2679
|
import_sdk7 = require("@arkade-os/sdk");
|
|
2661
2680
|
init_logger();
|
|
2681
|
+
init_errors();
|
|
2662
2682
|
import_base8 = require("@scure/base");
|
|
2663
2683
|
init_batch();
|
|
2664
2684
|
import_legacy = require("@noble/hashes/legacy.js");
|
|
@@ -2851,10 +2871,22 @@ var init_vhtlc = __esm({
|
|
|
2851
2871
|
`Expected one checkpoint transaction, got ${checkpointPtxs.length}`
|
|
2852
2872
|
);
|
|
2853
2873
|
const unsignedCheckpointTx = checkpointPtxs[0];
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2874
|
+
let boltzSignedRefundTx;
|
|
2875
|
+
let boltzSignedCheckpointTx;
|
|
2876
|
+
try {
|
|
2877
|
+
const result = await refundFunc(
|
|
2878
|
+
swapId,
|
|
2879
|
+
unsignedRefundTx,
|
|
2880
|
+
unsignedCheckpointTx
|
|
2881
|
+
);
|
|
2882
|
+
boltzSignedRefundTx = result.transaction;
|
|
2883
|
+
boltzSignedCheckpointTx = result.checkpoint;
|
|
2884
|
+
} catch (error) {
|
|
2885
|
+
throw new BoltzRefundError(
|
|
2886
|
+
`Boltz rejected refund for swap ${swapId}`,
|
|
2887
|
+
error
|
|
2888
|
+
);
|
|
2889
|
+
}
|
|
2858
2890
|
const boltzXOnlyPublicKeyHex = import_base8.hex.encode(boltzXOnlyPublicKey);
|
|
2859
2891
|
const refundLeafHash = (0, import_payment3.tapLeafHash)(
|
|
2860
2892
|
scriptFromTapLeafScript(input.tapLeafScript)
|
|
@@ -3218,10 +3250,14 @@ var init_arkade_swaps = __esm({
|
|
|
3218
3250
|
*/
|
|
3219
3251
|
async claimVHTLC(pendingSwap) {
|
|
3220
3252
|
if (!pendingSwap.preimage)
|
|
3221
|
-
throw new Error(
|
|
3253
|
+
throw new Error(
|
|
3254
|
+
`Swap ${pendingSwap.id}: preimage is required to claim VHTLC`
|
|
3255
|
+
);
|
|
3222
3256
|
const { refundPublicKey, lockupAddress, timeoutBlockHeights } = pendingSwap.response;
|
|
3223
3257
|
if (!refundPublicKey || !lockupAddress || !timeoutBlockHeights)
|
|
3224
|
-
throw new Error(
|
|
3258
|
+
throw new Error(
|
|
3259
|
+
`Swap ${pendingSwap.id}: incomplete reverse swap response`
|
|
3260
|
+
);
|
|
3225
3261
|
const preimage = import_base9.hex.decode(pendingSwap.preimage);
|
|
3226
3262
|
const arkInfo = await this.arkProvider.getInfo();
|
|
3227
3263
|
const address = await this.wallet.getAddress();
|
|
@@ -3249,17 +3285,23 @@ var init_arkade_swaps = __esm({
|
|
|
3249
3285
|
timeoutBlockHeights
|
|
3250
3286
|
});
|
|
3251
3287
|
if (!vhtlcScript.claimScript)
|
|
3252
|
-
throw new Error(
|
|
3288
|
+
throw new Error(
|
|
3289
|
+
`Swap ${pendingSwap.id}: failed to create VHTLC script for reverse swap`
|
|
3290
|
+
);
|
|
3253
3291
|
if (vhtlcAddress !== lockupAddress)
|
|
3254
|
-
throw new Error(
|
|
3292
|
+
throw new Error(
|
|
3293
|
+
`Swap ${pendingSwap.id}: VHTLC address mismatch. Expected ${lockupAddress}, got ${vhtlcAddress}`
|
|
3294
|
+
);
|
|
3255
3295
|
const { vtxos } = await this.indexerProvider.getVtxos({
|
|
3256
3296
|
scripts: [import_base9.hex.encode(vhtlcScript.pkScript)]
|
|
3257
3297
|
});
|
|
3258
3298
|
if (vtxos.length === 0)
|
|
3259
|
-
throw new Error(
|
|
3299
|
+
throw new Error(
|
|
3300
|
+
`Swap ${pendingSwap.id}: no spendable virtual coins found`
|
|
3301
|
+
);
|
|
3260
3302
|
const vtxo = vtxos[0];
|
|
3261
3303
|
if (vtxo.isSpent) {
|
|
3262
|
-
throw new Error(
|
|
3304
|
+
throw new Error(`Swap ${pendingSwap.id}: VHTLC is already spent`);
|
|
3263
3305
|
}
|
|
3264
3306
|
const input = {
|
|
3265
3307
|
...vtxo,
|
|
@@ -3392,7 +3434,9 @@ var init_arkade_swaps = __esm({
|
|
|
3392
3434
|
async sendLightningPayment(args) {
|
|
3393
3435
|
const pendingSwap = await this.createSubmarineSwap(args);
|
|
3394
3436
|
if (!pendingSwap.response.address)
|
|
3395
|
-
throw new Error(
|
|
3437
|
+
throw new Error(
|
|
3438
|
+
`Swap ${pendingSwap.id}: missing address in submarine swap response`
|
|
3439
|
+
);
|
|
3396
3440
|
await this.savePendingSubmarineSwap(pendingSwap);
|
|
3397
3441
|
const txid = await this.wallet.send({
|
|
3398
3442
|
address: pendingSwap.response.address,
|
|
@@ -3462,7 +3506,9 @@ var init_arkade_swaps = __esm({
|
|
|
3462
3506
|
async refundVHTLC(pendingSwap) {
|
|
3463
3507
|
const preimageHash = pendingSwap.request.invoice ? getInvoicePaymentHash(pendingSwap.request.invoice) : pendingSwap.preimageHash;
|
|
3464
3508
|
if (!preimageHash)
|
|
3465
|
-
throw new Error(
|
|
3509
|
+
throw new Error(
|
|
3510
|
+
`Swap ${pendingSwap.id}: preimage hash is required to refund VHTLC`
|
|
3511
|
+
);
|
|
3466
3512
|
const arkInfo = await this.arkProvider.getInfo();
|
|
3467
3513
|
const address = await this.wallet.getAddress();
|
|
3468
3514
|
if (!address) throw new Error("Failed to get ark address from wallet");
|
|
@@ -3478,7 +3524,9 @@ var init_arkade_swaps = __esm({
|
|
|
3478
3524
|
);
|
|
3479
3525
|
const { claimPublicKey, timeoutBlockHeights } = pendingSwap.response;
|
|
3480
3526
|
if (!claimPublicKey || !timeoutBlockHeights)
|
|
3481
|
-
throw new Error(
|
|
3527
|
+
throw new Error(
|
|
3528
|
+
`Swap ${pendingSwap.id}: incomplete submarine swap response`
|
|
3529
|
+
);
|
|
3482
3530
|
const boltzXOnlyPublicKey = normalizeToXOnlyKey(
|
|
3483
3531
|
import_base9.hex.decode(claimPublicKey),
|
|
3484
3532
|
"boltz",
|
|
@@ -3493,7 +3541,9 @@ var init_arkade_swaps = __esm({
|
|
|
3493
3541
|
timeoutBlockHeights
|
|
3494
3542
|
});
|
|
3495
3543
|
if (!vhtlcScript.claimScript)
|
|
3496
|
-
throw new Error(
|
|
3544
|
+
throw new Error(
|
|
3545
|
+
`Swap ${pendingSwap.id}: failed to create VHTLC script for submarine swap`
|
|
3546
|
+
);
|
|
3497
3547
|
if (vhtlcAddress !== pendingSwap.response.address)
|
|
3498
3548
|
throw new Error(
|
|
3499
3549
|
`VHTLC address mismatch for swap ${pendingSwap.id}: expected ${pendingSwap.response.address}, got ${vhtlcAddress}`
|
|
@@ -3508,30 +3558,50 @@ var init_arkade_swaps = __esm({
|
|
|
3508
3558
|
scripts: [vhtlcPkScriptHex]
|
|
3509
3559
|
});
|
|
3510
3560
|
throw new Error(
|
|
3511
|
-
allVtxos.length > 0 ?
|
|
3561
|
+
allVtxos.length > 0 ? `Swap ${pendingSwap.id}: VHTLC is already spent` : `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
|
|
3512
3562
|
);
|
|
3513
3563
|
}
|
|
3514
3564
|
const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
|
|
3565
|
+
const refundWithoutReceiverLeaf = vhtlcScript.refundWithoutReceiver();
|
|
3566
|
+
const refundLocktime = BigInt(timeoutBlockHeights.refund);
|
|
3567
|
+
const currentBlockHeight = await this.swapProvider.getChainHeight();
|
|
3568
|
+
const cltvSatisfied = BigInt(currentBlockHeight) >= refundLocktime;
|
|
3515
3569
|
let boltzCallCount = 0;
|
|
3570
|
+
let skippedCount = 0;
|
|
3516
3571
|
for (const vtxo of spendableVtxos) {
|
|
3517
3572
|
const isRecoverableVtxo = (0, import_sdk8.isRecoverable)(vtxo);
|
|
3518
|
-
const input = {
|
|
3519
|
-
...vtxo,
|
|
3520
|
-
tapLeafScript: isRecoverableVtxo ? vhtlcScript.refundWithoutReceiver() : vhtlcScript.refund(),
|
|
3521
|
-
tapTree: vhtlcScript.encode()
|
|
3522
|
-
};
|
|
3523
3573
|
const output = {
|
|
3524
3574
|
amount: BigInt(vtxo.value),
|
|
3525
3575
|
script: outputScript
|
|
3526
3576
|
};
|
|
3527
|
-
if (
|
|
3577
|
+
if (cltvSatisfied) {
|
|
3578
|
+
const input2 = {
|
|
3579
|
+
...vtxo,
|
|
3580
|
+
tapLeafScript: refundWithoutReceiverLeaf,
|
|
3581
|
+
tapTree: vhtlcScript.encode()
|
|
3582
|
+
};
|
|
3528
3583
|
await this.joinBatch(
|
|
3529
3584
|
this.wallet.identity,
|
|
3530
|
-
|
|
3585
|
+
input2,
|
|
3531
3586
|
output,
|
|
3532
|
-
arkInfo
|
|
3587
|
+
arkInfo,
|
|
3588
|
+
isRecoverableVtxo
|
|
3589
|
+
);
|
|
3590
|
+
continue;
|
|
3591
|
+
}
|
|
3592
|
+
if (isRecoverableVtxo) {
|
|
3593
|
+
logger.error(
|
|
3594
|
+
`Swap ${pendingSwap.id}: recoverable VTXO ${vtxo.txid}:${vtxo.vout} cannot be refunded yet \u2014 refundWithoutReceiver locktime has not passed (refundLocktime=${timeoutBlockHeights.refund}, currentBlockHeight=${currentBlockHeight}). Refund will be retried after locktime.`
|
|
3533
3595
|
);
|
|
3534
|
-
|
|
3596
|
+
skippedCount++;
|
|
3597
|
+
continue;
|
|
3598
|
+
}
|
|
3599
|
+
const input = {
|
|
3600
|
+
...vtxo,
|
|
3601
|
+
tapLeafScript: vhtlcScript.refund(),
|
|
3602
|
+
tapTree: vhtlcScript.encode()
|
|
3603
|
+
};
|
|
3604
|
+
try {
|
|
3535
3605
|
if (boltzCallCount > 0) {
|
|
3536
3606
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
3537
3607
|
}
|
|
@@ -3550,14 +3620,42 @@ var init_arkade_swaps = __esm({
|
|
|
3550
3620
|
)
|
|
3551
3621
|
);
|
|
3552
3622
|
boltzCallCount++;
|
|
3623
|
+
} catch (error) {
|
|
3624
|
+
if (!(error instanceof BoltzRefundError)) {
|
|
3625
|
+
throw error;
|
|
3626
|
+
}
|
|
3627
|
+
const tipNow = await this.swapProvider.getChainHeight();
|
|
3628
|
+
if (BigInt(tipNow) < refundLocktime) {
|
|
3629
|
+
logger.error(
|
|
3630
|
+
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint and refundWithoutReceiver locktime has not passed yet (currentBlockHeight=${tipNow}, locktime=${timeoutBlockHeights.refund}). Refund will be retried after locktime.`
|
|
3631
|
+
);
|
|
3632
|
+
skippedCount++;
|
|
3633
|
+
continue;
|
|
3634
|
+
}
|
|
3635
|
+
logger.warn(
|
|
3636
|
+
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver via joinBatch`
|
|
3637
|
+
);
|
|
3638
|
+
const fallbackInput = {
|
|
3639
|
+
...vtxo,
|
|
3640
|
+
tapLeafScript: refundWithoutReceiverLeaf,
|
|
3641
|
+
tapTree: vhtlcScript.encode()
|
|
3642
|
+
};
|
|
3643
|
+
await this.joinBatch(
|
|
3644
|
+
this.wallet.identity,
|
|
3645
|
+
fallbackInput,
|
|
3646
|
+
output,
|
|
3647
|
+
arkInfo,
|
|
3648
|
+
false
|
|
3649
|
+
);
|
|
3553
3650
|
}
|
|
3554
3651
|
}
|
|
3652
|
+
const fullyRefunded = skippedCount === 0;
|
|
3555
3653
|
await updateSubmarineSwapStatus(
|
|
3556
3654
|
pendingSwap,
|
|
3557
3655
|
pendingSwap.status,
|
|
3558
3656
|
// Keep current status
|
|
3559
3657
|
this.savePendingSubmarineSwap.bind(this),
|
|
3560
|
-
{ refundable: true, refunded:
|
|
3658
|
+
{ refundable: true, refunded: fullyRefunded }
|
|
3561
3659
|
);
|
|
3562
3660
|
}
|
|
3563
3661
|
/**
|
|
@@ -3760,14 +3858,22 @@ var init_arkade_swaps = __esm({
|
|
|
3760
3858
|
*/
|
|
3761
3859
|
async claimBtc(pendingSwap) {
|
|
3762
3860
|
if (!pendingSwap.toAddress)
|
|
3763
|
-
throw new Error(
|
|
3861
|
+
throw new Error(
|
|
3862
|
+
`Swap ${pendingSwap.id}: destination address is required`
|
|
3863
|
+
);
|
|
3764
3864
|
if (!pendingSwap.response.claimDetails.swapTree)
|
|
3765
|
-
throw new Error(
|
|
3865
|
+
throw new Error(
|
|
3866
|
+
`Swap ${pendingSwap.id}: missing swap tree in claim details`
|
|
3867
|
+
);
|
|
3766
3868
|
if (!pendingSwap.response.claimDetails.serverPublicKey)
|
|
3767
|
-
throw new Error(
|
|
3869
|
+
throw new Error(
|
|
3870
|
+
`Swap ${pendingSwap.id}: missing server public key in claim details`
|
|
3871
|
+
);
|
|
3768
3872
|
const swapStatus = await this.getSwapStatus(pendingSwap.id);
|
|
3769
3873
|
if (!swapStatus.transaction?.hex)
|
|
3770
|
-
throw new Error(
|
|
3874
|
+
throw new Error(
|
|
3875
|
+
`Swap ${pendingSwap.id}: BTC transaction hex is required`
|
|
3876
|
+
);
|
|
3771
3877
|
const lockupTx = import_btc_signer5.Transaction.fromRaw(
|
|
3772
3878
|
import_base9.hex.decode(swapStatus.transaction.hex)
|
|
3773
3879
|
);
|
|
@@ -3822,7 +3928,9 @@ var init_arkade_swaps = __esm({
|
|
|
3822
3928
|
}
|
|
3823
3929
|
);
|
|
3824
3930
|
if (!signedTxData.pubNonce || !signedTxData.partialSignature)
|
|
3825
|
-
throw new Error(
|
|
3931
|
+
throw new Error(
|
|
3932
|
+
`Swap ${pendingSwap.id}: invalid signature data from server`
|
|
3933
|
+
);
|
|
3826
3934
|
const musigSession = musigMessage.aggregateNonces([
|
|
3827
3935
|
[
|
|
3828
3936
|
import_base9.hex.decode(
|
|
@@ -3847,9 +3955,13 @@ var init_arkade_swaps = __esm({
|
|
|
3847
3955
|
*/
|
|
3848
3956
|
async refundArk(pendingSwap) {
|
|
3849
3957
|
if (!pendingSwap.response.lockupDetails.serverPublicKey)
|
|
3850
|
-
throw new Error(
|
|
3958
|
+
throw new Error(
|
|
3959
|
+
`Swap ${pendingSwap.id}: missing server public key in lockup details`
|
|
3960
|
+
);
|
|
3851
3961
|
if (!pendingSwap.response.lockupDetails.timeouts)
|
|
3852
|
-
throw new Error(
|
|
3962
|
+
throw new Error(
|
|
3963
|
+
`Swap ${pendingSwap.id}: missing timeouts in lockup details`
|
|
3964
|
+
);
|
|
3853
3965
|
const arkInfo = await this.arkProvider.getInfo();
|
|
3854
3966
|
const address = await this.wallet.getAddress();
|
|
3855
3967
|
const ourXOnlyPublicKey = normalizeToXOnlyKey(
|
|
@@ -3875,12 +3987,12 @@ var init_arkade_swaps = __esm({
|
|
|
3875
3987
|
});
|
|
3876
3988
|
if (vtxos.length === 0) {
|
|
3877
3989
|
throw new Error(
|
|
3878
|
-
`VHTLC not found for address ${pendingSwap.response.lockupDetails.lockupAddress}`
|
|
3990
|
+
`Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.lockupDetails.lockupAddress}`
|
|
3879
3991
|
);
|
|
3880
3992
|
}
|
|
3881
3993
|
const vtxo = vtxos[0];
|
|
3882
3994
|
if (vtxo.isSpent) {
|
|
3883
|
-
throw new Error(
|
|
3995
|
+
throw new Error(`Swap ${pendingSwap.id}: VHTLC is already spent`);
|
|
3884
3996
|
}
|
|
3885
3997
|
const { vhtlcAddress, vhtlcScript } = this.createVHTLCScript({
|
|
3886
3998
|
network: arkInfo.network,
|
|
@@ -3891,7 +4003,9 @@ var init_arkade_swaps = __esm({
|
|
|
3891
4003
|
timeoutBlockHeights: pendingSwap.response.lockupDetails.timeouts
|
|
3892
4004
|
});
|
|
3893
4005
|
if (!vhtlcScript.refundScript)
|
|
3894
|
-
throw new Error(
|
|
4006
|
+
throw new Error(
|
|
4007
|
+
`Swap ${pendingSwap.id}: failed to create VHTLC script for chain swap`
|
|
4008
|
+
);
|
|
3895
4009
|
if (pendingSwap.response.lockupDetails.lockupAddress !== vhtlcAddress) {
|
|
3896
4010
|
throw new SwapError({
|
|
3897
4011
|
message: "Unable to claim: invalid VHTLC address"
|
|
@@ -4065,11 +4179,17 @@ var init_arkade_swaps = __esm({
|
|
|
4065
4179
|
*/
|
|
4066
4180
|
async claimArk(pendingSwap) {
|
|
4067
4181
|
if (!pendingSwap.toAddress)
|
|
4068
|
-
throw new Error(
|
|
4182
|
+
throw new Error(
|
|
4183
|
+
`Swap ${pendingSwap.id}: destination address is required`
|
|
4184
|
+
);
|
|
4069
4185
|
if (!pendingSwap.response.claimDetails.serverPublicKey)
|
|
4070
|
-
throw new Error(
|
|
4186
|
+
throw new Error(
|
|
4187
|
+
`Swap ${pendingSwap.id}: missing server public key in claim details`
|
|
4188
|
+
);
|
|
4071
4189
|
if (!pendingSwap.response.claimDetails.timeouts)
|
|
4072
|
-
throw new Error(
|
|
4190
|
+
throw new Error(
|
|
4191
|
+
`Swap ${pendingSwap.id}: missing timeouts in claim details`
|
|
4192
|
+
);
|
|
4073
4193
|
const arkInfo = await this.arkProvider.getInfo();
|
|
4074
4194
|
const preimage = import_base9.hex.decode(pendingSwap.preimage);
|
|
4075
4195
|
const address = await this.wallet.getAddress();
|
|
@@ -4094,7 +4214,9 @@ var init_arkade_swaps = __esm({
|
|
|
4094
4214
|
timeoutBlockHeights: pendingSwap.response.claimDetails.timeouts
|
|
4095
4215
|
});
|
|
4096
4216
|
if (!vhtlcScript.claimScript)
|
|
4097
|
-
throw new Error(
|
|
4217
|
+
throw new Error(
|
|
4218
|
+
`Swap ${pendingSwap.id}: failed to create VHTLC script for chain swap`
|
|
4219
|
+
);
|
|
4098
4220
|
if (pendingSwap.response.claimDetails.lockupAddress !== vhtlcAddress) {
|
|
4099
4221
|
throw new SwapError({
|
|
4100
4222
|
message: "Unable to claim: invalid VHTLC address"
|
|
@@ -4105,7 +4227,9 @@ var init_arkade_swaps = __esm({
|
|
|
4105
4227
|
spendableOnly: true
|
|
4106
4228
|
});
|
|
4107
4229
|
if (spendableVtxos.vtxos.length === 0)
|
|
4108
|
-
throw new Error(
|
|
4230
|
+
throw new Error(
|
|
4231
|
+
`Swap ${pendingSwap.id}: no spendable virtual coins found`
|
|
4232
|
+
);
|
|
4109
4233
|
const vtxo = spendableVtxos.vtxos[0];
|
|
4110
4234
|
const input = {
|
|
4111
4235
|
...vtxo,
|
|
@@ -4145,16 +4269,20 @@ var init_arkade_swaps = __esm({
|
|
|
4145
4269
|
*/
|
|
4146
4270
|
async signCooperativeClaimForServer(pendingSwap) {
|
|
4147
4271
|
if (!pendingSwap.response.lockupDetails.swapTree)
|
|
4148
|
-
throw new Error(
|
|
4272
|
+
throw new Error(
|
|
4273
|
+
`Swap ${pendingSwap.id}: missing swap tree in lockup details`
|
|
4274
|
+
);
|
|
4149
4275
|
if (!pendingSwap.response.lockupDetails.serverPublicKey)
|
|
4150
|
-
throw new Error(
|
|
4276
|
+
throw new Error(
|
|
4277
|
+
`Swap ${pendingSwap.id}: missing server public key in lockup details`
|
|
4278
|
+
);
|
|
4151
4279
|
const claimDetails = await this.swapProvider.getChainClaimDetails(
|
|
4152
4280
|
pendingSwap.id
|
|
4153
4281
|
);
|
|
4154
4282
|
const serverPubKey = pendingSwap.response.lockupDetails.serverPublicKey;
|
|
4155
4283
|
if (claimDetails.publicKey !== serverPubKey) {
|
|
4156
4284
|
throw new Error(
|
|
4157
|
-
`
|
|
4285
|
+
`Swap ${pendingSwap.id}: server public key mismatch \u2014 claim response has ${claimDetails.publicKey}, expected ${serverPubKey}`
|
|
4158
4286
|
);
|
|
4159
4287
|
}
|
|
4160
4288
|
const musig = tweakMusig(
|
|
@@ -4274,15 +4402,23 @@ var init_arkade_swaps = __esm({
|
|
|
4274
4402
|
const { to, from, swap, arkInfo } = args;
|
|
4275
4403
|
if (from === "ARK") {
|
|
4276
4404
|
if (!swap.response.lockupDetails.serverPublicKey)
|
|
4277
|
-
throw new Error(
|
|
4405
|
+
throw new Error(
|
|
4406
|
+
`Swap ${swap.id}: missing serverPublicKey in lockup details`
|
|
4407
|
+
);
|
|
4278
4408
|
if (!swap.response.lockupDetails.timeouts)
|
|
4279
|
-
throw new Error(
|
|
4409
|
+
throw new Error(
|
|
4410
|
+
`Swap ${swap.id}: missing timeouts in lockup details`
|
|
4411
|
+
);
|
|
4280
4412
|
}
|
|
4281
4413
|
if (to === "ARK") {
|
|
4282
4414
|
if (!swap.response.claimDetails.serverPublicKey)
|
|
4283
|
-
throw new Error(
|
|
4415
|
+
throw new Error(
|
|
4416
|
+
`Swap ${swap.id}: missing serverPublicKey in claim details`
|
|
4417
|
+
);
|
|
4284
4418
|
if (!swap.response.claimDetails.timeouts)
|
|
4285
|
-
throw new Error(
|
|
4419
|
+
throw new Error(
|
|
4420
|
+
`Swap ${swap.id}: missing timeouts in claim details`
|
|
4421
|
+
);
|
|
4286
4422
|
}
|
|
4287
4423
|
const lockupAddress = to === "ARK" ? swap.response.claimDetails.lockupAddress : swap.response.lockupDetails.lockupAddress;
|
|
4288
4424
|
const receiverPubkey = to === "ARK" ? swap.request.claimPublicKey : swap.response.lockupDetails.serverPublicKey;
|
package/dist/expo/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IArkadeSwaps, A as ArkadeSwaps } from '../arkade-swaps-
|
|
2
|
-
import { A as ArkadeSwapsConfig, j as SwapRepository, m as BoltzSwapProvider, N as Network, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, F as FeesResponse, a as BoltzChainSwap, h as ArkToBtcResponse, i as BtcToArkResponse, d as Chain, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-
|
|
1
|
+
import { I as IArkadeSwaps, A as ArkadeSwaps } from '../arkade-swaps-BlK0ASlg.cjs';
|
|
2
|
+
import { A as ArkadeSwapsConfig, j as SwapRepository, m as BoltzSwapProvider, N as Network, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, F as FeesResponse, a as BoltzChainSwap, h as ArkToBtcResponse, i as BtcToArkResponse, d as Chain, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-CKxFfdEH.cjs';
|
|
3
3
|
import { Identity, ArkProvider, IndexerProvider, IWallet, ArkInfo, ArkTxInput, VHTLC } from '@arkade-os/sdk';
|
|
4
4
|
import { AsyncStorageTaskQueue, TaskProcessor } from '@arkade-os/sdk/worker/expo';
|
|
5
5
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IArkadeSwaps, A as ArkadeSwaps } from '../arkade-swaps-
|
|
2
|
-
import { A as ArkadeSwapsConfig, j as SwapRepository, m as BoltzSwapProvider, N as Network, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, F as FeesResponse, a as BoltzChainSwap, h as ArkToBtcResponse, i as BtcToArkResponse, d as Chain, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-
|
|
1
|
+
import { I as IArkadeSwaps, A as ArkadeSwaps } from '../arkade-swaps-CM-UQ9-5.js';
|
|
2
|
+
import { A as ArkadeSwapsConfig, j as SwapRepository, m as BoltzSwapProvider, N as Network, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, b as BoltzReverseSwap, F as FeesResponse, a as BoltzChainSwap, h as ArkToBtcResponse, i as BtcToArkResponse, d as Chain, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from '../types-CKxFfdEH.js';
|
|
3
3
|
import { Identity, ArkProvider, IndexerProvider, IWallet, ArkInfo, ArkTxInput, VHTLC } from '@arkade-os/sdk';
|
|
4
4
|
import { AsyncStorageTaskQueue, TaskProcessor } from '@arkade-os/sdk/worker/expo';
|
|
5
5
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
package/dist/expo/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
registerExpoSwapBackgroundTask,
|
|
5
5
|
swapsPollProcessor,
|
|
6
6
|
unregisterExpoSwapBackgroundTask
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-CNH5DDKV.js";
|
|
8
8
|
import {
|
|
9
9
|
ArkadeSwaps
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-RL4PDED5.js";
|
|
11
11
|
import "../chunk-3RG5ZIWI.js";
|
|
12
12
|
|
|
13
13
|
// src/expo/arkade-lightning.ts
|
|
@@ -56,7 +56,7 @@ var ExpoArkadeSwaps = class _ExpoArkadeSwaps {
|
|
|
56
56
|
await instance.seedSwapPollTask();
|
|
57
57
|
if (config.background.minimumBackgroundInterval) {
|
|
58
58
|
try {
|
|
59
|
-
const { registerExpoSwapBackgroundTask: registerExpoSwapBackgroundTask2 } = await import("../background-
|
|
59
|
+
const { registerExpoSwapBackgroundTask: registerExpoSwapBackgroundTask2 } = await import("../background-DX6SZGGJ.js");
|
|
60
60
|
await registerExpoSwapBackgroundTask2(
|
|
61
61
|
config.background.taskName,
|
|
62
62
|
{
|
|
@@ -129,7 +129,7 @@ var ExpoArkadeSwaps = class _ExpoArkadeSwaps {
|
|
|
129
129
|
}
|
|
130
130
|
await this.inner.dispose();
|
|
131
131
|
try {
|
|
132
|
-
const { unregisterExpoSwapBackgroundTask: unregisterExpoSwapBackgroundTask2 } = await import("../background-
|
|
132
|
+
const { unregisterExpoSwapBackgroundTask: unregisterExpoSwapBackgroundTask2 } = await import("../background-DX6SZGGJ.js");
|
|
133
133
|
await unregisterExpoSwapBackgroundTask2(this.taskName);
|
|
134
134
|
} catch (err) {
|
|
135
135
|
const message = err instanceof Error ? err.message : String(err);
|