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