aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-08-04 19:01:57 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-08-04 19:02:04 +0200
commit4f1a75b1aa9402e62bc2ed3e0296e4fba81254e4 (patch)
treede9abbc2c411dd826cdffd3d72c4d8c929258c59 /src/rpc
parent2b06af17470667a9c9ee68cb241936839b46bc33 (diff)
parent32fa49a18497a9b8c72e36a72ae96e7b23930223 (diff)
downloadbitcoin-4f1a75b1aa9402e62bc2ed3e0296e4fba81254e4.tar.xz
Merge bitcoin/bitcoin#22621: make ParseOutputType return a std::optional<OutputType>
32fa49a18497a9b8c72e36a72ae96e7b23930223 make 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: utACK 32fa49a18497a9b8c72e36a72ae96e7b23930223 jonatack: Code review ACK 32fa49a18497a9b8c72e36a72ae96e7b23930223 and debian clang 13 debug build is clean / unit tests locally are green MarcoFalke: review ACK 32fa49a18497a9b8c72e36a72ae96e7b23930223 🍢 Tree-SHA512: 7752193117669b800889226185d49d164395697853828f8acb568f07651789bc5b2cddc45555957450353886e46b9a1e13c77a5e730a14c6ee621fabc8dc3d10
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/misc.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index 5178ce60e8..1a94abf6d3 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -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: