diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include const std::function G_TRANSLATION_FUN = nullptr; @@ -225,7 +226,7 @@ std::string body; }; -static const char *http_errorstring(int code) { +static std::string http_errorstring(int code) { switch (code) { #if LIBEVENT_VERSION_NUMBER >= 0x02010300 case EVREQ_HTTP_TIMEOUT: diff --git a/src/core_read.cpp b/src/core_read.cpp --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -22,6 +22,7 @@ #include #include +#include CScript ParseScript(const std::string &s) { CScript result; @@ -34,12 +35,11 @@ continue; } - const char *name = GetOpName(static_cast(op)); - if (strcmp(name, "OP_UNKNOWN") == 0) { + std::string strName = GetOpName(static_cast(op)); + if (strName == "OP_UNKNOWN") { continue; } - std::string strName(name); mapOpNames[strName] = static_cast(op); // Convenience: OP_ADD and just ADD are both recognized: boost::algorithm::replace_first(strName, "OP_", ""); diff --git a/src/script/script.h b/src/script/script.h --- a/src/script/script.h +++ b/src/script/script.h @@ -198,7 +198,7 @@ // Maximum value that an opcode can be static const unsigned int MAX_OPCODE = FIRST_UNDEFINED_OP_VALUE - 1; -const char *GetOpName(opcodetype opcode); +std::string GetOpName(opcodetype opcode); /** * Check whether the given stack element data would be minimally pushed using diff --git a/src/script/script.cpp b/src/script/script.cpp --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -9,8 +9,9 @@ #include #include +#include -const char *GetOpName(opcodetype opcode) { +std::string GetOpName(opcodetype opcode) { switch (opcode) { // push value case OP_0: diff --git a/src/script/script_error.h b/src/script/script_error.h --- a/src/script/script_error.h +++ b/src/script/script_error.h @@ -6,6 +6,8 @@ #ifndef BITCOIN_SCRIPT_SCRIPT_ERROR_H #define BITCOIN_SCRIPT_SCRIPT_ERROR_H +#include + enum class ScriptError { OK = 0, UNKNOWN, @@ -85,7 +87,7 @@ #define SCRIPT_ERR_LAST ScriptError::ERROR_COUNT -const char *ScriptErrorString(const ScriptError error); +std::string ScriptErrorString(const ScriptError error); namespace { diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp --- a/src/script/script_error.cpp +++ b/src/script/script_error.cpp @@ -5,7 +5,9 @@ #include