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 /// Spark derivation path purpose value.
52 ///
53 /// This BIP-43 purpose value (8797555) is specific to Spark and is derived from
54 /// the last 3 bytes of SHA256("spark") in decimal (863d73).
55 /// It is critical for defining the correct derivation path for Spark wallets:
56 /// m/8797555'/account'/key_type'/[leaf_index']
57 pub const SPARK_DERIVATION_PATH_PURPOSE: u32 = 8797555;
58
59 /// Connection-related constants for network communication.
60 pub mod connection {
61 /// Default retry count for network operations.
62 ///
63 /// When a network operation to a Spark Operator fails, the SDK will automatically
64 /// retry up to this number of times before reporting an error.
65 pub const DEFAULT_RETRY_COUNT: u32 = 3;
66
67 /// Default coordinator index for Spark operators.
68 ///
69 /// The coordinator is the primary operator that the wallet
70 /// communicates with for orchestrating multi-party operations.
71 pub const DEFAULT_COORDINATOR_INDEX: u32 = 0;
72
73 /// List of Spark Operators for the Regtest network.
74 ///
75 /// Each entry is a tuple containing:
76 /// - The operator's endpoint URL
77 /// - The operator's identity public key (used for verification)
78 ///
79 /// These operators participate in threshold signing operations
80 /// in the regtest environment.
81 pub const SPARK_DEV_OPERATORS: &[(&str, &str)] = &[
82 (
83 "https://0.spark.dev.dev.sparkinfra.net",
84 "03acd9a5a88db102730ff83dee69d69088cc4c9d93bbee893e90fd5051b7da9651",
85 ),
86 (
87 "https://1.spark.dev.dev.sparkinfra.net",
88 "02d2d103cacb1d6355efeab27637c74484e2a7459e49110c3fe885210369782e23",
89 ),
90 (
91 "https://2.spark.dev.dev.sparkinfra.net",
92 "0350f07ffc21bfd59d31e0a7a600e2995273938444447cb9bc4c75b8a895dbb853",
93 ),
94 ];
95 }
96
97 /// Constants related to FROST threshold signing.
98 ///
99 /// FROST (Flexible Round-Optimized Schnorr Threshold) is the threshold signature
100 /// scheme used by Spark to allow multiple parties to participate in signing
101 /// without revealing their individual keys.
102 pub mod frost {
103 use spark_protos::frost::SigningRole;
104
105 /// User identifier for FROST signing.
106 ///
107 /// This hexadecimal value uniquely identifies the user's role
108 /// in FROST threshold signing operations. This is a fixed value
109 /// that represents the user party in the signing protocol.
110 pub const FROST_USER_IDENTIFIER: &str =
111 "0000000000000000000000000000000000000000000000000000000000000063";
112
113 /// User signing role value for FROST operations.
114 ///
115 /// This value identifies the role of the user in threshold signing
116 /// operations. It's used in protocol buffer messages to specify
117 /// the signing participant's role.
118 pub const FROST_USER_SIGNING_ROLE: i32 = SigningRole::User as i32;
119
120 /// Minimum number of signers required for the user's key package.
121 ///
122 /// This value specifies that at least one signer (the user) is required
123 /// for the user's portion of a threshold signature. This is always 1
124 /// because the user's part of the signature does not use threshold signing.
125 pub const FROST_USER_KEY_PACKAGE_MIN_SIGNERS: u32 = 1;
126 }
127}