@buildonspark/spark-sdk 0.3.8 → 0.4.0

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 +18 -0
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/uniffi/uniffi/spark_frost/spark_frost.kt +1361 -1367
  4. package/android/src/main/jniLibs/arm64-v8a/libuniffi_spark_frost.so +0 -0
  5. package/android/src/main/jniLibs/armeabi-v7a/libuniffi_spark_frost.so +0 -0
  6. package/android/src/main/jniLibs/x86/libuniffi_spark_frost.so +0 -0
  7. package/android/src/main/jniLibs/x86_64/libuniffi_spark_frost.so +0 -0
  8. package/dist/bare/index.cjs +1342 -1346
  9. package/dist/bare/index.d.cts +114 -68
  10. package/dist/bare/index.d.ts +114 -68
  11. package/dist/bare/index.js +1266 -1279
  12. package/dist/{chunk-FXIESWE6.js → chunk-27ILUWDJ.js} +1 -1
  13. package/dist/{chunk-5ASXVNTM.js → chunk-4YFT7DAE.js} +1 -1
  14. package/dist/{chunk-FP2CRVQH.js → chunk-G3LHXHF3.js} +1045 -1308
  15. package/dist/{chunk-XI6FCNYG.js → chunk-JLF6WJ7K.js} +1 -1
  16. package/dist/{chunk-3LPEQGVJ.js → chunk-LOXWCMZL.js} +1 -1
  17. package/dist/{chunk-5HU5W56H.js → chunk-WICAF6BS.js} +2 -2
  18. package/dist/{chunk-VFN34EOX.js → chunk-YEBEN7XD.js} +258 -0
  19. package/dist/{client-pNpGP15j.d.cts → client-BIqiUNy4.d.cts} +1 -1
  20. package/dist/{client-By-N7oJS.d.ts → client-BaQf-5gD.d.ts} +1 -1
  21. package/dist/debug.cjs +1330 -1336
  22. package/dist/debug.d.cts +20 -16
  23. package/dist/debug.d.ts +20 -16
  24. package/dist/debug.js +5 -5
  25. package/dist/graphql/objects/index.d.cts +3 -3
  26. package/dist/graphql/objects/index.d.ts +3 -3
  27. package/dist/index.cjs +1363 -1365
  28. package/dist/index.d.cts +7 -7
  29. package/dist/index.d.ts +7 -7
  30. package/dist/index.js +32 -24
  31. package/dist/index.node.cjs +1363 -1365
  32. package/dist/index.node.d.cts +7 -7
  33. package/dist/index.node.d.ts +7 -7
  34. package/dist/index.node.js +31 -23
  35. package/dist/{logging-DMFVY384.d.ts → logging-BNGm6dBp.d.ts} +42 -37
  36. package/dist/{logging-DxLp34Xm.d.cts → logging-D3IfXfHG.d.cts} +42 -37
  37. package/dist/native/index.react-native.cjs +1505 -1366
  38. package/dist/native/index.react-native.d.cts +112 -58
  39. package/dist/native/index.react-native.d.ts +112 -58
  40. package/dist/native/index.react-native.js +1415 -1289
  41. package/dist/proto/spark.cjs +258 -0
  42. package/dist/proto/spark.d.cts +1 -1
  43. package/dist/proto/spark.d.ts +1 -1
  44. package/dist/proto/spark.js +5 -1
  45. package/dist/proto/spark_token.d.cts +1 -1
  46. package/dist/proto/spark_token.d.ts +1 -1
  47. package/dist/proto/spark_token.js +2 -2
  48. package/dist/{spark-By6yHsrk.d.cts → spark-DOpheE8_.d.cts} +39 -2
  49. package/dist/{spark-By6yHsrk.d.ts → spark-DOpheE8_.d.ts} +39 -2
  50. package/dist/{spark-wallet.browser-C1dQknVj.d.ts → spark-wallet.browser-B2rGwjuM.d.ts} +2 -2
  51. package/dist/{spark-wallet.browser-CNMo3IvO.d.cts → spark-wallet.browser-Ck9No4Ks.d.cts} +2 -2
  52. package/dist/{spark-wallet.node-Og6__NMh.d.ts → spark-wallet.node-BqmKsGPs.d.ts} +2 -2
  53. package/dist/{spark-wallet.node-BZJhJZKq.d.cts → spark-wallet.node-C2TIkyt4.d.cts} +2 -2
  54. package/dist/tests/test-utils.cjs +1304 -1236
  55. package/dist/tests/test-utils.d.cts +18 -4
  56. package/dist/tests/test-utils.d.ts +18 -4
  57. package/dist/tests/test-utils.js +7 -7
  58. package/dist/{token-transactions-CLR3rnYi.d.cts → token-transactions-Db8mkjnU.d.cts} +2 -2
  59. package/dist/{token-transactions-C7yefB2S.d.ts → token-transactions-DoMcrxXQ.d.ts} +2 -2
  60. package/dist/types/index.cjs +256 -0
  61. package/dist/types/index.d.cts +2 -2
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/index.js +2 -2
  64. package/dist/{wallet-config-BoyMVa6n.d.ts → wallet-config-Bg3kWltL.d.ts} +42 -35
  65. package/dist/{wallet-config-xom-9UFF.d.cts → wallet-config-CuZKNo9S.d.cts} +42 -35
  66. package/ios/spark_frostFFI.xcframework/ios-arm64/SparkFrost +0 -0
  67. package/ios/spark_frostFFI.xcframework/ios-arm64/spark_frostFFI.framework/spark_frostFFI +0 -0
  68. package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/SparkFrost +0 -0
  69. package/ios/spark_frostFFI.xcframework/ios-arm64_x86_64-simulator/spark_frostFFI.framework/spark_frostFFI +0 -0
  70. package/ios/spark_frostFFI.xcframework/macos-arm64_x86_64/spark_frostFFI.framework/spark_frostFFI +0 -0
  71. package/package.json +1 -1
  72. package/src/index.react-native.ts +8 -2
  73. package/src/proto/spark.ts +348 -4
  74. package/src/services/config.ts +5 -0
  75. package/src/services/coop-exit.ts +26 -107
  76. package/src/services/deposit.ts +12 -48
  77. package/src/services/signing.ts +62 -49
  78. package/src/services/transfer.ts +437 -722
  79. package/src/services/wallet-config.ts +10 -0
  80. package/src/services/xhr-transport.ts +13 -3
  81. package/src/signer/signer.react-native.ts +73 -1
  82. package/src/spark-wallet/proto-descriptors.ts +1 -1
  83. package/src/spark-wallet/spark-wallet.ts +162 -315
  84. package/src/spark-wallet/types.ts +2 -2
  85. package/src/spark_descriptors.pb +0 -0
  86. package/src/tests/integration/lightning.test.ts +1 -27
  87. package/src/tests/integration/static_deposit.test.ts +6 -9
  88. package/src/tests/integration/unilateral-exit.test.ts +117 -0
  89. package/src/tests/optimize.test.ts +31 -1
  90. package/src/tests/utils/signing.ts +33 -0
  91. package/src/tests/utils/test-faucet.ts +61 -0
  92. package/src/utils/optimize.ts +42 -0
  93. package/src/utils/transaction.ts +250 -249
  94. package/src/utils/unilateral-exit.ts +1 -40
