aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authormruddy <mruddy@users.noreply.github.com>2015-07-30 19:56:00 -0400
committermruddy <mruddy@users.noreply.github.com>2015-07-30 19:56:00 -0400
commitaf3208bfa6967d6b35aecf0ba35d9d6bf0f8317e (patch)
treef61b271e4446dae05172096c63d9320f4dbcaf2d /src/script
parent675d2feffa84a6ffeabac32aeed37f6a7f74bee3 (diff)
downloadbitcoin-af3208bfa6967d6b35aecf0ba35d9d6bf0f8317e.tar.xz
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.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/interpreter.cpp2
-rw-r--r--src/script/interpreter.h2
-rw-r--r--src/script/script.cpp33
-rw-r--r--src/script/script.h1
4 files changed, 3 insertions, 35 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 0b78fdf5a8..03af78bce5 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -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) {
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index 35d572f0ad..213e8c7651 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -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
diff --git a/src/script/script.cpp b/src/script/script.cpp
index fd33924732..58dbade0e2 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -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;
-}
diff --git a/src/script/script.h b/src/script/script.h
index e39ca57f4f..f0725bbbf6 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -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.