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