Bugfix: Replace "URL" with "URI" where we aren't actually working with URLs
[novacoin.git] / src / bignum.h
index baa9cb5..c7c2ff1 100644 (file)
@@ -1,18 +1,17 @@
 // Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2011 The Bitcoin developers
+// Copyright (c) 2009-2012 The Bitcoin developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
 #ifndef BITCOIN_BIGNUM_H
 #define BITCOIN_BIGNUM_H
 
-#include <stdint.h>
-
 #include <stdexcept>
 #include <vector>
 #include <openssl/bn.h>
 
 #include "util.h"
 
+/** Errors thrown by the bignum class */
 class bignum_error : public std::runtime_error
 {
 public:
@@ -20,7 +19,7 @@ public:
 };
 
 
-
+/** RAII encapsulated BN_CTX (OpenSSL bignum context) */
 class CAutoBN_CTX
 {
 protected:
@@ -48,7 +47,7 @@ public:
 };
 
 
-
+/** C++ wrapper for BIGNUM (OpenSSl bignum) */
 class CBigNum : public BIGNUM
 {
 public:
@@ -83,12 +82,12 @@ public:
     CBigNum(short n)            { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
     CBigNum(int n)              { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
     CBigNum(long n)             { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
-    CBigNum(int64_t n)          { BN_init(this); setint64(n); }
+    CBigNum(int64 n)            { BN_init(this); setint64(n); }
     CBigNum(unsigned char n)    { BN_init(this); setulong(n); }
     CBigNum(unsigned short n)   { BN_init(this); setulong(n); }
     CBigNum(unsigned int n)     { BN_init(this); setulong(n); }
     CBigNum(unsigned long n)    { BN_init(this); setulong(n); }
-    CBigNum(uint64_t n)         { BN_init(this); setuint64(n); }
+    CBigNum(uint64 n)           { BN_init(this); setuint64(n); }
     explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }
 
     explicit CBigNum(const std::vector<unsigned char>& vch)
@@ -122,12 +121,12 @@ public:
             return (n > std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
     }
 
-    void setint64(int64_t n)
+    void setint64(int64 n)
     {
         unsigned char pch[sizeof(n) + 6];
         unsigned char* p = pch + 4;
         bool fNegative = false;
-        if (n < (int64_t)0)
+        if (n < (int64)0)
         {
             n = -n;
             fNegative = true;
@@ -157,7 +156,7 @@ public:
         BN_mpi2bn(pch, p - pch, this);
     }
 
-    void setuint64(uint64_t n)
+    void setuint64(uint64 n)
     {
         unsigned char pch[sizeof(n) + 6];
         unsigned char* p = pch + 4;
@@ -245,7 +244,7 @@ public:
     std::vector<unsigned char> getvch() const
     {
         unsigned int nSize = BN_bn2mpi(this, NULL);
-        if (nSize < 4)
+        if (nSize <= 4)
             return std::vector<unsigned char>();
         std::vector<unsigned char> vch(nSize);
         BN_bn2mpi(this, &vch[0]);