diff --git a/src/core_write.cpp b/src/core_write.cpp --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -35,7 +35,7 @@ continue; } - if (op >= OP_NOP && op <= OP_NOP10) { + if (op >= OP_NOP && op < FIRST_UNDEFINED_OP_VALUE) { std::string str(GetOpName(op)); if (str.substr(0, 3) == std::string("OP_")) { ret += str.substr(3, std::string::npos) + " "; @@ -222,7 +222,7 @@ UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue)); out.pushKV("value", outValue); - out.pushKV("n", (int64_t)i); + out.pushKV("n", int64_t(i)); UniValue o(UniValue::VOBJ); ScriptPubKeyToUniv(txout.scriptPubKey, o, true); diff --git a/src/test/core_io_tests.cpp b/src/test/core_io_tests.cpp --- a/src/test/core_io_tests.cpp +++ b/src/test/core_io_tests.cpp @@ -145,4 +145,14 @@ std::runtime_error); } +void TestFormatRoundTrip(const std::string &script) { + BOOST_CHECK_EQUAL(script, FormatScript(ParseScript(script))); +} + +BOOST_AUTO_TEST_CASE(format_script_test) { + TestFormatRoundTrip("0 1 5 CHECKDATASIG CHECKSIG XOR NOP5 NOP10 " + "CHECKDATASIGVERIFY DEPTH RETURN VERIFY SPLIT INVERT " + "EQUAL HASH256 GREATERTHANOREQUAL RSHIFT"); +} + BOOST_AUTO_TEST_SUITE_END()