circuits_lib/common/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pub mod constants;
pub mod hashes;
pub mod zkvm;

pub const NETWORK_TYPE: &str = {
    #[cfg(test)]
    {
        "testnet4"
    }
    #[cfg(not(test))]
    {
        match option_env!("BITCOIN_NETWORK") {
            Some(network) if matches!(network.as_bytes(), b"mainnet") => "mainnet",
            Some(network) if matches!(network.as_bytes(), b"testnet4") => "testnet4",
            Some(network) if matches!(network.as_bytes(), b"signet") => "signet",
            Some(network) if matches!(network.as_bytes(), b"regtest") => "regtest",
            None => "testnet4",
            _ => panic!("Invalid network type"),
        }
    }
};

// Then your function becomes simpler
pub const fn get_network() -> &'static str {
    NETWORK_TYPE
}