Bitcoin ABC 0.31.8
P2P Digital Currency
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
11std::string ChainTypeToString(ChainType chain) {
12 switch (chain) {
13 case ChainType::MAIN:
14 return "main";
16 return "test";
18 return "regtest";
19 }
20 assert(false);
21}
22
23std::optional<ChainType> ChainTypeFromString(std::string_view chain) {
24 if (chain == "main") {
25 return ChainType::MAIN;
26 } else if (chain == "test") {
27 return ChainType::TESTNET;
28 } else if (chain == "regtest") {
29 return ChainType::REGTEST;
30 } else {
31 return std::nullopt;
32 }
33}
std::optional< ChainType > ChainTypeFromString(std::string_view chain)
Definition: chaintype.cpp:23
std::string ChainTypeToString(ChainType chain)
Definition: chaintype.cpp:11
ChainType
Definition: chaintype.h:11
assert(!tx.IsCoinBase())