@satora/swap 1.10.0 → 1.10.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.
@@ -118,7 +118,7 @@ import {
118
118
  sha2562,
119
119
  sha512,
120
120
  utils
121
- } from "./chunk-SEHIFNWW.js";
121
+ } from "./chunk-BUYYVKK5.js";
122
122
  import {
123
123
  createSdkLogger
124
124
  } from "./chunk-G6NZFSWU.js";
@@ -22235,9 +22235,24 @@ function b64Encode(u) {
22235
22235
  for (let i = 0; i < u.length; i++) bin += String.fromCharCode(u[i]);
22236
22236
  return btoa(bin);
22237
22237
  }
22238
+ function isP2tr(script) {
22239
+ return script?.length === 34 && script[0] === 81 && script[1] === 32;
22240
+ }
22241
+ function parseEscrowPsbt(psbt) {
22242
+ const lenient = Transaction2.fromPSBT(psbt, { disableScriptCheck: true });
22243
+ let stripped = false;
22244
+ for (let i = 0; i < lenient.inputsLength; i++) {
22245
+ const input = lenient.getInput(i);
22246
+ if (input.witnessScript && isP2tr(input.witnessUtxo?.script)) {
22247
+ lenient.updateInput(i, { witnessScript: void 0 }, true);
22248
+ stripped = true;
22249
+ }
22250
+ }
22251
+ return Transaction2.fromPSBT(stripped ? lenient.toPSBT() : psbt);
22252
+ }
22238
22253
  function signEscrowArkTx(psbtB64, secretKey) {
22239
22254
  const sk = typeof secretKey === "string" ? hex.decode(secretKey) : secretKey;
22240
- const tx = Transaction2.fromPSBT(b64Decode(psbtB64));
22255
+ const tx = parseEscrowPsbt(b64Decode(psbtB64));
22241
22256
  tx.signIdx(sk, 0);
22242
22257
  const txId = tx.id;
22243
22258
  const txid = txId instanceof Uint8Array ? hex.encode(txId) : String(txId);
@@ -22249,7 +22264,7 @@ function signEscrowArkTx(psbtB64, secretKey) {
22249
22264
  function signEscrowCheckpoints(psbtB64s, secretKey) {
22250
22265
  const sk = typeof secretKey === "string" ? hex.decode(secretKey) : secretKey;
22251
22266
  return psbtB64s.map((cpB64) => {
22252
- const tx = Transaction2.fromPSBT(b64Decode(cpB64));
22267
+ const tx = parseEscrowPsbt(b64Decode(cpB64));
22253
22268
  tx.signIdx(sk, 0);
22254
22269
  return b64Encode(tx.toPSBT());
22255
22270
  });
@@ -22257,11 +22272,11 @@ function signEscrowCheckpoints(psbtB64s, secretKey) {
22257
22272
  async function signEscrowDelegate(intentProofB64, forfeitPsbtsB64, secretKey) {
22258
22273
  const sk = typeof secretKey === "string" ? secretKey : hex.encode(secretKey);
22259
22274
  const signer = SingleKey.fromHex(sk);
22260
- const intent = Transaction2.fromPSBT(b64Decode(intentProofB64));
22275
+ const intent = parseEscrowPsbt(b64Decode(intentProofB64));
22261
22276
  const signedIntent = await signer.sign(intent);
22262
22277
  const signedForfeits = [];
22263
22278
  for (const b64 of forfeitPsbtsB64) {
22264
- const forfeit = Transaction2.fromPSBT(b64Decode(b64));
22279
+ const forfeit = parseEscrowPsbt(b64Decode(b64));
22265
22280
  const signed = await signer.sign(forfeit);
22266
22281
  signedForfeits.push(b64Encode(signed.toPSBT()));
22267
22282
  }
@@ -22271,7 +22286,7 @@ async function signEscrowDelegate(intentProofB64, forfeitPsbtsB64, secretKey) {
22271
22286
  };
22272
22287
  }
22273
22288
  function getArkTxid(psbtB64) {
22274
- const tx = Transaction2.fromPSBT(b64Decode(psbtB64));
22289
+ const tx = parseEscrowPsbt(b64Decode(psbtB64));
22275
22290
  const txId = tx.id;
22276
22291
  return txId instanceof Uint8Array ? hex.encode(txId) : String(txId);
22277
22292
  }
@@ -22674,4 +22689,4 @@ export {
22674
22689
  @scure/bip39/index.js:
22675
22690
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
22676
22691
  */
22677
- //# sourceMappingURL=chunk-OWK4QVCF.js.map
22692
+ //# sourceMappingURL=chunk-U23SRA2T.js.map