@buildonspark/spark-sdk 0.2.2 → 0.2.4

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 +15 -0
  2. package/dist/{chunk-TM6CHQXC.js → chunk-3SEOTO43.js} +1 -1
  3. package/dist/{chunk-2ENZX6LT.js → chunk-AAZWSPUK.js} +84 -8
  4. package/dist/{chunk-4JD4HIAN.js → chunk-G4MSZ6DE.js} +299 -1
  5. package/dist/{chunk-S2AL73MZ.js → chunk-TVUMSHWA.js} +1 -1
  6. package/dist/{chunk-2TUM3R6C.js → chunk-W4ZRBSWM.js} +2351 -797
  7. package/dist/{chunk-CDLETEDT.js → chunk-WAQKYSDI.js} +13 -1
  8. package/dist/{client-CGTRS23n.d.ts → client-BF4cn8F4.d.ts} +15 -3
  9. package/dist/{client-CcYzmpmj.d.cts → client-KhNkrXz4.d.cts} +15 -3
  10. package/dist/debug.cjs +2948 -1023
  11. package/dist/debug.d.cts +19 -6
  12. package/dist/debug.d.ts +19 -6
  13. package/dist/debug.js +5 -5
  14. package/dist/graphql/objects/index.cjs +13 -1
  15. package/dist/graphql/objects/index.d.cts +2 -2
  16. package/dist/graphql/objects/index.d.ts +2 -2
  17. package/dist/graphql/objects/index.js +1 -1
  18. package/dist/index.cjs +2794 -858
  19. package/dist/index.d.cts +190 -9
  20. package/dist/index.d.ts +190 -9
  21. package/dist/index.js +32 -6
  22. package/dist/index.node.cjs +2931 -892
  23. package/dist/index.node.d.cts +10 -188
  24. package/dist/index.node.d.ts +10 -188
  25. package/dist/index.node.js +134 -6
  26. package/dist/native/index.cjs +2794 -858
  27. package/dist/native/index.d.cts +148 -40
  28. package/dist/native/index.d.ts +148 -40
  29. package/dist/native/index.js +2799 -877
  30. package/dist/proto/lrc20.d.cts +1 -1
  31. package/dist/proto/lrc20.d.ts +1 -1
  32. package/dist/proto/lrc20.js +1 -1
  33. package/dist/proto/spark.cjs +84 -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 +1 -1
  37. package/dist/proto/spark_token.cjs +301 -0
  38. package/dist/proto/spark_token.d.cts +35 -2
  39. package/dist/proto/spark_token.d.ts +35 -2
  40. package/dist/proto/spark_token.js +8 -2
  41. package/dist/{sdk-types-DJ2ve9YY.d.cts → sdk-types-CB9HrW5O.d.cts} +1 -1
  42. package/dist/{sdk-types-DCIVdKUT.d.ts → sdk-types-CkRNraXT.d.ts} +1 -1
  43. package/dist/{spark-BUOx3U7Q.d.cts → spark-B_7nZx6T.d.cts} +112 -10
  44. package/dist/{spark-BUOx3U7Q.d.ts → spark-B_7nZx6T.d.ts} +112 -10
  45. package/dist/{spark-wallet-B_96y9BS.d.ts → spark-wallet-C1Tr_VKI.d.ts} +38 -28
  46. package/dist/{spark-wallet-CHwKQYJu.d.cts → spark-wallet-DG3x2obf.d.cts} +38 -28
  47. package/dist/spark-wallet.node-CGxoeCpH.d.ts +13 -0
  48. package/dist/spark-wallet.node-CN9LoB_O.d.cts +13 -0
  49. package/dist/tests/test-utils.cjs +1086 -218
  50. package/dist/tests/test-utils.d.cts +13 -13
  51. package/dist/tests/test-utils.d.ts +13 -13
  52. package/dist/tests/test-utils.js +56 -19
  53. package/dist/types/index.cjs +97 -9
  54. package/dist/types/index.d.cts +3 -3
  55. package/dist/types/index.d.ts +3 -3
  56. package/dist/types/index.js +3 -3
  57. package/dist/{xchain-address-D5MIHCDL.d.cts → xchain-address-BHu6CpZC.d.ts} +55 -8
  58. package/dist/{xchain-address-DLbW1iDh.d.ts → xchain-address-HBr6isnc.d.cts} +55 -8
  59. package/package.json +1 -1
  60. package/src/graphql/client.ts +8 -0
  61. package/src/graphql/mutations/CompleteLeavesSwap.ts +9 -1
  62. package/src/graphql/mutations/RequestSwapLeaves.ts +4 -0
  63. package/src/graphql/objects/CompleteLeavesSwapInput.ts +34 -34
  64. package/src/graphql/objects/LeavesSwapRequest.ts +4 -0
  65. package/src/graphql/objects/RequestLeavesSwapInput.ts +48 -47
  66. package/src/graphql/objects/SwapLeaf.ts +40 -32
  67. package/src/graphql/objects/UserLeafInput.ts +24 -0
  68. package/src/graphql/objects/UserRequest.ts +4 -0
  69. package/src/index.node.ts +1 -1
  70. package/src/native/index.ts +4 -5
  71. package/src/proto/spark.ts +172 -16
  72. package/src/proto/spark_token.ts +369 -0
  73. package/src/services/coop-exit.ts +171 -36
  74. package/src/services/deposit.ts +471 -74
  75. package/src/services/lightning.ts +18 -5
  76. package/src/services/signing.ts +162 -50
  77. package/src/services/token-transactions.ts +6 -2
  78. package/src/services/transfer.ts +950 -384
  79. package/src/services/tree-creation.ts +342 -121
  80. package/src/spark-wallet/spark-wallet.node.ts +71 -66
  81. package/src/spark-wallet/spark-wallet.ts +459 -166
  82. package/src/tests/integration/coop-exit.test.ts +3 -8
  83. package/src/tests/integration/deposit.test.ts +3 -3
  84. package/src/tests/integration/lightning.test.ts +521 -466
  85. package/src/tests/integration/swap.test.ts +559 -307
  86. package/src/tests/integration/transfer.test.ts +625 -623
  87. package/src/tests/integration/wallet.test.ts +2 -2
  88. package/src/tests/integration/watchtower.test.ts +211 -0
  89. package/src/tests/test-utils.ts +63 -14
  90. package/src/tests/utils/test-faucet.ts +4 -2
  91. package/src/utils/adaptor-signature.ts +15 -5
  92. package/src/utils/fetch.ts +75 -0
  93. package/src/utils/mempool.ts +9 -4
  94. package/src/utils/transaction.ts +388 -26
