@buildonspark/spark-sdk 0.2.3 → 0.2.5

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 (91) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-3SEOTO43.js → chunk-3SPMJMUX.js} +3 -2
  3. package/dist/{chunk-CDLETEDT.js → chunk-CQY5ML2A.js} +16 -3
  4. package/dist/{chunk-PTRXJS7Q.js → chunk-LQZL2D3Y.js} +1 -1
  5. package/dist/{chunk-PLLJIZC3.js → chunk-U7LRIWTF.js} +2471 -822
  6. package/dist/{client-CcYzmpmj.d.cts → client-C88GCTPB.d.cts} +211 -104
  7. package/dist/{client-CGTRS23n.d.ts → client-Dg6vS_2I.d.ts} +211 -104
  8. package/dist/debug.cjs +2511 -831
  9. package/dist/debug.d.cts +19 -6
  10. package/dist/debug.d.ts +19 -6
  11. package/dist/debug.js +3 -3
  12. package/dist/graphql/objects/index.cjs +13 -1
  13. package/dist/graphql/objects/index.d.cts +6 -51
  14. package/dist/graphql/objects/index.d.ts +6 -51
  15. package/dist/graphql/objects/index.js +1 -1
  16. package/dist/index.cjs +2491 -797
  17. package/dist/index.d.cts +189 -9
  18. package/dist/index.d.ts +189 -9
  19. package/dist/index.js +32 -4
  20. package/dist/index.node.cjs +2596 -799
  21. package/dist/index.node.d.cts +9 -190
  22. package/dist/index.node.d.ts +9 -190
  23. package/dist/index.node.js +134 -4
  24. package/dist/native/index.cjs +2491 -797
  25. package/dist/native/index.d.cts +309 -174
  26. package/dist/native/index.d.ts +309 -174
  27. package/dist/native/index.js +2495 -814
  28. package/dist/proto/lrc20.d.cts +1 -1
  29. package/dist/proto/lrc20.d.ts +1 -1
  30. package/dist/proto/spark.d.cts +1 -1
  31. package/dist/proto/spark.d.ts +1 -1
  32. package/dist/proto/spark_token.d.cts +1 -1
  33. package/dist/proto/spark_token.d.ts +1 -1
  34. package/dist/{spark-B_7nZx6T.d.cts → spark-ESAfZARg.d.cts} +1 -1
  35. package/dist/{spark-B_7nZx6T.d.ts → spark-ESAfZARg.d.ts} +1 -1
  36. package/dist/{spark-wallet-CxcGPXRB.d.ts → spark-wallet-B2WwKN8W.d.ts} +57 -35
  37. package/dist/{spark-wallet-DJJm19BP.d.cts → spark-wallet-Di65w0Us.d.cts} +57 -35
  38. package/dist/spark-wallet.node-7R0Rxyj9.d.cts +13 -0
  39. package/dist/spark-wallet.node-CSPWOWRu.d.ts +13 -0
  40. package/dist/tests/test-utils.cjs +578 -77
  41. package/dist/tests/test-utils.d.cts +12 -13
  42. package/dist/tests/test-utils.d.ts +12 -13
  43. package/dist/tests/test-utils.js +54 -17
  44. package/dist/types/index.cjs +16 -3
  45. package/dist/types/index.d.cts +3 -4
  46. package/dist/types/index.d.ts +3 -4
  47. package/dist/types/index.js +2 -2
  48. package/dist/{xchain-address-Bh9w1SeC.d.ts → xchain-address-BsveIy5l.d.ts} +56 -8
  49. package/dist/{xchain-address-SZ7dkVUE.d.cts → xchain-address-CqRu3F21.d.cts} +56 -8
  50. package/package.json +1 -1
  51. package/src/graphql/client.ts +57 -8
  52. package/src/graphql/mutations/CompleteLeavesSwap.ts +9 -1
  53. package/src/graphql/mutations/RequestSwapLeaves.ts +4 -0
  54. package/src/graphql/objects/CompleteLeavesSwapInput.ts +34 -34
  55. package/src/graphql/objects/LeavesSwapRequest.ts +4 -0
  56. package/src/graphql/objects/RequestLeavesSwapInput.ts +48 -47
  57. package/src/graphql/objects/SparkWalletUser.ts +1 -1
  58. package/src/graphql/objects/SwapLeaf.ts +40 -32
  59. package/src/graphql/objects/UserLeafInput.ts +24 -0
  60. package/src/graphql/objects/UserRequest.ts +4 -0
  61. package/src/graphql/queries/Transfers.ts +15 -0
  62. package/src/index.node.ts +1 -1
  63. package/src/native/index.ts +4 -5
  64. package/src/services/coop-exit.ts +171 -36
  65. package/src/services/deposit.ts +471 -74
  66. package/src/services/lightning.ts +18 -5
  67. package/src/services/signing.ts +162 -50
  68. package/src/services/transfer.ts +950 -384
  69. package/src/services/tree-creation.ts +342 -121
  70. package/src/spark-wallet/spark-wallet.node.ts +71 -66
  71. package/src/spark-wallet/spark-wallet.ts +561 -192
  72. package/src/tests/integration/coop-exit.test.ts +3 -8
  73. package/src/tests/integration/deposit.test.ts +3 -3
  74. package/src/tests/integration/lightning.test.ts +521 -466
  75. package/src/tests/integration/ssp/static_deposit.test.ts +83 -1
  76. package/src/tests/integration/ssp/transfers.test.ts +97 -0
  77. package/src/tests/integration/swap.test.ts +559 -307
  78. package/src/tests/integration/transfer.test.ts +625 -623
  79. package/src/tests/integration/wallet.test.ts +2 -2
  80. package/src/tests/integration/watchtower.test.ts +211 -0
  81. package/src/tests/test-utils.ts +63 -14
  82. package/src/tests/utils/test-faucet.ts +4 -2
  83. package/src/types/sdk-types.ts +15 -0
  84. package/src/utils/adaptor-signature.ts +15 -5
  85. package/src/utils/bitcoin.ts +13 -0
  86. package/src/utils/fetch.ts +75 -0
  87. package/src/utils/mempool.ts +9 -4
  88. package/src/utils/transaction.ts +388 -26
  89. package/dist/sdk-types-CB9HrW5O.d.cts +0 -44
  90. package/dist/sdk-types-CkRNraXT.d.ts +0 -44
  91. package/src/graphql/queries/Transfer.ts +0 -10
