@arkade-os/boltz-swap 0.3.15 → 0.3.17

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.
@@ -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(
@@ -410,7 +429,7 @@ var init_boltz_swap_provider = __esm({
410
429
  invoiceAmount,
411
430
  claimPublicKey,
412
431
  preimageHash,
413
- ...description?.trim() ? { description: description.trim() } : {},
432
+ description: description?.trim() || "Send to Arkade address",
414
433
  ...this.referralId ? { referralId: this.referralId } : {}
415
434
  };
416
435
  const response = 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
- const {
2855
- transaction: boltzSignedRefundTx,
2856
- checkpoint: boltzSignedCheckpointTx
2857
- } = await refundFunc(swapId, unsignedRefundTx, unsignedCheckpointTx);
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("Preimage is required to claim VHTLC");
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("Incomplete reverse swap response");
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("Failed to create VHTLC script for reverse swap");
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("Boltz is trying to scam us");
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("No spendable virtual coins found");
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("VHTLC is already spent");
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("Missing address in submarine swap response");
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("Preimage hash is required to refund VHTLC");
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("Incomplete submarine swap response");
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,45 +3541,90 @@ var init_arkade_swaps = __esm({
3493
3541
  timeoutBlockHeights
3494
3542
  });
3495
3543
  if (!vhtlcScript.claimScript)
3496
- throw new Error("Failed to create VHTLC script for submarine swap");
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}`
3500
3550
  );
3501
3551
  const vhtlcPkScriptHex = import_base9.hex.encode(vhtlcScript.pkScript);
3502
- const { vtxos: spendableVtxos } = await this.indexerProvider.getVtxos({
3503
- scripts: [vhtlcPkScriptHex],
3504
- spendableOnly: true
3505
- });
3506
- if (spendableVtxos.length === 0) {
3552
+ const [spendableResult, recoverableResult] = await Promise.all([
3553
+ this.indexerProvider.getVtxos({
3554
+ scripts: [vhtlcPkScriptHex],
3555
+ spendableOnly: true
3556
+ }),
3557
+ this.indexerProvider.getVtxos({
3558
+ scripts: [vhtlcPkScriptHex],
3559
+ recoverableOnly: true
3560
+ })
3561
+ ]);
3562
+ const refundableVtxos = [
3563
+ ...new Map(
3564
+ [...spendableResult.vtxos, ...recoverableResult.vtxos].map(
3565
+ (vtxo) => [`${vtxo.txid}:${vtxo.vout}`, vtxo]
3566
+ )
3567
+ ).values()
3568
+ ];
3569
+ if (refundableVtxos.length === 0) {
3507
3570
  const { vtxos: allVtxos } = await this.indexerProvider.getVtxos({
3508
3571
  scripts: [vhtlcPkScriptHex]
3509
3572
  });
3573
+ if (allVtxos.length === 0) {
3574
+ throw new Error(
3575
+ `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
3576
+ );
3577
+ }
3578
+ if (allVtxos.every((vtxo) => vtxo.isSpent)) {
3579
+ throw new Error(
3580
+ `Swap ${pendingSwap.id}: VHTLC is already spent`
3581
+ );
3582
+ }
3510
3583
  throw new Error(
3511
- allVtxos.length > 0 ? "VHTLC is already spent" : `VHTLC not found for address ${pendingSwap.response.address}`
3584
+ `Swap ${pendingSwap.id}: VHTLC has no refundable VTXOs yet`
3512
3585
  );
3513
3586
  }
3514
3587
  const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
3588
+ const refundWithoutReceiverLeaf = vhtlcScript.refundWithoutReceiver();
3589
+ const refundLocktime = BigInt(timeoutBlockHeights.refund);
3590
+ const currentBlockHeight = await this.swapProvider.getChainHeight();
3591
+ const cltvSatisfied = BigInt(currentBlockHeight) >= refundLocktime;
3515
3592
  let boltzCallCount = 0;