@@ -8,10 +8,10 @@ import * as _scure_base from '@scure/base';
8
8
  import { Channel } from 'nice-grpc';
9
9
  import { Channel as Channel$1, createChannel } from 'nice-grpc-web';
10
10
  import { RetryOptions as RetryOptions$1 } from 'nice-grpc-client-middleware-retry';
11
+ import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
11
12
  import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
12
13
  import { EventEmitter } from 'eventemitter3';
13
14
  import * as nice_grpc_web_lib_client_Transport_js from 'nice-grpc-web/lib/client/Transport.js';
14
- import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
15
15
 
16
16
  declare class SparkSDKError extends Error {
17
17
  readonly context: Record<string, unknown>;
@@ -1088,6 +1088,17 @@ interface RenewLeafRequest {
1088
1088
  {
1089
1089
  $case: "renewRefundTimelockSigningJob";
1090
1090
  renewRefundTimelockSigningJob: RenewRefundTimelockSigningJob;
1091
+ } | //
1092
+ /**
1093
+ * A special case of refresh for when the node transaction is at 0 and
1094
+ * cannot be decremented further. This operation resets the refund
1095
+ * transaction's timelock and, similar to renew node, adds an additional
1096
+ * node transaction to the transaction chain with zero timelock as well.
1097
+ * This case is mostly used for user-created trees from L1 deposits.
1098
+ */
1099
+ {
1100
+ $case: "renewNodeZeroTimelockSigningJob";
1101
+ renewNodeZeroTimelockSigningJob: RenewNodeZeroTimelockSigningJob;
1091
1102
  } | undefined;
1092
1103
  }
1093
1104
  declare const RenewLeafRequest: MessageFns$2<RenewLeafRequest>;
@@ -1126,6 +1137,22 @@ interface RenewRefundTimelockSigningJob {
1126
1137
  directFromCpfpRefundTxSigningJob: UserSignedTxSigningJob | undefined;
1127
1138
  }
1128
1139
  declare const RenewRefundTimelockSigningJob: MessageFns$2<RenewRefundTimelockSigningJob>;
1140
+ interface RenewNodeZeroTimelockSigningJob {
1141
+ /**
1142
+ * Signing job with the new node transaction. The updated transaction is
1143
+ * expected to have a timelock of 0.
1144
+ */
1145
+ nodeTxSigningJob: UserSignedTxSigningJob | undefined;
1146
+ /**
1147
+ * Signing job with the updated refund transaction. This updated transaction
1148
+ * must have a timelock of 2000.
1149
+ */
1150
+ refundTxSigningJob: UserSignedTxSigningJob | undefined;
1151
+ directNodeTxSigningJob: UserSignedTxSigningJob | undefined;
1152
+ directRefundTxSigningJob: UserSignedTxSigningJob | undefined;
1153
+ directFromCpfpRefundTxSigningJob: UserSignedTxSigningJob | undefined;
1154
+ }
1155
+ declare const RenewNodeZeroTimelockSigningJob: MessageFns$2<RenewNodeZeroTimelockSigningJob>;
1129
1156
  interface RenewLeafResponse {
1130
1157
  renewResult?: {
1131
1158
  $case: "renewNodeTimelockResult";
@@ -1133,6 +1160,9 @@ interface RenewLeafResponse {
1133
1160
  } | {
1134
1161
  $case: "renewRefundTimelockResult";
1135
1162
  renewRefundTimelockResult: RenewRefundTimelockResult;
1163
+ } | {
1164
+ $case: "renewNodeZeroTimelockResult";
1165
+ renewNodeZeroTimelockResult: RenewNodeZeroTimelockResult;
1136
1166
  } | undefined;
1137
1167
  }
1138
1168
  declare const RenewLeafResponse: MessageFns$2<RenewLeafResponse>;
@@ -1145,6 +1175,11 @@ interface RenewRefundTimelockResult {
1145
1175
  node: TreeNode | undefined;
1146
1176
  }
1147
1177
  declare const RenewRefundTimelockResult: MessageFns$2<RenewRefundTimelockResult>;
1178
+ interface RenewNodeZeroTimelockResult {
1179
+ splitNode: TreeNode | undefined;
1180
+ node: TreeNode | undefined;
1181
+ }
1182
+ declare const RenewNodeZeroTimelockResult: MessageFns$2<RenewNodeZeroTimelockResult>;
1148
1183
  /**
1149
1184
  * NodeSignatureShares is the signature shares for a node on the tree.
1150
1185
  * For each tree node, the verifying key stays the same for both transactions.
@@ -3491,15 +3526,6 @@ declare function getNetworkFromAddress(address: string): BitcoinNetwork.MAINNET
3491
3526
  */
3492
3527
  declare function getNetworkFromString(network?: string): Network;
3493
3528
 
3494
- type Bech32mTokenIdentifier = `btkn1${string}` | `btknrt1${string}` | `btknt1${string}` | `btkns1${string}` | `btknl1${string}`;
3495
- interface Bech32mTokenIdentifierData {
3496
- tokenIdentifier: Uint8Array;
3497
- network: NetworkType;
3498
- }
3499
- declare function encodeBech32mTokenIdentifier(payload: Bech32mTokenIdentifierData): Bech32mTokenIdentifier;
3500
- declare function decodeBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier, network?: NetworkType): Bech32mTokenIdentifierData;
3501
- declare function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier): NetworkType;
3502
-
3503
3529
  declare const AddressNetwork: Record<NetworkType, string>;
