@arkade-os/boltz-swap 0.3.43 → 0.3.45
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-C8CmzknM.d.cts} +28 -2
- package/dist/{arkade-swaps-C3sUFr5f.d.cts → arkade-swaps-gXHRbR09.d.ts} +28 -2
- package/dist/{chunk-UXYHW7KV.js → chunk-5GBBRBFS.js} +199 -161
- package/dist/{chunk-CWY37W4B.js → chunk-WPAI2ECT.js} +1 -1
- package/dist/expo/background.cjs +199 -161
- package/dist/expo/background.d.cts +3 -3
- package/dist/expo/background.d.ts +3 -3
- package/dist/expo/background.js +2 -2
- package/dist/expo/index.cjs +199 -161
- package/dist/expo/index.d.cts +4 -4
- package/dist/expo/index.d.ts +4 -4
- package/dist/expo/index.js +2 -2
- package/dist/index.cjs +200 -162
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/{swapsPollProcessor-CGMXUKPe.d.cts → swapsPollProcessor-B98F6MQF.d.cts} +1 -1
- package/dist/{swapsPollProcessor-CuDM6sxV.d.ts → swapsPollProcessor-Ov-wp17v.d.ts} +1 -1
- package/dist/{types-8NrCdOpS.d.cts → types-CS62-oEy.d.cts} +19 -2
- package/dist/{types-8NrCdOpS.d.ts → types-CS62-oEy.d.ts} +19 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -95,7 +95,7 @@ __export(index_exports, {
|
|
|
95
95
|
module.exports = __toCommonJS(index_exports);
|
|
96
96
|
|
|
97
97
|
// package.json
|
|
98
|
-
var version = "0.3.
|
|
98
|
+
var version = "0.3.45";
|
|
99
99
|
|
|
100
100
|
// src/errors.ts
|
|
101
101
|
var SwapError = class extends Error {
|
|
@@ -667,20 +667,26 @@ var BoltzSwapProvider = class {
|
|
|
667
667
|
invoiceAmount,
|
|
668
668
|
claimPublicKey,
|
|
669
669
|
preimageHash,
|
|
670
|
-
description
|
|
670
|
+
description,
|
|
671
|
+
descriptionHash
|
|
671
672
|
}) {
|
|
672
673
|
if (claimPublicKey.length != 66) {
|
|
673
674
|
throw new SwapError({
|
|
674
675
|
message: "claimPublicKey must be a compressed public key"
|
|
675
676
|
});
|
|
676
677
|
}
|
|
678
|
+
if (descriptionHash !== void 0 && !/^[0-9a-fA-F]{64}$/.test(descriptionHash)) {
|
|
679
|
+
throw new SwapError({
|
|
680
|
+
message: "descriptionHash must be a 32-byte SHA256 (64 hex chars)"
|
|
681
|
+
});
|
|
682
|
+
}
|
|
677
683
|
const requestBody = {
|
|
678
684
|
from: "BTC",
|
|
679
685
|
to: "ARK",
|
|
680
686
|
invoiceAmount,
|
|
681
687
|
claimPublicKey,
|
|
682
688
|
preimageHash,
|
|
683
|
-
description: description?.trim() || "Send to Arkade address",
|
|
689
|
+
...descriptionHash ? { descriptionHash } : { description: description?.trim() || "Send to Arkade address" },
|
|
684
690
|
...this.referralId ? { referralId: this.referralId } : {}
|
|
685
691
|
};
|
|
686
692
|
const response = await this.request(
|
|
@@ -1434,6 +1440,12 @@ var decodeInvoice = (invoice) => {
|
|
|
1434
1440
|
expiry: decoded.expiry ?? 3600,
|
|
1435
1441
|
amountSats: Number(millisats / 1000n),
|
|
1436
1442
|
description: decoded.sections.find((s) => s.name === "description")?.value ?? "",
|
|
1443
|
+
// description_hash (BOLT11 `h`) is missing from light-bolt11-decoder's
|
|
1444
|
+
// Section union even though the decoder emits it. Widen just this lookup
|
|
1445
|
+
// rather than patch the library's types (separate repo, out of scope).
|
|
1446
|
+
descriptionHash: decoded.sections.find(
|
|
1447
|
+
(s) => s.name === "description_hash"
|
|
1448
|
+
)?.value ?? "",
|
|
1437
1449
|
paymentHash: decoded.sections.find((s) => s.name === "payment_hash")?.value ?? ""
|
|
1438
1450
|
};
|
|
1439
1451
|
};
|
|
@@ -3186,6 +3198,40 @@ var claimVHTLCwithOffchainTx = async (identity, vhtlcScript, serverXOnlyPublicKe
|
|
|
3186
3198
|
await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
3187
3199
|
return arkTxid;
|
|
3188
3200
|
};
|
|
3201
|
+
var refundWithoutReceiverVHTLCwithOffchainTx = async (identity, vhtlcScript, serverXOnlyPublicKey, input, output, arkInfo, arkProvider) => {
|
|
3202
|
+
const rawCheckpointTapscript = import_base8.hex.decode(arkInfo.checkpointTapscript);
|
|
3203
|
+
const serverUnrollScript = import_sdk7.CSVMultisigTapscript.decode(rawCheckpointTapscript);
|
|
3204
|
+
const { arkTx, checkpoints } = (0, import_sdk7.buildOffchainTx)([input], [output], serverUnrollScript);
|
|
3205
|
+
const signedArkTx = await identity.sign(arkTx);
|
|
3206
|
+
const { arkTxid, finalArkTx, signedCheckpointTxs } = await arkProvider.submitTx(
|
|
3207
|
+
import_base8.base64.encode(signedArkTx.toPSBT()),
|
|
3208
|
+
checkpoints.map((c) => import_base8.base64.encode(c.toPSBT()))
|
|
3209
|
+
);
|
|
3210
|
+
const finalTx = import_sdk7.Transaction.fromPSBT(import_base8.base64.decode(finalArkTx));
|
|
3211
|
+
const serverPubkeyHex = import_base8.hex.encode(serverXOnlyPublicKey);
|
|
3212
|
+
const refundLeafHash = (0, import_payment3.tapLeafHash)(
|
|
3213
|
+
scriptFromTapLeafScript(vhtlcScript.refundWithoutReceiver())
|
|
3214
|
+
);
|
|
3215
|
+
for (let i = 0; i < finalTx.inputsLength; i++) {
|
|
3216
|
+
if (!verifySignatures(finalTx, i, [serverPubkeyHex], refundLeafHash)) {
|
|
3217
|
+
throw new Error("Invalid final Ark transaction");
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
const finalCheckpoints = await Promise.all(
|
|
3221
|
+
signedCheckpointTxs.map(async (c, idx) => {
|
|
3222
|
+
const tx = import_sdk7.Transaction.fromPSBT(import_base8.base64.decode(c));
|
|
3223
|
+
const checkpointLeaf = checkpoints[idx].getInput(0).tapLeafScript[0];
|
|
3224
|
+
const cpLeafHash = (0, import_payment3.tapLeafHash)(scriptFromTapLeafScript(checkpointLeaf));
|
|
3225
|
+
if (!verifySignatures(tx, 0, [serverPubkeyHex], cpLeafHash)) {
|
|
3226
|
+
throw new Error("Invalid server signature in checkpoint transaction");
|
|
3227
|
+
}
|
|
3228
|
+
const signedCheckpoint = await identity.sign(tx, [0]);
|
|
3229
|
+
return import_base8.base64.encode(signedCheckpoint.toPSBT());
|
|
3230
|
+
})
|
|
3231
|
+
);
|
|
3232
|
+
await arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
3233
|
+
return arkTxid;
|
|
3234
|
+
};
|
|
3189
3235
|
var refundVHTLCwithOffchainTx = async (swapId, identity, arkProvider, boltzXOnlyPublicKey, ourXOnlyPublicKey, serverXOnlyPublicKey, input, output, arkInfo, refundFunc) => {
|
|
3190
3236
|
const rawCheckpointTapscript = import_base8.hex.decode(arkInfo.checkpointTapscript);
|
|
3191
3237
|
const serverUnrollScript = import_sdk7.CSVMultisigTapscript.decode(rawCheckpointTapscript);
|
|
@@ -3492,7 +3538,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
3492
3538
|
invoiceAmount: args.amount,
|
|
3493
3539
|
claimPublicKey,
|
|
3494
3540
|
preimageHash,
|
|
3495
|
-
...args.description?.trim() ? { description: args.description.trim() } : {}
|
|
3541
|
+
...args.descriptionHash !== void 0 ? { descriptionHash: args.descriptionHash } : args.description?.trim() ? { description: args.description.trim() } : {}
|
|
3496
3542
|
};
|
|
3497
3543
|
const swapResponse = await this.swapProvider.createReverseSwap(swapRequest);
|
|
3498
3544
|
const decodedInvoice = decodeInvoice(swapResponse.invoice);
|
|
@@ -3940,85 +3986,22 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
3940
3986
|
}
|
|
3941
3987
|
const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
|
|
3942
3988
|
const refundWithoutReceiverLeaf = vhtlcScript.refundWithoutReceiver();
|
|
3943
|
-
const
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
await this.joinBatch(
|
|
3960
|
-
this.wallet.identity,
|
|
3961
|
-
input2,
|
|
3962
|
-
output,
|
|
3963
|
-
arkInfo,
|
|
3964
|
-
isRecoverableVtxo
|
|
3965
|
-
);
|
|
3966
|
-
sweptCount++;
|
|
3967
|
-
continue;
|
|
3968
|
-
}
|
|
3969
|
-
if (isRecoverableVtxo) {
|
|
3970
|
-
logger.error(
|
|
3971
|
-
`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.`
|
|
3972
|
-
);
|
|
3973
|
-
skippedCount++;
|
|
3974
|
-
continue;
|
|
3975
|
-
}
|
|
3976
|
-
const input = {
|
|
3977
|
-
...vtxo,
|
|
3978
|
-
tapLeafScript: vhtlcScript.refund(),
|
|
3979
|
-
tapTree: vhtlcScript.encode()
|
|
3980
|
-
};
|
|
3981
|
-
try {
|
|
3982
|
-
if (boltzCallCount > 0) {
|
|
3983
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
3984
|
-
}
|
|
3985
|
-
boltzCallCount++;
|
|
3986
|
-
await refundVHTLCwithOffchainTx(
|
|
3987
|
-
pendingSwap.id,
|
|
3988
|
-
this.wallet.identity,
|
|
3989
|
-
this.arkProvider,
|
|
3990
|
-
boltzXOnlyPublicKey,
|
|
3991
|
-
ourXOnlyPublicKey,
|
|
3992
|
-
serverXOnlyPublicKey,
|
|
3993
|
-
input,
|
|
3994
|
-
output,
|
|
3995
|
-
arkInfo,
|
|
3996
|
-
this.swapProvider.refundSubmarineSwap.bind(this.swapProvider)
|
|
3997
|
-
);
|
|
3998
|
-
sweptCount++;
|
|
3999
|
-
} catch (error) {
|
|
4000
|
-
if (!(error instanceof BoltzRefundError)) {
|
|
4001
|
-
throw error;
|
|
4002
|
-
}
|
|
4003
|
-
if (!isSubmarineRefundLocktimeReached(vhtlcTimeouts.refund)) {
|
|
4004
|
-
logger.error(
|
|
4005
|
-
`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.`
|
|
4006
|
-
);
|
|
4007
|
-
skippedCount++;
|
|
4008
|
-
continue;
|
|
4009
|
-
}
|
|
4010
|
-
logger.warn(
|
|
4011
|
-
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver via joinBatch`
|
|
4012
|
-
);
|
|
4013
|
-
const fallbackInput = {
|
|
4014
|
-
...vtxo,
|
|
4015
|
-
tapLeafScript: refundWithoutReceiverLeaf,
|
|
4016
|
-
tapTree: vhtlcScript.encode()
|
|
4017
|
-
};
|
|
4018
|
-
await this.joinBatch(this.wallet.identity, fallbackInput, output, arkInfo, false);
|
|
4019
|
-
sweptCount++;
|
|
4020
|
-
}
|
|
4021
|
-
}
|
|
3989
|
+
const refundContext = {
|
|
3990
|
+
arkInfo,
|
|
3991
|
+
vhtlcScript,
|
|
3992
|
+
serverXOnlyPublicKey,
|
|
3993
|
+
refundWithoutReceiverLeaf,
|
|
3994
|
+
outputScript
|
|
3995
|
+
};
|
|
3996
|
+
const { swept: sweptCount, skipped: skippedCount } = await this.refundVtxos({
|
|
3997
|
+
swapId: pendingSwap.id,
|
|
3998
|
+
vtxos: refundableVtxos,
|
|
3999
|
+
refundLocktime: vhtlcTimeouts.refund,
|
|
4000
|
+
refundContext,
|
|
4001
|
+
boltzXOnlyPublicKey,
|
|
4002
|
+
ourXOnlyPublicKey,
|
|
4003
|
+
refundViaBoltz: this.swapProvider.refundSubmarineSwap.bind(this.swapProvider)
|
|
4004
|
+
});
|
|
4022
4005
|
if (!isSubmarineSuccessStatus(pendingSwap.status)) {
|
|
4023
4006
|
const fullyRefunded = skippedCount === 0;
|
|
4024
4007
|
await updateSubmarineSwapStatus(
|
|
@@ -4576,7 +4559,10 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
4576
4559
|
* swap's ARK lockup address.
|
|
4577
4560
|
*
|
|
4578
4561
|
* Path selection per VTXO:
|
|
4579
|
-
* - CLTV
|
|
4562
|
+
* - CLTV elapsed, live VTXO → `refundWithoutReceiver` offchain (sender +
|
|
4563
|
+
* server, no Boltz, no batch round).
|
|
4564
|
+
* - CLTV elapsed, swept VTXO → `refundWithoutReceiver` via `joinBatch`
|
|
4565
|
+
* (a swept VTXO is no longer a live leaf).
|
|
4580
4566
|
* - Pre-CLTV recoverable → skipped (Boltz can't co-sign swept-batch refund).
|
|
4581
4567
|
* - Pre-CLTV non-recoverable → cooperative 3-of-3 refund via Boltz.
|
|
4582
4568
|
*
|
|
@@ -4633,84 +4619,22 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
4633
4619
|
const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
|
|
4634
4620
|
const refundWithoutReceiverLeaf = vhtlcScript.refundWithoutReceiver();
|
|
4635
4621
|
const refundLocktime = pendingSwap.response.lockupDetails.timeouts.refund;
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
this.wallet.identity,
|
|
4653
|
-
input2,
|
|
4654
|
-
output,
|
|
4655
|
-
arkInfo,
|
|
4656
|
-
isRecoverableVtxo
|
|
4657
|
-
);
|
|
4658
|
-
sweptCount++;
|
|
4659
|
-
continue;
|
|
4660
|
-
}
|
|
4661
|
-
if (isRecoverableVtxo) {
|
|
4662
|
-
logger.error(
|
|
4663
|
-
`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.`
|
|
4664
|
-
);
|
|
4665
|
-
skippedCount++;
|
|
4666
|
-
continue;
|
|
4667
|
-
}
|
|
4668
|
-
const input = {
|
|
4669
|
-
...vtxo,
|
|
4670
|
-
tapLeafScript: vhtlcScript.refund(),
|
|
4671
|
-
tapTree: vhtlcScript.encode()
|
|
4672
|
-
};
|
|
4673
|
-
try {
|
|
4674
|
-
if (boltzCallCount > 0) {
|
|
4675
|
-
await new Promise((r) => setTimeout(r, 2e3));
|
|
4676
|
-
}
|
|
4677
|
-
boltzCallCount++;
|
|
4678
|
-
await refundVHTLCwithOffchainTx(
|
|
4679
|
-
pendingSwap.id,
|
|
4680
|
-
this.wallet.identity,
|
|
4681
|
-
this.arkProvider,
|
|
4682
|
-
boltzXOnlyPublicKey,
|
|
4683
|
-
ourXOnlyPublicKey,
|
|
4684
|
-
serverXOnlyPublicKey,
|
|
4685
|
-
input,
|
|
4686
|
-
output,
|
|
4687
|
-
arkInfo,
|
|
4688
|
-
this.swapProvider.refundChainSwap.bind(this.swapProvider)
|
|
4689
|
-
);
|
|
4690
|
-
sweptCount++;
|
|
4691
|
-
} catch (error) {
|
|
4692
|
-
if (!(error instanceof BoltzRefundError)) {
|
|
4693
|
-
throw error;
|
|
4694
|
-
}
|
|
4695
|
-
if (!isSubmarineRefundLocktimeReached(refundLocktime)) {
|
|
4696
|
-
logger.error(
|
|
4697
|
-
`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.`
|
|
4698
|
-
);
|
|
4699
|
-
skippedCount++;
|
|
4700
|
-
continue;
|
|
4701
|
-
}
|
|
4702
|
-
logger.warn(
|
|
4703
|
-
`Swap ${pendingSwap.id}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver via joinBatch`
|
|
4704
|
-
);
|
|
4705
|
-
const fallbackInput = {
|
|
4706
|
-
...vtxo,
|
|
4707
|
-
tapLeafScript: refundWithoutReceiverLeaf,
|
|
4708
|
-
tapTree: vhtlcScript.encode()
|
|
4709
|
-
};
|
|
4710
|
-
await this.joinBatch(this.wallet.identity, fallbackInput, output, arkInfo, false);
|
|
4711
|
-
sweptCount++;
|
|
4712
|
-
}
|
|
4713
|
-
}
|
|
4622
|
+
const refundContext = {
|
|
4623
|
+
arkInfo,
|
|
4624
|
+
vhtlcScript,
|
|
4625
|
+
serverXOnlyPublicKey,
|
|
4626
|
+
refundWithoutReceiverLeaf,
|
|
4627
|
+
outputScript
|
|
4628
|
+
};
|
|
4629
|
+
const { swept: sweptCount, skipped: skippedCount } = await this.refundVtxos({
|
|
4630
|
+
swapId: pendingSwap.id,
|
|
4631
|
+
vtxos: unspentVtxos,
|
|
4632
|
+
refundLocktime,
|
|
4633
|
+
refundContext,
|
|
4634
|
+
boltzXOnlyPublicKey,
|
|
4635
|
+
ourXOnlyPublicKey,
|
|
4636
|
+
refundViaBoltz: this.swapProvider.refundChainSwap.bind(this.swapProvider)
|
|
4637
|
+
});
|
|
4714
4638
|
const finalStatus = await this.getSwapStatus(pendingSwap.id);
|
|
4715
4639
|
await this.savePendingChainSwap({
|
|
4716
4640
|
...pendingSwap,
|
|
@@ -5243,6 +5167,120 @@ var ArkadeSwaps = class _ArkadeSwaps {
|
|
|
5243
5167
|
async joinBatch(identity, input, output, arkInfo, isRecoverable2 = true) {
|
|
5244
5168
|
return joinBatch(this.arkProvider, identity, input, output, arkInfo, isRecoverable2);
|
|
5245
5169
|
}
|
|
5170
|
+
/**
|
|
5171
|
+
* Settle a `refundWithoutReceiver` (sender + server, no Boltz) refund for a
|
|
5172
|
+
* single VTXO whose CLTV refund locktime has elapsed.
|
|
5173
|
+
*
|
|
5174
|
+
* A live VTXO settles the leaf with an offchain Ark tx — no batch round. A
|
|
5175
|
+
* swept (recoverable) VTXO is no longer a live leaf, so it can only be
|
|
5176
|
+
* reclaimed by re-registering it into a batch.
|
|
5177
|
+
*/
|
|
5178
|
+
async settleRefundWithoutReceiver(ctx, vtxo) {
|
|
5179
|
+
const input = {
|
|
5180
|
+
...vtxo,
|
|
5181
|
+
tapLeafScript: ctx.refundWithoutReceiverLeaf,
|
|
5182
|
+
tapTree: ctx.vhtlcScript.encode()
|
|
5183
|
+
};
|
|
5184
|
+
const output = { amount: BigInt(vtxo.value), script: ctx.outputScript };
|
|
5185
|
+
if ((0, import_sdk8.isRecoverable)(vtxo)) {
|
|
5186
|
+
await this.joinBatch(this.wallet.identity, input, output, ctx.arkInfo, true);
|
|
5187
|
+
} else {
|
|
5188
|
+
await refundWithoutReceiverVHTLCwithOffchainTx(
|
|
5189
|
+
this.wallet.identity,
|
|
5190
|
+
ctx.vhtlcScript,
|
|
5191
|
+
ctx.serverXOnlyPublicKey,
|
|
5192
|
+
input,
|
|
5193
|
+
output,
|
|
5194
|
+
ctx.arkInfo,
|
|
5195
|
+
this.arkProvider
|
|
5196
|
+
);
|
|
5197
|
+
}
|
|
5198
|
+
}
|
|
5199
|
+
/**
|
|
5200
|
+
* Refund every VTXO at a swap's VHTLC address back to the wallet, shared by
|
|
5201
|
+
* {@link ArkadeSwaps.refundVHTLC} (submarine) and {@link ArkadeSwaps.refundArk}
|
|
5202
|
+
* (chain). Path selection per VTXO:
|
|
5203
|
+
* - CLTV elapsed → `refundWithoutReceiver` (offchain for a live VTXO, via a
|
|
5204
|
+
* batch round for a swept one — see {@link settleRefundWithoutReceiver}).
|
|
5205
|
+
* - Pre-CLTV recoverable → skipped (Boltz can't co-sign a swept-batch refund).
|
|
5206
|
+
* - Pre-CLTV non-recoverable → cooperative 3-of-3 refund via Boltz, falling
|
|
5207
|
+
* back to `refundWithoutReceiver` offchain if Boltz rejects after the
|
|
5208
|
+
* locktime has since elapsed.
|
|
5209
|
+
*
|
|
5210
|
+
* @returns Counts of VTXOs swept vs. deferred.
|
|
5211
|
+
*/
|
|
5212
|
+
async refundVtxos(params) {
|
|
5213
|
+
const {
|
|
5214
|
+
swapId,
|
|
5215
|
+
vtxos,
|
|
5216
|
+
refundLocktime,
|
|
5217
|
+
refundContext,
|
|
5218
|
+
boltzXOnlyPublicKey,
|
|
5219
|
+
ourXOnlyPublicKey,
|
|
5220
|
+
refundViaBoltz
|
|
5221
|
+
} = params;
|
|
5222
|
+
const { vhtlcScript, serverXOnlyPublicKey, arkInfo, outputScript } = refundContext;
|
|
5223
|
+
let boltzCallCount = 0;
|
|
5224
|
+
let sweptCount = 0;
|
|
5225
|
+
let skippedCount = 0;
|
|
5226
|
+
for (const vtxo of vtxos) {
|
|
5227
|
+
const isRecoverableVtxo = (0, import_sdk8.isRecoverable)(vtxo);
|
|
5228
|
+
const output = { amount: BigInt(vtxo.value), script: outputScript };
|
|
5229
|
+
if (isSubmarineRefundLocktimeReached(refundLocktime)) {
|
|
5230
|
+
await this.settleRefundWithoutReceiver(refundContext, vtxo);
|
|
5231
|
+
sweptCount++;
|
|
5232
|
+
continue;
|
|
5233
|
+
}
|
|
5234
|
+
if (isRecoverableVtxo) {
|
|
5235
|
+
logger.error(
|
|
5236
|
+
`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.`
|
|
5237
|
+
);
|
|
5238
|
+
skippedCount++;
|
|
5239
|
+
continue;
|
|
5240
|
+
}
|
|
5241
|
+
const input = {
|
|
5242
|
+
...vtxo,
|
|
5243
|
+
tapLeafScript: vhtlcScript.refund(),
|
|
5244
|
+
tapTree: vhtlcScript.encode()
|
|
5245
|
+
};
|
|
5246
|
+
try {
|
|
5247
|
+
if (boltzCallCount > 0) {
|
|
5248
|
+
await new Promise((r) => setTimeout(r, 2e3));
|
|
5249
|
+
}
|
|
5250
|
+
boltzCallCount++;
|
|
5251
|
+
await refundVHTLCwithOffchainTx(
|
|
5252
|
+
swapId,
|
|
5253
|
+
this.wallet.identity,
|
|
5254
|
+
this.arkProvider,
|
|
5255
|
+
boltzXOnlyPublicKey,
|
|
5256
|
+
ourXOnlyPublicKey,
|
|
5257
|
+
serverXOnlyPublicKey,
|
|
5258
|
+
input,
|
|
5259
|
+
output,
|
|
5260
|
+
arkInfo,
|
|
5261
|
+
refundViaBoltz
|
|
5262
|
+
);
|
|
5263
|
+
sweptCount++;
|
|
5264
|
+
} catch (error) {
|
|
5265
|
+
if (!(error instanceof BoltzRefundError)) {
|
|
5266
|
+
throw error;
|
|
5267
|
+
}
|
|
5268
|
+
if (!isSubmarineRefundLocktimeReached(refundLocktime)) {
|
|
5269
|
+
logger.error(
|
|
5270
|
+
`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.`
|
|
5271
|
+
);
|
|
5272
|
+
skippedCount++;
|
|
5273
|
+
continue;
|
|
5274
|
+
}
|
|
5275
|
+
logger.warn(
|
|
5276
|
+
`Swap ${swapId}: Boltz rejected VTXO outpoint, falling back to refundWithoutReceiver offchain`
|
|
5277
|
+
);
|
|
5278
|
+
await this.settleRefundWithoutReceiver(refundContext, vtxo);
|
|
5279
|
+
sweptCount++;
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
return { swept: sweptCount, skipped: skippedCount };
|
|
5283
|
+
}
|
|
5246
5284
|
/**
|
|
5247
5285
|
* Creates a VHTLC script for the swap.
|
|
5248
5286
|
* Works for submarine, reverse, and chain swaps.
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-
|
|
2
|
-
export { A as ArkadeSwaps } from './arkade-swaps-
|
|
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-
|
|
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-
|
|
1
|
+
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-C8CmzknM.cjs';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-C8CmzknM.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, 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-CS62-oEy.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 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-CS62-oEy.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';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-
|
|
2
|
-
export { A as ArkadeSwaps } from './arkade-swaps-
|
|
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-
|
|
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-
|
|
1
|
+
import { Q as QuoteSwapOptions, I as IArkadeSwaps, V as VhtlcTimeouts } from './arkade-swaps-gXHRbR09.js';
|
|
2
|
+
export { A as ArkadeSwaps } from './arkade-swaps-gXHRbR09.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, 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-CS62-oEy.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 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-CS62-oEy.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';
|
package/dist/index.js
CHANGED
|
@@ -53,14 +53,14 @@ import {
|
|
|
53
53
|
updateReverseSwapStatus,
|
|
54
54
|
updateSubmarineSwapStatus,
|
|
55
55
|
verifySignatures
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-5GBBRBFS.js";
|
|
57
57
|
import {
|
|
58
58
|
applyCreatedAtOrder,
|
|
59
59
|
applySwapsFilter
|
|
60
60
|
} from "./chunk-SJQJQO7P.js";
|
|
61
61
|
|
|
62
62
|
// package.json
|
|
63
|
-
var version = "0.3.
|
|
63
|
+
var version = "0.3.45";
|
|
64
64
|
|
|
65
65
|
// src/serviceWorker/arkade-swaps-message-handler.ts
|
|
66
66
|
import { RestArkProvider, RestIndexerProvider } from "@arkade-os/sdk";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RealmLike } from '@arkade-os/sdk/repositories/realm';
|
|
2
|
-
import { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-
|
|
2
|
+
import { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-CS62-oEy.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 { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-
|
|
2
|
+
import { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-CS62-oEy.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 { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-
|
|
2
|
+
import { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-CS62-oEy.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 { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-
|
|
2
|
+
import { m as SwapRepository, B as BoltzSwap, p as GetSwapsFilter } from '../../types-CS62-oEy.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 { m as SwapRepository, N as Network, r as BoltzSwapProvider, A as ArkadeSwapsConfig } from './types-
|
|
3
|
+
import { m as SwapRepository, N as Network, r as BoltzSwapProvider, A as ArkadeSwapsConfig } from './types-CS62-oEy.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 { m as SwapRepository, N as Network, r as BoltzSwapProvider, A as ArkadeSwapsConfig } from './types-
|
|
3
|
+
import { m as SwapRepository, N as Network, r as BoltzSwapProvider, A as ArkadeSwapsConfig } from './types-CS62-oEy.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Dependencies injected into every swap processor at runtime.
|
|
@@ -144,6 +144,12 @@ type CreateReverseSwapRequest = {
|
|
|
144
144
|
preimageHash: string;
|
|
145
145
|
/** Optional description for the BOLT11 invoice. */
|
|
146
146
|
description?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Optional SHA256 description hash (hex, 32 bytes / 64 chars) to commit
|
|
149
|
+
* into the invoice instead of a plaintext description. BOLT11 carries one
|
|
150
|
+
* or the other, never both; when set, `description` is omitted.
|
|
151
|
+
*/
|
|
152
|
+
descriptionHash?: string;
|
|
147
153
|
};
|
|
148
154
|
/** Response from creating a reverse swap. */
|
|
149
155
|
type CreateReverseSwapResponse = {
|
|
@@ -345,7 +351,7 @@ declare class BoltzSwapProvider {
|
|
|
345
351
|
/** Creates a submarine swap (Arkade → Lightning) on Boltz. */
|
|
346
352
|
createSubmarineSwap({ invoice, refundPublicKey, }: CreateSubmarineSwapRequest): Promise<CreateSubmarineSwapResponse>;
|
|
347
353
|
/** Creates a reverse swap (Lightning → Arkade) on Boltz. */
|
|
348
|
-
createReverseSwap({ invoiceAmount, claimPublicKey, preimageHash, description, }: CreateReverseSwapRequest): Promise<CreateReverseSwapResponse>;
|
|
354
|
+
createReverseSwap({ invoiceAmount, claimPublicKey, preimageHash, description, descriptionHash, }: CreateReverseSwapRequest): Promise<CreateReverseSwapResponse>;
|
|
349
355
|
/** Creates a chain swap (ARK ↔ BTC) on Boltz. */
|
|
350
356
|
createChainSwap({ to, from, preimageHash, feeSatsPerByte, claimPublicKey, refundPublicKey, serverLockAmount, userLockAmount, }: CreateChainSwapRequest): Promise<CreateChainSwapResponse>;
|
|
351
357
|
/** Requests Boltz co-signature for a submarine swap refund. Returns signed transaction + checkpoint. */
|
|
@@ -915,6 +921,15 @@ interface CreateLightningInvoiceRequest {
|
|
|
915
921
|
amount: number;
|
|
916
922
|
/** Optional description embedded in the BOLT11 invoice. */
|
|
917
923
|
description?: string;
|
|
924
|
+
/**
|
|
925
|
+
* Optional SHA256 description hash (hex, 32 bytes) to commit into the
|
|
926
|
+
* BOLT11 invoice instead of a plaintext description. A BOLT11 invoice
|
|
927
|
+
* carries either a description or a description hash, never both, so when
|
|
928
|
+
* this is set `description` is ignored. Use this for flows that must bind
|
|
929
|
+
* the invoice to an external document — e.g. NIP-57 zaps, where the hash
|
|
930
|
+
* is SHA256 of the zap request and the receipt later proves the match.
|
|
931
|
+
*/
|
|
932
|
+
descriptionHash?: string;
|
|
918
933
|
}
|
|
919
934
|
/** Response containing the created Lightning invoice and swap details. */
|
|
920
935
|
interface CreateLightningInvoiceResponse {
|
|
@@ -1161,8 +1176,10 @@ interface DecodedInvoice {
|
|
|
1161
1176
|
expiry: number;
|
|
1162
1177
|
/** Invoice amount in satoshis. */
|
|
1163
1178
|
amountSats: number;
|
|
1164
|
-
/** Invoice description string. */
|
|
1179
|
+
/** Invoice description string (BOLT11 `d` field; "" if none). */
|
|
1165
1180
|
description: string;
|
|
1181
|
+
/** Invoice description hash (BOLT11 `h` field, hex; "" if none). */
|
|
1182
|
+
descriptionHash: string;
|
|
1166
1183
|
/** Payment hash (hex-encoded). */
|
|
1167
1184
|
paymentHash: string;
|
|
1168
1185
|
}
|
|
@@ -144,6 +144,12 @@ type CreateReverseSwapRequest = {
|
|
|
144
144
|
preimageHash: string;
|
|
145
145
|
/** Optional description for the BOLT11 invoice. */
|
|
146
146
|
description?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Optional SHA256 description hash (hex, 32 bytes / 64 chars) to commit
|
|
149
|
+
* into the invoice instead of a plaintext description. BOLT11 carries one
|
|
150
|
+
* or the other, never both; when set, `description` is omitted.
|
|
151
|
+
*/
|
|
152
|
+
descriptionHash?: string;
|
|
147
153
|
};
|
|
148
154
|
/** Response from creating a reverse swap. */
|
|
149
155
|
type CreateReverseSwapResponse = {
|
|
@@ -345,7 +351,7 @@ declare class BoltzSwapProvider {
|
|
|
345
351
|
/** Creates a submarine swap (Arkade → Lightning) on Boltz. */
|
|
346
352
|
createSubmarineSwap({ invoice, refundPublicKey, }: CreateSubmarineSwapRequest): Promise<CreateSubmarineSwapResponse>;
|
|
347
353
|
/** Creates a reverse swap (Lightning → Arkade) on Boltz. */
|
|
348
|
-
createReverseSwap({ invoiceAmount, claimPublicKey, preimageHash, description, }: CreateReverseSwapRequest): Promise<CreateReverseSwapResponse>;
|
|
354
|
+
createReverseSwap({ invoiceAmount, claimPublicKey, preimageHash, description, descriptionHash, }: CreateReverseSwapRequest): Promise<CreateReverseSwapResponse>;
|
|
349
355
|
/** Creates a chain swap (ARK ↔ BTC) on Boltz. */
|
|
350
356
|
createChainSwap({ to, from, preimageHash, feeSatsPerByte, claimPublicKey, refundPublicKey, serverLockAmount, userLockAmount, }: CreateChainSwapRequest): Promise<CreateChainSwapResponse>;
|
|
351
357
|
/** Requests Boltz co-signature for a submarine swap refund. Returns signed transaction + checkpoint. */
|
|
@@ -915,6 +921,15 @@ interface CreateLightningInvoiceRequest {
|
|
|
915
921
|
amount: number;
|
|
916
922
|
/** Optional description embedded in the BOLT11 invoice. */
|
|
917
923
|
description?: string;
|
|
924
|
+
/**
|
|
925
|
+
* Optional SHA256 description hash (hex, 32 bytes) to commit into the
|
|
926
|
+
* BOLT11 invoice instead of a plaintext description. A BOLT11 invoice
|
|
927
|
+
* carries either a description or a description hash, never both, so when
|
|
928
|
+
* this is set `description` is ignored. Use this for flows that must bind
|
|
929
|
+
* the invoice to an external document — e.g. NIP-57 zaps, where the hash
|
|
930
|
+
* is SHA256 of the zap request and the receipt later proves the match.
|
|
931
|
+
*/
|
|
932
|
+
descriptionHash?: string;
|
|
918
933
|
}
|
|
919
934
|
/** Response containing the created Lightning invoice and swap details. */
|
|
920
935
|
interface CreateLightningInvoiceResponse {
|
|
@@ -1161,8 +1176,10 @@ interface DecodedInvoice {
|
|
|
1161
1176
|
expiry: number;
|
|
1162
1177
|
/** Invoice amount in satoshis. */
|
|
1163
1178
|
amountSats: number;
|
|
1164
|
-
/** Invoice description string. */
|
|
1179
|
+
/** Invoice description string (BOLT11 `d` field; "" if none). */
|
|
1165
1180
|
description: string;
|
|
1181
|
+
/** Invoice description hash (BOLT11 `h` field, hex; "" if none). */
|
|
1182
|
+
descriptionHash: string;
|
|
1166
1183
|
/** Payment hash (hex-encoded). */
|
|
1167
1184
|
paymentHash: string;
|
|
1168
1185
|
}
|
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.45",
|
|
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.40"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"expo-task-manager": ">=3.0.0",
|