aboutsummaryrefslogtreecommitdiff
path: root/src/script/script.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/script.h')
-rw-r--r--src/script/script.h40
1 files changed, 6 insertions, 34 deletions
diff --git a/src/script/script.h b/src/script/script.h
index dd2ab2f070..c1f2b66921 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2019 The Bitcoin Core developers
+// Copyright (c) 2009-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -193,7 +193,7 @@ enum opcodetype
// Maximum value that an opcode can be
static const unsigned int MAX_OPCODE = OP_NOP10;
-const char* GetOpName(opcodetype opcode);
+std::string GetOpName(opcodetype opcode);
class scriptnum_error : public std::runtime_error
{
@@ -329,7 +329,7 @@ public:
std::vector<unsigned char> result;
const bool neg = value < 0;
- uint64_t absvalue = neg ? -value : value;
+ uint64_t absvalue = neg ? ~static_cast<uint64_t>(value) + 1 : static_cast<uint64_t>(value);
while(absvalue)
{
@@ -412,35 +412,17 @@ public:
CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
- ADD_SERIALIZE_METHODS;
-
- template <typename Stream, typename Operation>
- inline void SerializationOp(Stream& s, Operation ser_action) {
- READWRITEAS(CScriptBase, *this);
- }
-
- CScript& operator+=(const CScript& b)
- {
- reserve(size() + b.size());
- insert(end(), b.begin(), b.end());
- return *this;
- }
-
- friend CScript operator+(const CScript& a, const CScript& b)
- {
- CScript ret = a;
- ret += b;
- return ret;
- }
+ SERIALIZE_METHODS(CScript, obj) { READWRITEAS(CScriptBase, obj); }
explicit CScript(int64_t b) { operator<<(b); }
-
explicit CScript(opcodetype b) { operator<<(b); }
explicit CScript(const CScriptNum& b) { operator<<(b); }
// delete non-existent constructor to defend against future introduction
// e.g. via prevector
explicit CScript(const std::vector<unsigned char>& b) = delete;
+ /** Delete non-existent operator to defend against future introduction */
+ CScript& operator<<(const CScript& b) = delete;
CScript& operator<<(int64_t b) { return push_int64(b); }
@@ -487,15 +469,6 @@ public:
return *this;
}
- CScript& operator<<(const CScript& b)
- {
- // I'm not sure if this should push the script or concatenate scripts.
- // If there's ever a use for pushing a script onto a script, delete this member fn
- assert(!"Warning: Pushing a CScript onto a CScript with << is probably not intended, use + to concatenate!");
- return *this;
- }
-
-
bool GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet) const
{
return GetScriptOp(pc, end(), opcodeRet, &vchRet);
@@ -506,7 +479,6 @@ public:
return GetScriptOp(pc, end(), opcodeRet, nullptr);
}
-
/** Encode/decode small integers: */
static int DecodeOP_N(opcodetype opcode)
{