@arkade-os/boltz-swap 0.3.14 → 0.3.15

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.
@@ -1,5 +1,5 @@
1
1
  import { IWallet, ArkProvider, IndexerProvider, ArkInfo, Identity, ArkTxInput, VHTLC } from '@arkade-os/sdk';
2
- import { m as BoltzSwapProvider, V as SwapManager, j as SwapRepository, X as ArkadeSwapsCreateConfig, A as ArkadeSwapsConfig, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, b as BoltzReverseSwap, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, h as ArkToBtcResponse, a as BoltzChainSwap, i as BtcToArkResponse, d as Chain, F as FeesResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from './types-x542EUL6.js';
2
+ import { m as BoltzSwapProvider, V as SwapManager, j as SwapRepository, X as ArkadeSwapsCreateConfig, A as ArkadeSwapsConfig, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, b as BoltzReverseSwap, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, h as ArkToBtcResponse, a as BoltzChainSwap, i as BtcToArkResponse, d as Chain, F as FeesResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from './types-C-2sBQWJ.js';
3
3
  import { TransactionOutput } from '@scure/btc-signer/psbt.js';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { IWallet, ArkProvider, IndexerProvider, ArkInfo, Identity, ArkTxInput, VHTLC } from '@arkade-os/sdk';
2
- import { m as BoltzSwapProvider, V as SwapManager, j as SwapRepository, X as ArkadeSwapsCreateConfig, A as ArkadeSwapsConfig, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, b as BoltzReverseSwap, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, h as ArkToBtcResponse, a as BoltzChainSwap, i as BtcToArkResponse, d as Chain, F as FeesResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from './types-x542EUL6.cjs';
2
+ import { m as BoltzSwapProvider, V as SwapManager, j as SwapRepository, X as ArkadeSwapsCreateConfig, A as ArkadeSwapsConfig, k as SwapManagerClient, C as CreateLightningInvoiceRequest, e as CreateLightningInvoiceResponse, b as BoltzReverseSwap, S as SendLightningPaymentRequest, f as SendLightningPaymentResponse, c as BoltzSubmarineSwap, h as ArkToBtcResponse, a as BoltzChainSwap, i as BtcToArkResponse, d as Chain, F as FeesResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, B as BoltzSwap } from './types-C-2sBQWJ.cjs';
3
3
  import { TransactionOutput } from '@scure/btc-signer/psbt.js';
4
4
 
5
5
  /**
@@ -2,8 +2,8 @@ import {
2
2
  defineExpoSwapBackgroundTask,
3
3
  registerExpoSwapBackgroundTask,
4
4
  unregisterExpoSwapBackgroundTask
5
- } from "./chunk-2TWYSAFO.js";
6
- import "./chunk-AIVWXKNG.js";
5
+ } from "./chunk-DPGNWPDB.js";
6
+ import "./chunk-Y6GPJDXY.js";
7
7
  import "./chunk-3RG5ZIWI.js";
8
8
  export {
9
9
  defineExpoSwapBackgroundTask,
@@ -8,7 +8,7 @@ import {
8
8
  isSubmarineFinalStatus,
9
9
  isSubmarineSwapRefundable,
10
10
  logger
11
- } from "./chunk-AIVWXKNG.js";
11
+ } from "./chunk-Y6GPJDXY.js";
12
12
  import {
13
13
  __require
14
14
  } from "./chunk-3RG5ZIWI.js";
@@ -221,7 +221,7 @@ var isGetReverseSwapTxIdResponse = (data) => {
221
221
  return data && typeof data === "object" && typeof data.id === "string" && typeof data.timeoutBlockHeight === "number";
222
222
  };
223
223
  var isGetSwapStatusResponse = (data) => {
224
- return data && typeof data === "object" && typeof data.status === "string" && (data.zeroConfRejected === void 0 || typeof data.zeroConfRejected === "boolean") && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && (data.transaction.eta === void 0 || typeof data.transaction.eta === "number") && (data.transaction.hex === void 0 || typeof data.transaction.hex === "string") && (data.transaction.preimage === void 0 || typeof data.transaction.preimage === "string"));
224
+ return data && typeof data === "object" && typeof data.status === "string" && (data.zeroConfRejected === void 0 || typeof data.zeroConfRejected === "boolean") && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && (data.transaction.confirmed === void 0 || typeof data.transaction.confirmed === "boolean") && (data.transaction.eta === void 0 || typeof data.transaction.eta === "number") && (data.transaction.hex === void 0 || typeof data.transaction.hex === "string") && (data.transaction.preimage === void 0 || typeof data.transaction.preimage === "string"));
225
225
  };
226
226
  var isGetSubmarinePairsResponse = (data) => {
227
227
  return data && typeof data === "object" && data.ARK && typeof data.ARK === "object" && data.ARK.BTC && typeof data.ARK.BTC === "object" && typeof data.ARK.BTC.hash === "string" && typeof data.ARK.BTC.rate === "number" && data.ARK.BTC.limits && typeof data.ARK.BTC.limits === "object" && typeof data.ARK.BTC.limits.maximal === "number" && typeof data.ARK.BTC.limits.minimal === "number" && typeof data.ARK.BTC.limits.maximalZeroConf === "number" && data.ARK.BTC.fees && typeof data.ARK.BTC.fees === "object" && typeof data.ARK.BTC.fees.percentage === "number" && typeof data.ARK.BTC.fees.minerFees === "number";
@@ -230,13 +230,13 @@ var isGetReversePairsResponse = (data) => {
230
230
  return data && typeof data === "object" && data.BTC && typeof data.BTC === "object" && data.BTC.ARK && typeof data.BTC.ARK === "object" && data.BTC.ARK.hash && typeof data.BTC.ARK.hash === "string" && typeof data.BTC.ARK.rate === "number" && data.BTC.ARK.limits && typeof data.BTC.ARK.limits === "object" && typeof data.BTC.ARK.limits.maximal === "number" && typeof data.BTC.ARK.limits.minimal === "number" && data.BTC.ARK.fees && typeof data.BTC.ARK.fees === "object" && typeof data.BTC.ARK.fees.percentage === "number" && typeof data.BTC.ARK.fees.minerFees === "object" && typeof data.BTC.ARK.fees.minerFees.claim === "number" && typeof data.BTC.ARK.fees.minerFees.lockup === "number";
231
231
  };
232
232
  var isCreateSubmarineSwapResponse = (data) => {
233
- return data && typeof data === "object" && typeof data.id === "string" && typeof data.address === "string" && typeof data.expectedAmount === "number" && typeof data.claimPublicKey === "string" && typeof data.acceptZeroConf === "boolean" && isTimeoutBlockHeights(data.timeoutBlockHeights);
233
+ return data && typeof data === "object" && typeof data.id === "string" && typeof data.expectedAmount === "number" && (data.address === void 0 || typeof data.address === "string") && (data.claimPublicKey === void 0 || typeof data.claimPublicKey === "string") && (data.acceptZeroConf === void 0 || typeof data.acceptZeroConf === "boolean") && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights));
234
234
  };
235
235
  var isGetSwapPreimageResponse = (data) => {
236
236
  return data && typeof data === "object" && typeof data.preimage === "string";
237
237
  };
238
238
  var isCreateReverseSwapResponse = (data) => {
239
- return data && typeof data === "object" && typeof data.id === "string" && typeof data.invoice === "string" && typeof data.onchainAmount === "number" && typeof data.lockupAddress === "string" && typeof data.refundPublicKey === "string" && isTimeoutBlockHeights(data.timeoutBlockHeights);
239
+ return data && typeof data === "object" && typeof data.id === "string" && typeof data.invoice === "string" && (data.onchainAmount === void 0 || typeof data.onchainAmount === "number") && (data.lockupAddress === void 0 || typeof data.lockupAddress === "string") && (data.refundPublicKey === void 0 || typeof data.refundPublicKey === "string") && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights));
240
240
  };
241
241
  var isRefundSubmarineSwapResponse = (data) => {
242
242
  return data && typeof data === "object" && typeof data.transaction === "string" && typeof data.checkpoint === "string";
@@ -275,19 +275,19 @@ var isLeaf = (data) => {
275
275
  return data && typeof data === "object" && typeof data.version === "number" && typeof data.output === "string";
276
276
  };
277
277
  var isTree = (data) => {
278
- return data && typeof data === "object" && isLeaf(data.claimLeaf) && isLeaf(data.refundLeaf) && isLeaf(data.refundWithoutBoltzLeaf) && isLeaf(data.unilateralClaimLeaf) && isLeaf(data.unilateralRefundLeaf) && isLeaf(data.unilateralRefundWithoutBoltzLeaf);
278
+ return data && typeof data === "object" && isLeaf(data.claimLeaf) && isLeaf(data.refundLeaf) && (data.covenantClaimLeaf === void 0 || isLeaf(data.covenantClaimLeaf)) && (data.refundWithoutBoltzLeaf === void 0 || isLeaf(data.refundWithoutBoltzLeaf)) && (data.unilateralClaimLeaf === void 0 || isLeaf(data.unilateralClaimLeaf)) && (data.unilateralRefundLeaf === void 0 || isLeaf(data.unilateralRefundLeaf)) && (data.unilateralRefundWithoutBoltzLeaf === void 0 || isLeaf(data.unilateralRefundWithoutBoltzLeaf));
279
279
  };
280
280
  var isDetails = (data) => {
281
- return data && typeof data === "object" && isTree(data.tree) && (data.amount === void 0 || typeof data.amount === "number") && typeof data.keyIndex === "number" && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && typeof data.transaction.vout === "number") && typeof data.lockupAddress === "string" && typeof data.serverPublicKey === "string" && typeof data.timeoutBlockHeight === "number" && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights)) && (data.preimageHash === void 0 || typeof data.preimageHash === "string");
281
+ return data && typeof data === "object" && isTree(data.tree) && (data.amount === void 0 || typeof data.amount === "number") && typeof data.keyIndex === "number" && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && typeof data.transaction.vout === "number") && typeof data.lockupAddress === "string" && typeof data.serverPublicKey === "string" && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights)) && (data.preimageHash === void 0 || typeof data.preimageHash === "string");
282
282
  };
283
283
  var isRestoredChainSwap = (data) => {
284
- return data && typeof data === "object" && typeof data.id === "string" && data.type === "chain" && typeof data.status === "string" && typeof data.createdAt === "number" && (data.from === "ARK" || data.from === "BTC") && (data.to === "ARK" || data.to === "BTC") && typeof data.preimageHash === "string" && data.refundDetails && typeof data.refundDetails === "object" && isTree(data.refundDetails.tree) && typeof data.refundDetails.amount === "number" && typeof data.refundDetails.keyIndex === "number" && (data.refundDetails.transaction === void 0 || data.refundDetails.transaction && typeof data.refundDetails.transaction === "object" && typeof data.refundDetails.transaction.id === "string" && typeof data.refundDetails.transaction.vout === "number") && typeof data.refundDetails.lockupAddress === "string" && typeof data.refundDetails.serverPublicKey === "string" && typeof data.refundDetails.timeoutBlockHeight === "number";
284
+ return data && typeof data === "object" && typeof data.id === "string" && data.type === "chain" && typeof data.status === "string" && typeof data.createdAt === "number" && (data.from === "ARK" || data.from === "BTC") && (data.to === "ARK" || data.to === "BTC") && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && (data.invoice === void 0 || typeof data.invoice === "string") && (data.refundDetails === void 0 || isDetails(data.refundDetails)) && (data.claimDetails === void 0 || isDetails(data.claimDetails));
285
285
  };
286
286
  var isRestoredSubmarineSwap = (data) => {
287
- return data && typeof data === "object" && data.to === "BTC" && typeof data.id === "string" && data.from === "ARK" && data.type === "submarine" && typeof data.createdAt === "number" && typeof data.preimageHash === "string" && typeof data.status === "string" && isDetails(data.refundDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
287
+ return data && typeof data === "object" && data.to === "BTC" && typeof data.id === "string" && data.from === "ARK" && data.type === "submarine" && typeof data.createdAt === "number" && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && typeof data.status === "string" && isDetails(data.refundDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
288
288
  };
289
289
  var isRestoredReverseSwap = (data) => {
290
- return data && typeof data === "object" && data.to === "ARK" && typeof data.id === "string" && data.from === "BTC" && data.type === "reverse" && typeof data.createdAt === "number" && typeof data.preimageHash === "string" && typeof data.status === "string" && isDetails(data.claimDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
290
+ return data && typeof data === "object" && data.to === "ARK" && typeof data.id === "string" && data.from === "BTC" && data.type === "reverse" && typeof data.createdAt === "number" && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && typeof data.status === "string" && isDetails(data.claimDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
291
291
  };
292
292
  var isCreateSwapsRestoreResponse = (data) => {
293
293
  return Array.isArray(data) && data.every(
@@ -3214,6 +3214,9 @@ var ArkadeSwaps = class _ArkadeSwaps {
3214
3214
  async claimVHTLC(pendingSwap) {
3215
3215
  if (!pendingSwap.preimage)
3216
3216
  throw new Error("Preimage is required to claim VHTLC");
3217
+ const { refundPublicKey, lockupAddress, timeoutBlockHeights } = pendingSwap.response;
3218
+ if (!refundPublicKey || !lockupAddress || !timeoutBlockHeights)
3219
+ throw new Error("Incomplete reverse swap response");
3217
3220
  const preimage = hex8.decode(pendingSwap.preimage);
3218
3221
  const arkInfo = await this.arkProvider.getInfo();
3219
3222
  const address = await this.wallet.getAddress();
@@ -3223,7 +3226,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
3223
3226
  pendingSwap.id
3224
3227
  );
3225
3228
  const senderXOnly = normalizeToXOnlyKey(
3226
- hex8.decode(pendingSwap.response.refundPublicKey),
3229
+ hex8.decode(refundPublicKey),
3227
3230
  "boltz",
3228
3231
  pendingSwap.id
3229
3232
  );
@@ -3238,11 +3241,11 @@ var ArkadeSwaps = class _ArkadeSwaps {
3238
3241
  receiverPubkey: hex8.encode(receiverXOnly),
3239
3242
  senderPubkey: hex8.encode(senderXOnly),
3240
3243
  serverPubkey: hex8.encode(serverXOnly),
3241
- timeoutBlockHeights: pendingSwap.response.timeoutBlockHeights
3244
+ timeoutBlockHeights
3242
3245
  });
3243
3246
  if (!vhtlcScript.claimScript)
3244
3247
  throw new Error("Failed to create VHTLC script for reverse swap");
3245
- if (vhtlcAddress !== pendingSwap.response.lockupAddress)
3248
+ if (vhtlcAddress !== lockupAddress)
3246
3249
  throw new Error("Boltz is trying to scam us");
3247
3250
  const { vtxos } = await this.indexerProvider.getVtxos({
3248
3251
  scripts: [hex8.encode(vhtlcScript.pkScript)]
@@ -3383,6 +3386,8 @@ var ArkadeSwaps = class _ArkadeSwaps {
3383
3386
  */
3384
3387
  async sendLightningPayment(args) {
3385
3388
  const pendingSwap = await this.createSubmarineSwap(args);
3389
+ if (!pendingSwap.response.address)
3390
+ throw new Error("Missing address in submarine swap response");
3386
3391
  await this.savePendingSubmarineSwap(pendingSwap);
3387
3392
  const txid = await this.wallet.send({
3388
3393
  address: pendingSwap.response.address,
@@ -3466,8 +3471,11 @@ var ArkadeSwaps = class _ArkadeSwaps {
3466
3471
  "server",
3467
3472
  pendingSwap.id
3468
3473
  );
3474
+ const { claimPublicKey, timeoutBlockHeights } = pendingSwap.response;
3475
+ if (!claimPublicKey || !timeoutBlockHeights)
3476
+ throw new Error("Incomplete submarine swap response");
3469
3477
  const boltzXOnlyPublicKey = normalizeToXOnlyKey(
3470
- hex8.decode(pendingSwap.response.claimPublicKey),
3478
+ hex8.decode(claimPublicKey),
3471
3479
  "boltz",
3472
3480
  pendingSwap.id
3473
3481
  );
@@ -3477,7 +3485,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
3477
3485
  receiverPubkey: hex8.encode(boltzXOnlyPublicKey),
3478
3486
  senderPubkey: hex8.encode(ourXOnlyPublicKey),
3479
3487
  serverPubkey: hex8.encode(serverXOnlyPublicKey),
3480
- timeoutBlockHeights: pendingSwap.response.timeoutBlockHeights
3488
+ timeoutBlockHeights
3481
3489
  });
3482
3490
  if (!vhtlcScript.claimScript)
3483
3491
  throw new Error("Failed to create VHTLC script for submarine swap");
@@ -4479,7 +4487,8 @@ var ArkadeSwaps = class _ArkadeSwaps {
4479
4487
  lockupAddress,
4480
4488
  preimageHash,
4481
4489
  serverPublicKey,
4482
- tree
4490
+ tree,
4491
+ timeoutBlockHeights
4483
4492
  } = swap.claimDetails;
4484
4493
  reverseSwaps.push({
4485
4494
  id,
@@ -4495,18 +4504,18 @@ var ArkadeSwaps = class _ArkadeSwaps {
4495
4504
  onchainAmount: amount,
4496
4505
  lockupAddress,
4497
4506
  refundPublicKey: serverPublicKey,
4498
- timeoutBlockHeights: {
4507
+ timeoutBlockHeights: timeoutBlockHeights ?? {
4499
4508
  refund: extractTimeLockFromLeafOutput(
4500
- tree.refundWithoutBoltzLeaf.output
4509
+ tree.refundWithoutBoltzLeaf?.output ?? ""
4501
4510
  ),
4502
4511
  unilateralClaim: extractTimeLockFromLeafOutput(
4503
- tree.unilateralClaimLeaf.output
4512
+ tree.unilateralClaimLeaf?.output ?? ""
4504
4513
  ),
4505
4514
  unilateralRefund: extractTimeLockFromLeafOutput(
4506
- tree.unilateralRefundLeaf.output
4515
+ tree.unilateralRefundLeaf?.output ?? ""
4507
4516
  ),
4508
4517
  unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
4509
- tree.unilateralRefundWithoutBoltzLeaf.output
4518
+ tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
4510
4519
  )
4511
4520
  }
4512
4521
  },
@@ -4515,7 +4524,13 @@ var ArkadeSwaps = class _ArkadeSwaps {
4515
4524
  preimage: ""
4516
4525
  });
4517
4526
  } else if (isRestoredSubmarineSwap(swap)) {
4518
- const { amount, lockupAddress, serverPublicKey, tree } = swap.refundDetails;
4527
+ const {
4528
+ amount,
4529
+ lockupAddress,
4530
+ serverPublicKey,
4531
+ tree,
4532
+ timeoutBlockHeights
4533
+ } = swap.refundDetails;
4519
4534
  let preimage = "";
4520
4535
  if (!isSubmarineFinalStatus(status)) {
4521
4536
  try {
@@ -4546,29 +4561,31 @@ var ArkadeSwaps = class _ArkadeSwaps {
4546
4561
  address: lockupAddress,
4547
4562
  expectedAmount: amount,
4548
4563
  claimPublicKey: serverPublicKey,
4549
- timeoutBlockHeights: {
4564
+ timeoutBlockHeights: timeoutBlockHeights ?? {
4550
4565
  refund: extractTimeLockFromLeafOutput(
4551
- tree.refundWithoutBoltzLeaf.output
4566
+ tree.refundWithoutBoltzLeaf?.output ?? ""
4552
4567
  ),
4553
4568
  unilateralClaim: extractTimeLockFromLeafOutput(
4554
- tree.unilateralClaimLeaf.output
4569
+ tree.unilateralClaimLeaf?.output ?? ""
4555
4570
  ),
4556
4571
  unilateralRefund: extractTimeLockFromLeafOutput(
4557
- tree.unilateralRefundLeaf.output
4572
+ tree.unilateralRefundLeaf?.output ?? ""
4558
4573
  ),
4559
4574
  unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
4560
- tree.unilateralRefundWithoutBoltzLeaf.output
4575
+ tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
4561
4576
  )
4562
4577
  }
4563
4578
  }
4564
4579
  });
4565
4580
  } else if (isRestoredChainSwap(swap)) {
4581
+ const refundDetails = swap.refundDetails;
4582
+ if (!refundDetails) continue;
4566
4583
  const {
4567
4584
  amount,
4568
4585
  lockupAddress,
4569
4586
  serverPublicKey,
4570
4587
  timeoutBlockHeight
4571
- } = swap.refundDetails;
4588
+ } = refundDetails;
4572
4589
  chainSwaps.push({
4573
4590
  id,
4574
4591
  type: "chain",
@@ -185,7 +185,7 @@ var init_boltz_swap_provider = __esm({
185
185
  return data && typeof data === "object" && typeof data.id === "string" && typeof data.timeoutBlockHeight === "number";
186
186
  };
187
187
  isGetSwapStatusResponse = (data) => {
188
- return data && typeof data === "object" && typeof data.status === "string" && (data.zeroConfRejected === void 0 || typeof data.zeroConfRejected === "boolean") && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && (data.transaction.eta === void 0 || typeof data.transaction.eta === "number") && (data.transaction.hex === void 0 || typeof data.transaction.hex === "string") && (data.transaction.preimage === void 0 || typeof data.transaction.preimage === "string"));
188
+ return data && typeof data === "object" && typeof data.status === "string" && (data.zeroConfRejected === void 0 || typeof data.zeroConfRejected === "boolean") && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && (data.transaction.confirmed === void 0 || typeof data.transaction.confirmed === "boolean") && (data.transaction.eta === void 0 || typeof data.transaction.eta === "number") && (data.transaction.hex === void 0 || typeof data.transaction.hex === "string") && (data.transaction.preimage === void 0 || typeof data.transaction.preimage === "string"));
189
189
  };
190
190
  isGetSubmarinePairsResponse = (data) => {
191
191
  return data && typeof data === "object" && data.ARK && typeof data.ARK === "object" && data.ARK.BTC && typeof data.ARK.BTC === "object" && typeof data.ARK.BTC.hash === "string" && typeof data.ARK.BTC.rate === "number" && data.ARK.BTC.limits && typeof data.ARK.BTC.limits === "object" && typeof data.ARK.BTC.limits.maximal === "number" && typeof data.ARK.BTC.limits.minimal === "number" && typeof data.ARK.BTC.limits.maximalZeroConf === "number" && data.ARK.BTC.fees && typeof data.ARK.BTC.fees === "object" && typeof data.ARK.BTC.fees.percentage === "number" && typeof data.ARK.BTC.fees.minerFees === "number";
@@ -194,13 +194,13 @@ var init_boltz_swap_provider = __esm({
194
194
  return data && typeof data === "object" && data.BTC && typeof data.BTC === "object" && data.BTC.ARK && typeof data.BTC.ARK === "object" && data.BTC.ARK.hash && typeof data.BTC.ARK.hash === "string" && typeof data.BTC.ARK.rate === "number" && data.BTC.ARK.limits && typeof data.BTC.ARK.limits === "object" && typeof data.BTC.ARK.limits.maximal === "number" && typeof data.BTC.ARK.limits.minimal === "number" && data.BTC.ARK.fees && typeof data.BTC.ARK.fees === "object" && typeof data.BTC.ARK.fees.percentage === "number" && typeof data.BTC.ARK.fees.minerFees === "object" && typeof data.BTC.ARK.fees.minerFees.claim === "number" && typeof data.BTC.ARK.fees.minerFees.lockup === "number";
195
195
  };
196
196
  isCreateSubmarineSwapResponse = (data) => {
197
- return data && typeof data === "object" && typeof data.id === "string" && typeof data.address === "string" && typeof data.expectedAmount === "number" && typeof data.claimPublicKey === "string" && typeof data.acceptZeroConf === "boolean" && isTimeoutBlockHeights(data.timeoutBlockHeights);
197
+ return data && typeof data === "object" && typeof data.id === "string" && typeof data.expectedAmount === "number" && (data.address === void 0 || typeof data.address === "string") && (data.claimPublicKey === void 0 || typeof data.claimPublicKey === "string") && (data.acceptZeroConf === void 0 || typeof data.acceptZeroConf === "boolean") && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights));
198
198
  };
199
199
  isGetSwapPreimageResponse = (data) => {
200
200
  return data && typeof data === "object" && typeof data.preimage === "string";
201
201
  };
202
202
  isCreateReverseSwapResponse = (data) => {
203
- return data && typeof data === "object" && typeof data.id === "string" && typeof data.invoice === "string" && typeof data.onchainAmount === "number" && typeof data.lockupAddress === "string" && typeof data.refundPublicKey === "string" && isTimeoutBlockHeights(data.timeoutBlockHeights);
203
+ return data && typeof data === "object" && typeof data.id === "string" && typeof data.invoice === "string" && (data.onchainAmount === void 0 || typeof data.onchainAmount === "number") && (data.lockupAddress === void 0 || typeof data.lockupAddress === "string") && (data.refundPublicKey === void 0 || typeof data.refundPublicKey === "string") && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights));
204
204
  };
205
205
  isRefundSubmarineSwapResponse = (data) => {
206
206
  return data && typeof data === "object" && typeof data.transaction === "string" && typeof data.checkpoint === "string";
@@ -239,19 +239,19 @@ var init_boltz_swap_provider = __esm({
239
239
  return data && typeof data === "object" && typeof data.version === "number" && typeof data.output === "string";
240
240
  };
241
241
  isTree = (data) => {
242
- return data && typeof data === "object" && isLeaf(data.claimLeaf) && isLeaf(data.refundLeaf) && isLeaf(data.refundWithoutBoltzLeaf) && isLeaf(data.unilateralClaimLeaf) && isLeaf(data.unilateralRefundLeaf) && isLeaf(data.unilateralRefundWithoutBoltzLeaf);
242
+ return data && typeof data === "object" && isLeaf(data.claimLeaf) && isLeaf(data.refundLeaf) && (data.covenantClaimLeaf === void 0 || isLeaf(data.covenantClaimLeaf)) && (data.refundWithoutBoltzLeaf === void 0 || isLeaf(data.refundWithoutBoltzLeaf)) && (data.unilateralClaimLeaf === void 0 || isLeaf(data.unilateralClaimLeaf)) && (data.unilateralRefundLeaf === void 0 || isLeaf(data.unilateralRefundLeaf)) && (data.unilateralRefundWithoutBoltzLeaf === void 0 || isLeaf(data.unilateralRefundWithoutBoltzLeaf));
243
243
  };
244
244
  isDetails = (data) => {
245
- return data && typeof data === "object" && isTree(data.tree) && (data.amount === void 0 || typeof data.amount === "number") && typeof data.keyIndex === "number" && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && typeof data.transaction.vout === "number") && typeof data.lockupAddress === "string" && typeof data.serverPublicKey === "string" && typeof data.timeoutBlockHeight === "number" && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights)) && (data.preimageHash === void 0 || typeof data.preimageHash === "string");
245
+ return data && typeof data === "object" && isTree(data.tree) && (data.amount === void 0 || typeof data.amount === "number") && typeof data.keyIndex === "number" && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && typeof data.transaction.vout === "number") && typeof data.lockupAddress === "string" && typeof data.serverPublicKey === "string" && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights)) && (data.preimageHash === void 0 || typeof data.preimageHash === "string");
246
246
  };
