From bee56c78e94417f89b1f48682404e2821b57bdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Thu, 15 Apr 2021 11:07:47 +0100 Subject: rpc: Check default value type againts argument type --- src/rpc/util.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 71c6160322..df3ee9f007 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -498,6 +498,33 @@ RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector(arg.m_fallback).getType()) { + case UniValue::VOBJ: + CHECK_NONFATAL(type == RPCArg::Type::OBJ); + break; + case UniValue::VARR: + CHECK_NONFATAL(type == RPCArg::Type::ARR); + break; + case UniValue::VSTR: + CHECK_NONFATAL(type == RPCArg::Type::STR || type == RPCArg::Type::STR_HEX || type == RPCArg::Type::AMOUNT); + break; + case UniValue::VNUM: + CHECK_NONFATAL(type == RPCArg::Type::NUM || type == RPCArg::Type::AMOUNT || type == RPCArg::Type::RANGE); + break; + case UniValue::VBOOL: + CHECK_NONFATAL(type == RPCArg::Type::BOOL); + break; + case UniValue::VNULL: + // Null values are accepted in all arguments + break; + default: + CHECK_NONFATAL(false); + break; + } + } } } -- cgit v1.2.3