UPSTREAM MERGE BROKEN: Merge commit 'f617e05c38' into master

This commit is contained in:
Steven Roose 2019-05-01 19:15:40 +01:00
commit 7f894ae00b
No known key found for this signature in database
GPG key ID: 2F2A88D7F8D68E87
393 changed files with 7992 additions and 3340 deletions

View file

@ -7,11 +7,13 @@
#include <rpc/protocol.h>
#include <rpc/util.h>
#include <tinyformat.h>
#include <utilstrencodings.h>
#include <util/strencodings.h>
#include <policy/policy.h>
#include <assetsdir.h>
#include <core_io.h>
InitInterfaces* g_rpc_interfaces = nullptr;
// Converts a hex string to a public key if possible
CPubKey HexToPubKey(const std::string& hex_in)
{
@ -138,6 +140,99 @@ UniValue DescribeAddress(const CTxDestination& dest)
return boost::apply_visitor(DescribeAddressVisitor(), dest);
}
std::string RPCHelpMan::ToString() const
{
std::string ret;
ret += m_name;
bool is_optional{false};
for (const auto& arg : m_args) {
ret += " ";
if (arg.m_optional) {
if (!is_optional) ret += "( ";
is_optional = true;
} else {
// Currently we still support unnamed arguments, so any argument following an optional argument must also be optional
// If support for positional arguments is deprecated in the future, remove this line
assert(!is_optional);
}
ret += arg.ToString();
}
if (is_optional) ret += " )";
ret += "\n";
return ret;
}
std::string RPCArg::ToStringObj() const
{
std::string res = "\"" + m_name + "\":";
switch (m_type) {
case Type::STR:
return res + "\"str\"";
case Type::STR_HEX:
return res + "\"hex\"";
case Type::NUM:
return res + "n";
case Type::AMOUNT:
return res + "amount";
case Type::BOOL:
return res + "bool";
case Type::ARR:
res += "[";
for (const auto& i : m_inner) {
res += i.ToString() + ",";
}
return res + "...]";
case Type::OBJ:
case Type::OBJ_USER_KEYS:
// Currently unused, so avoid writing dead code
assert(false);
// no default case, so the compiler can warn about missing cases
}
assert(false);
}
std::string RPCArg::ToString() const
{
switch (m_type) {
case Type::STR_HEX:
case Type::STR: {
return "\"" + m_name + "\"";
}
case Type::NUM:
case Type::AMOUNT:
case Type::BOOL: {
return m_name;
}
case Type::OBJ:
case Type::OBJ_USER_KEYS: {
std::string res;
for (size_t i = 0; i < m_inner.size();) {
res += m_inner[i].ToStringObj();
if (++i < m_inner.size()) res += ",";
}
if (m_type == Type::OBJ) {
return "{" + res + "}";
} else {
return "{" + res + ",...}";
}
}
case Type::ARR: {
std::string res;
for (const auto& i : m_inner) {
res += i.ToString() + ",";
}
return "[" + res + "...]";
}
// no default case, so the compiler can warn about missing cases
}
assert(false);
}
//
// ELEMENTS
class BlindingPubkeyVisitor : public boost::static_visitor<CPubKey>
@ -306,3 +401,6 @@ UniValue AmountMapToUniv(const CAmountMap& balanceOrig, std::string strasset)
}
return obj;
}
// END ELEMENTS
//