3516
- for (const vtxo of spendableVtxos) {
3593
+ let skippedCount = 0;
3594
+ for (const vtxo of refundableVtxos) {
3517
3595
  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
3596
  const output = {
3524
3597
  amount: BigInt(vtxo.value),
3525
3598
  script: outputScript
3526
3599
  };
3527
- if (isRecoverableVtxo) {
3600
+ if (cltvSatisfied) {
3601
+ const input2 = {
3602
+ ...vtxo,
3603
+ tapLeafScript: refundWithoutReceiverLeaf,
3604
+ tapTree: vhtlcScript.encode()
3605
+ };
3528
3606
  await this.joinBatch(
3529
3607
  this.wallet.identity,
3530
- input,
3608
+ input2,
3531
3609
  output,
3532
- arkInfo
3610
+ arkInfo,
3611
+ isRecoverableVtxo
3612
+ );
3613
+ continue;
3614
+ }
3615
+ if (isRecoverableVtxo) {
3616
+ logger.error(
3617
+ `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
3618
  );
3534
- } else {
3619
+ skippedCount++;
3620
+ continue;
3621
+ }
3622
+ const input = {
3623
+ ...vtxo,
3624
+ tapLeafScript: vhtlcScript.refund(),
3625
+ tapTree: vhtlcScript.encode()
3626
+ };
3627
+ try {
3535
3628
  if (boltzCallCount > 0) {
3536
3629
  await new Promise((r) => setTimeout(r, 2e3));
3537
3630
  }
@@ -3550,14 +3643,42 @@ var init_arkade_swaps = __esm({
3550
3643
  )
3551
3644
  );
3552
3645
  boltzCallCount++;
3646
+ } catch (error) {
3647
+ if (!(error instanceof BoltzRefundError)) {
3648
+ throw error;
3649
+ }
3650
+ const tipNow = await this.swapProvider.getChainHeight();
3651
+ if (BigInt(tipNow) < refundLocktime) {
3652
+ logger.error(
3653
+ `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.`
3654
+ );
3655
+ skippedCount++;
3656
+ continue;
3657
+ }
3658
+ logger.warn(
3659
+ `Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver via joinBatch`
3660
+ );
3661
+ const fallbackInput = {
3662
+ ...vtxo,
3663
+ tapLeafScript: refundWithoutReceiverLeaf,
3664
+ tapTree: vhtlcScript.encode()
3665
+ };
3666
+ await this.joinBatch(
3667
+ this.wallet.identity,
3668
+ fallbackInput,
3669
+ output,
3670
+ arkInfo,
3671
+ false
3672
+ );
3553
3673
  }
3554
3674
  }
3675
+ const fullyRefunded = skippedCount === 0;
3555
3676
  await updateSubmarineSwapStatus(
3556
3677
  pendingSwap,
3557
3678
  pendingSwap.status,
3558
3679
  // Keep current status
3559
3680
  this.savePendingSubmarineSwap.bind(this),
3560
- { refundable: true, refunded: true }
3681
+ { refundable: true, refunded: fullyRefunded }
3561
3682
  );
3562
3683
  }
3563
3684
  /**
@@ -3760,14 +3881,22 @@ var init_arkade_swaps = __esm({
3760
3881
  */
3761
3882
  async claimBtc(pendingSwap) {
3762
3883
  if (!pendingSwap.toAddress)
3763
- throw new Error("Destination address is required");
3884
+ throw new Error(
3885
+ `Swap ${pendingSwap.id}: destination address is required`
3886
+ );
3764
3887
  if (!pendingSwap.response.claimDetails.swapTree)
3765
- throw new Error("Missing swap tree in claim details");
3888
+ throw new Error(
3889
+ `Swap ${pendingSwap.id}: missing swap tree in claim details`
3890
+ );
3766
3891
  if (!pendingSwap.response.claimDetails.serverPublicKey)
3767
- throw new Error("Missing server public key in claim details");
3892
+ throw new Error(
3893
+ `Swap ${pendingSwap.id}: missing server public key in claim details`
3894
+ );
3768
3895
  const swapStatus = await this.getSwapStatus(pendingSwap.id);
3769
3896
  if (!swapStatus.transaction?.hex)
3770
- throw new Error("BTC transaction hex is required");
3897
+ throw new Error(
3898
+ `Swap ${pendingSwap.id}: BTC transaction hex is required`
3899
+ );
3771
3900
  const lockupTx = import_btc_signer5.Transaction.fromRaw(
3772
3901
  import_base9.hex.decode(swapStatus.transaction.hex)
3773
3902
  );
@@ -3822,7 +3951,9 @@ var init_arkade_swaps = __esm({
3822
3951
  }
3823
3952
  );
3824
3953
  if (!signedTxData.pubNonce || !signedTxData.partialSignature)
3825
- throw new Error("Invalid signature data from server");
3954
+ throw new Error(
3955
+ `Swap ${pendingSwap.id}: invalid signature data from server`
3956
+ );
3826
3957
  const musigSession = musigMessage.aggregateNonces([
3827
3958
  [
3828
3959
  import_base9.hex.decode(
@@ -3847,9 +3978,13 @@ var init_arkade_swaps = __esm({
3847
3978
  */
3848
3979
  async refundArk(pendingSwap) {
3849
3980
  if (!pendingSwap.response.lockupDetails.serverPublicKey)
3850
- throw new Error("Missing server public key in lockup details");
3981
+ throw new Error(
3982
+ `Swap ${pendingSwap.id}: missing server public key in lockup details`
3983
+ );
3851
3984
  if (!pendingSwap.response.lockupDetails.timeouts)
3852
- throw new Error("Missing timeouts in lockup details");
3985
+ throw new Error(
3986
+ `Swap ${pendingSwap.id}: missing timeouts in lockup details`
3987
+ );
3853
3988
  const arkInfo = await this.arkProvider.getInfo();
3854
3989
  const address = await this.wallet.getAddress();
3855
3990
  const ourXOnlyPublicKey = normalizeToXOnlyKey(
@@ -3875,12 +4010,12 @@ var init_arkade_swaps = __esm({
3875
4010
  });
3876
4011
  if (vtxos.length === 0) {
3877
4012
  throw new Error(
3878
- `VHTLC not found for address ${pendingSwap.response.lockupDetails.lockupAddress}`
4013
+ `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.lockupDetails.lockupAddress}`
3879
4014
  );
3880
4015
  }
3881
4016
  const vtxo = vtxos[0];
3882
4017
  if (vtxo.isSpent) {
3883
- throw new Error("VHTLC is already spent");
4018
+ throw new Error(`Swap ${pendingSwap.id}: VHTLC is already spent`);
3884
4019
  }
3885
4020
  const { vhtlcAddress, vhtlcScript } = this.createVHTLCScript({
3886
4021
  network: arkInfo.network,
@@ -3891,7 +4026,9 @@ var init_arkade_swaps = __esm({
3891
4026
  timeoutBlockHeights: pendingSwap.response.lockupDetails.timeouts
3892
4027
  });
3893
4028
  if (!vhtlcScript.refundScript)
3894
- throw new Error("Failed to create VHTLC script for chain swap");
4029
+ throw new Error(
4030
+ `Swap ${pendingSwap.id}: failed to create VHTLC script for chain swap`
4031
+ );
3895
4032
  if (pendingSwap.response.lockupDetails.lockupAddress !== vhtlcAddress) {
3896
4033
  throw new SwapError({
3897
4034
  message: "Unable to claim: invalid VHTLC address"
@@ -4065,11 +4202,17 @@ var init_arkade_swaps = __esm({
4065
4202
  */
4066
4203
  async claimArk(pendingSwap) {
4067
4204
  if (!pendingSwap.toAddress)
4068
- throw new Error("Destination address is required");
4205
+ throw new Error(
4206
+ `Swap ${pendingSwap.id}: destination address is required`
4207
+ );
4069
4208
  if (!pendingSwap.response.claimDetails.serverPublicKey)
4070
- throw new Error("Missing server public key in claim details");
4209
+ throw new Error(
4210
+ `Swap ${pendingSwap.id}: missing server public key in claim details`
4211
+ );
4071
4212
  if (!pendingSwap.response.claimDetails.timeouts)
4072
- throw new Error("Missing timeouts in claim details");
4213
+ throw new Error(
4214
+ `Swap ${pendingSwap.id}: missing timeouts in claim details`
4215
+ );
4073
4216
  const arkInfo = await this.arkProvider.getInfo();
4074
4217
  const preimage = import_base9.hex.decode(pendingSwap.preimage);
4075
4218
  const address = await this.wallet.getAddress();
@@ -4094,7 +4237,9 @@ var init_arkade_swaps = __esm({
4094
4237
  timeoutBlockHeights: pendingSwap.response.claimDetails.timeouts
4095
4238
  });
4096
4239
  if (!vhtlcScript.claimScript)
4097
- throw new Error("Failed to create VHTLC script for chain swap");
4240
+ throw new Error(
4241
+ `Swap ${pendingSwap.id}: failed to create VHTLC script for chain swap`
4242
+ );
4098
4243
  if (pendingSwap.response.claimDetails.lockupAddress !== vhtlcAddress) {
4099
4244
  throw new SwapError({
4100
4245
  message: "Unable to claim: invalid VHTLC address"
@@ -4105,7 +4250,9 @@ var init_arkade_swaps = __esm({
4105
4250
  spendableOnly: true
4106
4251
  });
4107
4252
  if (spendableVtxos.vtxos.length === 0)
4108
- throw new Error("No spendable virtual coins found");
4253
+ throw new Error(
4254
+ `Swap ${pendingSwap.id}: no spendable virtual coins found`
4255
+ );
4109
4256
  const vtxo = spendableVtxos.vtxos[0];
4110
4257
  const input = {
4111
4258
  ...vtxo,
@@ -4145,16 +4292,20 @@ var init_arkade_swaps = __esm({
4145
4292
  */
4146
4293
  async signCooperativeClaimForServer(pendingSwap) {
4147
4294
  if (!pendingSwap.response.lockupDetails.swapTree)
4148
- throw new Error("Missing swap tree in lockup details");
4295
+ throw new Error(
4296
+ `Swap ${pendingSwap.id}: missing swap tree in lockup details`
4297
+ );
4149
4298
  if (!pendingSwap.response.lockupDetails.serverPublicKey)
4150
- throw new Error("Missing server public key in lockup details");
4299
+ throw new Error(
4300
+ `Swap ${pendingSwap.id}: missing server public key in lockup details`
4301
+ );
4151
4302
  const claimDetails = await this.swapProvider.getChainClaimDetails(
4152
4303
  pendingSwap.id
4153
4304
  );
4154
4305
  const serverPubKey = pendingSwap.response.lockupDetails.serverPublicKey;
4155
4306
  if (claimDetails.publicKey !== serverPubKey) {
4156
4307
  throw new Error(
4157
- `Server public key mismatch: claim response has ${claimDetails.publicKey}, expected ${serverPubKey}`
4308
+ `Swap ${pendingSwap.id}: server public key mismatch \u2014 claim response has ${claimDetails.publicKey}, expected ${serverPubKey}`
4158
4309
  );
4159
4310
  }
4160
4311
  const musig = tweakMusig(
@@ -4274,15 +4425,23 @@ var init_arkade_swaps = __esm({
4274
4425
  const { to, from, swap, arkInfo } = args;
4275
4426
  if (from === "ARK") {
4276
4427
  if (!swap.response.lockupDetails.serverPublicKey)
4277
- throw new Error("Missing serverPublicKey in lockup details");
4428
+ throw new Error(
4429
+ `Swap ${swap.id}: missing serverPublicKey in lockup details`
4430
+ );
4278
4431
  if (!swap.response.lockupDetails.timeouts)
4279
- throw new Error("Missing timeouts in lockup details");
4432
+ throw new Error(
4433
+ `Swap ${swap.id}: missing timeouts in lockup details`
4434
+ );
4280
4435
  }
4281
4436
  if (to === "ARK") {
4282
4437
  if (!swap.response.claimDetails.serverPublicKey)
4283
- throw new Error("Missing serverPublicKey in claim details");
4438
+ throw new Error(
4439
+ `Swap ${swap.id}: missing serverPublicKey in claim details`
4440
+ );
4284
4441
  if (!swap.response.claimDetails.timeouts)
4285
- throw new Error("Missing timeouts in claim details");
4442
+ throw new Error(
4443
+ `Swap ${swap.id}: missing timeouts in claim details`
4444
+ );
4286
4445
  }
4287
4446
  const lockupAddress = to === "ARK" ? swap.response.claimDetails.lockupAddress : swap.response.lockupDetails.lockupAddress;
4288
4447
  const receiverPubkey = to === "ARK" ? swap.request.claimPublicKey : swap.response.lockupDetails.serverPublicKey;
@@ -1,5 +1,5 @@
1
- import { I as IArkadeSwaps, A as ArkadeSwaps } from '../arkade-swaps-DkM_5yuv.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-C-2sBQWJ.cjs';
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';
@@ -1,5 +1,5 @@
1
- import { I as IArkadeSwaps, A as ArkadeSwaps } from '../arkade-swaps-DRMB_apa.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-C-2sBQWJ.js';
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';
@@ -4,10 +4,10 @@ import {
4
4
  registerExpoSwapBackgroundTask,
5
5
  swapsPollProcessor,
6
6
  unregisterExpoSwapBackgroundTask
7
- } from "../chunk-DPGNWPDB.js";
7
+ } from "../chunk-GSCLW33R.js";
8
8
  import {
9
9
  ArkadeSwaps
10
- } from "../chunk-Y6GPJDXY.js";
10
+ } from "../chunk-CS6UXZP6.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-646NBLSK.js");
59
+ const { registerExpoSwapBackgroundTask: registerExpoSwapBackgroundTask2 } = await import("../background-65LGXZHJ.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-646NBLSK.js");
132
+ const { unregisterExpoSwapBackgroundTask: unregisterExpoSwapBackgroundTask2 } = await import("../background-65LGXZHJ.js");
133
133
  await unregisterExpoSwapBackgroundTask2(this.taskName);
134
134
  } catch (err) {
135
135
  const message = err instanceof Error ? err.message : String(err);