@buildonspark/spark-sdk 0.2.11 → 0.2.12

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.
Files changed (94) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/bare/index.cjs +703 -206
  3. package/dist/bare/index.d.cts +47 -3
  4. package/dist/bare/index.d.ts +47 -3
  5. package/dist/bare/index.js +626 -133
  6. package/dist/{chunk-A5M55UR3.js → chunk-5VWGOHED.js} +499 -8
  7. package/dist/{chunk-3WBPICWC.js → chunk-NQMQVXR5.js} +1 -1
  8. package/dist/{chunk-QNYJGFPD.js → chunk-OEK3R57K.js} +149 -123
  9. package/dist/{chunk-76SYPHOC.js → chunk-TB7DG5CU.js} +2 -2
  10. package/dist/{chunk-6CMNEDBK.js → chunk-XXTWWW6L.js} +1 -1
  11. package/dist/{client-Dd3QnxQu.d.ts → client-D7KDa4Ih.d.ts} +1 -1
  12. package/dist/{client-B9CAWKWz.d.cts → client-DVuA5-7M.d.cts} +1 -1
  13. package/dist/debug.cjs +703 -206
  14. package/dist/debug.d.cts +4 -4
  15. package/dist/debug.d.ts +4 -4
  16. package/dist/debug.js +4 -4
  17. package/dist/graphql/objects/index.d.cts +3 -3
  18. package/dist/graphql/objects/index.d.ts +3 -3
  19. package/dist/index.cjs +725 -228
  20. package/dist/index.d.cts +6 -6
  21. package/dist/index.d.ts +6 -6
  22. package/dist/index.js +5 -5
  23. package/dist/index.node.cjs +725 -228
  24. package/dist/index.node.d.cts +6 -6
  25. package/dist/index.node.d.ts +6 -6
  26. package/dist/index.node.js +4 -4
  27. package/dist/{logging-Bt_WdZbu.d.ts → logging-ClNhGzus.d.ts} +3 -3
  28. package/dist/{logging-BOAzMqpM.d.cts → logging-D3kvES69.d.cts} +3 -3
  29. package/dist/native/index.cjs +724 -227
  30. package/dist/native/index.d.cts +47 -3
  31. package/dist/native/index.d.ts +47 -3
  32. package/dist/native/index.js +628 -135
  33. package/dist/proto/spark.cjs +499 -8
  34. package/dist/proto/spark.d.cts +1 -1
  35. package/dist/proto/spark.d.ts +1 -1
  36. package/dist/proto/spark.js +17 -1
  37. package/dist/proto/spark_token.d.cts +1 -1
  38. package/dist/proto/spark_token.d.ts +1 -1
  39. package/dist/proto/spark_token.js +2 -2
  40. package/dist/{spark-CtGJPkx4.d.cts → spark-C7OG9mGJ.d.cts} +79 -2
  41. package/dist/{spark-CtGJPkx4.d.ts → spark-C7OG9mGJ.d.ts} +79 -2
  42. package/dist/{spark-wallet-yc2KhsVY.d.cts → spark-wallet-Dg5IRQe2.d.cts} +3 -5
  43. package/dist/{spark-wallet-Cp3yv6cK.d.ts → spark-wallet-DiHSU-pz.d.ts} +3 -5
  44. package/dist/{spark-wallet.node-D4IovOHu.d.ts → spark-wallet.node-BZrxwomN.d.ts} +1 -1
  45. package/dist/{spark-wallet.node-D0Qw5Wb4.d.cts → spark-wallet.node-DSWb18zh.d.cts} +1 -1
  46. package/dist/tests/test-utils.cjs +573 -66
  47. package/dist/tests/test-utils.d.cts +4 -4
  48. package/dist/tests/test-utils.d.ts +4 -4
  49. package/dist/tests/test-utils.js +5 -5
  50. package/dist/{token-transactions-CwhlOgIP.d.cts → token-transactions-B-WqFYpW.d.cts} +2 -2
  51. package/dist/{token-transactions-0nmR9mQO.d.ts → token-transactions-DovxHIxV.d.ts} +2 -2
  52. package/dist/types/index.cjs +492 -9
  53. package/dist/types/index.d.cts +2 -2
  54. package/dist/types/index.d.ts +2 -2
  55. package/dist/types/index.js +2 -2
  56. package/package.json +1 -1
  57. package/src/proto/common.ts +1 -1
  58. package/src/proto/google/protobuf/descriptor.ts +4 -10
  59. package/src/proto/google/protobuf/duration.ts +1 -1
  60. package/src/proto/google/protobuf/empty.ts +1 -1
  61. package/src/proto/google/protobuf/timestamp.ts +1 -1
  62. package/src/proto/mock.ts +1 -1
  63. package/src/proto/spark.ts +593 -3
  64. package/src/proto/spark_authn.ts +1 -1
  65. package/src/proto/spark_token.ts +1 -1
  66. package/src/proto/validate/validate.ts +27 -79
  67. package/src/services/deposit.ts +55 -3
  68. package/src/services/lightning.ts +2 -2
  69. package/src/services/signing.ts +1 -1
  70. package/src/services/token-transactions.ts +2 -5
  71. package/src/services/transfer.ts +2 -2
  72. package/src/signer/signer.ts +2 -2
  73. package/src/spark-wallet/spark-wallet.ts +25 -33
  74. package/src/tests/address.test.ts +10 -10
  75. package/src/tests/bitcoin.test.ts +2 -2
  76. package/src/tests/integration/coop-exit.test.ts +1 -1
  77. package/src/tests/integration/lightning.test.ts +1 -1
  78. package/src/tests/integration/ssp/static_deposit.test.ts +122 -1
  79. package/src/tests/integration/swap.test.ts +1 -1
  80. package/src/tests/integration/transfer.test.ts +1 -5
  81. package/src/tests/integration/wallet.test.ts +7 -7
  82. package/src/tests/integration/watchtower.test.ts +1 -1
  83. package/src/tests/token-hashing.test.ts +3 -6
  84. package/src/tests/token-outputs.test.ts +3 -3
  85. package/src/tests/utils/test-faucet.ts +2 -2
  86. package/src/types/sdk-types.ts +1 -1
  87. package/src/utils/adaptor-signature.ts +1 -1
  88. package/src/utils/address.ts +1 -1
  89. package/src/utils/bitcoin.ts +1 -5
  90. package/src/utils/keys.ts +1 -1
  91. package/src/utils/secret-sharing.ts +1 -1
  92. package/src/utils/token-transactions.ts +1 -2
  93. package/src/utils/transfer_package.ts +1 -1
  94. package/src/utils/unilateral-exit.ts +1 -1