247
247
  isRestoredChainSwap = (data) => {
248
- return data && typeof data === "object" && typeof data.id === "string" && data.type === "chain" && typeof data.status === "string" && typeof data.createdAt === "number" && (data.from === "ARK" || data.from === "BTC") && (data.to === "ARK" || data.to === "BTC") && typeof data.preimageHash === "string" && data.refundDetails && typeof data.refundDetails === "object" && isTree(data.refundDetails.tree) && typeof data.refundDetails.amount === "number" && typeof data.refundDetails.keyIndex === "number" && (data.refundDetails.transaction === void 0 || data.refundDetails.transaction && typeof data.refundDetails.transaction === "object" && typeof data.refundDetails.transaction.id === "string" && typeof data.refundDetails.transaction.vout === "number") && typeof data.refundDetails.lockupAddress === "string" && typeof data.refundDetails.serverPublicKey === "string" && typeof data.refundDetails.timeoutBlockHeight === "number";
248
+ return data && typeof data === "object" && typeof data.id === "string" && data.type === "chain" && typeof data.status === "string" && typeof data.createdAt === "number" && (data.from === "ARK" || data.from === "BTC") && (data.to === "ARK" || data.to === "BTC") && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && (data.invoice === void 0 || typeof data.invoice === "string") && (data.refundDetails === void 0 || isDetails(data.refundDetails)) && (data.claimDetails === void 0 || isDetails(data.claimDetails));
249
249
  };
