@arkade-os/boltz-swap 0.3.34 → 0.3.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1501,6 +1501,20 @@ function extractInvoiceAmount(amountSats, fees) {
1501
1501
  if (miner >= amountSats) return 0;
1502
1502
  return Math.ceil((amountSats - miner) / (1 - percentage / 100));
1503
1503
  }
1504
+ function resolveVhtlcTimeouts(tree, timeoutBlockHeights) {
1505
+ const resolved = timeoutBlockHeights ?? {
1506
+ refund: extractTimeLockFromLeafOutput(tree.refundWithoutBoltzLeaf?.output ?? ""),
1507
+ unilateralClaim: extractTimeLockFromLeafOutput(tree.unilateralClaimLeaf?.output ?? ""),
1508
+ unilateralRefund: extractTimeLockFromLeafOutput(tree.unilateralRefundLeaf?.output ?? ""),
1509
+ unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
1510
+ tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
1511
+ )
1512
+ };
1513
+ if (!resolved.refund || !resolved.unilateralClaim || !resolved.unilateralRefund || !resolved.unilateralRefundWithoutReceiver) {
1514
+ return void 0;
1515
+ }
1516
+ return resolved;
1517
+ }
1504
1518
 
1505
1519
  // src/logger.ts
1506
1520
  var logger = console;
@@ -1565,6 +1579,13 @@ var SwapManager = class _SwapManager {
1565
1579
  swapsInProgress = /* @__PURE__ */ new Set();
1566
1580
  // Per-swap subscriptions for UI hooks
1567
1581
  swapSubscriptions = /* @__PURE__ */ new Map();
1582
+ // In-flight (or settled) chain-swap claim promises, keyed by swap id. The
1583
+ // manager performs chain claims itself, so the claim tx it broadcasts is
1584
+ // the swap's on-chain completion; getSwapStatus does not surface that txid
1585
+ // at transaction.claimed. resolveClaimedTxid awaits the stored promise so a
1586
+ // transaction.claimed update that races an in-flight claim still resolves
1587
+ // the real txid instead of falling back to the provider and failing.
1588
+ chainClaimPromises = /* @__PURE__ */ new Map();
1568
1589
  // Action callbacks (injected via setCallbacks)
1569
1590
  claimCallback = null;
1570
1591
  refundCallback = null;
@@ -1706,6 +1727,7 @@ var SwapManager = class _SwapManager {
1706
1727
  }
1707
1728
  this.isRunning = true;
1708
1729
  this.initialSwaps.clear();
1730
+ this.chainClaimPromises.clear();
1709
1731
  for (const swap of pendingSwaps) {
1710
1732
  this.initialSwaps.set(swap.id, swap);
1711
1733
  }
@@ -1799,6 +1821,7 @@ var SwapManager = class _SwapManager {
1799
1821
  async removeSwap(swapId) {
1800
1822
  this.monitoredSwaps.delete(swapId);
1801
1823
  this.swapSubscriptions.delete(swapId);
1824
+ this.chainClaimPromises.delete(swapId);
1802
1825
  const retryTimer = this.pollRetryTimers.get(swapId);
1803
1826
  if (retryTimer) {
1804
1827
  clearTimeout(retryTimer);
@@ -1841,9 +1864,14 @@ var SwapManager = class _SwapManager {
1841
1864
  * Blocks until the swap reaches a final status or fails.
1842
1865
  * Useful when you want blocking behavior even with SwapManager enabled.
1843
1866
  *
1844
- * @throws If the swap is already in a final status (submarine/chain swaps throw immediately;
1845
- * reverse swaps return the existing txid).
1867
+ * If the swap is already in a final status, resolves immediately with the
1868
+ * on-chain txid of the successfully claimed swap (reverse: from
1869
+ * getReverseSwapTxId; submarine/chain: from getSwapStatus) and throws for a
1870
+ * failed final status.
1871
+ *
1872
+ * @throws If the swap is already in a failed final status.
1846
1873
  * @throws If the swap is not found in the manager.
1874
+ * @throws If a completed swap has no transaction id available yet.
1847
1875
  */
1848
1876
  async waitForSwapCompletion(swapId) {
1849
1877
  let swap = this.monitoredSwaps.get(swapId);
@@ -1858,10 +1886,12 @@ var SwapManager = class _SwapManager {
1858
1886
  const response = await this.swapProvider.getReverseSwapTxId(swap.id);
1859
1887
  return { txid: response.id };
1860
1888
  }
1861
- if (isPendingSubmarineSwap(swap)) {
1862
- throw new Error("Submarine swap already completed");
1889
+ if (isPendingSubmarineSwap(swap) || isPendingChainSwap(swap)) {
1890
+ if (swap.status === "transaction.claimed") {
1891
+ return this.resolveClaimedTxid(swap.id);
1892
+ }
1893
+ throw new Error(`Swap ${swap.id} already in final status: ${swap.status}`);
1863
1894
  }
1864
- throw new Error("Chain swap already completed");
1865
1895
  }
1866
1896
  return new Promise((resolve, reject) => {
1867
1897
  let unsubscribe = null;
@@ -1876,13 +1906,13 @@ var SwapManager = class _SwapManager {
1876
1906
  }
1877
1907
  } else if (isPendingSubmarineSwap(updatedSwap)) {
1878
1908
  if (updatedSwap.status === "transaction.claimed") {
1879
- resolve({ txid: updatedSwap.id });
1909
+ this.resolveClaimedTxid(updatedSwap.id).then(resolve).catch(reject);
1880
1910
  } else {
1881
1911
  reject(new Error(`Swap failed with status: ${updatedSwap.status}`));
1882
1912
  }
1883
1913
  } else if (isPendingChainSwap(updatedSwap)) {
1884
1914
  if (updatedSwap.status === "transaction.claimed") {
1885
- resolve({ txid: updatedSwap.id });
1915
+ this.resolveClaimedTxid(updatedSwap.id).then(resolve).catch(reject);
1886
1916
  } else {
1887
1917
  reject(new Error(`Swap failed with status: ${updatedSwap.status}`));
1888
1918
  }
@@ -1893,6 +1923,37 @@ var SwapManager = class _SwapManager {
1893
1923
  }).catch(reject);
1894
1924
  });
1895
1925
  }
1926
+ /**
1927
+ * Resolve the on-chain txid for a claimed submarine/chain swap.
1928
+ *
1929
+ * Chain swaps are claimed by the manager itself, so the claim txid captured
1930
+ * from the claimArk/claimBtc callback is the swap's on-chain completion and
1931
+ * is preferred — Boltz does not surface it via getSwapStatus at
1932
+ * transaction.claimed. Submarine swaps (claimed by Boltz) and chain swaps
1933
+ * we never claimed in this session (e.g. restored already-claimed) fall
1934
+ * back to the provider status. Rejects when no transaction id is available,
1935
+ * so callers never receive the Boltz swap id in place of a real txid.
1936
+ */
1937
+ async resolveClaimedTxid(swapId) {
1938
+ const claimPromise = this.chainClaimPromises.get(swapId);
1939
+ if (claimPromise) {
1940
+ const claimTxid = await claimPromise.then(
1941
+ (result) => result?.txid,
1942
+ () => void 0
1943
+ );
1944
+ if (claimTxid && claimTxid.trim() !== "") {
1945
+ return { txid: claimTxid };
1946
+ }
1947
+ }
1948
+ const status = await this.swapProvider.getSwapStatus(swapId);
1949
+ const txid = status.transaction?.id;
1950
+ if (!txid || txid.trim() === "") {
1951
+ throw new SwapError({
1952
+ message: `Transaction ID not available for completed swap ${swapId}`
1953
+ });
1954
+ }
1955
+ return { txid };
1956
+ }
1896
1957
  /**
1897
1958
  * Check if a swap is currently being processed
1898
1959
  * Useful for preventing race conditions
@@ -2096,6 +2157,7 @@ var SwapManager = class _SwapManager {
2096
2157
  if (!this.monitoredSwaps.has(swap.id)) return;
2097
2158
  this.monitoredSwaps.delete(swap.id);
2098
2159
  this.swapSubscriptions.delete(swap.id);
2160
+ this.chainClaimPromises.delete(swap.id);
2099
2161
  const retryTimer = this.pollRetryTimers.get(swap.id);
2100
2162
  if (retryTimer) {
2101
2163
  clearTimeout(retryTimer);
@@ -2266,7 +2328,9 @@ var SwapManager = class _SwapManager {
2266
2328
  logger.error("claimArk callback not set");
2267
2329
  return;
2268
2330
  }
2269
- await this.claimArkCallback(swap);
2331
+ const claimPromise = this.claimArkCallback(swap);
2332
+ this.rememberChainClaim(swap.id, claimPromise);
2333
+ await claimPromise;
2270
2334
  }
2271
2335
  /**
2272
2336
  * Execute claim action for chain swap Ark to Btc
@@ -2276,7 +2340,23 @@ var SwapManager = class _SwapManager {
2276
2340
  logger.error("claimBtc callback not set");
2277
2341
  return;
2278
2342
  }
2279
- await this.claimBtcCallback(swap);
2343
+ const claimPromise = this.claimBtcCallback(swap);
2344
+ this.rememberChainClaim(swap.id, claimPromise);
2345
+ await claimPromise;
2346
+ }
2347
+ /**
2348
+ * Store the in-flight claim promise returned by a claim callback so
2349
+ * {@link resolveClaimedTxid} can await it and surface the real on-chain
2350
+ * txid at transaction.claimed — even when that update races the still
2351
+ * in-flight claim. Storing the promise (not the resolved txid) closes the
2352
+ * window where the txid is not yet captured when transaction.claimed
2353
+ * arrives. Defensive against callbacks that don't return a promise (older
2354
+ * integrations, test doubles): those simply fall back to getSwapStatus.
2355
+ */
2356
+ rememberChainClaim(swapId, claimPromise) {
2357
+ if (claimPromise) {
2358
+ this.chainClaimPromises.set(swapId, claimPromise);
2359
+ }
2280
2360
  }
2281
2361
  /**
2282
2362
  * Execute refund action for chain swap Ark to Btc
@@ -3070,6 +3150,7 @@ var claimVHTLCwithOffchainTx = async (identity, vhtlcScript, serverXOnlyPublicKe
3070
3150
  })
3071
3151
  );
3072
3152
  await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
3153
+ return arkTxid;
3073
3154
  };
3074
3155
  var refundVHTLCwithOffchainTx = async (swapId, identity, arkProvider, boltzXOnlyPublicKey, ourXOnlyPublicKey, serverXOnlyPublicKey, input, output, arkInfo, refundFunc) => {
3075
3156
  const rawCheckpointTapscript = import_base8.hex.decode(arkInfo.checkpointTapscript);
@@ -3228,12 +3309,8 @@ var ArkadeSwaps = class _ArkadeSwaps {
3228
3309
  refund: async (swap) => {
3229
3310
  await this.refundVHTLC(swap);
3230
3311
  },
3231
- claimArk: async (swap) => {
3232
- await this.claimArk(swap);
3233
- },
3234
- claimBtc: async (swap) => {
3235
- await this.claimBtc(swap);
3236
- },
3312
+ claimArk: (swap) => this.claimArk(swap),
3313
+ claimBtc: (swap) => this.claimBtc(swap),
3237
3314
  refundArk: async (swap) => {
3238
3315
  return this.refundArk(swap);
3239
3316
  },
@@ -4244,6 +4321,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4244
4321
  }
4245
4322
  return new Promise((resolve, reject) => {
4246
4323
  let claimStarted = false;
4324
+ let claimPromise;
4247
4325
  const swap = { ...pendingSwap };
4248
4326
  const onStatusUpdate = async (status, data) => {
4249
4327
  const updateSwapStatus = async () => {
@@ -4261,16 +4339,24 @@ var ArkadeSwaps = class _ArkadeSwaps {
4261
4339
  const updatedSwap = await updateSwapStatus();
4262
4340
  if (claimStarted) return;
4263
4341
  claimStarted = true;
4264
- this.claimBtc(updatedSwap).catch(reject);
4342
+ claimPromise = this.claimBtc(updatedSwap);
4343
+ claimPromise.catch(reject);
4265
4344
  break;
4266
4345
  }
4267
- case "transaction.claimed":
4346
+ case "transaction.claimed": {
4268
4347
  await updateSwapStatus();
4269
- const claimedStatus = await this.getSwapStatus(pendingSwap.id);
4270
- resolve({
4271
- txid: claimedStatus.transaction?.id ?? ""
4272
- });
4348
+ const txid = await this.resolveChainClaimTxid(pendingSwap.id, claimPromise);
4349
+ if (!txid) {
4350
+ reject(
4351
+ new SwapError({
4352
+ message: `Transaction ID not available for claimed swap ${pendingSwap.id}.`
4353
+ })
4354
+ );
4355
+ break;
4356
+ }
4357
+ resolve({ txid });
4273
4358
  break;
4359
+ }
4274
4360
  case "transaction.lockupFailed":
4275
4361
  await updateSwapStatus();
4276
4362
  await this.quoteSwap(swap.response.id, quoteOptionsForSwap(swap)).catch(
@@ -4319,6 +4405,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4319
4405
  /**
4320
4406
  * Claim sats on BTC chain by claiming the HTLC.
4321
4407
  * @param pendingSwap - The pending chain swap with BTC transaction hex.
4408
+ * @returns The BTC transaction ID of the claim.
4322
4409
  */
4323
4410
  async claimBtc(pendingSwap) {
4324
4411
  if (!pendingSwap.toAddress)
@@ -4391,6 +4478,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4391
4478
  finalScriptWitness: [musigSigned.aggregatePartials()]
4392
4479
  });
4393
4480
  await this.swapProvider.postBtcTransaction(claimTx.hex);
4481
+ return { txid: claimTx.id };
4394
4482
  }
4395
4483
  /**
4396
4484
  * When an ARK to BTC swap fails, refund every unspent VTXO at the chain
@@ -4590,6 +4678,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4590
4678
  }
4591
4679
  return new Promise((resolve, reject) => {
4592
4680
  let claimStarted = false;
4681
+ let claimPromise;
4593
4682
  const swap = { ...pendingSwap };
4594
4683
  const onStatusUpdate = async (status, data) => {
4595
4684
  const updateSwapStatus = () => {
@@ -4602,15 +4691,23 @@ var ArkadeSwaps = class _ArkadeSwaps {
4602
4691
  await updateSwapStatus();
4603
4692
  if (claimStarted) return;
4604
4693
  claimStarted = true;
4605
- this.claimArk(swap).catch(reject);
4694
+ claimPromise = this.claimArk(swap);
4695
+ claimPromise.catch(reject);
4606
4696
  break;
4607
- case "transaction.claimed":
4697
+ case "transaction.claimed": {
4608
4698
  await updateSwapStatus();
4609
- const claimedStatus = await this.getSwapStatus(pendingSwap.id);
4610
- resolve({
4611
- txid: claimedStatus.transaction?.id ?? ""
4612
- });
4699
+ const txid = await this.resolveChainClaimTxid(pendingSwap.id, claimPromise);
4700
+ if (!txid) {
4701
+ reject(
4702
+ new SwapError({
4703
+ message: `Transaction ID not available for claimed swap ${pendingSwap.id}.`
4704
+ })
4705
+ );
4706
+ break;
4707
+ }
4708
+ resolve({ txid });
4613
4709
  break;
4710
+ }
4614
4711
  case "transaction.claim.pending":
4615
4712
  await updateSwapStatus();
4616
4713
  await this.signCooperativeClaimForServer(swap).catch((err) => {
@@ -4669,6 +4766,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4669
4766
  * Claim sats on ARK chain by claiming the VHTLC.
4670
4767
  * Refactored to use claimVHTLCIdentity + claimVHTLCwithOffchainTx utilities.
4671
4768
  * @param pendingSwap - The pending chain swap.
4769
+ * @returns The Ark transaction ID of the claim.
4672
4770
  */
4673
4771
  async claimArk(pendingSwap) {
4674
4772
  if (!pendingSwap.toAddress)
@@ -4731,24 +4829,42 @@ var ArkadeSwaps = class _ArkadeSwaps {
4731
4829
  script: import_sdk8.ArkAddress.decode(address).pkScript
4732
4830
  };
4733
4831
  const vhtlcIdentity = claimVHTLCIdentity(this.wallet.identity, preimage);
4734
- if ((0, import_sdk8.isRecoverable)(vtxo)) {
4735
- await this.joinBatch(vhtlcIdentity, input, output, arkInfo);
4736
- } else {
4737
- await claimVHTLCwithOffchainTx(
4738
- vhtlcIdentity,
4739
- vhtlcScript,
4740
- serverXOnlyPublicKey,
4741
- input,
4742
- output,
4743
- arkInfo,
4744
- this.arkProvider
4745
- );
4746
- }
4832
+ const txid = (0, import_sdk8.isRecoverable)(vtxo) ? await this.joinBatch(vhtlcIdentity, input, output, arkInfo) : await claimVHTLCwithOffchainTx(
4833
+ vhtlcIdentity,
4834
+ vhtlcScript,
4835
+ serverXOnlyPublicKey,
4836
+ input,
4837
+ output,
4838
+ arkInfo,
4839
+ this.arkProvider
4840
+ );
4747
4841
  const finalStatus = await this.getSwapStatus(pendingSwap.id);
4748
4842
  await this.savePendingChainSwap({
4749
4843
  ...pendingSwap,
4750
4844
  status: finalStatus.status
4751
4845
  });
4846
+ return { txid };
4847
+ }
4848
+ /**
4849
+ * Resolve the on-chain txid for a chain swap at completion.
4850
+ *
4851
+ * The claim transaction we broadcast (claimBtc/claimArk) carries the real
4852
+ * on-chain txid; getSwapStatus does not surface it at transaction.claimed.
4853
+ * Prefer the claim's txid and fall back to the provider status only for
4854
+ * resumed swaps where we never ran the claim ourselves (claimPromise is
4855
+ * undefined). Returns undefined when no usable txid is available, so
4856
+ * callers never resolve with the Boltz swap id in place of a real txid.
4857
+ */
4858
+ async resolveChainClaimTxid(swapId, claimPromise) {
4859
+ if (claimPromise) {
4860
+ const claimTxid = await claimPromise.then(
4861
+ (res) => res.txid,
4862
+ () => void 0
4863
+ );
4864
+ if (claimTxid && claimTxid.trim() !== "") return claimTxid;
4865
+ }
4866
+ const txid = (await this.getSwapStatus(swapId)).transaction?.id;
4867
+ return txid && txid.trim() !== "" ? txid : void 0;
4752
4868
  }
4753
4869
  /**
4754
4870
  * Sign a cooperative claim for the server in BTC => ARK swaps.
@@ -5192,20 +5308,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
5192
5308
  onchainAmount: amount,
5193
5309
  lockupAddress,
5194
5310
  refundPublicKey: serverPublicKey,
5195
- timeoutBlockHeights: timeoutBlockHeights ?? {
5196
- refund: extractTimeLockFromLeafOutput(
5197
- tree.refundWithoutBoltzLeaf?.output ?? ""
5198
- ),
5199
- unilateralClaim: extractTimeLockFromLeafOutput(
5200
- tree.unilateralClaimLeaf?.output ?? ""
5201
- ),
5202
- unilateralRefund: extractTimeLockFromLeafOutput(
5203
- tree.unilateralRefundLeaf?.output ?? ""
5204
- ),
5205
- unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
5206
- tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
5207
- )
5208
- }
5311
+ timeoutBlockHeights: resolveVhtlcTimeouts(tree, timeoutBlockHeights)
5209
5312
  },
5210
5313
  status,
5211
5314
  type: "reverse",
@@ -5238,26 +5341,20 @@ var ArkadeSwaps = class _ArkadeSwaps {
5238
5341
  address: lockupAddress,
5239
5342
  expectedAmount: amount,
5240
5343
  claimPublicKey: serverPublicKey,
5241
- timeoutBlockHeights: timeoutBlockHeights ?? {
5242
- refund: extractTimeLockFromLeafOutput(
5243
- tree.refundWithoutBoltzLeaf?.output ?? ""
5244
- ),
5245
- unilateralClaim: extractTimeLockFromLeafOutput(
5246
- tree.unilateralClaimLeaf?.output ?? ""
5247
- ),
5248
- unilateralRefund: extractTimeLockFromLeafOutput(
5249
- tree.unilateralRefundLeaf?.output ?? ""
5250
- ),
5251
- unilateralRefundWithoutReceiver: extractTimeLockFromLeafOutput(
5252
- tree.unilateralRefundWithoutBoltzLeaf?.output ?? ""
5253
- )
5254
- }
5344
+ timeoutBlockHeights: resolveVhtlcTimeouts(tree, timeoutBlockHeights)
5255
5345
  }
5256
5346
  });
5257
5347
  } else if (isRestoredChainSwap(swap)) {
5258
5348
  const refundDetails = swap.refundDetails;
5259
5349
  if (!refundDetails) continue;
5260
- const { amount, lockupAddress, serverPublicKey, timeoutBlockHeight } = refundDetails;
5350
+ const {
5351
+ amount,
5352
+ lockupAddress,
5353
+ serverPublicKey,
5354
+ timeoutBlockHeight,
5355
+ tree,
5356
+ timeoutBlockHeights
5357
+ } = refundDetails;
5261
5358
  chainSwaps.push({
5262
5359
  id,
5263
5360
  type: "chain",
@@ -5283,7 +5380,8 @@ var ArkadeSwaps = class _ArkadeSwaps {
5283
5380
  amount,
5284
5381
  lockupAddress,
5285
5382
  serverPublicKey,
5286
- timeoutBlockHeight
5383
+ timeoutBlockHeight,
5384
+ timeouts: resolveVhtlcTimeouts(tree, timeoutBlockHeights)
5287
5385
  }
5288
5386
  }
5289
5387
  });
@@ -5647,12 +5745,14 @@ var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
5647
5745
  payload: res
5648
5746
  });
5649
5747
  }
5650
- case "CLAIM_ARK":
5651
- await this.handler.claimArk(message.payload);
5652
- return this.tagged({ id, type: "ARK_CLAIM_EXECUTED" });
5653
- case "CLAIM_BTC":
5654
- await this.handler.claimBtc(message.payload);
5655
- return this.tagged({ id, type: "BTC_CLAIM_EXECUTED" });
5748
+ case "CLAIM_ARK": {
5749
+ const res = await this.handler.claimArk(message.payload);
5750
+ return this.tagged({ id, type: "ARK_CLAIM_EXECUTED", payload: res });
5751
+ }
5752
+ case "CLAIM_BTC": {
5753
+ const res = await this.handler.claimBtc(message.payload);
5754
+ return this.tagged({ id, type: "BTC_CLAIM_EXECUTED", payload: res });
5755
+ }
5656
5756
  case "REFUND_ARK": {
5657
5757
  const outcome = await this.handler.refundArk(message.payload);
5658
5758
  return this.tagged({
@@ -6319,20 +6419,22 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
6319
6419
  }
6320
6420
  }
6321
6421
  async claimArk(pendingSwap) {
6322
- await this.sendMessage({
6422
+ const res = await this.sendMessage({
6323
6423
  id: (0, import_sdk10.getRandomId)(),
6324
6424
  tag: this.messageTag,
6325
6425
  type: "CLAIM_ARK",
6326
6426
  payload: pendingSwap
6327
6427
  });
6428
+ return res.payload;
6328
6429
  }
6329
6430
  async claimBtc(pendingSwap) {
6330
- await this.sendMessage({
6431
+ const res = await this.sendMessage({
6331
6432
  id: (0, import_sdk10.getRandomId)(),
6332
6433
  tag: this.messageTag,
6333
6434
  type: "CLAIM_BTC",
6334
6435
  payload: pendingSwap
6335
6436
  });
6437
+ return res.payload;
6336
6438
  }
6337
6439
  async refundArk(pendingSwap) {
6338
6440
  const res = await this.sendMessage({
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-CfMets16.cjs';
2
- export { A as ArkadeSwaps } from './arkade-swaps-CfMets16.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 SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as ChainArkRefundOutcome, n as SwapRepository, o as SwapManagerClient, p as GetSwapsFilter } from './types--axEWA8c.cjs';
4
- export { q as ArkadeSwapsCreateConfig, r as BoltzSwapProvider, s as BoltzSwapStatus, I as IncomingPaymentSubscription, P as PendingChainSwap, t as PendingReverseSwap, u as PendingSubmarineSwap, v as PendingSwap, w as SubmarineRecoveryStatus, x as SwapManager, y as SwapManagerCallbacks, z as SwapManagerConfig, E as SwapManagerEvents, V as Vtxo, H as isChainClaimableStatus, J as isChainFailedStatus, K as isChainFinalStatus, M as isChainPendingStatus, O as isChainRefundableStatus, Q as isChainSignableStatus, R as isChainSuccessStatus, T as isChainSwapClaimable, U as isChainSwapRefundable, W as isPendingChainSwap, X as isPendingReverseSwap, Y as isPendingSubmarineSwap, Z as isReverseClaimableStatus, _ as isReverseFailedStatus, $ as isReverseFinalStatus, a0 as isReversePendingStatus, a1 as isReverseSuccessStatus, a2 as isReverseSwapClaimable, a3 as isSubmarineFailedStatus, a4 as isSubmarineFinalStatus, a5 as isSubmarinePendingStatus, a6 as isSubmarineRefundableStatus, a7 as isSubmarineSuccessStatus, a8 as isSubmarineSwapRefundable } from './types--axEWA8c.cjs';
1
+ import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-DG9UepoS.cjs';
2
+ export { A as ArkadeSwaps } from './arkade-swaps-DG9UepoS.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 SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as ChainArkRefundOutcome, n as SwapRepository, o as SwapManagerClient, p as GetSwapsFilter } from './types-D97i1LFu.cjs';
4
+ export { q as ArkadeSwapsCreateConfig, r as BoltzSwapProvider, s as BoltzSwapStatus, I as IncomingPaymentSubscription, P as PendingChainSwap, t as PendingReverseSwap, u as PendingSubmarineSwap, v as PendingSwap, w as SubmarineRecoveryStatus, x as SwapManager, y as SwapManagerCallbacks, z as SwapManagerConfig, E as SwapManagerEvents, V as Vtxo, H as isChainClaimableStatus, J as isChainFailedStatus, K as isChainFinalStatus, M as isChainPendingStatus, O as isChainRefundableStatus, Q as isChainSignableStatus, R as isChainSuccessStatus, T as isChainSwapClaimable, U as isChainSwapRefundable, W as isPendingChainSwap, X as isPendingReverseSwap, Y as isPendingSubmarineSwap, Z as isReverseClaimableStatus, _ as isReverseFailedStatus, $ as isReverseFinalStatus, a0 as isReversePendingStatus, a1 as isReverseSuccessStatus, a2 as isReverseSwapClaimable, a3 as isSubmarineFailedStatus, a4 as isSubmarineFinalStatus, a5 as isSubmarinePendingStatus, a6 as isSubmarineRefundableStatus, a7 as isSubmarineSuccessStatus, a8 as isSubmarineSwapRefundable } from './types-D97i1LFu.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';
@@ -485,6 +485,9 @@ type RequestClaimArk = RequestEnvelope & {
485
485
  };
486
486
  type ResponseClaimArk = ResponseEnvelope & {
487
487
  type: "ARK_CLAIM_EXECUTED";
488
+ payload: {
489
+ txid: string;
490
+ };
488
491
  };
489
492
  type RequestClaimBtc = RequestEnvelope & {
490
493
  type: "CLAIM_BTC";
@@ -492,6 +495,9 @@ type RequestClaimBtc = RequestEnvelope & {
492
495
  };
493
496
  type ResponseClaimBtc = ResponseEnvelope & {
494
497
  type: "BTC_CLAIM_EXECUTED";
498
+ payload: {
499
+ txid: string;
500
+ };
495
501
  };
496
502
  type RequestRefundArk = RequestEnvelope & {
497
503
  type: "REFUND_ARK";
@@ -751,8 +757,12 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
751
757
  waitAndClaimBtc(pendingSwap: BoltzChainSwap): Promise<{
752
758
  txid: string;
753
759
  }>;
754
- claimArk(pendingSwap: BoltzChainSwap): Promise<void>;
755
- claimBtc(pendingSwap: BoltzChainSwap): Promise<void>;
760
+ claimArk(pendingSwap: BoltzChainSwap): Promise<{
761
+ txid: string;
762
+ }>;
763
+ claimBtc(pendingSwap: BoltzChainSwap): Promise<{
764
+ txid: string;
765
+ }>;
756
766
  refundArk(pendingSwap: BoltzChainSwap): Promise<ChainArkRefundOutcome>;
757
767
  signCooperativeClaimForServer(pendingSwap: BoltzChainSwap): Promise<void>;
758
768
  verifyChainSwap(args: {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-BXAD1s8j.js';
2
- export { A as ArkadeSwaps } from './arkade-swaps-BXAD1s8j.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 SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as ChainArkRefundOutcome, n as SwapRepository, o as SwapManagerClient, p as GetSwapsFilter } from './types--axEWA8c.js';
4
- export { q as ArkadeSwapsCreateConfig, r as BoltzSwapProvider, s as BoltzSwapStatus, I as IncomingPaymentSubscription, P as PendingChainSwap, t as PendingReverseSwap, u as PendingSubmarineSwap, v as PendingSwap, w as SubmarineRecoveryStatus, x as SwapManager, y as SwapManagerCallbacks, z as SwapManagerConfig, E as SwapManagerEvents, V as Vtxo, H as isChainClaimableStatus, J as isChainFailedStatus, K as isChainFinalStatus, M as isChainPendingStatus, O as isChainRefundableStatus, Q as isChainSignableStatus, R as isChainSuccessStatus, T as isChainSwapClaimable, U as isChainSwapRefundable, W as isPendingChainSwap, X as isPendingReverseSwap, Y as isPendingSubmarineSwap, Z as isReverseClaimableStatus, _ as isReverseFailedStatus, $ as isReverseFinalStatus, a0 as isReversePendingStatus, a1 as isReverseSuccessStatus, a2 as isReverseSwapClaimable, a3 as isSubmarineFailedStatus, a4 as isSubmarineFinalStatus, a5 as isSubmarinePendingStatus, a6 as isSubmarineRefundableStatus, a7 as isSubmarineSuccessStatus, a8 as isSubmarineSwapRefundable } from './types--axEWA8c.js';
1
+ import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-Uet3tgN6.js';
2
+ export { A as ArkadeSwaps } from './arkade-swaps-Uet3tgN6.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 SubmarineRefundOutcome, h as SubmarineRecoveryInfo, i as SubmarineRecoveryResult, j as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, k as ArkToBtcResponse, l as BtcToArkResponse, m as ChainArkRefundOutcome, n as SwapRepository, o as SwapManagerClient, p as GetSwapsFilter } from './types-D97i1LFu.js';
4
+ export { q as ArkadeSwapsCreateConfig, r as BoltzSwapProvider, s as BoltzSwapStatus, I as IncomingPaymentSubscription, P as PendingChainSwap, t as PendingReverseSwap, u as PendingSubmarineSwap, v as PendingSwap, w as SubmarineRecoveryStatus, x as SwapManager, y as SwapManagerCallbacks, z as SwapManagerConfig, E as SwapManagerEvents, V as Vtxo, H as isChainClaimableStatus, J as isChainFailedStatus, K as isChainFinalStatus, M as isChainPendingStatus, O as isChainRefundableStatus, Q as isChainSignableStatus, R as isChainSuccessStatus, T as isChainSwapClaimable, U as isChainSwapRefundable, W as isPendingChainSwap, X as isPendingReverseSwap, Y as isPendingSubmarineSwap, Z as isReverseClaimableStatus, _ as isReverseFailedStatus, $ as isReverseFinalStatus, a0 as isReversePendingStatus, a1 as isReverseSuccessStatus, a2 as isReverseSwapClaimable, a3 as isSubmarineFailedStatus, a4 as isSubmarineFinalStatus, a5 as isSubmarinePendingStatus, a6 as isSubmarineRefundableStatus, a7 as isSubmarineSuccessStatus, a8 as isSubmarineSwapRefundable } from './types-D97i1LFu.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';
@@ -485,6 +485,9 @@ type RequestClaimArk = RequestEnvelope & {
485
485
  };
486
486
  type ResponseClaimArk = ResponseEnvelope & {
487
487
  type: "ARK_CLAIM_EXECUTED";
488
+ payload: {
489
+ txid: string;
490
+ };
488
491
  };
489
492
  type RequestClaimBtc = RequestEnvelope & {
490
493
  type: "CLAIM_BTC";
@@ -492,6 +495,9 @@ type RequestClaimBtc = RequestEnvelope & {
492
495
  };
493
496
  type ResponseClaimBtc = ResponseEnvelope & {
494
497
  type: "BTC_CLAIM_EXECUTED";
498
+ payload: {
499
+ txid: string;
500
+ };
495
501
  };
496
502
  type RequestRefundArk = RequestEnvelope & {
497
503
  type: "REFUND_ARK";
@@ -751,8 +757,12 @@ declare class ServiceWorkerArkadeSwaps implements IArkadeSwaps {
751
757
  waitAndClaimBtc(pendingSwap: BoltzChainSwap): Promise<{
752
758
  txid: string;
753
759
  }>;
754
- claimArk(pendingSwap: BoltzChainSwap): Promise<void>;
755
- claimBtc(pendingSwap: BoltzChainSwap): Promise<void>;
760
+ claimArk(pendingSwap: BoltzChainSwap): Promise<{
761
+ txid: string;
762
+ }>;
763
+ claimBtc(pendingSwap: BoltzChainSwap): Promise<{
764
+ txid: string;
765
+ }>;
756
766
  refundArk(pendingSwap: BoltzChainSwap): Promise<ChainArkRefundOutcome>;
757
767
  signCooperativeClaimForServer(pendingSwap: BoltzChainSwap): Promise<void>;
758
768
  verifyChainSwap(args: {
package/dist/index.js CHANGED
@@ -52,7 +52,7 @@ import {
52
52
  updateReverseSwapStatus,
53
53
  updateSubmarineSwapStatus,
54
54
  verifySignatures
55
- } from "./chunk-TDBUZE4N.js";
55
+ } from "./chunk-CFB2NNGT.js";
56
56
  import {
57
57
  applyCreatedAtOrder,
58
58
  applySwapsFilter
@@ -400,12 +400,14 @@ var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
400
400
  payload: res
401
401
  });
402
402
  }
403
- case "CLAIM_ARK":
404
- await this.handler.claimArk(message.payload);
405
- return this.tagged({ id, type: "ARK_CLAIM_EXECUTED" });
406
- case "CLAIM_BTC":
407
- await this.handler.claimBtc(message.payload);
408
- return this.tagged({ id, type: "BTC_CLAIM_EXECUTED" });
403
+ case "CLAIM_ARK": {
404
+ const res = await this.handler.claimArk(message.payload);
405
+ return this.tagged({ id, type: "ARK_CLAIM_EXECUTED", payload: res });
406
+ }
407
+ case "CLAIM_BTC": {
408
+ const res = await this.handler.claimBtc(message.payload);
409
+ return this.tagged({ id, type: "BTC_CLAIM_EXECUTED", payload: res });
410
+ }
409
411
  case "REFUND_ARK": {
410
412
  const outcome = await this.handler.refundArk(message.payload);
411
413
  return this.tagged({
@@ -1076,20 +1078,22 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
1076
1078
  }
1077
1079
  }
1078
1080
  async claimArk(pendingSwap) {
1079
- await this.sendMessage({
1081
+ const res = await this.sendMessage({
1080
1082
  id: getRandomId(),
1081
1083
  tag: this.messageTag,
1082
1084
  type: "CLAIM_ARK",
1083
1085
  payload: pendingSwap
1084
1086
  });
1087
+ return res.payload;
1085
1088
  }
1086
1089
  async claimBtc(pendingSwap) {
1087
- await this.sendMessage({
1090
+ const res = await this.sendMessage({
1088
1091
  id: getRandomId(),
1089
1092
  tag: this.messageTag,
1090
1093
  type: "CLAIM_BTC",
1091
1094
  payload: pendingSwap
1092
1095
  });
1096
+ return res.payload;
1093
1097
  }
1094
1098
  async refundArk(pendingSwap) {
1095
1099
  const res = await this.sendMessage({
@@ -1,5 +1,5 @@
1
1
  import { RealmLike } from '@arkade-os/sdk/repositories/realm';
2
- import { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types--axEWA8c.cjs';
2
+ import { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-D97i1LFu.cjs';
3
3
  import '@arkade-os/sdk';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { RealmLike } from '@arkade-os/sdk/repositories/realm';
2
- import { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types--axEWA8c.js';
2
+ import { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-D97i1LFu.js';
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 { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types--axEWA8c.cjs';
2
+ import { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-D97i1LFu.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 { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types--axEWA8c.js';
2
+ import { n as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-D97i1LFu.js';
3
3
  import '@arkade-os/sdk';
4
4
 
5
5
  /**
@@ -1,6 +1,6 @@
1
1
  import { AsyncStorageTaskQueue, TaskProcessor } from '@arkade-os/sdk/worker/expo';
2
2
  import { Identity, ArkProvider, IndexerProvider, IWallet } from '@arkade-os/sdk';
3
- import { n as SwapRepository, N as Network, r as BoltzSwapProvider, A as ArkadeSwapsConfig } from './types--axEWA8c.cjs';
3
+ import { n as SwapRepository, N as Network, r as BoltzSwapProvider, A as ArkadeSwapsConfig } from './types-D97i1LFu.cjs';
4
4
 
5
5
  /**
6
6
  * Dependencies injected into every swap processor at runtime.