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;
9use crate::version::DkgVersion;
10
11#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Serialize)]
12/// Connection information sent between peers in order to start config gen
13pub struct PeerSetupCode {
14 /// Name of the peer, used in TLS auth
15 pub name: String,
16 /// The peer's api and p2p endpoint
17 pub endpoints: PeerEndpoints,
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 /// Bitcoin network configured locally by the guardian
27 pub network: Network,
28 /// Normalized Fedimint `x.y.z` release version with optional vendor suffix
29 ///
30 /// Its consensus encoding remains the historical string encoding so setup
31 /// codes generated before this field became semantically typed still
32 /// decode.
33 pub fedimint_version: DkgVersion,
34}
35
36#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Serialize)]
37pub enum PeerEndpoints {
38 Tcp {
39 /// Url for our websocket api endpoint
40 api_url: SafeUrl,
41 /// Url for our websocket p2p endpoint
42 p2p_url: SafeUrl,
43 /// TLS certificate for our websocket p2p endpoint#
44 #[serde(with = "::fedimint_core::encoding::as_hex")]
45 cert: Vec<u8>,
46 },
47 Iroh {
48 /// Public key for our iroh api endpoint
49 api_pk: iroh_base::PublicKey,
50 /// Public key for our iroh p2p endpoint
51 p2p_pk: iroh_base::PublicKey,
52 },
53}