3504
3530
  declare const LegacyAddressNetwork: Record<NetworkType, string>;
3505
3531
  type Bech32String = `${string}1${string}`;
@@ -3547,6 +3573,15 @@ declare function assertBech32(s: string): asserts s is Bech32String;
3547
3573
  declare function bech32mDecode(address: string): _scure_base.Bech32Decoded<string>;
3548
3574
  declare function isSafeForNumber(bi: bigint): boolean;
3549
3575
 
3576
+ type Bech32mTokenIdentifier = `btkn1${string}` | `btknrt1${string}` | `btknt1${string}` | `btkns1${string}` | `btknl1${string}`;
3577
+ interface Bech32mTokenIdentifierData {
3578
+ tokenIdentifier: Uint8Array;
3579
+ network: NetworkType;
3580
+ }
3581
+ declare function encodeBech32mTokenIdentifier(payload: Bech32mTokenIdentifierData): Bech32mTokenIdentifier;
3582
+ declare function decodeBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier, network?: NetworkType): Bech32mTokenIdentifierData;
3583
+ declare function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier): NetworkType;
3584
+
3550
3585
  type CreateLightningInvoiceParams = {
3551
3586
  amountSats: number;
3552
3587
  memo?: string;
@@ -3668,6 +3703,10 @@ type SigningOperator = {
3668
3703
  type ConsoleOptions = {
3669
3704
  otel?: boolean;
3670
3705
  };
3706
+ type OptimizationOptions = {
3707
+ readonly auto?: boolean;
3708
+ readonly multiplicity?: number;
3709
+ };
3671
3710
  type ConfigOptions = MayHaveSspClientOptions & {
3672
3711
  readonly network?: NetworkType;
3673
3712
  readonly signingOperators?: Readonly<Record<string, SigningOperator>>;
@@ -3683,6 +3722,7 @@ type ConfigOptions = MayHaveSspClientOptions & {
3683
3722
  readonly signerWithPreExistingKeys?: boolean;
3684
3723
  readonly console?: ConsoleOptions;
3685
3724
  readonly events?: Partial<SparkWalletEvents>;
3725
+ readonly optimizationOptions?: OptimizationOptions;
3686
3726
  };
3687
3727
 
3688
3728
  declare class WalletConfigService implements HasSspClientOptions {
@@ -3708,6 +3748,7 @@ declare class WalletConfigService implements HasSspClientOptions {
3708
3748
  getSspIdentityPublicKey(): string;
3709
3749
  getConsoleOptions(): ConsoleOptions;
3710
3750
  getEvents(): Partial<SparkWalletEvents>;
3751
+ getOptimizationOptions(): OptimizationOptions;
3711
3752
  }
3712
3753
 
3713
3754
  /** Challenge represents the core challenge data */
@@ -3876,6 +3917,7 @@ declare class SigningService {
3876
3917
  directLeafSigningJobs: UserSignedTxSigningJob[];
3877
3918
  directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
3878
3919
  }>;
3920
+ signSigningJobs(signingJobs: (SigningJobWithOptionalNonce & RequestedSigningCommitments)[]): Promise<Map<SigningJobType, UserSignedTxSigningJob>>;
3879
3921
  }
3880
3922
 
3881
3923
  type LeafKeyTweak = {
@@ -3896,6 +3938,17 @@ type LeafRefundSigningData = {
3896
3938
  directFromCpfpRefundSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
3897
3939
  vout: number;
3898
3940
  };
3941
+ type SigningJobType = "split" | "directSplit" | "node" | "directNode" | "cpfp" | "direct" | "directFromCpfp";
3942
+ type SigningJobWithOptionalNonce = {
3943
+ signingPublicKey: Uint8Array;
3944
+ rawTx: Uint8Array;
3945
+ signingNonceCommitment: SigningCommitmentWithOptionalNonce;
3946
+ type: SigningJobType;
3947
+ parentTxOut: TransactionOutput;
3948
+ leafId: string;
3949
+ keyDerivation: KeyDerivation;
3950
+ verifyingKey: Uint8Array;
3951
+ };
3899
3952
  declare class BaseTransferService {
3900
3953
  protected readonly config: WalletConfigService;
3901
3954
  protected readonly connectionManager: ConnectionManager;
@@ -3948,11 +4001,12 @@ declare class TransferService extends BaseTransferService {
3948
4001
  claimTransferSignRefunds(transfer: Transfer, leafKeys: LeafKeyTweak[], proofMap?: Map<string, Uint8Array[]>): Promise<NodeSignatures[]>;
3949
4002
  private finalizeNodeSignatures;
3950
4003
  queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
3951
- private refreshTimelockNodesInternal;
3952
- refreshTimelockNodes(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3953
- extendTimelock(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3954
- testonly_expireTimeLockNodeTx(node: TreeNode, parentNode: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
3955
- testonly_expireTimeLockRefundtx(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
4004
+ renewRefundTxn(node: TreeNode, parentNode: TreeNode): Promise<TreeNode>;
4005
+ renewNodeTxn(node: TreeNode, parentNode: TreeNode): Promise<TreeNode>;
4006
+ private createRenewRefundSigningJobs;
4007
+ private createRenewNodeSigningJobs;
4008
+ renewZeroTimelockNodeTxn(node: TreeNode): Promise<TreeNode>;
4009
+ private createRenewZeroTimelockNodeSigningJobs;
3956
4010
  }
3957
4011
 
3958
4012
  /**
@@ -3992,13 +4046,15 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
3992
4046
  private handleStreamEvent;
3993
4047
  protected setupBackgroundStream(): Promise<void>;
3994
4048
  getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
3995
- private checkExtendLeaves;
3996
4049
  private verifyKey;
3997
4050
  private popOrThrow;
3998
4051
  private selectLeaves;
3999
4052
  private selectLeavesForSwap;
4000
- private areLeavesInefficient;
4001
- private optimizeLeaves;
4053
+ optimizeLeaves(multiplicity?: number | undefined): AsyncGenerator<{
4054
+ step: number;
4055
+ total: number;
4056
+ controller: AbortController;
4057
+ }, void, void>;
4002
4058
  private syncWallet;
4003
4059
  private withLeaves;
4004
4060
  /**
@@ -4303,15 +4359,7 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4303
4359
  private transferWithInvoice;
4304
4360
  private buildTweaksByAmount;
4305
4361
  private toSendTweak;
4306
- private checkExtendTimeLockNodes;
4307
- /**
4308
- * Internal method to refresh timelock nodes.
4309
- *
4310
- * @param {string} nodeId - The optional ID of the node to refresh. If not provided, all nodes will be checked.
4311
- * @returns {Promise<void>}
4312
- * @private
4313
- */
4314
- private checkRefreshTimelockNodes;
4362
+ private checkRenewLeaves;
4315
4363
  private claimTransferCore;
4316
4364
  private processClaimedTransferResults;
4317
4365
  /**
@@ -4550,13 +4598,6 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
4550
4598
  nodeTimelock: number;
4551
4599
  refundTimelock: number;
4552
4600
  }>;
4553
- /**
4554
- * Refresh the timelock of a specific node.
4555
- *
4556
- * @param {string} nodeId - The ID of the node to refresh
4557
- * @returns {Promise<void>} Promise that resolves when the timelock is refreshed
4558
- */
4559
- testOnly_expireTimelock(nodeId: string): Promise<void>;
4560
4601
  private cleanup;
4561
4602
  cleanupConnections(): Promise<void>;
4562
4603
  private startPeriodicClaimTransfers;
@@ -4658,7 +4699,6 @@ declare const DIRECT_TIMELOCK_OFFSET = 50;
4658
4699
  declare const HTLC_TIMELOCK_OFFSET = 70;
4659
4700
  declare const DIRECT_HTLC_TIMELOCK_OFFSET = 85;
4660
4701
  declare const INITIAL_SEQUENCE: number;
4661
- declare const INITIAL_DIRECT_SEQUENCE: number;
4662
4702
  declare const TEST_UNILATERAL_SEQUENCE: number;
4663
4703
  declare const TEST_UNILATERAL_DIRECT_SEQUENCE: number;
4664
4704
  declare const DEFAULT_FEE_SATS: number;
@@ -4667,55 +4707,60 @@ declare const DEFAULT_FEE_SATS: number;
4667
4707
  * Returns the original amount if it's less than or equal to the fee.
4668
4708
  */
4669
4709
  declare function maybeApplyFee(amount: bigint): bigint;
4670
- declare function createRootTx(depositOutPoint: TransactionInput, depositTxOut: TransactionOutput): [Transaction, Transaction];
4671
- declare function createSplitTx(parentOutPoint: TransactionInput, childTxOuts: TransactionOutput[]): [Transaction, Transaction];
4672
- interface CreateNodeTxInput {
4673
- txOut: TransactionOutput;
4674
- parentOutPoint: TransactionInput;
4675
- applyFee?: boolean;
4676
- includeAnchor?: boolean;
4677
- }
4678
- declare function createNodeTx({ txOut, parentOutPoint, applyFee, includeAnchor, }: CreateNodeTxInput): Transaction;
4679
- declare function createNodeTxs(txOut: TransactionOutput, txIn: TransactionInput, directTxIn?: TransactionInput): {
4680
- cpfpNodeTx: Transaction;
4681
- directNodeTx?: Transaction;
4710
+ declare function createRootNodeTx(parentTx: Transaction, vout: number): {
4711
+ nodeTx: Transaction;
4712
+ directNodeTx: Transaction;
4713
+ };
4714
+ declare function createZeroTimelockNodeTx(parentTx: Transaction): {
4715
+ nodeTx: Transaction;
4716
+ directNodeTx: Transaction;
4717
+ };
4718
+ declare function createInitialTimelockNodeTx(parentTx: Transaction): {
4719
+ nodeTx: Transaction;
4720
+ directNodeTx: Transaction;
4721
+ };
4722
+ declare function createDecrementedTimelockNodeTx(parentTx: Transaction, currentTx: Transaction): {
4723
+ nodeTx: Transaction;
4724
+ directNodeTx: Transaction;
4725
+ };
4726
+ declare function createTestUnilateralTimelockNodeTx(parentTx: Transaction, nodeTx: Transaction): {
4727
+ nodeTx: Transaction;
4728
+ directNodeTx: Transaction;
4682
4729
  };
4683
- declare function createLeafNodeTx(sequence: number, directSequence: number, parentOutPoint: TransactionInput, txOut: TransactionOutput, shouldCalculateFee: boolean): [Transaction, Transaction];
4684
- interface CreateRefundTxInput {
4685
- sequence: number;
4686
- input: TransactionInput;
4687
- amountSats: bigint;
4688
- receivingPubkey: Uint8Array;
4689
- network: Network;
4690
- shouldCalculateFee: boolean;
4691
- includeAnchor: boolean;
4692
- }
4693
- declare function createRefundTx({ sequence, input, amountSats, receivingPubkey, network, shouldCalculateFee, includeAnchor, }: CreateRefundTxInput): Transaction;
4694
4730
  declare function getNextHTLCTransactionSequence(currSequence: number, isNodeTx?: boolean): {
4695
4731
  nextSequence: number;
4696
4732
  nextDirectSequence: number;
4697
4733
  };
4698
- interface CreateRefundTxsInput {
4699
- sequence: number;
4700
- directSequence?: number;
4701
- input: TransactionInput;
4702
- directInput?: TransactionInput;
4703
- amountSats: bigint;
4734
+ interface RefundTxParams {
4735
+ nodeTx: Transaction;
4736
+ directNodeTx?: Transaction;
4704
4737
  receivingPubkey: Uint8Array;
4705
4738
  network: Network;
4706
4739
  }
4707
- declare function createRefundTxs({ sequence, directSequence, input, directInput, amountSats, receivingPubkey, network, }: CreateRefundTxsInput): {
4740
+ interface RefundTxWithSequenceParams extends RefundTxParams {
4741
+ sequence: number;
4742
+ }
4743
+ interface RefundTxWithSequenceAndConnectorOutputParams extends RefundTxWithSequenceParams {
4744
+ connectorOutput: TransactionInput;
4745
+ }
4746
+ interface RefundTxs {
4708
4747
  cpfpRefundTx: Transaction;
4709
4748
  directRefundTx?: Transaction;
4710
4749
  directFromCpfpRefundTx?: Transaction;
4711
- };
4712
- declare function createConnectorRefundTransactions(sequence: number, cpfpNodeOutPoint: TransactionInput, directNodeOutPoint: TransactionInput, connectorOutput: TransactionInput, amountSats: bigint, receiverPubKey: Uint8Array, network: Network, shouldCalculateFee: boolean): [Transaction, Transaction, Transaction];
4750
+ }
4751
+ declare function createInitialTimelockRefundTxs(params: RefundTxParams): RefundTxs;
4752
+ declare function createDecrementedTimelockRefundTxs(params: RefundTxWithSequenceParams): RefundTxs;
4753
+ declare function createCurrentTimelockRefundTxs(params: RefundTxWithSequenceParams): RefundTxs;
4754
+ declare function createTestUnilateralRefundTxs(params: RefundTxParams): RefundTxs;
4755
+ declare function createConnectorRefundTxs(params: RefundTxWithSequenceAndConnectorOutputParams): RefundTxs;
4713
4756
  declare function getCurrentTimelock(currSequence?: number): number;
4714
4757
  declare function getTransactionSequence(currSequence?: number): {
4715
4758
  nextSequence: number;
4716
4759
  nextDirectSequence: number;
4717
4760
  };
4718
4761
  declare function checkIfValidSequence(currSequence?: number): void;
4762
+ declare function isZeroTimelock(currSequence: number): boolean;
4763
+ declare function doesTxnNeedRenewed(currSequence: number): boolean;
4719
4764
  declare function doesLeafNeedRefresh(currSequence: number, isNodeTx?: boolean): boolean;
4720
4765
  declare function getNextTransactionSequence(currSequence: number, isNodeTx?: boolean): {
4721
4766
  nextSequence: number;
@@ -4766,6 +4811,7 @@ interface BroadcastResult {
4766
4811
  declare function isEphemeralAnchorOutput(script?: Uint8Array, amount?: bigint): boolean;
4767
4812
  declare function constructUnilateralExitTxs(nodeHexStrings: string[], sparkClient?: SparkServiceClient, network?: any): Promise<TxChain[]>;
4768
4813
  declare function constructUnilateralExitFeeBumpPackages(nodeHexStrings: string[], utxos: Utxo[], feeRate: FeeRate, electrsUrl: string, sparkClient?: SparkServiceClient, network?: any): Promise<FeeBumpTxChain[]>;
4814
+ declare function hash160(data: Uint8Array): Uint8Array;
4769
4815
  declare function constructFeeBumpTx(txHex: string, utxos: Utxo[], feeRate: FeeRate, previousFeeBumpTx?: string): {
4770
4816
  feeBumpPsbt: string;
4771
4817
  usedUtxos: Utxo[];
@@ -4787,4 +4833,4 @@ declare class SparkSdkLogger {
4787
4833
  static setAllEnabled(enabled: boolean): void;
4788
4834
  }
4789
4835
 
4790
- export { type AggregateFrostParams, AuthenticationError, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, ConfigurationError, DEFAULT_FEE_SATS, DIRECT_HTLC_TIMELOCK_OFFSET, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, DefaultSparkSigner, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, HTLC_TIMELOCK_OFFSET, type IKeyPackage, INITIAL_DIRECT_SEQUENCE, INITIAL_SEQUENCE, InternalValidationError, LOGGER_NAMES, type LeafInfo, type LegacySparkAddressFormat, type LoggerName, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, RPCError, type SignFrostParams, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkSdkLogger, type SparkSigner, SparkWalletBare as SparkWallet, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, TaprootOutputKeysGenerator, TaprootSparkSigner, type TxChain, UnsafeStatelessSparkSigner, type Utxo, ValidationError, type VerifiableSecretShare, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, assertBech32, bech32mDecode, 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, encodeSparkAddressWithSignature, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenIdentifier, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromBech32mTokenIdentifier, getNetworkFromSparkAddress, getNetworkFromString, getNextHTLCTransactionSequence, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxEstimatedVbytesSizeByNumberOfInputsOutputs, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, isEphemeralAnchorOutput, isLegacySparkAddress, isSafeForNumber, isTxBroadcast, isValidPublicKey, isValidSparkAddress, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, toProtoTimestamp, validateOutboundAdaptorSignature, validateShare, validateSparkInvoiceFields, validateSparkInvoiceSignature };
4836
+ export { type AggregateFrostParams, AuthenticationError, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, ConfigurationError, DEFAULT_FEE_SATS, DIRECT_HTLC_TIMELOCK_OFFSET, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, DefaultSparkSigner, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, HTLC_TIMELOCK_OFFSET, type IKeyPackage, INITIAL_SEQUENCE, InternalValidationError, LOGGER_NAMES, type LeafInfo, type LegacySparkAddressFormat, type LoggerName, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, RPCError, type SignFrostParams, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkSdkLogger, type SparkSigner, SparkWalletBare as SparkWallet, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, TaprootOutputKeysGenerator, TaprootSparkSigner, type TxChain, UnsafeStatelessSparkSigner, type Utxo, ValidationError, type VerifiableSecretShare, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, assertBech32, bech32mDecode, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createConnectorRefundTxs, createCurrentTimelockRefundTxs, createDecrementedTimelockNodeTx, createDecrementedTimelockRefundTxs, createInitialTimelockNodeTx, createInitialTimelockRefundTxs, createRootNodeTx, createSigningCommitment, createSigningNonce, createTestUnilateralRefundTxs, createTestUnilateralTimelockNodeTx, createZeroTimelockNodeTx, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, doesLeafNeedRefresh, doesTxnNeedRenewed, encodeBech32mTokenIdentifier, encodeSigningCommitmentToBytes, encodeSigningNonceToBytes, encodeSparkAddress, encodeSparkAddressWithSignature, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenIdentifier, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromBech32mTokenIdentifier, getNetworkFromSparkAddress, getNetworkFromString, getNextHTLCTransactionSequence, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxEstimatedVbytesSizeByNumberOfInputsOutputs, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, hash160, isEphemeralAnchorOutput, isLegacySparkAddress, isSafeForNumber, isTxBroadcast, isValidPublicKey, isValidSparkAddress, isZeroTimelock, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, toProtoTimestamp, validateOutboundAdaptorSignature, validateShare, validateSparkInvoiceFields, validateSparkInvoiceSignature };