mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 16:53:52 +02:00
Merge bitcoin/bitcoin#22621: make ParseOutputType return a std::optional<OutputType>
32fa49a184make ParseOutputType return a std::optional<OutputType> (fanquake) Pull request description: Similar to #22220. Skipped using `auto` here for the same reasons outlined in that PR. ACKs for top commit: jnewbery: utACK32fa49a184jonatack: Code review ACK32fa49a184and debian clang 13 debug build is clean / unit tests locally are green MarcoFalke: review ACK32fa49a184🍢 Tree-SHA512: 7752193117669b800889226185d49d164395697853828f8acb568f07651789bc5b2cddc45555957450353886e46b9a1e13c77a5e730a14c6ee621fabc8dc3d10
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