From 3d0b0336149c84c014fa03a04c672ef022df58ff Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Fri, 13 Jul 2018 13:27:29 +0200 Subject: [PATCH] Small stack pushes are not treated as int when converting scripts to asm - treat all as hex. --- src/core_write.cpp | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/core_write.cpp b/src/core_write.cpp index 6f9e2266a..a884ca1a3 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -87,27 +87,23 @@ string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode) return str; } if (0 <= opcode && opcode <= OP_PUSHDATA4) { - if (vch.size() <= static_cast::size_type>(4)) { - str += strprintf("%d", CScriptNum(vch, false).getint()); - } else { - // the IsUnspendable check makes sure not to try to decode OP_RETURN data that may match the format of a signature - if (fAttemptSighashDecode && !script.IsUnspendable()) { - string strSigHashDecode; - // goal: only attempt to decode a defined sighash type from data that looks like a signature within a scriptSig. - // this won't decode correctly formatted public keys in Pubkey or Multisig scripts due to - // the restrictions on the pubkey formats (see IsCompressedOrUncompressedPubKey) being incongruous with the - // checks in CheckSignatureEncoding. - if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, NULL)) { - const unsigned char chSigHashType = vch.back(); - if (mapSigHashTypes.count(chSigHashType)) { - strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]"; - vch.pop_back(); // remove the sighash type byte. it will be replaced by the decode. - } + // the IsUnspendable check makes sure not to try to decode OP_RETURN data that may match the format of a signature + if (fAttemptSighashDecode && !script.IsUnspendable()) { + string strSigHashDecode; + // goal: only attempt to decode a defined sighash type from data that looks like a signature within a scriptSig. + // this won't decode correctly formatted public keys in Pubkey or Multisig scripts due to + // the restrictions on the pubkey formats (see IsCompressedOrUncompressedPubKey) being incongruous with the + // checks in CheckSignatureEncoding. + if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, NULL)) { + const unsigned char chSigHashType = vch.back(); + if (mapSigHashTypes.count(chSigHashType)) { + strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]"; + vch.pop_back(); // remove the sighash type byte. it will be replaced by the decode. } - str += HexStr(vch) + strSigHashDecode; - } else { - str += HexStr(vch); } + str += HexStr(vch) + strSigHashDecode; + } else { + str += HexStr(vch); } } else { str += GetOpName(opcode);