mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
Merge pull request #5264
af3208b Resolve issue 3166. These changes decode valid SIGHASH types on signatures in assembly (asm) representations of scriptSig scripts. This squashed commit incorporates substantial helpful feedback from jtimon, laanwj, and sipa. (mruddy)
This commit is contained in:
@@ -188,7 +188,7 @@ bool static IsDefinedHashtypeSignature(const valtype &vchSig) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool static CheckSignatureEncoding(const valtype &vchSig, unsigned int flags, ScriptError* serror) {
|
||||
bool CheckSignatureEncoding(const vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror) {
|
||||
// Empty signature. Not strictly DER encoded, but allowed to provide a
|
||||
// compact way to provide an invalid signature for use with CHECK(MULTI)SIG
|
||||
if (vchSig.size() == 0) {
|
||||
|
||||
@@ -83,6 +83,8 @@ enum
|
||||
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY = (1U << 9),
|
||||
};
|
||||
|
||||
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);
|
||||
|
||||
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
|
||||
|
||||
class BaseSignatureChecker
|
||||
|
||||
@@ -8,16 +8,6 @@
|
||||
#include "tinyformat.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
namespace {
|
||||
inline std::string ValueString(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
if (vch.size() <= 4)
|
||||
return strprintf("%d", CScriptNum(vch, false).getint());
|
||||
else
|
||||
return HexStr(vch);
|
||||
}
|
||||
} // anon namespace
|
||||
|
||||
using namespace std;
|
||||
|
||||
const char* GetOpName(opcodetype opcode)
|
||||
@@ -237,26 +227,3 @@ bool CScript::IsPushOnly() const
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string CScript::ToString() const
|
||||
{
|
||||
std::string str;
|
||||
opcodetype opcode;
|
||||
std::vector<unsigned char> vch;
|
||||
const_iterator pc = begin();
|
||||
while (pc < end())
|
||||
{
|
||||
if (!str.empty())
|
||||
str += " ";
|
||||
if (!GetOp(pc, opcode, vch))
|
||||
{
|
||||
str += "[error]";
|
||||
return str;
|
||||
}
|
||||
if (0 <= opcode && opcode <= OP_PUSHDATA4)
|
||||
str += ValueString(vch);
|
||||
else
|
||||
str += GetOpName(opcode);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -601,7 +601,6 @@ public:
|
||||
return (size() > 0 && *begin() == OP_RETURN);
|
||||
}
|
||||
|
||||
std::string ToString() const;
|
||||
void clear()
|
||||
{
|
||||
// The default std::vector::clear() does not release memory.
|
||||
|
||||
Reference in New Issue
Block a user