@arkade-os/boltz-swap 0.2.13 → 0.2.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.
package/dist/index.d.cts CHANGED
@@ -17,6 +17,7 @@ declare const isSubmarineRefundableStatus: (status: BoltzSwapStatus) => boolean;
17
17
  declare const isSubmarineSwapRefundable: (swap: PendingSubmarineSwap | PendingReverseSwap) => swap is PendingSubmarineSwap;
18
18
  type GetReverseSwapTxIdResponse = {
19
19
  id: string;
20
+ hex: string;
20
21
  timeoutBlockHeight: number;
21
22
  };
22
23
  type GetSwapStatusResponse = {
@@ -69,6 +70,52 @@ type CreateReverseSwapResponse = {
69
70
  unilateralRefundWithoutReceiver: number;
70
71
  };
71
72
  };
73
+ type Leaf = {
74
+ version: number;
75
+ output: string;
76
+ };
77
+ type Tree = {
78
+ claimLeaf: Leaf;
79
+ refundLeaf: Leaf;
80
+ refundWithoutBoltzLeaf: Leaf;
81
+ unilateralClaimLeaf: Leaf;
82
+ unilateralRefundLeaf: Leaf;
83
+ unilateralRefundWithoutBoltzLeaf: Leaf;
84
+ };
85
+ type Details = {
86
+ tree: Tree;
87
+ amount?: number;
88
+ keyIndex: number;
89
+ transaction?: {
90
+ id: string;
91
+ vout: number;
92
+ };
93
+ lockupAddress: string;
94
+ serverPublicKey: string;
95
+ timeoutBlockHeight: number;
96
+ preimageHash?: string;
97
+ };
98
+ type RestoredSubmarineSwap = {
99
+ to: "BTC";
100
+ id: string;
101
+ from: "ARK";
102
+ type: "submarine";
103
+ createdAt: number;
104
+ preimageHash: string;
105
+ status: BoltzSwapStatus;
106
+ refundDetails: Details;
107
+ };
108
+ type RestoredReverseSwap = {
109
+ to: "ARK";
110
+ id: string;
111
+ from: "BTC";
112
+ type: "reverse";
113
+ createdAt: number;
114
+ preimageHash: string;
115
+ status: BoltzSwapStatus;
116
+ claimDetails: Details;
117
+ };
118
+ type CreateSwapsRestoreResponse = (RestoredReverseSwap | RestoredSubmarineSwap)[];
72
119
  declare class BoltzSwapProvider {
73
120
  private readonly wsUrl;
74
121
  private readonly apiUrl;
@@ -90,6 +137,7 @@ declare class BoltzSwapProvider {
90
137
  checkpoint: Transaction;
91
138
  }>;
92
139
  monitorSwap(swapId: string, update: (type: BoltzSwapStatus, data?: any) => void): Promise<void>;
140
+ restoreSwaps(publicKey: string): Promise<CreateSwapsRestoreResponse>;
93
141
  private request;
94
142
  }
95
143
 
