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    /// Fedimint `x.y.z` cargo release version running on this peer
30    pub fedimint_version: String,
31}
32
33#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Serialize)]
34pub enum PeerEndpoints {
35    Tcp {
36        /// Url for our websocket api endpoint
37        api_url: SafeUrl,
38        /// Url for our websocket p2p endpoint
39        p2p_url: SafeUrl,
40        /// TLS certificate for our websocket p2p endpoint#
41        #[serde(with = "::fedimint_core::encoding::as_hex")]
42        cert: Vec<u8>,
43    },
44    Iroh {
45        /// Public key for our iroh api endpoint
46        api_pk: iroh_base::PublicKey,
47        /// Public key for our iroh p2p endpoint
48        p2p_pk: iroh_base::PublicKey,
49    },
50}