spark_rust/constants.rs
1//! Constants for the Spark Wallet SDK.
2
3pub mod spark {
4 /// TimeLockInterval is the interval between time locks.
5 pub const TIME_LOCK_INTERVAL: u32 = 100;
6
7 /// InitialTimeLock is the initial time lock for the wallet.
8 pub const INITIAL_TIME_LOCK: u32 = 2000;
9
10 /// Regtest Threshold for the number of signatures required to sign a transaction.
11 ///
12 /// This defines the minimum number of Spark operators that must participate
13 /// in threshold signing for the regtest network.
14 pub const SPARK_REGTEST_SIGNING_THRESHOLD: u32 = 2;
15
16 /// Transfer expiry duration in seconds.
17 ///
18 /// When a transfer is created, it will be claimable for this duration.
19 /// After this period elapses, the transfer may expire if not claimed by the recipient.
20 /// The default is 30 days (in seconds).
21 pub const DEFAULT_TRANSFER_EXPIRY: u64 = 60 * 60 * 24 * 30; // 30 days
22
23 /// Default cooperative exit expiry time in seconds.
24 ///
25 /// When requesting a cooperative exit (withdrawal to on-chain Bitcoin),
26 /// the request is valid for this duration. If not completed within this time,
27 /// the cooperative exit request may expire and need to be resubmitted.
28 /// The default is 3 hours (in seconds).
29 pub const DEFAULT_COOPERATIVE_EXIT_EXPIRY: u64 = 60 * 60 * 3; // 3 hours
30
31 /// Default withdrawal amount in sats.
32 ///
33 /// When requesting a withdrawal (withdrawal to on-chain Bitcoin),
34 /// the amount to withdraw is specified. The default is 1000 sats.
35 pub const DEFAULT_WITHDRAWAL_AMOUNT: u64 = 10_000;
36
37 /// Lightspark's SSP (Spark Service Provider) API endpoint. Lightspark's SSP is the default service provider for Spark Rust SDK.
38 ///
39 /// This is the GraphQL endpoint used to communicate with the
40 /// Lightspark Spark Service Provider for operations like Lightning payments.
41 pub const LIGHTSPARK_SSP_ENDPOINT: &str = "https://api.dev.dev.sparkinfra.net/graphql/spark/rc";
42
43 /// Lightspark SSP identity public key (regtest)
44 pub const LIGHTSPARK_SSP_REGTEST_IDENTITY_PUBLIC_KEY: &str =
45 "028c094a432d46a0ac95349d792c2e3730bd60c29188db716f56a99e39b95338b4";
46
47 /// Lightspark SSP identity public key (mainnet)
48 pub const LIGHTSPARK_SSP_MAINNET_IDENTITY_PUBLIC_KEY: &str =
49 "02e0b8d42c5d3b5fe4c5beb6ea796ab3bc8aaf28a3d3195407482c67e0b58228a5";
50
51 /// Connection-related constants for network communication.
52 pub mod connection {
53 /// Default retry count for network operations.
54 ///
55 /// When a network operation to a Spark Operator fails, the SDK will automatically
56 /// retry up to this number of times before reporting an error.
57 pub const DEFAULT_RETRY_COUNT: u32 = 3;
58
59 /// Default coordinator index for Spark operators.
60 ///
61 /// The coordinator is the primary operator that the wallet
62 /// communicates with for orchestrating multi-party operations.
63 pub const DEFAULT_COORDINATOR_INDEX: u32 = 0;
64
65 /// List of Spark Operators for the Regtest network.
66 ///
67 /// Each entry is a tuple containing:
68 /// - The operator's endpoint URL
69 /// - The operator's identity public key (used for verification)
70 ///
71 /// These operators participate in threshold signing operations
72 /// in the regtest environment.
73 pub const SPARK_DEV_OPERATORS: &[(&str, &str)] = &[
74 (
75 "https://0.spark.dev.dev.sparkinfra.net",
76 "03acd9a5a88db102730ff83dee69d69088cc4c9d93bbee893e90fd5051b7da9651",
77 ),
78 (
79 "https://1.spark.dev.dev.sparkinfra.net",
80 "02d2d103cacb1d6355efeab27637c74484e2a7459e49110c3fe885210369782e23",
81 ),
82 (
83 "https://2.spark.dev.dev.sparkinfra.net",
84 "0350f07ffc21bfd59d31e0a7a600e2995273938444447cb9bc4c75b8a895dbb853",
85 ),
86 ];
87 }
88
89 /// Constants related to FROST threshold signing.
90 ///
91 /// FROST (Flexible Round-Optimized Schnorr Threshold) is the threshold signature
92 /// scheme used by Spark to allow multiple parties to participate in signing
93 /// without revealing their individual keys.
94 pub mod frost {
95 use spark_protos::frost::SigningRole;
96
97 /// User identifier for FROST signing.
98 ///
99 /// This hexadecimal value uniquely identifies the user's role
100 /// in FROST threshold signing operations. This is a fixed value
101 /// that represents the user party in the signing protocol.
102 pub const FROST_USER_IDENTIFIER: &str =
103 "0000000000000000000000000000000000000000000000000000000000000063";
104
105 /// User signing role value for FROST operations.
106 ///
107 /// This value identifies the role of the user in threshold signing
108 /// operations. It's used in protocol buffer messages to specify
109 /// the signing participant's role.
110 pub const FROST_USER_SIGNING_ROLE: i32 = SigningRole::User as i32;
111
112 /// Minimum number of signers required for the user's key package.
113 ///
114 /// This value specifies that at least one signer (the user) is required
115 /// for the user's portion of a threshold signature. This is always 1
116 /// because the user's part of the signature does not use threshold signing.
117 pub const FROST_USER_KEY_PACKAGE_MIN_SIGNERS: u32 = 1;
118 }
119}