@@ -694,7 +694,7 @@ interface FinalizeTokenTransactionRequest {
694
694
  sparkPaymentIntent: string;
695
695
  }
696
696
  declare const FinalizeTokenTransactionRequest: MessageFns$2<FinalizeTokenTransactionRequest>;
697
- interface FreezeTokensPayload {
697
+ interface FreezeTokensPayload$1 {
698
698
  ownerPublicKey: Uint8Array;
699
699
  tokenPublicKey: Uint8Array;
700
700
  issuerProvidedTimestamp: number;
@@ -703,19 +703,19 @@ interface FreezeTokensPayload {
703
703
  shouldUnfreeze: boolean;
704
704
  tokenIdentifier?: Uint8Array | undefined;
705
705
  }
706
- declare const FreezeTokensPayload: MessageFns$2<FreezeTokensPayload>;
707
- interface FreezeTokensRequest {
708
- freezeTokensPayload: FreezeTokensPayload | undefined;
706
+ declare const FreezeTokensPayload$1: MessageFns$2<FreezeTokensPayload$1>;
707
+ interface FreezeTokensRequest$1 {
708
+ freezeTokensPayload: FreezeTokensPayload$1 | undefined;
709
709
  /** This is a Schnorr or ECDSA DER signature which can be between 64 and 73 bytes. */
710
710
  issuerSignature: Uint8Array;
711
711
  }
712
- declare const FreezeTokensRequest: MessageFns$2<FreezeTokensRequest>;
713
- interface FreezeTokensResponse {
712
+ declare const FreezeTokensRequest$1: MessageFns$2<FreezeTokensRequest$1>;
713
+ interface FreezeTokensResponse$1 {
714
714
  impactedOutputIds: string[];
715
715
  /** Decoded uint128 */
716
716
  impactedTokenAmount: Uint8Array;
717
717
  }
718
- declare const FreezeTokensResponse: MessageFns$2<FreezeTokensResponse>;
718
+ declare const FreezeTokensResponse$1: MessageFns$2<FreezeTokensResponse$1>;
719
719
  interface QueryTokenOutputsRequest$1 {
720
720
  ownerPublicKeys: Uint8Array[];
721
721
  /** Optionally provide token public keys. If not set return leaves for all tokens. */
@@ -1486,7 +1486,6 @@ interface SparkServiceClient<CallOptionsExt = {}> {
1486
1486
  extend_leaf(request: DeepPartial$2<ExtendLeafRequest>, options?: CallOptions & CallOptionsExt): Promise<ExtendLeafResponse>;
1487
1487
  prepare_tree_address(request: DeepPartial$2<PrepareTreeAddressRequest>, options?: CallOptions & CallOptionsExt): Promise<PrepareTreeAddressResponse>;
1488
1488
  create_tree(request: DeepPartial$2<CreateTreeRequest>, options?: CallOptions & CallOptionsExt): Promise<CreateTreeResponse>;
1489
- create_tree_v2(request: DeepPartial$2<CreateTreeRequest>, options?: CallOptions & CallOptionsExt): Promise<CreateTreeResponse>;
1490
1489
  get_signing_operator_list(request: DeepPartial$2<Empty>, options?: CallOptions & CallOptionsExt): Promise<GetSigningOperatorListResponse>;
1491
1490
  query_nodes(request: DeepPartial$2<QueryNodesRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryNodesResponse>;
1492
1491
  query_nodes_distribution(request: DeepPartial$2<QueryNodesDistributionRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryNodesDistributionResponse>;
@@ -1497,7 +1496,7 @@ interface SparkServiceClient<CallOptionsExt = {}> {
1497
1496
  start_token_transaction(request: DeepPartial$2<StartTokenTransactionRequest>, options?: CallOptions & CallOptionsExt): Promise<StartTokenTransactionResponse>;
1498
1497
  sign_token_transaction(request: DeepPartial$2<SignTokenTransactionRequest>, options?: CallOptions & CallOptionsExt): Promise<SignTokenTransactionResponse>;
1499
1498
  finalize_token_transaction(request: DeepPartial$2<FinalizeTokenTransactionRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
1500
- freeze_tokens(request: DeepPartial$2<FreezeTokensRequest>, options?: CallOptions & CallOptionsExt): Promise<FreezeTokensResponse>;
1499
+ freeze_tokens(request: DeepPartial$2<FreezeTokensRequest$1>, options?: CallOptions & CallOptionsExt): Promise<FreezeTokensResponse$1>;
1501
1500
  query_token_outputs(request: DeepPartial$2<QueryTokenOutputsRequest$1>, options?: CallOptions & CallOptionsExt): Promise<QueryTokenOutputsResponse$1>;
1502
1501
  query_token_transactions(request: DeepPartial$2<QueryTokenTransactionsRequest$1>, options?: CallOptions & CallOptionsExt): Promise<QueryTokenTransactionsResponse$1>;
1503
1502
  return_lightning_payment(request: DeepPartial$2<ReturnLightningPaymentRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
@@ -1521,6 +1520,20 @@ interface SparkServiceClient<CallOptionsExt = {}> {
1521
1520
  */
1522
1521
  initiate_utxo_swap(request: DeepPartial$2<InitiateUtxoSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiateUtxoSwapResponse>;
1523
1522
  exit_single_node_trees(request: DeepPartial$2<ExitSingleNodeTreesRequest>, options?: CallOptions & CallOptionsExt): Promise<ExitSingleNodeTreesResponse>;
1523
+ /**
1524
+ * The following endpoints enforce inclusion of Direct Transactions used
1525
+ * for unilateral exits
1526
+ */
1527
+ create_tree_v2(request: DeepPartial$2<CreateTreeRequest>, options?: CallOptions & CallOptionsExt): Promise<CreateTreeResponse>;
1528
+ cooperative_exit_v2(request: DeepPartial$2<CooperativeExitRequest>, options?: CallOptions & CallOptionsExt): Promise<CooperativeExitResponse>;
1529
+ extend_leaf_v2(request: DeepPartial$2<ExtendLeafRequest>, options?: CallOptions & CallOptionsExt): Promise<ExtendLeafResponse>;
1530
+ claim_transfer_sign_refunds_v2(request: DeepPartial$2<ClaimTransferSignRefundsRequest>, options?: CallOptions & CallOptionsExt): Promise<ClaimTransferSignRefundsResponse>;
1531
+ finalize_node_signatures_v2(request: DeepPartial$2<FinalizeNodeSignaturesRequest>, options?: CallOptions & CallOptionsExt): Promise<FinalizeNodeSignaturesResponse>;
1532
+ initiate_preimage_swap_v2(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
1533
+ start_leaf_swap_v2(request: DeepPartial$2<StartTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<StartTransferResponse>;
1534
+ counter_leaf_swap_v2(request: DeepPartial$2<CounterLeafSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<CounterLeafSwapResponse>;
1535
+ start_transfer_v2(request: DeepPartial$2<StartTransferRequest>, options?: CallOptions & CallOptionsExt): Promise<StartTransferResponse>;
1536
+ refresh_timelock_v2(request: DeepPartial$2<RefreshTimelockRequest>, options?: CallOptions & CallOptionsExt): Promise<RefreshTimelockResponse>;
1524
1537
  }
1525
1538
  type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | undefined;
1526
1539
  type DeepPartial$2<T> = T extends Builtin$2 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$2<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$2<U>> : T extends {
@@ -2004,6 +2017,29 @@ interface TokenTransactionWithStatus {
2004
2017
  tokenTransactionHash: Uint8Array;
2005
2018
  }
2006
2019
  declare const TokenTransactionWithStatus: MessageFns$1<TokenTransactionWithStatus>;
2020
+ interface FreezeTokensPayload {
2021
+ version: number;
2022
+ ownerPublicKey: Uint8Array;
2023
+ tokenPublicKey?: Uint8Array | undefined;
2024
+ tokenIdentifier?: Uint8Array | undefined;
2025
+ issuerProvidedTimestamp: number;
2026
+ operatorIdentityPublicKey: Uint8Array;
2027
+ /** Set to false when requesting a freeze. */
2028
+ shouldUnfreeze: boolean;
2029
+ }
2030
+ declare const FreezeTokensPayload: MessageFns$1<FreezeTokensPayload>;
2031
+ interface FreezeTokensRequest {
2032
+ freezeTokensPayload: FreezeTokensPayload | undefined;
2033
+ /** This is a Schnorr or ECDSA DER signature which can be between 64 and 73 bytes. */
2034
+ issuerSignature: Uint8Array;
2035
+ }
2036
+ declare const FreezeTokensRequest: MessageFns$1<FreezeTokensRequest>;
2037
+ interface FreezeTokensResponse {
2038
+ impactedOutputIds: string[];
2039
+ /** Decoded uint128 */
2040
+ impactedTokenAmount: Uint8Array;
2041
+ }
2042
+ declare const FreezeTokensResponse: MessageFns$1<FreezeTokensResponse>;
2007
2043
  interface SparkTokenServiceClient<CallOptionsExt = {}> {
2008
2044
  /**
2009
2045
  * Start process to create final token transaction with all inputs required
@@ -2018,6 +2054,7 @@ interface SparkTokenServiceClient<CallOptionsExt = {}> {
2018
2054
  query_token_metadata(request: DeepPartial$1<QueryTokenMetadataRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryTokenMetadataResponse>;
2019
2055
  query_token_transactions(request: DeepPartial$1<QueryTokenTransactionsRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryTokenTransactionsResponse>;
2020
2056
  query_token_outputs(request: DeepPartial$1<QueryTokenOutputsRequest>, options?: CallOptions & CallOptionsExt): Promise<QueryTokenOutputsResponse>;
2057
+ freeze_tokens(request: DeepPartial$1<FreezeTokensRequest>, options?: CallOptions & CallOptionsExt): Promise<FreezeTokensResponse>;
2021
2058
  }
2022
2059
  type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
2023
2060
  type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {
@@ -2304,6 +2341,8 @@ interface CompleteCoopExitInput {
2304
2341
 
2305
2342
  interface CompleteLeavesSwapInput {
2306
2343
  adaptorSecretKey: string;
2344
+ directAdaptorSecretKey: string;
2345
+ directFromCpfpAdaptorSecretKey: string;
2307
2346
  userOutboundTransferExternalId: string;
2308
2347
  leavesSwapRequestId: string;
2309
2348
  }
@@ -2399,6 +2438,10 @@ interface SwapLeaf {
2399
2438
  leafId: string;
2400
2439
  rawUnsignedRefundTransaction: string;
2401
2440
  adaptorSignedSignature: string;
2441
+ directRawUnsignedRefundTransaction?: string;
2442
+ directAdaptorSignedSignature?: string;
2443
+ directFromCpfpRawUnsignedRefundTransaction?: string;
2444
+ directFromCpfpAdaptorSignedSignature?: string;
2402
2445
  }
2403
2446
 
2404
2447
  interface LeavesSwapRequest {
@@ -2546,11 +2589,17 @@ interface RequestCoopExitInput {
2546
2589
  interface UserLeafInput {
2547
2590
  leaf_id: string;
2548
2591
  raw_unsigned_refund_transaction: string;
2592
+ direct_raw_unsigned_refund_transaction: string;
2593
+ direct_from_cpfp_raw_unsigned_refund_transaction: string;
2549
2594
  adaptor_added_signature: string;
2595
+ direct_adaptor_added_signature: string;
2596
+ direct_from_cpfp_adaptor_added_signature: string;
2550
2597
  }
2551
2598
 
2552
2599
  interface RequestLeavesSwapInput {
2553
2600
  adaptorPubkey: string;
2601
+ directAdaptorPubkey?: string;
2602
+ directFromCpfpAdaptorPubkey?: string;
2554
2603
  totalAmountSats: number;
2555
2604
  targetAmountSats: number;
2556
2605
  feeSats: number;
@@ -2657,8 +2706,8 @@ declare class SspClient {
2657
2706
  requestCoopExit({ leafExternalIds, withdrawalAddress, idempotencyKey, exitSpeed, feeLeafExternalIds, feeQuoteId, withdrawAll, }: RequestCoopExitInput): Promise<CoopExitRequest | null>;
2658
2707
  requestLightningReceive({ amountSats, network, paymentHash, expirySecs, memo, includeSparkAddress, receiverIdentityPubkey, descriptionHash, }: RequestLightningReceiveInput): Promise<LightningReceiveRequest | null>;
2659
2708
  requestLightningSend({ encodedInvoice, idempotencyKey, amountSats, }: RequestLightningSendInput): Promise<LightningSendRequest | null>;
2660
- requestLeaveSwap({ adaptorPubkey, totalAmountSats, targetAmountSats, feeSats, userLeaves, idempotencyKey, targetAmountSatsList, }: RequestLeavesSwapInput): Promise<LeavesSwapRequest | null>;
2661
- completeLeaveSwap({ adaptorSecretKey, userOutboundTransferExternalId, leavesSwapRequestId, }: CompleteLeavesSwapInput): Promise<LeavesSwapRequest | null>;
2709
+ requestLeaveSwap({ adaptorPubkey, directAdaptorPubkey, directFromCpfpAdaptorPubkey, totalAmountSats, targetAmountSats, feeSats, userLeaves, idempotencyKey, targetAmountSatsList, }: RequestLeavesSwapInput): Promise<LeavesSwapRequest | null>;
2710
+ completeLeaveSwap({ adaptorSecretKey, directAdaptorSecretKey, directFromCpfpAdaptorSecretKey, userOutboundTransferExternalId, leavesSwapRequestId, }: CompleteLeavesSwapInput): Promise<LeavesSwapRequest | null>;
2662
2711
  getLightningReceiveRequest(id: string): Promise<LightningReceiveRequest | null>;
2663
2712
  getLightningSendRequest(id: string): Promise<LightningSendRequest | null>;
2664
2713
  getLeaveSwapRequest(id: string): Promise<LeavesSwapRequest | null>;
@@ -2807,19 +2856,66 @@ declare function filterTokenBalanceForTokenPublicKey(tokenBalances: TokenBalance
2807
2856
 
2808
2857
  declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
2809
2858
 
2859
+ declare const DIRECT_TIMELOCK_OFFSET = 50;
2860
+ declare const INITIAL_SEQUENCE: number;
2861
+ declare const INITIAL_DIRECT_SEQUENCE: number;
2862
+ declare const TEST_UNILATERAL_SEQUENCE: number;
2863
+ declare const TEST_UNILATERAL_DIRECT_SEQUENCE: number;
2810
2864
  declare const DEFAULT_FEE_SATS: number;
2811
2865
  /**
2812
2866
  * Subtracts the default fee from the amount if it's greater than the fee.
2813
2867
  * Returns the original amount if it's less than or equal to the fee.
2814
2868
  */
2815
2869
  declare function maybeApplyFee(amount: bigint): bigint;
2816
- declare function createRefundTx(sequence: number, nodeOutPoint: TransactionInput, amountSats: bigint, receivingPubkey: Uint8Array, network: Network): Transaction;
2870
+ declare function createRootTx(depositOutPoint: TransactionInput, depositTxOut: TransactionOutput): [Transaction, Transaction];
2871
+ declare function createSplitTx(parentOutPoint: TransactionInput, childTxOuts: TransactionOutput[]): [Transaction, Transaction];
2872
+ interface CreateNodeTxInput {
2873
+ txOut: TransactionOutput;
2874
+ parentOutPoint: TransactionInput;
2875
+ applyFee?: boolean;
2876
+ includeAnchor?: boolean;
2877
+ }
2878
+ declare function createNodeTx({ txOut, parentOutPoint, applyFee, includeAnchor, }: CreateNodeTxInput): Transaction;
2879
+ declare function createNodeTxs(txOut: TransactionOutput, txIn: TransactionInput, directTxIn?: TransactionInput): {
2880
+ cpfpNodeTx: Transaction;
2881
+ directNodeTx?: Transaction;
2882
+ };
2883
+ declare function createLeafNodeTx(sequence: number, directSequence: number, parentOutPoint: TransactionInput, txOut: TransactionOutput, shouldCalculateFee: boolean): [Transaction, Transaction];
2884
+ interface CreateRefundTxInput {
2885
+ sequence: number;
2886
+ input: TransactionInput;
2887
+ amountSats: bigint;
2888
+ receivingPubkey: Uint8Array;
2889
+ network: Network;
2890
+ shouldCalculateFee: boolean;
2891
+ includeAnchor: boolean;
2892
+ }
2893
+ declare function createRefundTx({ sequence, input, amountSats, receivingPubkey, network, shouldCalculateFee, includeAnchor, }: CreateRefundTxInput): Transaction;
2894
+ interface CreateRefundTxsInput {
2895
+ sequence: number;
2896
+ directSequence?: number;
2897
+ input: TransactionInput;
2898
+ directInput?: TransactionInput;
2899
+ amountSats: bigint;
2900
+ receivingPubkey: Uint8Array;
2901
+ network: Network;
2902
+ }
2903
+ declare function createRefundTxs({ sequence, directSequence, input, directInput, amountSats, receivingPubkey, network, }: CreateRefundTxsInput): {
2904
+ cpfpRefundTx: Transaction;
2905
+ directRefundTx?: Transaction;
2906
+ directFromCpfpRefundTx?: Transaction;
2907
+ };
2908
+ declare function createConnectorRefundTransactions(sequence: number, cpfpNodeOutPoint: TransactionInput, directNodeOutPoint: TransactionInput, connectorOutput: TransactionInput, amountSats: bigint, receiverPubKey: Uint8Array, network: Network, shouldCalculateFee: boolean): [Transaction, Transaction, Transaction];
2817
2909
  declare function getCurrentTimelock(currSequence?: number): number;
2818
- declare function getTransactionSequence(currSequence?: number): number;
2910
+ declare function getTransactionSequence(currSequence?: number): {
2911
+ nextSequence: number;
2912
+ nextDirectSequence: number;
2913
+ };
2819
2914
  declare function checkIfValidSequence(currSequence?: number): void;
2820
- declare function getNextTransactionSequence(currSequence?: number, forRefresh?: boolean): {
2915
+ declare function doesLeafNeedRefresh(currSequence: number, isNodeTx?: boolean): boolean;
2916
+ declare function getNextTransactionSequence(currSequence: number, isNodeTx?: boolean): {
2821
2917
  nextSequence: number;
2822
- needRefresh: boolean;
2918
+ nextDirectSequence: number;
2823
2919
  };
2824
2920
  declare function getEphemeralAnchorOutput(): TransactionOutput;
2825
2921
 
@@ -2990,7 +3086,12 @@ declare class ConnectionManager {
2990
3086
  declare class SigningService {
2991
3087
  private readonly config;
2992
3088
  constructor(config: WalletConfigService);
2993
- signRefunds(leaves: LeafKeyTweak[], signingCommitments: RequestedSigningCommitments[], receiverIdentityPubkey: Uint8Array): Promise<UserSignedTxSigningJob[]>;
3089
+ private signRefundsInternal;
3090
+ signRefunds(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, cpfpSigningCommitments: RequestedSigningCommitments[], directSigningCommitments: RequestedSigningCommitments[], directFromCpfpSigningCommitments: RequestedSigningCommitments[]): Promise<{
3091
+ cpfpLeafSigningJobs: UserSignedTxSigningJob[];
3092
+ directLeafSigningJobs: UserSignedTxSigningJob[];
3093
+ directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
3094
+ }>;
2994
3095
  }
2995
3096
 
2996
3097
  type LeafKeyTweak = {
@@ -2998,19 +3099,17 @@ type LeafKeyTweak = {
2998
3099
  keyDerivation: KeyDerivation;
2999
3100
  newKeyDerivation: KeyDerivation;
3000
3101
  };
3001
- type ClaimLeafData = {
3002
- keyDerivation: KeyDerivation;
3003
- tx?: Transaction;
3004
- refundTx?: Transaction;
3005
- signingNonceCommitment: SigningCommitmentWithOptionalNonce;
3006
- vout?: number;
3007
- };
3008
3102
  type LeafRefundSigningData = {
3009
3103
  keyDerivation: KeyDerivation;
3010
3104
  receivingPubkey: Uint8Array;
3105
+ signingNonceCommitment: SigningCommitmentWithOptionalNonce;
3106
+ directSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
3011
3107
  tx: Transaction;
3108
+ directTx?: Transaction;
3012
3109
  refundTx?: Transaction;
3013
- signingNonceCommitment: SigningCommitmentWithOptionalNonce;
3110
+ directRefundTx?: Transaction;
3111
+ directFromCpfpRefundTx?: Transaction;
3112
+ directFromCpfpRefundSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
3014
3113
  vout: number;
3015
3114
  };
3016
3115
  declare class BaseTransferService {
@@ -3018,12 +3117,12 @@ declare class BaseTransferService {
3018
3117
  protected readonly connectionManager: ConnectionManager;
3019
3118
  protected readonly signingService: SigningService;
3020
3119
  constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
3021
- sendTransferTweakKey(transfer: Transfer$1, leaves: LeafKeyTweak[], refundSignatureMap: Map<string, Uint8Array>): Promise<Transfer$1>;
3022
- deliverTransferPackage(transfer: Transfer$1, leaves: LeafKeyTweak[], refundSignatureMap: Map<string, Uint8Array>): Promise<Transfer$1>;
3120
+ sendTransferTweakKey(transfer: Transfer$1, leaves: LeafKeyTweak[], cpfpRefundSignatureMap: Map<string, Uint8Array>, directRefundSignatureMap: Map<string, Uint8Array>, directFromCpfpRefundSignatureMap: Map<string, Uint8Array>): Promise<Transfer$1>;
3121
+ deliverTransferPackage(transfer: Transfer$1, leaves: LeafKeyTweak[], cpfpRefundSignatureMap: Map<string, Uint8Array>, directRefundSignatureMap: Map<string, Uint8Array>, directFromCpfpRefundSignatureMap: Map<string, Uint8Array>): Promise<Transfer$1>;
3023
3122
  sendTransferWithKeyTweaks(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array): Promise<Transfer$1>;
3024
3123
  private prepareTransferPackage;
3025
3124
  private finalizeTransfer;
3026
- signRefunds(leafDataMap: Map<string, ClaimLeafData>, operatorSigningResults: LeafRefundTxSigningResult[], adaptorPubKey?: Uint8Array): Promise<NodeSignatures[]>;
3125
+ signRefunds(leafDataMap: Map<string, LeafRefundSigningData>, operatorSigningResults: LeafRefundTxSigningResult[], cpfpAdaptorPubKey?: Uint8Array, directAdaptorPubKey?: Uint8Array, directFromCpfpAdaptorPubKey?: Uint8Array): Promise<NodeSignatures[]>;
3027
3126
  private prepareSendTransferKeyTweaks;
3028
3127
  private prepareSingleSendTransferKeyTweak;
3029
3128
  protected findShare(shares: VerifiableSecretShare[], operatorID: number): VerifiableSecretShare | undefined;
@@ -3044,22 +3143,30 @@ declare class TransferService extends BaseTransferService {
3044
3143
  sendTransferSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
3045
3144
  transfer: Transfer$1;
3046
3145
  signatureMap: Map<string, Uint8Array>;
3146
+ directSignatureMap: Map<string, Uint8Array>;
3147
+ directFromCpfpSignatureMap: Map<string, Uint8Array>;
3047
3148
  leafDataMap: Map<string, LeafRefundSigningData>;
3048
3149
  }>;
3049
3150
  startSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date): Promise<{
3050
3151
  transfer: Transfer$1;
3051
3152
  signatureMap: Map<string, Uint8Array>;
3153
+ directSignatureMap: Map<string, Uint8Array>;
3154
+ directFromCpfpSignatureMap: Map<string, Uint8Array>;
3052
3155
  leafDataMap: Map<string, LeafRefundSigningData>;
3053
3156
  }>;
3054
- counterSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, adaptorPubKey?: Uint8Array): Promise<{
3157
+ counterSwapSignRefund(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, cpfpAdaptorPubKey?: Uint8Array, directAdaptorPubKey?: Uint8Array, directFromCpfpAdaptorPubKey?: Uint8Array): Promise<{
3055
3158
  transfer: Transfer$1;
3056
3159
  signatureMap: Map<string, Uint8Array>;
3160
+ directSignatureMap: Map<string, Uint8Array>;
3161
+ directFromCpfpSignatureMap: Map<string, Uint8Array>;
3057
3162
  leafDataMap: Map<string, LeafRefundSigningData>;
3058
3163
  signingResults: LeafRefundTxSigningResult[];
3059
3164
  }>;
3060
- sendTransferSignRefundInternal(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, forSwap: boolean, adaptorPubKey?: Uint8Array): Promise<{
3165
+ sendTransferSignRefundInternal(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, expiryTime: Date, forSwap: boolean, cpfpAdaptorPubKey?: Uint8Array, directAdaptorPubKey?: Uint8Array, directFromCpfpAdaptorPubKey?: Uint8Array): Promise<{
3061
3166
  transfer: Transfer$1;
3062
3167
  signatureMap: Map<string, Uint8Array>;
3168
+ directSignatureMap: Map<string, Uint8Array>;
3169
+ directFromCpfpSignatureMap: Map<string, Uint8Array>;
3063
3170
  leafDataMap: Map<string, LeafRefundSigningData>;
3064
3171
  signingResults: LeafRefundTxSigningResult[];
3065
3172
  }>;
@@ -3071,9 +3178,11 @@ declare class TransferService extends BaseTransferService {
3071
3178
  private finalizeNodeSignatures;
3072
3179
  cancelTransfer(transfer: Transfer$1, operatorAddress: string): Promise<Transfer$1 | undefined>;
3073
3180
  queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
3074
- refreshTimelockNodes(nodes: TreeNode[], parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3181
+ private refreshTimelockNodesInternal;
3182
+ refreshTimelockNodes(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3075
3183
  extendTimelock(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3076
- refreshTimelockRefundTx(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3184
+ testonly_expireTimeLockNodeTx(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3185
+ testonly_expireTimeLockRefundtx(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3077
3186
  }
3078
3187
 
3079
3188
  interface WalletLeaf {
@@ -3154,6 +3263,8 @@ declare class SparkWallet extends EventEmitter {
3154
3263
  private handleStreamEvent;
3155
3264
  protected setupBackgroundStream(): Promise<void>;
3156
3265
  getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
3266
+ private checkExtendLeaves;
3267
+ private verifyKey;
3157
3268
  private selectLeaves;
3158
3269
  private selectLeavesForSwap;
3159
3270
  private areLeavesInefficient;
@@ -3560,12 +3671,14 @@ declare class SparkWallet extends EventEmitter {
3560
3671
  * @param outputIds - Optional array of output IDs to filter by
3561
3672
  * @returns Promise resolving to array of token transactions with their current status
3562
3673
  */
3563
- queryTokenTransactions({ ownerPublicKeys, issuerPublicKeys, tokenTransactionHashes, tokenIdentifiers, outputIds, }: {
3674
+ queryTokenTransactions({ ownerPublicKeys, issuerPublicKeys, tokenTransactionHashes, tokenIdentifiers, outputIds, pageSize, offset, }: {
3564
3675
  ownerPublicKeys?: string[];
3565
3676
  issuerPublicKeys?: string[];
3566
3677
  tokenTransactionHashes?: string[];
3567
3678
  tokenIdentifiers?: string[];
3568
3679
  outputIds?: string[];
3680
+ pageSize?: number;
3681
+ offset?: number;
3569
3682
  }): Promise<TokenTransactionWithStatus[]>;
3570
3683
  getTokenL1Address(): Promise<string>;
3571
3684
  /**
@@ -3634,13 +3747,6 @@ declare class SparkWallet extends EventEmitter {
3634
3747
  * @returns {Promise<void>} Promise that resolves when the timelock is refreshed
3635
3748
  */
3636
3749
  testOnly_expireTimelock(nodeId: string): Promise<void>;
3637
- /**
3638
- * Refresh the timelock of a specific node's refund transaction only.
3639
- *
3640
- * @param {string} nodeId - The ID of the node whose refund transaction to refresh
3641
- * @returns {Promise<void>} Promise that resolves when the refund timelock is refreshed
3642
- */
3643
- testOnly_expireTimelockRefundTx(nodeId: string): Promise<void>;
3644
3750
  private cleanup;
3645
3751
  cleanupConnections(): Promise<void>;
3646
3752
  private startPeriodicClaimTransfers;
@@ -3659,6 +3765,8 @@ interface QueryTokenTransactionsParams {
3659
3765
  tokenTransactionHashes?: string[];
3660
3766
  tokenIdentifiers?: string[];
3661
3767
  outputIds?: string[];
3768
+ pageSize: number;
3769
+ offset: number;
3662
3770
  }
3663
3771
  declare class TokenTransactionService {
3664
3772
  protected readonly config: WalletConfigService;
@@ -3700,4 +3808,4 @@ declare class TokenTransactionService {
3700
3808
  private createSignaturesForOperators;
3701
3809
  }
3702
3810
 
3703
- export { AuthenticationError, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, type ConfigOptions, ConfigurationError, ConnectionManager, type CreateLightningInvoiceParams, DEFAULT_FEE_SATS, type DecodedSparkAddressData, ReactNativeSparkSigner as DefaultSparkSigner, type DepositParams, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, type InitWalletResponse, InternalValidationError, LRC_WALLET_NETWORK, LRC_WALLET_NETWORK_TYPE, type LeafInfo, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, type PayLightningInvoiceParams, RPCError, type RawTokenIdentifierHex, ReactNativeSparkSigner, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkWallet, type SparkWalletEvents, type SparkWalletProps, type TokenBalanceMap, type TokenMetadataMap, type TokenOutputsMap, TokenTransactionService, type TransferParams, type TxChain, type UserTokenMetadata, type Utxo, ValidationError, type VerifiableSecretShare, WalletConfig, WalletConfigService, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createRefundTx, createSigningCommitment, createSigningNonce, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, encodeBech32mTokenIdentifier, encodeSigningCommitmentToBytes, encodeSigningNonceToBytes, encodeSparkAddress, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenPublicKey, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromString, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, isEphemeralAnchorOutput, isTxBroadcast, isValidPublicKey, isValidSparkAddress, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, validateOutboundAdaptorSignature, validateShare };
3811
+ export { AuthenticationError, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, type ConfigOptions, ConfigurationError, ConnectionManager, type CreateLightningInvoiceParams, DEFAULT_FEE_SATS, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, ReactNativeSparkSigner as DefaultSparkSigner, type DepositParams, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, INITIAL_DIRECT_SEQUENCE, INITIAL_SEQUENCE, type InitWalletResponse, InternalValidationError, LRC_WALLET_NETWORK, LRC_WALLET_NETWORK_TYPE, type LeafInfo, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, type PayLightningInvoiceParams, RPCError, type RawTokenIdentifierHex, ReactNativeSparkSigner, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkWallet, type SparkWalletEvents, type SparkWalletProps, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, type TokenBalanceMap, type TokenMetadataMap, type TokenOutputsMap, TokenTransactionService, type TransferParams, type TxChain, type UserTokenMetadata, type Utxo, ValidationError, type VerifiableSecretShare, WalletConfig, WalletConfigService, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createConnectorRefundTransactions, createLeafNodeTx, createNodeTx, createNodeTxs, createRefundTx, createRefundTxs, createRootTx, createSigningCommitment, createSigningNonce, createSplitTx, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, doesLeafNeedRefresh, encodeBech32mTokenIdentifier, encodeSigningCommitmentToBytes, encodeSigningNonceToBytes, encodeSparkAddress, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenPublicKey, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromString, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, isEphemeralAnchorOutput, isTxBroadcast, isValidPublicKey, isValidSparkAddress, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, validateOutboundAdaptorSignature, validateShare };