Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/util.cpp
// Copyright (c) 2017-2019 The Bitcoin Core developers | // Copyright (c) 2017-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <keystore.h> | #include <keystore.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <rpc/util.h> | #include <rpc/util.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/string.h> | |||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <boost/variant/static_visitor.hpp> | #include <boost/variant/static_visitor.hpp> | ||||
NodeContext *g_rpc_node = nullptr; | NodeContext *g_rpc_node = nullptr; | ||||
void RPCTypeCheck(const UniValue ¶ms, | void RPCTypeCheck(const UniValue ¶ms, | ||||
▲ Show 20 Lines • Show All 622 Lines • ▼ Show 20 Lines | switch (m_type) { | ||||
} | } | ||||
case Type::NUM: | case Type::NUM: | ||||
case Type::AMOUNT: | case Type::AMOUNT: | ||||
case Type::BOOL: { | case Type::BOOL: { | ||||
return m_name; | return m_name; | ||||
} | } | ||||
case Type::OBJ: | case Type::OBJ: | ||||
case Type::OBJ_USER_KEYS: { | case Type::OBJ_USER_KEYS: { | ||||
std::string res; | const std::string res = Join(m_inner, ",", [&](const RPCArg &i) { | ||||
for (size_t i = 0; i < m_inner.size();) { | return i.ToStringObj(oneline); | ||||
res += m_inner[i].ToStringObj(oneline); | }); | ||||
if (++i < m_inner.size()) { | |||||
res += ","; | |||||
} | |||||
} | |||||
if (m_type == Type::OBJ) { | if (m_type == Type::OBJ) { | ||||
return "{" + res + "}"; | return "{" + res + "}"; | ||||
} else { | } else { | ||||
return "{" + res + ",...}"; | return "{" + res + ",...}"; | ||||
} | } | ||||
} | } | ||||
case Type::ARR: { | case Type::ARR: { | ||||
std::string res; | std::string res; | ||||
Show All 10 Lines |