Skip to main content

anyswap_core/
lib.rs

1//! On-chain primitives and API types for AnySwap, shared by the server and the SDK.
2
3pub mod api;
4pub mod codec;
5#[cfg(feature = "esplora")]
6pub mod esplora;
7pub mod fee;
8pub mod invoice;
9pub mod script;
10pub mod transaction;
11pub mod types;
12pub mod utils;
13pub mod wallet;
14
15pub mod musig;
16
17pub mod auth;
18
19use std::sync::OnceLock;
20
21use bitcoin::secp256k1::{All, Secp256k1};
22
23/// The wire protocol this build speaks: the crate's major and minor version,
24/// since a patch release never changes the wire.
25pub const PROTOCOL_VERSION: &str = concat!(
26    env!("CARGO_PKG_VERSION_MAJOR"),
27    ".",
28    env!("CARGO_PKG_VERSION_MINOR"),
29    ".0"
30);
31
32/// Shared secp256k1 context, lazily initialized once per process.
33pub fn secp() -> &'static Secp256k1<All> {
34    static SECP: OnceLock<Secp256k1<All>> = OnceLock::new();
35    SECP.get_or_init(Secp256k1::new)
36}