aboutsummaryrefslogtreecommitdiff
path: root/src/script.h
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2014-03-26 15:55:35 -0400
committerCory Fields <cory-nospam-@coryfields.com>2014-04-22 00:32:30 -0400
commit27bff74e39c4c2951a709114e0d565568a0554fa (patch)
tree6fb72eb4147931cffe1478ce539c68dc85454c40 /src/script.h
parent48d8eb1847d4218ee24ec1c27c73b90e03b1f007 (diff)
script: switch to CScriptNum usage for scripts
Diffstat (limited to 'src/script.h')
-rw-r--r--src/script.h51
1 files changed, 11 insertions, 40 deletions
diff --git a/src/script.h b/src/script.h
index 9bc06b2e07..7781ea61c7 100644
--- a/src/script.h
+++ b/src/script.h
@@ -374,7 +374,7 @@ const char* GetOpName(opcodetype opcode);
inline std::string ValueString(const std::vector<unsigned char>& vch)
{
if (vch.size() <= 4)
- return strprintf("%d", CBigNum(vch).getint());
+ return strprintf("%d", CScriptNum(vch).getint());
else
return HexStr(vch);
}
@@ -410,26 +410,10 @@ protected:
}
else
{
- CBigNum bn(n);
- *this << bn.getvch();
+ *this << CScriptNum::serialize(n);
}
return *this;
}
-
- CScript& push_uint64(uint64_t n)
- {
- if (n >= 1 && n <= 16)
- {
- push_back(n + (OP_1 - 1));
- }
- else
- {
- CBigNum bn(n);
- *this << bn.getvch();
- }
- return *this;
- }
-
public:
CScript() { }
CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }
@@ -452,35 +436,16 @@ public:
}
- //explicit CScript(char b) is not portable. Use 'signed char' or 'unsigned char'.
- explicit CScript(signed char b) { operator<<(b); }
- explicit CScript(short b) { operator<<(b); }
- explicit CScript(int b) { operator<<(b); }
- explicit CScript(long b) { operator<<(b); }
- explicit CScript(long long b) { operator<<(b); }
- explicit CScript(unsigned char b) { operator<<(b); }
- explicit CScript(unsigned int b) { operator<<(b); }
- explicit CScript(unsigned short b) { operator<<(b); }
- explicit CScript(unsigned long b) { operator<<(b); }
- explicit CScript(unsigned long long b) { operator<<(b); }
+ 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 CBigNum& b) { operator<<(b); }
explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
- //CScript& operator<<(char b) is not portable. Use 'signed char' or 'unsigned char'.
- CScript& operator<<(signed char b) { return push_int64(b); }
- CScript& operator<<(short b) { return push_int64(b); }
- CScript& operator<<(int b) { return push_int64(b); }
- CScript& operator<<(long b) { return push_int64(b); }
- CScript& operator<<(long long b) { return push_int64(b); }
- CScript& operator<<(unsigned char b) { return push_uint64(b); }
- CScript& operator<<(unsigned int b) { return push_uint64(b); }
- CScript& operator<<(unsigned short b) { return push_uint64(b); }
- CScript& operator<<(unsigned long b) { return push_uint64(b); }
- CScript& operator<<(unsigned long long b) { return push_uint64(b); }
+ CScript& operator<<(int64_t b) { return push_int64(b); }
CScript& operator<<(opcodetype opcode)
{
@@ -518,6 +483,12 @@ public:
return *this;
}
+ CScript& operator<<(const CScriptNum& b)
+ {
+ *this << b.getvch();
+ return *this;
+ }
+
CScript& operator<<(const std::vector<unsigned char>& b)
{
if (b.size() < OP_PUSHDATA1)