mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-03 11:43:04 +02:00
refactor: Use C++17 std::array deduction for OUTPUT_TYPES
This commit is contained in:
parent
2dab2d239a
commit
fa39cdd072
@ -19,8 +19,6 @@ static const std::string OUTPUT_TYPE_STRING_LEGACY = "legacy";
|
|||||||
static const std::string OUTPUT_TYPE_STRING_P2SH_SEGWIT = "p2sh-segwit";
|
static const std::string OUTPUT_TYPE_STRING_P2SH_SEGWIT = "p2sh-segwit";
|
||||||
static const std::string OUTPUT_TYPE_STRING_BECH32 = "bech32";
|
static const std::string OUTPUT_TYPE_STRING_BECH32 = "bech32";
|
||||||
|
|
||||||
const std::array<OutputType, 3> OUTPUT_TYPES = {OutputType::LEGACY, OutputType::P2SH_SEGWIT, OutputType::BECH32};
|
|
||||||
|
|
||||||
bool ParseOutputType(const std::string& type, OutputType& output_type)
|
bool ParseOutputType(const std::string& type, OutputType& output_type)
|
||||||
{
|
{
|
||||||
if (type == OUTPUT_TYPE_STRING_LEGACY) {
|
if (type == OUTPUT_TYPE_STRING_LEGACY) {
|
||||||
|
@ -20,7 +20,11 @@ enum class OutputType {
|
|||||||
BECH32,
|
BECH32,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const std::array<OutputType, 3> OUTPUT_TYPES;
|
static constexpr auto OUTPUT_TYPES = std::array{
|
||||||
|
OutputType::LEGACY,
|
||||||
|
OutputType::P2SH_SEGWIT,
|
||||||
|
OutputType::BECH32,
|
||||||
|
};
|
||||||
|
|
||||||
[[nodiscard]] bool ParseOutputType(const std::string& str, OutputType& output_type);
|
[[nodiscard]] bool ParseOutputType(const std::string& str, OutputType& output_type);
|
||||||
const std::string& FormatOutputType(OutputType type);
|
const std::string& FormatOutputType(OutputType type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user