@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.
@@ -473,8 +473,23 @@ interface SwapManagerClient {
473
473
  interface SwapManagerCallbacks {
474
474
  claim: (swap: BoltzReverseSwap) => Promise<void>;
475
475
  refund: (swap: BoltzSubmarineSwap) => Promise<void>;
476
- claimArk: (swap: BoltzChainSwap) => Promise<void>;
477
- claimBtc: (swap: BoltzChainSwap) => Promise<void>;
476
+ /**
477
+ * Claim the ARK side of a BTC→ARK chain swap.
478
+ *
479
+ * Returns the on-chain claim txid — the manager surfaces it from
480
+ * {@link SwapManager.waitForSwapCompletion}, since Boltz does not report a
481
+ * usable transaction id for chain swaps at `transaction.claimed`.
482
+ */
483
+ claimArk: (swap: BoltzChainSwap) => Promise<{
484
+ txid: string;
485
+ }>;
486
+ /**
487
+ * Claim the BTC side of an ARK→BTC chain swap. Returns the on-chain claim
488
+ * txid; see {@link SwapManagerCallbacks.claimArk}.
489
+ */
490
+ claimBtc: (swap: BoltzChainSwap) => Promise<{
491
+ txid: string;
492
+ }>;
478
493
  refundArk: (swap: BoltzChainSwap) => Promise<ChainArkRefundOutcome>;
479
494
  signServerClaim?: (swap: BoltzChainSwap) => Promise<void>;
480
495
  saveSwap: (swap: BoltzSwap) => Promise<void>;
@@ -530,6 +545,7 @@ declare class SwapManager implements SwapManagerClient {
530
545
  private webSocketUnavailable;
531
546
  private swapsInProgress;
532
547
  private swapSubscriptions;
548
+ private chainClaimPromises;
533
549
  private claimCallback;
534
550
  private refundCallback;
535
551
  private claimArkCallback;
@@ -629,13 +645,30 @@ declare class SwapManager implements SwapManagerClient {
629
645
  * Blocks until the swap reaches a final status or fails.
630
646
  * Useful when you want blocking behavior even with SwapManager enabled.
631
647
  *
632
- * @throws If the swap is already in a final status (submarine/chain swaps throw immediately;
633
- * reverse swaps return the existing txid).
648
+ * If the swap is already in a final status, resolves immediately with the
649
+ * on-chain txid of the successfully claimed swap (reverse: from
650
+ * getReverseSwapTxId; submarine/chain: from getSwapStatus) and throws for a
651
+ * failed final status.
652
+ *
653
+ * @throws If the swap is already in a failed final status.
634
654
  * @throws If the swap is not found in the manager.
655
+ * @throws If a completed swap has no transaction id available yet.
635
656
  */
636
657
  waitForSwapCompletion(swapId: string): Promise<{
637
658
  txid: string;
638
659
  }>;
660
+ /**
661
+ * Resolve the on-chain txid for a claimed submarine/chain swap.
662
+ *
663
+ * Chain swaps are claimed by the manager itself, so the claim txid captured
664
+ * from the claimArk/claimBtc callback is the swap's on-chain completion and
665
+ * is preferred — Boltz does not surface it via getSwapStatus at
666
+ * transaction.claimed. Submarine swaps (claimed by Boltz) and chain swaps
667
+ * we never claimed in this session (e.g. restored already-claimed) fall
668
+ * back to the provider status. Rejects when no transaction id is available,
669
+ * so callers never receive the Boltz swap id in place of a real txid.
670
+ */
671
+ private resolveClaimedTxid;
639
672
  /**
640
673
  * Check if a swap is currently being processed
641
674
  * Useful for preventing race conditions
@@ -711,6 +744,16 @@ declare class SwapManager implements SwapManagerClient {
711
744
  * Execute claim action for chain swap Ark to Btc
712
745
  */
713
746
  private executeClaimBtcAction;
747
+ /**
748
+ * Store the in-flight claim promise returned by a claim callback so
749
+ * {@link resolveClaimedTxid} can await it and surface the real on-chain
750
+ * txid at transaction.claimed — even when that update races the still
751
+ * in-flight claim. Storing the promise (not the resolved txid) closes the
752
+ * window where the txid is not yet captured when transaction.claimed
753
+ * arrives. Defensive against callbacks that don't return a promise (older
754
+ * integrations, test doubles): those simply fall back to getSwapStatus.
755
+ */
756
+ private rememberChainClaim;
714
757
  /**
715
758
  * Execute refund action for chain swap Ark to Btc
716
759
  */
@@ -473,8 +473,23 @@ interface SwapManagerClient {
473
473
  interface SwapManagerCallbacks {
474
474
  claim: (swap: BoltzReverseSwap) => Promise<void>;
475
475
  refund: (swap: BoltzSubmarineSwap) => Promise<void>;
476
- claimArk: (swap: BoltzChainSwap) => Promise<void>;
477
- claimBtc: (swap: BoltzChainSwap) => Promise<void>;
476
+ /**
477
+ * Claim the ARK side of a BTC→ARK chain swap.
478
+ *
479
+ * Returns the on-chain claim txid — the manager surfaces it from
480
+ * {@link SwapManager.waitForSwapCompletion}, since Boltz does not report a
481
+ * usable transaction id for chain swaps at `transaction.claimed`.
482
+ */
483
+ claimArk: (swap: BoltzChainSwap) => Promise<{
484
+ txid: string;
485
+ }>;
486
+ /**
487
+ * Claim the BTC side of an ARK→BTC chain swap. Returns the on-chain claim
488
+ * txid; see {@link SwapManagerCallbacks.claimArk}.
489
+ */
490
+ claimBtc: (swap: BoltzChainSwap) => Promise<{
491
+ txid: string;
492
+ }>;
478
493
  refundArk: (swap: BoltzChainSwap) => Promise<ChainArkRefundOutcome>;
479
494
  signServerClaim?: (swap: BoltzChainSwap) => Promise<void>;
480
495
  saveSwap: (swap: BoltzSwap) => Promise<void>;
@@ -530,6 +545,7 @@ declare class SwapManager implements SwapManagerClient {
530
545
  private webSocketUnavailable;
531
546
  private swapsInProgress;
532
547
  private swapSubscriptions;
548
+ private chainClaimPromises;
533
549
  private claimCallback;
534
550
  private refundCallback;
535
551
  private claimArkCallback;
@@ -629,13 +645,30 @@ declare class SwapManager implements SwapManagerClient {
629
645
  * Blocks until the swap reaches a final status or fails.
630
646
  * Useful when you want blocking behavior even with SwapManager enabled.
631
647
  *
632
- * @throws If the swap is already in a final status (submarine/chain swaps throw immediately;
633
- * reverse swaps return the existing txid).
648
+ * If the swap is already in a final status, resolves immediately with the
649
+ * on-chain txid of the successfully claimed swap (reverse: from
650
+ * getReverseSwapTxId; submarine/chain: from getSwapStatus) and throws for a
651
+ * failed final status.
652
+ *
653
+ * @throws If the swap is already in a failed final status.
634
654
  * @throws If the swap is not found in the manager.
655
+ * @throws If a completed swap has no transaction id available yet.
635
656
  */
636
657
  waitForSwapCompletion(swapId: string): Promise<{
637
658
  txid: string;
638
659
  }>;
660
+ /**
661
+ * Resolve the on-chain txid for a claimed submarine/chain swap.
662
+ *
663
+ * Chain swaps are claimed by the manager itself, so the claim txid captured
664
+ * from the claimArk/claimBtc callback is the swap's on-chain completion and
665
+ * is preferred — Boltz does not surface it via getSwapStatus at
666
+ * transaction.claimed. Submarine swaps (claimed by Boltz) and chain swaps
667
+ * we never claimed in this session (e.g. restored already-claimed) fall
668
+ * back to the provider status. Rejects when no transaction id is available,
669
+ * so callers never receive the Boltz swap id in place of a real txid.
670
+ */
671
+ private resolveClaimedTxid;
639
672
  /**
640
673
  * Check if a swap is currently being processed
641
674
  * Useful for preventing race conditions
@@ -711,6 +744,16 @@ declare class SwapManager implements SwapManagerClient {
711
744
  * Execute claim action for chain swap Ark to Btc
712
745
  */
713
746
  private executeClaimBtcAction;
747
+ /**
748
+ * Store the in-flight claim promise returned by a claim callback so
749
+ * {@link resolveClaimedTxid} can await it and surface the real on-chain
750
+ * txid at transaction.claimed — even when that update races the still
751
+ * in-flight claim. Storing the promise (not the resolved txid) closes the
752
+ * window where the txid is not yet captured when transaction.claimed
753
+ * arrives. Defensive against callbacks that don't return a promise (older
754
+ * integrations, test doubles): those simply fall back to getSwapStatus.
755
+ */
756
+ private rememberChainClaim;
714
757
  /**
715
758
  * Execute refund action for chain swap Ark to Btc
716
759
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/boltz-swap",
3
- "version": "0.3.35",
3
+ "version": "0.3.37",
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",
@@ -76,7 +76,7 @@
76
76
  "@scure/btc-signer": "2.0.1",
77
77
  "bip68": "1.0.4",
78
78
  "light-bolt11-decoder": "3.2.0",
79
- "@arkade-os/sdk": "0.4.30"
79
+ "@arkade-os/sdk": "0.4.32"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "expo-task-manager": ">=3.0.0",