250
250
  isRestoredSubmarineSwap = (data) => {
251
- return data && typeof data === "object" && data.to === "BTC" && typeof data.id === "string" && data.from === "ARK" && data.type === "submarine" && typeof data.createdAt === "number" && typeof data.preimageHash === "string" && typeof data.status === "string" && isDetails(data.refundDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
251
+ return data && typeof data === "object" && data.to === "BTC" && typeof data.id === "string" && data.from === "ARK" && data.type === "submarine" && typeof data.createdAt === "number" && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && typeof data.status === "string" && isDetails(data.refundDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
252
252
  };
253
253
  isRestoredReverseSwap = (data) => {
254
- return data && typeof data === "object" && data.to === "ARK" && typeof data.id === "string" && data.from === "BTC" && data.type === "reverse" && typeof data.createdAt === "number" && typeof data.preimageHash === "string" && typeof data.status === "string" && isDetails(data.claimDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
254
+ return data && typeof data === "object" && data.to === "ARK" && typeof data.id === "string" && data.from === "BTC" && data.type === "reverse" && typeof data.createdAt === "number" && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && typeof data.status === "string" && isDetails(data.claimDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
255
255
  };
256
256
  isCreateSwapsRestoreResponse = (data) => {
257
257
  return Array.isArray(data) && data.every(
@@ -3219,6 +3219,9 @@ var init_arkade_swaps = __esm({
3219
3219
  async claimVHTLC(pendingSwap) {
3220
3220
  if (!pendingSwap.preimage)
3221
3221
  throw new Error("Preimage is required to claim VHTLC");
3222
+ const { refundPublicKey, lockupAddress, timeoutBlockHeights } = pendingSwap.response;
3223
+ if (!refundPublicKey || !lockupAddress || !timeoutBlockHeights)
3224
+ throw new Error("Incomplete reverse swap response");
3222
3225
  const preimage = import_base9.hex.decode(pendingSwap.preimage);
3223
3226
  const arkInfo = await this.arkProvider.getInfo();
3224
3227
  const address = await this.wallet.getAddress();
@@ -3228,7 +3231,7 @@ var init_arkade_swaps = __esm({
3228
3231
  pendingSwap.id
3229
3232
  );
3230
3233
  const senderXOnly = normalizeToXOnlyKey(
3231
- import_base9.hex.decode(pendingSwap.response.refundPublicKey),
3234
+ import_base9.hex.decode(refundPublicKey),
3232
3235
  "boltz",
3233
3236
  pendingSwap.id
3234
3237
  );
@@ -3243,11 +3246,11 @@ var init_arkade_swaps = __esm({
3243
3246
  receiverPubkey: import_base9.hex.encode(receiverXOnly),
3244
3247
  senderPubkey: import_base9.hex.encode(senderXOnly),
3245
3248
  serverPubkey: import_base9.hex.encode(serverXOnly),
3246
- timeoutBlockHeights: pendingSwap.response.timeoutBlockHeights
3249
+ timeoutBlockHeights
3247
3250
  });
3248
3251
  if (!vhtlcScript.claimScript)
3249
3252
  throw new Error("Failed to create VHTLC script for reverse swap");
3250
- if (vhtlcAddress !== pendingSwap.response.lockupAddress)
3253
+ if (vhtlcAddress !== lockupAddress)
3251
3254
  throw new Error("Boltz is trying to scam us");
3252
3255
  const { vtxos } = await this.indexerProvider.getVtxos({
3253
3256
  scripts: [import_base9.hex.encode(vhtlcScript.pkScript)]
@@ -3388,6 +3391,8 @@ var init_arkade_swaps = __esm({
3388
3391
  */
3389
3392
  async sendLightningPayment(args) {
3390
3393
  const pendingSwap = await this.createSubmarineSwap(args);
3394
+ if (!pendingSwap.response.address)
3395
+ throw new Error("Missing address in submarine swap response");
3391
3396
  await this.savePendingSubmarineSwap(pendingSwap);
3392
3397
  const txid = await this.wallet.send({
3393
3398
  address: pendingSwap.response.address,
@@ -3471,8 +3476,11 @@ var init_arkade_swaps = __esm({
3471
3476
  "server",
3472
3477
  pendingSwap.id
3473
3478
  );
3479
+ const { claimPublicKey, timeoutBlockHeights } = pendingSwap.response;
3480
+ if (!claimPublicKey || !timeoutBlockHeights)
3481
+ throw new Error("Incomplete submarine swap response");
3474
3482
  const boltzXOnlyPublicKey = normalizeToXOnlyKey(
3475
- import_base9.hex.decode(pendingSwap.response.claimPublicKey),
3483
+ import_base9.hex.decode(claimPublicKey),
3476
3484
  "boltz",
3477
3485
  pendingSwap.id
3478
3486
  );
@@ -3482,7 +3490,7 @@ var init_arkade_swaps = __esm({
3482
3490
  receiverPubkey: import_base9.hex.encode(boltzXOnlyPublicKey),
3483
3491
  senderPubkey: import_base9.hex.encode(ourXOnlyPublicKey),
3484
3492
  serverPubkey: import_base9.hex.encode(serverXOnlyPublicKey),
3485
- timeoutBlockHeights: pendingSwap.response.timeoutBlockHeights
3493
+ timeoutBlockHeights
3486
3494
  });
3487
3495
  if (!vhtlcScript.claimScript)
3488
3496
  throw new Error("Failed to create VHTLC script for submarine swap");
@@ -4484,7 +4492,8 @@ var init_arkade_swaps = __esm({
4484
4492
  lockupAddress,
4485
4493
  preimageHash,
4486
4494
  serverPublicKey,
4487
- tree
4495
+ tree,
4496
+ timeoutBlockHeights
4488
4497
  } = swap.claimDetails;
4489
4498
  reverseSwaps.push({
4490
4499
  id,
@@ -4500,18 +4509,18 @@ var init_arkade_swaps = __esm({
4500
4509
  onchainAmount: amount,
4501
4510
  lockupAddress,
4502
4511
  refundPublicKey: serverPublicKey,
4503
- timeoutBlockHeights: {
4512
+ timeoutBlockHeights: timeoutBlockHeights ?? {
4504
4513
  refund: extractTimeLockFromLeafOutput(
4505
- tree.refundWithoutBoltzLeaf.output
4514
+ tree.refundWithoutBoltzLeaf?.output ?? ""
4506
4515
  ),
4507
4516
  unilateralClaim: extractTimeLockFromLeafOutput(
4508
- tree.unilateralClaimLeaf.output
4517
+ tree.unilateralClaimLeaf?.output ?? ""
4509
4518
  ),
4510
4519
  unilateralRefund: extractTimeLockFromLeafOutput(
4511
- tree.unilateralRefundLeaf.output
4520
+ tree.unilateralRefundLeaf?.output ?? ""
4512
4521
  ),
4513
4522
  unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
4514
- tree.unilateralRefundWithoutBoltzLeaf.output
4523
+ tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
4515
4524
  )
4516
4525
  }
4517
4526
  },
@@ -4520,7 +4529,13 @@ var init_arkade_swaps = __esm({
4520
4529
  preimage: ""
4521
4530
  });
4522
4531
  } else if (isRestoredSubmarineSwap(swap)) {
4523
- const { amount, lockupAddress, serverPublicKey, tree } = swap.refundDetails;
4532
+ const {
4533
+ amount,
4534
+ lockupAddress,
4535
+ serverPublicKey,
4536
+ tree,
4537
+ timeoutBlockHeights
4538
+ } = swap.refundDetails;
4524
4539
  let preimage = "";
4525
4540
  if (!isSubmarineFinalStatus(status)) {
4526
4541
  try {
@@ -4551,29 +4566,31 @@ var init_arkade_swaps = __esm({
4551
4566
  address: lockupAddress,
4552
4567
  expectedAmount: amount,
4553
4568
  claimPublicKey: serverPublicKey,
4554
- timeoutBlockHeights: {
4569
+ timeoutBlockHeights: timeoutBlockHeights ?? {
4555
4570
  refund: extractTimeLockFromLeafOutput(
4556
- tree.refundWithoutBoltzLeaf.output
4571
+ tree.refundWithoutBoltzLeaf?.output ?? ""
4557
4572
  ),
4558
4573
  unilateralClaim: extractTimeLockFromLeafOutput(
4559
- tree.unilateralClaimLeaf.output
4574
+ tree.unilateralClaimLeaf?.output ?? ""
4560
4575
  ),
4561
4576
  unilateralRefund: extractTimeLockFromLeafOutput(
4562
- tree.unilateralRefundLeaf.output
4577
+ tree.unilateralRefundLeaf?.output ?? ""
4563
4578
  ),
4564
4579
  unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
4565
- tree.unilateralRefundWithoutBoltzLeaf.output
4580
+ tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
4566
4581
  )
4567
4582
  }
4568
4583
  }
4569
4584
  });
4570
4585
  } else if (isRestoredChainSwap(swap)) {
4586
+ const refundDetails = swap.refundDetails;
4587
+ if (!refundDetails) continue;
4571
4588
  const {
4572
4589
  amount,
4573
4590
  lockupAddress,
4574
4591
  serverPublicKey,
4575
4592
  timeoutBlockHeight
4576
- } = swap.refundDetails;
4593
+ } = refundDetails;
4577
4594
  chainSwaps.push({
4578
4595
  id,
4579
4596
  type: "chain",
@@ -1,5 +1,5 @@
1
- import { I as IArkadeSwaps, A as ArkadeSwaps } from '../arkade-swaps-CwQbGdU9.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-x542EUL6.cjs';
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';
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-BfHIKMq0.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-x542EUL6.js';
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';
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-2TWYSAFO.js";
7
+ } from "../chunk-DPGNWPDB.js";
8
8
  import {
9
9
  ArkadeSwaps
10
- } from "../chunk-AIVWXKNG.js";
10
+ } from "../chunk-Y6GPJDXY.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-5XMCGVMS.js");
59
+ const { registerExpoSwapBackgroundTask: registerExpoSwapBackgroundTask2 } = await import("../background-646NBLSK.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-5XMCGVMS.js");
132
+ const { unregisterExpoSwapBackgroundTask: unregisterExpoSwapBackgroundTask2 } = await import("../background-646NBLSK.js");
133
133
  await unregisterExpoSwapBackgroundTask2(this.taskName);
134
134
  } catch (err) {
135
135
  const message = err instanceof Error ? err.message : String(err);
package/dist/index.cjs CHANGED
@@ -314,7 +314,7 @@ var isGetReverseSwapTxIdResponse = (data) => {
314
314
  return data && typeof data === "object" && typeof data.id === "string" && typeof data.timeoutBlockHeight === "number";
315
315
  };
316
316
  var isGetSwapStatusResponse = (data) => {
317
- return data && typeof data === "object" && typeof data.status === "string" && (data.zeroConfRejected === void 0 || typeof data.zeroConfRejected === "boolean") && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && (data.transaction.eta === void 0 || typeof data.transaction.eta === "number") && (data.transaction.hex === void 0 || typeof data.transaction.hex === "string") && (data.transaction.preimage === void 0 || typeof data.transaction.preimage === "string"));
317
+ return data && typeof data === "object" && typeof data.status === "string" && (data.zeroConfRejected === void 0 || typeof data.zeroConfRejected === "boolean") && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && (data.transaction.confirmed === void 0 || typeof data.transaction.confirmed === "boolean") && (data.transaction.eta === void 0 || typeof data.transaction.eta === "number") && (data.transaction.hex === void 0 || typeof data.transaction.hex === "string") && (data.transaction.preimage === void 0 || typeof data.transaction.preimage === "string"));
318
318
  };
319
319
  var isGetSubmarinePairsResponse = (data) => {
320
320
  return data && typeof data === "object" && data.ARK && typeof data.ARK === "object" && data.ARK.BTC && typeof data.ARK.BTC === "object" && typeof data.ARK.BTC.hash === "string" && typeof data.ARK.BTC.rate === "number" && data.ARK.BTC.limits && typeof data.ARK.BTC.limits === "object" && typeof data.ARK.BTC.limits.maximal === "number" && typeof data.ARK.BTC.limits.minimal === "number" && typeof data.ARK.BTC.limits.maximalZeroConf === "number" && data.ARK.BTC.fees && typeof data.ARK.BTC.fees === "object" && typeof data.ARK.BTC.fees.percentage === "number" && typeof data.ARK.BTC.fees.minerFees === "number";
@@ -323,13 +323,13 @@ var isGetReversePairsResponse = (data) => {
323
323
  return data && typeof data === "object" && data.BTC && typeof data.BTC === "object" && data.BTC.ARK && typeof data.BTC.ARK === "object" && data.BTC.ARK.hash && typeof data.BTC.ARK.hash === "string" && typeof data.BTC.ARK.rate === "number" && data.BTC.ARK.limits && typeof data.BTC.ARK.limits === "object" && typeof data.BTC.ARK.limits.maximal === "number" && typeof data.BTC.ARK.limits.minimal === "number" && data.BTC.ARK.fees && typeof data.BTC.ARK.fees === "object" && typeof data.BTC.ARK.fees.percentage === "number" && typeof data.BTC.ARK.fees.minerFees === "object" && typeof data.BTC.ARK.fees.minerFees.claim === "number" && typeof data.BTC.ARK.fees.minerFees.lockup === "number";
324
324
  };
325
325
  var isCreateSubmarineSwapResponse = (data) => {
326
- return data && typeof data === "object" && typeof data.id === "string" && typeof data.address === "string" && typeof data.expectedAmount === "number" && typeof data.claimPublicKey === "string" && typeof data.acceptZeroConf === "boolean" && isTimeoutBlockHeights(data.timeoutBlockHeights);
326
+ return data && typeof data === "object" && typeof data.id === "string" && typeof data.expectedAmount === "number" && (data.address === void 0 || typeof data.address === "string") && (data.claimPublicKey === void 0 || typeof data.claimPublicKey === "string") && (data.acceptZeroConf === void 0 || typeof data.acceptZeroConf === "boolean") && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights));
327
327
  };
328
328
  var isGetSwapPreimageResponse = (data) => {
329
329
  return data && typeof data === "object" && typeof data.preimage === "string";
330
330
  };
331
331
  var isCreateReverseSwapResponse = (data) => {
332
- return data && typeof data === "object" && typeof data.id === "string" && typeof data.invoice === "string" && typeof data.onchainAmount === "number" && typeof data.lockupAddress === "string" && typeof data.refundPublicKey === "string" && isTimeoutBlockHeights(data.timeoutBlockHeights);
332
+ return data && typeof data === "object" && typeof data.id === "string" && typeof data.invoice === "string" && (data.onchainAmount === void 0 || typeof data.onchainAmount === "number") && (data.lockupAddress === void 0 || typeof data.lockupAddress === "string") && (data.refundPublicKey === void 0 || typeof data.refundPublicKey === "string") && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights));
333
333
  };
334
334
  var isRefundSubmarineSwapResponse = (data) => {
335
335
  return data && typeof data === "object" && typeof data.transaction === "string" && typeof data.checkpoint === "string";
@@ -368,19 +368,19 @@ var isLeaf = (data) => {
368
368
  return data && typeof data === "object" && typeof data.version === "number" && typeof data.output === "string";
369
369
  };
370
370
  var isTree = (data) => {
371
- return data && typeof data === "object" && isLeaf(data.claimLeaf) && isLeaf(data.refundLeaf) && isLeaf(data.refundWithoutBoltzLeaf) && isLeaf(data.unilateralClaimLeaf) && isLeaf(data.unilateralRefundLeaf) && isLeaf(data.unilateralRefundWithoutBoltzLeaf);
371
+ return data && typeof data === "object" && isLeaf(data.claimLeaf) && isLeaf(data.refundLeaf) && (data.covenantClaimLeaf === void 0 || isLeaf(data.covenantClaimLeaf)) && (data.refundWithoutBoltzLeaf === void 0 || isLeaf(data.refundWithoutBoltzLeaf)) && (data.unilateralClaimLeaf === void 0 || isLeaf(data.unilateralClaimLeaf)) && (data.unilateralRefundLeaf === void 0 || isLeaf(data.unilateralRefundLeaf)) && (data.unilateralRefundWithoutBoltzLeaf === void 0 || isLeaf(data.unilateralRefundWithoutBoltzLeaf));
372
372
  };
373
373
  var isDetails = (data) => {
374
- return data && typeof data === "object" && isTree(data.tree) && (data.amount === void 0 || typeof data.amount === "number") && typeof data.keyIndex === "number" && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && typeof data.transaction.vout === "number") && typeof data.lockupAddress === "string" && typeof data.serverPublicKey === "string" && typeof data.timeoutBlockHeight === "number" && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights)) && (data.preimageHash === void 0 || typeof data.preimageHash === "string");
374
+ return data && typeof data === "object" && isTree(data.tree) && (data.amount === void 0 || typeof data.amount === "number") && typeof data.keyIndex === "number" && (data.transaction === void 0 || data.transaction && typeof data.transaction === "object" && typeof data.transaction.id === "string" && typeof data.transaction.vout === "number") && typeof data.lockupAddress === "string" && typeof data.serverPublicKey === "string" && (data.timeoutBlockHeight === void 0 || typeof data.timeoutBlockHeight === "number") && (data.timeoutBlockHeights === void 0 || isTimeoutBlockHeights(data.timeoutBlockHeights)) && (data.preimageHash === void 0 || typeof data.preimageHash === "string");
375
375
  };
376
376
  var isRestoredChainSwap = (data) => {
377
- return data && typeof data === "object" && typeof data.id === "string" && data.type === "chain" && typeof data.status === "string" && typeof data.createdAt === "number" && (data.from === "ARK" || data.from === "BTC") && (data.to === "ARK" || data.to === "BTC") && typeof data.preimageHash === "string" && data.refundDetails && typeof data.refundDetails === "object" && isTree(data.refundDetails.tree) && typeof data.refundDetails.amount === "number" && typeof data.refundDetails.keyIndex === "number" && (data.refundDetails.transaction === void 0 || data.refundDetails.transaction && typeof data.refundDetails.transaction === "object" && typeof data.refundDetails.transaction.id === "string" && typeof data.refundDetails.transaction.vout === "number") && typeof data.refundDetails.lockupAddress === "string" && typeof data.refundDetails.serverPublicKey === "string" && typeof data.refundDetails.timeoutBlockHeight === "number";
377
+ return data && typeof data === "object" && typeof data.id === "string" && data.type === "chain" && typeof data.status === "string" && typeof data.createdAt === "number" && (data.from === "ARK" || data.from === "BTC") && (data.to === "ARK" || data.to === "BTC") && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && (data.invoice === void 0 || typeof data.invoice === "string") && (data.refundDetails === void 0 || isDetails(data.refundDetails)) && (data.claimDetails === void 0 || isDetails(data.claimDetails));
378
378
  };
379
379
  var isRestoredSubmarineSwap = (data) => {
380
- return data && typeof data === "object" && data.to === "BTC" && typeof data.id === "string" && data.from === "ARK" && data.type === "submarine" && typeof data.createdAt === "number" && typeof data.preimageHash === "string" && typeof data.status === "string" && isDetails(data.refundDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
380
+ return data && typeof data === "object" && data.to === "BTC" && typeof data.id === "string" && data.from === "ARK" && data.type === "submarine" && typeof data.createdAt === "number" && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && typeof data.status === "string" && isDetails(data.refundDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
381
381
  };
382
382
  var isRestoredReverseSwap = (data) => {
383
- return data && typeof data === "object" && data.to === "ARK" && typeof data.id === "string" && data.from === "BTC" && data.type === "reverse" && typeof data.createdAt === "number" && typeof data.preimageHash === "string" && typeof data.status === "string" && isDetails(data.claimDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
383
+ return data && typeof data === "object" && data.to === "ARK" && typeof data.id === "string" && data.from === "BTC" && data.type === "reverse" && typeof data.createdAt === "number" && (data.preimageHash === void 0 || typeof data.preimageHash === "string") && typeof data.status === "string" && isDetails(data.claimDetails) && (data.invoice === void 0 || typeof data.invoice === "string");
384
384
  };
385
385
  var isCreateSwapsRestoreResponse = (data) => {
386
386
  return Array.isArray(data) && data.every(
@@ -3273,6 +3273,9 @@ var ArkadeSwaps = class _ArkadeSwaps {
3273
3273
  async claimVHTLC(pendingSwap) {
3274
3274
  if (!pendingSwap.preimage)
3275
3275
  throw new Error("Preimage is required to claim VHTLC");
3276
+ const { refundPublicKey, lockupAddress, timeoutBlockHeights } = pendingSwap.response;
3277
+ if (!refundPublicKey || !lockupAddress || !timeoutBlockHeights)
3278
+ throw new Error("Incomplete reverse swap response");
3276
3279
  const preimage = import_base9.hex.decode(pendingSwap.preimage);
3277
3280
  const arkInfo = await this.arkProvider.getInfo();
3278
3281
  const address = await this.wallet.getAddress();
@@ -3282,7 +3285,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
3282
3285
  pendingSwap.id
3283
3286
  );
3284
3287
  const senderXOnly = normalizeToXOnlyKey(
3285
- import_base9.hex.decode(pendingSwap.response.refundPublicKey),
3288
+ import_base9.hex.decode(refundPublicKey),
3286
3289
  "boltz",
3287
3290
  pendingSwap.id
3288
3291
  );
@@ -3297,11 +3300,11 @@ var ArkadeSwaps = class _ArkadeSwaps {
3297
3300
  receiverPubkey: import_base9.hex.encode(receiverXOnly),
3298
3301
  senderPubkey: import_base9.hex.encode(senderXOnly),
3299
3302
  serverPubkey: import_base9.hex.encode(serverXOnly),
3300
- timeoutBlockHeights: pendingSwap.response.timeoutBlockHeights
3303
+ timeoutBlockHeights
3301
3304
  });
3302
3305
  if (!vhtlcScript.claimScript)
3303
3306
  throw new Error("Failed to create VHTLC script for reverse swap");
3304
- if (vhtlcAddress !== pendingSwap.response.lockupAddress)
3307
+ if (vhtlcAddress !== lockupAddress)
3305
3308
  throw new Error("Boltz is trying to scam us");
3306
3309
  const { vtxos } = await this.indexerProvider.getVtxos({
3307
3310
  scripts: [import_base9.hex.encode(vhtlcScript.pkScript)]
@@ -3442,6 +3445,8 @@ var ArkadeSwaps = class _ArkadeSwaps {
3442
3445
  */
3443
3446
  async sendLightningPayment(args) {
3444
3447
  const pendingSwap = await this.createSubmarineSwap(args);
3448
+ if (!pendingSwap.response.address)
3449
+ throw new Error("Missing address in submarine swap response");
3445
3450
  await this.savePendingSubmarineSwap(pendingSwap);
3446
3451
  const txid = await this.wallet.send({
3447
3452
  address: pendingSwap.response.address,
@@ -3525,8 +3530,11 @@ var ArkadeSwaps = class _ArkadeSwaps {
3525
3530
  "server",
3526
3531
  pendingSwap.id
3527
3532
  );
3533
+ const { claimPublicKey, timeoutBlockHeights } = pendingSwap.response;
3534
+ if (!claimPublicKey || !timeoutBlockHeights)
3535
+ throw new Error("Incomplete submarine swap response");
3528
3536
  const boltzXOnlyPublicKey = normalizeToXOnlyKey(
3529
- import_base9.hex.decode(pendingSwap.response.claimPublicKey),
3537
+ import_base9.hex.decode(claimPublicKey),
3530
3538
  "boltz",
3531
3539
  pendingSwap.id
3532
3540
  );
@@ -3536,7 +3544,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
3536
3544
  receiverPubkey: import_base9.hex.encode(boltzXOnlyPublicKey),
3537
3545
  senderPubkey: import_base9.hex.encode(ourXOnlyPublicKey),
3538
3546
  serverPubkey: import_base9.hex.encode(serverXOnlyPublicKey),
3539
- timeoutBlockHeights: pendingSwap.response.timeoutBlockHeights
3547
+ timeoutBlockHeights
3540
3548
  });
3541
3549
  if (!vhtlcScript.claimScript)
3542
3550
  throw new Error("Failed to create VHTLC script for submarine swap");
@@ -4538,7 +4546,8 @@ var ArkadeSwaps = class _ArkadeSwaps {
4538
4546
  lockupAddress,
4539
4547
  preimageHash,
4540
4548
  serverPublicKey,
4541
- tree
4549
+ tree,
4550
+ timeoutBlockHeights
4542
4551
  } = swap.claimDetails;
4543
4552
  reverseSwaps.push({
4544
4553
  id,
@@ -4554,18 +4563,18 @@ var ArkadeSwaps = class _ArkadeSwaps {
4554
4563
  onchainAmount: amount,
4555
4564
  lockupAddress,
4556
4565
  refundPublicKey: serverPublicKey,
4557
- timeoutBlockHeights: {
4566
+ timeoutBlockHeights: timeoutBlockHeights ?? {
4558
4567
  refund: extractTimeLockFromLeafOutput(
4559
- tree.refundWithoutBoltzLeaf.output
4568
+ tree.refundWithoutBoltzLeaf?.output ?? ""
4560
4569
  ),
4561
4570
  unilateralClaim: extractTimeLockFromLeafOutput(
4562
- tree.unilateralClaimLeaf.output
4571
+ tree.unilateralClaimLeaf?.output ?? ""
4563
4572
  ),
4564
4573
  unilateralRefund: extractTimeLockFromLeafOutput(
4565
- tree.unilateralRefundLeaf.output
4574
+ tree.unilateralRefundLeaf?.output ?? ""
4566
4575
  ),
4567
4576
  unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
4568
- tree.unilateralRefundWithoutBoltzLeaf.output
4577
+ tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
4569
4578
  )
4570
4579
  }
4571
4580
  },
@@ -4574,7 +4583,13 @@ var ArkadeSwaps = class _ArkadeSwaps {
4574
4583
  preimage: ""
4575
4584
  });
4576
4585
  } else if (isRestoredSubmarineSwap(swap)) {
4577
- const { amount, lockupAddress, serverPublicKey, tree } = swap.refundDetails;
4586
+ const {
4587
+ amount,
4588
+ lockupAddress,
4589
+ serverPublicKey,
4590
+ tree,
4591
+ timeoutBlockHeights
4592
+ } = swap.refundDetails;
4578
4593
  let preimage = "";
4579
4594
  if (!isSubmarineFinalStatus(status)) {
4580
4595
  try {
@@ -4605,29 +4620,31 @@ var ArkadeSwaps = class _ArkadeSwaps {
4605
4620
  address: lockupAddress,
4606
4621
  expectedAmount: amount,
4607
4622
  claimPublicKey: serverPublicKey,
4608
- timeoutBlockHeights: {
4623
+ timeoutBlockHeights: timeoutBlockHeights ?? {
4609
4624
  refund: extractTimeLockFromLeafOutput(
4610
- tree.refundWithoutBoltzLeaf.output
4625
+ tree.refundWithoutBoltzLeaf?.output ?? ""
4611
4626
  ),
4612
4627
  unilateralClaim: extractTimeLockFromLeafOutput(
4613
- tree.unilateralClaimLeaf.output
4628
+ tree.unilateralClaimLeaf?.output ?? ""
4614
4629
  ),
4615
4630
  unilateralRefund: extractTimeLockFromLeafOutput(
4616
- tree.unilateralRefundLeaf.output
4631
+ tree.unilateralRefundLeaf?.output ?? ""
4617
4632
  ),
4618
4633
  unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
4619
- tree.unilateralRefundWithoutBoltzLeaf.output
4634
+ tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
4620
4635
  )
4621
4636
  }
4622
4637
  }
4623
4638
  });
4624
4639
  } else if (isRestoredChainSwap(swap)) {
4640
+ const refundDetails = swap.refundDetails;
4641
+ if (!refundDetails) continue;
4625
4642
  const {
4626
4643
  amount,
4627
4644
  lockupAddress,
4628
4645
  serverPublicKey,
4629
4646
  timeoutBlockHeight
4630
- } = swap.refundDetails;
4647
+ } = refundDetails;
4631
4648
  chainSwaps.push({
4632
4649
  id,
4633
4650
  type: "chain",
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IArkadeSwaps } from './arkade-swaps-CwQbGdU9.cjs';
2
- export { A as ArkadeSwaps } from './arkade-swaps-CwQbGdU9.cjs';
3
- import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, h as ArkToBtcResponse, i as BtcToArkResponse, j as SwapRepository, k as SwapManagerClient, l as GetSwapsFilter } from './types-x542EUL6.cjs';
4
- export { X as ArkadeSwapsCreateConfig, m as BoltzSwapProvider, n as BoltzSwapStatus, W as IncomingPaymentSubscription, V as SwapManager, $ as SwapManagerCallbacks, Z as SwapManagerConfig, _ as SwapManagerEvents, Y as Vtxo, o as isChainClaimableStatus, p as isChainFailedStatus, q as isChainFinalStatus, r as isChainPendingStatus, s as isChainRefundableStatus, t as isChainSignableStatus, u as isChainSuccessStatus, v as isChainSwapClaimable, w as isChainSwapRefundable, x as isPendingChainSwap, y as isPendingReverseSwap, z as isPendingSubmarineSwap, E as isReverseClaimableStatus, H as isReverseFailedStatus, I as isReverseFinalStatus, J as isReversePendingStatus, K as isReverseSuccessStatus, M as isReverseSwapClaimable, O as isSubmarineFailedStatus, P as isSubmarineFinalStatus, Q as isSubmarinePendingStatus, T as isSubmarineRefundableStatus, R as isSubmarineSuccessStatus, U as isSubmarineSwapRefundable } from './types-x542EUL6.cjs';
1
+ import { I as IArkadeSwaps } from './arkade-swaps-DkM_5yuv.cjs';
2
+ export { A as ArkadeSwaps } from './arkade-swaps-DkM_5yuv.cjs';
3
+ import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, h as ArkToBtcResponse, i as BtcToArkResponse, j as SwapRepository, k as SwapManagerClient, l as GetSwapsFilter } from './types-C-2sBQWJ.cjs';
4
+ export { X as ArkadeSwapsCreateConfig, m as BoltzSwapProvider, n as BoltzSwapStatus, W as IncomingPaymentSubscription, V as SwapManager, $ as SwapManagerCallbacks, Z as SwapManagerConfig, _ as SwapManagerEvents, Y as Vtxo, o as isChainClaimableStatus, p as isChainFailedStatus, q as isChainFinalStatus, r as isChainPendingStatus, s as isChainRefundableStatus, t as isChainSignableStatus, u as isChainSuccessStatus, v as isChainSwapClaimable, w as isChainSwapRefundable, x as isPendingChainSwap, y as isPendingReverseSwap, z as isPendingSubmarineSwap, E as isReverseClaimableStatus, H as isReverseFailedStatus, I as isReverseFinalStatus, J as isReversePendingStatus, K as isReverseSuccessStatus, M as isReverseSwapClaimable, O as isSubmarineFailedStatus, P as isSubmarineFinalStatus, Q as isSubmarinePendingStatus, T as isSubmarineRefundableStatus, R as isSubmarineSuccessStatus, U as isSubmarineSwapRefundable } from './types-C-2sBQWJ.cjs';
5
5
  import { Transaction } from '@scure/btc-signer';
6
6
  import { MessageHandler, RequestEnvelope, ArkInfo, ResponseEnvelope, IWallet, IReadonlyWallet, VHTLC, Identity, ArkTxInput } from '@arkade-os/sdk';
7
7
  import { TransactionOutput } from '@scure/btc-signer/psbt.js';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { I as IArkadeSwaps } from './arkade-swaps-BfHIKMq0.js';
2
- export { A as ArkadeSwaps } from './arkade-swaps-BfHIKMq0.js';
3
- import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, h as ArkToBtcResponse, i as BtcToArkResponse, j as SwapRepository, k as SwapManagerClient, l as GetSwapsFilter } from './types-x542EUL6.js';
4
- export { X as ArkadeSwapsCreateConfig, m as BoltzSwapProvider, n as BoltzSwapStatus, W as IncomingPaymentSubscription, V as SwapManager, $ as SwapManagerCallbacks, Z as SwapManagerConfig, _ as SwapManagerEvents, Y as Vtxo, o as isChainClaimableStatus, p as isChainFailedStatus, q as isChainFinalStatus, r as isChainPendingStatus, s as isChainRefundableStatus, t as isChainSignableStatus, u as isChainSuccessStatus, v as isChainSwapClaimable, w as isChainSwapRefundable, x as isPendingChainSwap, y as isPendingReverseSwap, z as isPendingSubmarineSwap, E as isReverseClaimableStatus, H as isReverseFailedStatus, I as isReverseFinalStatus, J as isReversePendingStatus, K as isReverseSuccessStatus, M as isReverseSwapClaimable, O as isSubmarineFailedStatus, P as isSubmarineFinalStatus, Q as isSubmarinePendingStatus, T as isSubmarineRefundableStatus, R as isSubmarineSuccessStatus, U as isSubmarineSwapRefundable } from './types-x542EUL6.js';
1
+ import { I as IArkadeSwaps } from './arkade-swaps-DRMB_apa.js';
2
+ export { A as ArkadeSwaps } from './arkade-swaps-DRMB_apa.js';
3
+ import { B as BoltzSwap, D as DecodedInvoice, a as BoltzChainSwap, b as BoltzReverseSwap, c as BoltzSubmarineSwap, A as ArkadeSwapsConfig, N as Network, C as CreateLightningInvoiceRequest, S as SendLightningPaymentRequest, F as FeesResponse, d as Chain, e as CreateLightningInvoiceResponse, f as SendLightningPaymentResponse, g as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, h as ArkToBtcResponse, i as BtcToArkResponse, j as SwapRepository, k as SwapManagerClient, l as GetSwapsFilter } from './types-C-2sBQWJ.js';
4
+ export { X as ArkadeSwapsCreateConfig, m as BoltzSwapProvider, n as BoltzSwapStatus, W as IncomingPaymentSubscription, V as SwapManager, $ as SwapManagerCallbacks, Z as SwapManagerConfig, _ as SwapManagerEvents, Y as Vtxo, o as isChainClaimableStatus, p as isChainFailedStatus, q as isChainFinalStatus, r as isChainPendingStatus, s as isChainRefundableStatus, t as isChainSignableStatus, u as isChainSuccessStatus, v as isChainSwapClaimable, w as isChainSwapRefundable, x as isPendingChainSwap, y as isPendingReverseSwap, z as isPendingSubmarineSwap, E as isReverseClaimableStatus, H as isReverseFailedStatus, I as isReverseFinalStatus, J as isReversePendingStatus, K as isReverseSuccessStatus, M as isReverseSwapClaimable, O as isSubmarineFailedStatus, P as isSubmarineFinalStatus, Q as isSubmarinePendingStatus, T as isSubmarineRefundableStatus, R as isSubmarineSuccessStatus, U as isSubmarineSwapRefundable } from './types-C-2sBQWJ.js';
5
5
  import { Transaction } from '@scure/btc-signer';
6
6
  import { MessageHandler, RequestEnvelope, ArkInfo, ResponseEnvelope, IWallet, IReadonlyWallet, VHTLC, Identity, ArkTxInput } from '@arkade-os/sdk';
7
7
  import { TransactionOutput } from '@scure/btc-signer/psbt.js';
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ import {
49
49
  updateReverseSwapStatus,
50
50
  updateSubmarineSwapStatus,
51
51
  verifySignatures
52
- } from "./chunk-AIVWXKNG.js";
52
+ } from "./chunk-Y6GPJDXY.js";
53
53
  import "./chunk-3RG5ZIWI.js";
54
54
 
55
55
  // src/serviceWorker/arkade-swaps-message-handler.ts
@@ -1,4 +1,4 @@
1
- import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-x542EUL6.cjs';
1
+ import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-C-2sBQWJ.cjs';
2
2
  import '@arkade-os/sdk';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-x542EUL6.js';
1
+ import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-C-2sBQWJ.js';
2
2
  import '@arkade-os/sdk';
3
3
 
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
2
- import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-x542EUL6.cjs';
2
+ import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-C-2sBQWJ.cjs';
3
3
  import '@arkade-os/sdk';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { SQLExecutor } from '@arkade-os/sdk/repositories/sqlite';
2
- import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-x542EUL6.js';
2
+ import { j as SwapRepository, B as BoltzSwap, l as GetSwapsFilter } from '../../types-C-2sBQWJ.js';
3
3
  import '@arkade-os/sdk';
4
4
 
5
5
  /**
@@ -81,6 +81,7 @@ type GetSwapStatusResponse = {
81
81
  transaction?: {
82
82
  id: string;
83
83
  hex?: string;
84
+ confirmed?: boolean;
84
85
  eta?: number;
85
86
  preimage?: string;
86
87
  };
@@ -96,16 +97,18 @@ type CreateSubmarineSwapRequest = {
96
97
  type CreateSubmarineSwapResponse = {
97
98
  /** Unique swap ID. */
98
99
  id: string;
99
- /** ARK lockup address to send funds to. */
100
- address: string;
101
100
  /** Amount in satoshis to send. */
102
101
  expectedAmount: number;
102
+ /** ARK lockup address to send funds to. */
103
+ address?: string;
103
104
  /** Boltz's public key for the claim path. */
104
- claimPublicKey: string;
105
+ claimPublicKey?: string;
105
106
  /** Whether zero-conf transactions are accepted. */
106
- acceptZeroConf: boolean;
107
+ acceptZeroConf?: boolean;
108
+ /** Block height for the onchain HTLC timeout. */
109
+ timeoutBlockHeight?: number;
107
110
  /** Block heights for various timeout/refund scenarios. */
108
- timeoutBlockHeights: TimeoutBlockHeights;
111
+ timeoutBlockHeights?: TimeoutBlockHeights;
109
112
  };
110
113
  type GetSwapPreimageResponse = {
111
114
  preimage: string;
@@ -128,13 +131,15 @@ type CreateReverseSwapResponse = {
128
131
  /** BOLT11-encoded Lightning invoice to be paid. */
129
132
  invoice: string;
130
133
  /** On-chain amount in satoshis (after Boltz fees). */
131
- onchainAmount: number;
134
+ onchainAmount?: number;
132
135
  /** ARK lockup address where Boltz will lock funds. */
133
- lockupAddress: string;
136
+ lockupAddress?: string;
134
137
  /** Boltz's public key for the refund path. */
135
- refundPublicKey: string;
138
+ refundPublicKey?: string;
139
+ /** Block height for the onchain HTLC timeout. */
140
+ timeoutBlockHeight?: number;
136
141
  /** Block heights for various timeout/refund scenarios. */
137
- timeoutBlockHeights: TimeoutBlockHeights;
142
+ timeoutBlockHeights?: TimeoutBlockHeights;
138
143
  };
139
144
  type SwapTree = {
140
145
  claimLeaf: {
@@ -223,10 +228,11 @@ type Leaf = {
223
228
  type Tree = {
224
229
  claimLeaf: Leaf;
225
230
  refundLeaf: Leaf;
226
- refundWithoutBoltzLeaf: Leaf;
227
- unilateralClaimLeaf: Leaf;
228
- unilateralRefundLeaf: Leaf;
229
- unilateralRefundWithoutBoltzLeaf: Leaf;
231
+ covenantClaimLeaf?: Leaf;
232
+ refundWithoutBoltzLeaf?: Leaf;
233
+ unilateralClaimLeaf?: Leaf;
234
+ unilateralRefundLeaf?: Leaf;
235
+ unilateralRefundWithoutBoltzLeaf?: Leaf;
230
236
  };
231
237
  type Details = {
232
238
  tree: Tree;
@@ -238,7 +244,7 @@ type Details = {
238
244
  };
239
245
  lockupAddress: string;
240
246
  serverPublicKey: string;
241
- timeoutBlockHeight: number;
247
+ timeoutBlockHeight?: number;
242
248
  timeoutBlockHeights?: TimeoutBlockHeights;
243
249
  preimageHash?: string;
244
250
  };
@@ -249,19 +255,10 @@ type RestoredChainSwap = {
249
255
  createdAt: number;
250
256
  from: "ARK" | "BTC";
251
257
  to: "ARK" | "BTC";
252
- preimageHash: string;
253
- refundDetails: {
254
- amount: number;
255
- keyIndex: number;
256
- lockupAddress: string;
257
- serverPublicKey: string;
258
- timeoutBlockHeight: number;
259
- transaction?: {
260
- id: string;
261
- vout: number;
262
- };
263
- tree: Tree;
264
- };
258
+ preimageHash?: string;
259
+ invoice?: string;
260
+ refundDetails?: Details;
261
+ claimDetails?: Details;
265
262
  };
266
263
  type RestoredSubmarineSwap = {
267
264
  to: "BTC";
@@ -269,7 +266,7 @@ type RestoredSubmarineSwap = {
269
266
  from: "ARK";
270
267
  type: "submarine";
271
268
  createdAt: number;
272
- preimageHash: string;
269
+ preimageHash?: string;
273
270
  status: BoltzSwapStatus;
274
271
  refundDetails: Details;
275
272
  invoice?: string;
@@ -280,7 +277,7 @@ type RestoredReverseSwap = {
280
277
  from: "BTC";
281
278
  type: "reverse";
282
279
  createdAt: number;
283
- preimageHash: string;
280
+ preimageHash?: string;
284
281
  status: BoltzSwapStatus;
285
282
  claimDetails: Details;
286
283
  invoice?: string;
@@ -81,6 +81,7 @@ type GetSwapStatusResponse = {
81
81
  transaction?: {
82
82
  id: string;
83
83
  hex?: string;
84
+ confirmed?: boolean;
84
85
  eta?: number;
85
86
  preimage?: string;
86
87
  };
@@ -96,16 +97,18 @@ type CreateSubmarineSwapRequest = {
96
97
  type CreateSubmarineSwapResponse = {
97
98
  /** Unique swap ID. */
98
99
  id: string;
99
- /** ARK lockup address to send funds to. */
100
- address: string;
101
100
  /** Amount in satoshis to send. */
102
101
  expectedAmount: number;
102
+ /** ARK lockup address to send funds to. */
103
+ address?: string;
103
104
  /** Boltz's public key for the claim path. */
104
- claimPublicKey: string;
105
+ claimPublicKey?: string;
105
106
  /** Whether zero-conf transactions are accepted. */
106
- acceptZeroConf: boolean;
107
+ acceptZeroConf?: boolean;
108
+ /** Block height for the onchain HTLC timeout. */
109
+ timeoutBlockHeight?: number;
107
110
  /** Block heights for various timeout/refund scenarios. */
108
- timeoutBlockHeights: TimeoutBlockHeights;
111
+ timeoutBlockHeights?: TimeoutBlockHeights;
109
112
  };
110
113
  type GetSwapPreimageResponse = {
111
114
  preimage: string;
@@ -128,13 +131,15 @@ type CreateReverseSwapResponse = {
128
131
  /** BOLT11-encoded Lightning invoice to be paid. */
129
132
  invoice: string;
130
133
  /** On-chain amount in satoshis (after Boltz fees). */
131
- onchainAmount: number;
134
+ onchainAmount?: number;
132
135
  /** ARK lockup address where Boltz will lock funds. */
133
- lockupAddress: string;
136
+ lockupAddress?: string;
134
137
  /** Boltz's public key for the refund path. */
135
- refundPublicKey: string;
138
+ refundPublicKey?: string;
139
+ /** Block height for the onchain HTLC timeout. */
140
+ timeoutBlockHeight?: number;
136
141
  /** Block heights for various timeout/refund scenarios. */
137
- timeoutBlockHeights: TimeoutBlockHeights;
142
+ timeoutBlockHeights?: TimeoutBlockHeights;
138
143
  };
139
144
  type SwapTree = {
140
145
  claimLeaf: {
@@ -223,10 +228,11 @@ type Leaf = {
223
228
  type Tree = {
224
229
  claimLeaf: Leaf;
225
230
  refundLeaf: Leaf;
226
- refundWithoutBoltzLeaf: Leaf;
227
- unilateralClaimLeaf: Leaf;
228
- unilateralRefundLeaf: Leaf;
229
- unilateralRefundWithoutBoltzLeaf: Leaf;
231
+ covenantClaimLeaf?: Leaf;
232
+ refundWithoutBoltzLeaf?: Leaf;
233
+ unilateralClaimLeaf?: Leaf;
234
+ unilateralRefundLeaf?: Leaf;
235
+ unilateralRefundWithoutBoltzLeaf?: Leaf;
230
236
  };
231
237
  type Details = {
232
238
  tree: Tree;
@@ -238,7 +244,7 @@ type Details = {
238
244
  };
239
245
  lockupAddress: string;
240
246
  serverPublicKey: string;
241
- timeoutBlockHeight: number;
247
+ timeoutBlockHeight?: number;
242
248
  timeoutBlockHeights?: TimeoutBlockHeights;
243
249
  preimageHash?: string;
244
250
  };
@@ -249,19 +255,10 @@ type RestoredChainSwap = {
249
255
  createdAt: number;
250
256
  from: "ARK" | "BTC";
251
257
  to: "ARK" | "BTC";
252
- preimageHash: string;
253
- refundDetails: {
254
- amount: number;
255
- keyIndex: number;
256
- lockupAddress: string;
257
- serverPublicKey: string;
258
- timeoutBlockHeight: number;
259
- transaction?: {
260
- id: string;
261
- vout: number;
262
- };
263
- tree: Tree;
264
- };
258
+ preimageHash?: string;
259
+ invoice?: string;
260
+ refundDetails?: Details;
261
+ claimDetails?: Details;
265
262
  };
266
263
  type RestoredSubmarineSwap = {
267
264
  to: "BTC";
@@ -269,7 +266,7 @@ type RestoredSubmarineSwap = {
269
266
  from: "ARK";
270
267
  type: "submarine";
271
268
  createdAt: number;
272
- preimageHash: string;
269
+ preimageHash?: string;
273
270
  status: BoltzSwapStatus;
274
271
  refundDetails: Details;
275
272
  invoice?: string;
@@ -280,7 +277,7 @@ type RestoredReverseSwap = {
280
277
  from: "BTC";
281
278
  type: "reverse";
282
279
  createdAt: number;
283
- preimageHash: string;
280
+ preimageHash?: string;
284
281
  status: BoltzSwapStatus;
285
282
  claimDetails: Details;
286
283
  invoice?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/boltz-swap",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "type": "module",
5
5
  "description": "A production-ready TypeScript package that brings Boltz submarine-swaps to Arkade.",
6
6
  "main": "./dist/index.js",