@@ -1289,9 +1289,11 @@ var test_utils_exports = {};
1289
1289
  __export(test_utils_exports, {
1290
1290
  BitcoinFaucet: () => BitcoinFaucet,
1291
1291
  createNewTree: () => createNewTree,
1292
+ createNewTreeWithoutDirectTx: () => createNewTreeWithoutDirectTx,
1292
1293
  getTestWalletConfig: () => getTestWalletConfig,
1293
1294
  getTestWalletConfigWithIdentityKey: () => getTestWalletConfigWithIdentityKey,
1294
- signerTypes: () => signerTypes
1295
+ signerTypes: () => signerTypes,
1296
+ walletTypes: () => walletTypes
1295
1297
  });
1296
1298
  module.exports = __toCommonJS(test_utils_exports);
1297
1299
  init_buffer();
@@ -16341,6 +16343,10 @@ fragment LeavesSwapRequestFragment on LeavesSwapRequest {
16341
16343
  swap_leaf_leaf_id: leaf_id
16342
16344
  swap_leaf_raw_unsigned_refund_transaction: raw_unsigned_refund_transaction
16343
16345
  swap_leaf_adaptor_signed_signature: adaptor_signed_signature
16346
+ swap_leaf_direct_raw_unsigned_refund_transaction: direct_raw_unsigned_refund_transaction
16347
+ swap_leaf_direct_adaptor_signed_signature: direct_adaptor_signed_signature
16348
+ swap_leaf_direct_from_cpfp_raw_unsigned_refund_transaction: direct_from_cpfp_raw_unsigned_refund_transaction
16349
+ swap_leaf_direct_from_cpfp_adaptor_signed_signature: direct_from_cpfp_adaptor_signed_signature
16344
16350
  }
16345
16351
  }`;
16346
16352
 
@@ -16607,6 +16613,10 @@ fragment UserRequestFragment on UserRequest {
16607
16613
  swap_leaf_leaf_id: leaf_id
16608
16614
  swap_leaf_raw_unsigned_refund_transaction: raw_unsigned_refund_transaction
16609
16615
  swap_leaf_adaptor_signed_signature: adaptor_signed_signature
16616
+ swap_leaf_direct_raw_unsigned_refund_transaction: direct_raw_unsigned_refund_transaction
16617
+ swap_leaf_direct_adaptor_signed_signature: direct_adaptor_signed_signature
16618
+ swap_leaf_direct_from_cpfp_raw_unsigned_refund_transaction: direct_from_cpfp_raw_unsigned_refund_transaction
16619
+ swap_leaf_direct_from_cpfp_adaptor_signed_signature: direct_from_cpfp_adaptor_signed_signature
16610
16620
  }
16611
16621
  }
16612
16622
  ... on LightningReceiveRequest {
@@ -16691,6 +16701,27 @@ fragment UserRequestFragment on UserRequest {
16691
16701
  init_buffer();
16692
16702
  var import_utils7 = require("@noble/curves/abstract/utils");
16693
16703
 
16704
+ // src/utils/fetch.ts
16705
+ init_buffer();
16706
+ var fetchImpl = typeof window !== "undefined" && window.fetch ? window.fetch.bind(window) : globalThis.fetch ? globalThis.fetch : null;
16707
+ var Headers = globalThis.Headers ?? null;
16708
+ var getFetch = () => {
16709
+ if (!fetchImpl) {
16710
+ throw new Error(
16711
+ "Fetch implementation is not set. Please set it using setFetch()."
16712
+ );
16713
+ }
16714
+ if (!Headers) {
16715
+ throw new Error(
16716
+ "Headers implementation is not set. Please set it using setFetch()."
16717
+ );
16718
+ }
16719
+ return {
16720
+ fetch: fetchImpl,
16721
+ Headers
16722
+ };
16723
+ };
16724
+
16694
16725
  // src/utils/proof.ts
16695
16726
  init_buffer();
16696
16727
  var import_sha22 = require("@noble/hashes/sha2");
@@ -16823,9 +16854,122 @@ var import_sha23 = require("@noble/hashes/sha2");
16823
16854
  // src/utils/transaction.ts
16824
16855
  init_buffer();
16825
16856
  var import_btc_signer = require("@scure/btc-signer");
16857
+ var INITIAL_TIMELOCK = 2e3;
16858
+ var TEST_UNILATERAL_TIMELOCK = 100;
16859
+ var DIRECT_TIMELOCK_OFFSET = 50;
16860
+ var INITIAL_SEQUENCE = 1 << 30 | INITIAL_TIMELOCK;
16861
+ var INITIAL_DIRECT_SEQUENCE = 1 << 30 | INITIAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
16862
+ var TEST_UNILATERAL_SEQUENCE = 1 << 30 | TEST_UNILATERAL_TIMELOCK;
16863
+ var TEST_UNILATERAL_DIRECT_SEQUENCE = 1 << 30 | TEST_UNILATERAL_TIMELOCK + DIRECT_TIMELOCK_OFFSET;
16826
16864
  var ESTIMATED_TX_SIZE = 191;
16827
16865
  var DEFAULT_SATS_PER_VBYTE = 5;
16828
16866
  var DEFAULT_FEE_SATS = ESTIMATED_TX_SIZE * DEFAULT_SATS_PER_VBYTE;
16867
+ function maybeApplyFee(amount) {
16868
+ if (amount > BigInt(DEFAULT_FEE_SATS)) {
16869
+ return amount - BigInt(DEFAULT_FEE_SATS);
16870
+ }
16871
+ return amount;
16872
+ }
16873
+ function createRootTx(depositOutPoint, depositTxOut) {
16874
+ const cpfpRootTx = new import_btc_signer.Transaction({
16875
+ version: 3,
16876
+ allowUnknownOutputs: true
16877
+ });
16878
+ cpfpRootTx.addInput(depositOutPoint);
16879
+ cpfpRootTx.addOutput(depositTxOut);
16880
+ cpfpRootTx.addOutput(getEphemeralAnchorOutput());
16881
+ const directRootTx = new import_btc_signer.Transaction({
16882
+ version: 3,
16883
+ allowUnknownOutputs: true
16884
+ });
16885
+ directRootTx.addInput(depositOutPoint);
16886
+ directRootTx.addOutput({
16887
+ script: depositTxOut.script,
16888
+ amount: maybeApplyFee(depositTxOut.amount ?? 0n)
16889
+ });
16890
+ return [cpfpRootTx, directRootTx];
16891
+ }
16892
+ function createRefundTx({
16893
+ sequence,
16894
+ input,
16895
+ amountSats,
16896
+ receivingPubkey,
16897
+ network,
16898
+ shouldCalculateFee,
16899
+ includeAnchor
16900
+ }) {
16901
+ const refundTx = new import_btc_signer.Transaction({
16902
+ version: 3,
16903
+ allowUnknownOutputs: true
16904
+ });
16905
+ refundTx.addInput({
16906
+ ...input,
16907
+ sequence
16908
+ });
16909
+ const refundPkScript = getP2TRScriptFromPublicKey(receivingPubkey, network);
16910
+ let outputAmount = amountSats;
16911
+ if (shouldCalculateFee) {
16912
+ outputAmount = maybeApplyFee(amountSats);
16913
+ }
16914
+ refundTx.addOutput({
16915
+ script: refundPkScript,
16916
+ amount: outputAmount
16917
+ });
16918
+ if (includeAnchor) {
16919
+ refundTx.addOutput(getEphemeralAnchorOutput());
16920
+ }
16921
+ return refundTx;
16922
+ }
16923
+ function createRefundTxs({
16924
+ sequence,
16925
+ directSequence,
16926
+ input,
16927
+ directInput,
16928
+ amountSats,
16929
+ receivingPubkey,
16930
+ network
16931
+ }) {
16932
+ const cpfpRefundTx = createRefundTx({
16933
+ sequence,
16934
+ input,
16935
+ amountSats,
16936
+ receivingPubkey,
16937
+ network,
16938
+ shouldCalculateFee: false,
16939
+ includeAnchor: true
16940
+ });
16941
+ let directRefundTx;
16942
+ let directFromCpfpRefundTx;
16943
+ if (directSequence && directInput) {
16944
+ directRefundTx = createRefundTx({
16945
+ sequence: directSequence,
16946
+ input: directInput,
16947
+ amountSats,
16948
+ receivingPubkey,
16949
+ network,
16950
+ shouldCalculateFee: true,
16951
+ includeAnchor: false
16952
+ });
16953
+ directFromCpfpRefundTx = createRefundTx({
16954
+ sequence: directSequence,
16955
+ input,
16956
+ amountSats,
16957
+ receivingPubkey,
16958
+ network,
16959
+ shouldCalculateFee: true,
16960
+ includeAnchor: false
16961
+ });
16962
+ } else if (directInput && !directSequence) {
16963
+ throw new ValidationError(
16964
+ "directSequence must be provided if directInput is",
16965
+ {
16966
+ field: "directSequence",
16967
+ value: directSequence
16968
+ }
16969
+ );
16970
+ }
16971
+ return { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx };
16972
+ }
16829
16973
  function getEphemeralAnchorOutput() {
16830
16974
  return {
16831
16975
  script: new Uint8Array([81, 2, 78, 115]),
@@ -16871,7 +17015,7 @@ init_buffer();
16871
17015
  var import_core8 = require("@lightsparkdev/core");
16872
17016
  var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
16873
17017
  var isBun = globalThis.Bun !== void 0;
16874
- var packageVersion = true ? "0.2.3" : "unknown";
17018
+ var packageVersion = true ? "0.2.5" : "unknown";
16875
17019
  var baseEnvStr = "unknown";
16876
17020
  if (isBun) {
16877
17021
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -17484,10 +17628,18 @@ init_buffer();
17484
17628
  var CompleteLeavesSwap = `
