Bitcoin ABC  0.24.7
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | List of all members
CScriptNum Class Reference

#include <script.h>

Public Member Functions

 CScriptNum (const int64_t &n)
 
 CScriptNum (const std::vector< uint8_t > &vch, bool fRequireMinimal, const size_t nMaxNumSize=MAXIMUM_ELEMENT_SIZE)
 
bool operator== (const int64_t &rhs) const
 
bool operator!= (const int64_t &rhs) const
 
bool operator<= (const int64_t &rhs) const
 
bool operator< (const int64_t &rhs) const
 
bool operator>= (const int64_t &rhs) const
 
bool operator> (const int64_t &rhs) const
 
bool operator== (const CScriptNum &rhs) const
 
bool operator!= (const CScriptNum &rhs) const
 
bool operator<= (const CScriptNum &rhs) const
 
bool operator< (const CScriptNum &rhs) const
 
bool operator>= (const CScriptNum &rhs) const
 
bool operator> (const CScriptNum &rhs) const
 
CScriptNum operator+ (const int64_t &rhs) const
 
CScriptNum operator- (const int64_t &rhs) const
 
CScriptNum operator+ (const CScriptNum &rhs) const
 
CScriptNum operator- (const CScriptNum &rhs) const
 
CScriptNum operator/ (const int64_t &rhs) const
 
CScriptNum operator/ (const CScriptNum &rhs) const
 
CScriptNum operator% (const int64_t &rhs) const
 
CScriptNum operator% (const CScriptNum &rhs) const
 
CScriptNumoperator+= (const CScriptNum &rhs)
 
CScriptNumoperator-= (const CScriptNum &rhs)
 
CScriptNum operator& (const int64_t &rhs) const
 
CScriptNum operator& (const CScriptNum &rhs) const
 
CScriptNumoperator&= (const CScriptNum &rhs)
 
CScriptNum operator- () const
 
CScriptNumoperator= (const int64_t &rhs)
 
CScriptNumoperator+= (const int64_t &rhs)
 
CScriptNumoperator-= (const int64_t &rhs)
 
CScriptNumoperator&= (const int64_t &rhs)
 
int getint () const
 
std::vector< uint8_t > getvch () const
 

Static Public Member Functions

static bool IsMinimallyEncoded (const std::vector< uint8_t > &vch, const size_t nMaxNumSize=CScriptNum::MAXIMUM_ELEMENT_SIZE)
 
static bool MinimallyEncode (std::vector< uint8_t > &data)
 
static std::vector< uint8_t > serialize (const int64_t &value)
 

Static Public Attributes

static const size_t MAXIMUM_ELEMENT_SIZE = 4
 Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers. More...
 

Static Private Member Functions

static int64_t set_vch (const std::vector< uint8_t > &vch)
 

Private Attributes

int64_t m_value
 

Detailed Description

Definition at line 215 of file script.h.

Constructor & Destructor Documentation

◆ CScriptNum() [1/2]

CScriptNum::CScriptNum ( const int64_t &  n)
inlineexplicit

Definition at line 228 of file script.h.

Here is the caller graph for this function:

◆ CScriptNum() [2/2]

CScriptNum::CScriptNum ( const std::vector< uint8_t > &  vch,
bool  fRequireMinimal,
const size_t  nMaxNumSize = MAXIMUM_ELEMENT_SIZE 
)
inlineexplicit

Definition at line 230 of file script.h.

Here is the call graph for this function:

Member Function Documentation

◆ getint()

int CScriptNum::getint ( ) const
inline

Definition at line 351 of file script.h.

Here is the caller graph for this function:

◆ getvch()

std::vector<uint8_t> CScriptNum::getvch ( ) const
inline

Definition at line 360 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsMinimallyEncoded()

bool CScriptNum::IsMinimallyEncoded ( const std::vector< uint8_t > &  vch,
const size_t  nMaxNumSize = CScriptNum::MAXIMUM_ELEMENT_SIZE 
)
static

Definition at line 299 of file script.cpp.

Here is the caller graph for this function:

◆ MinimallyEncode()

bool CScriptNum::MinimallyEncode ( std::vector< uint8_t > &  data)
static

Definition at line 327 of file script.cpp.

Here is the caller graph for this function:

◆ operator!=() [1/2]

bool CScriptNum::operator!= ( const CScriptNum rhs) const
inline

Definition at line 257 of file script.h.

Here is the call graph for this function:

◆ operator!=() [2/2]

bool CScriptNum::operator!= ( const int64_t &  rhs) const
inline

Definition at line 248 of file script.h.

Here is the caller graph for this function:

◆ operator%() [1/2]

CScriptNum CScriptNum::operator% ( const CScriptNum rhs) const
inline

Definition at line 296 of file script.h.

Here is the call graph for this function:

◆ operator%() [2/2]

CScriptNum CScriptNum::operator% ( const int64_t &  rhs) const
inline

Definition at line 293 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator&() [1/2]

CScriptNum CScriptNum::operator& ( const CScriptNum rhs) const
inline

Definition at line 310 of file script.h.

Here is the call graph for this function:

◆ operator&() [2/2]

CScriptNum CScriptNum::operator& ( const int64_t &  rhs) const
inline

