@arkade-os/boltz-swap 0.3.35 → 0.3.37

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
@@ -1579,6 +1579,13 @@ var SwapManager = class _SwapManager {
1579
1579
  swapsInProgress = /* @__PURE__ */ new Set();
1580
1580
  // Per-swap subscriptions for UI hooks
1581
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();
1582
1589
  // Action callbacks (injected via setCallbacks)
1583
1590
  claimCallback = null;
1584
1591
  refundCallback = null;
@@ -1720,6 +1727,7 @@ var SwapManager = class _SwapManager {
1720
1727
  }
1721
1728
  this.isRunning = true;
1722
1729
  this.initialSwaps.clear();
1730
+ this.chainClaimPromises.clear();
1723
1731
  for (const swap of pendingSwaps) {
1724
1732
  this.initialSwaps.set(swap.id, swap);
1725
1733
  }
@@ -1813,6 +1821,7 @@ var SwapManager = class _SwapManager {
1813
1821
  async removeSwap(swapId) {
1814
1822
  this.monitoredSwaps.delete(swapId);
1815
1823
  this.swapSubscriptions.delete(swapId);
1824
+ this.chainClaimPromises.delete(swapId);
1816
1825
  const retryTimer = this.pollRetryTimers.get(swapId);
1817
1826
  if (retryTimer) {
1818
1827
  clearTimeout(retryTimer);
@@ -1855,9 +1864,14 @@ var SwapManager = class _SwapManager {
1855
1864
  * Blocks until the swap reaches a final status or fails.
1856
1865
  * Useful when you want blocking behavior even with SwapManager enabled.
1857
1866
  *
1858
- * @throws If the swap is already in a final status (submarine/chain swaps throw immediately;
1859
- * 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.
1860
1873
  * @throws If the swap is not found in the manager.
1874
+ * @throws If a completed swap has no transaction id available yet.
1861
1875
  */
1862
1876
  async waitForSwapCompletion(swapId) {
1863
1877
  let swap = this.monitoredSwaps.get(swapId);
@@ -1872,10 +1886,12 @@ var SwapManager = class _SwapManager {
1872
1886
  const response = await this.swapProvider.getReverseSwapTxId(swap.id);
1873
1887
  return { txid: response.id };
1874
1888
  }
1875
- if (isPendingSubmarineSwap(swap)) {
1876
- 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}`);
1877
1894
  }
1878
- throw new Error("Chain swap already completed");
1879
1895
  }
1880
1896
  return new Promise((resolve, reject) => {
1881
1897
  let unsubscribe = null;
@@ -1890,13 +1906,13 @@ var SwapManager = class _SwapManager {
1890
1906
  }
1891
1907
  } else if (isPendingSubmarineSwap(updatedSwap)) {
1892
1908
  if (updatedSwap.status === "transaction.claimed") {
1893
- resolve({ txid: updatedSwap.id });
1909
+ this.resolveClaimedTxid(updatedSwap.id).then(resolve).catch(reject);
1894
1910
  } else {
1895
1911
  reject(new Error(`Swap failed with status: ${updatedSwap.status}`));
1896
1912
  }
1897
1913
  } else if (isPendingChainSwap(updatedSwap)) {
1898
1914
  if (updatedSwap.status === "transaction.claimed") {
1899
- resolve({ txid: updatedSwap.id });
1915
+ this.resolveClaimedTxid(updatedSwap.id).then(resolve).catch(reject);
1900
1916
  } else {
1901
1917
  reject(new Error(`Swap failed with status: ${updatedSwap.status}`));
1902
1918
  }
@@ -1907,6 +1923,37 @@ var SwapManager = class _SwapManager {
1907
1923
  }).catch(reject);
1908
1924
  });
1909
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
+ }
1910
1957
  /**
1911
1958
  * Check if a swap is currently being processed
1912
1959
  * Useful for preventing race conditions
@@ -2110,6 +2157,7 @@ var SwapManager = class _SwapManager {
2110
2157
  if (!this.monitoredSwaps.has(swap.id)) return;
2111
2158
  this.monitoredSwaps.delete(swap.id);
2112
2159
  this.swapSubscriptions.delete(swap.id);
2160
+ this.chainClaimPromises.delete(swap.id);
2113
2161
  const retryTimer = this.pollRetryTimers.get(swap.id);
2114
2162
  if (retryTimer) {
2115
2163
  clearTimeout(retryTimer);
@@ -2280,7 +2328,9 @@ var SwapManager = class _SwapManager {
2280
2328
  logger.error("claimArk callback not set");
2281
2329
  return;
2282
2330
  }
2283
- await this.claimArkCallback(swap);
2331
+ const claimPromise = this.claimArkCallback(swap);
2332
+ this.rememberChainClaim(swap.id, claimPromise);
2333
+ await claimPromise;
2284
2334
  }
2285
2335
  /**
2286
2336
  * Execute claim action for chain swap Ark to Btc
@@ -2290,7 +2340,23 @@ var SwapManager = class _SwapManager {
2290
2340
  logger.error("claimBtc callback not set");
2291
2341
  return;
2292
2342
  }
2293
- 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
+ }
2294
2360
  }
2295
2361
  /**
2296
2362
  * Execute refund action for chain swap Ark to Btc
@@ -3084,6 +3150,7 @@ var claimVHTLCwithOffchainTx = async (identity, vhtlcScript, serverXOnlyPublicKe
3084
3150
  })
3085
3151
  );
3086
3152
  await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
3153
+ return arkTxid;
3087
3154
  };
3088
3155
  var refundVHTLCwithOffchainTx = async (swapId, identity, arkProvider, boltzXOnlyPublicKey, ourXOnlyPublicKey, serverXOnlyPublicKey, input, output, arkInfo, refundFunc) => {
3089
3156
  const rawCheckpointTapscript = import_base8.hex.decode(arkInfo.checkpointTapscript);
@@ -3242,12 +3309,8 @@ var ArkadeSwaps = class _ArkadeSwaps {
3242
3309
  refund: async (swap) => {
3243
3310
  await this.refundVHTLC(swap);
3244
3311
  },
3245
- claimArk: async (swap) => {
3246
- await this.claimArk(swap);
3247
- },
3248
- claimBtc: async (swap) => {
3249
- await this.claimBtc(swap);
3250
- },
3312
+ claimArk: (swap) => this.claimArk(swap),
3313
+ claimBtc: (swap) => this.claimBtc(swap),
3251
3314
  refundArk: async (swap) => {
3252
3315
  return this.refundArk(swap);
3253
3316
  },
@@ -4258,6 +4321,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4258
4321
  }
4259
4322
  return new Promise((resolve, reject) => {
4260
4323
  let claimStarted = false;
4324
+ let claimPromise;
4261
4325
  const swap = { ...pendingSwap };
4262
4326
  const onStatusUpdate = async (status, data) => {
4263
4327
  const updateSwapStatus = async () => {
@@ -4275,16 +4339,24 @@ var ArkadeSwaps = class _ArkadeSwaps {
4275
4339
  const updatedSwap = await updateSwapStatus();
4276
4340
  if (claimStarted) return;
4277
4341
  claimStarted = true;
4278
- this.claimBtc(updatedSwap).catch(reject);
4342
+ claimPromise = this.claimBtc(updatedSwap);
4343
+ claimPromise.catch(reject);
4279
4344
  break;
4280
4345
  }
4281
- case "transaction.claimed":
4346
+ case "transaction.claimed": {
4282
4347
  await updateSwapStatus();
4283
- const claimedStatus = await this.getSwapStatus(pendingSwap.id);
4284
- resolve({
4285
- txid: claimedStatus.transaction?.id ?? ""
4286
- });
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 });
4287
4358
  break;
4359
+ }
4288
4360
  case "transaction.lockupFailed":
4289
4361
  await updateSwapStatus();
4290
4362
  await this.quoteSwap(swap.response.id, quoteOptionsForSwap(swap)).catch(
@@ -4333,6 +4405,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4333
4405
  /**
4334
4406
  * Claim sats on BTC chain by claiming the HTLC.
4335
4407
  * @param pendingSwap - The pending chain swap with BTC transaction hex.
4408
+ * @returns The BTC transaction ID of the claim.
4336
4409
  */
4337
4410
  async claimBtc(pendingSwap) {
4338
4411
  if (!pendingSwap.toAddress)
@@ -4405,6 +4478,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4405
4478
  finalScriptWitness: [musigSigned.aggregatePartials()]
4406
4479
  });
4407
4480
  await this.swapProvider.postBtcTransaction(claimTx.hex);
4481
+ return { txid: claimTx.id };
4408
4482
  }
4409
4483
  /**
4410
4484
  * When an ARK to BTC swap fails, refund every unspent VTXO at the chain
@@ -4604,6 +4678,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4604
4678
  }
4605
4679
  return new Promise((resolve, reject) => {
4606
4680
  let claimStarted = false;
4681
+ let claimPromise;
4607
4682
  const swap = { ...pendingSwap };
4608
4683
  const onStatusUpdate = async (status, data) => {
4609
4684
  const updateSwapStatus = () => {
@@ -4616,15 +4691,23 @@ var ArkadeSwaps = class _ArkadeSwaps {
4616
4691
  await updateSwapStatus();
4617
4692
  if (claimStarted) return;
4618
4693
  claimStarted = true;
4619
- this.claimArk(swap).catch(reject);
4694
+ claimPromise = this.claimArk(swap);
4695
+ claimPromise.catch(reject);
4620
4696
  break;
4621
- case "transaction.claimed":
4697
+ case "transaction.claimed": {
4622
4698
  await updateSwapStatus();
4623
- const claimedStatus = await this.getSwapStatus(pendingSwap.id);
4624
- resolve({
4625
- txid: claimedStatus.transaction?.id ?? ""
4626
- });
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 });
4627
4709
  break;
4710
+ }
4628
4711
  case "transaction.claim.pending":
4629
4712
  await updateSwapStatus();
4630
4713
  await this.signCooperativeClaimForServer(swap).catch((err) => {
@@ -4683,6 +4766,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
4683
4766
  * Claim sats on ARK chain by claiming the VHTLC.
4684
4767
  * Refactored to use claimVHTLCIdentity + claimVHTLCwithOffchainTx utilities.
4685
4768
  * @param pendingSwap - The pending chain swap.
4769
+ * @returns The Ark transaction ID of the claim.
4686
4770
  */
4687
4771
  async claimArk(pendingSwap) {
4688
4772
  if (!pendingSwap.toAddress)
@@ -4745,24 +4829,42 @@ var ArkadeSwaps = class _ArkadeSwaps {
4745
4829
  script: import_sdk8.ArkAddress.decode(address).pkScript
4746
4830
  };
4747
4831
  const vhtlcIdentity = claimVHTLCIdentity(this.wallet.identity, preimage);
4748
- if ((0, import_sdk8.isRecoverable)(vtxo)) {
4749
- await this.joinBatch(vhtlcIdentity, input, output, arkInfo);
4750
- } else {
4751
- await claimVHTLCwithOffchainTx(
4752
- vhtlcIdentity,
4753
- vhtlcScript,
4754
- serverXOnlyPublicKey,
4755
- input,
4756
- output,
4757
- arkInfo,
4758
- this.arkProvider
4759
- );
4760
- }
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
+ );
4761
4841
  const finalStatus = await this.getSwapStatus(pendingSwap.id);
4762
4842
  await this.savePendingChainSwap({
4763
4843
  ...pendingSwap,
4764
4844
  status: finalStatus.status
4765
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;
4766
4868
  }
4767
4869
  /**
4768
4870
  * Sign a cooperative claim for the server in BTC => ARK swaps.
@@ -5643,12 +5745,14 @@ var ArkadeSwapsMessageHandler = class _ArkadeSwapsMessageHandler {
5643
5745
  payload: res
5644
5746
  });
5645
5747
  }
5646
- case "CLAIM_ARK":
5647
- await this.handler.claimArk(message.payload);
5648
- return this.tagged({ id, type: "ARK_CLAIM_EXECUTED" });
5649
- case "CLAIM_BTC":
5650
- await this.handler.claimBtc(message.payload);
5651
- 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
+ }
5652
5756
  case "REFUND_ARK": {
5653
5757
  const outcome = await this.handler.refundArk(message.payload);
5654
5758
  return this.tagged({
@@ -6315,20 +6419,22 @@ var ServiceWorkerArkadeSwaps = class _ServiceWorkerArkadeSwaps {
6315
6419
  }
6316
6420
  }
6317
6421
  async claimArk(pendingSwap) {
6318
- await this.sendMessage({
6422
+ const res = await this.sendMessage({
6319
6423
  id: (0, import_sdk10.getRandomId)(),
6320
6424
  tag: this.messageTag,
6321
6425
  type: "CLAIM_ARK",
6322
6426
  payload: pendingSwap
6323
6427
  });
6428
+ return res.payload;
6324
6429
  }
6325
6430
  async claimBtc(pendingSwap) {
6326
- await this.sendMessage({
6431
+ const res = await this.sendMessage({
6327
6432
  id: (0, import_sdk10.getRandomId)(),
6328
6433
  tag: this.messageTag,
6329
6434
  type: "CLAIM_BTC",
6330
6435
  payload: pendingSwap
6331
6436
  });
6437
+ return res.payload;
6332
6438
  }
6333
6439
  async refundArk(pendingSwap) {
6334
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-B4CYBKFJ.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.
@@ -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.js';
3
+ import { n as SwapRepository, N as Network, r as BoltzSwapProvider, A as ArkadeSwapsConfig } from './types-D97i1LFu.js';
4
4
 
5
5
  /**
6
6
  * Dependencies injected into every swap processor at runtime.