@@ -393,6 +441,8 @@ interface PendingSubmarineSwap {
393
441
  type: "submarine";
394
442
  createdAt: number;
395
443
  preimage?: string;
444
+ /** Original preimage hash from Boltz (available for restored swaps) */
445
+ preimageHash?: string;
396
446
  refunded?: boolean;
397
447
  refundable?: boolean;
398
448
  status: BoltzSwapStatus;
@@ -562,6 +612,46 @@ declare class ArkadeLightning {
562
612
  waitForSwapSettlement(pendingSwap: PendingSubmarineSwap): Promise<{
563
613
  preimage: string;
564
614
  }>;
615
+ /**
616
+ * Restore swaps from Boltz API.
617
+ *
618
+ * Note: restored swaps may lack local-only data such as the original
619
+ * Lightning invoice or preimage. They are intended primarily for
620
+ * display/monitoring and are not automatically wired into the SwapManager.
621
+ * Do not call `claimVHTLC` / `refundVHTLC` on them unless you have
622
+ * enriched the objects with the missing fields.
623
+ *
624
+ * @param boltzFees - Optional fees response to use for restoration.
625
+ * @returns An object containing arrays of restored reverse and submarine swaps.
626
+ */
627
+ restoreSwaps(boltzFees?: FeesResponse): Promise<{
628
+ reverseSwaps: PendingReverseSwap[];
629
+ submarineSwaps: PendingSubmarineSwap[];
630
+ }>;
631
+ /**
632
+ * Enrich a restored reverse swap with its preimage.
633
+ * This makes the swap claimable via `claimVHTLC`.
634
+ * Validates that the preimage hash matches the swap's expected preimageHash.
635
+ *
636
+ * @param swap - The restored reverse swap to enrich.
637
+ * @param preimage - The preimage (hex-encoded) for the swap.
638
+ * @returns The enriched swap object (same reference, mutated).
639
+ * @throws Error if the preimage does not match the swap's preimageHash.
640
+ */
641
+ enrichReverseSwapPreimage(swap: PendingReverseSwap, preimage: string): PendingReverseSwap;
642
+ /**
643
+ * Enrich a restored submarine swap with its invoice.
644
+ * This makes the swap refundable via `refundVHTLC`.
645
+ * Validates that the invoice is well-formed and its payment hash can be extracted.
646
+ * If the swap has a preimageHash (from restoration), validates that the invoice's
647
+ * payment hash matches.
648
+ *
649
+ * @param swap - The restored submarine swap to enrich.
650
+ * @param invoice - The Lightning invoice for the swap.
651
+ * @returns The enriched swap object (same reference, mutated).
652
+ * @throws Error if the invoice is invalid, cannot be decoded, or payment hash doesn't match.
653
+ */
654
+ enrichSubmarineSwapInvoice(swap: PendingSubmarineSwap, invoice: string): PendingSubmarineSwap;
565
655
  private claimVHTLCwithOffchainTx;
566
656
  private refundVHTLCwithOffchainTx;
567
657
  /**
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ declare const isSubmarineRefundableStatus: (status: BoltzSwapStatus) => boolean;
17
17
  declare const isSubmarineSwapRefundable: (swap: PendingSubmarineSwap | PendingReverseSwap) => swap is PendingSubmarineSwap;
18
18
  type GetReverseSwapTxIdResponse = {
19
19
  id: string;
20
+ hex: string;
20
21
  timeoutBlockHeight: number;
21
22
  };
22
23
  type GetSwapStatusResponse = {
@@ -69,6 +70,52 @@ type CreateReverseSwapResponse = {
69
70
  unilateralRefundWithoutReceiver: number;
70
71
  };
71
72
  };
73
+ type Leaf = {
74
+ version: number;
75
+ output: string;
76
+ };
77
+ type Tree = {
78
+ claimLeaf: Leaf;
79
+ refundLeaf: Leaf;
80
+ refundWithoutBoltzLeaf: Leaf;
81
+ unilateralClaimLeaf: Leaf;
82
+ unilateralRefundLeaf: Leaf;
83
+ unilateralRefundWithoutBoltzLeaf: Leaf;
84
+ };
85
+ type Details = {
86
+ tree: Tree;
87
+ amount?: number;
88
+ keyIndex: number;
89
+ transaction?: {
90
+ id: string;
91
+ vout: number;
92
+ };
93
+ lockupAddress: string;
94
+ serverPublicKey: string;
95
+ timeoutBlockHeight: number;
96
+ preimageHash?: string;
97
+ };
98
+ type RestoredSubmarineSwap = {
99
+ to: "BTC";
100
+ id: string;
101
+ from: "ARK";
102
+ type: "submarine";
103
+ createdAt: number;
104
+ preimageHash: string;
105
+ status: BoltzSwapStatus;
106
+ refundDetails: Details;
107
+ };
108
+ type RestoredReverseSwap = {
109
+ to: "ARK";
110
+ id: string;
111
+ from: "BTC";
112
+ type: "reverse";
113
+ createdAt: number;
114
+ preimageHash: string;
115
+ status: BoltzSwapStatus;
116
+ claimDetails: Details;
117
+ };
118
+ type CreateSwapsRestoreResponse = (RestoredReverseSwap | RestoredSubmarineSwap)[];
72
119
  declare class BoltzSwapProvider {
73
120
  private readonly wsUrl;
74
121
  private readonly apiUrl;
@@ -90,6 +137,7 @@ declare class BoltzSwapProvider {
90
137
  checkpoint: Transaction;
91
138
  }>;
92
139
  monitorSwap(swapId: string, update: (type: BoltzSwapStatus, data?: any) => void): Promise<void>;
140
+ restoreSwaps(publicKey: string): Promise<CreateSwapsRestoreResponse>;
93
141
  private request;
94
142
  }
95
143
 
@@ -393,6 +441,8 @@ interface PendingSubmarineSwap {
393
441
  type: "submarine";
394
442
  createdAt: number;
395
443
  preimage?: string;
444
+ /** Original preimage hash from Boltz (available for restored swaps) */
445
+ preimageHash?: string;
396
446
  refunded?: boolean;
397
447
  refundable?: boolean;
398
448
  status: BoltzSwapStatus;
@@ -562,6 +612,46 @@ declare class ArkadeLightning {
562
612
  waitForSwapSettlement(pendingSwap: PendingSubmarineSwap): Promise<{
563
613
  preimage: string;
564
614
  }>;
615
+ /**
616
+ * Restore swaps from Boltz API.
617
+ *
618
+ * Note: restored swaps may lack local-only data such as the original
619
+ * Lightning invoice or preimage. They are intended primarily for
620
+ * display/monitoring and are not automatically wired into the SwapManager.
621
+ * Do not call `claimVHTLC` / `refundVHTLC` on them unless you have
622
+ * enriched the objects with the missing fields.
623
+ *
624
+ * @param boltzFees - Optional fees response to use for restoration.
625
+ * @returns An object containing arrays of restored reverse and submarine swaps.
626
+ */
627
+ restoreSwaps(boltzFees?: FeesResponse): Promise<{
628
+ reverseSwaps: PendingReverseSwap[];
629
+ submarineSwaps: PendingSubmarineSwap[];
630
+ }>;
631
+ /**
632
+ * Enrich a restored reverse swap with its preimage.
633
+ * This makes the swap claimable via `claimVHTLC`.
634
+ * Validates that the preimage hash matches the swap's expected preimageHash.
635
+ *
636
+ * @param swap - The restored reverse swap to enrich.
637
+ * @param preimage - The preimage (hex-encoded) for the swap.
638
+ * @returns The enriched swap object (same reference, mutated).
639
+ * @throws Error if the preimage does not match the swap's preimageHash.
640
+ */
641
+ enrichReverseSwapPreimage(swap: PendingReverseSwap, preimage: string): PendingReverseSwap;
642
+ /**
643
+ * Enrich a restored submarine swap with its invoice.
644
+ * This makes the swap refundable via `refundVHTLC`.
645
+ * Validates that the invoice is well-formed and its payment hash can be extracted.
646
+ * If the swap has a preimageHash (from restoration), validates that the invoice's
647
+ * payment hash matches.
648
+ *
649
+ * @param swap - The restored submarine swap to enrich.
650
+ * @param invoice - The Lightning invoice for the swap.
651
+ * @returns The enriched swap object (same reference, mutated).
652
+ * @throws Error if the invoice is invalid, cannot be decoded, or payment hash doesn't match.
653
+ */
654
+ enrichSubmarineSwapInvoice(swap: PendingSubmarineSwap, invoice: string): PendingSubmarineSwap;
565
655
  private claimVHTLCwithOffchainTx;
566
656
  private refundVHTLCwithOffchainTx;
567
657
  /**