Definition at line 307 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator&=() [1/2]

CScriptNum& CScriptNum::operator&= ( const CScriptNum rhs)
inline

Definition at line 314 of file script.h.

◆ operator&=() [2/2]

CScriptNum& CScriptNum::operator&= ( const int64_t &  rhs)
inline

Definition at line 346 of file script.h.

◆ operator+() [1/2]

CScriptNum CScriptNum::operator+ ( const CScriptNum rhs) const
inline

Definition at line 279 of file script.h.

Here is the call graph for this function:

◆ operator+() [2/2]

CScriptNum CScriptNum::operator+ ( const int64_t &  rhs) const
inline

Definition at line 273 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator+=() [1/2]

CScriptNum& CScriptNum::operator+= ( const CScriptNum rhs)
inline

Definition at line 300 of file script.h.

◆ operator+=() [2/2]

CScriptNum& CScriptNum::operator+= ( const int64_t &  rhs)
inline

Definition at line 328 of file script.h.

◆ operator-() [1/3]

CScriptNum CScriptNum::operator- ( ) const
inline

Definition at line 318 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator-() [2/3]

CScriptNum CScriptNum::operator- ( const CScriptNum rhs) const
inline

Definition at line 282 of file script.h.

Here is the call graph for this function:

◆ operator-() [3/3]

CScriptNum CScriptNum::operator- ( const int64_t &  rhs) const
inline

Definition at line 276 of file script.h.

Here is the call graph for this function:

◆ operator-=() [1/2]

CScriptNum& CScriptNum::operator-= ( const CScriptNum rhs)
inline

Definition at line 303 of file script.h.

◆ operator-=() [2/2]

CScriptNum& CScriptNum::operator-= ( const int64_t &  rhs)
inline

Definition at line 337 of file script.h.

◆ operator/() [1/2]

CScriptNum CScriptNum::operator/ ( const CScriptNum rhs) const
inline

Definition at line 289 of file script.h.

Here is the call graph for this function:

◆ operator/() [2/2]

CScriptNum CScriptNum::operator/ ( const int64_t &  rhs) const
inline

Definition at line 286 of file script.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<() [1/2]

bool CScriptNum::operator< ( const CScriptNum rhs) const
inline

Definition at line 263 of file script.h.

Here is the call graph for this function:

◆ operator<() [2/2]

bool CScriptNum::operator< ( const int64_t &  rhs) const
inline

Definition at line 250 of file script.h.

Here is the caller graph for this function:

◆ operator<=() [1/2]

bool CScriptNum::operator<= ( const CScriptNum rhs) const
inline

Definition at line 260 of file script.h.

Here is the call graph for this function:

◆ operator<=() [2/2]

bool CScriptNum::operator<= ( const int64_t &  rhs) const
inline

Definition at line 249 of file script.h.

Here is the caller graph for this function:

◆ operator=()

CScriptNum& CScriptNum::operator= ( const int64_t &  rhs)
inline

Definition at line 323 of file script.h.

◆ operator==() [1/2]

bool CScriptNum::operator== ( const CScriptNum rhs) const
inline

Definition at line 254 of file script.h.

Here is the call graph for this function:

◆ operator==() [2/2]

bool CScriptNum::operator== ( const int64_t &  rhs) const
inline

Definition at line 247 of file script.h.

Here is the caller graph for this function:

◆ operator>() [1/2]

bool CScriptNum::operator> ( const CScriptNum rhs) const
inline

Definition at line 269 of file script.h.

Here is the call graph for this function:

◆ operator>() [2/2]

bool CScriptNum::operator> ( const int64_t &  rhs) const
inline

Definition at line 252 of file script.h.

Here is the caller graph for this function:

◆ operator>=() [1/2]

bool CScriptNum::operator>= ( const CScriptNum rhs) const
inline

Definition at line 266 of file script.h.

Here is the call graph for this function:

◆ operator>=() [2/2]

bool CScriptNum::operator>= ( const int64_t &  rhs) const
inline

Definition at line 251 of file script.h.

Here is the caller graph for this function:

◆ serialize()

static std::vector<uint8_t> CScriptNum::serialize ( const int64_t &  value)
inlinestatic

Definition at line 362 of file script.h.

Here is the caller graph for this function:

◆ set_vch()

static int64_t CScriptNum::set_vch ( const std::vector< uint8_t > &  vch)
inlinestaticprivate

Definition at line 395 of file script.h.

Here is the caller graph for this function:

Member Data Documentation

◆ m_value

int64_t CScriptNum::m_value
private

Definition at line 414 of file script.h.

◆ MAXIMUM_ELEMENT_SIZE

const size_t CScriptNum::MAXIMUM_ELEMENT_SIZE = 4
static

Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.

The semantics are subtle, though: operands must be in the range [-2^31 +1...2^31 -1], but results may overflow (and are valid as long as they are not used in a subsequent numeric operation). CScriptNum enforces those semantics by storing results as an int64 and allowing out-of-range values to be returned as a vector of bytes but throwing an exception if arithmetic is done or the result is interpreted as an integer.

Definition at line 226 of file script.h.


The documentation for this class was generated from the following files: