Coverage Report

Created: 2025-09-25 19:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/util/chaintype.cpp
Line
Count
Source
1
// Copyright (c) 2023 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <util/chaintype.h>
6
7
#include <cassert>
8
#include <optional>
9
#include <string>
10
11
std::string ChainTypeToString(ChainType chain)
12
254k
{
13
254k
    switch (chain) {
14
253k
    case ChainType::MAIN:
15
253k
        return "main";
16
0
    case ChainType::TESTNET:
17
0
        return "test";
18
0
    case ChainType::TESTNET4:
19
0
        return "testnet4";
20
0
    case ChainType::SIGNET:
21
0
        return "signet";
22
1.68k
    case ChainType::REGTEST:
23
1.68k
        return "regtest";
24
254k
    }
25
254k
    assert(false);
26
0
}
27
28
std::optional<ChainType> ChainTypeFromString(std::string_view chain)
29
0
{
30
0
    if (chain == "main") {
31
0
        return ChainType::MAIN;
32
0
    } else if (chain == "test") {
33
0
        return ChainType::TESTNET;
34
0
    } else if (chain == "testnet4") {
35
0
        return ChainType::TESTNET4;
36
0
    } else if (chain == "signet") {
37
0
        return ChainType::SIGNET;
38
0
    } else if (chain == "regtest") {
39
0
        return ChainType::REGTEST;
40
0
    } else {
41
0
        return std::nullopt;
42
0
    }
43
0
}