17485
17629
  mutation CompleteLeavesSwap(
17486
17630
  $adaptor_secret_key: String!
17631
+ $direct_adaptor_secret_key: String!
17632
+ $direct_from_cpfp_adaptor_secret_key: String!
17487
17633
  $user_outbound_transfer_external_id: UUID!
17488
17634
  $leaves_swap_request_id: ID!
17489
17635
  ) {
17490
- complete_leaves_swap(input: { adaptor_secret_key: $adaptor_secret_key, user_outbound_transfer_external_id: $user_outbound_transfer_external_id, leaves_swap_request_id: $leaves_swap_request_id }) {
17636
+ complete_leaves_swap(input: {
17637
+ adaptor_secret_key: $adaptor_secret_key,
17638
+ direct_adaptor_secret_key: $direct_adaptor_secret_key,
17639
+ direct_from_cpfp_adaptor_secret_key: $direct_from_cpfp_adaptor_secret_key,
17640
+ user_outbound_transfer_external_id: $user_outbound_transfer_external_id,
17641
+ leaves_swap_request_id: $leaves_swap_request_id
17642
+ }) {
17491
17643
  request {
17492
17644
  ...LeavesSwapRequestFragment
17493
17645
  }
@@ -17613,6 +17765,8 @@ init_buffer();
17613
17765
  var RequestSwapLeaves = `
17614
17766
  mutation RequestSwapLeaves(
17615
17767
  $adaptor_pubkey: PublicKey!
17768
+ $direct_adaptor_pubkey: PublicKey
17769
+ $direct_from_cpfp_adaptor_pubkey: PublicKey
17616
17770
  $total_amount_sats: Long!
17617
17771
  $target_amount_sats: Long!
17618
17772
  $fee_sats: Long!
@@ -17622,6 +17776,8 @@ var RequestSwapLeaves = `
17622
17776
  ) {
17623
17777
  request_leaves_swap(input: {
17624
17778
  adaptor_pubkey: $adaptor_pubkey
17779
+ direct_adaptor_pubkey: $direct_adaptor_pubkey
17780
+ direct_from_cpfp_adaptor_pubkey: $direct_from_cpfp_adaptor_pubkey
17625
17781
  total_amount_sats: $total_amount_sats
17626
17782
  target_amount_sats: $target_amount_sats
17627
17783
  fee_sats: $fee_sats
@@ -17878,15 +18034,19 @@ var LightningSendFeeEstimate = `
17878
18034
  ${FRAGMENT13}
17879
18035
  `;
17880
18036
 
17881
- // src/graphql/queries/Transfer.ts
18037
+ // src/graphql/queries/Transfers.ts
17882
18038
  init_buffer();
17883
- var GetTransfer = `
17884
- query Transfer($transfer_spark_id: UUID!) {
17885
- transfer(transfer_spark_id: $transfer_spark_id) {
18039
+ var GetTransfers = `
18040
+ query Transfers($transfer_spark_ids: [UUID!]!) {
18041
+ transfers(transfer_spark_ids: $transfer_spark_ids) {
17886
18042
  ...TransferFragment
18043
+ transfer_user_request: user_request {
18044
+ ...UserRequestFragment
18045
+ }
17887
18046
  }
17888
18047
  }
17889
18048
  ${FRAGMENT2}
18049
+ ${FRAGMENT6}
17890
18050
  `;
17891
18051
 
17892
18052
  // src/graphql/queries/UserRequest.ts
@@ -21820,10 +21980,8 @@ init_buffer();
21820
21980
  var import_secp256k110 = require("@noble/curves/secp256k1");
21821
21981
  var import_sha29 = require("@noble/hashes/sha2");
21822
21982
  var import_utils15 = require("@noble/hashes/utils");
21823
- var btc5 = __toESM(require("@scure/btc-signer"), 1);
21824
21983
  var import_btc_signer4 = require("@scure/btc-signer");
21825
21984
  var import_utils16 = require("@scure/btc-signer/utils");
21826
- var INITIAL_TIME_LOCK = 2e3;
21827
21985
  var DepositService = class {
21828
21986
  config;
21829
21987
  connectionManager;
@@ -21941,7 +22099,6 @@ var DepositService = class {
21941
22099
  depositTx,
21942
22100
  vout
21943
22101
  }) {
21944
- const rootTx = new import_btc_signer4.Transaction({ version: 3 });
21945
22102
  const output = depositTx.getOutput(vout);
21946
22103
  if (!output) {
21947
22104
  throw new ValidationError("Invalid deposit transaction output", {
@@ -21959,39 +22116,345 @@ var DepositService = class {
21959
22116
  expected: "Output with script and amount"
21960
22117
  });
21961
22118
  }
21962
- let outputAmount = amount;
21963
- rootTx.addInput({
21964
- txid: getTxId(depositTx),
22119
+ const depositOutPoint = {
22120
+ txid: (0, import_utils15.hexToBytes)(getTxId(depositTx)),
21965
22121
  index: vout
21966
- });
21967
- rootTx.addOutput({
22122
+ };
22123
+ const depositTxOut = {
21968
22124
  script,
21969
- amount: outputAmount
22125
+ amount
22126
+ };
22127
+ const [cpfpRootTx, directRootTx] = createRootTx(
22128
+ depositOutPoint,
22129
+ depositTxOut
22130
+ );
22131
+ const cpfpRootNonceCommitment = await this.config.signer.getRandomSigningCommitment();
22132
+ const directRootNonceCommitment = await this.config.signer.getRandomSigningCommitment();
22133
+ const cpfpRootTxSighash = getSigHashFromTx(cpfpRootTx, 0, output);
22134
+ const directRootTxSighash = getSigHashFromTx(directRootTx, 0, output);
22135
+ const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
22136
+ const { cpfpRefundTx, directRefundTx, directFromCpfpRefundTx } = createRefundTxs({
22137
+ sequence: INITIAL_SEQUENCE,
22138
+ directSequence: INITIAL_DIRECT_SEQUENCE,
22139
+ input: { txid: (0, import_utils15.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
22140
+ directInput: { txid: (0, import_utils15.hexToBytes)(getTxId(directRootTx)), index: 0 },
22141
+ amountSats: amount,
22142
+ receivingPubkey: signingPubKey,
22143
+ network: this.config.getNetwork()
22144
+ });
22145
+ const cpfpRefundNonceCommitment = await this.config.signer.getRandomSigningCommitment();
22146
+ const directRefundNonceCommitment = await this.config.signer.getRandomSigningCommitment();
22147
+ const directFromCpfpRefundNonceCommitment = await this.config.signer.getRandomSigningCommitment();
22148
+ const cpfpRefundTxSighash = getSigHashFromTx(
22149
+ cpfpRefundTx,
22150
+ 0,
22151
+ cpfpRootTx.getOutput(0)
22152
+ );
22153
+ if (!directRefundTx || !directFromCpfpRefundTx) {
22154
+ throw new ValidationError(
22155
+ "Expected direct refund transactions for tree creation",
22156
+ {
22157
+ field: "directRefundTx",
22158
+ value: directRefundTx
22159
+ }
22160
+ );
22161
+ }
22162
+ const directRefundTxSighash = getSigHashFromTx(
22163
+ directRefundTx,
22164
+ 0,
22165
+ directRootTx.getOutput(0)
22166
+ );
22167
+ const directFromCpfpRefundTxSighash = getSigHashFromTx(
22168
+ directFromCpfpRefundTx,
22169
+ 0,
22170
+ cpfpRootTx.getOutput(0)
22171
+ );
22172
+ const sparkClient = await this.connectionManager.createSparkClient(
22173
+ this.config.getCoordinatorAddress()
22174
+ );
22175
+ let treeResp;
22176
+ try {
22177
+ treeResp = await sparkClient.start_deposit_tree_creation({
22178
+ identityPublicKey: await this.config.signer.getIdentityPublicKey(),
22179
+ onChainUtxo: {
22180
+ vout,
22181
+ rawTx: depositTx.toBytes(true),
22182
+ network: this.config.getNetworkProto()
22183
+ },
22184
+ rootTxSigningJob: {
22185
+ rawTx: cpfpRootTx.toBytes(),
22186
+ signingPublicKey: signingPubKey,
22187
+ signingNonceCommitment: cpfpRootNonceCommitment.commitment
22188
+ },
22189
+ refundTxSigningJob: {
22190
+ rawTx: cpfpRefundTx.toBytes(),
22191
+ signingPublicKey: signingPubKey,
22192
+ signingNonceCommitment: cpfpRefundNonceCommitment.commitment
22193
+ },
22194
+ directRootTxSigningJob: {
22195
+ rawTx: directRootTx.toBytes(),
22196
+ signingPublicKey: signingPubKey,
22197
+ signingNonceCommitment: directRootNonceCommitment.commitment
22198
+ },
22199
+ directRefundTxSigningJob: {
22200
+ rawTx: directRefundTx.toBytes(),
22201
+ signingPublicKey: signingPubKey,
22202
+ signingNonceCommitment: directRefundNonceCommitment.commitment
22203
+ },
22204
+ directFromCpfpRefundTxSigningJob: {
22205
+ rawTx: directFromCpfpRefundTx.toBytes(),
22206
+ signingPublicKey: signingPubKey,
22207
+ signingNonceCommitment: directFromCpfpRefundNonceCommitment.commitment
22208
+ }
22209
+ });
22210
+ } catch (error) {
22211
+ throw new NetworkError(
22212
+ "Failed to start deposit tree creation",
22213
+ {
22214
+ operation: "start_deposit_tree_creation",
22215
+ errorCount: 1,
22216
+ errors: error instanceof Error ? error.message : String(error)
22217
+ },
22218
+ error
22219
+ );
22220
+ }
22221
+ if (!treeResp.rootNodeSignatureShares?.verifyingKey) {
22222
+ throw new ValidationError("No verifying key found in tree response", {
22223
+ field: "verifyingKey",
22224
+ value: treeResp.rootNodeSignatureShares,
22225
+ expected: "Non-null verifying key"
22226
+ });
22227
+ }
22228
+ if (!treeResp.rootNodeSignatureShares.nodeTxSigningResult?.signingNonceCommitments) {
22229
+ throw new ValidationError(
22230
+ "No signing nonce commitments found in tree response",
22231
+ {
22232
+ field: "nodeTxSigningResult.signingNonceCommitments",
22233
+ value: treeResp.rootNodeSignatureShares.nodeTxSigningResult,
22234
+ expected: "Non-null signing nonce commitments"
22235
+ }
22236
+ );
22237
+ }
22238
+ if (!treeResp.rootNodeSignatureShares.refundTxSigningResult?.signingNonceCommitments) {
22239
+ throw new ValidationError(
22240
+ "No signing nonce commitments found in tree response",
22241
+ {
22242
+ field: "refundTxSigningResult.signingNonceCommitments"
22243
+ }
22244
+ );
22245
+ }
22246
+ if (!treeResp.rootNodeSignatureShares.directNodeTxSigningResult?.signingNonceCommitments) {
22247
+ throw new ValidationError(
22248
+ "No direct node signing nonce commitments found in tree response",
22249
+ {
22250
+ field: "directNodeTxSigningResult.signingNonceCommitments"
22251
+ }
22252
+ );
22253
+ }
22254
+ if (!treeResp.rootNodeSignatureShares.directRefundTxSigningResult?.signingNonceCommitments) {
22255
+ throw new ValidationError(
22256
+ "No direct refund signing nonce commitments found in tree response",
22257
+ {
22258
+ field: "directRefundTxSigningResult.signingNonceCommitments"
22259
+ }
22260
+ );
22261
+ }
22262
+ if (!treeResp.rootNodeSignatureShares.directFromCpfpRefundTxSigningResult?.signingNonceCommitments) {
22263
+ throw new ValidationError(
22264
+ "No direct from CPFP refund signing nonce commitments found in tree response",
22265
+ {
22266
+ field: "directFromCpfpRefundTxSigningResult.signingNonceCommitments"
22267
+ }
22268
+ );
22269
+ }
22270
+ if (!(0, import_utils16.equalBytes)(treeResp.rootNodeSignatureShares.verifyingKey, verifyingKey)) {
22271
+ throw new ValidationError("Verifying key mismatch", {
22272
+ field: "verifyingKey",
22273
+ value: treeResp.rootNodeSignatureShares.verifyingKey,
22274
+ expected: verifyingKey
22275
+ });
22276
+ }
22277
+ const cpfpRootSignature = await this.config.signer.signFrost({
22278
+ message: cpfpRootTxSighash,
22279
+ publicKey: signingPubKey,
22280
+ keyDerivation,
22281
+ verifyingKey,
22282
+ selfCommitment: cpfpRootNonceCommitment,
22283
+ statechainCommitments: treeResp.rootNodeSignatureShares.nodeTxSigningResult.signingNonceCommitments,
22284
+ adaptorPubKey: new Uint8Array()
22285
+ });
22286
+ const directRootSignature = await this.config.signer.signFrost({
22287
+ message: directRootTxSighash,
22288
+ publicKey: signingPubKey,
22289
+ keyDerivation,
22290
+ verifyingKey,
22291
+ selfCommitment: directRootNonceCommitment,
22292
+ statechainCommitments: treeResp.rootNodeSignatureShares.directNodeTxSigningResult.signingNonceCommitments,
22293
+ adaptorPubKey: new Uint8Array()
22294
+ });
22295
+ const cpfpRefundSignature = await this.config.signer.signFrost({
22296
+ message: cpfpRefundTxSighash,
22297
+ publicKey: signingPubKey,
22298
+ keyDerivation,
22299
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22300
+ selfCommitment: cpfpRefundNonceCommitment,
22301
+ statechainCommitments: treeResp.rootNodeSignatureShares.refundTxSigningResult.signingNonceCommitments,
22302
+ adaptorPubKey: new Uint8Array()
22303
+ });
22304
+ const directRefundSignature = await this.config.signer.signFrost({
22305
+ message: directRefundTxSighash,
22306
+ publicKey: signingPubKey,
22307
+ keyDerivation,
22308
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22309
+ selfCommitment: directRefundNonceCommitment,
22310
+ statechainCommitments: treeResp.rootNodeSignatureShares.directRefundTxSigningResult.signingNonceCommitments,
22311
+ adaptorPubKey: new Uint8Array()
22312
+ });
22313
+ const directFromCpfpRefundSignature = await this.config.signer.signFrost({
22314
+ message: directFromCpfpRefundTxSighash,
22315
+ publicKey: signingPubKey,
22316
+ keyDerivation,
22317
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22318
+ selfCommitment: directFromCpfpRefundNonceCommitment,
22319
+ statechainCommitments: treeResp.rootNodeSignatureShares.directFromCpfpRefundTxSigningResult.signingNonceCommitments,
22320
+ adaptorPubKey: new Uint8Array()
22321
+ });
22322
+ const cpfpRootAggregate = await this.config.signer.aggregateFrost({
22323
+ message: cpfpRootTxSighash,
22324
+ statechainSignatures: treeResp.rootNodeSignatureShares.nodeTxSigningResult.signatureShares,
22325
+ statechainPublicKeys: treeResp.rootNodeSignatureShares.nodeTxSigningResult.publicKeys,
22326
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22327
+ statechainCommitments: treeResp.rootNodeSignatureShares.nodeTxSigningResult.signingNonceCommitments,
22328
+ selfCommitment: cpfpRootNonceCommitment,
22329
+ publicKey: signingPubKey,
22330
+ selfSignature: cpfpRootSignature,
22331
+ adaptorPubKey: new Uint8Array()
21970
22332
  });
21971
- rootTx.addOutput(getEphemeralAnchorOutput());
21972
- const rootNonceCommitment = await this.config.signer.getRandomSigningCommitment();
21973
- const rootTxSighash = getSigHashFromTx(rootTx, 0, output);
21974
- const refundTx = new import_btc_signer4.Transaction({ version: 3 });
21975
- const sequence = 1 << 30 | INITIAL_TIME_LOCK;
21976
- refundTx.addInput({
21977
- txid: getTxId(rootTx),
21978
- index: 0,
21979
- sequence
22333
+ const directRootAggregate = await this.config.signer.aggregateFrost({
22334
+ message: directRootTxSighash,
22335
+ statechainSignatures: treeResp.rootNodeSignatureShares.directNodeTxSigningResult.signatureShares,
22336
+ statechainPublicKeys: treeResp.rootNodeSignatureShares.directNodeTxSigningResult.publicKeys,
22337
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22338
+ statechainCommitments: treeResp.rootNodeSignatureShares.directNodeTxSigningResult.signingNonceCommitments,
22339
+ selfCommitment: directRootNonceCommitment,
22340
+ publicKey: signingPubKey,
22341
+ selfSignature: directRootSignature,
22342
+ adaptorPubKey: new Uint8Array()
21980
22343
  });
22344
+ const cpfpRefundAggregate = await this.config.signer.aggregateFrost({
22345
+ message: cpfpRefundTxSighash,
22346
+ statechainSignatures: treeResp.rootNodeSignatureShares.refundTxSigningResult.signatureShares,
22347
+ statechainPublicKeys: treeResp.rootNodeSignatureShares.refundTxSigningResult.publicKeys,
22348
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22349
+ statechainCommitments: treeResp.rootNodeSignatureShares.refundTxSigningResult.signingNonceCommitments,
22350
+ selfCommitment: cpfpRefundNonceCommitment,
22351
+ publicKey: signingPubKey,
22352
+ selfSignature: cpfpRefundSignature,
22353
+ adaptorPubKey: new Uint8Array()
22354
+ });
22355
+ const directRefundAggregate = await this.config.signer.aggregateFrost({
22356
+ message: directRefundTxSighash,
22357
+ statechainSignatures: treeResp.rootNodeSignatureShares.directRefundTxSigningResult.signatureShares,
22358
+ statechainPublicKeys: treeResp.rootNodeSignatureShares.directRefundTxSigningResult.publicKeys,
22359
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22360
+ statechainCommitments: treeResp.rootNodeSignatureShares.directRefundTxSigningResult.signingNonceCommitments,
22361
+ selfCommitment: directRefundNonceCommitment,
22362
+ publicKey: signingPubKey,
22363
+ selfSignature: directRefundSignature,
22364
+ adaptorPubKey: new Uint8Array()
22365
+ });
22366
+ const directFromCpfpRefundAggregate = await this.config.signer.aggregateFrost({
22367
+ message: directFromCpfpRefundTxSighash,
22368
+ statechainSignatures: treeResp.rootNodeSignatureShares.directFromCpfpRefundTxSigningResult.signatureShares,
22369
+ statechainPublicKeys: treeResp.rootNodeSignatureShares.directFromCpfpRefundTxSigningResult.publicKeys,
22370
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22371
+ statechainCommitments: treeResp.rootNodeSignatureShares.directFromCpfpRefundTxSigningResult.signingNonceCommitments,
22372
+ selfCommitment: directFromCpfpRefundNonceCommitment,
22373
+ publicKey: signingPubKey,
22374
+ selfSignature: directFromCpfpRefundSignature,
22375
+ adaptorPubKey: new Uint8Array()
22376
+ });
22377
+ let finalizeResp;
22378
+ try {
22379
+ finalizeResp = await sparkClient.finalize_node_signatures_v2({
22380
+ intent: 0 /* CREATION */,
22381
+ nodeSignatures: [
22382
+ {
22383
+ nodeId: treeResp.rootNodeSignatureShares.nodeId,
22384
+ nodeTxSignature: cpfpRootAggregate,
22385
+ refundTxSignature: cpfpRefundAggregate,
22386
+ directNodeTxSignature: directRootAggregate,
22387
+ directRefundTxSignature: directRefundAggregate,
22388
+ directFromCpfpRefundTxSignature: directFromCpfpRefundAggregate
22389
+ }
22390
+ ]
22391
+ });
22392
+ } catch (error) {
22393
+ throw new NetworkError(
22394
+ "Failed to finalize node signatures",
22395
+ {
22396
+ operation: "finalize_node_signatures",
22397
+ errorCount: 1,
22398
+ errors: error instanceof Error ? error.message : String(error)
22399
+ },
22400
+ error
22401
+ );
22402
+ }
22403
+ return finalizeResp;
22404
+ }
22405
+ /**
22406
+ * @deprecated
22407
+ * Use createTreeRoot instead.
22408
+ * This is currently only used to test backwards compatibility.
22409
+ */
22410
+ async createTreeWithoutDirectTx({
22411
+ keyDerivation,
22412
+ verifyingKey,
22413
+ depositTx,
22414
+ vout
22415
+ }) {
22416
+ const output = depositTx.getOutput(vout);
22417
+ if (!output) {
22418
+ throw new ValidationError("Invalid deposit transaction output", {
22419
+ field: "vout",
22420
+ value: vout,
22421
+ expected: "Valid output index"
22422
+ });
22423
+ }
22424
+ const script = output.script;
22425
+ const amount = output.amount;
22426
+ if (!script || !amount) {
22427
+ throw new ValidationError("No script or amount found in deposit tx", {
22428
+ field: "output",
22429
+ value: output,
22430
+ expected: "Output with script and amount"
22431
+ });
22432
+ }
22433
+ const depositOutPoint = {
22434
+ txid: (0, import_utils15.hexToBytes)(getTxId(depositTx)),
22435
+ index: vout
22436
+ };
22437
+ const depositTxOut = {
22438
+ script,
22439
+ amount
22440
+ };
22441
+ const [cpfpRootTx, _] = createRootTx(depositOutPoint, depositTxOut);
22442
+ const cpfpRootNonceCommitment = await this.config.signer.getRandomSigningCommitment();
22443
+ const cpfpRootTxSighash = getSigHashFromTx(cpfpRootTx, 0, output);
21981
22444
  const signingPubKey = await this.config.signer.getPublicKeyFromDerivation(keyDerivation);
21982
- const refundP2trAddress = getP2TRAddressFromPublicKey(
21983
- signingPubKey,
21984
- this.config.getNetwork()
21985
- );
21986
- const refundAddress = btc5.Address(getNetwork(this.config.getNetwork())).decode(refundP2trAddress);
21987
- const refundPkScript = btc5.OutScript.encode(refundAddress);
21988
- refundTx.addOutput({
21989
- script: refundPkScript,
21990
- amount: outputAmount
22445
+ const { cpfpRefundTx } = createRefundTxs({
22446
+ sequence: INITIAL_SEQUENCE,
22447
+ input: { txid: (0, import_utils15.hexToBytes)(getTxId(cpfpRootTx)), index: 0 },
22448
+ amountSats: amount,
22449
+ receivingPubkey: signingPubKey,
22450
+ network: this.config.getNetwork()
21991
22451
  });
21992
- refundTx.addOutput(getEphemeralAnchorOutput());
21993
- const refundNonceCommitment = await this.config.signer.getRandomSigningCommitment();
21994
- const refundTxSighash = getSigHashFromTx(refundTx, 0, rootTx.getOutput(0));
22452
+ const cpfpRefundNonceCommitment = await this.config.signer.getRandomSigningCommitment();
22453
+ const cpfpRefundTxSighash = getSigHashFromTx(
22454
+ cpfpRefundTx,
22455
+ 0,
22456
+ cpfpRootTx.getOutput(0)
22457
+ );
21995
22458
  const sparkClient = await this.connectionManager.createSparkClient(
21996
22459
  this.config.getCoordinatorAddress()
21997
22460
  );
@@ -22005,14 +22468,14 @@ var DepositService = class {
22005
22468
  network: this.config.getNetworkProto()
22006
22469
  },
22007
22470
  rootTxSigningJob: {
22008
- rawTx: rootTx.toBytes(),
22471
+ rawTx: cpfpRootTx.toBytes(),
22009
22472
  signingPublicKey: signingPubKey,
22010
- signingNonceCommitment: rootNonceCommitment.commitment
22473
+ signingNonceCommitment: cpfpRootNonceCommitment.commitment
22011
22474
  },
22012
22475
  refundTxSigningJob: {
22013
- rawTx: refundTx.toBytes(),
22476
+ rawTx: cpfpRefundTx.toBytes(),
22014
22477
  signingPublicKey: signingPubKey,
22015
- signingNonceCommitment: refundNonceCommitment.commitment
22478
+ signingNonceCommitment: cpfpRefundNonceCommitment.commitment
22016
22479
  }
22017
22480
  });
22018
22481
  } catch (error) {
@@ -22058,55 +22521,55 @@ var DepositService = class {
22058
22521
  expected: verifyingKey
22059
22522
  });
22060
22523
  }
22061
- const rootSignature = await this.config.signer.signFrost({
22062
- message: rootTxSighash,
22524
+ const cpfpRootSignature = await this.config.signer.signFrost({
22525
+ message: cpfpRootTxSighash,
22063
22526
  publicKey: signingPubKey,
22064
22527
  keyDerivation,
22065
22528
  verifyingKey,
22066
- selfCommitment: rootNonceCommitment,
22529
+ selfCommitment: cpfpRootNonceCommitment,
22067
22530
  statechainCommitments: treeResp.rootNodeSignatureShares.nodeTxSigningResult.signingNonceCommitments,
22068
22531
  adaptorPubKey: new Uint8Array()
22069
22532
  });
22070
- const refundSignature = await this.config.signer.signFrost({
22071
- message: refundTxSighash,
22533
+ const cpfpRefundSignature = await this.config.signer.signFrost({
22534
+ message: cpfpRefundTxSighash,
22072
22535
  publicKey: signingPubKey,
22073
22536
  keyDerivation,
22074
- verifyingKey,
22075
- selfCommitment: refundNonceCommitment,
22537
+ verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22538
+ selfCommitment: cpfpRefundNonceCommitment,
22076
22539
  statechainCommitments: treeResp.rootNodeSignatureShares.refundTxSigningResult.signingNonceCommitments,
22077
22540
  adaptorPubKey: new Uint8Array()
22078
22541
  });
22079
- const rootAggregate = await this.config.signer.aggregateFrost({
22080
- message: rootTxSighash,
22542
+ const cpfpRootAggregate = await this.config.signer.aggregateFrost({
22543
+ message: cpfpRootTxSighash,
22081
22544
  statechainSignatures: treeResp.rootNodeSignatureShares.nodeTxSigningResult.signatureShares,
22082
22545
  statechainPublicKeys: treeResp.rootNodeSignatureShares.nodeTxSigningResult.publicKeys,
22083
22546
  verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22084
22547
  statechainCommitments: treeResp.rootNodeSignatureShares.nodeTxSigningResult.signingNonceCommitments,
22085
- selfCommitment: rootNonceCommitment,
22548
+ selfCommitment: cpfpRootNonceCommitment,
22086
22549
  publicKey: signingPubKey,
22087
- selfSignature: rootSignature,
22550
+ selfSignature: cpfpRootSignature,
22088
22551
  adaptorPubKey: new Uint8Array()
22089
22552
  });
22090
- const refundAggregate = await this.config.signer.aggregateFrost({
22091
- message: refundTxSighash,
22553
+ const cpfpRefundAggregate = await this.config.signer.aggregateFrost({
22554
+ message: cpfpRefundTxSighash,
22092
22555
  statechainSignatures: treeResp.rootNodeSignatureShares.refundTxSigningResult.signatureShares,
22093
22556
  statechainPublicKeys: treeResp.rootNodeSignatureShares.refundTxSigningResult.publicKeys,
22094
22557
  verifyingKey: treeResp.rootNodeSignatureShares.verifyingKey,
22095
22558
  statechainCommitments: treeResp.rootNodeSignatureShares.refundTxSigningResult.signingNonceCommitments,
22096
- selfCommitment: refundNonceCommitment,
22559
+ selfCommitment: cpfpRefundNonceCommitment,
22097
22560
  publicKey: signingPubKey,
22098
- selfSignature: refundSignature,
22561
+ selfSignature: cpfpRefundSignature,
22099
22562
  adaptorPubKey: new Uint8Array()
22100
22563
  });
22101
22564
  let finalizeResp;
22102
22565
  try {
22103
- finalizeResp = await sparkClient.finalize_node_signatures({
22566
+ finalizeResp = await sparkClient.finalize_node_signatures_v2({
22104
22567
  intent: 0 /* CREATION */,
22105
22568
  nodeSignatures: [
22106
22569
  {
22107
22570
  nodeId: treeResp.rootNodeSignatureShares.nodeId,
22108
- nodeTxSignature: rootAggregate,
22109
- refundTxSignature: refundAggregate
22571
+ nodeTxSignature: cpfpRootAggregate,
22572
+ refundTxSignature: cpfpRefundAggregate
22110
22573
  }
22111
22574
  ]
22112
22575
  });
@@ -22171,7 +22634,7 @@ var import_utils21 = require("@noble/curves/abstract/utils");
22171
22634
  init_buffer();
22172
22635
  var import_utils22 = require("@noble/curves/abstract/utils");
22173
22636
  var import_secp256k114 = require("@noble/curves/secp256k1");
22174
- var btc6 = __toESM(require("@scure/btc-signer"), 1);
22637
+ var btc5 = __toESM(require("@scure/btc-signer"), 1);
22175
22638
  var import_btc_signer6 = require("@scure/btc-signer");
22176
22639
  var import_utils23 = require("@scure/btc-signer/utils");
22177
22640
  var STATIC_FAUCET_KEY = (0, import_utils22.hexToBytes)(
@@ -22317,7 +22780,7 @@ var BitcoinFaucet = class _BitcoinFaucet {
22317
22780
  }
22318
22781
  async sendFaucetCoinToP2WPKHAddress(pubKey) {
22319
22782
  const sendToPubKeyTx = new import_btc_signer6.Transaction();
22320
- const p2wpkhAddress = btc6.p2wpkh(pubKey, getNetwork(4 /* LOCAL */)).address;
22783
+ const p2wpkhAddress = btc5.p2wpkh(pubKey, getNetwork(4 /* LOCAL */)).address;
22321
22784
  if (!p2wpkhAddress) {
22322
22785
  throw new Error("Invalid P2WPKH address");
22323
22786
  }
@@ -22373,12 +22836,13 @@ var BitcoinFaucet = class _BitcoinFaucet {
22373
22836
  }
22374
22837
  async call(method, params) {
22375
22838
  try {
22376
- const response = await fetch(this.url, {
22839
+ const { fetch: fetch2, Headers: Headers2 } = getFetch();
22840
+ const response = await fetch2(this.url, {
22377
22841
  method: "POST",
22378
- headers: {
22842
+ headers: new Headers2({
22379
22843
  "Content-Type": "application/json",
22380
22844
  Authorization: "Basic " + btoa(`${this.username}:${this.password}`)
22381
- },
22845
+ }),
22382
22846
  body: JSON.stringify({
22383
22847
  jsonrpc: "1.0",
22384
22848
  id: "spark-js",
@@ -22492,7 +22956,7 @@ function getTestWalletConfigWithIdentityKey(identityPrivateKey) {
22492
22956
  identityPrivateKey
22493
22957
  };
22494
22958
  }
22495
- async function createNewTree(wallet, leafId, faucet, amountSats = 100000n) {
22959
+ async function createDeposit(wallet, leafId, faucet, amountSats = 100000n, includeDirectTx = true) {
22496
22960
  const faucetCoin = await faucet.fund();
22497
22961
  const configService = new WalletConfigService(
22498
22962
  {
@@ -22523,15 +22987,28 @@ async function createNewTree(wallet, leafId, faucet, amountSats = 100000n) {
22523
22987
  );
22524
22988
  const script = import_btc_signer8.OutScript.encode(addr);
22525
22989
  depositTx.addOutput({ script, amount: amountSats });
22526
- const treeResp = await depositService.createTreeRoot({
22527
- keyDerivation: {
22528
- type: "leaf" /* LEAF */,
22529
- path: leafId
22530
- },
22531
- verifyingKey: depositResp.depositAddress.verifyingKey,
22532
- depositTx,
22533
- vout: 0
22534
- });
22990
+ let treeResp;
22991
+ if (includeDirectTx) {
22992
+ treeResp = await depositService.createTreeRoot({
22993
+ keyDerivation: {
22994
+ type: "leaf" /* LEAF */,
22995
+ path: leafId
22996
+ },
22997
+ verifyingKey: depositResp.depositAddress.verifyingKey,
22998
+ depositTx,
22999
+ vout: 0
23000
+ });
23001
+ } else {
23002
+ treeResp = await depositService.createTreeWithoutDirectTx({
23003
+ keyDerivation: {
23004
+ type: "leaf" /* LEAF */,
23005
+ path: leafId
23006
+ },
23007
+ verifyingKey: depositResp.depositAddress.verifyingKey,
23008
+ depositTx,
23009
+ vout: 0
23010
+ });
23011
+ }
22535
23012
  const signedDepositTx = await faucet.signFaucetCoin(
22536
23013
  depositTx,
22537
23014
  faucetCoin.txout,
@@ -22548,15 +23025,39 @@ async function createNewTree(wallet, leafId, faucet, amountSats = 100000n) {
22548
23025
  await new Promise((resolve) => setTimeout(resolve, 100));
22549
23026
  return treeResp.nodes[0];
22550
23027
  }
23028
+ async function createNewTree(wallet, leafId, faucet, amountSats = 100000n) {
23029
+ return await createDeposit(wallet, leafId, faucet, amountSats, true);
23030
+ }
23031
+ async function createNewTreeWithoutDirectTx(wallet, leafId, faucet, amountSats = 100000n) {
23032
+ return await createDeposit(wallet, leafId, faucet, amountSats, false);
23033
+ }
22551
23034
  var signerTypes = [
22552
- { name: "DefaultSparkSigner", Signer: DefaultSparkSigner },
22553
- { name: "UnsafeStatelessSparkSigner", Signer: UnsafeStatelessSparkSigner }
23035
+ {
23036
+ name: "DefaultSparkSigner",
23037
+ Signer: DefaultSparkSigner,
23038
+ createTree: createNewTree
23039
+ },
23040
+ {
23041
+ name: "UnsafeStatelessSparkSigner",
23042
+ Signer: UnsafeStatelessSparkSigner,
23043
+ createTree: createNewTree
23044
+ }
23045
+ ];
23046
+ var walletTypes = [
23047
+ ...signerTypes,
23048
+ {
23049
+ name: "DefaultSparkSignerWithoutDirectTx",
23050
+ Signer: UnsafeStatelessSparkSigner,
23051
+ createTree: createNewTreeWithoutDirectTx
23052
+ }
22554
23053
  ];
22555
23054
  // Annotate the CommonJS export names for ESM import in node:
22556
23055
  0 && (module.exports = {
22557
23056
  BitcoinFaucet,
22558
23057
  createNewTree,
23058
+ createNewTreeWithoutDirectTx,
22559
23059
  getTestWalletConfig,
22560
23060
  getTestWalletConfigWithIdentityKey,
22561
- signerTypes
23061
+ signerTypes,
23062
+ walletTypes
22562
23063
  });