Skip to main content

fedimint_core/
setup_code.rs

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