Coverage Report

Created: 2026-10-19 15:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/tmp/bitcoin/src/util/chaintype.cpp
Line
Count
Source
1
// Copyright (c) 2023-present 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 <util/check.h>
8
9
#include <optional>
10
#include <string>
11
12
std::string ChainTypeToString(ChainType chain)
13
1.23M
{
14
1.23M
    switch (chain) {
15
1.18M
    case ChainType::MAIN:
16
1.18M
        return "main";
17
8.88k
    case ChainType::TESTNET:
18
8.88k
        return "test";
19
9.18k
    case ChainType::TESTNET4:
20
9.18k
        return "testnet4";
21
9.05k
    case ChainType::SIGNET:
22
9.05k
        return "signet";
23
25.0k
    case ChainType::REGTEST:
24
25.0k
        return "regtest";
25
1.23M
    }
26
1.23M
    assert(false);
27
0
}
28
29
std::optional<ChainType> ChainTypeFromString(std::string_view chain)
30
173
{
31
173
    if (chain == "main") {
32
36
        return ChainType::MAIN;
33
137
    } else if (chain == "test") {
34
0
        return ChainType::TESTNET;
35
137
    } else if (chain == "testnet4") {
36
36
        return ChainType::TESTNET4;
37
101
    } else if (chain == "signet") {
38
36
        return ChainType::SIGNET;
39
65
    } else if (chain == "regtest") {
40
65
        return ChainType::REGTEST;
41
65
    } else {
42
0
        return std::nullopt;
43
0
    }
44
173
}