|
| 1 | +//! # Clementine Configuration Options |
| 2 | +
|
| 3 | +use std::path::PathBuf; |
| 4 | + |
| 5 | +use bitcoin::{address::NetworkUnchecked, secp256k1, Amount, Network}; |
| 6 | +use serde::{Deserialize, Serialize}; |
| 7 | + |
| 8 | +/// Clementine's configuration options. |
| 9 | +#[derive(Debug, Clone, Serialize, Deserialize)] |
| 10 | +pub struct ClementineClient { |
| 11 | + /// Host of the operator or the verifier |
| 12 | + pub host: String, |
| 13 | + /// Port of the operator or the verifier |
| 14 | + pub port: u16, |
| 15 | + /// Bitcoin network to work on. |
| 16 | + pub network: Network, |
| 17 | + /// Secret key for the operator or the verifier. |
| 18 | + pub secret_key: secp256k1::SecretKey, |
| 19 | + /// Verifiers public keys. |
| 20 | + pub verifiers_public_keys: Vec<secp256k1::PublicKey>, |
| 21 | + /// Number of verifiers. |
| 22 | + pub num_verifiers: usize, |
| 23 | + /// Operators x-only public keys. |
| 24 | + pub operators_xonly_pks: Vec<secp256k1::XOnlyPublicKey>, |
| 25 | + /// Operators wallet addresses. |
| 26 | + pub operator_wallet_addresses: Vec<bitcoin::Address<NetworkUnchecked>>, |
| 27 | + /// Number of operators. |
| 28 | + pub num_operators: usize, |
| 29 | + /// Operator's fee for withdrawal, in satoshis. |
| 30 | + pub operator_withdrawal_fee_sats: Option<Amount>, |
| 31 | + /// Number of blocks after which user can take deposit back if deposit request fails. |
| 32 | + pub user_takes_after: u32, |
| 33 | + /// Number of blocks after which operator can take reimburse the bridge fund if they are honest. |
| 34 | + pub operator_takes_after: u32, |
| 35 | + /// Bridge amount in satoshis. |
| 36 | + pub bridge_amount_sats: Amount, |
| 37 | + /// Operator: number of kickoff UTXOs per funding transaction. |
| 38 | + pub operator_num_kickoff_utxos_per_tx: usize, |
| 39 | + /// Threshold for confirmation. |
| 40 | + pub confirmation_threshold: u32, |
| 41 | + /// Bitcoin remote procedure call URL. |
| 42 | + pub bitcoin_rpc_url: String, |
| 43 | + /// Bitcoin RPC user. |
| 44 | + pub bitcoin_rpc_user: String, |
| 45 | + /// Bitcoin RPC user password. |
| 46 | + pub bitcoin_rpc_password: String, |
| 47 | + /// All Secret keys. Just for testing purposes. |
| 48 | + pub all_verifiers_secret_keys: Option<Vec<secp256k1::SecretKey>>, |
| 49 | + /// All Secret keys. Just for testing purposes. |
| 50 | + pub all_operators_secret_keys: Option<Vec<secp256k1::SecretKey>>, |
| 51 | + /// Verifier endpoints. |
| 52 | + pub verifier_endpoints: Option<Vec<String>>, |
| 53 | + /// PostgreSQL database host address. |
| 54 | + pub db_host: String, |
| 55 | + /// PostgreSQL database port. |
| 56 | + pub db_port: usize, |
| 57 | + /// PostgreSQL database user name. |
| 58 | + pub db_user: String, |
| 59 | + /// PostgreSQL database user password. |
| 60 | + pub db_password: String, |
| 61 | + /// PostgreSQL database name. |
| 62 | + pub db_name: String, |
| 63 | + /// Citrea RPC URL. |
| 64 | + pub citrea_rpc_url: String, |
| 65 | + /// Bridge contract address. |
| 66 | + pub bridge_contract_address: String, |
| 67 | +} |
| 68 | + |
| 69 | +impl Default for ClementineClient { |
| 70 | + fn default() -> Self { |
| 71 | + Self { |
| 72 | + host: "127.0.0.1".to_string(), |
| 73 | + port: 3030, |
| 74 | + secret_key: secp256k1::SecretKey::new(&mut secp256k1::rand::thread_rng()), |
| 75 | + verifiers_public_keys: vec![], |
| 76 | + num_verifiers: 7, |
| 77 | + operators_xonly_pks: vec![], |
| 78 | + operator_wallet_addresses: vec![], |
| 79 | + num_operators: 3, |
| 80 | + operator_withdrawal_fee_sats: None, |
| 81 | + user_takes_after: 5, |
| 82 | + operator_takes_after: 5, |
| 83 | + bridge_amount_sats: Amount::from_sat(100_000_000), |
| 84 | + operator_num_kickoff_utxos_per_tx: 10, |
| 85 | + confirmation_threshold: 1, |
| 86 | + network: Network::Regtest, |
| 87 | + bitcoin_rpc_url: "http://127.0.0.1:18443".to_string(), |
| 88 | + bitcoin_rpc_user: "admin".to_string(), |
| 89 | + bitcoin_rpc_password: "admin".to_string(), |
| 90 | + all_verifiers_secret_keys: None, |
| 91 | + all_operators_secret_keys: None, |
| 92 | + verifier_endpoints: None, |
| 93 | + db_host: "127.0.0.1".to_string(), |
| 94 | + db_port: 5432, |
| 95 | + db_user: "postgres".to_string(), |
| 96 | + db_password: "postgres".to_string(), |
| 97 | + db_name: "postgres".to_string(), |
| 98 | + citrea_rpc_url: "http://127.0.0.1:12345".to_string(), |
| 99 | + bridge_contract_address: "3100000000000000000000000000000000000002".to_string(), |
| 100 | + } |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +#[derive(Debug, Clone)] |
| 105 | +pub struct ClementineConfig { |
| 106 | + pub client: ClementineClient, |
| 107 | + pub docker_image: Option<String>, |
| 108 | + pub data_dir: PathBuf, |
| 109 | +} |
| 110 | + |
| 111 | +impl Default for ClementineConfig { |
| 112 | + fn default() -> Self { |
| 113 | + Self { |
| 114 | + client: ClementineClient::default(), |
| 115 | + docker_image: None, |
| 116 | + data_dir: PathBuf::from("bridge_backend"), |
| 117 | + } |
| 118 | + } |
| 119 | +} |
0 commit comments