@@ -4,11 +4,11 @@ import {
4
4
  } from "./chunk-NX5KPN5F.js";
5
5
  import {
6
6
  SparkTokenServiceDefinition
7
- } from "./chunk-6CMNEDBK.js";
7
+ } from "./chunk-XXTWWW6L.js";
8
8
  import {
9
9
  mapTransferToWalletTransfer,
10
10
  mapTreeNodeToWalletLeaf
11
- } from "./chunk-76SYPHOC.js";
11
+ } from "./chunk-TB7DG5CU.js";
12
12
  import {
13
13
  Empty,
14
14
  SatsPayment,
@@ -19,7 +19,7 @@ import {
19
19
  TokensPayment,
20
20
  TreeNode,
21
21
  networkToJSON
22
- } from "./chunk-A5M55UR3.js";
22
+ } from "./chunk-5VWGOHED.js";
23
23
  import {
24
24
  BitcoinNetwork_default,
25
25
  ClaimStaticDepositFromJson,
@@ -152,8 +152,8 @@ var NotImplementedError = class extends SparkSDKError {
152
152
  };
153
153
 
154
154
  // src/utils/keys.ts
155
- import { numberToBytesBE } from "@noble/curves/abstract/utils";
156
155
  import { secp256k1 } from "@noble/curves/secp256k1";
156
+ import { numberToBytesBE } from "@noble/curves/utils";
157
157
  function addPublicKeys(a, b) {
158
158
  if (a.length !== 33 || b.length !== 33) {
159
159
  throw new ValidationError("Public keys must be 33 bytes", {
@@ -264,8 +264,8 @@ var setCrypto = (cryptoImplParam) => {
264
264
  };
265
265
 
266
266
  // src/utils/secret-sharing.ts
267
- import { bytesToHex as bytesToHex2, equalBytes } from "@noble/curves/abstract/utils";
268
267
  import { secp256k1 as secp256k12 } from "@noble/curves/secp256k1";
268
+ import { bytesToHex as bytesToHex2, equalBytes } from "@noble/curves/utils";
269
269
  function getRandomBigInt(max) {
270
270
  const byteLength = max.toString(2).length + 7 >> 3;
271
271
  const maxBigInt = max;
@@ -561,13 +561,13 @@ var KeyDerivationType = /* @__PURE__ */ ((KeyDerivationType2) => {
561
561
 
562
562
  // src/signer/signer.ts
563
563
  import { privateNegate } from "@bitcoinerlab/secp256k1";
564
+ import { schnorr, secp256k1 as secp256k14 } from "@noble/curves/secp256k1";
564
565
  import {
565
566
  bytesToHex as bytesToHex3,
566
567
  bytesToNumberBE,
567
568
  equalBytes as equalBytes2,
568
569
  hexToBytes
569
- } from "@noble/curves/abstract/utils";
570
- import { schnorr, secp256k1 as secp256k14 } from "@noble/curves/secp256k1";
570
+ } from "@noble/curves/utils";
571
571
  import { sha256 } from "@noble/hashes/sha2";
572
572
  import { HDKey } from "@scure/bip32";
573
573
  import { generateMnemonic, mnemonicToSeed } from "@scure/bip39";
@@ -579,7 +579,7 @@ import * as ecies from "eciesjs";
579
579
  import { isNode, isBare } from "@lightsparkdev/core";
580
580
  var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
581
581
  var isBun = globalThis.Bun !== void 0;
582
- var packageVersion = true ? "0.2.11" : "unknown";
582
+ var packageVersion = true ? "0.2.12" : "unknown";
583
583
  var baseEnvStr = "unknown";
584
584
  if (isBun) {
585
585
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -2808,12 +2808,8 @@ var ConnectionManager = class {
2808
2808
  };
2809
2809
 
2810
2810
  // src/utils/bitcoin.ts
2811
- import {
2812
- bytesToHex as bytesToHex4,
2813
- bytesToNumberBE as bytesToNumberBE2,
2814
- hexToBytes as hexToBytes2
2815
- } from "@noble/curves/abstract/utils";
2816
2811
  import { schnorr as schnorr2, secp256k1 as secp256k15 } from "@noble/curves/secp256k1";
2812
+ import { bytesToHex as bytesToHex4, bytesToNumberBE as bytesToNumberBE2, hexToBytes as hexToBytes2 } from "@noble/curves/utils";
2817
2813
  import { sha256 as sha2563 } from "@noble/hashes/sha2";
2818
2814
  import * as btc2 from "@scure/btc-signer";
2819
2815
  function computeTaprootKeyNoScript(pubkey) {
@@ -3299,7 +3295,7 @@ function getEphemeralAnchorOutput() {
3299
3295
  }
3300
3296
 
3301
3297
  // src/utils/transfer_package.ts
3302
- import { hexToBytes as hexToBytes3 } from "@noble/curves/abstract/utils";
3298
+ import { hexToBytes as hexToBytes3 } from "@noble/curves/utils";
3303
3299
  import { sha256 as sha2564 } from "@noble/hashes/sha2";
3304
3300
  function getTransferPackageSigningPayload(transferID, transferPackage) {
3305
3301
  const encryptedPayload = transferPackage.keyTweakPackage;
@@ -3350,7 +3346,8 @@ var DepositService = class {
3350
3346
  }
3351
3347
  async validateDepositAddress({
3352
3348
  address: address2,
3353
- userPubkey
3349
+ userPubkey,
3350
+ verifyCoordinatorProof = false
3354
3351
  }) {
3355
3352
  if (!address2.depositAddressProof || !address2.depositAddressProof.proofOfPossessionSignature || !address2.depositAddressProof.addressSignatures) {
3356
3353
  throw new ValidationError(
@@ -3388,7 +3385,7 @@ var DepositService = class {
3388
3385
  }
3389
3386
  const addrHash = sha2566(address2.address);
3390
3387
  for (const operator of Object.values(this.config.getSigningOperators())) {
3391
- if (operator.identifier === this.config.getCoordinatorIdentifier()) {
3388
+ if (operator.identifier === this.config.getCoordinatorIdentifier() && !verifyCoordinatorProof) {
3392
3389
  continue;
3393
3390
  }
3394
3391
  const operatorPubkey2 = hexToBytes4(operator.identityPublicKey);
@@ -3413,6 +3410,46 @@ var DepositService = class {
3413
3410
  }
3414
3411
  }
3415
3412
  }
3413
+ async generateStaticDepositAddress({
3414
+ signingPubkey
3415
+ }) {
3416
+ const sparkClient = await this.connectionManager.createSparkClient(
3417
+ this.config.getCoordinatorAddress()
3418
+ );
3419
+ let depositResp;
3420
+ try {
3421
+ depositResp = await sparkClient.generate_static_deposit_address({
3422
+ signingPublicKey: signingPubkey,
3423
+ identityPublicKey: await this.config.signer.getIdentityPublicKey(),
3424
+ network: this.config.getNetworkProto()
3425
+ });
3426
+ } catch (error) {
3427
+ throw new NetworkError(
3428
+ "Failed to generate static deposit address",
3429
+ {
3430
+ operation: "generate_static_deposit_address",
3431
+ errorCount: 1,
3432
+ errors: error instanceof Error ? error.message : String(error)
3433
+ },
3434
+ error
3435
+ );
3436
+ }
3437
+ if (!depositResp.depositAddress) {
3438
+ throw new ValidationError(
3439
+ "No static deposit address response from coordinator",
3440
+ {
3441
+ field: "depositAddress",
3442
+ value: depositResp
3443
+ }
3444
+ );
3445
+ }
3446
+ await this.validateDepositAddress({
3447
+ address: depositResp.depositAddress,
3448
+ userPubkey: signingPubkey,
3449
+ verifyCoordinatorProof: true
3450
+ });
3451
+ return depositResp;
3452
+ }
3416
3453
  async generateDepositAddress({
3417
3454
  signingPubkey,
3418
3455
  leafId,
@@ -3953,8 +3990,8 @@ var DepositService = class {
3953
3990
 
3954
3991
  // src/utils/address.ts
3955
3992
  import { BinaryWriter as BinaryWriter3 } from "@bufbuild/protobuf/wire";
3956
- import { bytesToNumberBE as bytesToNumberBE3 } from "@noble/curves/abstract/utils";
3957
3993
  import { schnorr as schnorr4, secp256k1 as secp256k17 } from "@noble/curves/secp256k1";
3994
+ import { bytesToNumberBE as bytesToNumberBE3 } from "@noble/curves/utils";
3958
3995
  import { bytesToHex as bytesToHex5, hexToBytes as hexToBytes5 } from "@noble/hashes/utils";
3959
3996
  import { bech32m } from "@scure/base";
3960
3997
  import { UUID } from "uuidv7";
@@ -4601,8 +4638,7 @@ function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier) {
4601
4638
  }
4602
4639
 
4603
4640
  // src/utils/token-transactions.ts
4604
- import { bytesToNumberBE as bytesToNumberBE4 } from "@noble/curves/abstract/utils";
4605
- import { equalBytes as equalBytes4 } from "@scure/btc-signer/utils";
4641
+ import { bytesToNumberBE as bytesToNumberBE4, equalBytes as equalBytes4 } from "@noble/curves/utils";
4606
4642
  function sumAvailableTokens(outputs) {
4607
4643
  try {
4608
4644
  return outputs.reduce(
@@ -4650,12 +4686,12 @@ function filterTokenBalanceForTokenIdentifier(tokenBalances, tokenIdentifier) {
4650
4686
  }
4651
4687
 
4652
4688
  // src/services/token-transactions.ts
4689
+ import { secp256k1 as secp256k19 } from "@noble/curves/secp256k1";
4653
4690
  import {
4654
- bytesToHex as bytesToHex7,
4691
+ bytesToHex as bytesToHex6,
4655
4692
  bytesToNumberBE as bytesToNumberBE5,
4656
4693
  numberToBytesBE as numberToBytesBE2
4657
- } from "@noble/curves/abstract/utils";
4658
- import { secp256k1 as secp256k19 } from "@noble/curves/secp256k1";
4694
+ } from "@noble/curves/utils";
4659
4695
  import { hexToBytes as hexToBytes6 } from "@noble/hashes/utils";
4660
4696
 
4661
4697
  // src/utils/token-hashing.ts
@@ -6792,7 +6828,7 @@ var TokenTransactionService = class {
6792
6828
  {
6793
6829
  field: "revocationCommitment",
6794
6830
  value: derivedRevocationCommitment,
6795
- expected: bytesToHex7(outputsToSpendCommitments[outputIndex]),
6831
+ expected: bytesToHex6(outputsToSpendCommitments[outputIndex]),
6796
6832
  outputIndex
6797
6833
  }
6798
6834
  )
@@ -6818,7 +6854,7 @@ var TokenTransactionService = class {
6818
6854
  threshold
6819
6855
  );
6820
6856
  }
6821
- return bytesToHex7(finalTokenTransactionHash);
6857
+ return bytesToHex6(finalTokenTransactionHash);
6822
6858
  }
6823
6859
  async broadcastTokenTransactionV1(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
6824
6860
  const { finalTokenTransaction, finalTokenTransactionHash, threshold } = await this.startTokenTransaction(
@@ -6832,7 +6868,7 @@ var TokenTransactionService = class {
6832
6868
  finalTokenTransactionHash,
6833
6869
  signingOperators
6834
6870
  );
6835
- return bytesToHex7(finalTokenTransactionHash);
6871
+ return bytesToHex6(finalTokenTransactionHash);
6836
6872
  }
6837
6873
  async startTokenTransactionV0(tokenTransaction, signingOperators, outputsToSpendSigningPublicKeys, outputsToSpendCommitments) {
6838
6874
  const sparkClient = await this.connectionManager.createSparkClient(
@@ -7424,7 +7460,7 @@ var TokenTransactionService = class {
7424
7460
  // Helper function for deciding if the signer public key is the identity public key
7425
7461
  async signMessageWithKey(message, publicKey) {
7426
7462
  const tokenSignatures = this.config.getTokenSignatures();
7427
- if (bytesToHex7(publicKey) === bytesToHex7(await this.config.signer.getIdentityPublicKey())) {
7463
+ if (bytesToHex6(publicKey) === bytesToHex6(await this.config.signer.getIdentityPublicKey())) {
7428
7464
  if (tokenSignatures === "SCHNORR") {
7429
7465
  return await this.config.signer.signSchnorrWithIdentityKey(message);
7430
7466
  } else {
@@ -7433,8 +7469,8 @@ var TokenTransactionService = class {
7433
7469
  } else {
7434
7470
  throw new ValidationError("Invalid public key", {
7435
7471
  field: "publicKey",
7436
- value: bytesToHex7(publicKey),
7437
- expected: bytesToHex7(await this.config.signer.getIdentityPublicKey())
7472
+ value: bytesToHex6(publicKey),
7473
+ expected: bytesToHex6(await this.config.signer.getIdentityPublicKey())
7438
7474
  });
7439
7475
  }
7440
7476
  }
@@ -7564,8 +7600,8 @@ function isTokenTransaction(tokenTransaction) {
7564
7600
 
7565
7601
  // src/utils/adaptor-signature.ts
7566
7602
  import { mod } from "@noble/curves/abstract/modular";
7567
- import { bytesToNumberBE as bytesToNumberBE6, numberToBytesBE as numberToBytesBE3 } from "@noble/curves/abstract/utils";
7568
7603
  import { schnorr as schnorr5, secp256k1 as secp256k110 } from "@noble/curves/secp256k1";
7604
+ import { bytesToNumberBE as bytesToNumberBE6, numberToBytesBE as numberToBytesBE3 } from "@noble/curves/utils";
7569
7605
  function generateSignatureFromExistingAdaptor(signature, adaptorPrivateKeyBytes) {
7570
7606
  const { r, s } = parseSignature(signature);
7571
7607
  const sBigInt = bytesToNumberBE6(s);
@@ -7693,8 +7729,8 @@ function parseSignature(signature) {
7693
7729
  }
7694
7730
 
7695
7731
  // src/tests/utils/test-faucet.ts
7696
- import { bytesToHex as bytesToHex8, hexToBytes as hexToBytes7 } from "@noble/curves/abstract/utils";
7697
7732
  import { schnorr as schnorr6, secp256k1 as secp256k111 } from "@noble/curves/secp256k1";
7733
+ import { bytesToHex as bytesToHex7, hexToBytes as hexToBytes7 } from "@noble/curves/utils";
7698
7734
  import * as btc3 from "@scure/btc-signer";
7699
7735
  import { Address as Address2, OutScript as OutScript2, SigHash as SigHash2, Transaction as Transaction4 } from "@scure/btc-signer";
7700
7736
  import { taprootTweakPrivKey as taprootTweakPrivKey2 } from "@scure/btc-signer/utils";
@@ -7849,7 +7885,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
7849
7885
  },
7850
7886
  STATIC_MINING_KEY
7851
7887
  );
7852
- await this.broadcastTx(bytesToHex8(signedSplitTx.extract()));
7888
+ await this.broadcastTx(bytesToHex7(signedSplitTx.extract()));
7853
7889
  const splitTxId = signedSplitTx.id;
7854
7890
  for (let i = 0; i < numCoinsToCreate; i++) {
7855
7891
  this.coins.push({
@@ -7883,7 +7919,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
7883
7919
  coinToSend.txout,
7884
7920
  coinToSend.key
7885
7921
  );
7886
- await this.broadcastTx(bytesToHex8(signedTx.extract()));
7922
+ await this.broadcastTx(bytesToHex7(signedTx.extract()));
7887
7923
  }
7888
7924
  async signFaucetCoin(unsignedTx, fundingTxOut, key) {
7889
7925
  const pubKey = secp256k111.getPublicKey(key);
@@ -8003,7 +8039,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
8003
8039
  });
8004
8040
  }
8005
8041
  const signedTx = await this.signFaucetCoin(tx, coin.txout, coin.key);
8006
- const txHex = bytesToHex8(signedTx.extract());
8042
+ const txHex = bytesToHex7(signedTx.extract());
8007
8043
  await this.broadcastTx(txHex);
8008
8044
  const randomKey = secp256k111.utils.randomPrivateKey();
8009
8045
  const randomPubKey = secp256k111.getPublicKey(randomKey);
@@ -8021,14 +8057,14 @@ var BitcoinFaucet = class _BitcoinFaucet {
8021
8057
 
8022
8058
  // src/spark-wallet/spark-wallet.ts
8023
8059
  import { isNode as isNode3, isObject as isObject2, mapCurrencyAmount } from "@lightsparkdev/core";
8060
+ import { secp256k1 as secp256k114 } from "@noble/curves/secp256k1";
8024
8061
  import {
8025
- bytesToHex as bytesToHex11,
8062
+ bytesToHex as bytesToHex10,
8026
8063
  bytesToNumberBE as bytesToNumberBE8,
8027
8064
  equalBytes as equalBytes6,
8028
8065
  hexToBytes as hexToBytes11,
8029
8066
  numberToVarBytesBE
8030
- } from "@noble/curves/abstract/utils";
8031
- import { secp256k1 as secp256k114 } from "@noble/curves/secp256k1";
8067
+ } from "@noble/curves/utils";
8032
8068
  import { validateMnemonic } from "@scure/bip39";
8033
8069
  import { wordlist as wordlist2 } from "@scure/bip39/wordlists/english";
8034
8070
  import { Address as Address3, OutScript as OutScript3, Transaction as Transaction7 } from "@scure/btc-signer";
@@ -8037,7 +8073,7 @@ import { uuidv7 as uuidv74, uuidv7obj } from "uuidv7";
8037
8073
 
8038
8074
  // src/graphql/client.ts
8039
8075
  import {
8040
- bytesToHex as bytesToHex9,
8076
+ bytesToHex as bytesToHex8,
8041
8077
  DefaultCrypto,
8042
8078
  NodeKeyCache,
8043
8079
  Requester,
@@ -9023,7 +9059,7 @@ var SspClient = class {
9023
9059
  {
9024
9060
  queryPayload: GetChallenge,
9025
9061
  variables: {
9026
- public_key: bytesToHex9(await this.signer.getIdentityPublicKey())
9062
+ public_key: bytesToHex8(await this.signer.getIdentityPublicKey())
9027
9063
  },
9028
9064
  constructObject: (response) => {
9029
9065
  return GetChallengeOutputFromJson(response.get_challenge);
@@ -9039,7 +9075,7 @@ var SspClient = class {
9039
9075
  variables: {
9040
9076
  protected_challenge: protectedChallenge,
9041
9077
  signature,
9042
- identity_public_key: bytesToHex9(
9078
+ identity_public_key: bytesToHex8(
9043
9079
  await this.signer.getIdentityPublicKey()
9044
9080
  )
9045
9081
  },
@@ -9156,13 +9192,13 @@ import { Transaction as Transaction6 } from "@scure/btc-signer";
9156
9192
  import { uuidv7 as uuidv72 } from "uuidv7";
9157
9193
 
9158
9194
  // src/services/transfer.ts
9195
+ import { secp256k1 as secp256k112 } from "@noble/curves/secp256k1";
9159
9196
  import {
9160
- bytesToHex as bytesToHex10,
9197
+ bytesToHex as bytesToHex9,
9161
9198
  equalBytes as equalBytes5,
9162
9199
  hexToBytes as hexToBytes8,
9163
9200
  numberToBytesBE as numberToBytesBE4
9164
- } from "@noble/curves/abstract/utils";
9165
- import { secp256k1 as secp256k112 } from "@noble/curves/secp256k1";
9201
+ } from "@noble/curves/utils";
9166
9202
  import { sha256 as sha25610 } from "@noble/hashes/sha2";
9167
9203
  import { Transaction as Transaction5 } from "@scure/btc-signer";
9168
9204
  import * as ecies2 from "eciesjs";
@@ -9532,7 +9568,7 @@ var BaseTransferService = class {
9532
9568
  }
9533
9569
  async prepareSendTransferKeyTweaks(transferID, receiverIdentityPubkey, leaves, cpfpRefundSignatureMap, directRefundSignatureMap, directFromCpfpRefundSignatureMap) {
9534
9570
  const receiverEciesPubKey = ecies2.PublicKey.fromHex(
9535
- bytesToHex10(receiverIdentityPubkey)
9571
+ bytesToHex9(receiverIdentityPubkey)
9536
9572
  );
9537
9573
  const leavesTweaksMap = /* @__PURE__ */ new Map();
9538
9574
  for (const leaf of leaves) {
@@ -11051,12 +11087,12 @@ var CoopExitService = class extends BaseTransferService {
11051
11087
  };
11052
11088
 
11053
11089
  // src/services/lightning.ts
11090
+ import { secp256k1 as secp256k113 } from "@noble/curves/secp256k1";
11054
11091
  import {
11055
11092
  bytesToNumberBE as bytesToNumberBE7,
11056
11093
  hexToBytes as hexToBytes9,
11057
11094
  numberToBytesBE as numberToBytesBE5
11058
- } from "@noble/curves/abstract/utils";
11059
- import { secp256k1 as secp256k113 } from "@noble/curves/secp256k1";
11095
+ } from "@noble/curves/utils";
11060
11096
  import { sha256 as sha25611 } from "@noble/hashes/sha2";
11061
11097
  import { uuidv7 as uuidv73 } from "uuidv7";
11062
11098
 
@@ -11412,7 +11448,7 @@ import { EventEmitter } from "eventemitter3";
11412
11448
  import { ClientError, Status } from "nice-grpc-common";
11413
11449
 
11414
11450
  // src/services/signing.ts
11415
- import { hexToBytes as hexToBytes10 } from "@noble/curves/abstract/utils";
11451
+ import { hexToBytes as hexToBytes10 } from "@noble/curves/utils";
11416
11452
  var SigningService = class {
11417
11453
  config;
11418
11454
  constructor(config) {
@@ -12126,7 +12162,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12126
12162
  * @returns {Promise<string>} The identity public key as a hex string.
12127
12163
  */
12128
12164
  async getIdentityPublicKey() {
12129
- return bytesToHex11(await this.config.signer.getIdentityPublicKey());
12165
+ return bytesToHex10(await this.config.signer.getIdentityPublicKey());
12130
12166
  }
12131
12167
  /**
12132
12168
  * Gets the Spark address of the wallet.
@@ -12136,7 +12172,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12136
12172
  async getSparkAddress() {
12137
12173
  if (!this.sparkAddress) {
12138
12174
  this.sparkAddress = encodeSparkAddress({
12139
- identityPublicKey: bytesToHex11(
12175
+ identityPublicKey: bytesToHex10(
12140
12176
  await this.config.signer.getIdentityPublicKey()
12141
12177
  ),
12142
12178
  network: this.config.getNetworkType()
@@ -12220,7 +12256,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12220
12256
  const signature = await this.config.signer.signSchnorrWithIdentityKey(hash);
12221
12257
  return encodeSparkAddressWithSignature(
12222
12258
  {
12223
- identityPublicKey: bytesToHex11(identityPublicKey),
12259
+ identityPublicKey: bytesToHex10(identityPublicKey),
12224
12260
  network: this.config.getNetworkType(),
12225
12261
  sparkInvoiceFields: invoiceFields
12226
12262
  },
@@ -12288,7 +12324,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12288
12324
  });
12289
12325
  }
12290
12326
  this.sparkAddress = encodeSparkAddress({
12291
- identityPublicKey: bytesToHex11(identityPublicKey),
12327
+ identityPublicKey: bytesToHex10(identityPublicKey),
12292
12328
  network: this.config.getNetworkType()
12293
12329
  });
12294
12330
  return this.sparkAddress;
@@ -12468,18 +12504,18 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12468
12504
  const userLeaves = [];
12469
12505
  userLeaves.push({
12470
12506
  leaf_id: transfer.leaves[0].leaf.id,
12471
- raw_unsigned_refund_transaction: bytesToHex11(
12507
+ raw_unsigned_refund_transaction: bytesToHex10(
12472
12508
  transfer.leaves[0].intermediateRefundTx
12473
12509
  ),
12474
- direct_raw_unsigned_refund_transaction: bytesToHex11(
12510
+ direct_raw_unsigned_refund_transaction: bytesToHex10(
12475
12511
  transfer.leaves[0].intermediateDirectRefundTx
12476
12512
  ),
12477
- direct_from_cpfp_raw_unsigned_refund_transaction: bytesToHex11(
12513
+ direct_from_cpfp_raw_unsigned_refund_transaction: bytesToHex10(
12478
12514
  transfer.leaves[0].intermediateDirectFromCpfpRefundTx
12479
12515
  ),
12480
- adaptor_added_signature: bytesToHex11(cpfpAdaptorSignature),
12481
- direct_adaptor_added_signature: bytesToHex11(directAdaptorSignature),
12482
- direct_from_cpfp_adaptor_added_signature: bytesToHex11(
12516
+ adaptor_added_signature: bytesToHex10(cpfpAdaptorSignature),
12517
+ direct_adaptor_added_signature: bytesToHex10(directAdaptorSignature),
12518
+ direct_from_cpfp_adaptor_added_signature: bytesToHex10(
12483
12519
  directFromCpfpAdaptorSignature
12484
12520
  )
12485
12521
  });
@@ -12532,24 +12568,24 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12532
12568
  }
12533
12569
  userLeaves.push({
12534
12570
  leaf_id: leaf.leaf.id,
12535
- raw_unsigned_refund_transaction: bytesToHex11(
12571
+ raw_unsigned_refund_transaction: bytesToHex10(
12536
12572
  leaf.intermediateRefundTx
12537
12573
  ),
12538
- direct_raw_unsigned_refund_transaction: bytesToHex11(
12574
+ direct_raw_unsigned_refund_transaction: bytesToHex10(
12539
12575
  leaf.intermediateDirectRefundTx
12540
12576
  ),
12541
- direct_from_cpfp_raw_unsigned_refund_transaction: bytesToHex11(
12577
+ direct_from_cpfp_raw_unsigned_refund_transaction: bytesToHex10(
12542
12578
  leaf.intermediateDirectFromCpfpRefundTx
12543
12579
  ),
12544
- adaptor_added_signature: bytesToHex11(cpfpSignature),
12545
- direct_adaptor_added_signature: bytesToHex11(directSignature),
12546
- direct_from_cpfp_adaptor_added_signature: bytesToHex11(
12580
+ adaptor_added_signature: bytesToHex10(cpfpSignature),
12581
+ direct_adaptor_added_signature: bytesToHex10(directSignature),
12582
+ direct_from_cpfp_adaptor_added_signature: bytesToHex10(
12547
12583
  directFromCpfpSignature
12548
12584
  )
12549
12585
  });
12550
12586
  }
12551
12587
  const sspClient = this.getSspClient();
12552
- const cpfpAdaptorPubkey = bytesToHex11(
12588
+ const cpfpAdaptorPubkey = bytesToHex10(
12553
12589
  secp256k114.getPublicKey(cpfpAdaptorPrivateKey)
12554
12590
  );
12555
12591
  if (!cpfpAdaptorPubkey) {
@@ -12557,13 +12593,13 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12557
12593
  }
12558
12594
  let directAdaptorPubkey;
12559
12595
  if (directAdaptorPrivateKey.length > 0) {
12560
- directAdaptorPubkey = bytesToHex11(
12596
+ directAdaptorPubkey = bytesToHex10(
12561
12597
  secp256k114.getPublicKey(directAdaptorPrivateKey)
12562
12598
  );
12563
12599
  }
12564
12600
  let directFromCpfpAdaptorPubkey;
12565
12601
  if (directFromCpfpAdaptorPrivateKey.length > 0) {
12566
- directFromCpfpAdaptorPubkey = bytesToHex11(
12602
+ directFromCpfpAdaptorPubkey = bytesToHex10(
12567
12603
  secp256k114.getPublicKey(directFromCpfpAdaptorPrivateKey)
12568
12604
  );
12569
12605
  }
@@ -12703,9 +12739,9 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12703
12739
  directFromCpfpSignatureMap
12704
12740
  );
12705
12741
  const completeResponse = await sspClient.completeLeaveSwap({
12706
- adaptorSecretKey: bytesToHex11(cpfpAdaptorPrivateKey),
12707
- directAdaptorSecretKey: bytesToHex11(directAdaptorPrivateKey),
12708
- directFromCpfpAdaptorSecretKey: bytesToHex11(
12742
+ adaptorSecretKey: bytesToHex10(cpfpAdaptorPrivateKey),
12743
+ directAdaptorSecretKey: bytesToHex10(directAdaptorPrivateKey),
12744
+ directFromCpfpAdaptorSecretKey: bytesToHex10(
12709
12745
  directFromCpfpAdaptorPrivateKey
12710
12746
  ),
12711
12747
  userOutboundTransferExternalId: transfer.id,
@@ -12800,7 +12836,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12800
12836
  let tokenMetadataMap = /* @__PURE__ */ new Map();
12801
12837
  for (const [tokenIdentifier, metadata] of this.tokenMetadata) {
12802
12838
  tokenMetadataMap.set(tokenIdentifier, {
12803
- tokenPublicKey: bytesToHex11(metadata.issuerPublicKey),
12839
+ tokenPublicKey: bytesToHex10(metadata.issuerPublicKey),
12804
12840
  rawTokenIdentifier: metadata.tokenIdentifier,
12805
12841
  tokenName: metadata.tokenName,
12806
12842
  tokenTicker: metadata.tokenTicker,
@@ -12840,7 +12876,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12840
12876
  * @returns {Promise<string>} A Bitcoin address for depositing funds
12841
12877
  */
12842
12878
  async getSingleUseDepositAddress() {
12843
- return await this.generateDepositAddress(false);
12879
+ return await this.generateDepositAddress();
12844
12880
  }
12845
12881
  /**
12846
12882
  * Generates a new static deposit address for receiving bitcoin funds.
@@ -12849,43 +12885,32 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12849
12885
  * @returns {Promise<string>} A Bitcoin address for depositing funds
12850
12886
  */
12851
12887
  async getStaticDepositAddress() {
12852
- try {
12853
- return await this.generateDepositAddress(true);
12854
- } catch (error) {
12855
- if (error.message?.includes("static deposit address already exists")) {
12856
- const existingAddresses = await this.queryStaticDepositAddresses();
12857
- if (existingAddresses.length > 0 && existingAddresses[0]) {
12858
- return existingAddresses[0];
12859
- } else {
12860
- throw error;
12861
- }
12862
- } else {
12863
- throw error;
12864
- }
12888
+ const signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
12889
+ const address2 = await this.depositService.generateStaticDepositAddress({
12890
+ signingPubkey
12891
+ });
12892
+ if (!address2.depositAddress) {
12893
+ throw new RPCError("Failed to generate static deposit address", {
12894
+ method: "generateStaticDepositAddress",
12895
+ params: { signingPubkey }
12896
+ });
12865
12897
  }
12898
+ return address2.depositAddress.address;
12866
12899
  }
12867
12900
  /**
12868
12901
  * Generates a deposit address for receiving funds.
12869
- *
12870
- * @param {boolean} static - Whether the address is static or single use
12871
12902
  * @returns {Promise<string>} A deposit address
12872
12903
  * @private
12873
12904
  */
12874
- async generateDepositAddress(isStatic) {
12905
+ async generateDepositAddress() {
12875
12906
  const leafId = uuidv74();
12876
- let signingPubkey;
12877
- if (isStatic) {
12878
- signingPubkey = await this.config.signer.getStaticDepositSigningKey(0);
12879
- } else {
12880
- signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
12881
- type: "leaf" /* LEAF */,
12882
- path: leafId
12883
- });
12884
- }
12907
+ const signingPubkey = await this.config.signer.getPublicKeyFromDerivation({
12908
+ type: "leaf" /* LEAF */,
12909
+ path: leafId
12910
+ });
12885
12911
  const address2 = await this.depositService.generateDepositAddress({
12886
12912
  signingPubkey,
12887
- leafId,
12888
- isStatic
12913
+ leafId
12889
12914
  });
12890
12915
  if (!address2.depositAddress) {
12891
12916
  throw new RPCError("Failed to generate deposit address", {
@@ -12912,7 +12937,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12912
12937
  * @param offset - Pagination offset (default 0).
12913
12938
  * @returns {Promise<{ txid: string, vout: number }[]>} List of confirmed UTXOs.
12914
12939
  */
12915
- async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0) {
12940
+ async getUtxosForDepositAddress(depositAddress, limit = 100, offset = 0, excludeClaimed = false) {
12916
12941
  if (!depositAddress) {
12917
12942
  throw new ValidationError("Deposit address cannot be empty", {
12918
12943
  field: "depositAddress"
@@ -12926,10 +12951,11 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12926
12951
  address: depositAddress,
12927
12952
  network: NetworkToProto[this.config.getNetwork()],
12928
12953
  limit,
12929
- offset
12954
+ offset,
12955
+ excludeClaimed
12930
12956
  });
12931
12957
  return response.utxos.map((utxo) => ({
12932
- txid: bytesToHex11(utxo.txid),
12958
+ txid: bytesToHex10(utxo.txid),
12933
12959
  vout: utxo.vout
12934
12960
  })) ?? [];
12935
12961
  } catch (error) {
@@ -12999,7 +13025,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12999
13025
  if (network === BitcoinNetwork_default.FUTURE_VALUE) {
13000
13026
  network = BitcoinNetwork_default.REGTEST;
13001
13027
  }
13002
- const depositSecretKey = bytesToHex11(
13028
+ const depositSecretKey = bytesToHex10(
13003
13029
  await this.config.signer.getStaticDepositSecretKey(0)
13004
13030
  );
13005
13031
  const message = await this.getStaticDepositSigningPayload(
@@ -13012,7 +13038,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
13012
13038
  );
13013
13039
  const hashBuffer = sha25612(message);
13014
13040
  const signatureBytes = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
13015
- const signature = bytesToHex11(signatureBytes);
13041
+ const signature = bytesToHex10(signatureBytes);
13016
13042
  const response = await this.sspClient.claimStaticDeposit({
13017
13043
  transactionId,
13018
13044
  outputIndex,
@@ -13164,7 +13190,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
13164
13190
  networkJSON.toLowerCase(),
13165
13191
  2 /* Refund */,
13166
13192
  creditAmountSats,
13167
- bytesToHex11(spendTxSighash)
13193
+ bytesToHex10(spendTxSighash)
13168
13194
  );
13169
13195
  const hashBuffer = sha25612(message);
13170
13196
  const swapResponseUserSignature = await this.config.signer.signMessageWithIdentityKey(hashBuffer);
@@ -13687,7 +13713,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
13687
13713
  }
13688
13714
  return mapTransferToWalletTransfer(
13689
13715
  transfer,
13690
- bytesToHex11(await this.config.signer.getIdentityPublicKey())
13716
+ bytesToHex10(await this.config.signer.getIdentityPublicKey())
13691
13717
  );
13692
13718
  });
13693
13719
  }
@@ -14043,7 +14069,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
14043
14069
  const invoice2 = await sspClient.requestLightningReceive({
14044
14070
  amountSats: amountSats2,
14045
14071
  network: bitcoinNetwork,
14046
- paymentHash: bytesToHex11(paymentHash),
14072
+ paymentHash: bytesToHex10(paymentHash),
14047
14073
  expirySecs: expirySeconds,
14048
14074
  memo: memo2,
14049
14075
  includeSparkAddress,
@@ -14573,7 +14599,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
14573
14599
  return transfers?.[0];
14574
14600
  }
14575
14601
  async constructTransfersWithUserRequest(transfers) {
14576
- const identityPublicKey = bytesToHex11(
14602
+ const identityPublicKey = bytesToHex10(
14577
14603
  await this.config.signer.getIdentityPublicKey()
14578
14604
  );
14579
14605
  const userRequests = await this.sspClient?.getTransfers(
@@ -14817,7 +14843,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
14817
14843
  hash,
14818
14844
  compact
14819
14845
  );
14820
- return bytesToHex11(signature);
14846
+ return bytesToHex10(signature);
14821
14847
  }
14822
14848
  /**
14823
14849
  * Validates a message with the identity key.
@@ -14875,7 +14901,7 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
14875
14901
  publicKey,
14876
14902
  this.config.getNetwork()
14877
14903
  );
14878
- if (bytesToHex11(script) === bytesToHex11(identityScript)) {
14904
+ if (bytesToHex10(script) === bytesToHex10(identityScript)) {
14879
14905
  try {
14880
14906
  this.config.signer.signTransactionIndex(tx, i, publicKey);
14881
14907
  inputsSigned++;
@@ -14919,13 +14945,13 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
14919
14945
  depositPubKey,
14920
14946
  this.config.getNetwork()
14921
14947
  );
14922
- if (bytesToHex11(script) === bytesToHex11(identityScript)) {
14948
+ if (bytesToHex10(script) === bytesToHex10(identityScript)) {
14923
14949
  return {
14924
14950
  publicKey: identityPubKey,
14925
14951
  keyType: "identity"
14926
14952
  };
14927
14953
  }
14928
- if (bytesToHex11(script) === bytesToHex11(depositScript)) {
14954
+ if (bytesToHex10(script) === bytesToHex10(depositScript)) {
14929
14955
  return {
14930
14956
  publicKey: depositPubKey,
14931
14957
  keyType: "deposit"
@@ -15385,7 +15411,7 @@ async function isTxBroadcast(txid, baseUrl, network) {
15385
15411
  }
15386
15412
 
15387
15413
  // src/utils/unilateral-exit.ts
15388
- import { bytesToHex as bytesToHex12, hexToBytes as hexToBytes12 } from "@noble/curves/abstract/utils";
15414
+ import { bytesToHex as bytesToHex11, hexToBytes as hexToBytes12 } from "@noble/curves/utils";
15389
15415
  import { ripemd160 } from "@noble/hashes/legacy";
15390
15416
  import { sha256 as sha25613 } from "@noble/hashes/sha2";
15391
15417
  import * as btc4 from "@scure/btc-signer";
@@ -15456,10 +15482,10 @@ async function constructUnilateralExitTxs(nodeHexStrings, sparkClient, network)
15456
15482
  }
15457
15483
  }
15458
15484
  for (const chainNode of chain) {
15459
- const nodeTx = bytesToHex12(chainNode.nodeTx);
15485
+ const nodeTx = bytesToHex11(chainNode.nodeTx);
15460
15486
  transactions.push(nodeTx);
15461
15487
  if (chainNode.id === node.id) {
15462
- const refundTx = bytesToHex12(chainNode.refundTx);
15488
+ const refundTx = bytesToHex11(chainNode.refundTx);
15463
15489
  transactions.push(refundTx);
15464
15490
  }
15465
15491
  }
@@ -15565,7 +15591,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
15565
15591
  }
15566
15592
  }
15567
15593
  for (const chainNode of chain) {
15568
- let nodeTxHex = bytesToHex12(chainNode.nodeTx);
15594
+ let nodeTxHex = bytesToHex11(chainNode.nodeTx);
15569
15595
  try {
15570
15596
  const txObj = getTxFromRawTxHex(nodeTxHex);
15571
15597
  const txid = getTxId(txObj);
@@ -15582,7 +15608,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
15582
15608
  for (let i = txObj.outputsLength - 1; i >= 0; i--) {
15583
15609
  const output = txObj.getOutput(i);
15584
15610
  if (output?.amount === 0n && output.script) {
15585
- anchorOutputScriptHex = bytesToHex12(output.script);
15611
+ anchorOutputScriptHex = bytesToHex11(output.script);
15586
15612
  break;
15587
15613
  }
15588
15614
  }
@@ -15607,7 +15633,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
15607
15633
  var feeBumpOut = feeBumpTx.outputsLength === 1 ? feeBumpTx.getOutput(0) : null;
15608
15634
  var feeBumpOutPubKey = null;
15609
15635
  for (const usedUtxo of usedUtxos) {
15610
- if (feeBumpOut && bytesToHex12(feeBumpOut.script) == usedUtxo.script) {
15636
+ if (feeBumpOut && bytesToHex11(feeBumpOut.script) == usedUtxo.script) {
15611
15637
  feeBumpOutPubKey = usedUtxo.publicKey;
15612
15638
  }
15613
15639
  const index = availableUtxos.findIndex(
@@ -15622,20 +15648,20 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
15622
15648
  txid: getTxId(feeBumpTx),
15623
15649
  vout: 0,
15624
15650
  value: feeBumpOut.amount,
15625
- script: bytesToHex12(feeBumpOut.script),
15651
+ script: bytesToHex11(feeBumpOut.script),
15626
15652
  publicKey: feeBumpOutPubKey
15627
15653
  });
15628
15654
  const finalNodeTx = correctedParentTx || nodeTxHex;
15629
15655
  txPackages.push({ tx: finalNodeTx, feeBumpPsbt: nodeFeeBumpPsbt });
15630
15656
  if (chainNode.id === node.id) {
15631
- let refundTxHex = bytesToHex12(chainNode.refundTx);
15657
+ let refundTxHex = bytesToHex11(chainNode.refundTx);
15632
15658
  try {
15633
15659
  const txObj = getTxFromRawTxHex(refundTxHex);
15634
15660
  let anchorOutputScriptHex;
15635
15661
  for (let i = txObj.outputsLength - 1; i >= 0; i--) {
15636
15662
  const output = txObj.getOutput(i);
15637
15663
  if (output?.amount === 0n && output.script) {
15638
- anchorOutputScriptHex = bytesToHex12(output.script);
15664
+ anchorOutputScriptHex = bytesToHex11(output.script);
15639
15665
  break;
15640
15666
  }
15641
15667
  }
@@ -15663,7 +15689,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
15663
15689
  var feeBumpOut = feeBumpTx2.outputsLength === 1 ? feeBumpTx2.getOutput(0) : null;
15664
15690
  var feeBumpOutPubKey = null;
15665
15691
  for (const usedUtxo of usedUtxos) {
15666
- if (feeBumpOut && bytesToHex12(feeBumpOut.script) == usedUtxo.script) {
15692
+ if (feeBumpOut && bytesToHex11(feeBumpOut.script) == usedUtxo.script) {
15667
15693
  feeBumpOutPubKey = usedUtxo.publicKey;
15668
15694
  }
15669
15695
  const index = availableUtxos.findIndex(
@@ -15678,7 +15704,7 @@ async function constructUnilateralExitFeeBumpPackages(nodeHexStrings, utxos, fee
15678
15704
  txid: getTxId(feeBumpTx2),
15679
15705
  vout: 0,
15680
15706
  value: feeBumpOut.amount,
15681
- script: bytesToHex12(feeBumpOut.script),
15707
+ script: bytesToHex11(feeBumpOut.script),
15682
15708
  publicKey: feeBumpOutPubKey
15683
15709
  });
15684
15710
  txPackages.push({
@@ -15776,7 +15802,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
15776
15802
  const pubKeyHash = hash160(hexToBytes12(fundingUtxo.publicKey));
15777
15803
  const scriptToUse = new Uint8Array([0, 20, ...pubKeyHash]);
15778
15804
  const providedScript = hexToBytes12(fundingUtxo.script);
15779
- if (bytesToHex12(scriptToUse) !== bytesToHex12(providedScript)) {
15805
+ if (bytesToHex11(scriptToUse) !== bytesToHex11(providedScript)) {
15780
15806
  throw new Error(
15781
15807
  `\u274C Derived script doesn't match provided script for UTXO ${i + 1}.`
15782
15808
  );
@@ -15841,7 +15867,7 @@ function constructFeeBumpTx(txHex, utxos, feeRate, previousFeeBumpTx) {
15841
15867
  }
15842
15868
  let psbtHex;
15843
15869
  try {
15844
- psbtHex = bytesToHex12(builder.toPSBT());
15870
+ psbtHex = bytesToHex11(builder.toPSBT());
15845
15871
  } catch (error) {
15846
15872
  throw new Error(`Failed to extract transaction: ${error}`);
15847
15873
  }