Expand description
Fedimint Core library
fedimint-core
contains commonly used types, utilities and primitives,
shared between both client and server code.
Things that are server-side only typically live in fedimint-server
, and
client-side only in fedimint-client
.
§Wasm support
All code in fedimint-core
needs to compile on Wasm, and fedimint-core
includes helpers and wrappers around non-wasm-safe utitlies.
In particular:
fedimint_core::task
for task spawning and controlfedimint_core::time
for time-related operations
Re-exports§
pub use module::ServerModule;
pub use tiered::Tiered;
pub use crate::core::server;
pub use anyhow;
pub use hex;
pub use secp256k1;
pub use tiered_multi::*;
Modules§
- Admin (guardian) client types
- Federation-stored client backups Federation-stored client backups
- Gradual bitcoin dependency migration helpers
- Legacy serde encoding for bls12_381
- Federation configuration
- Fundamental types Fedimint Core API (common) module interface
- Database handling Core Fedimint database traits and types
- Consensus encoding This module defines a binary encoding interface which is more suitable for consensus critical encoding than e.g.
bincode
. Over time all structs that need to be encoded to binary will be migrated to this interface. - Common environment variables
- Formatting helpers
- Federation invite code
- Common macros
- Extenable module sysystem Fedimint supports modules to allow extending it’s functionality. Some of the standard functionality is implemented in form of modules as well.
- Peer networking
- Runtime (wasm32 vs native) differences handling Copyright 2021 The Matrix.org Foundation C.I.C. Abstraction over an executor so we can spawn tasks under WASM the same way we do usually.
- Atomic BFT unit containing consensus items
- Task handling, including wasm safe logic
- Types handling per-denomination values
- Types handling multiple per-denomination values
- Time handling, wasm safe functionality
- Timing helpers
- Fedimint transaction (inpus + outputs + signature) types
- Peg-in txo proofs
- General purpose utilities
Macros§
- Example
- async trait that use MaybeSend
- Define “dyn newtype” (a newtype over
dyn Trait
) - Implements the
Display
trait for dyn newtypes whose traits implementDisplay
- Implement
Clone
on a “dyn newtype” - Wraps a type into an enum with a default variant, this allows to add new versions of the type in the future. Depending on context unknown versions may be ignored or lead to errors. E.g. the client might just ignore an unknown input version since it cannot originate from itself while the server would reject it for not being able to validate its correctness.
- Get value of
FEDIMINT_BUILD_CODE_VERSION_ENV
at compile time - This is a helper macro that generates the implementations of
DatabaseRecord
necessary for reading/writing to the database and fetching by prefix. - MaybeSync can not be used in
dyn $Trait + MaybeSend
- See
maybe_add_send
- Define a “module plugin dyn-newtype” which is like a standard “dyn newtype”, but with associated “module_instance_id”.
- Implement
Encodable
andDecodable
for a “module dyn newtype” - Define a “plugin” trait
- A copy of
module_lugin_static_trait_define
but forClientConfig
, which is a snowflake that requires: Serialize
and conditional implementation forDynUnknown
. The macro is getting gnarly, so seems easier to copy-paste-modify, than pile up conditional argument. - Implements the necessary traits for all associated types of a
FederationServer
module. - Implements the necessary traits for all configuration related types of a
FederationServer
module.
Structs§
- Represents an amount of BTC. The base denomination is millisatoshis, which is why the
Amount
type from rust-bitcoin isn’t used instead. - The number of guardians in a federation.
OutPoint
represents a globally unique output in a transaction- A transaction id for peg-ins, peg-outs and reissuances
Enums§
- Amount of bitcoin to send, or
All
to send all available funds
Constants§
Traits§
- Trait which applies to hashes of all types.
- Types that can be easily converted to
NumPeers
Functions§
- Shorthand for
Amount::from_msats
- Shorthand for
Amount::from_sats
- Converts weight to virtual bytes, defined in BIP-141 as weight / 4 (rounded up to the next integer).