@arkade-os/boltz-swap 0.3.42 → 0.3.44
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/{arkade-swaps-LvsGHtre.d.ts → arkade-swaps-2q3VSgb4.d.ts} +27 -1
- package/dist/{arkade-swaps-C3sUFr5f.d.cts → arkade-swaps-DwgfLCMY.d.cts} +27 -1
- package/dist/{chunk-CWY37W4B.js → chunk-PHF6C2NE.js} +1 -1
- package/dist/{chunk-UXYHW7KV.js → chunk-QVXFEX5F.js} +184 -158
- package/dist/expo/background.cjs +184 -158
- package/dist/expo/background.js +2 -2
- package/dist/expo/index.cjs +184 -158
- package/dist/expo/index.d.cts +1 -1
- package/dist/expo/index.d.ts +1 -1
- package/dist/expo/index.js +2 -2
- package/dist/index.cjs +192 -158
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +8 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -85,6 +85,7 @@ __export(index_exports, {
|
|
|
85
85
|
logger: () => logger,
|
|
86
86
|
migrateToSwapRepository: () => migrateToSwapRepository,
|
|
87
87
|
saveSwap: () => saveSwap,
|
|
88
|
+
sdkVersion: () => sdkVersion,
|
|
88
89
|
setLogger: () => setLogger,
|
|
89
90
|
updateChainSwapStatus: () => updateChainSwapStatus,
|
|
90
91
|
updateReverseSwapStatus: () => updateReverseSwapStatus,
|
|
@@ -93,6 +94,9 @@ __export(index_exports, {
|
|
|
93
94
|
});
|
|
94
95
|
module.exports = __toCommonJS(index_exports);
|
|
95
96
|
|
|
97
|
+
// package.json
|
|
98
|
+
var version = "0.3.44";
|
|
99
|
+
|
|
96
100
|
// src/errors.ts
|
|
97
101
|
var SwapError = class extends Error {
|
|
98
102
|
/** Whether the swap can still be claimed (default: false). */
|
|
@@ -3182,6 +3186,40 @@ var claimVHTLCwithOffchainTx = async (identity, vhtlcScript, serverXOnlyPublicKe
|
|
|
3182
3186
|
await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
3183
3187
|
return arkTxid;
|
|
3184
3188
|
};
|
|
3189
|
+
var refundWithoutReceiverVHTLCwithOffchainTx = async (identity, vhtlcScript, serverXOnlyPublicKey, input, output, arkInfo, arkProvider) => {
|
|
3190
|
+
const rawCheckpointTapscript = import_base8.hex.decode(arkInfo.checkpointTapscript);
|
|
3191
|
+
const serverUnrollScript = import_sdk7.CSVMultisigTapscript.decode(rawCheckpointTapscript);
|
|
3192
|
+
const { arkTx, checkpoints } = (0, import_sdk7.buildOffchainTx)([input], [output], serverUnrollScript);
|
|
3193
|
+
const signedArkTx = await identity.sign(arkTx);
|
|
3194
|
+
const { arkTxid, finalArkTx, signedCheckpointTxs } = await arkProvider.submitTx(
|
|
3195
|
+
import_base8.base64.encode(signedArkTx.toPSBT()),
|
|
3196
|
+
checkpoints.map((c) => import_base8.base64.encode(c.toPSBT()))
|
|
3197
|
+
);
|
|
3198
|
+
const finalTx = import_sdk7.Transaction.fromPSBT(import_base8.base64.decode(finalArkTx));
|
|
3199
|
+
const serverPubkeyHex = import_base8.hex.encode(serverXOnlyPublicKey);
|
|
3200
|
+
const refundLeafHash = (0, import_payment3.tapLeafHash)(
|
|
3201
|
+
scriptFromTapLeafScript(vhtlcScript.refundWithoutReceiver())
|
|
3202
|
+
);
|
|
3203
|
+
for (let i = 0; i < finalTx.inputsLength; i++) {
|
|
3204
|
+
if (!verifySignatures(finalTx, i, [serverPubkeyHex], refundLeafHash)) {
|
|
3205
|
+
throw new Error("Invalid final Ark transaction");
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
const finalCheckpoints = await Promise.all(
|
|
3209
|
+
signedCheckpointTxs.map(async (c, idx) => {
|
|
3210
|
+
const tx = import_sdk7.Transaction.fromPSBT(import_base8.base64.decode(c));
|
|
3211
|
+
const checkpointLeaf = checkpoints[idx].getInput(0).tapLeafScript[0];
|
|
3212
|
+
const cpLeafHash = (0, import_payment3.tapLeafHash)(scriptFromTapLeafScript(checkpointLeaf));
|
|
3213
|
+
if (!verifySignatures(tx, 0, [serverPubkeyHex], cpLeafHash)) {
|
|
3214
|
+
throw new Error("Invalid server signature in checkpoint transaction");
|
|
3215
|
+
}
|
|
3216
|
+
const signedCheckpoint = await identity.sign(tx, [0]);
|
|
3217
|
+
return import_base8.base64.encode(signedCheckpoint.toPSBT());
|
|
3218
|
+
})
|
|
3219
|
+
);
|
|
3220
|
+
await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
3221
|
+
return arkTxid;
|
|
3222
|
+
};
|
|
3185
3223
|
var refundVHTLCwithOffchainTx = async (swapId, identity, arkProvider, boltzXOnlyPublicKey, ourXOnlyPublicKey, serverXOnlyPublicKey, input, output, arkInfo, refundFunc) => {
|
|
3186
3224
|
const rawCheckpointTapscript = import_base8.hex.decode(arkInfo.checkpointTapscript);
|
|
3187
3225
|
const serverUnrollScript = import_sdk7.CSVMultisigTapscript.decode(rawCheckpointTapscript);
|
|
@@ -3936,85 +3974,22 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
3936
3974
|
}
|
|
3937
3975
|
const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
|
|
3938
3976
|
const refundWithoutReceiverLeaf = vhtlcScript.refundWithoutReceiver();
|
|
3939
|
-
const
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
await this.joinBatch(
|
|
3956
|
-
this.wallet.identity,
|
|
3957
|
-
input2,
|
|
3958
|
-
output,
|
|
3959
|
-
arkInfo,
|
|
3960
|
-
isRecoverableVtxo
|
|
3961
|
-
);
|
|
3962
|
-
sweptCount++;
|
|
3963
|
-
continue;
|
|
3964
|
-
}
|
|
3965
|
-
if (isRecoverableVtxo) {
|
|
3966
|
-
logger.error(
|
|
3967
|
-
`Swap ${pendingSwap.id}: recoverable VTXO ${vtxo.txid}:${vtxo.vout} cannot be refunded yet \u2014 refundWithoutReceiver locktime has not passed (refundLocktime=${vhtlcTimeouts.refund}, currentTimestamp=${Math.floor(Date.now() / 1e3)}). Refund will be retried after locktime.`
|
|
3968
|
-
);
|
|
3969
|
-
skippedCount++;
|
|
3970
|
-
continue;
|
|
3971
|
-
}
|
|
3972
|
-
const input = {
|
|
3973
|
-
...vtxo,
|
|
3974
|
-
tapLeafScript: vhtlcScript.refund(),
|
|
3975
|
-
tapTree: vhtlcScript.encode()
|
|
3976
|
-
};
|
|
3977
|
-
try {
|
|
3978
|
-
if (boltzCallCount > 0) {
|
|
3979
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
3980
|
-
}
|
|
3981
|
-
boltzCallCount++;
|
|
3982
|
-
await refundVHTLCwithOffchainTx(
|
|
3983
|
-
pendingSwap.id,
|
|
3984
|
-
this.wallet.identity,
|
|
3985
|
-
this.arkProvider,
|
|
3986
|
-
boltzXOnlyPublicKey,
|
|
3987
|
-
ourXOnlyPublicKey,
|
|
3988
|
-
serverXOnlyPublicKey,
|
|
3989
|
-
input,
|
|
3990
|
-
output,
|
|
3991
|
-
arkInfo,
|
|
3992
|
-
this.swapProvider.refundSubmarineSwap.bind(this.swapProvider)
|
|
3993
|
-
);
|
|
3994
|
-
sweptCount++;
|
|
3995
|
-
} catch (error) {
|
|
3996
|
-
if (!(error instanceof BoltzRefundError)) {
|
|
3997
|
-
throw error;
|
|
3998
|
-
}
|
|
3999
|
-
if (!isSubmarineRefundLocktimeReached(vhtlcTimeouts.refund)) {
|
|
4000
|
-
logger.error(
|
|
4001
|
-
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint and refundWithoutReceiver locktime has not passed yet (currentTimestamp=${Math.floor(Date.now() / 1e3)}, locktime=${vhtlcTimeouts.refund}). Refund will be retried after locktime.`
|
|
4002
|
-
);
|
|
4003
|
-
skippedCount++;
|
|
4004
|
-
continue;
|
|
4005
|
-
}
|
|
4006
|
-
logger.warn(
|
|
4007
|
-
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver via joinBatch`
|
|
4008
|
-
);
|
|
4009
|
-
const fallbackInput = {
|
|
4010
|
-
...vtxo,
|
|
4011
|
-
tapLeafScript: refundWithoutReceiverLeaf,
|
|
4012
|
-
tapTree: vhtlcScript.encode()
|
|
4013
|
-
};
|
|
4014
|
-
await this.joinBatch(this.wallet.identity, fallbackInput, output, arkInfo, false);
|
|
4015
|
-
sweptCount++;
|
|
4016
|
-
}
|
|
4017
|
-
}
|
|
3977
|
+
const refundContext = {
|
|
3978
|
+
arkInfo,
|
|
3979
|
+
vhtlcScript,
|
|
3980
|
+
serverXOnlyPublicKey,
|
|
3981
|
+
refundWithoutReceiverLeaf,
|
|
3982
|
+
outputScript
|
|
3983
|
+
};
|
|
3984
|
+
const { swept: sweptCount, skipped: skippedCount } = await this.refundVtxos({
|
|
3985
|
+
swapId: pendingSwap.id,
|
|
3986
|
+
vtxos: refundableVtxos,
|
|
3987
|
+
refundLocktime: vhtlcTimeouts.refund,
|
|
3988
|
+
refundContext,
|
|
3989
|
+
boltzXOnlyPublicKey,
|
|
3990
|
+
ourXOnlyPublicKey,
|
|
3991
|
+
refundViaBoltz: this.swapProvider.refundSubmarineSwap.bind(this.swapProvider)
|
|
3992
|
+
});
|
|
4018
3993
|
if (!isSubmarineSuccessStatus(pendingSwap.status)) {
|
|
4019
3994
|
const fullyRefunded = skippedCount === 0;
|
|
4020
3995
|
await updateSubmarineSwapStatus(
|
|
@@ -4572,7 +4547,10 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
4572
4547
|
* swap's ARK lockup address.
|
|
4573
4548
|
*
|
|
4574
4549
|
* Path selection per VTXO:
|
|
4575
|
-
* - CLTV
|
|
4550
|
+
* - CLTV elapsed, live VTXO → `refundWithoutReceiver` offchain (sender +
|
|
4551
|
+
* server, no Boltz, no batch round).
|
|
4552
|
+
* - CLTV elapsed, swept VTXO → `refundWithoutReceiver` via `joinBatch`
|
|
4553
|
+
* (a swept VTXO is no longer a live leaf).
|
|
4576
4554
|
* - Pre-CLTV recoverable → skipped (Boltz can't co-sign swept-batch refund).
|
|
4577
4555
|
* - Pre-CLTV non-recoverable → cooperative 3-of-3 refund via Boltz.
|
|
4578
4556
|
*
|
|
@@ -4629,84 +4607,22 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
4629
4607
|
const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
|
|
4630
4608
|
const refundWithoutReceiverLeaf = vhtlcScript.refundWithoutReceiver();
|
|
4631
4609
|
const refundLocktime = pendingSwap.response.lockupDetails.timeouts.refund;
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
this.wallet.identity,
|
|
4649
|
-
input2,
|
|
4650
|
-
output,
|
|
4651
|
-
arkInfo,
|
|
4652
|
-
isRecoverableVtxo
|
|
4653
|
-
);
|
|
4654
|
-
sweptCount++;
|
|
4655
|
-
continue;
|
|
4656
|
-
}
|
|
4657
|
-
if (isRecoverableVtxo) {
|
|
4658
|
-
logger.error(
|
|
4659
|
-
`Swap ${pendingSwap.id}: recoverable VTXO ${vtxo.txid}:${vtxo.vout} cannot be refunded yet \u2014 refundWithoutReceiver locktime has not passed (refundLocktime=${refundLocktime}, currentTimestamp=${Math.floor(Date.now() / 1e3)}). Refund will be retried after locktime.`
|
|
4660
|
-
);
|
|
4661
|
-
skippedCount++;
|
|
4662
|
-
continue;
|
|
4663
|
-
}
|
|
4664
|
-
const input = {
|
|
4665
|
-
...vtxo,
|
|
4666
|
-
tapLeafScript: vhtlcScript.refund(),
|
|
4667
|
-
tapTree: vhtlcScript.encode()
|
|
4668
|
-
};
|
|
4669
|
-
try {
|
|
4670
|
-
if (boltzCallCount > 0) {
|
|
4671
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
4672
|
-
}
|
|
4673
|
-
boltzCallCount++;
|
|
4674
|
-
await refundVHTLCwithOffchainTx(
|
|
4675
|
-
pendingSwap.id,
|
|
4676
|
-
this.wallet.identity,
|
|
4677
|
-
this.arkProvider,
|
|
4678
|
-
boltzXOnlyPublicKey,
|
|
4679
|
-
ourXOnlyPublicKey,
|
|
4680
|
-
serverXOnlyPublicKey,
|
|
4681
|
-
input,
|
|
4682
|
-
output,
|
|
4683
|
-
arkInfo,
|
|
4684
|
-
this.swapProvider.refundChainSwap.bind(this.swapProvider)
|
|
4685
|
-
);
|
|
4686
|
-
sweptCount++;
|
|
4687
|
-
} catch (error) {
|
|
4688
|
-
if (!(error instanceof BoltzRefundError)) {
|
|
4689
|
-
throw error;
|
|
4690
|
-
}
|
|
4691
|
-
if (!isSubmarineRefundLocktimeReached(refundLocktime)) {
|
|
4692
|
-
logger.error(
|
|
4693
|
-
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint and refundWithoutReceiver locktime has not passed yet (currentTimestamp=${Math.floor(Date.now() / 1e3)}, locktime=${refundLocktime}). Refund will be retried after locktime.`
|
|
4694
|
-
);
|
|
4695
|
-
skippedCount++;
|
|
4696
|
-
continue;
|
|
4697
|
-
}
|
|
4698
|
-
logger.warn(
|
|
4699
|
-
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver via joinBatch`
|
|
4700
|
-
);
|
|
4701
|
-
const fallbackInput = {
|
|
4702
|
-
...vtxo,
|
|
4703
|
-
tapLeafScript: refundWithoutReceiverLeaf,
|
|
4704
|
-
tapTree: vhtlcScript.encode()
|
|
4705
|
-
};
|
|
4706
|
-
await this.joinBatch(this.wallet.identity, fallbackInput, output, arkInfo, false);
|
|
4707
|
-
sweptCount++;
|
|
4708
|
-
}
|
|
4709
|
-
}
|
|
4610
|
+
const refundContext = {
|
|
4611
|
+
arkInfo,
|
|
4612
|
+
vhtlcScript,
|
|
4613
|
+
serverXOnlyPublicKey,
|
|
4614
|
+
refundWithoutReceiverLeaf,
|
|
4615
|
+
outputScript
|
|
4616
|
+
};
|
|
4617
|
+
const { swept: sweptCount, skipped: skippedCount } = await this.refundVtxos({
|
|
4618
|
+
swapId: pendingSwap.id,
|
|
4619
|
+
vtxos: unspentVtxos,
|
|
4620
|
+
refundLocktime,
|
|
4621
|
+
refundContext,
|
|
4622
|
+
boltzXOnlyPublicKey,
|
|
4623
|
+
ourXOnlyPublicKey,
|
|
4624
|
+
refundViaBoltz: this.swapProvider.refundChainSwap.bind(this.swapProvider)
|
|
4625
|
+
});
|
|
4710
4626
|
const finalStatus = await this.getSwapStatus(pendingSwap.id);
|
|
4711
4627
|
await this.savePendingChainSwap({
|
|
4712
4628
|
...pendingSwap,
|
|
@@ -5239,6 +5155,120 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
5239
5155
|
async joinBatch(identity, input, output, arkInfo, isRecoverable2 = true) {
|
|
5240
5156
|
return joinBatch(this.arkProvider, identity, input, output, arkInfo, isRecoverable2);
|
|
5241
5157
|
}
|
|
5158
|
+
/**
|
|
5159
|
+
* Settle a `refundWithoutReceiver` (sender + server, no Boltz) refund for a
|
|
5160
|
+
* single VTXO whose CLTV refund locktime has elapsed.
|
|
5161
|
+
*
|
|
5162
|
+
* A live VTXO settles the leaf with an offchain Ark tx — no batch round. A
|
|
5163
|
+
* swept (recoverable) VTXO is no longer a live leaf, so it can only be
|
|
5164
|
+
* reclaimed by re-registering it into a batch.
|
|
5165
|
+
*/
|
|
5166
|
+
async settleRefundWithoutReceiver(ctx, vtxo) {
|
|
5167
|
+
const input = {
|
|
5168
|
+
...vtxo,
|
|
5169
|
+
tapLeafScript: ctx.refundWithoutReceiverLeaf,
|
|
5170
|
+
tapTree: ctx.vhtlcScript.encode()
|
|
5171
|
+
};
|
|
5172
|
+
const output = { amount: BigInt(vtxo.value), script: ctx.outputScript };
|
|
5173
|
+
if ((0, import_sdk8.isRecoverable)(vtxo)) {
|
|
5174
|
+
await this.joinBatch(this.wallet.identity, input, output, ctx.arkInfo, true);
|
|
5175
|
+
} else {
|
|
5176
|
+
await refundWithoutReceiverVHTLCwithOffchainTx(
|
|
5177
|
+
this.wallet.identity,
|
|
5178
|
+
ctx.vhtlcScript,
|
|
5179
|
+
ctx.serverXOnlyPublicKey,
|
|
5180
|
+
input,
|
|
5181
|
+
output,
|
|
5182
|
+
ctx.arkInfo,
|
|
5183
|
+
this.arkProvider
|
|
5184
|
+
);
|
|
5185
|
+
}
|
|
5186
|
+
}
|
|
5187
|
+
/**
|
|
5188
|
+
* Refund every VTXO at a swap's VHTLC address back to the wallet, shared by
|
|
5189
|
+
* {@link ArkadeSwaps.refundVHTLC} (submarine) and {@link ArkadeSwaps.refundArk}
|
|
5190
|
+
* (chain). Path selection per VTXO:
|
|
5191
|
+
* - CLTV elapsed → `refundWithoutReceiver` (offchain for a live VTXO, via a
|
|
5192
|
+
* batch round for a swept one — see {@link settleRefundWithoutReceiver}).
|
|
5193
|
+
* - Pre-CLTV recoverable → skipped (Boltz can't co-sign a swept-batch refund).
|
|
5194
|
+
* - Pre-CLTV non-recoverable → cooperative 3-of-3 refund via Boltz, falling
|
|
5195
|
+
* back to `refundWithoutReceiver` offchain if Boltz rejects after the
|
|
5196
|
+
* locktime has since elapsed.
|
|
5197
|
+
*
|
|
5198
|
+
* @returns Counts of VTXOs swept vs. deferred.
|
|
5199
|
+
*/
|
|
5200
|
+
async refundVtxos(params) {
|
|
5201
|
+
const {
|
|
5202
|
+
swapId,
|
|
5203
|
+
vtxos,
|
|
5204
|
+
refundLocktime,
|
|
5205
|
+
refundContext,
|
|
5206
|
+
boltzXOnlyPublicKey,
|
|
5207
|
+
ourXOnlyPublicKey,
|
|
5208
|
+
refundViaBoltz
|
|
5209
|
+
} = params;
|
|
5210
|
+
const { vhtlcScript, serverXOnlyPublicKey, arkInfo, outputScript } = refundContext;
|
|
5211
|
+
let boltzCallCount = 0;
|
|
5212
|
+
let sweptCount = 0;
|
|
5213
|
+
let skippedCount = 0;
|
|
5214
|
+
for (const vtxo of vtxos) {
|
|
5215
|
+
const isRecoverableVtxo = (0, import_sdk8.isRecoverable)(vtxo);
|
|
5216
|
+
const output = { amount: BigInt(vtxo.value), script: outputScript };
|
|
5217
|
+
if (isSubmarineRefundLocktimeReached(refundLocktime)) {
|
|
5218
|
+
await this.settleRefundWithoutReceiver(refundContext, vtxo);
|
|
5219
|
+
sweptCount++;
|
|
5220
|
+
continue;
|
|
5221
|
+
}
|
|
5222
|
+
if (isRecoverableVtxo) {
|
|
5223
|
+
logger.error(
|
|
5224
|
+
`Swap ${swapId}: recoverable VTXO ${vtxo.txid}:${vtxo.vout} cannot be refunded yet \u2014 refundWithoutReceiver locktime has not passed (refundLocktime=${refundLocktime}, currentTimestamp=${Math.floor(Date.now() / 1e3)}). Refund will be retried after locktime.`
|
|
5225
|
+
);
|
|
5226
|
+
skippedCount++;
|
|
5227
|
+
continue;
|
|
5228
|
+
}
|
|
5229
|
+
const input = {
|
|
5230
|
+
...vtxo,
|
|
5231
|
+
tapLeafScript: vhtlcScript.refund(),
|
|
5232
|
+
tapTree: vhtlcScript.encode()
|
|
5233
|
+
};
|
|
5234
|
+
try {
|
|
5235
|
+
if (boltzCallCount > 0) {
|
|
5236
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
5237
|
+
}
|
|
5238
|
+
boltzCallCount++;
|
|
5239
|
+
await refundVHTLCwithOffchainTx(
|
|
5240
|
+
swapId,
|
|
5241
|
+
this.wallet.identity,
|
|
5242
|
+
this.arkProvider,
|
|
5243
|
+
boltzXOnlyPublicKey,
|
|
5244
|
+
ourXOnlyPublicKey,
|
|
5245
|
+
serverXOnlyPublicKey,
|
|
5246
|
+
input,
|
|
5247
|
+
output,
|
|
5248
|
+
arkInfo,
|
|
5249
|
+
refundViaBoltz
|
|
5250
|
+
);
|
|
5251
|
+
sweptCount++;
|
|
5252
|
+
} catch (error) {
|
|
5253
|
+
if (!(error instanceof BoltzRefundError)) {
|
|
5254
|
+
throw error;
|
|
5255
|
+
}
|
|
5256
|
+
if (!isSubmarineRefundLocktimeReached(refundLocktime)) {
|
|
5257
|
+
logger.error(
|
|
5258
|
+
`Swap ${swapId}: Boltz rejected VTXO outpoint and refundWithoutReceiver locktime has not passed yet (currentTimestamp=${Math.floor(Date.now() / 1e3)}, locktime=${refundLocktime}). Refund will be retried after locktime.`
|
|
5259
|
+
);
|
|
5260
|
+
skippedCount++;
|
|
5261
|
+
continue;
|
|
5262
|
+
}
|
|
5263
|
+
logger.warn(
|
|
5264
|
+
`Swap ${swapId}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver offchain`
|
|
5265
|
+
);
|
|
5266
|
+
await this.settleRefundWithoutReceiver(refundContext, vtxo);
|
|
5267
|
+
sweptCount++;
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
return { swept: sweptCount, skipped: skippedCount };
|
|
5271
|
+
}
|
|
5242
5272
|
/**
|
|
5243
5273
|
* Creates a VHTLC script for the swap.
|
|
5244
5274
|
* Works for submarine, reverse, and chain swaps.
|
|
@@ -7043,6 +7073,9 @@ var InMemorySwapRepository = class {
|
|
|
7043
7073
|
await this.clear();
|
|
7044
7074
|
}
|
|
7045
7075
|
};
|
|
7076
|
+
|
|
7077
|
+
// src/index.ts
|
|
7078
|
+
var sdkVersion = `boltz-swap/${version}`;
|
|
7046
7079
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7047
7080
|
0 && (module.exports = {
|
|
7048
7081
|
ArkadeLightningMessageHandler,
|
|
@@ -7100,6 +7133,7 @@ var InMemorySwapRepository = class {
|
|
|
7100
7133
|
logger,
|
|
7101
7134
|
migrateToSwapRepository,
|
|
7102
7135
|
saveSwap,
|
|
7136
|
+
sdkVersion,
|
|
7103
7137
|
setLogger,
|
|
7104
7138
|
updateChainSwapStatus,
|
|
7105
7139
|
updateReverseSwapStatus,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-
|
|
2
|
-
export { A as ArkadeSwaps } from './arkade-swaps-
|
|
1
|
+
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-DwgfLCMY.cjs';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-DwgfLCMY.cjs';
|
|
3
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, O as OptimisticSendLightningPaymentResponse, f as SubmarineRefundOutcome, g as SubmarineRecoveryInfo, h as SubmarineRecoveryResult, i as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, j as ArkToBtcResponse, k as BtcToArkResponse, l as ChainArkRefundOutcome, m as SwapRepository, n as SwapManagerClient, o as SendLightningPaymentResponse, p as GetSwapsFilter } from './types-8NrCdOpS.cjs';
|
|
4
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 SubmarineProgressionStatus, x as SubmarineRecoveryStatus, y as SwapManager, z as SwapManagerCallbacks, E as SwapManagerConfig, H as SwapManagerEvents, V as Vtxo, J as hasSubmarineStatusReached, K as isChainClaimableStatus, M as isChainFailedStatus, Q as isChainFinalStatus, R as isChainPendingStatus, T as isChainRefundableStatus, U as isChainSignableStatus, W as isChainSuccessStatus, X as isChainSwapClaimable, Y as isChainSwapRefundable, Z as isPendingChainSwap, _ as isPendingReverseSwap, $ as isPendingSubmarineSwap, a0 as isReverseClaimableStatus, a1 as isReverseFailedStatus, a2 as isReverseFinalStatus, a3 as isReversePendingStatus, a4 as isReverseSuccessStatus, a5 as isReverseSwapClaimable, a6 as isSubmarineFailedStatus, a7 as isSubmarineFinalStatus, a8 as isSubmarinePendingStatus, a9 as isSubmarineRefundableStatus, aa as isSubmarineSuccessStatus, ab as isSubmarineSwapRefundable } from './types-8NrCdOpS.cjs';
|
|
5
5
|
import { Transaction } from '@scure/btc-signer';
|
|
@@ -891,4 +891,10 @@ declare class InMemorySwapRepository implements SwapRepository {
|
|
|
891
891
|
[Symbol.asyncDispose](): Promise<void>;
|
|
892
892
|
}
|
|
893
893
|
|
|
894
|
-
|
|
894
|
+
/**
|
|
895
|
+
* This SDK plugin's own version string, sourced from package.json, and scoped
|
|
896
|
+
* by plugin name.
|
|
897
|
+
*/
|
|
898
|
+
declare const sdkVersion: string;
|
|
899
|
+
|
|
900
|
+
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, InMemorySwapRepository, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, OptimisticSendLightningPaymentResponse, PreimageFetchError, QuoteRejectedError, type QuoteRejectionReason, QuoteSwapOptions, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SubmarineRecoveryInfo, SubmarineRecoveryResult, SubmarineRefundOutcome, SwapError, SwapExpiredError, SwapManagerClient, SwapNotFoundError, SwapRepository, type SwapSaver, TransactionFailedError, decodeInvoice, enrichReverseSwapPreimage, enrichSubmarineSwapInvoice, getInvoicePaymentHash, getInvoiceSatoshis, isValidArkAddress, logger, migrateToSwapRepository, saveSwap, sdkVersion, setLogger, updateChainSwapStatus, updateReverseSwapStatus, updateSubmarineSwapStatus, verifySignatures };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-
|
|
2
|
-
export { A as ArkadeSwaps } from './arkade-swaps-
|
|
1
|
+
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-2q3VSgb4.js';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-2q3VSgb4.js';
|
|
3
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, O as OptimisticSendLightningPaymentResponse, f as SubmarineRefundOutcome, g as SubmarineRecoveryInfo, h as SubmarineRecoveryResult, i as ChainFeesResponse, L as LimitsResponse, G as GetSwapStatusResponse, j as ArkToBtcResponse, k as BtcToArkResponse, l as ChainArkRefundOutcome, m as SwapRepository, n as SwapManagerClient, o as SendLightningPaymentResponse, p as GetSwapsFilter } from './types-8NrCdOpS.js';
|
|
4
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 SubmarineProgressionStatus, x as SubmarineRecoveryStatus, y as SwapManager, z as SwapManagerCallbacks, E as SwapManagerConfig, H as SwapManagerEvents, V as Vtxo, J as hasSubmarineStatusReached, K as isChainClaimableStatus, M as isChainFailedStatus, Q as isChainFinalStatus, R as isChainPendingStatus, T as isChainRefundableStatus, U as isChainSignableStatus, W as isChainSuccessStatus, X as isChainSwapClaimable, Y as isChainSwapRefundable, Z as isPendingChainSwap, _ as isPendingReverseSwap, $ as isPendingSubmarineSwap, a0 as isReverseClaimableStatus, a1 as isReverseFailedStatus, a2 as isReverseFinalStatus, a3 as isReversePendingStatus, a4 as isReverseSuccessStatus, a5 as isReverseSwapClaimable, a6 as isSubmarineFailedStatus, a7 as isSubmarineFinalStatus, a8 as isSubmarinePendingStatus, a9 as isSubmarineRefundableStatus, aa as isSubmarineSuccessStatus, ab as isSubmarineSwapRefundable } from './types-8NrCdOpS.js';
|
|
5
5
|
import { Transaction } from '@scure/btc-signer';
|
|
@@ -891,4 +891,10 @@ declare class InMemorySwapRepository implements SwapRepository {
|
|
|
891
891
|
[Symbol.asyncDispose](): Promise<void>;
|
|
892
892
|
}
|
|
893
893
|
|
|
894
|
-
|
|
894
|
+
/**
|
|
895
|
+
* This SDK plugin's own version string, sourced from package.json, and scoped
|
|
896
|
+
* by plugin name.
|
|
897
|
+
*/
|
|
898
|
+
declare const sdkVersion: string;
|
|
899
|
+
|
|
900
|
+
export { ArkToBtcResponse, ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler, ArkadeSwapsConfig, ArkadeSwapsMessageHandler, BoltzChainSwap, BoltzRefundError, BoltzReverseSwap, BoltzSubmarineSwap, BoltzSwap, BtcToArkResponse, Chain, ChainFeesResponse, CreateLightningInvoiceRequest, CreateLightningInvoiceResponse, DecodedInvoice, FeesResponse, InMemorySwapRepository, IndexedDbSwapRepository, InsufficientFundsError, InvoiceExpiredError, InvoiceFailedToPayError, LimitsResponse, type Logger, Network, NetworkError, OptimisticSendLightningPaymentResponse, PreimageFetchError, QuoteRejectedError, type QuoteRejectionReason, QuoteSwapOptions, SchemaError, SendLightningPaymentRequest, SendLightningPaymentResponse, ServiceWorkerArkadeSwaps as ServiceWorkerArkadeLightning, ServiceWorkerArkadeSwaps, SubmarineRecoveryInfo, SubmarineRecoveryResult, SubmarineRefundOutcome, SwapError, SwapExpiredError, SwapManagerClient, SwapNotFoundError, SwapRepository, type SwapSaver, TransactionFailedError, decodeInvoice, enrichReverseSwapPreimage, enrichSubmarineSwapInvoice, getInvoicePaymentHash, getInvoiceSatoshis, isValidArkAddress, logger, migrateToSwapRepository, saveSwap, sdkVersion, setLogger, updateChainSwapStatus, updateReverseSwapStatus, updateSubmarineSwapStatus, verifySignatures };
|
package/dist/index.js
CHANGED
|
@@ -53,12 +53,15 @@ import {
|
|
|
53
53
|
updateReverseSwapStatus,
|
|
54
54
|
updateSubmarineSwapStatus,
|
|
55
55
|
verifySignatures
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-QVXFEX5F.js";
|
|
57
57
|
import {
|
|
58
58
|
applyCreatedAtOrder,
|
|
59
59
|
applySwapsFilter
|
|
60
60
|
} from "./chunk-SJQJQO7P.js";
|
|
61
61
|
|
|
62
|
+
// package.json
|
|
63
|
+
var version = "0.3.44";
|
|
64
|
+
|
|
62
65
|
// src/serviceWorker/arkade-swaps-message-handler.ts
|
|
63
66
|
import { RestArkProvider, RestIndexerProvider } from "@arkade-os/sdk";
|
|
64
67
|
function toQuoteTransportError(error) {
|
|
@@ -1554,6 +1557,9 @@ var InMemorySwapRepository = class {
|
|
|
1554
1557
|
await this.clear();
|
|
1555
1558
|
}
|
|
1556
1559
|
};
|
|
1560
|
+
|
|
1561
|
+
// src/index.ts
|
|
1562
|
+
var sdkVersion = `boltz-swap/${version}`;
|
|
1557
1563
|
export {
|
|
1558
1564
|
ArkadeSwapsMessageHandler as ArkadeLightningMessageHandler,
|
|
1559
1565
|
ArkadeSwaps,
|
|
@@ -1610,6 +1616,7 @@ export {
|
|
|
1610
1616
|
logger,
|
|
1611
1617
|
migrateToSwapRepository,
|
|
1612
1618
|
saveSwap,
|
|
1619
|
+
sdkVersion,
|
|
1613
1620
|
setLogger,
|
|
1614
1621
|
updateChainSwapStatus,
|
|
1615
1622
|
updateReverseSwapStatus,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkade-os/boltz-swap",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.44",
|
|
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.
|
|
79
|
+
"@arkade-os/sdk": "0.4.39"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"expo-task-manager": ">=3.0.0",
|