@arkade-os/boltz-swap 0.3.16 → 0.3.17

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.
@@ -2,8 +2,8 @@ import {
2
2
  defineExpoSwapBackgroundTask,
3
3
  registerExpoSwapBackgroundTask,
4
4
  unregisterExpoSwapBackgroundTask
5
- } from "./chunk-CNH5DDKV.js";
6
- import "./chunk-RL4PDED5.js";
5
+ } from "./chunk-GSCLW33R.js";
6
+ import "./chunk-CS6UXZP6.js";
7
7
  import "./chunk-3RG5ZIWI.js";
8
8
  export {
9
9
  defineExpoSwapBackgroundTask,
@@ -465,7 +465,7 @@ var BoltzSwapProvider = class {
465
465
  invoiceAmount,
466
466
  claimPublicKey,
467
467
  preimageHash,
468
- ...description?.trim() ? { description: description.trim() } : {},
468
+ description: description?.trim() || "Send to Arkade address",
469
469
  ...this.referralId ? { referralId: this.referralId } : {}
470
470
  };
471
471
  const response = await this.request(
@@ -3543,16 +3543,39 @@ var ArkadeSwaps = class _ArkadeSwaps {
3543
3543
  `VHTLC address mismatch for swap ${pendingSwap.id}: expected ${pendingSwap.response.address}, got ${vhtlcAddress}`
3544
3544
  );
3545
3545
  const vhtlcPkScriptHex = hex8.encode(vhtlcScript.pkScript);
3546
- const { vtxos: spendableVtxos } = await this.indexerProvider.getVtxos({
3547
- scripts: [vhtlcPkScriptHex],
3548
- spendableOnly: true
3549
- });
3550
- if (spendableVtxos.length === 0) {
3546
+ const [spendableResult, recoverableResult] = await Promise.all([
3547
+ this.indexerProvider.getVtxos({
3548
+ scripts: [vhtlcPkScriptHex],
3549
+ spendableOnly: true
3550
+ }),
3551
+ this.indexerProvider.getVtxos({
3552
+ scripts: [vhtlcPkScriptHex],
3553
+ recoverableOnly: true
3554
+ })
3555
+ ]);
3556
+ const refundableVtxos = [
3557
+ ...new Map(
3558
+ [...spendableResult.vtxos, ...recoverableResult.vtxos].map(
3559
+ (vtxo) => [`${vtxo.txid}:${vtxo.vout}`, vtxo]
3560
+ )
3561
+ ).values()
3562
+ ];
3563
+ if (refundableVtxos.length === 0) {
3551
3564
  const { vtxos: allVtxos } = await this.indexerProvider.getVtxos({
3552
3565
  scripts: [vhtlcPkScriptHex]
3553
3566
  });
3567
+ if (allVtxos.length === 0) {
3568
+ throw new Error(
3569
+ `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
3570
+ );
3571
+ }
3572
+ if (allVtxos.every((vtxo) => vtxo.isSpent)) {
3573
+ throw new Error(
3574
+ `Swap ${pendingSwap.id}: VHTLC is already spent`
3575
+ );
3576
+ }
3554
3577
  throw new Error(
3555
- allVtxos.length > 0 ? `Swap ${pendingSwap.id}: VHTLC is already spent` : `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
3578
+ `Swap ${pendingSwap.id}: VHTLC has no refundable VTXOs yet`
3556
3579
  );
3557
3580
  }
3558
3581
  const outputScript = ArkAddress2.decode(address).pkScript;
@@ -3562,7 +3585,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
3562
3585
  const cltvSatisfied = BigInt(currentBlockHeight) >= refundLocktime;
3563
3586
  let boltzCallCount = 0;
3564
3587
  let skippedCount = 0;
3565
- for (const vtxo of spendableVtxos) {
3588
+ for (const vtxo of refundableVtxos) {
3566
3589
  const isRecoverableVtxo = isRecoverable(vtxo);
3567
3590
  const output = {
3568
3591
  amount: BigInt(vtxo.value),
@@ -8,7 +8,7 @@ import {
8
8
  isSubmarineFinalStatus,
9
9
  isSubmarineSwapRefundable,
10
10
  logger
11
- } from "./chunk-RL4PDED5.js";
11
+ } from "./chunk-CS6UXZP6.js";
12
12
  import {
13
13
  __require
14
14
  } from "./chunk-3RG5ZIWI.js";
@@ -429,7 +429,7 @@ var init_boltz_swap_provider = __esm({
429
429
  invoiceAmount,
430
430
  claimPublicKey,
431
431
  preimageHash,
432
- ...description?.trim() ? { description: description.trim() } : {},
432
+ description: description?.trim() || "Send to Arkade address",
433
433
  ...this.referralId ? { referralId: this.referralId } : {}
434
434
  };
435
435
  const response = await this.request(
@@ -3549,16 +3549,39 @@ var init_arkade_swaps = __esm({
3549
3549
  `VHTLC address mismatch for swap ${pendingSwap.id}: expected ${pendingSwap.response.address}, got ${vhtlcAddress}`
3550
3550
  );
3551
3551
  const vhtlcPkScriptHex = import_base9.hex.encode(vhtlcScript.pkScript);
3552
- const { vtxos: spendableVtxos } = await this.indexerProvider.getVtxos({
3553
- scripts: [vhtlcPkScriptHex],
3554
- spendableOnly: true
3555
- });
3556
- if (spendableVtxos.length === 0) {
3552
+ const [spendableResult, recoverableResult] = await Promise.all([
3553
+ this.indexerProvider.getVtxos({
3554
+ scripts: [vhtlcPkScriptHex],
3555
+ spendableOnly: true
3556
+ }),
3557
+ this.indexerProvider.getVtxos({
3558
+ scripts: [vhtlcPkScriptHex],
3559
+ recoverableOnly: true
3560
+ })
3561
+ ]);
3562
+ const refundableVtxos = [
3563
+ ...new Map(
3564
+ [...spendableResult.vtxos, ...recoverableResult.vtxos].map(
3565
+ (vtxo) => [`${vtxo.txid}:${vtxo.vout}`, vtxo]
3566
+ )
3567
+ ).values()
3568
+ ];
3569
+ if (refundableVtxos.length === 0) {
3557
3570
  const { vtxos: allVtxos } = await this.indexerProvider.getVtxos({
3558
3571
  scripts: [vhtlcPkScriptHex]
3559
3572
  });
3573
+ if (allVtxos.length === 0) {
3574
+ throw new Error(
3575
+ `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
3576
+ );
3577
+ }
3578
+ if (allVtxos.every((vtxo) => vtxo.isSpent)) {
3579
+ throw new Error(
3580
+ `Swap ${pendingSwap.id}: VHTLC is already spent`
3581
+ );
3582
+ }
3560
3583
  throw new Error(
3561
- allVtxos.length > 0 ? `Swap ${pendingSwap.id}: VHTLC is already spent` : `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
3584
+ `Swap ${pendingSwap.id}: VHTLC has no refundable VTXOs yet`
3562
3585
  );
3563
3586
  }
3564
3587
  const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
@@ -3568,7 +3591,7 @@ var init_arkade_swaps = __esm({
3568
3591
  const cltvSatisfied = BigInt(currentBlockHeight) >= refundLocktime;
3569
3592
  let boltzCallCount = 0;
3570
3593
  let skippedCount = 0;
3571
- for (const vtxo of spendableVtxos) {
3594
+ for (const vtxo of refundableVtxos) {
3572
3595
  const isRecoverableVtxo = (0, import_sdk8.isRecoverable)(vtxo);
3573
3596
  const output = {
3574
3597
  amount: BigInt(vtxo.value),
@@ -4,10 +4,10 @@ import {
4
4
  registerExpoSwapBackgroundTask,
5
5
  swapsPollProcessor,
6
6
  unregisterExpoSwapBackgroundTask
7
- } from "../chunk-CNH5DDKV.js";
7
+ } from "../chunk-GSCLW33R.js";
8
8
  import {
9
9
  ArkadeSwaps
10
- } from "../chunk-RL4PDED5.js";
10
+ } from "../chunk-CS6UXZP6.js";
11
11
  import "../chunk-3RG5ZIWI.js";
12
12
 
13
13
  // src/expo/arkade-lightning.ts
@@ -56,7 +56,7 @@ var ExpoArkadeSwaps = class _ExpoArkadeSwaps {
56
56
  await instance.seedSwapPollTask();
57
57
  if (config.background.minimumBackgroundInterval) {
58
58
  try {
59
- const { registerExpoSwapBackgroundTask: registerExpoSwapBackgroundTask2 } = await import("../background-DX6SZGGJ.js");
59
+ const { registerExpoSwapBackgroundTask: registerExpoSwapBackgroundTask2 } = await import("../background-65LGXZHJ.js");
60
60
  await registerExpoSwapBackgroundTask2(
61
61
  config.background.taskName,
62
62
  {
@@ -129,7 +129,7 @@ var ExpoArkadeSwaps = class _ExpoArkadeSwaps {
129
129
  }
130
130
  await this.inner.dispose();
131
131
  try {
132
- const { unregisterExpoSwapBackgroundTask: unregisterExpoSwapBackgroundTask2 } = await import("../background-DX6SZGGJ.js");
132
+ const { unregisterExpoSwapBackgroundTask: unregisterExpoSwapBackgroundTask2 } = await import("../background-65LGXZHJ.js");
133
133
  await unregisterExpoSwapBackgroundTask2(this.taskName);
134
134
  } catch (err) {
135
135
  const message = err instanceof Error ? err.message : String(err);
package/dist/index.cjs CHANGED
@@ -559,7 +559,7 @@ var BoltzSwapProvider = class {
559
559
  invoiceAmount,
560
560
  claimPublicKey,
561
561
  preimageHash,
562
- ...description?.trim() ? { description: description.trim() } : {},
562
+ description: description?.trim() || "Send to Arkade address",
563
563
  ...this.referralId ? { referralId: this.referralId } : {}
564
564
  };
565
565
  const response = await this.request(
@@ -3603,16 +3603,39 @@ var ArkadeSwaps = class _ArkadeSwaps {
3603
3603
  `VHTLC address mismatch for swap ${pendingSwap.id}: expected ${pendingSwap.response.address}, got ${vhtlcAddress}`
3604
3604
  );
3605
3605
  const vhtlcPkScriptHex = import_base9.hex.encode(vhtlcScript.pkScript);
3606
- const { vtxos: spendableVtxos } = await this.indexerProvider.getVtxos({
3607
- scripts: [vhtlcPkScriptHex],
3608
- spendableOnly: true
3609
- });
3610
- if (spendableVtxos.length === 0) {
3606
+ const [spendableResult, recoverableResult] = await Promise.all([
3607
+ this.indexerProvider.getVtxos({
3608
+ scripts: [vhtlcPkScriptHex],
3609
+ spendableOnly: true
3610
+ }),
3611
+ this.indexerProvider.getVtxos({
3612
+ scripts: [vhtlcPkScriptHex],
3613
+ recoverableOnly: true
3614
+ })
3615
+ ]);
3616
+ const refundableVtxos = [
3617
+ ...new Map(
3618
+ [...spendableResult.vtxos, ...recoverableResult.vtxos].map(
3619
+ (vtxo) => [`${vtxo.txid}:${vtxo.vout}`, vtxo]
3620
+ )
3621
+ ).values()
3622
+ ];
3623
+ if (refundableVtxos.length === 0) {
3611
3624
  const { vtxos: allVtxos } = await this.indexerProvider.getVtxos({
3612
3625
  scripts: [vhtlcPkScriptHex]
3613
3626
  });
3627
+ if (allVtxos.length === 0) {
3628
+ throw new Error(
3629
+ `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
3630
+ );
3631
+ }
3632
+ if (allVtxos.every((vtxo) => vtxo.isSpent)) {
3633
+ throw new Error(
3634
+ `Swap ${pendingSwap.id}: VHTLC is already spent`
3635
+ );
3636
+ }
3614
3637
  throw new Error(
3615
- allVtxos.length > 0 ? `Swap ${pendingSwap.id}: VHTLC is already spent` : `Swap ${pendingSwap.id}: VHTLC not found for address ${pendingSwap.response.address}`
3638
+ `Swap ${pendingSwap.id}: VHTLC has no refundable VTXOs yet`
3616
3639
  );
3617
3640
  }
3618
3641
  const outputScript = import_sdk8.ArkAddress.decode(address).pkScript;
@@ -3622,7 +3645,7 @@ var ArkadeSwaps = class _ArkadeSwaps {
3622
3645
  const cltvSatisfied = BigInt(currentBlockHeight) >= refundLocktime;
3623
3646
  let boltzCallCount = 0;
3624
3647
  let skippedCount = 0;
3625
- for (const vtxo of spendableVtxos) {
3648
+ for (const vtxo of refundableVtxos) {
3626
3649
  const isRecoverableVtxo = (0, import_sdk8.isRecoverable)(vtxo);
3627
3650
  const output = {
3628
3651
  amount: BigInt(vtxo.value),
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  updateReverseSwapStatus,
51
51
  updateSubmarineSwapStatus,
52
52
  verifySignatures
53
- } from "./chunk-RL4PDED5.js";
53
+ } from "./chunk-CS6UXZP6.js";
54
54
  import "./chunk-3RG5ZIWI.js";
55
55
 
56
56
  // src/serviceWorker/arkade-swaps-message-handler.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/boltz-swap",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
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",
@@ -60,7 +60,7 @@
60
60
  "author": "Arkade-OS",
61
61
  "license": "MIT",
62
62
  "dependencies": {
63
- "@arkade-os/sdk": "0.4.15",
63
+ "@arkade-os/sdk": "0.4.16",
64
64
  "@noble/hashes": "2.0.1",
65
65
  "@scure/base": "2.0.0",
66
66
  "@scure/btc-signer": "2.0.1",