Bitcoin Core
31.99.0
P2P Digital Currency
src
util
chaintype.cpp
Go to the documentation of this file.
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
{
14
switch
(chain) {
15
case
ChainType::MAIN
:
16
return
"main"
;
17
case
ChainType::TESTNET
:
18
return
"test"
;
19
case
ChainType::TESTNET4
:
20
return
"testnet4"
;
21
case
ChainType::SIGNET
:
22
return
"signet"
;
23
case
ChainType::REGTEST
:
24
return
"regtest"
;
25
}
26
assert
(
false
);
27
}
28
29
std::optional<ChainType>
ChainTypeFromString
(std::string_view chain)
30
{
31
if
(chain ==
"main"
) {
32
return
ChainType::MAIN
;
33
}
else
if
(chain ==
"test"
) {
34
return
ChainType::TESTNET
;
35
}
else
if
(chain ==
"testnet4"
) {
36
return
ChainType::TESTNET4
;
37
}
else
if
(chain ==
"signet"
) {
38
return
ChainType::SIGNET
;
39
}
else
if
(chain ==
"regtest"
) {
40
return
ChainType::REGTEST
;
41
}
else
{
42
return
std::nullopt;
43
}
44
}
ChainTypeFromString
std::optional< ChainType > ChainTypeFromString(std::string_view chain)
Definition:
chaintype.cpp:29
ChainTypeToString
std::string ChainTypeToString(ChainType chain)
Definition:
chaintype.cpp:12
chaintype.h
ChainType
ChainType
Definition:
chaintype.h:12
ChainType::SIGNET
@ SIGNET
ChainType::MAIN
@ MAIN
ChainType::TESTNET
@ TESTNET
ChainType::REGTEST
@ REGTEST
ChainType::TESTNET4
@ TESTNET4
check.h
assert
assert(!tx.IsCoinBase())
Generated on Mon Apr 13 2026 20:00:31 for Bitcoin Core by
1.9.4