Skip to main content

fedimint_core/
setup_code.rs

1use std::collections::BTreeSet;
2
3use bitcoin::Network;
4use serde::Serialize;
5
6use crate::core::ModuleKind;
7use crate::encoding::{Decodable, Encodable};
8use crate::util::SafeUrl;
9
10#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Serialize)]
11/// Connection information sent between peers in order to start config gen
12pub struct PeerSetupCode {
13    /// Name of the peer, used in TLS auth
14    pub name: String,
15    /// The peer's api and p2p endpoint
16    pub endpoints: PeerEndpoints,
17    /// Federation name set by the leader
18    pub federation_name: Option<String>,
19    /// Whether to disable base fees, set by the leader
20    pub disable_base_fees: Option<bool>,
21    /// Modules enabled by the leader (if None, all available modules are
22    /// enabled)
23    pub enabled_modules: Option<BTreeSet<ModuleKind>>,
24    /// Total number of guardians (including the one who sets this), set by the
25    /// leader
26    pub federation_size: Option<u32>,
27    /// Bitcoin network configured locally by the guardian
28    pub network: Network,
29}
30
31#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Serialize)]
32pub enum PeerEndpoints {
33    Tcp {
34        /// Url for our websocket api endpoint
35        api_url: SafeUrl,
36        /// Url for our websocket p2p endpoint
37        p2p_url: SafeUrl,
38        /// TLS certificate for our websocket p2p endpoint#
39        #[serde(with = "::fedimint_core::encoding::as_hex")]
40        cert: Vec<u8>,
41    },
42    Iroh {
43        /// Public key for our iroh api endpoint
44        api_pk: iroh_base::PublicKey,
45        /// Public key for our iroh p2p endpoint
46        p2p_pk: iroh_base::PublicKey,
47    },
48}