@satora/swap 1.11.0 → 1.11.1

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.
@@ -115,7 +115,7 @@ import {
115
115
  sha2562,
116
116
  sha512,
117
117
  utils
118
- } from "./chunk-ZAQ7YV6W.js";
118
+ } from "./chunk-TT3J2OOS.js";
119
119
  import {
120
120
  ArkAddress,
121
121
  CSVMultisigTapscript,
@@ -13796,8 +13796,7 @@ async function buildArkadeClaim(params) {
13796
13796
  // The preimage will be added to the witness during signing
13797
13797
  witnessData: preimageBytes
13798
13798
  }));
13799
- const { ArkAddress: ArkAddress2 } = await import("./dist-OHZT2JOQ-IUFU3NGC.js");
13800
- const destAddr = ArkAddress2.decode(destinationAddress);
13799
+ const destAddr = ArkAddress.decode(destinationAddress);
13801
13800
  const destPkScript = destAddr.pkScript;
13802
13801
  const outputs = [
13803
13802
  {
@@ -13867,7 +13866,7 @@ async function continueArkadeClaim(params) {
13867
13866
  unilateralClaimDelay,
13868
13867
  unilateralRefundDelay,
13869
13868
  unilateralRefundWithoutReceiverDelay,
13870
- // destinationAddress not needed — we continue an existing pending tx
13869
+ destinationAddress,
13871
13870
  network,
13872
13871
  arkadeHtlcScriptVersion,
13873
13872
  arkadeServerUrl
@@ -13948,7 +13947,6 @@ async function continueArkadeClaim(params) {
13948
13947
  throw new Error("Total VTXO amount is zero");
13949
13948
  }
13950
13949
  const claimLeafScript = vhtlc.claim();
13951
- const claimScriptByte = claimLeafScript[1];
13952
13950
  const tapTree = vhtlc.encode();
13953
13951
  logger.info({
13954
13952
  event: "arkade.claim.continue_vtxos_found",
@@ -13996,6 +13994,25 @@ async function continueArkadeClaim(params) {
13996
13994
  "No pending transactions found at the VHTLC address. The claim may have already been finalized or was never submitted."
13997
13995
  );
13998
13996
  }
13997
+ if (destinationAddress) {
13998
+ const expectedScript = hex.encode(
13999
+ ArkAddress.decode(destinationAddress).pkScript
14000
+ );
14001
+ for (const { arkTxid, finalArkTx } of pendingTxs) {
14002
+ const arkTx = Transaction2.fromPSBT(base64.decode(finalArkTx));
14003
+ if (arkTx.id !== arkTxid) {
14004
+ throw new Error(
14005
+ "Pending Arkade claim transaction ID does not match its PSBT."
14006
+ );
14007
+ }
14008
+ const { amount, script } = arkTx.getOutput(0);
14009
+ if (!amount || !script || hex.encode(script) !== expectedScript) {
14010
+ throw new Error(
14011
+ "Pending Arkade claim does not pay the requested destination address."
14012
+ );
14013
+ }
14014
+ }
14015
+ }
13999
14016
  logger.info({
14000
14017
  event: "arkade.claim.pending_txs_found",
14001
14018
  message: "Found pending Arkade claim transactions",
@@ -14007,9 +14024,6 @@ async function continueArkadeClaim(params) {
14007
14024
  const finalCheckpoints = await Promise.all(
14008
14025
  signedCheckpointTxs.map(async (c) => {
14009
14026
  const checkpointTx = Transaction2.fromPSBT(base64.decode(c));
14010
- checkpointTx.updateInput(0, {
14011
- witnessScript: claimScriptByte
14012
- });
14013
14027
  for (let i = 0; i < checkpointTx.inputsLength; i++) {
14014
14028
  ensureConditionWitness(checkpointTx, i, preimageBytes);
14015
14029
  }
@@ -17439,12 +17453,7 @@ var Client = class _Client {
17439
17453
  };
17440
17454
  }
17441
17455
  if (vtxoStatus === "spent") {
17442
- const continued = await this.continueArkadeClaimSwap(id);
17443
- if (continued.success) return continued;
17444
- return {
17445
- success: false,
17446
- message: "All VTXOs have already been spent."
17447
- };
17456
+ return this.#continueArkadeClaim(claimParams, options);
17448
17457
  }
17449
17458
  if (vtxoStatus === "spendable") {
17450
17459
  return this.#claimArkadeOffchain(claimParams, options);
@@ -17675,13 +17684,16 @@ var Client = class _Client {
17675
17684
  message: `Expected an Arkade-destination swap, got ${swap.direction}.`
17676
17685
  };
17677
17686
  }
17678
- const claimParams = this.#extractArkadeClaimParams(id, storedSwap);
17687
+ return this.#continueArkadeClaim(
17688
+ this.#extractArkadeClaimParams(id, storedSwap)
17689
+ );
17690
+ }
17691
+ async #continueArkadeClaim(claimParams, options) {
17679
17692
  try {
17680
17693
  const result = await continueArkadeClaim({
17681
17694
  ...claimParams,
17682
- destinationAddress: "",
17683
- // not needed for continue
17684
- arkadeServerUrl: this.#config.arkadeServerUrl,
17695
+ destinationAddress: options?.destinationAddress,
17696
+ arkadeServerUrl: options?.arkadeServerUrl ?? this.#config.arkadeServerUrl,
17685
17697
  logger: this.#config.logger,
17686
17698
  logLevel: this.#config.logLevel
17687
17699
  });
@@ -22993,4 +23005,4 @@ export {
22993
23005
  @scure/bip39/index.js:
22994
23006
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
22995
23007
  */
22996
- //# sourceMappingURL=chunk-BVTLZLT2.js.map
23008
+ //# sourceMappingURL=chunk-WQMAL2VD.js.map