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 /// Federation name set by the leader
19 pub federation_name: Option<String>,
20 /// Whether to disable base fees, set by the leader
21 pub disable_base_fees: Option<bool>,
22 /// Modules enabled by the leader (if None, all available modules are
23 /// enabled)
24 pub enabled_modules: Option<BTreeSet<ModuleKind>>,
25 /// Total number of guardians (including the one who sets this), set by the
26 /// leader
27 pub federation_size: Option<u32>,
28 /// Bitcoin network configured locally by the guardian
29 pub network: Network,
30 /// Normalized Fedimint `x.y.z` release version with optional vendor suffix
31 ///
32 /// Its consensus encoding remains the historical string encoding so setup
33 /// codes generated before this field became semantically typed still
34 /// decode.
35 pub fedimint_version: DkgVersion,
36}
37
38#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Serialize)]
39pub enum PeerEndpoints {
40 Tcp {
41 /// Url for our websocket api endpoint
42 api_url: SafeUrl,
43 /// Url for our websocket p2p endpoint
44 p2p_url: SafeUrl,
45 /// TLS certificate for our websocket p2p endpoint#
46 #[serde(with = "::fedimint_core::encoding::as_hex")]
47 cert: Vec<u8>,
48 },
49 Iroh {
50 /// Public key for our iroh api endpoint
51 api_pk: iroh_base::PublicKey,
52 /// Public key for our iroh p2p endpoint
53 p2p_pk: iroh_base::PublicKey,
54 },
55}