mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
make ParseOutputType return a std::optional<OutputType>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
#include <tuple>
|
||||
#ifdef HAVE_MALLOC_INFO
|
||||
@@ -128,12 +129,13 @@ static RPCHelpMan createmultisig()
|
||||
// Get the output type
|
||||
OutputType output_type = OutputType::LEGACY;
|
||||
if (!request.params[2].isNull()) {
|
||||
if (!ParseOutputType(request.params[2].get_str(), output_type)) {
|
||||
std::optional<OutputType> parsed = ParseOutputType(request.params[2].get_str());
|
||||
if (!parsed) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[2].get_str()));
|
||||
}
|
||||
if (output_type == OutputType::BECH32M) {
|
||||
} else if (parsed.value() == OutputType::BECH32M) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "createmultisig cannot create bech32m multisig addresses");
|
||||
}
|
||||
output_type = parsed.value();
|
||||
}
|
||||
|
||||
// Construct using pay-to-script-hash:
|
||||
|
||||
Reference in New Issue
Block a user