From 066e2a1403fe306787a2ce0c8571aa9de57386cf Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 24 Sep 2014 22:24:46 -0400 Subject: script: move CScriptID to standard.h and add a ctor for creating them from CScripts This allows for a reversal of the current behavior. This: CScript foo; CScriptID bar(foo.GetID()); Becomes: CScript foo; CScriptID bar(foo); This way, CScript is no longer dependent on CScriptID or Hash(); --- src/script/script.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/script/script.h') diff --git a/src/script/script.h b/src/script/script.h index caf176476..4d685f559 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -610,12 +610,6 @@ public: } return str; } - - CScriptID GetID() const - { - return CScriptID(Hash160(*this)); - } - void clear() { // The default std::vector::clear() does not release memory. -- cgit v1.2.3 From e9ca4280f3abb8b2b6fa35a41e881996278ebfff Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 24 Sep 2014 22:54:08 -0400 Subject: script: add ToByteVector() for converting anything with begin/end This should move to a util header once their dependencies are cleaned up. --- src/script/script.h | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'src/script/script.h') diff --git a/src/script/script.h b/src/script/script.h index 4d685f559..6676e852a 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -16,6 +16,12 @@ static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes +template +std::vector ToByteVector(const T& in) +{ + return std::vector(in.begin(), in.end()); +} + /** Script opcodes */ enum opcodetype { @@ -358,7 +364,6 @@ public: CScript(int64_t b) { operator<<(b); } explicit CScript(opcodetype b) { operator<<(b); } - explicit CScript(const uint256& b) { operator<<(b); } explicit CScript(const CScriptNum& b) { operator<<(b); } explicit CScript(const std::vector& b) { operator<<(b); } @@ -373,28 +378,6 @@ public: return *this; } - CScript& operator<<(const uint160& b) - { - insert(end(), sizeof(b)); - insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b)); - return *this; - } - - CScript& operator<<(const uint256& b) - { - insert(end(), sizeof(b)); - insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b)); - return *this; - } - - CScript& operator<<(const CPubKey& key) - { - assert(key.size() < OP_PUSHDATA1); - insert(end(), (unsigned char)key.size()); - insert(end(), key.begin(), key.end()); - return *this; - } - CScript& operator<<(const CScriptNum& b) { *this << b.getvch(); -- cgit v1.2.3 From db8eb54bd7239ff2b046fe34b1c8d692860c6b5b Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 30 Sep 2014 19:45:20 -0400 Subject: script: move ToString and ValueString out of the header --- src/script/script.h | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'src/script/script.h') diff --git a/src/script/script.h b/src/script/script.h index 6676e852a..4f6ee0c52 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -318,13 +318,6 @@ private: int64_t m_value; }; -inline std::string ValueString(const std::vector& vch) -{ - if (vch.size() <= 4) - return strprintf("%d", CScriptNum(vch).getint()); - else - return HexStr(vch); -} /** Serialized script, used inside transaction inputs and outputs */ class CScript : public std::vector @@ -571,28 +564,7 @@ public: return (size() > 0 && *begin() == OP_RETURN); } - std::string ToString() const - { - std::string str; - opcodetype opcode; - std::vector 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; - } + std::string ToString() const; void clear() { // The default std::vector::clear() does not release memory. -- cgit v1.2.3 From 85c579e3a63cf505d6cedc454755265572e97d3e Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 24 Sep 2014 23:32:36 -0400 Subject: script: add a slew of includes all around and drop includes from script.h Lots of files ended up with indirect includes from script.h. --- src/script/script.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/script/script.h') diff --git a/src/script/script.h b/src/script/script.h index 4f6ee0c52..a68924c73 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -6,13 +6,13 @@ #ifndef H_BITCOIN_SCRIPT #define H_BITCOIN_SCRIPT -#include "key.h" -#include "tinyformat.h" -#include "utilstrencodings.h" - +#include +#include +#include #include - -#include +#include +#include +#include static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes -- cgit v1.2.3