INCLUDEPATH += src src/json src/qt
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
-DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
+DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE __STDC_FORMAT_MACROS
CONFIG += no_include_pwd
CONFIG += thread
CONFIG += static
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
ss1 << nKey << vchKey;
- uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
+ uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();
CDataStream ss2(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
- uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
+ uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
}
std::vector<unsigned char> vchGroupKey = GetGroup();
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
- uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
+ uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();
CDataStream ss2(SER_GETHASH, 0);
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
- uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
+ uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
}
-bool CAddrInfo::IsTerrible(int64 nNow) const
+bool CAddrInfo::IsTerrible(int64_t nNow) const
{
if (nLastTry && nLastTry >= nNow-60) // never remove things tried the last minute
return false;
return false;
}
-double CAddrInfo::GetChance(int64 nNow) const
+double CAddrInfo::GetChance(int64_t nNow) const
{
double fChance = 1.0;
- int64 nSinceLastSeen = nNow - nTime;
- int64 nSinceLastTry = nNow - nLastTry;
+ int64_t nSinceLastSeen = nNow - nTime;
+ int64_t nSinceLastTry = nNow - nLastTry;
if (nSinceLastSeen < 0) nSinceLastSeen = 0;
if (nSinceLastTry < 0) nSinceLastTry = 0;
// random shuffle the first few elements (using the entire list)
// find the least recently tried among them
- int64 nOldest = -1;
+ int64_t nOldest = -1;
int nOldestPos = -1;
for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++)
{
return;
}
-void CAddrMan::Good_(const CService &addr, int64 nTime)
+void CAddrMan::Good_(const CService &addr, int64_t nTime)
{
// printf("Good: addr=%s\n", addr.ToString().c_str());
MakeTried(info, nId, nUBucket);
}
-bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePenalty)
+bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty)
{
if (!addr.IsRoutable())
return false;
{
// periodically update nTime
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
- int64 nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
+ int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty))
- pinfo->nTime = max((int64)0, addr.nTime - nTimePenalty);
+ pinfo->nTime = max((int64_t)0, addr.nTime - nTimePenalty);
// add services
pinfo->nServices |= addr.nServices;
return false;
} else {
pinfo = Create(addr, source, &nId);
- pinfo->nTime = max((int64)0, (int64)pinfo->nTime - nTimePenalty);
+ pinfo->nTime = max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty);
// printf("Added %s [nTime=%fhr]\n", pinfo->ToString().c_str(), (GetAdjustedTime() - pinfo->nTime) / 3600.0);
nNew++;
fNew = true;
return fNew;
}
-void CAddrMan::Attempt_(const CService &addr, int64 nTime)
+void CAddrMan::Attempt_(const CService &addr, int64_t nTime)
{
CAddrInfo *pinfo = Find(addr);
}
}
-void CAddrMan::Connected_(const CService &addr, int64 nTime)
+void CAddrMan::Connected_(const CService &addr, int64_t nTime)
{
CAddrInfo *pinfo = Find(addr);
return;
// update info
- int64 nUpdateInterval = 20 * 60;
+ int64_t nUpdateInterval = 20 * 60;
if (nTime - info.nTime > nUpdateInterval)
info.nTime = nTime;
}
CNetAddr source;
// last successful connection by us
- int64 nLastSuccess;
+ int64_t nLastSuccess;
// last try whatsoever by us:
- // int64 CAddress::nLastTry
+ // int64_t CAddress::nLastTry
// connection attempts since last successful attempt
int nAttempts;
}
// Determine whether the statistics about this entry are bad enough so that it can just be deleted
- bool IsTerrible(int64 nNow = GetAdjustedTime()) const;
+ bool IsTerrible(int64_t nNow = GetAdjustedTime()) const;
// Calculate the relative chance this entry should be given when selecting nodes to connect to
- double GetChance(int64 nNow = GetAdjustedTime()) const;
+ double GetChance(int64_t nNow = GetAdjustedTime()) const;
};
void MakeTried(CAddrInfo& info, int nId, int nOrigin);
// Mark an entry "good", possibly moving it from "new" to "tried".
- void Good_(const CService &addr, int64 nTime);
+ void Good_(const CService &addr, int64_t nTime);
// Add an entry to the "new" table.
- bool Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePenalty);
+ bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty);
// Mark an entry as attempted to connect.
- void Attempt_(const CService &addr, int64 nTime);
+ void Attempt_(const CService &addr, int64_t nTime);
// Select an address to connect to.
// nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100)
void GetAddr_(std::vector<CAddress> &vAddr);
// Mark an entry as currently-connected-to.
- void Connected_(const CService &addr, int64 nTime);
+ void Connected_(const CService &addr, int64_t nTime);
public:
}
// Add a single address.
- bool Add(const CAddress &addr, const CNetAddr& source, int64 nTimePenalty = 0)
+ bool Add(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty = 0)
{
bool fRet = false;
{
}
// Add multiple addresses.
- bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64 nTimePenalty = 0)
+ bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
{
int nAdd = 0;
{
}
// Mark an entry as accessible.
- void Good(const CService &addr, int64 nTime = GetAdjustedTime())
+ void Good(const CService &addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
}
// Mark an entry as connection attempted to.
- void Attempt(const CService &addr, int64 nTime = GetAdjustedTime())
+ void Attempt(const CService &addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
}
// Mark an entry as currently-connected-to.
- void Connected(const CService &addr, int64 nTime = GetAdjustedTime())
+ void Connected(const CService &addr, int64_t nTime = GetAdjustedTime())
{
{
LOCK(cs);
return strprintf(
"CAlert(\n"
" nVersion = %d\n"
- " nRelayUntil = %" PRI64d "\n"
- " nExpiration = %" PRI64d "\n"
+ " nRelayUntil = %" PRId64 "\n"
+ " nExpiration = %" PRId64 "\n"
" nID = %d\n"
" nCancel = %d\n"
" setCancel = %s\n"
{
public:
int nVersion;
- int64 nRelayUntil; // when newer nodes stop relaying to newer nodes
- int64 nExpiration;
+ int64_t nRelayUntil; // when newer nodes stop relaying to newer nodes
+ int64_t nExpiration;
int nID;
int nCancel;
std::set<int> setCancel;
#include <stdexcept>
#include <vector>
#include <openssl/bn.h>
-
-#include "util.h" // for uint64
+#include "util.h"
/** Errors thrown by the bignum class */
class bignum_error : public std::runtime_error
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 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 n) { BN_init(this); setuint64(n); }
explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }
explicit CBigNum(const std::vector<unsigned char>& vch)
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
}
- void setint64(int64 sn)
+ void setint64(int64_t sn)
{
unsigned char pch[sizeof(sn) + 6];
unsigned char* p = pch + 4;
bool fNegative;
- uint64 n;
+ uint64_t n;
- if (sn < (int64)0)
+ if (sn < (int64_t)0)
{
// Since the minimum signed integer cannot be represented as positive so long as its type is signed, and it's not well-defined what happens if you make it unsigned before negating it, we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
n = -(sn + 1);
BN_mpi2bn(pch, p - pch, this);
}
- uint64 getuint64()
+ uint64_t getuint64()
{
unsigned int nSize = BN_bn2mpi(this, NULL);
if (nSize < 4)
BN_bn2mpi(this, &vch[0]);
if (vch.size() > 4)
vch[4] &= 0x7f;
- uint64 n = 0;
+ uint64_t n = 0;
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
((unsigned char*)&n)[i] = vch[j];
return n;
}
- void setuint64(uint64 n)
+ void setuint64(uint64_t n)
{
unsigned char pch[sizeof(n) + 6];
unsigned char* p = pch + 4;
}
}
-int64 AmountFromValue(const Value& value)
+int64_t AmountFromValue(const Value& value)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > MAX_MONEY)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
- int64 nAmount = roundint64(dAmount * COIN);
+ int64_t nAmount = roundint64(dAmount * COIN);
if (!MoneyRange(nAmount))
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
return nAmount;
}
-Value ValueFromAmount(int64 amount)
+Value ValueFromAmount(int64_t amount)
{
return (double)amount / (double)COIN;
}
extern const CRPCTable tableRPC;
-extern int64 nWalletUnlockTime;
-extern int64 AmountFromValue(const json_spirit::Value& value);
-extern json_spirit::Value ValueFromAmount(int64 amount);
+extern int64_t nWalletUnlockTime;
+extern int64_t AmountFromValue(const json_spirit::Value& value);
+extern json_spirit::Value ValueFromAmount(int64_t amount);
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
extern double GetPoWMHashPS();
void CDBEnv::Flush(bool fShutdown)
{
- int64 nStart = GetTimeMillis();
+ int64_t nStart = GetTimeMillis();
// Flush log data to the actual data file
// on all files that are not in use
printf("Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started");
else
mi++;
}
- printf("DBFlush(%s)%s ended %15" PRI64d "ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
+ printf("DBFlush(%s)%s ended %15" PRId64 "ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart);
if (fShutdown)
{
char** listp;
NewThread(ThreadScriptCheck, NULL);
}
- int64 nStart;
+ int64_t nStart;
// ********************************************************* Step 5: verify database integrity
if (mapArgs.count("-reservebalance")) // ppcoin: reserve balance amount
{
- int64 nReserveBalance = 0;
+ int64_t nReserveBalance = 0;
if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
{
InitError(_("Invalid amount for -reservebalance=<amount>"));
printf("Shutdown requested. Exiting.\n");
return false;
}
- printf(" block index %15" PRI64d "ms\n", GetTimeMillis() - nStart);
+ printf(" block index %15" PRId64 "ms\n", GetTimeMillis() - nStart);
if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree"))
{
}
printf("%s", strErrors.str().c_str());
- printf(" wallet %15" PRI64d "ms\n", GetTimeMillis() - nStart);
+ printf(" wallet %15" PRId64 "ms\n", GetTimeMillis() - nStart);
RegisterWallet(pwalletMain);
printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
nStart = GetTimeMillis();
pwalletMain->ScanForWalletTransactions(pindexRescan, true);
- printf(" rescan %15" PRI64d "ms\n", GetTimeMillis() - nStart);
+ printf(" rescan %15" PRId64 "ms\n", GetTimeMillis() - nStart);
}
// ********************************************************* Step 9: import blocks
printf("Invalid or missing peers.dat; recreating\n");
}
- printf("Loaded %i addresses from peers.dat %" PRI64d "ms\n",
+ printf("Loaded %i addresses from peers.dat %" PRId64 "ms\n",
addrman.size(), GetTimeMillis() - nStart);
// ********************************************************* Step 11: start node
if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3)
strMyName = EncodeAddress(GetLocalAddress(&addrConnect));
if (strMyName == "")
- strMyName = strprintf("x%" PRI64u "", GetRand(1000000000));
+ strMyName = strprintf("x%" PRIu64 "", GetRand(1000000000));
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str());
Send(hSocket, strprintf("WHO #novacoin%02d\r", channel_number).c_str());
}
- int64 nStart = GetTime();
+ int64_t nStart = GetTime();
string strLine;
strLine.reserve(10000);
while (!fShutdown && RecvLineIRC(hSocket, strLine))
}
// Get time weight
-int64 GetWeight(int64 nIntervalBeginning, int64 nIntervalEnd)
+int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd)
{
// Kernel hash weight starts from 0 at the 30-day min age
// this change increases active coins participating the hash and helps
//
// Maximum TimeWeight is 90 days.
- return min(nIntervalEnd - nIntervalBeginning - nStakeMinAge, (int64)nStakeMaxAge);
+ return min(nIntervalEnd - nIntervalBeginning - nStakeMinAge, (int64_t)nStakeMaxAge);
}
// Get the last stake modifier and its generation time from a given block
-static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64& nStakeModifier, int64& nModifierTime)
+static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64_t& nStakeModifier, int64_t& nModifierTime)
{
if (!pindex)
return error("GetLastStakeModifier: null pindex");
}
// Get selection interval section (in seconds)
-static int64 GetStakeModifierSelectionIntervalSection(int nSection)
+static int64_t GetStakeModifierSelectionIntervalSection(int nSection)
{
assert (nSection >= 0 && nSection < 64);
return (nModifierInterval * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))));
}
// Get stake modifier selection interval (in seconds)
-static int64 GetStakeModifierSelectionInterval()
+static int64_t GetStakeModifierSelectionInterval()
{
- int64 nSelectionInterval = 0;
+ int64_t nSelectionInterval = 0;
for (int nSection=0; nSection<64; nSection++)
nSelectionInterval += GetStakeModifierSelectionIntervalSection(nSection);
return nSelectionInterval;
// select a block from the candidate blocks in vSortedByTimestamp, excluding
// already selected blocks in vSelectedBlocks, and with timestamp up to
// nSelectionIntervalStop.
-static bool SelectBlockFromCandidates(vector<pair<int64, uint256> >& vSortedByTimestamp, map<uint256, const CBlockIndex*>& mapSelectedBlocks,
- int64 nSelectionIntervalStop, uint64 nStakeModifierPrev, const CBlockIndex** pindexSelected)
+static bool SelectBlockFromCandidates(vector<pair<int64_t, uint256> >& vSortedByTimestamp, map<uint256, const CBlockIndex*>& mapSelectedBlocks,
+ int64_t nSelectionIntervalStop, uint64_t nStakeModifierPrev, const CBlockIndex** pindexSelected)
{
bool fSelected = false;
uint256 hashBest = 0;
*pindexSelected = (const CBlockIndex*) 0;
- BOOST_FOREACH(const PAIRTYPE(int64, uint256)& item, vSortedByTimestamp)
+ BOOST_FOREACH(const PAIRTYPE(int64_t, uint256)& item, vSortedByTimestamp)
{
if (!mapBlockIndex.count(item.second))
return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str());
// block. This is to make it difficult for an attacker to gain control of
// additional bits in the stake modifier, even after generating a chain of
// blocks.
-bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64& nStakeModifier, bool& fGeneratedStakeModifier)
+bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier)
{
nStakeModifier = 0;
fGeneratedStakeModifier = false;
// First find current stake modifier and its generation block time
// if it's not old enough, return the same stake modifier
- int64 nModifierTime = 0;
+ int64_t nModifierTime = 0;
if (!GetLastStakeModifier(pindexPrev, nStakeModifier, nModifierTime))
return error("ComputeNextStakeModifier: unable to get last modifier");
if (fDebug)
{
- printf("ComputeNextStakeModifier: prev modifier=0x%016" PRI64x " time=%s epoch=%u\n", nStakeModifier, DateTimeStrFormat(nModifierTime).c_str(), (unsigned int)nModifierTime);
+ printf("ComputeNextStakeModifier: prev modifier=0x%016" PRIx64 " time=%s epoch=%u\n", nStakeModifier, DateTimeStrFormat(nModifierTime).c_str(), (unsigned int)nModifierTime);
}
if (nModifierTime / nModifierInterval >= pindexPrev->GetBlockTime() / nModifierInterval)
{
}
// Sort candidate blocks by timestamp
- vector<pair<int64, uint256> > vSortedByTimestamp;
+ vector<pair<int64_t, uint256> > vSortedByTimestamp;
vSortedByTimestamp.reserve(64 * nModifierInterval / nStakeTargetSpacing);
- int64 nSelectionInterval = GetStakeModifierSelectionInterval();
- int64 nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval;
+ int64_t nSelectionInterval = GetStakeModifierSelectionInterval();
+ int64_t nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval;
const CBlockIndex* pindex = pindexPrev;
while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart)
{
sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end());
// Select 64 blocks from candidate blocks to generate stake modifier
- uint64 nStakeModifierNew = 0;
- int64 nSelectionIntervalStop = nSelectionIntervalStart;
+ uint64_t nStakeModifierNew = 0;
+ int64_t nSelectionIntervalStop = nSelectionIntervalStart;
map<uint256, const CBlockIndex*> mapSelectedBlocks;
for (int nRound=0; nRound<min(64, (int)vSortedByTimestamp.size()); nRound++)
{
if (!SelectBlockFromCandidates(vSortedByTimestamp, mapSelectedBlocks, nSelectionIntervalStop, nStakeModifier, &pindex))
return error("ComputeNextStakeModifier: unable to select block at round %d", nRound);
// write the entropy bit of the selected block
- nStakeModifierNew |= (((uint64)pindex->GetStakeEntropyBit()) << nRound);
+ nStakeModifierNew |= (((uint64_t)pindex->GetStakeEntropyBit()) << nRound);
// add the selected block from candidates to selected list
mapSelectedBlocks.insert(make_pair(pindex->GetBlockHash(), pindex));
if (fDebug && GetBoolArg("-printstakemodifier"))
}
if (fDebug)
{
- printf("ComputeNextStakeModifier: new modifier=0x%016" PRI64x " time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime()).c_str());
+ printf("ComputeNextStakeModifier: new modifier=0x%016" PRIx64 " time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime()).c_str());
}
nStakeModifier = nStakeModifierNew;
// The stake modifier used to hash for a stake kernel is chosen as the stake
// modifier about a selection interval later than the coin generating the kernel
-static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier, int& nStakeModifierHeight, int64& nStakeModifierTime, bool fPrintProofOfStake)
+static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier, int& nStakeModifierHeight, int64_t& nStakeModifierTime, bool fPrintProofOfStake)
{
nStakeModifier = 0;
if (!mapBlockIndex.count(hashBlockFrom))
const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom];
nStakeModifierHeight = pindexFrom->nHeight;
nStakeModifierTime = pindexFrom->GetBlockTime();
- int64 nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval();
+ int64_t nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval();
const CBlockIndex* pindex = pindexFrom;
// loop to find the stake modifier later by a selection interval
while (nStakeModifierTime < pindexFrom->GetBlockTime() + nStakeModifierSelectionInterval)
return true;
}
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier)
+bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier)
{
int nStakeModifierHeight;
- int64 nStakeModifierTime;
+ int64_t nStakeModifierTime;
return GetKernelStakeModifier(hashBlockFrom, nStakeModifier, nStakeModifierHeight, nStakeModifierTime, false);
}
CBigNum bnTargetPerCoinDay;
bnTargetPerCoinDay.SetCompact(nBits);
- int64 nValueIn = txPrev.vout[prevout.n].nValue;
+ int64_t nValueIn = txPrev.vout[prevout.n].nValue;
uint256 hashBlockFrom = blockFrom.GetHash();
- CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64)txPrev.nTime, (int64)nTimeTx) / COIN / (24 * 60 * 60);
+ CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60);
targetProofOfStake = (bnCoinDayWeight * bnTargetPerCoinDay).getuint256();
// Calculate hash
CDataStream ss(SER_GETHASH, 0);
- uint64 nStakeModifier = 0;
+ uint64_t nStakeModifier = 0;
int nStakeModifierHeight = 0;
- int64 nStakeModifierTime = 0;
+ int64_t nStakeModifierTime = 0;
if (!GetKernelStakeModifier(hashBlockFrom, nStakeModifier, nStakeModifierHeight, nStakeModifierTime, fPrintProofOfStake))
return false;
hashProofOfStake = Hash(ss.begin(), ss.end());
if (fPrintProofOfStake)
{
- printf("CheckStakeKernelHash() : using modifier 0x%016" PRI64x " at height=%d timestamp=%s for block from height=%d timestamp=%s\n",
+ printf("CheckStakeKernelHash() : using modifier 0x%016" PRIx64 " at height=%d timestamp=%s for block from height=%d timestamp=%s\n",
nStakeModifier, nStakeModifierHeight,
DateTimeStrFormat(nStakeModifierTime).c_str(),
mapBlockIndex[hashBlockFrom]->nHeight,
DateTimeStrFormat(blockFrom.GetBlockTime()).c_str());
- printf("CheckStakeKernelHash() : check modifier=0x%016" PRI64x " nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n",
+ printf("CheckStakeKernelHash() : check modifier=0x%016" PRIx64 " nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n",
nStakeModifier,
nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx,
hashProofOfStake.ToString().c_str());
return false;
if (fDebug && !fPrintProofOfStake)
{
- printf("CheckStakeKernelHash() : using modifier 0x%016" PRI64x " at height=%d timestamp=%s for block from height=%d timestamp=%s\n",
+ printf("CheckStakeKernelHash() : using modifier 0x%016" PRIx64 " at height=%d timestamp=%s for block from height=%d timestamp=%s\n",
nStakeModifier, nStakeModifierHeight,
DateTimeStrFormat(nStakeModifierTime).c_str(),
mapBlockIndex[hashBlockFrom]->nHeight,
DateTimeStrFormat(blockFrom.GetBlockTime()).c_str());
- printf("CheckStakeKernelHash() : pass modifier=0x%016" PRI64x " nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n",
+ printf("CheckStakeKernelHash() : pass modifier=0x%016" PRIx64 " nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n",
nStakeModifier,
nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx,
hashProofOfStake.ToString().c_str());
}
// Scan given coins set for kernel solution
-bool ScanForStakeKernelHash(MetaMap &mapMeta, KernelSearchSettings &settings, CoinsSet::value_type &kernelcoin, unsigned int &nTimeTx, unsigned int &nBlockTime, uint64 &nKernelsTried, uint64 &nCoinDaysTried)
+bool ScanForStakeKernelHash(MetaMap &mapMeta, KernelSearchSettings &settings, CoinsSet::value_type &kernelcoin, unsigned int &nTimeTx, unsigned int &nBlockTime, uint64_t &nKernelsTried, uint64_t &nCoinDaysTried)
{
uint256 hashProofOfStake = 0;
CTxIndex txindex = (*meta_item).second.first.first;
CBlock block = (*meta_item).second.second.first;
- uint64 nStakeModifier = (*meta_item).second.second.second;
+ uint64_t nStakeModifier = (*meta_item).second.second.second;
// Get coin
CoinsSet::value_type pcoin = meta_item->second.first.second;
unsigned int nTxOffset = txindex.pos.nTxPos - txindex.pos.nBlockPos;
// Current timestamp scanning interval
- unsigned int nCurrentSearchInterval = min((int64)settings.nSearchInterval, (int64)nMaxStakeSearchInterval);
+ unsigned int nCurrentSearchInterval = min((int64_t)settings.nSearchInterval, (int64_t)nMaxStakeSearchInterval);
nBlockTime = block.nTime;
CBigNum bnTargetPerCoinDay;
bnTargetPerCoinDay.SetCompact(settings.nBits);
- int64 nValueIn = pcoin.first->vout[pcoin.second].nValue;
+ int64_t nValueIn = pcoin.first->vout[pcoin.second].nValue;
// Search backward in time from the given timestamp
// Search nSearchInterval seconds back up to nMaxStakeSearchInterval
for (unsigned int n=0; n<nCurrentSearchInterval && fCoinsDataActual && !fShutdown; n++)
{
nTimeTx = settings.nTime - n;
- CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64)pcoin.first->nTime, (int64)nTimeTx) / COIN / (24 * 60 * 60);
+ CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)pcoin.first->nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60);
CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
// Build kernel
if (bnTargetProofOfStake >= CBigNum(hashProofOfStake))
{
if (fDebug)
- printf("nStakeModifier=0x%016" PRI64x ", nBlockTime=%u nTxOffset=%u nTxPrevTime=%u nVout=%u nTimeTx=%u hashProofOfStake=%s Success=true\n",
+ printf("nStakeModifier=0x%016" PRIx64 ", nBlockTime=%u nTxOffset=%u nTxPrevTime=%u nVout=%u nTimeTx=%u hashProofOfStake=%s Success=true\n",
nStakeModifier, nBlockTime, nTxOffset, pcoin.first->nTime, pcoin.second, nTimeTx, hashProofOfStake.GetHex().c_str());
kernelcoin = pcoin;
}
if (fDebug)
- printf("nStakeModifier=0x%016" PRI64x ", nBlockTime=%u nTxOffset=%u nTxPrevTime=%u nTxNumber=%u nTimeTx=%u hashProofOfStake=%s Success=false\n",
+ printf("nStakeModifier=0x%016" PRIx64 ", nBlockTime=%u nTxOffset=%u nTxPrevTime=%u nTxNumber=%u nTimeTx=%u hashProofOfStake=%s Success=false\n",
nStakeModifier, nBlockTime, nTxOffset, pcoin.first->nTime, pcoin.second, nTimeTx, hashProofOfStake.GetHex().c_str());
}
}
bool IsFixedModifierInterval(unsigned int nTimeBlock);
// Compute the hash modifier for proof-of-stake
-bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64& nStakeModifier, bool& fGeneratedStakeModifier);
+bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier);
// The stake modifier used to hash for a stake kernel is chosen as the stake
// modifier about a selection interval later than the coin generating the kernel
-bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier);
+bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifier);
// Check whether stake kernel meets hash target
// Sets hashProofOfStake on success return
// Preloaded coins metadata
// txid => ((txindex, (tx, vout.n)), (block, modifier))
-typedef std::map<std::pair<uint256, unsigned int>, std::pair<std::pair<CTxIndex, std::pair<const CWalletTx*,unsigned int> >, std::pair<CBlock, uint64> > > MetaMap;
+typedef std::map<std::pair<uint256, unsigned int>, std::pair<std::pair<CTxIndex, std::pair<const CWalletTx*,unsigned int> >, std::pair<CBlock, uint64_t> > > MetaMap;
// Scan given coins set for kernel solution
-bool ScanForStakeKernelHash(MetaMap &mapMeta, KernelSearchSettings &settings, CoinsSet::value_type &kernelcoin, unsigned int &nTimeTx, unsigned int &nBlockTime, uint64 &nKernelsTried, uint64 &nCoinDaysTried);
+bool ScanForStakeKernelHash(MetaMap &mapMeta, KernelSearchSettings &settings, CoinsSet::value_type &kernelcoin, unsigned int &nTimeTx, unsigned int &nBlockTime, uint64_t &nKernelsTried, uint64_t &nCoinDaysTried);
// Check kernel hash target and coinstake signature
// Sets hashProofOfStake on success return
bool CheckStakeModifierCheckpoints(int nHeight, unsigned int nStakeModifierChecksum);
// Get time weight using supplied timestamps
-int64 GetWeight(int64 nIntervalBeginning, int64 nIntervalEnd);
+int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd);
#endif // PPCOIN_KERNEL_H
vector<KernelRecord> KernelRecord::decomposeOutput(const CWallet *wallet, const CWalletTx &wtx)
{
vector<KernelRecord> parts;
- int64 nTime = wtx.GetTxTime();
+ int64_t nTime = wtx.GetTxTime();
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;
- int64 nDayWeight = (min((GetAdjustedTime() - nTime), (int64)(nStakeMaxAge+nStakeMinAge)) - nStakeMinAge); // DayWeight * 86400, чтобы был
+ int64_t nDayWeight = (min((GetAdjustedTime() - nTime), (int64_t)(nStakeMaxAge+nStakeMinAge)) - nStakeMinAge); // DayWeight * 86400, чтобы был
// правильный расчёт CoinAge
if (showTransaction(wtx))
{
CTxDestination address;
std::string addrStr;
- uint64 coinAge = max( (txOut.nValue * nDayWeight) / (COIN * 86400), (int64)0);
+ uint64_t coinAge = max( (txOut.nValue * nDayWeight) / (COIN * 86400), (int64_t)0);
if (ExtractDestination(txOut.scriptPubKey, address))
{
return hash.ToString() + strprintf("-%03d", idx);
}
-int64 KernelRecord::getAge() const
+int64_t KernelRecord::getAge() const
{
return (GetAdjustedTime() - nTime) / 86400;
}
-uint64 KernelRecord::getCoinDay() const
+uint64_t KernelRecord::getCoinDay() const
{
- int64 nWeight = GetAdjustedTime() - nTime - nStakeMinAge;
+ int64_t nWeight = GetAdjustedTime() - nTime - nStakeMinAge;
if( nWeight < 0)
return 0;
- nWeight = min(nWeight, (int64)nStakeMaxAge);
- uint64 coinAge = (nValue * nWeight ) / (COIN * 86400);
+ nWeight = min(nWeight, (int64_t)nStakeMaxAge);
+ uint64_t coinAge = (nValue * nWeight ) / (COIN * 86400);
return coinAge;
}
-int64 KernelRecord::getPoSReward(int nBits, int minutes)
+int64_t KernelRecord::getPoSReward(int nBits, int minutes)
{
double PoSReward;
- int64 nWeight = GetAdjustedTime() - nTime + minutes * 60;
+ int64_t nWeight = GetAdjustedTime() - nTime + minutes * 60;
if( nWeight < nStakeMinAge)
return 0;
- uint64 coinAge = (nValue * nWeight ) / (COIN * 86400);
+ uint64_t coinAge = (nValue * nWeight ) / (COIN * 86400);
PoSReward = GetProofOfStakeReward(coinAge, nBits, GetAdjustedTime() + minutes * 60);
return PoSReward;
}
{
//double maxTarget = pow(static_cast<double>(2), 224);
//double target = maxTarget / difficulty;
- //int dayWeight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge) / 86400;
- //uint64 coinAge = max(nValue * dayWeight / COIN, (int64)0);
+ //int dayWeight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64_t)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge) / 86400;
+ //uint64_t coinAge = max(nValue * dayWeight / COIN, (int64_t)0);
//return target * coinAge / pow(static_cast<double>(2), 256);
- int Weight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge);
- uint64 coinAge = max(nValue * Weight / (COIN * 86400), (int64)0);
+ int Weight = (min((GetAdjustedTime() - nTime) + timeOffset, (int64_t)(nStakeMinAge+nStakeMaxAge)) - nStakeMinAge);
+ uint64_t coinAge = max(nValue * Weight / (COIN * 86400), (int64_t)0);
return coinAge / (pow(static_cast<double>(2),32) * difficulty);
}
{
}
- KernelRecord(uint256 hash, int64 nTime):
+ KernelRecord(uint256 hash, int64_t nTime):
hash(hash), nTime(nTime), address(""), nValue(0), idx(0), spent(false), coinAge(0), prevMinutes(0), prevDifficulty(0), prevProbability(0)
{
}
- KernelRecord(uint256 hash, int64 nTime,
+ KernelRecord(uint256 hash, int64_t nTime,
const std::string &address,
- int64 nValue, bool spent, int64 coinAge):
+ int64_t nValue, bool spent, int64_t coinAge):
hash(hash), nTime(nTime), address(address), nValue(nValue),
idx(0), spent(spent), coinAge(coinAge), prevMinutes(0), prevDifficulty(0), prevProbability(0)
{
uint256 hash;
- int64 nTime;
+ int64_t nTime;
std::string address;
- int64 nValue;
+ int64_t nValue;
int idx;
bool spent;
- int64 coinAge;
+ int64_t coinAge;
std::string getTxID();
- int64 getAge() const;
- uint64 getCoinDay() const;
+ int64_t getAge() const;
+ uint64_t getCoinDay() const;
double getProbToMintStake(double difficulty, int timeOffset = 0) const;
double getProbToMintWithinNMinutes(double difficulty, int minutes);
- int64 getPoSReward(int nBits, int timeOffset);
+ int64_t getPoSReward(int nBits, int timeOffset);
protected:
int prevMinutes;
double prevDifficulty;
uint256 hashBestChain = 0;
CBlockIndex* pindexBest = NULL;
-int64 nTimeBestReceived = 0;
+int64_t nTimeBestReceived = 0;
int nScriptCheckThreads = 0;
CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
const string strMessageMagic = "NovaCoin Signed Message:\n";
// Settings
-int64 nTransactionFee = MIN_TX_FEE;
-int64 nMinimumInputValue = MIN_TX_FEE;
+int64_t nTransactionFee = MIN_TX_FEE;
+int64_t nMinimumInputValue = MIN_TX_FEE;
extern enum Checkpoints::CPMode CheckpointsMode;
return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
// Check for negative or overflow output values
- int64 nValueOut = 0;
+ int64_t nValueOut = 0;
for (unsigned int i = 0; i < vout.size(); i++)
{
const CTxOut& txout = vout[i];
return true;
}
-int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum GetMinFee_mode mode, unsigned int nBytes) const
+int64_t CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum GetMinFee_mode mode, unsigned int nBytes) const
{
// Use new fees approach if we are on test network or
// switch date has been reached
bool fNewApproach = fTestNet || nTime > FEE_SWITCH_TIME;
- int64 nMinTxFee = MIN_TX_FEE, nMinRelayTxFee = MIN_RELAY_TX_FEE;
+ int64_t nMinTxFee = MIN_TX_FEE, nMinRelayTxFee = MIN_RELAY_TX_FEE;
if(!fNewApproach || IsCoinStake())
{
}
// Base fee is either nMinTxFee or nMinRelayTxFee
- int64 nBaseFee = (mode == GMF_RELAY) ? nMinRelayTxFee : nMinTxFee;
+ int64_t nBaseFee = (mode == GMF_RELAY) ? nMinRelayTxFee : nMinTxFee;
unsigned int nNewBlockSize = nBlockSize + nBytes;
- int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
+ int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee;
if (fNewApproach)
{
return tx.DoS(100, error("CTxMemPool::accept() : coinstake as individual tx"));
// To help v0.1.5 clients who would see it as a negative number
- if ((int64)tx.nLockTime > std::numeric_limits<int>::max())
+ if ((int64_t)tx.nLockTime > std::numeric_limits<int>::max())
return error("CTxMemPool::accept() : not accepting nLockTime beyond 2038 yet");
// Rather not work on nonstandard transactions (unless -testnet)
// you should add code here to check that the transaction does a
// reasonable number of ECDSA signature verifications.
- int64 nFees = tx.GetValueIn(mapInputs)-tx.GetValueOut();
+ int64_t nFees = tx.GetValueIn(mapInputs)-tx.GetValueOut();
unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
// Don't accept it if it can't get into a block
- int64 txMinFee = tx.GetMinFee(1000, true, GMF_RELAY, nSize);
+ int64_t txMinFee = tx.GetMinFee(1000, true, GMF_RELAY, nSize);
if (nFees < txMinFee)
- return error("CTxMemPool::accept() : not enough fees %s, %" PRI64d " < %" PRI64d,
+ return error("CTxMemPool::accept() : not enough fees %s, %" PRId64 " < %" PRId64,
hash.ToString().c_str(),
nFees, txMinFee);
{
static CCriticalSection cs;
static double dFreeCount;
- static int64 nLastTime;
- int64 nNow = GetTime();
+ static int64_t nLastTime;
+ int64_t nNow = GetTime();
{
LOCK(cs);
}
// miner's coin base reward based on nBits
-int64 GetProofOfWorkReward(unsigned int nBits, int64 nFees)
+int64_t GetProofOfWorkReward(unsigned int nBits, int64_t nFees)
{
CBigNum bnSubsidyLimit = MAX_MINT_PROOF_OF_WORK;
{
CBigNum bnMidValue = (bnLowerBound + bnUpperBound) / 2;
if (fDebug && GetBoolArg("-printcreation"))
- printf("GetProofOfWorkReward() : lower=%" PRI64d " upper=%" PRI64d " mid=%" PRI64d "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64());
+ printf("GetProofOfWorkReward() : lower=%" PRId64 " upper=%" PRId64 " mid=%" PRId64 "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64());
if (bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnTargetLimit > bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnTarget)
bnUpperBound = bnMidValue;
else
bnLowerBound = bnMidValue;
}
- int64 nSubsidy = bnUpperBound.getuint64();
+ int64_t nSubsidy = bnUpperBound.getuint64();
nSubsidy = (nSubsidy / CENT) * CENT;
if (fDebug && GetBoolArg("-printcreation"))
- printf("GetProofOfWorkReward() : create=%s nBits=0x%08x nSubsidy=%" PRI64d "\n", FormatMoney(nSubsidy).c_str(), nBits, nSubsidy);
+ printf("GetProofOfWorkReward() : create=%s nBits=0x%08x nSubsidy=%" PRId64 "\n", FormatMoney(nSubsidy).c_str(), nBits, nSubsidy);
return min(nSubsidy, MAX_MINT_PROOF_OF_WORK) + nFees;
}
// miner's coin stake reward based on nBits and coin age spent (coin-days)
-int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly)
+int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly)
{
- int64 nRewardCoinYear, nSubsidy, nSubsidyLimit = 10 * COIN;
+ int64_t nRewardCoinYear, nSubsidy, nSubsidyLimit = 10 * COIN;
if(fTestNet || nTime > STAKE_SWITCH_TIME)
{
{
CBigNum bnMidValue = (bnLowerBound + bnUpperBound) / 2;
if (fDebug && GetBoolArg("-printcreation"))
- printf("GetProofOfStakeReward() : lower=%" PRI64d " upper=%" PRI64d " mid=%" PRI64d "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64());
+ printf("GetProofOfStakeReward() : lower=%" PRId64 " upper=%" PRId64 " mid=%" PRId64 "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64());
if(!fTestNet && nTime < STAKECURVE_SWITCH_TIME)
{
}
if (fDebug && GetBoolArg("-printcreation"))
- printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRI64d " nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits);
+ printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRId64 " nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits);
return nSubsidy;
}
-static const int64 nTargetTimespan = 7 * 24 * 60 * 60; // one week
+static const int64_t nTargetTimespan = 7 * 24 * 60 * 60; // one week
// get proof of work blocks max spacing according to hard-coded conditions
-int64 inline GetTargetSpacingWorkMax(int nHeight, unsigned int nTime)
+int64_t inline GetTargetSpacingWorkMax(int nHeight, unsigned int nTime)
{
if(nTime > TARGETS_SWITCH_TIME)
return 3 * nStakeTargetSpacing; // 30 minutes on mainNet since 20 Jul 2013 00:00:00
//
// maximum nBits value could possible be required nTime after
//
-unsigned int ComputeMaxBits(CBigNum bnTargetLimit, unsigned int nBase, int64 nTime)
+unsigned int ComputeMaxBits(CBigNum bnTargetLimit, unsigned int nBase, int64_t nTime)
{
CBigNum bnResult;
bnResult.SetCompact(nBase);
// minimum amount of work that could possibly be required nTime after
// minimum proof-of-work required was nBase
//
-unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
+unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime)
{
return ComputeMaxBits(bnProofOfWorkLimit, nBase, nTime);
}
// minimum amount of stake that could possibly be required nTime after
// minimum proof-of-stake required was nBase
//
-unsigned int ComputeMinStake(unsigned int nBase, int64 nTime, unsigned int nBlockTime)
+unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime)
{
return ComputeMaxBits(GetProofOfStakeLimit(0, nBlockTime), nBase, nTime);
}
if (pindexPrevPrev->pprev == NULL)
return bnTargetLimit.GetCompact(); // second block
- int64 nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime();
+ int64_t nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime();
// ppcoin: target change every block
// ppcoin: retarget with exponential moving toward target spacing
CBigNum bnNew;
bnNew.SetCompact(pindexPrev->nBits);
- int64 nTargetSpacing = fProofOfStake? nStakeTargetSpacing : min(GetTargetSpacingWorkMax(pindexLast->nHeight, pindexLast->nTime), (int64) nStakeTargetSpacing * (1 + pindexLast->nHeight - pindexPrev->nHeight));
- int64 nInterval = nTargetTimespan / nTargetSpacing;
+ int64_t nTargetSpacing = fProofOfStake? nStakeTargetSpacing : min(GetTargetSpacingWorkMax(pindexLast->nHeight, pindexLast->nTime), (int64_t) nStakeTargetSpacing * (1 + pindexLast->nHeight - pindexPrev->nHeight));
+ int64_t nInterval = nTargetTimespan / nTargetSpacing;
bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing);
bnNew /= ((nInterval + 1) * nTargetSpacing);
{
if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate())
return true;
- static int64 nLastUpdate;
+ static int64_t nLastUpdate;
static CBlockIndex* pindexLastBest;
if (pindexBest != pindexLastBest)
{
uint256 nBestInvalidBlockTrust = pindexNew->nChainTrust - pindexNew->pprev->nChainTrust;
uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust;
- printf("InvalidChainFound: invalid block=%s height=%d trust=%s blocktrust=%" PRI64d " date=%s\n",
+ printf("InvalidChainFound: invalid block=%s height=%d trust=%s blocktrust=%" PRId64 " date=%s\n",
pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight,
CBigNum(pindexNew->nChainTrust).ToString().c_str(), nBestInvalidBlockTrust.Get64(),
DateTimeStrFormat("%x %H:%M:%S", pindexNew->GetBlockTime()).c_str());
- printf("InvalidChainFound: current best=%s height=%d trust=%s blocktrust=%" PRI64d " date=%s\n",
+ printf("InvalidChainFound: current best=%s height=%d trust=%s blocktrust=%" PRId64 " date=%s\n",
hashBestChain.ToString().substr(0,20).c_str(), nBestHeight,
CBigNum(pindexBest->nChainTrust).ToString().c_str(),
nBestBlockTrust.Get64(),
return txPrev.vout[input.prevout.n];
}
-int64 CTransaction::GetValueIn(const MapPrevTx& inputs) const
+int64_t CTransaction::GetValueIn(const MapPrevTx& inputs) const
{
if (IsCoinBase())
return 0;
- int64 nResult = 0;
+ int64_t nResult = 0;
for (unsigned int i = 0; i < vin.size(); i++)
{
nResult += GetOutputFor(vin[i], inputs).nValue;
if (!IsCoinBase())
{
- int64 nValueIn = 0;
- int64 nFees = 0;
+ int64_t nValueIn = 0;
+ int64_t nFees = 0;
for (unsigned int i = 0; i < vin.size(); i++)
{
COutPoint prevout = vin[i].prevout;
if (IsCoinStake())
{
// ppcoin: coin stake tx earns reward instead of paying fee
- uint64 nCoinAge;
+ uint64_t nCoinAge;
if (!GetCoinAge(txdb, nCoinAge))
return error("ConnectInputs() : %s unable to get coin age for coinstake", GetHash().ToString().substr(0,10).c_str());
unsigned int nTxSize = (nTime > VALIDATION_SWITCH_TIME || fTestNet) ? GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) : 0;
- int64 nReward = GetValueOut() - nValueIn;
- int64 nCalculatedReward = GetProofOfStakeReward(nCoinAge, pindexBlock->nBits, nTime) - GetMinFee(1, false, GMF_BLOCK, nTxSize) + CENT;
+ int64_t nReward = GetValueOut() - nValueIn;
+ int64_t nCalculatedReward = GetProofOfStakeReward(nCoinAge, pindexBlock->nBits, nTime) - GetMinFee(1, false, GMF_BLOCK, nTxSize) + CENT;
if (nReward > nCalculatedReward)
- return DoS(100, error("ConnectInputs() : coinstake pays too much(actual=%" PRI64d " vs calculated=%" PRI64d ")", nReward, nCalculatedReward));
+ return DoS(100, error("ConnectInputs() : coinstake pays too much(actual=%" PRId64 " vs calculated=%" PRId64 ")", nReward, nCalculatedReward));
}
else
{
return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
// Tally transaction fees
- int64 nTxFee = nValueIn - GetValueOut();
+ int64_t nTxFee = nValueIn - GetValueOut();
if (nTxFee < 0)
return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
// Take over previous transactions' spent pointers
{
LOCK(mempool.cs);
- int64 nValueIn = 0;
+ int64_t nValueIn = 0;
for (unsigned int i = 0; i < vin.size(); i++)
{
// Get prev tx from single transactions in memory
map<uint256, CTxIndex> mapQueuedChanges;
CCheckQueueControl<CScriptCheck> control(fScriptChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL);
- int64 nFees = 0;
- int64 nValueIn = 0;
- int64 nValueOut = 0;
+ int64_t nFees = 0;
+ int64_t nValueIn = 0;
+ int64_t nValueOut = 0;
unsigned int nSigOps = 0;
BOOST_FOREACH(CTransaction& tx, vtx)
{
if (nSigOps > MAX_BLOCK_SIGOPS)
return DoS(100, error("ConnectBlock() : too many sigops"));
- int64 nTxValueIn = tx.GetValueIn(mapInputs);
- int64 nTxValueOut = tx.GetValueOut();
+ int64_t nTxValueIn = tx.GetValueIn(mapInputs);
+ int64_t nTxValueOut = tx.GetValueOut();
nValueIn += nTxValueIn;
nValueOut += nTxValueOut;
if (!tx.IsCoinStake())
if (IsProofOfWork())
{
- int64 nBlockReward = GetProofOfWorkReward(nBits, nFees);
+ int64_t nBlockReward = GetProofOfWorkReward(nBits, nFees);
// Check coinbase reward
if (vtx[0].GetValueOut() > nBlockReward)
- return error("CheckBlock() : coinbase reward exceeded (actual=%" PRI64d " vs calculated=%" PRI64d ")",
+ return error("CheckBlock() : coinbase reward exceeded (actual=%" PRId64 " vs calculated=%" PRId64 ")",
vtx[0].GetValueOut(),
nBlockReward);
}
// fees are not collected by proof-of-stake miners
// fees are destroyed to compensate the entire network
if (fDebug && IsProofOfStake() && GetBoolArg("-printcreation"))
- printf("ConnectBlock() : destroy=%s nFees=%" PRI64d "\n", FormatMoney(nFees).c_str(), nFees);
+ printf("ConnectBlock() : destroy=%s nFees=%" PRId64 "\n", FormatMoney(nFees).c_str(), nFees);
if (fJustCheck)
return true;
uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust;
- printf("SetBestChain: new best=%s height=%d trust=%s blocktrust=%" PRI64d " date=%s\n",
+ printf("SetBestChain: new best=%s height=%d trust=%s blocktrust=%" PRId64 " date=%s\n",
hashBestChain.ToString().substr(0,20).c_str(), nBestHeight,
CBigNum(nBestChainTrust).ToString().c_str(),
nBestBlockTrust.Get64(),
// guaranteed to be in main chain by sync-checkpoint. This rule is
// introduced to help nodes establish a consistent view of the coin
// age (trust score) of competing branches.
-bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const
+bool CTransaction::GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge) const
{
CBigNum bnCentSecond = 0; // coin age in the unit of cent-seconds
nCoinAge = 0;
if (block.GetBlockTime() + nStakeMinAge > nTime)
continue; // only count coins meeting min age requirement
- int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;
+ int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT;
if (fDebug && GetBoolArg("-printcoinage"))
- printf("coin age nValueIn=%" PRI64d " nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str());
+ printf("coin age nValueIn=%" PRId64 " nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str());
}
CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60);
}
// ppcoin: total coin age spent in block, in the unit of coin-days.
-bool CBlock::GetCoinAge(uint64& nCoinAge) const
+bool CBlock::GetCoinAge(uint64_t& nCoinAge) const
{
nCoinAge = 0;
CTxDB txdb("r");
BOOST_FOREACH(const CTransaction& tx, vtx)
{
- uint64 nTxCoinAge;
+ uint64_t nTxCoinAge;
if (tx.GetCoinAge(txdb, nTxCoinAge))
nCoinAge += nTxCoinAge;
else
if (nCoinAge == 0) // block coin age minimum 1 coin-day
nCoinAge = 1;
if (fDebug && GetBoolArg("-printcoinage"))
- printf("block coin age total nCoinDays=%" PRI64d "\n", nCoinAge);
+ printf("block coin age total nCoinDays=%" PRId64 "\n", nCoinAge);
return true;
}
}
// ppcoin: compute stake modifier
- uint64 nStakeModifier = 0;
+ uint64_t nStakeModifier = 0;
bool fGeneratedStakeModifier = false;
if (!ComputeNextStakeModifier(pindexNew, nStakeModifier, fGeneratedStakeModifier))
return error("AddToBlockIndex() : ComputeNextStakeModifier() failed");
pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier);
pindexNew->nStakeModifierChecksum = GetStakeModifierChecksum(pindexNew);
if (!CheckStakeModifierCheckpoints(pindexNew->nHeight, pindexNew->nStakeModifierChecksum))
- return error("AddToBlockIndex() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016" PRI64x, pindexNew->nHeight, nStakeModifier);
+ return error("AddToBlockIndex() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016" PRIx64, pindexNew->nHeight, nStakeModifier);
// Add to mapBlockIndex
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
return DoS(100, error("CheckBlock() : first tx is not coinbase"));
// Check coinbase timestamp
- if (GetBlockTime() < PastDrift((int64)vtx[0].nTime))
+ if (GetBlockTime() < PastDrift((int64_t)vtx[0].nTime))
return DoS(50, error("CheckBlock() : coinbase timestamp is too late"));
for (unsigned int i = 1; i < vtx.size(); i++)
return DoS(100, error("CheckBlock() : more than one coinbase"));
// Check transaction timestamp
- if (GetBlockTime() < (int64)vtx[i].nTime)
+ if (GetBlockTime() < (int64_t)vtx[i].nTime)
return DoS(50, error("CheckBlock() : block timestamp earlier than transaction timestamp"));
}
return DoS(100, error("CheckBlock() : more than one coinstake"));
// Check coinstake timestamp
- if (GetBlockTime() != (int64)vtx[1].nTime)
- return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%" PRI64d " nTimeTx=%u", GetBlockTime(), vtx[1].nTime));
+ if (GetBlockTime() != (int64_t)vtx[1].nTime)
+ return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%" PRId64 " nTimeTx=%u", GetBlockTime(), vtx[1].nTime));
// NovaCoin: check proof-of-stake block signature
if (fCheckSig && !CheckBlockSignature(true))
if (pcheckpoint && pblock->hashPrevBlock != hashBestChain && !Checkpoints::WantedByPendingSyncCheckpoint(hash))
{
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
- int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
+ int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
CBigNum bnNewBlock;
bnNewBlock.SetCompact(pblock->nBits);
CBigNum bnRequired;
if (IsProofOfStake())
return true;
- static int64 nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp
+ static int64_t nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp
CKey key;
CTransaction txCoinStake;
- int64 nSearchTime = txCoinStake.nTime; // search to current time
+ int64_t nSearchTime = txCoinStake.nTime; // search to current time
if (nSearchTime > nLastCoinStakeSearchTime)
{
return false;
}
-bool CheckDiskSpace(uint64 nAdditionalBytes)
+bool CheckDiskSpace(uint64_t nAdditionalBytes)
{
- uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
+ uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
// Check for nMinDiskSpace bytes (currently 50MB)
if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes)
bool LoadExternalBlockFile(FILE* fileIn)
{
- int64 nStart = GetTimeMillis();
+ int64_t nStart = GetTimeMillis();
int nLoaded = 0;
{
BOOST_CURRENT_FUNCTION);
}
}
- printf("Loaded %i blocks from external file in %" PRI64d "ms\n", nLoaded, GetTimeMillis() - nStart);
+ printf("Loaded %i blocks from external file in %" PRId64 "ms\n", nLoaded, GetTimeMillis() - nStart);
return nLoaded > 0;
}
return false;
}
- int64 nTime;
+ int64_t nTime;
CAddress addrMe;
CAddress addrFrom;
- uint64 nNonce = 1;
+ uint64_t nNonce = 1;
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
if (pfrom->nVersion < MIN_PROTO_VERSION)
{
// Store the new addresses
vector<CAddress> vAddrOk;
- int64 nNow = GetAdjustedTime();
- int64 nSince = nNow - 10 * 60;
+ int64_t nNow = GetAdjustedTime();
+ int64_t nSince = nNow - 10 * 60;
BOOST_FOREACH(CAddress& addr, vAddr)
{
if (fShutdown)
static uint256 hashSalt;
if (hashSalt == 0)
hashSalt = GetRandHash();
- uint64 hashAddr = addr.GetHash();
+ uint64_t hashAddr = addr.GetHash();
uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60));
hashRand = Hash(BEGIN(hashRand), END(hashRand));
multimap<uint256, CNode*> mapMix;
else if (strCommand == "getaddr")
{
// Don't return addresses older than nCutOff timestamp
- int64 nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60);
+ int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60);
pfrom->vAddrToSend.clear();
vector<CAddress> vAddr = addrman.GetAddr();
BOOST_FOREACH(const CAddress &addr, vAddr)
{
if (pfrom->nVersion > BIP0031_VERSION)
{
- uint64 nonce = 0;
+ uint64_t nonce = 0;
vRecv >> nonce;
// Echo the message back with the nonce. This allows for two useful features:
//
// Keep-alive ping. We send a nonce of zero because we don't use it anywhere
// right now.
if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty()) {
- uint64 nonce = 0;
+ uint64_t nonce = 0;
if (pto->nVersion > BIP0031_VERSION)
pto->PushMessage("ping", nonce);
else
ResendWalletTransactions();
// Address refresh broadcast
- static int64 nLastRebroadcast;
+ static int64_t nLastRebroadcast;
if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
{
{
// Message: getdata
//
vector<CInv> vGetData;
- int64 nNow = GetTime() * 1000000;
+ int64_t nNow = GetTime() * 1000000;
CTxDB txdb("r");
while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)
{
static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
static const unsigned int MAX_INV_SZ = 50000;
-static const int64 MIN_TX_FEE = CENT/10;
-static const int64 MIN_RELAY_TX_FEE = CENT/50;
+static const int64_t MIN_TX_FEE = CENT/10;
+static const int64_t MIN_RELAY_TX_FEE = CENT/50;
-static const int64 MAX_MONEY = 2000000000 * COIN;
-static const int64 MAX_MINT_PROOF_OF_WORK = 100 * COIN;
-static const int64 MAX_MINT_PROOF_OF_STAKE = 1 * COIN;
-static const int64 MIN_TXOUT_AMOUNT = CENT/100;
+static const int64_t MAX_MONEY = 2000000000 * COIN;
+static const int64_t MAX_MINT_PROOF_OF_WORK = 100 * COIN;
+static const int64_t MAX_MINT_PROOF_OF_STAKE = 1 * COIN;
+static const int64_t MIN_TXOUT_AMOUNT = CENT/100;
-inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
+inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
// Maximum number of script-checking threads allowed
static const uint256 hashGenesisBlock("0x00000a060336cbb72fe969666d337b87198b1add2abaa59cca226820b32933a4");
static const uint256 hashGenesisBlockTestNet("0x000c763e402f2436da9ed36c7286f62c3f6e5dbafce9ff289bd43d7459327eb");
-inline int64 PastDrift(int64 nTime) { return nTime - 2 * 60 * 60; } // up to 2 hours from the past
-inline int64 FutureDrift(int64 nTime) { return nTime + 2 * 60 * 60; } // up to 2 hours from the future
+inline int64_t PastDrift(int64_t nTime) { return nTime - 2 * 60 * 60; } // up to 2 hours from the past
+inline int64_t FutureDrift(int64_t nTime) { return nTime + 2 * 60 * 60; } // up to 2 hours from the future
extern CScript COINBASE_FLAGS;
extern CCriticalSection cs_main;
extern uint256 hashBestChain;
extern CBlockIndex* pindexBest;
extern unsigned int nTransactionsUpdated;
-extern uint64 nLastBlockTx;
-extern uint64 nLastBlockSize;
-extern int64 nLastCoinStakeSearchInterval;
+extern uint64_t nLastBlockTx;
+extern uint64_t nLastBlockSize;
+extern int64_t nLastCoinStakeSearchInterval;
extern const std::string strMessageMagic;
-extern int64 nTimeBestReceived;
+extern int64_t nTimeBestReceived;
extern CCriticalSection cs_setpwalletRegistered;
extern std::set<CWallet*> setpwalletRegistered;
extern unsigned char pchMessageStart[4];
extern std::map<uint256, CBlock*> mapOrphanBlocks;
// Settings
-extern int64 nTransactionFee;
-extern int64 nMinimumInputValue;
+extern int64_t nTransactionFee;
+extern int64_t nMinimumInputValue;
extern bool fUseFastIndex;
extern unsigned int nDerivationMethodIndex;
extern int nScriptCheckThreads;
// Minimum disk space required - used in CheckDiskSpace()
-static const uint64 nMinDiskSpace = 52428800;
+static const uint64_t nMinDiskSpace = 52428800;
class CReserveKey;
class CTxDB;
void UnregisterWallet(CWallet* pwalletIn);
void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL, bool fUpdate = false, bool fConnect = true);
bool ProcessBlock(CNode* pfrom, CBlock* pblock);
-bool CheckDiskSpace(uint64 nAdditionalBytes=0);
+bool CheckDiskSpace(uint64_t nAdditionalBytes=0);
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
FILE* AppendBlockFile(unsigned int& nFileRet);
bool LoadBlockIndex(bool fAllowNew=true);
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake);
-int64 GetProofOfWorkReward(unsigned int nBits, int64 nFees=0);
-int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly=false);
-unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
-unsigned int ComputeMinStake(unsigned int nBase, int64 nTime, unsigned int nBlockTime);
+int64_t GetProofOfWorkReward(unsigned int nBits, int64_t nFees=0);
+int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly=false);
+unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime);
+unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime);
int GetNumBlocksOfPeers();
bool IsInitialBlockDownload();
std::string GetWarnings(std::string strFor);
class CTxOut
{
public:
- int64 nValue;
+ int64_t nValue;
CScript scriptPubKey;
CTxOut()
SetNull();
}
- CTxOut(int64 nValueIn, CScript scriptPubKeyIn)
+ CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
{
nValue = nValueIn;
scriptPubKey = scriptPubKeyIn;
return SerializeHash(*this);
}
- bool IsFinal(int nBlockHeight=0, int64 nBlockTime=0) const
+ bool IsFinal(int nBlockHeight=0, int64_t nBlockTime=0) const
{
// Time based nLockTime implemented in 0.1.6
if (nLockTime == 0)
nBlockHeight = nBestHeight;
if (nBlockTime == 0)
nBlockTime = GetAdjustedTime();
- if ((int64)nLockTime < ((int64)nLockTime < LOCKTIME_THRESHOLD ? (int64)nBlockHeight : nBlockTime))
+ if ((int64_t)nLockTime < ((int64_t)nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
return true;
BOOST_FOREACH(const CTxIn& txin, vin)
if (!txin.IsFinal())
/** Amount of bitcoins spent by this transaction.
@return sum of all outputs (note: does not include fees)
*/
- int64 GetValueOut() const
+ int64_t GetValueOut() const
{
- int64 nValueOut = 0;
+ int64_t nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, vout)
{
nValueOut += txout.nValue;
@return Sum of value of all inputs (scriptSigs)
@see CTransaction::FetchInputs
*/
- int64 GetValueIn(const MapPrevTx& mapInputs) const;
+ int64_t GetValueIn(const MapPrevTx& mapInputs) const;
static bool AllowFree(double dPriority)
{
return dPriority > COIN * 144 / 250;
}
- int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=false, enum GetMinFee_mode mode=GMF_BLOCK, unsigned int nBytes = 0) const;
+ int64_t GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=false, enum GetMinFee_mode mode=GMF_BLOCK, unsigned int nBytes = 0) const;
bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL)
{
bool ClientConnectInputs();
bool CheckTransaction() const;
bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
- bool GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const; // ppcoin: get transaction coin age
+ bool GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge) const; // ppcoin: get transaction coin age
protected:
const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const;
return scrypt_blockhash(CVOIDBEGIN(nVersion));
}
- int64 GetBlockTime() const
+ int64_t GetBlockTime() const
{
- return (int64)nTime;
+ return (int64_t)nTime;
}
void UpdateTime(const CBlockIndex* pindexPrev);
{
// Take last bit of block hash as entropy bit
unsigned int nEntropyBit = ((GetHash().Get64()) & 1ULL);
- //unsigned int nEntropyBit = 1;
if (fDebug && GetBoolArg("-printstakemodifier"))
printf("GetStakeEntropyBit: nTime=%u hashBlock=%s nEntropyBit=%u\n", nTime, GetHash().ToString().c_str(), nEntropyBit);
return nEntropyBit;
printf("GetStakeEntropyBit: hashSig=%s", hashSig.ToString().c_str());
hashSig >>= 159; // take the first bit of the hash
if (fDebug && GetBoolArg("-printstakemodifier"))
- printf(" entropybit=%" PRI64d "\n", hashSig.Get64());
+ printf(" entropybit=%" PRId64 "\n", hashSig.Get64());
return hashSig.Get64();
}
}
// ppcoin: get max transaction timestamp
- int64 GetMaxTransactionTime() const
+ int64_t GetMaxTransactionTime() const
{
- int64 maxTransactionTime = 0;
+ int64_t maxTransactionTime = 0;
BOOST_FOREACH(const CTransaction& tx, vtx)
- maxTransactionTime = std::max(maxTransactionTime, (int64)tx.nTime);
+ maxTransactionTime = std::max(maxTransactionTime, (int64_t)tx.nTime);
return maxTransactionTime;
}
bool AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos);
bool CheckBlock(bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fCheckSig=true) const;
bool AcceptBlock();
- bool GetCoinAge(uint64& nCoinAge) const; // ppcoin: calculate total coin age spent in block
+ bool GetCoinAge(uint64_t& nCoinAge) const; // ppcoin: calculate total coin age spent in block
bool SignBlock(CWallet& keystore);
bool CheckBlockSignature(bool fProofOfStake) const;
uint256 nChainTrust; // ppcoin: trust score of block chain
int nHeight;
- int64 nMint;
- int64 nMoneySupply;
+ int64_t nMint;
+ int64_t nMoneySupply;
unsigned int nFlags; // ppcoin: block index flags
enum
BLOCK_STAKE_MODIFIER = (1 << 2), // regenerated stake modifier
};
- uint64 nStakeModifier; // hash modifier for proof-of-stake
+ uint64_t nStakeModifier; // hash modifier for proof-of-stake
unsigned int nStakeModifierChecksum; // checksum of index; in-memeory only
// proof-of-stake specific fields
return *phashBlock;
}
- int64 GetBlockTime() const
+ int64_t GetBlockTime() const
{
- return (int64)nTime;
+ return (int64_t)nTime;
}
uint256 GetBlockTrust() const;
enum { nMedianTimeSpan=11 };
- int64 GetMedianTimePast() const
+ int64_t GetMedianTimePast() const
{
- int64 pmedian[nMedianTimeSpan];
- int64* pbegin = &pmedian[nMedianTimeSpan];
- int64* pend = &pmedian[nMedianTimeSpan];
+ int64_t pmedian[nMedianTimeSpan];
+ int64_t* pbegin = &pmedian[nMedianTimeSpan];
+ int64_t* pend = &pmedian[nMedianTimeSpan];
const CBlockIndex* pindex = this;
for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
return pbegin[(pend - pbegin)/2];
}
- int64 GetMedianTime() const
+ int64_t GetMedianTime() const
{
const CBlockIndex* pindex = this;
for (int i = 0; i < nMedianTimeSpan/2; i++)
return (nFlags & BLOCK_STAKE_MODIFIER);
}
- void SetStakeModifier(uint64 nModifier, bool fGeneratedStakeModifier)
+ void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier)
{
nStakeModifier = nModifier;
if (fGeneratedStakeModifier)
std::string ToString() const
{
- return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016" PRI64x ", nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)",
+ return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016" PRIx64 ", nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)",
pprev, pnext, nFile, nBlockPos, nHeight,
FormatMoney(nMint).c_str(), FormatMoney(nMoneySupply).c_str(),
GeneratedStakeModifier() ? "MOD" : "-", GetStakeEntropyBit(), IsProofOfStake()? "PoS" : "PoW",
LINK:=$(CXX)
-DEFS=-DBOOST_SPIRIT_THREADSAFE
+DEFS=-DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS
DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
-l crypto \
-Wl,-Bstatic -lpthread -Wl,-Bdynamic
-DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
+DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS
DEBUGFLAGS=-g
CFLAGS=-O2 -msse2 -w -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++
-l ssl \
-l crypto
-DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
+DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS
DEBUGFLAGS=-g
CFLAGS=-mthreads -O2 -msse2 -w -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
-TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
-
ifndef USE_UPNP
override USE_UPNP = -
endif
-lz
endif
-DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE
+DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS
ifdef RELEASE
# Compile for maximum compatibility and smallest size.
LINK:=$(CXX)
ARCH:=$(system lscpu | head -n 1 | awk '{print $2}')
-DEFS=-DBOOST_SPIRIT_THREADSAFE
+DEFS=-DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS
DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
};
-uint64 nLastBlockTx = 0;
-uint64 nLastBlockSize = 0;
-int64 nLastCoinStakeSearchInterval = 0;
+uint64_t nLastBlockTx = 0;
+uint64_t nLastBlockSize = 0;
+int64_t nLastCoinStakeSearchInterval = 0;
// We want to sort transactions by priority and fee, so:
typedef boost::tuple<double, double, CTransaction*> TxPriority;
// a transaction spammer can cheaply fill blocks using
// 1-satoshi-fee transactions. It should be set above the real
// cost to you of processing a transaction.
- int64 nMinTxFee = MIN_TX_FEE;
+ int64_t nMinTxFee = MIN_TX_FEE;
if (mapArgs.count("-mintxfee"))
ParseMoney(mapArgs["-mintxfee"], nMinTxFee);
pblock->nBits = GetNextTargetRequired(pindexPrev, fProofOfStake);
// Collect memory pool transactions into the block
- int64 nFees = 0;
+ int64_t nFees = 0;
{
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = pindexBest;
COrphan* porphan = NULL;
double dPriority = 0;
- int64 nTotalIn = 0;
+ int64_t nTotalIn = 0;
bool fMissingInputs = false;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
nTotalIn += mempool.mapTx[txin.prevout.hash].vout[txin.prevout.n].nValue;
continue;
}
- int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;
+ int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
nTotalIn += nValueIn;
int nConf = txindex.GetDepthInMainChain();
// Collect transactions into block
map<uint256, CTxIndex> mapTestPool;
- uint64 nBlockSize = 1000;
- uint64 nBlockTx = 0;
+ uint64_t nBlockSize = 1000;
+ uint64_t nBlockTx = 0;
int nBlockSigOps = 100;
bool fSortedByFee = (nBlockPrioritySize <= 0);
continue;
// Simplify transaction fee - allow free = false
- int64 nMinFee = tx.GetMinFee(nBlockSize, true, GMF_BLOCK, nTxSize);
+ int64_t nMinFee = tx.GetMinFee(nBlockSize, true, GMF_BLOCK, nTxSize);
// Skip free transactions if we're past the minimum block size:
if (fSortedByFee && (dFeePerKb < nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize))
if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid))
continue;
- int64 nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut();
+ int64_t nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut();
if (nTxFees < nMinFee)
continue;
pblock->vtx[0].vout[0].nValue = GetProofOfWorkReward(pblock->nBits, nFees);
if (fDebug)
- printf("CreateNewBlock(): reward %" PRI64u "\n", pblock->vtx[0].vout[0].nValue);
+ printf("CreateNewBlock(): reward %" PRIu64 "\n", pblock->vtx[0].vout[0].nValue);
}
if (fDebug && GetBoolArg("-printpriority"))
- printf("CreateNewBlock(): total size %" PRI64u "\n", nBlockSize);
+ printf("CreateNewBlock(): total size %" PRIu64 "\n", nBlockSize);
// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
bool fClient = false;
bool fDiscover = true;
bool fUseUPnP = false;
-uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
+uint64_t nLocalServices = (fClient ? 0 : NODE_NETWORK);
static CCriticalSection cs_mapLocalHost;
static map<CNetAddr, LocalServiceInfo> mapLocalHost;
static bool vfReachable[NET_MAX] = {};
static CNode* pnodeLocalHost = NULL;
static CNode* pnodeSync = NULL;
CAddress addrSeenByPeer(CService("0.0.0.0", 0), nLocalServices);
-uint64 nLocalHostNonce = 0;
+uint64_t nLocalHostNonce = 0;
boost::array<int, THREAD_MAX> vnThreadsRunning;
static std::vector<SOCKET> vhListenSocket;
CAddrMan addrman;
vector<CNode*> vNodes;
CCriticalSection cs_vNodes;
map<CInv, CDataStream> mapRelay;
-deque<pair<int64, CInv> > vRelayExpiration;
+deque<pair<int64_t, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
-map<CInv, int64> mapAlreadyAskedFor;
+map<CInv, int64_t> mapAlreadyAskedFor;
static deque<string> vOneShots;
CCriticalSection cs_vOneShots;
bool GetMyExternalIP(CNetAddr& ipRet)
{
struct sockaddr_in mapped;
- uint64 rnd = GetRand(~0LL);
+ uint64_t rnd = GetRand(~0LL);
const char *srv;
int rc = GetExternalIPbySTUN(rnd, &mapped, &srv);
if(rc >= 0) {
ipRet = CNetAddr(mapped.sin_addr);
- printf("GetExternalIPbySTUN(%" PRI64u ") returned %s in attempt %d; Server=%s\n", rnd, ipRet.ToStringIP().c_str(), rc, srv);
+ printf("GetExternalIPbySTUN(%" PRIu64 ") returned %s in attempt %d; Server=%s\n", rnd, ipRet.ToStringIP().c_str(), rc, srv);
return true;
}
return false;
return NULL;
}
-CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64 nTimeout)
+CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64_t nTimeout)
{
if (pszDest == NULL) {
if (IsLocal(addrConnect))
void CNode::PushVersion()
{
/// when NTP implemented, change to just nTime = GetAdjustedTime()
- int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
+ int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime());
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
CAddress addrMe = GetLocalAddress(&addr);
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
-std::map<CNetAddr, int64> CNode::setBanned;
+std::map<CNetAddr, int64_t> CNode::setBanned;
CCriticalSection CNode::cs_setBanned;
void CNode::ClearBanned()
bool fResult = false;
{
LOCK(cs_setBanned);
- std::map<CNetAddr, int64>::iterator i = setBanned.find(ip);
+ std::map<CNetAddr, int64_t>::iterator i = setBanned.find(ip);
if (i != setBanned.end())
{
- int64 t = (*i).second;
+ int64_t t = (*i).second;
if (GetTime() < t)
fResult = true;
}
nMisbehavior += howmuch;
if (nMisbehavior >= GetArg("-banscore", 100))
{
- int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
+ int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
printf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
{
LOCK(cs_setBanned);
void DumpAddresses()
{
- int64 nStart = GetTimeMillis();
+ int64_t nStart = GetTimeMillis();
CAddrDB adb;
adb.Write(addrman);
- printf("Flushed %d addresses to peers.dat %" PRI64d "ms\n",
+ printf("Flushed %d addresses to peers.dat %" PRId64 "ms\n",
addrman.size(), GetTimeMillis() - nStart);
}
// Connect to specific addresses
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0)
{
- for (int64 nLoop = 0;; nLoop++)
+ for (int64_t nLoop = 0;; nLoop++)
{
ProcessOneShot();
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
}
// Initiate network connections
- int64 nStart = GetTime();
+ int64_t nStart = GetTime();
while (true)
{
ProcessOneShot();
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time' of between one and two
// weeks ago.
- const int64 nOneWeek = 7*24*60*60;
+ const int64_t nOneWeek = 7*24*60*60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
}
}
- int64 nANow = GetAdjustedTime();
+ int64_t nANow = GetAdjustedTime();
int nTries = 0;
while (true)
printf("StopNode()\n");
fShutdown = true;
nTransactionsUpdated++;
- int64 nStart = GetTime();
+ int64_t nStart = GetTime();
{
LOCK(cs_main);
ThreadScriptCheckQuit();
void AddressCurrentlyConnected(const CService& addr);
CNode* FindNode(const CNetAddr& ip);
CNode* FindNode(const CService& ip);
-CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, int64 nTimeout=0);
+CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, int64_t nTimeout=0);
void MapPort();
unsigned short GetListenPort();
bool BindListenPort(const CService &bindAddr, std::string& strError=REF(std::string()));
extern bool fClient;
extern bool fDiscover;
extern bool fUseUPnP;
-extern uint64 nLocalServices;
-extern uint64 nLocalHostNonce;
+extern uint64_t nLocalServices;
+extern uint64_t nLocalHostNonce;
extern CAddress addrSeenByPeer;
extern boost::array<int, THREAD_MAX> vnThreadsRunning;
extern CAddrMan addrman;
extern std::vector<CNode*> vNodes;
extern CCriticalSection cs_vNodes;
extern std::map<CInv, CDataStream> mapRelay;
-extern std::deque<std::pair<int64, CInv> > vRelayExpiration;
+extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration;
extern CCriticalSection cs_mapRelay;
-extern std::map<CInv, int64> mapAlreadyAskedFor;
+extern std::map<CInv, int64_t> mapAlreadyAskedFor;
class CNodeStats
{
public:
- uint64 nServices;
- int64 nLastSend;
- int64 nLastRecv;
- int64 nTimeConnected;
+ uint64_t nServices;
+ int64_t nLastSend;
+ int64_t nLastRecv;
+ int64_t nTimeConnected;
std::string addrName;
int nVersion;
std::string strSubVer;
bool fInbound;
- int64 nReleaseTime;
+ int64_t nReleaseTime;
int nStartingHeight;
int nMisbehavior;
- uint64 nSendBytes;
- uint64 nRecvBytes;
+ uint64_t nSendBytes;
+ uint64_t nRecvBytes;
bool fSyncNode;
};
{
public:
// socket
- uint64 nServices;
+ uint64_t nServices;
SOCKET hSocket;
CDataStream vSend;
CDataStream vRecv;
- uint64 nSendBytes;
- uint64 nRecvBytes;
+ uint64_t nSendBytes;
+ uint64_t nRecvBytes;
CCriticalSection cs_vSend;
CCriticalSection cs_vRecv;
- int64 nLastSend;
- int64 nLastRecv;
- int64 nLastSendEmpty;
- int64 nTimeConnected;
+ int64_t nLastSend;
+ int64_t nLastRecv;
+ int64_t nLastSendEmpty;
+ int64_t nTimeConnected;
int nHeaderStart;
unsigned int nMessageStart;
CAddress addr;
// Denial-of-service detection/prevention
// Key is IP address, value is banned-until-time
- static std::map<CNetAddr, int64> setBanned;
+ static std::map<CNetAddr, int64_t> setBanned;
static CCriticalSection cs_setBanned;
int nMisbehavior;
public:
- int64 nReleaseTime;
+ int64_t nReleaseTime;
std::map<uint256, CRequestTracker> mapRequests;
CCriticalSection cs_mapRequests;
uint256 hashContinue;
mruset<CInv> setInventoryKnown;
std::vector<CInv> vInventoryToSend;
CCriticalSection cs_inventory;
- std::multimap<int64, CInv> mapAskFor;
+ std::multimap<int64_t, CInv> mapAskFor;
CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : vSend(SER_NETWORK, MIN_PROTO_VERSION), vRecv(SER_NETWORK, MIN_PROTO_VERSION)
{
return std::max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);
}
- CNode* AddRef(int64 nTimeout=0)
+ CNode* AddRef(int64_t nTimeout=0)
{
if (nTimeout != 0)
nReleaseTime = std::max(nReleaseTime, GetTime() + nTimeout);
{
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
- int64& nRequestTime = mapAlreadyAskedFor[inv];
+ int64_t& nRequestTime = mapAlreadyAskedFor[inv];
if (fDebugNet)
- printf("askfor %s %" PRI64d " (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
+ printf("askfor %s %" PRId64 " (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
// Make sure not to reuse time indexes to keep things in the same order
- int64 nNow = (GetTime() - 1) * 1000000;
- static int64 nLastTime;
+ int64_t nNow = (GetTime() - 1) * 1000000;
+ static int64_t nLastTime;
++nLastTime;
nNow = std::max(nNow, nLastTime);
nLastTime = nNow;
return vchRet;
}
-uint64 CNetAddr::GetHash() const
+uint64_t CNetAddr::GetHash() const
{
uint256 hash = Hash(&ip[0], &ip[16]);
- uint64 nRet;
+ uint64_t nRet;
memcpy(&nRet, &hash, sizeof(nRet));
return nRet;
}
std::string ToString() const;
std::string ToStringIP() const;
unsigned int GetByte(int n) const;
- uint64 GetHash() const;
+ uint64_t GetHash() const;
bool GetInAddr(struct in_addr* pipv4Addr) const;
std::vector<unsigned char> GetGroup() const;
int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const;
return 4;
}
-static bool noui_ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption)
+static bool noui_ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption)
{
return true;
}
+++ /dev/null
-*
-!.gitignore
Init();
}
-CAddress::CAddress(CService ipIn, uint64 nServicesIn) : CService(ipIn)
+CAddress::CAddress(CService ipIn, uint64_t nServicesIn) : CService(ipIn)
{
Init();
nServices = nServicesIn;
{
public:
CAddress();
- explicit CAddress(CService ipIn, uint64 nServicesIn=NODE_NETWORK);
+ explicit CAddress(CService ipIn, uint64_t nServicesIn=NODE_NETWORK);
void Init();
// TODO: make private (improves encapsulation)
public:
- uint64 nServices;
+ uint64_t nServices;
// disk and network only
unsigned int nTime;
// memory only
- int64 nLastTry;
+ int64_t nLastTry;
};
/** inv message data */
}
}
-static bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption)
+static bool ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption)
{
if(!guiref)
return false;
{
labelMiningIcon->setPixmap(QIcon(":/icons/mining_active").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
- uint64 nNetworkWeight = clientModel->getPoSKernelPS();
+ uint64_t nNetworkWeight = clientModel->getPoSKernelPS();
/*
double dDifficulty = clientModel->getDifficulty(true);
QString msg;
extern double GetPoSKernelPS();
extern double GetDifficulty(const CBlockIndex* blockindex);
-static const int64 nClientStartupTime = GetTime();
+static const int64_t nClientStartupTime = GetTime();
ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
QObject(parent), optionsModel(optionsModel),
ui->treeWidget->setColumnWidth(COLUMN_WEIGHT, 100);
ui->treeWidget->setColumnHidden(COLUMN_TXHASH, true); // store transacton hash in this column, but dont show it
ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but dont show it
- ui->treeWidget->setColumnHidden(COLUMN_AMOUNT_INT64, true); // store amount int64 in this column, but dont show it
- ui->treeWidget->setColumnHidden(COLUMN_PRIORITY_INT64, true); // store priority int64 in this column, but dont show it
+ ui->treeWidget->setColumnHidden(COLUMN_AMOUNT_INT64, true); // store amount int64_t in this column, but dont show it
+ ui->treeWidget->setColumnHidden(COLUMN_PRIORITY_INT64, true); // store priority int64_t in this column, but dont show it
// default view is sorted by amount desc
sortView(COLUMN_AMOUNT_INT64, Qt::DescendingOrder);
}
QString sPriorityLabel = "";
- int64 nAmount = 0;
- int64 nPayFee = 0;
- int64 nAfterFee = 0;
- int64 nChange = 0;
+ int64_t nAmount = 0;
+ int64_t nPayFee = 0;
+ int64_t nAfterFee = 0;
+ int64_t nChange = 0;
unsigned int nBytes = 0;
unsigned int nBytesInputs = 0;
double dPriority = 0;
sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority);
// Fee
- int64 nFee = nTransactionFee * (1 + (int64)nBytes / 1000);
+ int64_t nFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
// Min Fee
bool fAllowFree = CTransaction::AllowFree(dPriority);
fAllowFree = false;
}
- int64 nMinFee = txDummy.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
+ int64_t nMinFee = txDummy.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
nPayFee = max(nFee, nMinFee);
itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress);
}
- int64 nSum = 0;
+ int64_t nSum = 0;
double dPrioritySum = 0;
int nChildren = 0;
int nInputSum = 0;
- uint64 nTxWeight = 0, nTxWeightSum = 0;
+ uint64_t nTxWeight = 0, nTxWeightSum = 0;
BOOST_FOREACH(const COutput& out, coins.second)
{
int nInputSize = 148; // 180 if uncompressed public key
// priority
double dPriority = ((double)out.tx->vout[out.i].nValue / (nInputSize + 78)) * (out.nDepth+1); // 78 = 2 * 34 + 10
itemOutput->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPriority));
- itemOutput->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64)dPriority), 20, " "));
+ itemOutput->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPriority), 20, " "));
dPrioritySum += (double)out.tx->vout[out.i].nValue * (out.nDepth+1);
nInputSum += nInputSize;
itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum));
itemWalletAddress->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(nSum), 15, " "));
itemWalletAddress->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPrioritySum));
- itemWalletAddress->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64)dPrioritySum), 20, " "));
- itemWalletAddress->setText(COLUMN_WEIGHT, strPad(QString::number((uint64)nTxWeightSum),8," "));
+ itemWalletAddress->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPrioritySum), 20, " "));
+ itemWalletAddress->setText(COLUMN_WEIGHT, strPad(QString::number((uint64_t)nTxWeightSum),8," "));
}
}
case TxHash:
return formatTxHash(rec);
case Age:
- return rec->getAge();
+ return static_cast<qlonglong>(rec->getAge());
case CoinDay:
- return rec->coinAge;
+ return static_cast<qlonglong>(rec->coinAge);
case Balance:
- return rec->nValue;
+ return static_cast<qlonglong>(rec->nValue);
case MintProbability:
return getDayToMint(rec);
case MintReward:
QString MintingTableModel::formatTxAge(const KernelRecord *wtx) const
{
- int64 nAge = wtx->getAge();
+ int64_t nAge = wtx->getAge();
return QString::number(nAge);
}
CBitcoinAddress address(recipient.address.toStdString());
CScript scriptPubKey;
scriptPubKey.SetDestination(address.Get());
- int64 amount = recipient.amount;
+ int64_t amount = recipient.amount;
CTxOut output(amount, scriptPubKey);
transaction.vout.push_back(output);
}
void MultisigDialog::on_sendTransactionButton_clicked()
{
- int64 transactionSize = ui->signedTransaction->text().size() / 2;
+ int64_t transactionSize = ui->signedTransaction->text().size() / 2;
if(transactionSize == 0)
return;
// Check the fee
- int64 fee = (int64 ) (ui->fee->text().toDouble() * COIN);
- int64 minFee = MIN_TX_FEE * (1 + (int64) transactionSize / 1000);
+ int64_t fee = (int64_t ) (ui->fee->text().toDouble() * COIN);
+ int64_t minFee = MIN_TX_FEE * (1 + (int64_t) transactionSize / 1000);
if(fee < minFee)
{
QMessageBox::StandardButton ret = QMessageBox::question(this, tr("Confirm send transaction"), tr("The fee of the transaction (%1 NVC) is smaller than the expected fee (%2 NVC). Do you want to send the transaction anyway?").arg((double) fee / COIN).arg((double) minFee / COIN), QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
void MultisigDialog::updateAmounts()
{
// Update inputs amount
- int64 inputsAmount = 0;
+ int64_t inputsAmount = 0;
for(int i = 0; i < ui->inputs->count(); i++)
{
MultisigInputEntry *entry = qobject_cast<MultisigInputEntry *>(ui->inputs->itemAt(i)->widget());
ui->inputsAmount->setText(inputsAmountStr);
// Update outputs amount
- int64 outputsAmount = 0;
+ int64_t outputsAmount = 0;
for(int i = 0; i < ui->outputs->count(); i++)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>(ui->outputs->itemAt(i)->widget());
ui->outputsAmount->setText(outputsAmountStr);
// Update Fee amount
- int64 fee = inputsAmount - outputsAmount;
+ int64_t fee = inputsAmount - outputsAmount;
QString feeStr;
feeStr.sprintf("%.6f", (double) fee / COIN);
ui->fee->setText(feeStr);
return input;
}
-int64 MultisigInputEntry::getAmount()
+int64_t MultisigInputEntry::getAmount()
{
- int64 amount = 0;
+ int64_t amount = 0;
int nOutput = ui->transactionOutput->currentIndex();
CTransaction tx;
uint256 blockHash = 0;
QString idStr;
idStr.setNum(i);
const CTxOut& txOut = tx.vout[i];
- int64 amount = txOut.nValue;
+ int64_t amount = txOut.nValue;
QString amountStr;
amountStr.sprintf("%.6f", (double) amount / COIN);
CScript script = txOut.scriptPubKey;
void setModel(WalletModel *model);
bool validate();
CTxIn getInput();
- int64 getAmount();
+ int64_t getAmount();
QString getRedeemScript();
void setTransactionId(QString transactionId);
void setTransactionOutputIndex(int index);
case ProxySocksVersion:
return settings.value("nSocksVersion", 5);
case Fee:
- return QVariant(nTransactionFee);
+ return QVariant(static_cast<qlonglong>(nTransactionFee));
case DisplayUnit:
return QVariant(nDisplayUnit);
case DisplayAddresses:
break;
case Fee:
nTransactionFee = value.toLongLong();
- settings.setValue("nTransactionFee", nTransactionFee);
+ settings.setValue("nTransactionFee", static_cast<qlonglong>(nTransactionFee));
emit transactionFeeChanged(nTransactionFee);
break;
case DisplayUnit:
strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
- int64 nTime = wtx.GetTxTime();
- int64 nCredit = wtx.GetCredit(MINE_ALL);
- int64 nDebit = wtx.GetDebit(MINE_ALL);
- int64 nNet = nCredit - nDebit;
+ int64_t nTime = wtx.GetTxTime();
+ int64_t nCredit = wtx.GetCredit(MINE_ALL);
+ int64_t nDebit = wtx.GetDebit(MINE_ALL);
+ int64_t nNet = nCredit - nDebit;
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
int nRequests = wtx.GetRequestCount();
//
// Coinbase
//
- int64 nUnmatured = 0;
+ int64_t nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout, MINE_ALL);
strHTML += "<b>" + tr("Credit") + ":</b> ";
if (fAllToMe)
{
// Payment to self
- int64 nChange = wtx.GetChange();
- int64 nValue = nCredit - nChange;
+ int64_t nChange = wtx.GetChange();
+ int64_t nValue = nCredit - nChange;
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nValue) + "<br>";
}
- int64 nTxFee = nDebit - wtx.GetValueOut();
+ int64_t nTxFee = nDebit - wtx.GetValueOut();
if (nTxFee > 0)
strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nTxFee) + "<br>";
}
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
{
QList<TransactionRecord> parts;
- int64 nTime = wtx.GetTxTime();
- int64 nCredit = wtx.GetCredit(true);
- int64 nDebit = wtx.GetDebit(MINE_ALL);
- int64 nNet = nCredit - nDebit;
+ int64_t nTime = wtx.GetTxTime();
+ int64_t nCredit = wtx.GetCredit(true);
+ int64_t nDebit = wtx.GetDebit(MINE_ALL);
+ int64_t nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash(), hashPrev = 0;
std::map<std::string, std::string> mapValue = wtx.mapValue;
if (fAllFromMe && fAllToMe)
{
// Payment to self
- int64 nChange = wtx.GetChange();
+ int64_t nChange = wtx.GetChange();
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
//
// Debit
//
- int64 nTxFee = nDebit - wtx.GetValueOut();
+ int64_t nTxFee = nDebit - wtx.GetValueOut();
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
{
sub.address = mapValue["to"];
}
- int64 nValue = txout.nValue;
+ int64_t nValue = txout.nValue;
/* Add fee to first output */
if (nTxFee > 0)
{
/** @name Reported status
@{*/
Status status;
- int64 depth;
- int64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */
+ int64_t depth;
+ int64_t open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */
/**@}*/
/** Current number of blocks (to know whether cached status is still valid) */
{
}
- TransactionRecord(uint256 hash, int64 time):
+ TransactionRecord(uint256 hash, int64_t time):
hash(hash), time(time), type(Other), address(""), debit(0),
credit(0), idx(0)
{
}
- TransactionRecord(uint256 hash, int64 time,
+ TransactionRecord(uint256 hash, int64_t time,
Type type, const std::string &address,
- int64 debit, int64 credit):
+ int64_t debit, int64_t credit):
hash(hash), time(time), type(type), address(address), debit(debit), credit(credit),
idx(0)
{
/** @name Immutable transaction attributes
@{*/
uint256 hash;
- int64 time;
+ int64_t time;
Type type;
std::string address;
- int64 debit;
- int64 credit;
+ int64_t debit;
+ int64_t credit;
/**@}*/
/** Subtransaction index, for sort key */
case Status:
return QString::fromStdString(rec->status.sortKey);
case Date:
- return rec->time;
+ // We need cast here to prevent ambigious conversion error
+ return static_cast<qlonglong>(rec->time);
case Type:
return formatTxType(rec);
case ToAddress:
return formatTxToAddress(rec, true);
case Amount:
- return rec->credit + rec->debit;
+ // Same here
+ return static_cast<qlonglong>(rec->credit + rec->debit);
}
break;
case Qt::ToolTipRole:
case LabelRole:
return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
case AmountRole:
- return rec->credit + rec->debit;
+ // And here
+ return static_cast<qlonglong>(rec->credit + rec->debit);
case TxIDRole:
return QString::fromStdString(rec->getTxID());
case TxHashRole:
return DuplicateAddress;
}
- int64 nBalance = 0;
+ int64_t nBalance = 0;
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins, true, coinControl);
LOCK2(cs_main, wallet->cs_wallet);
// Sendmany
- std::vector<std::pair<CScript, int64> > vecSend;
+ std::vector<std::pair<CScript, int64_t> > vecSend;
foreach(const SendCoinsRecipient &rcp, recipients)
{
CScript scriptPubKey;
CWalletTx wtx;
CReserveKey keyChange(wallet);
- int64 nFeeRequired = 0;
+ int64_t nFeeRequired = 0;
bool fCreated = wallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, coinControl);
if(!fCreated)
wallet->GetStakeStats(nKernelsRate, nCoinDaysRate);
}
-void WalletModel::getStakeWeightFromValue(const int64& nTime, const int64& nValue, uint64& nWeight)
+void WalletModel::getStakeWeightFromValue(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight)
{
wallet->GetStakeWeightFromValue(nTime, nValue, nWeight);
}
bool importWallet(const QString &filename);
void getStakeStats(float &nKernelsRate, float &nCoinDaysRate);
- void getStakeWeightFromValue(const qint64& nTime, const qint64& nValue, quint64& nWeight);
+ void getStakeWeightFromValue(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight);
// RAI object for unlocking wallet, returned by requestUnlock()
class UnlockContext
double GetPoWMHashPS()
{
int nPoWInterval = 72;
- int64 nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30;
+ int64_t nTargetSpacingWorkMin = 30, nTargetSpacingWork = 30;
CBlockIndex* pindex = pindexGenesisBlock;
CBlockIndex* pindexPrevWork = pindexGenesisBlock;
{
if (pindex->IsProofOfWork())
{
- int64 nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
+ int64_t nActualSpacingWork = pindex->GetBlockTime() - pindexPrevWork->GetBlockTime();
nTargetSpacingWork = ((nPoWInterval - 1) * nTargetSpacingWork + nActualSpacingWork + nActualSpacingWork) / (nPoWInterval + 1);
nTargetSpacingWork = max(nTargetSpacingWork, nTargetSpacingWorkMin);
pindexPrevWork = pindex;
result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": "")));
result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex()));
result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit()));
- result.push_back(Pair("modifier", strprintf("%016" PRI64x, blockindex->nStakeModifier)));
+ result.push_back(Pair("modifier", strprintf("%016" PRIx64, blockindex->nStakeModifier)));
result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum)));
Array txinfo;
BOOST_FOREACH (const CTransaction& tx, block.vtx)
{
public:
CBlockIndex *pindex;
- int64 nValue;
+ int64_t nValue;
bool fSpent;
CWalletTx* ptx;
int nOut;
// Update block
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
- static int64 nStart;
+ static int64_t nStart;
static CBlock* pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
// Update block
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
- static int64 nStart;
+ static int64_t nStart;
static CBlock* pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
// Update block
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
- static int64 nStart;
+ static int64_t nStart;
static CBlock* pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5))
Object obj;
obj.push_back(Pair("addr", stats.addrName));
- obj.push_back(Pair("services", strprintf("%08" PRI64x, stats.nServices)));
+ obj.push_back(Pair("services", strprintf("%08" PRIx64, stats.nServices)));
obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend));
obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv));
obj.push_back(Pair("bytessent", (boost::int64_t)stats.nSendBytes));
continue;
}
- int64 nValue = out.tx->vout[out.i].nValue;
+ int64_t nValue = out.tx->vout[out.i].nValue;
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
Object entry;
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
CScript scriptPubKey;
scriptPubKey.SetDestination(address.Get());
- int64 nAmount = AmountFromValue(s.value_);
+ int64_t nAmount = AmountFromValue(s.value_);
CTxOut out(nAmount, scriptPubKey);
rawTx.vout.push_back(out);
using namespace json_spirit;
using namespace std;
-int64 nWalletUnlockTime;
+int64_t nWalletUnlockTime;
static CCriticalSection cs_nWalletUnlockTime;
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry);
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
// Total amount
- int64 nAmount = AmountFromValue(params[0]);
+ int64_t nAmount = AmountFromValue(params[0]);
// Min input amount
- int64 nMinValue = AmountFromValue(params[1]);
+ int64_t nMinValue = AmountFromValue(params[1]);
// Output amount
- int64 nOutputValue = AmountFromValue(params[2]);
+ int64_t nOutputValue = AmountFromValue(params[2]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
// Amount
- int64 nAmount = AmountFromValue(params[1]);
+ int64_t nAmount = AmountFromValue(params[1]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
"in past transactions");
Array jsonGroupings;
- map<CTxDestination, int64> balances = pwalletMain->GetAddressBalances();
+ map<CTxDestination, int64_t> balances = pwalletMain->GetAddressBalances();
BOOST_FOREACH(set<CTxDestination> grouping, pwalletMain->GetAddressGroupings())
{
Array jsonGrouping;
nMinDepth = params[1].get_int();
// Tally
- int64 nAmount = 0;
+ int64_t nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
GetAccountAddresses(strAccount, setAddress);
// Tally
- int64 nAmount = 0;
+ int64_t nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
}
-int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth, const isminefilter& filter)
+int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth, const isminefilter& filter)
{
- int64 nBalance = 0;
+ int64_t nBalance = 0;
// Tally wallet transactions
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
if (!wtx.IsFinal())
continue;
- int64 nGenerated, nReceived, nSent, nFee;
+ int64_t nGenerated, nReceived, nSent, nFee;
wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee, filter);
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
return nBalance;
}
-int64 GetAccountBalance(const string& strAccount, int nMinDepth, const isminefilter& filter)
+int64_t GetAccountBalance(const string& strAccount, int nMinDepth, const isminefilter& filter)
{
CWalletDB walletdb(pwalletMain->strWalletFile);
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
// Calculate total balance a different way from GetBalance()
// (GetBalance() sums up all unspent TxOuts)
// getbalance and getbalance '*' 0 should return the same number.
- int64 nBalance = 0;
+ int64_t nBalance = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (!wtx.IsTrusted())
continue;
- int64 allGeneratedImmature, allGeneratedMature, allFee;
+ int64_t allGeneratedImmature, allGeneratedMature, allFee;
allGeneratedImmature = allGeneratedMature = allFee = 0;
string strSentAccount;
- list<pair<CTxDestination, int64> > listReceived;
- list<pair<CTxDestination, int64> > listSent;
+ list<pair<CTxDestination, int64_t> > listReceived;
+ list<pair<CTxDestination, int64_t> > listSent;
wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount, filter);
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listReceived)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived)
nBalance += r.second;
}
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listSent)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listSent)
nBalance -= r.second;
nBalance -= allFee;
nBalance += allGeneratedMature;
string strAccount = AccountFromValue(params[0]);
- int64 nBalance = GetAccountBalance(strAccount, nMinDepth, filter);
+ int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, filter);
return ValueFromAmount(nBalance);
}
string strFrom = AccountFromValue(params[0]);
string strTo = AccountFromValue(params[1]);
- int64 nAmount = AmountFromValue(params[2]);
+ int64_t nAmount = AmountFromValue(params[2]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
if (!walletdb.TxnBegin())
throw JSONRPCError(RPC_DATABASE_ERROR, "database error");
- int64 nNow = GetAdjustedTime();
+ int64_t nNow = GetAdjustedTime();
// Debit
CAccountingEntry debit;
CBitcoinAddress address(params[1].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
- int64 nAmount = AmountFromValue(params[2]);
+ int64_t nAmount = AmountFromValue(params[2]);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
EnsureWalletIsUnlocked();
// Check funds
- int64 nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
+ int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
if (nAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
wtx.mapValue["comment"] = params[3].get_str();
set<CBitcoinAddress> setAddress;
- vector<pair<CScript, int64> > vecSend;
+ vector<pair<CScript, int64_t> > vecSend;
- int64 totalAmount = 0;
+ int64_t totalAmount = 0;
BOOST_FOREACH(const Pair& s, sendTo)
{
CBitcoinAddress address(s.name_);
CScript scriptPubKey;
scriptPubKey.SetDestination(address.Get());
- int64 nAmount = AmountFromValue(s.value_);
+ int64_t nAmount = AmountFromValue(s.value_);
if (nAmount < MIN_TXOUT_AMOUNT)
throw JSONRPCError(-101, "Send amount too small");
EnsureWalletIsUnlocked();
// Check funds
- int64 nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
+ int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
if (totalAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
// Send
CReserveKey keyChange(pwalletMain);
- int64 nFeeRequired = 0;
+ int64_t nFeeRequired = 0;
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired);
if (!fCreated)
{
- int64 nTotal = pwalletMain->GetBalance(), nWatchOnly = pwalletMain->GetWatchOnlyBalance();
+ int64_t nTotal = pwalletMain->GetBalance(), nWatchOnly = pwalletMain->GetWatchOnlyBalance();
if (totalAmount + nFeeRequired > nTotal - nWatchOnly)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
throw JSONRPCError(RPC_WALLET_ERROR, "Transaction creation failed");
struct tallyitem
{
- int64 nAmount;
+ int64_t nAmount;
int nConf;
tallyitem()
{
if (it == mapTally.end() && !fIncludeEmpty)
continue;
- int64 nAmount = 0;
+ int64_t nAmount = 0;
int nConf = std::numeric_limits<int>::max();
if (it != mapTally.end())
{
{
for (map<string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it)
{
- int64 nAmount = (*it).second.nAmount;
+ int64_t nAmount = (*it).second.nAmount;
int nConf = (*it).second.nConf;
Object obj;
obj.push_back(Pair("account", (*it).first));
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret, const isminefilter& filter)
{
- int64 nGeneratedImmature, nGeneratedMature, nFee;
+ int64_t nGeneratedImmature, nGeneratedMature, nFee;
string strSentAccount;
- list<pair<CTxDestination, int64> > listReceived;
- list<pair<CTxDestination, int64> > listSent;
+ list<pair<CTxDestination, int64_t> > listReceived;
+ list<pair<CTxDestination, int64_t> > listSent;
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount, filter);
// Sent
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
{
- BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& s, listSent)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent)
{
Object entry;
entry.push_back(Pair("account", strSentAccount));
// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
{
- BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& r, listReceived)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived)
{
string account;
if (pwalletMain->mapAddressBook.count(r.first))
includeWatchonly = includeWatchonly | MINE_WATCH_ONLY;
- map<string, int64> mapAccountBalances;
+ map<string, int64_t> mapAccountBalances;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& entry, pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, entry.first)) // This address belongs to me
mapAccountBalances[entry.second] = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
- int64 nGeneratedImmature, nGeneratedMature, nFee;
+ int64_t nGeneratedImmature, nGeneratedMature, nFee;
string strSentAccount;
- list<pair<CTxDestination, int64> > listReceived;
- list<pair<CTxDestination, int64> > listSent;
+ list<pair<CTxDestination, int64_t> > listReceived;
+ list<pair<CTxDestination, int64_t> > listSent;
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount, includeWatchonly);
mapAccountBalances[strSentAccount] -= nFee;
- BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& s, listSent)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent)
mapAccountBalances[strSentAccount] -= s.second;
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
mapAccountBalances[""] += nGeneratedMature;
- BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64)& r, listReceived)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived)
if (pwalletMain->mapAddressBook.count(r.first))
mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second;
else
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
Object ret;
- BOOST_FOREACH(const PAIRTYPE(string, int64)& accountBalance, mapAccountBalances) {
+ BOOST_FOREACH(const PAIRTYPE(string, int64_t)& accountBalance, mapAccountBalances) {
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
}
return ret;
TxToJSON(wtx, 0, entry);
- int64 nCredit = wtx.GetCredit(filter);
- int64 nDebit = wtx.GetDebit(filter);
- int64 nNet = nCredit - nDebit;
- int64 nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);
+ int64_t nCredit = wtx.GetCredit(filter);
+ int64_t nDebit = wtx.GetDebit(filter);
+ int64_t nNet = nCredit - nDebit;
+ int64_t nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
if (wtx.IsFromMe(filter))
"Fills the keypool."
+ HelpRequiringPassphrase());
- unsigned int nSize = max(GetArg("-keypool", 100), 0LL);
+ unsigned int nSize = max<unsigned int>(GetArg("-keypool", 100), 0);
if (params.size() > 0) {
if (params[0].get_int() < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size");
// Make this thread recognisable as the wallet relocking thread
RenameThread("novacoin-lock-wa");
- int64 nMyWakeTime = GetTimeMillis() + *((int64*)parg) * 1000;
+ int64_t nMyWakeTime = GetTimeMillis() + *((int64_t*)parg) * 1000;
ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime);
{
if (nWalletUnlockTime==0)
break;
- int64 nToSleep = nWalletUnlockTime - GetTimeMillis();
+ int64_t nToSleep = nWalletUnlockTime - GetTimeMillis();
if (nToSleep <= 0)
break;
LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime);
- delete (int64*)parg;
+ delete (int64_t*)parg;
}
Value walletpassphrase(const Array& params, bool fHelp)
"Stores the wallet decryption key in memory for <timeout> seconds.");
NewThread(ThreadTopUpKeyPool, NULL);
- int64* pnSleepTime = new int64(params[1].get_int64());
+ int64_t* pnSleepTime = new int64_t(params[1].get_int64());
NewThread(ThreadCleanWalletPassphrase, pnSleepTime);
// ppcoin: if user OS account compromised prevent trivial sendmoney commands
{
if (params.size() == 1)
throw runtime_error("must provide amount to reserve balance.\n");
- int64 nAmount = AmountFromValue(params[1]);
+ int64_t nAmount = AmountFromValue(params[1]);
nAmount = (nAmount / CENT) * CENT; // round to cent
if (nAmount < 0)
throw runtime_error("amount cannot be negative.\n");
}
Object result;
- int64 nReserveBalance = 0;
+ int64_t nReserveBalance = 0;
if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
throw runtime_error("invalid reserve balance amount\n");
result.push_back(Pair("reserve", (nReserveBalance > 0)));
"Check wallet for integrity.\n");
int nMismatchSpent;
- int64 nBalanceInQuestion;
+ int64_t nBalanceInQuestion;
pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion, true);
Object result;
if (nMismatchSpent == 0)
"Repair wallet if checkwallet reports any problem.\n");
int nMismatchSpent;
- int64 nBalanceInQuestion;
+ int64_t nBalanceInQuestion;
pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion);
Object result;
if (nMismatchSpent == 0)
// (~200 bytes per cache entry times 50,000 entries)
// Since there are a maximum of 20,000 signature operations per block
// 50,000 is a reasonable default.
- int64 nMaxCacheSize = GetArg("-maxsigcachesize", 50000);
+ int64_t nMaxCacheSize = GetArg("-maxsigcachesize", 50000);
if (nMaxCacheSize <= 0) return;
boost::shared_lock<boost::shared_mutex> lock(cs_sigcache);
- while (static_cast<int64>(setValid.size()) > nMaxCacheSize)
+ while (static_cast<int64_t>(setValid.size()) > nMaxCacheSize)
{
// Evict a random entry. Random because that helps
// foil would-be DoS attackers who might try to pre-generate
class CScript : public std::vector<unsigned char>
{
protected:
- CScript& push_int64(int64 n)
+ CScript& push_int64(int64_t n)
{
if (n == -1 || (n >= 1 && n <= 16))
{
return *this;
}
- CScript& push_uint64(uint64 n)
+ CScript& push_uint64(uint64_t n)
{
if (n >= 1 && n <= 16)
{
explicit CScript(short b) { operator<<(b); }
explicit CScript(int b) { operator<<(b); }
explicit CScript(long b) { operator<<(b); }
- explicit CScript(int64 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(uint64 b) { operator<<(b); }
explicit CScript(opcodetype b) { operator<<(b); }
explicit CScript(const uint256& b) { operator<<(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<<(int64 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<<(uint64 b) { return push_uint64(b); }
CScript& operator<<(opcodetype opcode)
{
#include <stdlib.h>
-#include <stdint.h>
#include "scrypt.h"
#include "pbkdf2.h"
#undef max
#endif
-typedef long long int64;
-typedef unsigned long long uint64;
+#include <inttypes.h>
class CScript;
class CDataStream;
inline unsigned int GetSerializeSize(unsigned short a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(signed int a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(unsigned int a, int, int=0) { return sizeof(a); }
-inline unsigned int GetSerializeSize(signed long a, int, int=0) { return sizeof(a); }
-inline unsigned int GetSerializeSize(unsigned long a, int, int=0) { return sizeof(a); }
-inline unsigned int GetSerializeSize(int64 a, int, int=0) { return sizeof(a); }
-inline unsigned int GetSerializeSize(uint64 a, int, int=0) { return sizeof(a); }
+//inline unsigned int GetSerializeSize(signed long a, int, int=0) { return sizeof(a); }
+//inline unsigned int GetSerializeSize(unsigned long a, int, int=0) { return sizeof(a); }
+inline unsigned int GetSerializeSize(int64_t a, int, int=0) { return sizeof(a); }
+inline unsigned int GetSerializeSize(uint64_t a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(float a, int, int=0) { return sizeof(a); }
inline unsigned int GetSerializeSize(double a, int, int=0) { return sizeof(a); }
template<typename Stream> inline void Serialize(Stream& s, unsigned short a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, signed int a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, unsigned int a, int, int=0) { WRITEDATA(s, a); }
-template<typename Stream> inline void Serialize(Stream& s, signed long a, int, int=0) { WRITEDATA(s, a); }
-template<typename Stream> inline void Serialize(Stream& s, unsigned long a, int, int=0) { WRITEDATA(s, a); }
-template<typename Stream> inline void Serialize(Stream& s, int64 a, int, int=0) { WRITEDATA(s, a); }
-template<typename Stream> inline void Serialize(Stream& s, uint64 a, int, int=0) { WRITEDATA(s, a); }
+//template<typename Stream> inline void Serialize(Stream& s, signed long a, int, int=0) { WRITEDATA(s, a); }
+//template<typename Stream> inline void Serialize(Stream& s, unsigned long a, int, int=0) { WRITEDATA(s, a); }
+template<typename Stream> inline void Serialize(Stream& s, int64_t a, int, int=0) { WRITEDATA(s, a); }
+template<typename Stream> inline void Serialize(Stream& s, uint64_t a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, float a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Serialize(Stream& s, double a, int, int=0) { WRITEDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, unsigned short& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, signed int& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, unsigned int& a, int, int=0) { READDATA(s, a); }
-template<typename Stream> inline void Unserialize(Stream& s, signed long& a, int, int=0) { READDATA(s, a); }
-template<typename Stream> inline void Unserialize(Stream& s, unsigned long& a, int, int=0) { READDATA(s, a); }
-template<typename Stream> inline void Unserialize(Stream& s, int64& a, int, int=0) { READDATA(s, a); }
-template<typename Stream> inline void Unserialize(Stream& s, uint64& a, int, int=0) { READDATA(s, a); }
+//template<typename Stream> inline void Unserialize(Stream& s, signed long& a, int, int=0) { READDATA(s, a); }
+//template<typename Stream> inline void Unserialize(Stream& s, unsigned long& a, int, int=0) { READDATA(s, a); }
+template<typename Stream> inline void Unserialize(Stream& s, int64_t& a, int, int=0) { READDATA(s, a); }
+template<typename Stream> inline void Unserialize(Stream& s, uint64_t& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, float& a, int, int=0) { READDATA(s, a); }
template<typename Stream> inline void Unserialize(Stream& s, double& a, int, int=0) { READDATA(s, a); }
// size <= UINT_MAX -- 5 bytes (254 + 4 bytes)
// size > UINT_MAX -- 9 bytes (255 + 8 bytes)
//
-inline unsigned int GetSizeOfCompactSize(uint64 nSize)
+inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
{
if (nSize < 253) return sizeof(unsigned char);
else if (nSize <= std::numeric_limits<unsigned short>::max()) return sizeof(unsigned char) + sizeof(unsigned short);
else if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int);
- else return sizeof(unsigned char) + sizeof(uint64);
+ else return sizeof(unsigned char) + sizeof(uint64_t);
}
template<typename Stream>
-void WriteCompactSize(Stream& os, uint64 nSize)
+void WriteCompactSize(Stream& os, uint64_t nSize)
{
if (nSize < 253)
{
else
{
unsigned char chSize = 255;
- uint64 xSize = nSize;
+ uint64_t xSize = nSize;
WRITEDATA(os, chSize);
WRITEDATA(os, xSize);
}
}
template<typename Stream>
-uint64 ReadCompactSize(Stream& is)
+uint64_t ReadCompactSize(Stream& is)
{
unsigned char chSize;
READDATA(is, chSize);
- uint64 nSizeRet = 0;
+ uint64_t nSizeRet = 0;
if (chSize < 253)
{
nSizeRet = chSize;
}
else
{
- uint64 xSize;
+ uint64_t xSize;
READDATA(is, xSize);
nSizeRet = xSize;
}
- if (nSizeRet > (uint64)MAX_SIZE)
+ if (nSizeRet > (uint64_t)MAX_SIZE)
throw std::ios_base::failure("ReadCompactSize() : size too large");
return nSizeRet;
}
{
private:
FILE *src; // source file
- uint64 nSrcPos; // how many bytes have been read from source
- uint64 nReadPos; // how many bytes have been read from this
- uint64 nReadLimit; // up to which position we're allowed to read
- uint64 nRewind; // how many bytes we guarantee to rewind
+ uint64_t nSrcPos; // how many bytes have been read from source
+ uint64_t nReadPos; // how many bytes have been read from this
+ uint64_t nReadLimit; // up to which position we're allowed to read
+ uint64_t nRewind; // how many bytes we guarantee to rewind
std::vector<char> vchBuf; // the buffer
short state;
int nType;
int nVersion;
- CBufferedFile(FILE *fileIn, uint64 nBufSize, uint64 nRewindIn, int nTypeIn, int nVersionIn) :
- src(fileIn), nSrcPos(0), nReadPos(0), nReadLimit((uint64)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0),
+ CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) :
+ src(fileIn), nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0),
state(0), exceptmask(std::ios_base::badbit | std::ios_base::failbit), nType(nTypeIn), nVersion(nVersionIn) {
}
}
// return the current reading position
- uint64 GetPos() {
+ uint64_t GetPos() {
return nReadPos;
}
// rewind to a given reading position
- bool SetPos(uint64 nPos) {
+ bool SetPos(uint64_t nPos) {
nReadPos = nPos;
if (nReadPos + nRewind < nSrcPos) {
nReadPos = nSrcPos - nRewind;
}
}
- bool Seek(uint64 nPos) {
+ bool Seek(uint64_t nPos) {
long nLongPos = nPos;
- if (nPos != (uint64)nLongPos)
+ if (nPos != (uint64_t)nLongPos)
return false;
if (fseek(src, nLongPos, SEEK_SET))
return false;
// prevent reading beyond a certain position
// no argument removes the limit
- bool SetLimit(uint64 nPos = (uint64)(-1)) {
+ bool SetLimit(uint64_t nPos = (uint64_t)(-1)) {
if (nPos < nReadPos)
return false;
nReadLimit = nPos;
+++ /dev/null
-//
-// Unit tests for block-chain checkpoints
-//
-#include <boost/assign/list_of.hpp> // for 'map_list_of()'
-#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
-
-#include "../checkpoints.h"
-#include "../util.h"
-
-using namespace std;
-
-BOOST_AUTO_TEST_SUITE(Checkpoints_tests)
-
-BOOST_AUTO_TEST_CASE(sanity)
-{
- uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
- uint256 p134444 = uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe");
- BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111));
- BOOST_CHECK(Checkpoints::CheckBlock(134444, p134444));
-
-
- // Wrong hashes at checkpoints should fail:
- BOOST_CHECK(!Checkpoints::CheckBlock(11111, p134444));
- BOOST_CHECK(!Checkpoints::CheckBlock(134444, p11111));
-
- // ... but any hash not at a checkpoint should succeed:
- BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p134444));
- BOOST_CHECK(Checkpoints::CheckBlock(134444+1, p11111));
-
- BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 134444);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-//
-// Unit tests for denial-of-service detection/prevention code
-//
-#include <algorithm>
-
-#include <boost/assign/list_of.hpp> // for 'map_list_of()'
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
-
-#include "main.h"
-#include "wallet.h"
-#include "net.h"
-#include "util.h"
-
-#include <stdint.h>
-
-// Tests this internal-to-main.cpp method:
-extern bool AddOrphanTx(const CDataStream& vMsg);
-extern unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans);
-extern std::map<uint256, CDataStream*> mapOrphanTransactions;
-extern std::map<uint256, std::map<uint256, CDataStream*> > mapOrphanTransactionsByPrev;
-
-CService ip(uint32_t i)
-{
- struct in_addr s;
- s.s_addr = i;
- return CService(CNetAddr(s), GetDefaultPort());
-}
-
-BOOST_AUTO_TEST_SUITE(DoS_tests)
-
-BOOST_AUTO_TEST_CASE(DoS_banning)
-{
- CNode::ClearBanned();
- CAddress addr1(ip(0xa0b0c001));
- CNode dummyNode1(INVALID_SOCKET, addr1, "", true);
- dummyNode1.Misbehaving(100); // Should get banned
- BOOST_CHECK(CNode::IsBanned(addr1));
- BOOST_CHECK(!CNode::IsBanned(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned
-
- CAddress addr2(ip(0xa0b0c002));
- CNode dummyNode2(INVALID_SOCKET, addr2, "", true);
- dummyNode2.Misbehaving(50);
- BOOST_CHECK(!CNode::IsBanned(addr2)); // 2 not banned yet...
- BOOST_CHECK(CNode::IsBanned(addr1)); // ... but 1 still should be
- dummyNode2.Misbehaving(50);
- BOOST_CHECK(CNode::IsBanned(addr2));
-}
-
-BOOST_AUTO_TEST_CASE(DoS_banscore)
-{
- CNode::ClearBanned();
- mapArgs["-banscore"] = "111"; // because 11 is my favorite number
- CAddress addr1(ip(0xa0b0c001));
- CNode dummyNode1(INVALID_SOCKET, addr1, "", true);
- dummyNode1.Misbehaving(100);
- BOOST_CHECK(!CNode::IsBanned(addr1));
- dummyNode1.Misbehaving(10);
- BOOST_CHECK(!CNode::IsBanned(addr1));
- dummyNode1.Misbehaving(1);
- BOOST_CHECK(CNode::IsBanned(addr1));
- mapArgs.erase("-banscore");
-}
-
-BOOST_AUTO_TEST_CASE(DoS_bantime)
-{
- CNode::ClearBanned();
- int64 nStartTime = GetTime();
- SetMockTime(nStartTime); // Overrides future calls to GetTime()
-
- CAddress addr(ip(0xa0b0c001));
- CNode dummyNode(INVALID_SOCKET, addr, "", true);
-
- dummyNode.Misbehaving(100);
- BOOST_CHECK(CNode::IsBanned(addr));
-
- SetMockTime(nStartTime+60*60);
- BOOST_CHECK(CNode::IsBanned(addr));
-
- SetMockTime(nStartTime+60*60*24+1);
- BOOST_CHECK(!CNode::IsBanned(addr));
-}
-
-static bool CheckNBits(unsigned int nbits1, int64 time1, unsigned int nbits2, int64 time2)\
-{
- if (time1 > time2)
- return CheckNBits(nbits2, time2, nbits1, time1);
- int64 deltaTime = time2-time1;
-
- CBigNum required;
- required.SetCompact(ComputeMinWork(nbits1, deltaTime));
- CBigNum have;
- have.SetCompact(nbits2);
- return (have <= required);
-}
-
-BOOST_AUTO_TEST_CASE(DoS_checknbits)
-{
- using namespace boost::assign; // for 'map_list_of()'
-
- // Timestamps,nBits from the bitcoin blockchain.
- // These are the block-chain checkpoint blocks
- typedef std::map<int64, unsigned int> BlockData;
- BlockData chainData =
- map_list_of(1239852051,486604799)(1262749024,486594666)
- (1279305360,469854461)(1280200847,469830746)(1281678674,469809688)
- (1296207707,453179945)(1302624061,453036989)(1309640330,437004818)
- (1313172719,436789733);
-
- // Make sure CheckNBits considers every combination of block-chain-lock-in-points
- // "sane":
- BOOST_FOREACH(const BlockData::value_type& i, chainData)
- {
- BOOST_FOREACH(const BlockData::value_type& j, chainData)
- {
- BOOST_CHECK(CheckNBits(i.second, i.first, j.second, j.first));
- }
- }
-
- // Test a couple of insane combinations:
- BlockData::value_type firstcheck = *(chainData.begin());
- BlockData::value_type lastcheck = *(chainData.rbegin());
-
- // First checkpoint difficulty at or a while after the last checkpoint time should fail when
- // compared to last checkpoint
- BOOST_CHECK(!CheckNBits(firstcheck.second, lastcheck.first+60*10, lastcheck.second, lastcheck.first));
- BOOST_CHECK(!CheckNBits(firstcheck.second, lastcheck.first+60*60*24*14, lastcheck.second, lastcheck.first));
-
- // ... but OK if enough time passed for difficulty to adjust downward:
- BOOST_CHECK(CheckNBits(firstcheck.second, lastcheck.first+60*60*24*365*4, lastcheck.second, lastcheck.first));
-
-}
-
-CTransaction RandomOrphan()
-{
- std::map<uint256, CDataStream*>::iterator it;
- it = mapOrphanTransactions.lower_bound(GetRandHash());
- if (it == mapOrphanTransactions.end())
- it = mapOrphanTransactions.begin();
- const CDataStream* pvMsg = it->second;
- CTransaction tx;
- CDataStream(*pvMsg) >> tx;
- return tx;
-}
-
-BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
-{
- CKey key;
- key.MakeNewKey(true);
- CBasicKeyStore keystore;
- keystore.AddKey(key);
-
- // 50 orphan transactions:
- for (int i = 0; i < 50; i++)
- {
- CTransaction tx;
- tx.vin.resize(1);
- tx.vin[0].prevout.n = 0;
- tx.vin[0].prevout.hash = GetRandHash();
- tx.vin[0].scriptSig << OP_1;
- tx.vout.resize(1);
- tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
-
- CDataStream ds(SER_DISK, CLIENT_VERSION);
- ds << tx;
- AddOrphanTx(ds);
- }
-
- // ... and 50 that depend on other orphans:
- for (int i = 0; i < 50; i++)
- {
- CTransaction txPrev = RandomOrphan();
-
- CTransaction tx;
- tx.vin.resize(1);
- tx.vin[0].prevout.n = 0;
- tx.vin[0].prevout.hash = txPrev.GetHash();
- tx.vout.resize(1);
- tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
- SignSignature(keystore, txPrev, tx, 0);
-
- CDataStream ds(SER_DISK, CLIENT_VERSION);
- ds << tx;
- AddOrphanTx(ds);
- }
-
- // This really-big orphan should be ignored:
- for (int i = 0; i < 10; i++)
- {
- CTransaction txPrev = RandomOrphan();
-
- CTransaction tx;
- tx.vout.resize(1);
- tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
- tx.vin.resize(500);
- for (unsigned int j = 0; j < tx.vin.size(); j++)
- {
- tx.vin[j].prevout.n = j;
- tx.vin[j].prevout.hash = txPrev.GetHash();
- }
- SignSignature(keystore, txPrev, tx, 0);
- // Re-use same signature for other inputs
- // (they don't have to be valid for this test)
- for (unsigned int j = 1; j < tx.vin.size(); j++)
- tx.vin[j].scriptSig = tx.vin[0].scriptSig;
-
- CDataStream ds(SER_DISK, CLIENT_VERSION);
- ds << tx;
- BOOST_CHECK(!AddOrphanTx(ds));
- }
-
- // Test LimitOrphanTxSize() function:
- LimitOrphanTxSize(40);
- BOOST_CHECK(mapOrphanTransactions.size() <= 40);
- LimitOrphanTxSize(10);
- BOOST_CHECK(mapOrphanTransactions.size() <= 10);
- LimitOrphanTxSize(0);
- BOOST_CHECK(mapOrphanTransactions.empty());
- BOOST_CHECK(mapOrphanTransactionsByPrev.empty());
-}
-
-BOOST_AUTO_TEST_CASE(DoS_checkSig)
-{
- // Test signature caching code (see key.cpp Verify() methods)
-
- CKey key;
- key.MakeNewKey(true);
- CBasicKeyStore keystore;
- keystore.AddKey(key);
-
- // 100 orphan transactions:
- static const int NPREV=100;
- CTransaction orphans[NPREV];
- for (int i = 0; i < NPREV; i++)
- {
- CTransaction& tx = orphans[i];
- tx.vin.resize(1);
- tx.vin[0].prevout.n = 0;
- tx.vin[0].prevout.hash = GetRandHash();
- tx.vin[0].scriptSig << OP_1;
- tx.vout.resize(1);
- tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
-
- CDataStream ds(SER_DISK, CLIENT_VERSION);
- ds << tx;
- AddOrphanTx(ds);
- }
-
- // Create a transaction that depends on orphans:
- CTransaction tx;
- tx.vout.resize(1);
- tx.vout[0].nValue = 1*CENT;
- tx.vout[0].scriptPubKey.SetDestination(key.GetPubKey().GetID());
- tx.vin.resize(NPREV);
- for (unsigned int j = 0; j < tx.vin.size(); j++)
- {
- tx.vin[j].prevout.n = 0;
- tx.vin[j].prevout.hash = orphans[j].GetHash();
- }
- // Creating signatures primes the cache:
- boost::posix_time::ptime mst1 = boost::posix_time::microsec_clock::local_time();
- for (unsigned int j = 0; j < tx.vin.size(); j++)
- BOOST_CHECK(SignSignature(keystore, orphans[j], tx, j));
- boost::posix_time::ptime mst2 = boost::posix_time::microsec_clock::local_time();
- boost::posix_time::time_duration msdiff = mst2 - mst1;
- long nOneValidate = msdiff.total_milliseconds();
- if (fDebug) printf("DoS_Checksig sign: %ld\n", nOneValidate);
-
- // ... now validating repeatedly should be quick:
- // 2.8GHz machine, -g build: Sign takes ~760ms,
- // uncached Verify takes ~250ms, cached Verify takes ~50ms
- // (for 100 single-signature inputs)
- mst1 = boost::posix_time::microsec_clock::local_time();
- for (unsigned int i = 0; i < 5; i++)
- for (unsigned int j = 0; j < tx.vin.size(); j++)
- BOOST_CHECK(VerifySignature(orphans[j], tx, j, true, SIGHASH_ALL));
- mst2 = boost::posix_time::microsec_clock::local_time();
- msdiff = mst2 - mst1;
- long nManyValidate = msdiff.total_milliseconds();
- if (fDebug) printf("DoS_Checksig five: %ld\n", nManyValidate);
-
- BOOST_CHECK_MESSAGE(nManyValidate < nOneValidate, "Signature cache timing failed");
-
- // Empty a signature, validation should fail:
- CScript save = tx.vin[0].scriptSig;
- tx.vin[0].scriptSig = CScript();
- BOOST_CHECK(!VerifySignature(orphans[0], tx, 0, true, SIGHASH_ALL));
- tx.vin[0].scriptSig = save;
-
- // Swap signatures, validation should fail:
- std::swap(tx.vin[0].scriptSig, tx.vin[1].scriptSig);
- BOOST_CHECK(!VerifySignature(orphans[0], tx, 0, true, SIGHASH_ALL));
- BOOST_CHECK(!VerifySignature(orphans[1], tx, 1, true, SIGHASH_ALL));
- std::swap(tx.vin[0].scriptSig, tx.vin[1].scriptSig);
-
- // Exercise -maxsigcachesize code:
- mapArgs["-maxsigcachesize"] = "10";
- // Generate a new, different signature for vin[0] to trigger cache clear:
- CScript oldSig = tx.vin[0].scriptSig;
- BOOST_CHECK(SignSignature(keystore, orphans[0], tx, 0));
- BOOST_CHECK(tx.vin[0].scriptSig != oldSig);
- for (unsigned int j = 0; j < tx.vin.size(); j++)
- BOOST_CHECK(VerifySignature(orphans[j], tx, j, true, SIGHASH_ALL));
- mapArgs.erase("-maxsigcachesize");
-
- LimitOrphanTxSize(0);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-The sources in this directory are unit test cases. Boost includes a
-unit testing framework, and since bitcoin already uses boost, it makes
-sense to simply use this framework rather than require developers to
-configure some other framework (we want as few impediments to creating
-unit tests as possible).
-
-The build system is setup to compile an executable called "test_bitcoin"
-that runs all of the unit tests. The main source file is called
-test_bitcoin.cpp, which simply includes other files that contain the
-actual unit tests (outside of a couple required preprocessor
-directives). The pattern is to create one test file for each class or
-source file for which you want to create unit tests. The file naming
-convention is "<source_filename>_tests.cpp" and such files should wrap
-their tests in a test suite called "<source_filename>_tests". For an
-examples of this pattern, examine uint160_tests.cpp and
-uint256_tests.cpp.
-
-For further reading, I found the following website to be helpful in
-explaining how the boost unit test framework works:
-
-http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include <boost/foreach.hpp>
-
-#include "init.h"
-#include "wallet.h"
-#include "walletdb.h"
-
-BOOST_AUTO_TEST_SUITE(accounting_tests)
-
-static void
-GetResults(CWalletDB& walletdb, std::map<int64, CAccountingEntry>& results)
-{
- std::list<CAccountingEntry> aes;
-
- results.clear();
- BOOST_CHECK(walletdb.ReorderTransactions(pwalletMain) == DB_LOAD_OK);
- walletdb.ListAccountCreditDebit("", aes);
- BOOST_FOREACH(CAccountingEntry& ae, aes)
- {
- results[ae.nOrderPos] = ae;
- }
-}
-
-BOOST_AUTO_TEST_CASE(acc_orderupgrade)
-{
- CWalletDB walletdb(pwalletMain->strWalletFile);
- std::vector<CWalletTx*> vpwtx;
- CWalletTx wtx;
- CAccountingEntry ae;
- std::map<int64, CAccountingEntry> results;
-
- ae.strAccount = "";
- ae.nCreditDebit = 1;
- ae.nTime = 1333333333;
- ae.strOtherAccount = "b";
- ae.strComment = "";
- walletdb.WriteAccountingEntry(ae);
-
- wtx.mapValue["comment"] = "z";
- pwalletMain->AddToWallet(wtx);
- vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]);
- vpwtx[0]->nTimeReceived = (unsigned int)1333333335;
- vpwtx[0]->nOrderPos = -1;
-
- ae.nTime = 1333333336;
- ae.strOtherAccount = "c";
- walletdb.WriteAccountingEntry(ae);
-
- GetResults(walletdb, results);
-
- BOOST_CHECK(pwalletMain->nOrderPosNext == 3);
- BOOST_CHECK(2 == results.size());
- BOOST_CHECK(results[0].nTime == 1333333333);
- BOOST_CHECK(results[0].strComment.empty());
- BOOST_CHECK(1 == vpwtx[0]->nOrderPos);
- BOOST_CHECK(results[2].nTime == 1333333336);
- BOOST_CHECK(results[2].strOtherAccount == "c");
-
-
- ae.nTime = 1333333330;
- ae.strOtherAccount = "d";
- ae.nOrderPos = pwalletMain->IncOrderPosNext();
- walletdb.WriteAccountingEntry(ae);
-
- GetResults(walletdb, results);
-
- BOOST_CHECK(results.size() == 3);
- BOOST_CHECK(pwalletMain->nOrderPosNext == 4);
- BOOST_CHECK(results[0].nTime == 1333333333);
- BOOST_CHECK(1 == vpwtx[0]->nOrderPos);
- BOOST_CHECK(results[2].nTime == 1333333336);
- BOOST_CHECK(results[3].nTime == 1333333330);
- BOOST_CHECK(results[3].strComment.empty());
-
-
- wtx.mapValue["comment"] = "y";
- --wtx.nLockTime; // Just to change the hash :)
- pwalletMain->AddToWallet(wtx);
- vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]);
- vpwtx[1]->nTimeReceived = (unsigned int)1333333336;
-
- wtx.mapValue["comment"] = "x";
- --wtx.nLockTime; // Just to change the hash :)
- pwalletMain->AddToWallet(wtx);
- vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]);
- vpwtx[2]->nTimeReceived = (unsigned int)1333333329;
- vpwtx[2]->nOrderPos = -1;
-
- GetResults(walletdb, results);
-
- BOOST_CHECK(results.size() == 3);
- BOOST_CHECK(pwalletMain->nOrderPosNext == 6);
- BOOST_CHECK(0 == vpwtx[2]->nOrderPos);
- BOOST_CHECK(results[1].nTime == 1333333333);
- BOOST_CHECK(2 == vpwtx[0]->nOrderPos);
- BOOST_CHECK(results[3].nTime == 1333333336);
- BOOST_CHECK(results[4].nTime == 1333333330);
- BOOST_CHECK(results[4].strComment.empty());
- BOOST_CHECK(5 == vpwtx[1]->nOrderPos);
-
-
- ae.nTime = 1333333334;
- ae.strOtherAccount = "e";
- ae.nOrderPos = -1;
- walletdb.WriteAccountingEntry(ae);
-
- GetResults(walletdb, results);
-
- BOOST_CHECK(results.size() == 4);
- BOOST_CHECK(pwalletMain->nOrderPosNext == 7);
- BOOST_CHECK(0 == vpwtx[2]->nOrderPos);
- BOOST_CHECK(results[1].nTime == 1333333333);
- BOOST_CHECK(2 == vpwtx[0]->nOrderPos);
- BOOST_CHECK(results[3].nTime == 1333333336);
- BOOST_CHECK(results[3].strComment.empty());
- BOOST_CHECK(results[4].nTime == 1333333330);
- BOOST_CHECK(results[4].strComment.empty());
- BOOST_CHECK(results[5].nTime == 1333333334);
- BOOST_CHECK(6 == vpwtx[1]->nOrderPos);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include "init.h"
-#include "main.h"
-#include "util.h"
-
-BOOST_AUTO_TEST_SUITE(allocator_tests)
-
-// Dummy memory page locker for platform independent tests
-static const void *last_lock_addr, *last_unlock_addr;
-static size_t last_lock_len, last_unlock_len;
-class TestLocker
-{
-public:
- bool Lock(const void *addr, size_t len)
- {
- last_lock_addr = addr;
- last_lock_len = len;
- return true;
- }
- bool Unlock(const void *addr, size_t len)
- {
- last_unlock_addr = addr;
- last_unlock_len = len;
- return true;
- }
-};
-
-BOOST_AUTO_TEST_CASE(test_LockedPageManagerBase)
-{
- const size_t test_page_size = 4096;
- LockedPageManagerBase<TestLocker> lpm(test_page_size);
- size_t addr;
- last_lock_addr = last_unlock_addr = 0;
- last_lock_len = last_unlock_len = 0;
-
- /* Try large number of small objects */
- addr = 0;
- for(int i=0; i<1000; ++i)
- {
- lpm.LockRange(reinterpret_cast<void*>(addr), 33);
- addr += 33;
- }
- /* Try small number of page-sized objects, straddling two pages */
- addr = test_page_size*100 + 53;
- for(int i=0; i<100; ++i)
- {
- lpm.LockRange(reinterpret_cast<void*>(addr), test_page_size);
- addr += test_page_size;
- }
- /* Try small number of page-sized objects aligned to exactly one page */
- addr = test_page_size*300;
- for(int i=0; i<100; ++i)
- {
- lpm.LockRange(reinterpret_cast<void*>(addr), test_page_size);
- addr += test_page_size;
- }
- /* one very large object, straddling pages */
- lpm.LockRange(reinterpret_cast<void*>(test_page_size*600+1), test_page_size*500);
- BOOST_CHECK(last_lock_addr == reinterpret_cast<void*>(test_page_size*(600+500)));
- /* one very large object, page aligned */
- lpm.LockRange(reinterpret_cast<void*>(test_page_size*1200), test_page_size*500-1);
- BOOST_CHECK(last_lock_addr == reinterpret_cast<void*>(test_page_size*(1200+500-1)));
-
- BOOST_CHECK(lpm.GetLockedPageCount() == (
- (1000*33+test_page_size-1)/test_page_size + // small objects
- 101 + 100 + // page-sized objects
- 501 + 500)); // large objects
- BOOST_CHECK((last_lock_len & (test_page_size-1)) == 0); // always lock entire pages
- BOOST_CHECK(last_unlock_len == 0); // nothing unlocked yet
-
- /* And unlock again */
- addr = 0;
- for(int i=0; i<1000; ++i)
- {
- lpm.UnlockRange(reinterpret_cast<void*>(addr), 33);
- addr += 33;
- }
- addr = test_page_size*100 + 53;
- for(int i=0; i<100; ++i)
- {
- lpm.UnlockRange(reinterpret_cast<void*>(addr), test_page_size);
- addr += test_page_size;
- }
- addr = test_page_size*300;
- for(int i=0; i<100; ++i)
- {
- lpm.UnlockRange(reinterpret_cast<void*>(addr), test_page_size);
- addr += test_page_size;
- }
- lpm.UnlockRange(reinterpret_cast<void*>(test_page_size*600+1), test_page_size*500);
- lpm.UnlockRange(reinterpret_cast<void*>(test_page_size*1200), test_page_size*500-1);
-
- /* Check that everything is released */
- BOOST_CHECK(lpm.GetLockedPageCount() == 0);
-
- /* A few and unlocks of size zero (should have no effect) */
- addr = 0;
- for(int i=0; i<1000; ++i)
- {
- lpm.LockRange(reinterpret_cast<void*>(addr), 0);
- addr += 1;
- }
- BOOST_CHECK(lpm.GetLockedPageCount() == 0);
- addr = 0;
- for(int i=0; i<1000; ++i)
- {
- lpm.UnlockRange(reinterpret_cast<void*>(addr), 0);
- addr += 1;
- }
- BOOST_CHECK(lpm.GetLockedPageCount() == 0);
- BOOST_CHECK((last_unlock_len & (test_page_size-1)) == 0); // always unlock entire pages
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include "util.h"
-
-BOOST_AUTO_TEST_SUITE(base32_tests)
-
-BOOST_AUTO_TEST_CASE(base32_testvectors)
-{
- static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"};
- static const std::string vstrOut[] = {"","my======","mzxq====","mzxw6===","mzxw6yq=","mzxw6ytb","mzxw6ytboi======"};
- for (unsigned int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
- {
- std::string strEnc = EncodeBase32(vstrIn[i]);
- BOOST_CHECK(strEnc == vstrOut[i]);
- std::string strDec = DecodeBase32(vstrOut[i]);
- BOOST_CHECK(strDec == vstrIn[i]);
- }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-#include "json/json_spirit_reader_template.h"
-#include "json/json_spirit_writer_template.h"
-#include "json/json_spirit_utils.h"
-
-#include "base58.h"
-#include "util.h"
-
-using namespace json_spirit;
-extern Array read_json(const std::string& filename);
-
-BOOST_AUTO_TEST_SUITE(base58_tests)
-
-// Goal: test low-level base58 encoding functionality
-BOOST_AUTO_TEST_CASE(base58_EncodeBase58)
-{
- Array tests = read_json("base58_encode_decode.json");
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- std::string strTest = write_string(tv, false);
- if (test.size() < 2) // Allow for extra stuff (useful for comments)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
- std::vector<unsigned char> sourcedata = ParseHex(test[0].get_str());
- std::string base58string = test[1].get_str();
- BOOST_CHECK_MESSAGE(
- EncodeBase58(&sourcedata[0], &sourcedata[sourcedata.size()]) == base58string,
- strTest);
- }
-}
-
-// Goal: test low-level base58 decoding functionality
-BOOST_AUTO_TEST_CASE(base58_DecodeBase58)
-{
- Array tests = read_json("base58_encode_decode.json");
- std::vector<unsigned char> result;
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- std::string strTest = write_string(tv, false);
- if (test.size() < 2) // Allow for extra stuff (useful for comments)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
- std::vector<unsigned char> expected = ParseHex(test[0].get_str());
- std::string base58string = test[1].get_str();
- BOOST_CHECK_MESSAGE(DecodeBase58(base58string, result), strTest);
- BOOST_CHECK_MESSAGE(result.size() == expected.size() && std::equal(result.begin(), result.end(), expected.begin()), strTest);
- }
-
- BOOST_CHECK(!DecodeBase58("invalid", result));
-}
-
-// Visitor to check address type
-class TestAddrTypeVisitor : public boost::static_visitor<bool>
-{
-private:
- std::string exp_addrType;
-public:
- TestAddrTypeVisitor(const std::string &exp_addrType) : exp_addrType(exp_addrType) { }
- bool operator()(const CKeyID &id) const
- {
- return (exp_addrType == "pubkey");
- }
- bool operator()(const CScriptID &id) const
- {
- return (exp_addrType == "script");
- }
- bool operator()(const CNoDestination &no) const
- {
- return (exp_addrType == "none");
- }
-};
-
-// Visitor to check address payload
-class TestPayloadVisitor : public boost::static_visitor<bool>
-{
-private:
- std::vector<unsigned char> exp_payload;
-public:
- TestPayloadVisitor(std::vector<unsigned char> &exp_payload) : exp_payload(exp_payload) { }
- bool operator()(const CKeyID &id) const
- {
- uint160 exp_key(exp_payload);
- return exp_key == id;
- }
- bool operator()(const CScriptID &id) const
- {
- uint160 exp_key(exp_payload);
- return exp_key == id;
- }
- bool operator()(const CNoDestination &no) const
- {
- return exp_payload.size() == 0;
- }
-};
-
-// Goal: check that parsed keys match test payload
-BOOST_AUTO_TEST_CASE(base58_keys_valid_parse)
-{
- Array tests = read_json("base58_keys_valid.json");
- std::vector<unsigned char> result;
- CBitcoinSecret secret;
- CBitcoinAddress addr;
- // Save global state
- bool fTestNet_stored = fTestNet;
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- std::string strTest = write_string(tv, false);
- if (test.size() < 3) // Allow for extra stuff (useful for comments)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
- std::string exp_base58string = test[0].get_str();
- std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
- const Object &metadata = test[2].get_obj();
- bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
- bool isTestnet = find_value(metadata, "isTestnet").get_bool();
- fTestNet = isTestnet; // Override testnet flag
- if(isPrivkey)
- {
- bool isCompressed = find_value(metadata, "isCompressed").get_bool();
- // Must be valid private key
- // Note: CBitcoinSecret::SetString tests isValid, whereas CBitcoinAddress does not!
- BOOST_CHECK_MESSAGE(secret.SetString(exp_base58string), "!SetString:"+ strTest);
- BOOST_CHECK_MESSAGE(secret.IsValid(), "!IsValid:" + strTest);
- bool fCompressedOut = false;
- CSecret privkey = secret.GetSecret(fCompressedOut);
- BOOST_CHECK_MESSAGE(fCompressedOut == isCompressed, "compressed mismatch:" + strTest);
- BOOST_CHECK_MESSAGE(privkey.size() == exp_payload.size() && std::equal(privkey.begin(), privkey.end(), exp_payload.begin()), "key mismatch:" + strTest);
-
- // Private key must be invalid public key
- addr.SetString(exp_base58string);
- BOOST_CHECK_MESSAGE(!addr.IsValid(), "IsValid privkey as pubkey:" + strTest);
- }
- else
- {
- std::string exp_addrType = find_value(metadata, "addrType").get_str(); // "script" or "pubkey"
- // Must be valid public key
- BOOST_CHECK_MESSAGE(addr.SetString(exp_base58string), "SetString:" + strTest);
- BOOST_CHECK_MESSAGE(addr.IsValid(), "!IsValid:" + strTest);
- BOOST_CHECK_MESSAGE(addr.IsScript() == (exp_addrType == "script"), "isScript mismatch" + strTest);
- CTxDestination dest = addr.Get();
- BOOST_CHECK_MESSAGE(boost::apply_visitor(TestAddrTypeVisitor(exp_addrType), dest), "addrType mismatch" + strTest);
-
- // Public key must be invalid private key
- secret.SetString(exp_base58string);
- BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid pubkey as privkey:" + strTest);
- }
- }
- // Restore global state
- fTestNet = fTestNet_stored;
-}
-
-// Goal: check that generated keys match test vectors
-BOOST_AUTO_TEST_CASE(base58_keys_valid_gen)
-{
- Array tests = read_json("base58_keys_valid.json");
- std::vector<unsigned char> result;
- // Save global state
- bool fTestNet_stored = fTestNet;
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- std::string strTest = write_string(tv, false);
- if (test.size() < 3) // Allow for extra stuff (useful for comments)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
- std::string exp_base58string = test[0].get_str();
- std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str());
- const Object &metadata = test[2].get_obj();
- bool isPrivkey = find_value(metadata, "isPrivkey").get_bool();
- bool isTestnet = find_value(metadata, "isTestnet").get_bool();
- fTestNet = isTestnet; // Override testnet flag
- if(isPrivkey)
- {
- bool isCompressed = find_value(metadata, "isCompressed").get_bool();
- CBitcoinSecret secret;
- secret.SetSecret(CSecret(exp_payload.begin(), exp_payload.end()), isCompressed);
- BOOST_CHECK_MESSAGE(secret.ToString() == exp_base58string, "result mismatch: " + strTest);
- }
- else
- {
- std::string exp_addrType = find_value(metadata, "addrType").get_str();
- CTxDestination dest;
- if(exp_addrType == "pubkey")
- {
- dest = CKeyID(uint160(exp_payload));
- }
- else if(exp_addrType == "script")
- {
- dest = CScriptID(uint160(exp_payload));
- }
- else if(exp_addrType == "none")
- {
- dest = CNoDestination();
- }
- else
- {
- BOOST_ERROR("Bad addrtype: " << strTest);
- continue;
- }
- CBitcoinAddress addrOut;
- BOOST_CHECK_MESSAGE(boost::apply_visitor(CBitcoinAddressVisitor(&addrOut), dest), "encode dest: " + strTest);
- BOOST_CHECK_MESSAGE(addrOut.ToString() == exp_base58string, "mismatch: " + strTest);
- }
- }
-
- // Visiting a CNoDestination must fail
- CBitcoinAddress dummyAddr;
- CTxDestination nodest = CNoDestination();
- BOOST_CHECK(!boost::apply_visitor(CBitcoinAddressVisitor(&dummyAddr), nodest));
-
- // Restore global state
- fTestNet = fTestNet_stored;
-}
-
-// Goal: check that base58 parsing code is robust against a variety of corrupted data
-BOOST_AUTO_TEST_CASE(base58_keys_invalid)
-{
- Array tests = read_json("base58_keys_invalid.json"); // Negative testcases
- std::vector<unsigned char> result;
- CBitcoinSecret secret;
- CBitcoinAddress addr;
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- std::string strTest = write_string(tv, false);
- if (test.size() < 1) // Allow for extra stuff (useful for comments)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
- std::string exp_base58string = test[0].get_str();
-
- // must be invalid as public and as private key
- addr.SetString(exp_base58string);
- BOOST_CHECK_MESSAGE(!addr.IsValid(), "IsValid pubkey:" + strTest);
- secret.SetString(exp_base58string);
- BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid privkey:" + strTest);
- }
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include "main.h"
-#include "wallet.h"
-#include "util.h"
-
-BOOST_AUTO_TEST_SUITE(base64_tests)
-
-BOOST_AUTO_TEST_CASE(base64_testvectors)
-{
- static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"};
- static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"};
- for (unsigned int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
- {
- std::string strEnc = EncodeBase64(vstrIn[i]);
- BOOST_CHECK(strEnc == vstrOut[i]);
- std::string strDec = DecodeBase64(strEnc);
- BOOST_CHECK(strDec == vstrIn[i]);
- }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-#include <limits>
-
-#include "bignum.h"
-#include "util.h"
-
-BOOST_AUTO_TEST_SUITE(bignum_tests)
-
-// Unfortunately there's no standard way of preventing a function from being
-// inlined, so we define a macro for it.
-//
-// You should use it like this:
-// NOINLINE void function() {...}
-#if defined(__GNUC__)
-// This also works and will be defined for any compiler implementing GCC
-// extensions, such as Clang and ICC.
-#define NOINLINE __attribute__((noinline))
-#elif defined(_MSC_VER)
-#define NOINLINE __declspec(noinline)
-#else
-// We give out a warning because it impacts the correctness of one bignum test.
-#warning You should define NOINLINE for your compiler.
-#define NOINLINE
-#endif
-
-// For the following test case, it is useful to use additional tools.
-//
-// The simplest one to use is the compiler flag -ftrapv, which detects integer
-// overflows and similar errors. However, due to optimizations and compilers
-// taking advantage of undefined behavior sometimes it may not actually detect
-// anything.
-//
-// You can also use compiler-based stack protection to possibly detect possible
-// stack buffer overruns.
-//
-// For more accurate diagnostics, you can use an undefined arithmetic operation
-// detector such as the clang-based tool:
-//
-// "IOC: An Integer Overflow Checker for C/C++"
-//
-// Available at: http://embed.cs.utah.edu/ioc/
-//
-// It might also be useful to use Google's AddressSanitizer to detect
-// stack buffer overruns, which valgrind can't currently detect.
-
-// Let's force this code not to be inlined, in order to actually
-// test a generic version of the function. This increases the chance
-// that -ftrapv will detect overflows.
-NOINLINE void mysetint64(CBigNum& num, int64 n)
-{
- num.setint64(n);
-}
-
-// For each number, we do 2 tests: one with inline code, then we reset the
-// value to 0, then the second one with a non-inlined function.
-BOOST_AUTO_TEST_CASE(bignum_setint64)
-{
- int64 n;
-
- {
- n = 0;
- CBigNum num(n);
- BOOST_CHECK(num.ToString() == "0");
- num.setulong(0);
- BOOST_CHECK(num.ToString() == "0");
- mysetint64(num, n);
- BOOST_CHECK(num.ToString() == "0");
- }
- {
- n = 1;
- CBigNum num(n);
- BOOST_CHECK(num.ToString() == "1");
- num.setulong(0);
- BOOST_CHECK(num.ToString() == "0");
- mysetint64(num, n);
- BOOST_CHECK(num.ToString() == "1");
- }
- {
- n = -1;
- CBigNum num(n);
- BOOST_CHECK(num.ToString() == "-1");
- num.setulong(0);
- BOOST_CHECK(num.ToString() == "0");
- mysetint64(num, n);
- BOOST_CHECK(num.ToString() == "-1");
- }
- {
- n = 5;
- CBigNum num(n);
- BOOST_CHECK(num.ToString() == "5");
- num.setulong(0);
- BOOST_CHECK(num.ToString() == "0");
- mysetint64(num, n);
- BOOST_CHECK(num.ToString() == "5");
- }
- {
- n = -5;
- CBigNum num(n);
- BOOST_CHECK(num.ToString() == "-5");
- num.setulong(0);
- BOOST_CHECK(num.ToString() == "0");
- mysetint64(num, n);
- BOOST_CHECK(num.ToString() == "-5");
- }
- {
- n = std::numeric_limits<int64>::min();
- CBigNum num(n);
- BOOST_CHECK(num.ToString() == "-9223372036854775808");
- num.setulong(0);
- BOOST_CHECK(num.ToString() == "0");
- mysetint64(num, n);
- BOOST_CHECK(num.ToString() == "-9223372036854775808");
- }
- {
- n = std::numeric_limits<int64>::max();
- CBigNum num(n);
- BOOST_CHECK(num.ToString() == "9223372036854775807");
- num.setulong(0);
- BOOST_CHECK(num.ToString() == "0");
- mysetint64(num, n);
- BOOST_CHECK(num.ToString() == "9223372036854775807");
- }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-[
-["", ""],
-["61", "2g"],
-["626262", "a3gV"],
-["636363", "aPEr"],
-["73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"],
-["00eb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"],
-["516b6fcd0f", "ABnLTmg"],
-["bf4f89001e670274dd", "3SEo3LWLoPntC"],
-["572e4794", "3EFU7m"],
-["ecac89cad93923c02321", "EJDM8drfXA6uyA"],
-["10c8511e", "Rt5zm"],
-["00000000000000000000", "1111111111"]
-]
+++ /dev/null
-[
- [
- ""
- ],
- [
- "x"
- ],
- [
- "37qgekLpCCHrQuSjvX3fs496FWTGsHFHizjJAs6NPcR47aefnnCWECAhHV6E3g4YN7u7Yuwod5Y"
- ],
- [
- "dzb7VV1Ui55BARxv7ATxAtCUeJsANKovDGWFVgpTbhq9gvPqP3yv"
- ],
- [
- "MuNu7ZAEDFiHthiunm7dPjwKqrVNCM3mAz6rP9zFveQu14YA8CxExSJTHcVP9DErn6u84E6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MUdkN2Y4dHB1wPsZAeVXUGD83MfRED"
- ]
-]
+++ /dev/null
-[
- [
- "1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i",
- "65a16059864a2fdbc7c99a4723a8395bc6f188eb",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "3CMNFxN1oHBc4R1EpboAL5yzHGgE611Xou",
- "74f209f6ea907e2ea48f74fae05782ae8a665257",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs",
- "53c0307d6851aa0ce7825ba883c6bd9ad242b486",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br",
- "6349a418fc4578d10a372b54b45c280cc8c4382f",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr",
- "eddbdc1168f1daeadbd3e44c1e3f8f5a284c2029f78ad26af98583a499de5b19",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "Kz6UJmQACJmLtaQj5A3JAge4kVTNQ8gbvXuwbmCj7bsaabudb3RD",
- "55c9bccb9ed68446d1b75273bbce89d7fe013a8acd1625514420fb2aca1a21c4",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "9213qJab2HNEpMpYNBa7wHGFKKbkDn24jpANDs2huN3yi4J11ko",
- "36cb93b9ab1bdabf7fb9f2c04f1b9cc879933530ae7842398eef5a63a56800c2",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "cTpB4YiyKiBcPxnefsDpbnDxFDffjqJob8wGCEDXxgQ7zQoMXJdH",
- "b9f4892c9e8282028fea1d2667c4dc5213564d41fc5783896a0d843fc15089f3",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "1Ax4gZtb7gAit2TivwejZHYtNNLT18PUXJ",
- "6d23156cbbdcc82a5a47eee4c2c7c583c18b6bf4",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "3QjYXhTkvuj8qPaXHTTWb5wjXhdsLAAWVy",
- "fcc5460dd6e2487c7d75b1963625da0e8f4c5975",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "n3ZddxzLvAY9o7184TB4c6FJasAybsw4HZ",
- "f1d470f9b02370fdec2e6b708b08ac431bf7a5f7",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n",
- "c579342c2c4c9220205e2cdc285617040c924a0a",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "5K494XZwps2bGyeL71pWid4noiSNA2cfCibrvRWqcHSptoFn7rc",
- "a326b95ebae30164217d7a7f57d72ab2b54e3be64928a19da0210b9568d4015e",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "L1RrrnXkcKut5DEMwtDthjwRcTTwED36thyL1DebVrKuwvohjMNi",
- "7d998b45c219a1e38e99e7cbd312ef67f77a455a9b50c730c27f02c6f730dfb4",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "93DVKyFYwSN6wEo3E2fCrFPUp17FtrtNi2Lf7n4G3garFb16CRj",
- "d6bca256b5abc5602ec2e1c121a08b0da2556587430bcf7e1898af2224885203",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "cTDVKtMGVYWTHCb1AFjmVbEbWjvKpKqKgMaR3QJxToMSQAhmCeTN",
- "a81ca4e8f90181ec4b61b6a7eb998af17b2cb04de8a03b504b9e34c4c61db7d9",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "1C5bSj1iEGUgSTbziymG7Cn18ENQuT36vv",
- "7987ccaa53d02c8873487ef919677cd3db7a6912",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "3AnNxabYGoTxYiTEZwFEnerUoeFXK2Zoks",
- "63bcc565f9e68ee0189dd5cc67f1b0e5f02f45cb",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "n3LnJXCqbPjghuVs8ph9CYsAe4Sh4j97wk",
- "ef66444b5b17f14e8fae6e7e19b045a78c54fd79",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "2NB72XtkjpnATMggui83aEtPawyyKvnbX2o",
- "c3e55fceceaa4391ed2a9677f4a4d34eacd021a0",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "5KaBW9vNtWNhc3ZEDyNCiXLPdVPHCikRxSBWwV9NrpLLa4LsXi9",
- "e75d936d56377f432f404aabb406601f892fd49da90eb6ac558a733c93b47252",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "L1axzbSyynNYA8mCAhzxkipKkfHtAXYF4YQnhSKcLV8YXA874fgT",
- "8248bd0375f2f75d7e274ae544fb920f51784480866b102384190b1addfbaa5c",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "927CnUkUbasYtDwYwVn2j8GdTuACNnKkjZ1rpZd2yBB1CLcnXpo",
- "44c4f6a096eac5238291a94cc24c01e3b19b8d8cef72874a079e00a242237a52",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "cUcfCMRjiQf85YMzzQEk9d1s5A4K7xL5SmBCLrezqXFuTVefyhY7",
- "d1de707020a9059d6d3abaf85e17967c6555151143db13dbb06db78df0f15c69",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "1Gqk4Tv79P91Cc1STQtU3s1W6277M2CVWu",
- "adc1cc2081a27206fae25792f28bbc55b831549d",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "33vt8ViH5jsr115AGkW6cEmEz9MpvJSwDk",
- "188f91a931947eddd7432d6e614387e32b244709",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "mhaMcBxNh5cqXm4aTQ6EcVbKtfL6LGyK2H",
- "1694f5bc1a7295b600f40018a618a6ea48eeb498",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "2MxgPqX1iThW3oZVk9KoFcE5M4JpiETssVN",
- "3b9b3fd7a50d4f08d1a5b0f62f644fa7115ae2f3",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "5HtH6GdcwCJA4ggWEL1B3jzBBUB8HPiBi9SBc5h9i4Wk4PSeApR",
- "091035445ef105fa1bb125eccfb1882f3fe69592265956ade751fd095033d8d0",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "L2xSYmMeVo3Zek3ZTsv9xUrXVAmrWxJ8Ua4cw8pkfbQhcEFhkXT8",
- "ab2b4bcdfc91d34dee0ae2a8c6b6668dadaeb3a88b9859743156f462325187af",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "92xFEve1Z9N8Z641KQQS7ByCSb8kGjsDzw6fAmjHN1LZGKQXyMq",
- "b4204389cef18bbe2b353623cbf93e8678fbc92a475b664ae98ed594e6cf0856",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "cVM65tdYu1YK37tNoAyGoJTR13VBYFva1vg9FLuPAsJijGvG6NEA",
- "e7b230133f1b5489843260236b06edca25f66adb1be455fbd38d4010d48faeef",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "1JwMWBVLtiqtscbaRHai4pqHokhFCbtoB4",
- "c4c1b72491ede1eedaca00618407ee0b772cad0d",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "3QCzvfL4ZRvmJFiWWBVwxfdaNBT8EtxB5y",
- "f6fe69bcb548a829cce4c57bf6fff8af3a5981f9",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "mizXiucXRCsEriQCHUkCqef9ph9qtPbZZ6",
- "261f83568a098a8638844bd7aeca039d5f2352c0",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "2NEWDzHWwY5ZZp8CQWbB7ouNMLqCia6YRda",
- "e930e1834a4d234702773951d627cce82fbb5d2e",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "5KQmDryMNDcisTzRp3zEq9e4awRmJrEVU1j5vFRTKpRNYPqYrMg",
- "d1fab7ab7385ad26872237f1eb9789aa25cc986bacc695e07ac571d6cdac8bc0",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "L39Fy7AC2Hhj95gh3Yb2AU5YHh1mQSAHgpNixvm27poizcJyLtUi",
- "b0bbede33ef254e8376aceb1510253fc3550efd0fcf84dcd0c9998b288f166b3",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "91cTVUcgydqyZLgaANpf1fvL55FH53QMm4BsnCADVNYuWuqdVys",
- "037f4192c630f399d9271e26c575269b1d15be553ea1a7217f0cb8513cef41cb",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "cQspfSzsgLeiJGB2u8vrAiWpCU4MxUT6JseWo2SjXy4Qbzn2fwDw",
- "6251e205e8ad508bab5596bee086ef16cd4b239e0cc0c5d7c4e6035441e7d5de",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "19dcawoKcZdQz365WpXWMhX6QCUpR9SY4r",
- "5eadaf9bb7121f0f192561a5a62f5e5f54210292",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "37Sp6Rv3y4kVd1nQ1JV5pfqXccHNyZm1x3",
- "3f210e7277c899c3a155cc1c90f4106cbddeec6e",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "myoqcgYiehufrsnnkqdqbp69dddVDMopJu",
- "c8a3c2a09a298592c3e180f02487cd91ba3400b5",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "2N7FuwuUuoTBrDFdrAZ9KxBmtqMLxce9i1C",
- "99b31df7c9068d1481b596578ddbb4d3bd90baeb",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": true
- }
- ],
- [
- "5KL6zEaMtPRXZKo1bbMq7JDjjo1bJuQcsgL33je3oY8uSJCR5b4",
- "c7666842503db6dc6ea061f092cfb9c388448629a6fe868d068c42a488b478ae",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "KwV9KAfwbwt51veZWNscRTeZs9CKpojyu1MsPnaKTF5kz69H1UN2",
- "07f0803fc5399e773555ab1e8939907e9badacc17ca129e67a2f5f2ff84351dd",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": false
- }
- ],
- [
- "93N87D6uxSBzwXvpokpzg8FFmfQPmvX4xHoWQe3pLdYpbiwT5YV",
- "ea577acfb5d1d14d3b7b195c321566f12f87d2b77ea3a53f68df7ebf8604a801",
- {
- "isCompressed": false,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "cMxXusSihaX58wpJ3tNuuUcZEQGt6DKJ1wEpxys88FFaQCYjku9h",
- "0b3b34f0958d8a268193a9814da92c3e8b58b4a4378a542863e34ac289cd830c",
- {
- "isCompressed": true,
- "isPrivkey": true,
- "isTestnet": true
- }
- ],
- [
- "13p1ijLwsnrcuyqcTvJXkq2ASdXqcnEBLE",
- "1ed467017f043e91ed4c44b4e8dd674db211c4e6",
- {
- "addrType": "pubkey",
- "isPrivkey": false,
- "isTestnet": false
- }
- ],
- [
- "3ALJH9Y951VCGcVZYAdpA3KchoP9McEj1G",
- "5ece0cadddc415b1980f001785947120acdb36fc",
- {
- "addrType": "script",
- "isPrivkey": false,
- "isTestnet": false
- }
- ]
-]
+++ /dev/null
-[
-["", ""],
-["", "NOP"],
-["NOP", ""],
-["NOP","NOP"],
-
-["0x4c01","0x01 NOP", "PUSHDATA1 with not enough bytes"],
-["0x4d0200ff","0x01 NOP", "PUSHDATA2 with not enough bytes"],
-["0x4e03000000ffff","0x01 NOP", "PUSHDATA4 with not enough bytes"],
-
-["1", "IF 0x50 ENDIF 1", "0x50 is reserved"],
-["0x52", "0x5f ADD 0x60 EQUAL", "0x51 through 0x60 push 1 through 16 onto stack"],
-["0","NOP"],
-["1", "IF VER ELSE 1 ENDIF", "VER non-functional"],
-["0", "IF VERIF ELSE 1 ENDIF", "VERIF illegal everywhere"],
-["0", "IF VERNOTIF ELSE 1 ENDIF", "VERNOT illegal everywhere"],
-
-["1 IF", "1 ENDIF", "IF/ENDIF can't span scriptSig/scriptPubKey"],
-["1 IF 0 ENDIF", "1 ENDIF"],
-["1 ELSE 0 ENDIF", "1"],
-["0 NOTIF", "123"],
-
-["0", "DUP IF ENDIF"],
-["0", "IF 1 ENDIF"],
-["0", "DUP IF ELSE ENDIF"],
-["0", "IF 1 ELSE ENDIF"],
-["0", "NOTIF ELSE 1 ENDIF"],
-
-["0 1", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["0 0", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["0 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["0 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["1", "RETURN"],
-["1", "DUP IF RETURN ENDIF"],
-
-["0", "VERIFY 1"],
-["1", "VERIFY"],
-["1", "VERIFY 0"],
-
-["1 TOALTSTACK", "FROMALTSTACK 1", "alt stack not shared between sig/pubkey"],
-
-["IFDUP", "DEPTH 0 EQUAL"],
-["DROP", "DEPTH 0 EQUAL"],
-["DUP", "DEPTH 0 EQUAL"],
-["1", "DUP 1 ADD 2 EQUALVERIFY 0 EQUAL"],
-["NOP", "NIP"],
-["NOP", "1 NIP"],
-["NOP", "1 0 NIP"],
-["NOP", "OVER 1"],
-["1", "OVER"],
-["0 1", "OVER DEPTH 3 EQUALVERIFY"],
-["19 20 21", "PICK 19 EQUALVERIFY DEPTH 2 EQUAL"],
-["NOP", "0 PICK"],
-["1", "-1 PICK"],
-["19 20 21", "0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL"],
-["19 20 21", "1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL"],
-["19 20 21", "2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL"],
-["NOP", "0 ROLL"],
-["1", "-1 ROLL"],
-["19 20 21", "0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL"],
-["19 20 21", "1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL"],
-["19 20 21", "2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL"],
-["NOP", "ROT 1"],
-["NOP", "1 ROT 1"],
-["NOP", "1 2 ROT 1"],
-["NOP", "0 1 2 ROT"],
-["NOP", "SWAP 1"],
-["1", "SWAP 1"],
-["0 1", "SWAP 1 EQUALVERIFY"],
-["NOP", "TUCK 1"],
-["1", "TUCK 1"],
-["1 0", "TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP"],
-["NOP", "2DUP 1"],
-["1", "2DUP 1"],
-["NOP", "3DUP 1"],
-["1", "3DUP 1"],
-["1 2", "3DUP 1"],
-["NOP", "2OVER 1"],
-["1", "2 3 2OVER 1"],
-["NOP", "2SWAP 1"],
-["1", "2 3 2SWAP 1"],
-
-["'a' 'b'", "CAT", "CAT disabled"],
-["'a' 'b' 0", "IF CAT ELSE 1 ENDIF", "CAT disabled"],
-["'abc' 1 1", "SUBSTR", "SUBSTR disabled"],
-["'abc' 1 1 0", "IF SUBSTR ELSE 1 ENDIF", "SUBSTR disabled"],
-["'abc' 2 0", "IF LEFT ELSE 1 ENDIF", "LEFT disabled"],
-["'abc' 2 0", "IF RIGHT ELSE 1 ENDIF", "RIGHT disabled"],
-
-["NOP", "SIZE 1"],
-
-["'abc'", "IF INVERT ELSE 1 ENDIF", "INVERT disabled"],
-["1 2 0 IF AND ELSE 1 ENDIF", "NOP", "AND disabled"],
-["1 2 0 IF OR ELSE 1 ENDIF", "NOP", "OR disabled"],
-["1 2 0 IF XOR ELSE 1 ENDIF", "NOP", "XOR disabled"],
-["2 0 IF 2MUL ELSE 1 ENDIF", "NOP", "2MUL disabled"],
-["2 0 IF 2DIV ELSE 1 ENDIF", "NOP", "2DIV disabled"],
-["2 2 0 IF MUL ELSE 1 ENDIF", "NOP", "MUL disabled"],
-["2 2 0 IF DIV ELSE 1 ENDIF", "NOP", "DIV disabled"],
-["2 2 0 IF MOD ELSE 1 ENDIF", "NOP", "MOD disabled"],
-["2 2 0 IF LSHIFT ELSE 1 ENDIF", "NOP", "LSHIFT disabled"],
-["2 2 0 IF RSHIFT ELSE 1 ENDIF", "NOP", "RSHIFT disabled"],
-
-["0 1","EQUAL"],
-["1 1 ADD", "0 EQUAL"],
-["11 1 ADD 12 SUB", "11 EQUAL"],
-
-["2147483648 0 ADD", "NOP", "arithmetic operands must be in range [-2^31...2^31] "],
-["-2147483648 0 ADD", "NOP", "arithmetic operands must be in range [-2^31...2^31] "],
-["2147483647 DUP ADD", "4294967294 NUMEQUAL", "NUMEQUAL must be in numeric range"],
-["'abcdef' NOT", "0 EQUAL", "NOT is an arithmetic operand"],
-
-["2 DUP MUL", "4 EQUAL", "disabled"],
-["2 DUP DIV", "1 EQUAL", "disabled"],
-["2 2MUL", "4 EQUAL", "disabled"],
-["2 2DIV", "1 EQUAL", "disabled"],
-["7 3 MOD", "1 EQUAL", "disabled"],
-["2 2 LSHIFT", "8 EQUAL", "disabled"],
-["2 1 RSHIFT", "1 EQUAL", "disabled"],
-
-["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL"],
-["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL"],
-
-["0x50","1", "opcode 0x50 is reserved"],
-["1", "IF 0xba ELSE 1 ENDIF", "opcodes above NOP10 invalid"],
-["1", "IF 0xc0 ELSE 1 ENDIF"],
-["1", "IF 0xd1 ELSE 1 ENDIF"],
-["1", "IF 0xee ELSE 1 ENDIF"],
-["1", "IF 0xfd ELSE 1 ENDIF"],
-["1", "IF 0xff ELSE 1 ENDIF"],
-
-["NOP", "RIPEMD160"],
-["NOP", "SHA1"],
-["NOP", "SHA256"],
-["NOP", "HASH160"],
-["NOP", "HASH256"],
-
-["NOP",
-"'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'",
-">520 byte push"],
-["0",
-"IF 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' ENDIF 1",
-">520 byte push in non-executed IF branch"],
-["1",
-"0x61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
-">201 opcodes executed. 0x61 is NOP"],
-["0",
-"IF 0x6161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 ENDIF 1",
-">201 opcodes including non-executed IF branch. 0x61 is NOP"],
-["1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
-"1 2 3 4 5 6 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
-">1,000 stack size (0x6f is 3DUP)"],
-["1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f 2DUP 0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
-"10,001-byte scriptPubKey"],
-
-["NOP1","NOP10"],
-
-["1","VER", "OP_VER is reserved"],
-["1","VERIF", "OP_VERIF is reserved"],
-["1","VERNOTIF", "OP_VERNOTIF is reserved"],
-["1","RESERVED1", "OP_RESERVED1 is reserved"],
-["1","RESERVED2", "OP_RESERVED2 is reserved"],
-["1","0xba", "0xba == OP_NOP10 + 1"],
-
-["2147483648", "1ADD 1", "We cannot do math on 5-byte integers"],
-["-2147483648", "1ADD 1", "Because we use a sign bit, -2147483648 is also 5 bytes"],
-
-["1", "1 ENDIF", "ENDIF without IF"],
-["1", "IF 1", "IF without ENDIF"],
-["1 IF 1", "ENDIF", "IFs don't carry over"],
-
-["NOP", "IF 1 ENDIF", "The following tests check the if(stack.size() < N) tests in each opcode"],
-["NOP", "NOTIF 1 ENDIF", "They are here to catch copy-and-paste errors"],
-["NOP", "VERIFY 1", "Most of them are duplicated elsewhere,"],
-
-["NOP", "TOALTSTACK 1", "but, hey, more is always better, right?"],
-["1", "FROMALTSTACK"],
-["1", "2DROP 1"],
-["1", "2DUP"],
-["1 1", "3DUP"],
-["1 1 1", "2OVER"],
-["1 1 1 1 1", "2ROT"],
-["1 1 1", "2SWAP"],
-["NOP", "IFDUP 1"],
-["NOP", "DROP 1"],
-["NOP", "DUP 1"],
-["1", "NIP"],
-["1", "OVER"],
-["1 1 1 3", "PICK"],
-["0", "PICK 1"],
-["1 1 1 3", "ROLL"],
-["0", "ROLL 1"],
-["1 1", "ROT"],
-["1", "SWAP"],
-["1", "TUCK"],
-
-["NOP", "SIZE 1"],
-
-["1", "EQUAL 1"],
-["1", "EQUALVERIFY 1"],
-
-["NOP", "1ADD 1"],
-["NOP", "1SUB 1"],
-["NOP", "NEGATE 1"],
-["NOP", "ABS 1"],
-["NOP", "NOT 1"],
-["NOP", "0NOTEQUAL 1"],
-
-["1", "ADD"],
-["1", "SUB"],
-["1", "BOOLAND"],
-["1", "BOOLOR"],
-["1", "NUMEQUAL"],
-["1", "NUMEQUALVERIFY 1"],
-["1", "NUMNOTEQUAL"],
-["1", "LESSTHAN"],
-["1", "GREATERTHAN"],
-["1", "LESSTHANOREQUAL"],
-["1", "GREATERTHANOREQUAL"],
-["1", "MIN"],
-["1", "MAX"],
-["1 1", "WITHIN"],
-
-["NOP", "RIPEMD160 1"],
-["NOP", "SHA1 1"],
-["NOP", "SHA256 1"],
-["NOP", "HASH160 1"],
-["NOP", "HASH256 1"],
-
-["NOP 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "Tests for Script.IsPushOnly()"],
-["NOP1 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL"],
-
-["0 0x01 0x50", "HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL", "OP_RESERVED in P2SH should fail"],
-["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "OP_VER in P2SH should fail"]
-]
+++ /dev/null
-[
-["0x01 0x0b", "11 EQUAL", "push 1 byte"],
-["0x02 0x417a", "'Az' EQUAL"],
-["0x4b 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a",
- "'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL", "push 75 bytes"],
-
-["0x4c 0x01 0x07","7 EQUAL", "0x4c is OP_PUSHDATA1"],
-["0x4d 0x0100 0x08","8 EQUAL", "0x4d is OP_PUSHDATA2"],
-["0x4e 0x01000000 0x09","9 EQUAL", "0x4e is OP_PUSHDATA4"],
-
-["0x4c 0x00","0 EQUAL"],
-["0x4d 0x0000","0 EQUAL"],
-["0x4e 0x00000000","0 EQUAL"],
-["0x4f 1000 ADD","999 EQUAL"],
-["0", "IF 0x50 ENDIF 1", "0x50 is reserved (ok if not executed)"],
-["0x51", "0x5f ADD 0x60 EQUAL", "0x51 through 0x60 push 1 through 16 onto stack"],
-["1","NOP"],
-["0", "IF VER ELSE 1 ENDIF", "VER non-functional (ok if not executed)"],
-["0", "IF RESERVED1 RESERVED2 ELSE 1 ENDIF", "RESERVED ok in un-executed IF"],
-
-["1", "DUP IF ENDIF"],
-["1", "IF 1 ENDIF"],
-["1", "DUP IF ELSE ENDIF"],
-["1", "IF 1 ELSE ENDIF"],
-["0", "IF ELSE 1 ENDIF"],
-
-["1 1", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 0", "IF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 1", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 0", "IF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["1 0", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 1", "NOTIF IF 1 ELSE 0 ENDIF ENDIF"],
-["1 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-["0 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
-
-["1 1", "VERIFY"],
-
-["10 0 11 TOALTSTACK DROP FROMALTSTACK", "ADD 21 EQUAL"],
-["'gavin_was_here' TOALTSTACK 11 FROMALTSTACK", "'gavin_was_here' EQUALVERIFY 11 EQUAL"],
-
-["0 IFDUP", "DEPTH 1 EQUALVERIFY 0 EQUAL"],
-["1 IFDUP", "DEPTH 2 EQUALVERIFY 1 EQUALVERIFY 1 EQUAL"],
-["0 DROP", "DEPTH 0 EQUAL"],
-["0", "DUP 1 ADD 1 EQUALVERIFY 0 EQUAL"],
-["0 1", "NIP"],
-["1 0", "OVER DEPTH 3 EQUALVERIFY"],
-["22 21 20", "0 PICK 20 EQUALVERIFY DEPTH 3 EQUAL"],
-["22 21 20", "1 PICK 21 EQUALVERIFY DEPTH 3 EQUAL"],
-["22 21 20", "2 PICK 22 EQUALVERIFY DEPTH 3 EQUAL"],
-["22 21 20", "0 ROLL 20 EQUALVERIFY DEPTH 2 EQUAL"],
-["22 21 20", "1 ROLL 21 EQUALVERIFY DEPTH 2 EQUAL"],
-["22 21 20", "2 ROLL 22 EQUALVERIFY DEPTH 2 EQUAL"],
-["22 21 20", "ROT 22 EQUAL"],
-["22 21 20", "ROT DROP 20 EQUAL"],
-["22 21 20", "ROT DROP DROP 21 EQUAL"],
-["22 21 20", "ROT ROT 21 EQUAL"],
-["22 21 20", "ROT ROT ROT 20 EQUAL"],
-["25 24 23 22 21 20", "2ROT 24 EQUAL"],
-["25 24 23 22 21 20", "2ROT DROP 25 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP 20 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP DROP 21 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP 2DROP 22 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2DROP 2DROP DROP 23 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2ROT 22 EQUAL"],
-["25 24 23 22 21 20", "2ROT 2ROT 2ROT 20 EQUAL"],
-["1 0", "SWAP 1 EQUALVERIFY 0 EQUAL"],
-["0 1", "TUCK DEPTH 3 EQUALVERIFY SWAP 2DROP"],
-["13 14", "2DUP ROT EQUALVERIFY EQUAL"],
-["-1 0 1 2", "3DUP DEPTH 7 EQUALVERIFY ADD ADD 3 EQUALVERIFY 2DROP 0 EQUALVERIFY"],
-["1 2 3 5", "2OVER ADD ADD 8 EQUALVERIFY ADD ADD 6 EQUAL"],
-["1 3 5 7", "2SWAP ADD 4 EQUALVERIFY ADD 12 EQUAL"],
-["0", "SIZE 0 EQUAL"],
-["1", "SIZE 1 EQUAL"],
-["127", "SIZE 1 EQUAL"],
-["128", "SIZE 2 EQUAL"],
-["32767", "SIZE 2 EQUAL"],
-["32768", "SIZE 3 EQUAL"],
-["8388607", "SIZE 3 EQUAL"],
-["8388608", "SIZE 4 EQUAL"],
-["2147483647", "SIZE 4 EQUAL"],
-["2147483648", "SIZE 5 EQUAL"],
-["-1", "SIZE 1 EQUAL"],
-["-127", "SIZE 1 EQUAL"],
-["-128", "SIZE 2 EQUAL"],
-["-32767", "SIZE 2 EQUAL"],
-["-32768", "SIZE 3 EQUAL"],
-["-8388607", "SIZE 3 EQUAL"],
-["-8388608", "SIZE 4 EQUAL"],
-["-2147483647", "SIZE 4 EQUAL"],
-["-2147483648", "SIZE 5 EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "SIZE 26 EQUAL"],
-
-
-["2 -2 ADD", "0 EQUAL"],
-["2147483647 -2147483647 ADD", "0 EQUAL"],
-["-1 -1 ADD", "-2 EQUAL"],
-
-["0 0","EQUAL"],
-["1 1 ADD", "2 EQUAL"],
-["1 1ADD", "2 EQUAL"],
-["111 1SUB", "110 EQUAL"],
-["111 1 ADD 12 SUB", "100 EQUAL"],
-["0 ABS", "0 EQUAL"],
-["16 ABS", "16 EQUAL"],
-["-16 ABS", "-16 NEGATE EQUAL"],
-["0 NOT", "NOP"],
-["1 NOT", "0 EQUAL"],
-["11 NOT", "0 EQUAL"],
-["0 0NOTEQUAL", "0 EQUAL"],
-["1 0NOTEQUAL", "1 EQUAL"],
-["111 0NOTEQUAL", "1 EQUAL"],
-["-111 0NOTEQUAL", "1 EQUAL"],
-["1 1 BOOLAND", "NOP"],
-["1 0 BOOLAND", "NOT"],
-["0 1 BOOLAND", "NOT"],
-["0 0 BOOLAND", "NOT"],
-["16 17 BOOLAND", "NOP"],
-["1 1 BOOLOR", "NOP"],
-["1 0 BOOLOR", "NOP"],
-["0 1 BOOLOR", "NOP"],
-["0 0 BOOLOR", "NOT"],
-["16 17 BOOLOR", "NOP"],
-["11 10 1 ADD", "NUMEQUAL"],
-["11 10 1 ADD", "NUMEQUALVERIFY 1"],
-["11 10 1 ADD", "NUMNOTEQUAL NOT"],
-["111 10 1 ADD", "NUMNOTEQUAL"],
-["11 10", "LESSTHAN NOT"],
-["4 4", "LESSTHAN NOT"],
-["10 11", "LESSTHAN"],
-["-11 11", "LESSTHAN"],
-["-11 -10", "LESSTHAN"],
-["11 10", "GREATERTHAN"],
-["4 4", "GREATERTHAN NOT"],
-["10 11", "GREATERTHAN NOT"],
-["-11 11", "GREATERTHAN NOT"],
-["-11 -10", "GREATERTHAN NOT"],
-["11 10", "LESSTHANOREQUAL NOT"],
-["4 4", "LESSTHANOREQUAL"],
-["10 11", "LESSTHANOREQUAL"],
-["-11 11", "LESSTHANOREQUAL"],
-["-11 -10", "LESSTHANOREQUAL"],
-["11 10", "GREATERTHANOREQUAL"],
-["4 4", "GREATERTHANOREQUAL"],
-["10 11", "GREATERTHANOREQUAL NOT"],
-["-11 11", "GREATERTHANOREQUAL NOT"],
-["-11 -10", "GREATERTHANOREQUAL NOT"],
-["1 0 MIN", "0 NUMEQUAL"],
-["0 1 MIN", "0 NUMEQUAL"],
-["-1 0 MIN", "-1 NUMEQUAL"],
-["0 -2147483647 MIN", "-2147483647 NUMEQUAL"],
-["2147483647 0 MAX", "2147483647 NUMEQUAL"],
-["0 100 MAX", "100 NUMEQUAL"],
-["-100 0 MAX", "0 NUMEQUAL"],
-["0 -2147483647 MAX", "0 NUMEQUAL"],
-["0 0 1", "WITHIN"],
-["1 0 1", "WITHIN NOT"],
-["0 -2147483647 2147483647", "WITHIN"],
-["-1 -100 100", "WITHIN"],
-["11 -100 100", "WITHIN"],
-["-2147483647 -100 100", "WITHIN NOT"],
-["2147483647 -100 100", "WITHIN NOT"],
-
-["2147483647 2147483647 SUB", "0 EQUAL"],
-["2147483647 DUP ADD", "4294967294 EQUAL", ">32 bit EQUAL is valid"],
-["2147483647 NEGATE DUP ADD", "-4294967294 EQUAL"],
-
-["''", "RIPEMD160 0x14 0x9c1185a5c5e9fc54612808977ee8f548b2258d31 EQUAL"],
-["'a'", "RIPEMD160 0x14 0x0bdc9d2d256b3ee9daae347be6f4dc835a467ffe EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "RIPEMD160 0x14 0xf71c27109c692c1b56bbdceb5b9d2865b3708dbc EQUAL"],
-["''", "SHA1 0x14 0xda39a3ee5e6b4b0d3255bfef95601890afd80709 EQUAL"],
-["'a'", "SHA1 0x14 0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "SHA1 0x14 0x32d10c7b8cf96570ca04ce37f2a19d84240d3a89 EQUAL"],
-["''", "SHA256 0x20 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 EQUAL"],
-["'a'", "SHA256 0x20 0xca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "SHA256 0x20 0x71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73 EQUAL"],
-["''", "DUP HASH160 SWAP SHA256 RIPEMD160 EQUAL"],
-["''", "DUP HASH256 SWAP SHA256 SHA256 EQUAL"],
-["''", "NOP HASH160 0x14 0xb472a266d0bd89c13706a4132ccfb16f7c3b9fcb EQUAL"],
-["'a'", "HASH160 NOP 0x14 0x994355199e516ff76c4fa4aab39337b9d84cf12b EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "HASH160 0x4c 0x14 0xc286a1af0947f58d1ad787385b1c2c4a976f9e71 EQUAL"],
-["''", "HASH256 0x20 0x5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456 EQUAL"],
-["'a'", "HASH256 0x20 0xbf5d3affb73efd2ec6c36ad3112dd933efed63c4e1cbffcfa88e2759c144f2d8 EQUAL"],
-["'abcdefghijklmnopqrstuvwxyz'", "HASH256 0x4c 0x20 0xca139bc10c2f660da42666f72e89a225936fc60f193c161124a672050c434671 EQUAL"],
-
-
-["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL"],
-["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL"],
-
-["0", "IF 0xba ELSE 1 ENDIF", "opcodes above NOP10 invalid if executed"],
-["0", "IF 0xc0 ELSE 1 ENDIF"],
-["0", "IF 0xd1 ELSE 1 ENDIF"],
-["0", "IF 0xee ELSE 1 ENDIF"],
-["0", "IF 0xfd ELSE 1 ENDIF"],
-["0", "IF 0xff ELSE 1 ENDIF"],
-
-["NOP",
-"'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'",
-"520 byte push"],
-["1",
-"0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
-"201 opcodes executed. 0x61 is NOP"],
-["1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f",
-"1 2 3 4 5 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' 0x6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f6f 2DUP 0x616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161",
-"Max-size (10,000-byte), max-push(520 bytes), max-opcodes(201), max stack size(1,000 items). 0x6f is 3DUP, 0x61 is NOP"],
-
-["NOP","1"],
-
-["1", "0x01 0x01 EQUAL", "The following is useful for checking implementations of BN_bn2mpi"],
-["127", "0x01 0x7F EQUAL"],
-["128", "0x02 0x8000 EQUAL", "Leave room for the sign bit"],
-["32767", "0x02 0xFF7F EQUAL"],
-["32768", "0x03 0x008000 EQUAL"],
-["8388607", "0x03 0xFFFF7F EQUAL"],
-["8388608", "0x04 0x00008000 EQUAL"],
-["2147483647", "0x04 0xFFFFFF7F EQUAL"],
-["2147483648", "0x05 0x0000008000 EQUAL"],
-["-1", "0x01 0x81 EQUAL", "Numbers are little-endian with the MSB being a sign bit"],
-["-127", "0x01 0xFF EQUAL"],
-["-128", "0x02 0x8080 EQUAL"],
-["-32767", "0x02 0xFFFF EQUAL"],
-["-32768", "0x03 0x008080 EQUAL"],
-["-8388607", "0x03 0xFFFFFF EQUAL"],
-["-8388608", "0x04 0x00008080 EQUAL"],
-["-2147483647", "0x04 0xFFFFFFFF EQUAL"],
-["-2147483648", "0x05 0x0000008080 EQUAL"],
-
-["2147483647", "1ADD 2147483648 EQUAL", "We can do math on 4-byte integers, and compare 5-byte ones"],
-["2147483647", "1ADD 1"],
-["-2147483647", "1ADD 1"],
-
-
-["NOP", "NOP 1", "The following tests check the if(stack.size() < N) tests in each opcode"],
-["1", "IF 1 ENDIF", "They are here to catch copy-and-paste errors"],
-["0", "NOTIF 1 ENDIF", "Most of them are duplicated elsewhere,"],
-["1", "VERIFY 1", "but, hey, more is always better, right?"],
-
-["0", "TOALTSTACK 1"],
-["1", "TOALTSTACK FROMALTSTACK"],
-["0 0", "2DROP 1"],
-["0 1", "2DUP"],
-["0 0 1", "3DUP"],
-["0 1 0 0", "2OVER"],
-["0 1 0 0 0 0", "2ROT"],
-["0 1 0 0", "2SWAP"],
-["1", "IFDUP"],
-["NOP", "DEPTH 1"],
-["0", "DROP 1"],
-["1", "DUP"],
-["0 1", "NIP"],
-["1 0", "OVER"],
-["1 0 0 0 3", "PICK"],
-["1 0", "PICK"],
-["1 0 0 0 3", "ROLL"],
-["1 0", "ROLL"],
-["1 0 0", "ROT"],
-["1 0", "SWAP"],
-["0 1", "TUCK"],
-
-["1", "SIZE"],
-
-["0 0", "EQUAL"],
-["0 0", "EQUALVERIFY 1"],
-
-["0", "1ADD"],
-["2", "1SUB"],
-["-1", "NEGATE"],
-["-1", "ABS"],
-["0", "NOT"],
-["-1", "0NOTEQUAL"],
-
-["1 0", "ADD"],
-["1 0", "SUB"],
-["-1 -1", "BOOLAND"],
-["-1 0", "BOOLOR"],
-["0 0", "NUMEQUAL"],
-["0 0", "NUMEQUALVERIFY 1"],
-["-1 0", "NUMNOTEQUAL"],
-["-1 0", "LESSTHAN"],
-["1 0", "GREATERTHAN"],
-["0 0", "LESSTHANOREQUAL"],
-["0 0", "GREATERTHANOREQUAL"],
-["-1 0", "MIN"],
-["1 0", "MAX"],
-["-1 -1 0", "WITHIN"],
-
-["0", "RIPEMD160"],
-["0", "SHA1"],
-["0", "SHA256"],
-["0", "HASH160"],
-["0", "HASH256"],
-["NOP", "CODESEPARATOR 1"],
-
-["NOP", "NOP1 1"],
-["NOP", "NOP2 1"],
-["NOP", "NOP3 1"],
-["NOP", "NOP4 1"],
-["NOP", "NOP5 1"],
-["NOP", "NOP6 1"],
-["NOP", "NOP7 1"],
-["NOP", "NOP8 1"],
-["NOP", "NOP9 1"],
-["NOP", "NOP10 1"],
-
-["0 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL", "Very basic P2SH"],
-["0x4c 0 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL"]
-]
+++ /dev/null
-[
-["The following are deserialized transactions which are invalid."],
-["They are in the form"],
-["[[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"],
-["serializedTransaction, enforceP2SH]"],
-["Objects that are only a single string (like this one) are ignored"],
-
-["0e1b5688cf179cd9f7cbda1fac0090f6e684bbf8cd946660120197c3f3681809 but with extra junk appended to the end of the scriptPubKey"],
-[[["6ca7ec7b1847f6bdbd737176050e6a08d66ccd55bb94ad24f4018024107a5827", 0, "0x41 0x043b640e983c9690a14c039a2037ecc3467b27a0dcd58f19d76c7bc118d09fec45adc5370a1c5bf8067ca9f5557a4cf885fdb0fe0dcc9c3a7137226106fbc779a5 CHECKSIG VERIFY 1"]],
-"010000000127587a10248001f424ad94bb55cd6cd6086a0e05767173bdbdf647187beca76c000000004948304502201b822ad10d6adc1a341ae8835be3f70a25201bbff31f59cbb9c5353a5f0eca18022100ea7b2f7074e9aa9cf70aa8d0ffee13e6b45dddabf1ab961bda378bcdb778fa4701ffffffff0100f2052a010000001976a914fc50c5907d86fed474ba5ce8b12a66e0a4c139d888ac00000000", true],
-
-["This is the nearly-standard transaction with CHECKSIGVERIFY 1 instead of CHECKSIG from tx_valid.json"],
-["but with the signature duplicated in the scriptPubKey with a non-standard pushdata prefix"],
-["See FindAndDelete, which will only remove if it uses the same pushdata prefix as is standard"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x4c 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006a473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
-
-["Same as above, but with the sig in the scriptSig also pushed with the same non-standard OP_PUSHDATA"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x4c 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006b4c473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
-
-["An invalid P2SH Transaction"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7a052c840ba73af26755de42cf01cc9e0a49fef0 EQUAL"]],
-"010000000100010000000000000000000000000000000000000000000000000000000000000000000009085768617420697320ffffffff010000000000000000015100000000", true],
-
-["Tests for CTransaction::CheckTransaction()"],
-["No inputs"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7a052c840ba73af26755de42cf01cc9e0a49fef0 EQUAL"]],
-"0100000000010000000000000000015100000000", true],
-
-["No outputs"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x05ab9e14d983742513f0f451e105ffb4198d1dd4 EQUAL"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006d483045022100f16703104aab4e4088317c862daec83440242411b039d14280e03dd33b487ab802201318a7be236672c5c56083eb7a5a195bc57a40af7923ff8545016cd3b571e2a601232103c40e5d339df3f30bf753e7e04450ae4ef76c9e45587d1d993bdc4cd06f0651c7acffffffff0000000000", true],
-
-["Negative output"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xae609aca8061d77c5e111f6bb62501a6bbe2bfdb EQUAL"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006d4830450220063222cbb128731fc09de0d7323746539166544d6c1df84d867ccea84bcc8903022100bf568e8552844de664cd41648a031554327aa8844af34b4f27397c65b92c04de0123210243ec37dee0e2e053a9c976f43147e79bc7d9dc606ea51010af1ac80db6b069e1acffffffff01ffffffffffffffff015100000000", true],
-
-["MAX_MONEY + 1 output"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x32afac281462b822adbec5094b8d4d337dd5bd6a EQUAL"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006e493046022100e1eadba00d9296c743cb6ecc703fd9ddc9b3cd12906176a226ae4c18d6b00796022100a71aef7d2874deff681ba6080f1b278bac7bb99c61b08a85f4311970ffe7f63f012321030c0588dc44d92bdcbf8e72093466766fdc265ead8db64517b0c542275b70fffbacffffffff010140075af0750700015100000000", true],
-
-["MAX_MONEY output + 1 output"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xb558cbf4930954aa6a344363a15668d7477ae716 EQUAL"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006d483045022027deccc14aa6668e78a8c9da3484fbcd4f9dcc9bb7d1b85146314b21b9ae4d86022100d0b43dece8cfb07348de0ca8bc5b86276fa88f7f2138381128b7c36ab2e42264012321029bb13463ddd5d2cc05da6e84e37536cb9525703cfd8f43afdb414988987a92f6acffffffff020040075af075070001510001000000000000015100000000", true],
-
-["Duplicate inputs"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x236d0639db62b0773fd8ac34dc85ae19e9aba80a EQUAL"]],
-"01000000020001000000000000000000000000000000000000000000000000000000000000000000006c47304402204bb1197053d0d7799bf1b30cd503c44b58d6240cccbdc85b6fe76d087980208f02204beeed78200178ffc6c74237bb74b3f276bbb4098b5605d814304fe128bf1431012321039e8815e15952a7c3fada1905f8cf55419837133bd7756c0ef14fc8dfe50c0deaacffffffff0001000000000000000000000000000000000000000000000000000000000000000000006c47304402202306489afef52a6f62e90bf750bbcdf40c06f5c6b138286e6b6b86176bb9341802200dba98486ea68380f47ebb19a7df173b99e6bc9c681d6ccf3bde31465d1f16b3012321039e8815e15952a7c3fada1905f8cf55419837133bd7756c0ef14fc8dfe50c0deaacffffffff010000000000000000015100000000", true],
-
-["Coinbase of size 1"],
-["Note the input is just required to make the tester happy"],
-[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "1"]],
-"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0151ffffffff010000000000000000015100000000", true],
-
-["Coinbase of size 101"],
-["Note the input is just required to make the tester happy"],
-[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "1"]],
-"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff655151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151ffffffff010000000000000000015100000000", true],
-
-["Null txin"],
-[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "HASH160 0x14 0x02dae7dbbda56097959cba59b1989dd3e47937bf EQUAL"]],
-"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6e49304602210086f39e028e46dafa8e1e3be63906465f4cf038fbe5ed6403dc3e74ae876e6431022100c4625c675cfc5c7e3a0e0d7eaec92ac24da20c73a88eb40d09253e51ac6def5201232103a183ddc41e84753aca47723c965d1b5c8b0e2b537963518355e6dd6cf8415e50acffffffff010000000000000000015100000000", true]
-]
+++ /dev/null
-[
-["The following are deserialized transactions which are valid."],
-["They are in the form"],
-["[[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"],
-["serializedTransaction, enforceP2SH]"],
-["Objects that are only a single string (like this one) are ignored"],
-
-["The following is 23b397edccd3740a74adb603c9756370fafcde9bcc4483eb271ecad09a94dd63"],
-["It is of particular interest because it contains an invalidly-encoded signature which OpenSSL accepts"],
-["See http://r6.ca/blog/20111119T211504Z.html"],
-["It is also the first OP_CHECKMULTISIG transaction in standard form"],
-[[["60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1", 0, "1 0x41 0x04cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4 0x41 0x0461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af 2 OP_CHECKMULTISIG"]],
-"0100000001b14bdcbc3e01bdaad36cc08e81e69c82e1060bc14e518db2b49aa43ad90ba26000000000490047304402203f16c6f40162ab686621ef3000b04e75418a0c0cb2d8aebeac894ae360ac1e780220ddc15ecdfc3507ac48e1681a33eb60996631bf6bf5bc0a0682c4db743ce7ca2b01ffffffff0140420f00000000001976a914660d4ef3a743e3e696ad990364e555c271ad504b88ac00000000", true],
-
-["The following is a tweaked form of 23b397edccd3740a74adb603c9756370fafcde9bcc4483eb271ecad09a94dd63"],
-["It has an arbitrary extra byte stuffed into the signature at pos length - 2"],
-[[["60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1", 0, "1 0x41 0x04cc71eb30d653c0c3163990c47b976f3fb3f37cccdcbedb169a1dfef58bbfbfaff7d8a473e7e2e6d317b87bafe8bde97e3cf8f065dec022b51d11fcdd0d348ac4 0x41 0x0461cbdcc5409fb4b4d42b51d33381354d80e550078cb532a34bfa2fcfdeb7d76519aecc62770f5b0e4ef8551946d8a540911abe3e7854a26f39f58b25c15342af 2 OP_CHECKMULTISIG"]],
-"0100000001b14bdcbc3e01bdaad36cc08e81e69c82e1060bc14e518db2b49aa43ad90ba260000000004A0048304402203f16c6f40162ab686621ef3000b04e75418a0c0cb2d8aebeac894ae360ac1e780220ddc15ecdfc3507ac48e1681a33eb60996631bf6bf5bc0a0682c4db743ce7ca2bab01ffffffff0140420f00000000001976a914660d4ef3a743e3e696ad990364e555c271ad504b88ac00000000", true],
-
-["The following is c99c49da4c38af669dea436d3e73780dfdb6c1ecf9958baa52960e8baee30e73"],
-["It is of interest because it contains a 0-sequence as well as a signature of SIGHASH type 0 (which is not a real type)"],
-[[["406b2b06bcd34d3c8733e6b79f7a394c8a431fbf4ff5ac705c93f4076bb77602", 0, "DUP HASH160 0x14 0xdc44b1164188067c3a32d4780f5996fa14a4f2d9 EQUALVERIFY CHECKSIG"]],
-"01000000010276b76b07f4935c70acf54fbf1f438a4c397a9fb7e633873c4dd3bc062b6b40000000008c493046022100d23459d03ed7e9511a47d13292d3430a04627de6235b6e51a40f9cd386f2abe3022100e7d25b080f0bb8d8d5f878bba7d54ad2fda650ea8d158a33ee3cbd11768191fd004104b0e2c879e4daf7b9ab68350228c159766676a14f5815084ba166432aab46198d4cca98fa3e9981d0a90b2effc514b76279476550ba3663fdcaff94c38420e9d5000000000100093d00000000001976a9149a7b0f3b80c6baaeedce0a0842553800f832ba1f88ac00000000", true],
-
-["A nearly-standard transaction with CHECKSIGVERIFY 1 instead of CHECKSIG"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006a473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
-
-["Same as above, but with the signature duplicated in the scriptPubKey with the proper pushdata prefix"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0x5b6462475454710f3c22f5fdf0b40704c92f25c3 EQUALVERIFY CHECKSIGVERIFY 1 0x47 0x3044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a01"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006a473044022067288ea50aa799543a536ff9306f8e1cba05b9c6b10951175b924f96732555ed022026d7b5265f38d21541519e4a1e55044d5b9e17e15cdbaf29ae3792e99e883e7a012103ba8c8b86dea131c22ab967e6dd99bdae8eff7a1f75a2c35f1f944109e3fe5e22ffffffff010000000000000000015100000000", true],
-
-["The following is f7fdd091fa6d8f5e7a8c2458f5c38faffff2d3f1406b6e4fe2c99dcc0d2d1cbb"],
-["It caught a bug in the workaround for 23b397edccd3740a74adb603c9756370fafcde9bcc4483eb271ecad09a94dd63 in an overly simple implementation"],
-[[["b464e85df2a238416f8bdae11d120add610380ea07f4ef19c5f9dfd472f96c3d", 0, "DUP HASH160 0x14 0xbef80ecf3a44500fda1bc92176e442891662aed2 EQUALVERIFY CHECKSIG"],
-["b7978cc96e59a8b13e0865d3f95657561a7f725be952438637475920bac9eb21", 1, "DUP HASH160 0x14 0xbef80ecf3a44500fda1bc92176e442891662aed2 EQUALVERIFY CHECKSIG"]],
-"01000000023d6cf972d4dff9c519eff407ea800361dd0a121de1da8b6f4138a2f25de864b4000000008a4730440220ffda47bfc776bcd269da4832626ac332adfca6dd835e8ecd83cd1ebe7d709b0e022049cffa1cdc102a0b56e0e04913606c70af702a1149dc3b305ab9439288fee090014104266abb36d66eb4218a6dd31f09bb92cf3cfa803c7ea72c1fc80a50f919273e613f895b855fb7465ccbc8919ad1bd4a306c783f22cd3227327694c4fa4c1c439affffffff21ebc9ba20594737864352e95b727f1a565756f9d365083eb1a8596ec98c97b7010000008a4730440220503ff10e9f1e0de731407a4a245531c9ff17676eda461f8ceeb8c06049fa2c810220c008ac34694510298fa60b3f000df01caa244f165b727d4896eb84f81e46bcc4014104266abb36d66eb4218a6dd31f09bb92cf3cfa803c7ea72c1fc80a50f919273e613f895b855fb7465ccbc8919ad1bd4a306c783f22cd3227327694c4fa4c1c439affffffff01f0da5200000000001976a914857ccd42dded6df32949d4646dfa10a92458cfaa88ac00000000", true],
-
-["The following tests for the presence of a bug in the handling of SIGHASH_SINGLE"],
-["It results in signing the constant 1, instead of something generated based on the transaction,"],
-["when the input doing the signing has an index greater than the maximum output index"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "DUP HASH160 0x14 0xe52b482f2faa8ecbf0db344f93c84ac908557f33 EQUALVERIFY CHECKSIG"], ["0000000000000000000000000000000000000000000000000000000000000200", 0, "1"]],
-"01000000020002000000000000000000000000000000000000000000000000000000000000000000000151ffffffff0001000000000000000000000000000000000000000000000000000000000000000000006b483045022100c9cdd08798a28af9d1baf44a6c77bcc7e279f47dc487c8c899911bc48feaffcc0220503c5c50ae3998a733263c5c0f7061b483e2b56c4c41b456e7d2f5a78a74c077032102d5c25adb51b61339d2b05315791e21bbe80ea470a49db0135720983c905aace0ffffffff010000000000000000015100000000", true],
-
-["An invalid P2SH Transaction"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7a052c840ba73af26755de42cf01cc9e0a49fef0 EQUAL"]],
-"010000000100010000000000000000000000000000000000000000000000000000000000000000000009085768617420697320ffffffff010000000000000000015100000000", false],
-
-["A valid P2SH Transaction using the standard transaction type put forth in BIP 16"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x8febbed40483661de6958d957412f82deed8e2f7 EQUAL"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006e493046022100c66c9cdf4c43609586d15424c54707156e316d88b0a1534c9e6b0d4f311406310221009c0fe51dbc9c4ab7cc25d3fdbeccf6679fe6827f08edf2b4a9f16ee3eb0e438a0123210338e8034509af564c62644c07691942e0c056752008a173c89f60ab2a88ac2ebfacffffffff010000000000000000015100000000", true],
-
-["Tests for CTransaction::CheckTransaction()"],
-["MAX_MONEY output"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x32afac281462b822adbec5094b8d4d337dd5bd6a EQUAL"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006e493046022100e1eadba00d9296c743cb6ecc703fd9ddc9b3cd12906176a226ae4c18d6b00796022100a71aef7d2874deff681ba6080f1b278bac7bb99c61b08a85f4311970ffe7f63f012321030c0588dc44d92bdcbf8e72093466766fdc265ead8db64517b0c542275b70fffbacffffffff010040075af0750700015100000000", true],
-
-["MAX_MONEY output + 0 output"],
-[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xb558cbf4930954aa6a344363a15668d7477ae716 EQUAL"]],
-"01000000010001000000000000000000000000000000000000000000000000000000000000000000006d483045022027deccc14aa6668e78a8c9da3484fbcd4f9dcc9bb7d1b85146314b21b9ae4d86022100d0b43dece8cfb07348de0ca8bc5b86276fa88f7f2138381128b7c36ab2e42264012321029bb13463ddd5d2cc05da6e84e37536cb9525703cfd8f43afdb414988987a92f6acffffffff020040075af075070001510000000000000000015100000000", true],
-
-["Coinbase of size 2"],
-["Note the input is just required to make the tester happy"],
-[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "1"]],
-"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff025151ffffffff010000000000000000015100000000", true],
-
-["Coinbase of size 100"],
-["Note the input is just required to make the tester happy"],
-[[["0000000000000000000000000000000000000000000000000000000000000000", -1, "1"]],
-"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6451515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151515151ffffffff010000000000000000015100000000", true]
-]
+++ /dev/null
-#include <boost/algorithm/string.hpp>
-#include <boost/foreach.hpp>
-#include <boost/test/unit_test.hpp>
-
-#include "util.h"
-
-BOOST_AUTO_TEST_SUITE(getarg_tests)
-
-static void
-ResetArgs(const std::string& strArg)
-{
- std::vector<std::string> vecArg;
- boost::split(vecArg, strArg, boost::is_space(), boost::token_compress_on);
-
- // Insert dummy executable name:
- vecArg.insert(vecArg.begin(), "testbitcoin");
-
- // Convert to char*:
- std::vector<const char*> vecChar;
- BOOST_FOREACH(std::string& s, vecArg)
- vecChar.push_back(s.c_str());
-
- ParseParameters(vecChar.size(), &vecChar[0]);
-}
-
-BOOST_AUTO_TEST_CASE(boolarg)
-{
- ResetArgs("-foo");
- BOOST_CHECK(GetBoolArg("-foo"));
- BOOST_CHECK(GetBoolArg("-foo", false));
- BOOST_CHECK(GetBoolArg("-foo", true));
-
- BOOST_CHECK(!GetBoolArg("-fo"));
- BOOST_CHECK(!GetBoolArg("-fo", false));
- BOOST_CHECK(GetBoolArg("-fo", true));
-
- BOOST_CHECK(!GetBoolArg("-fooo"));
- BOOST_CHECK(!GetBoolArg("-fooo", false));
- BOOST_CHECK(GetBoolArg("-fooo", true));
-
- ResetArgs("-foo=0");
- BOOST_CHECK(!GetBoolArg("-foo"));
- BOOST_CHECK(!GetBoolArg("-foo", false));
- BOOST_CHECK(!GetBoolArg("-foo", true));
-
- ResetArgs("-foo=1");
- BOOST_CHECK(GetBoolArg("-foo"));
- BOOST_CHECK(GetBoolArg("-foo", false));
- BOOST_CHECK(GetBoolArg("-foo", true));
-
- // New 0.6 feature: auto-map -nosomething to !-something:
- ResetArgs("-nofoo");
- BOOST_CHECK(!GetBoolArg("-foo"));
- BOOST_CHECK(!GetBoolArg("-foo", false));
- BOOST_CHECK(!GetBoolArg("-foo", true));
-
- ResetArgs("-nofoo=1");
- BOOST_CHECK(!GetBoolArg("-foo"));
- BOOST_CHECK(!GetBoolArg("-foo", false));
- BOOST_CHECK(!GetBoolArg("-foo", true));
-
- ResetArgs("-foo -nofoo"); // -foo should win
- BOOST_CHECK(GetBoolArg("-foo"));
- BOOST_CHECK(GetBoolArg("-foo", false));
- BOOST_CHECK(GetBoolArg("-foo", true));
-
- ResetArgs("-foo=1 -nofoo=1"); // -foo should win
- BOOST_CHECK(GetBoolArg("-foo"));
- BOOST_CHECK(GetBoolArg("-foo", false));
- BOOST_CHECK(GetBoolArg("-foo", true));
-
- ResetArgs("-foo=0 -nofoo=0"); // -foo should win
- BOOST_CHECK(!GetBoolArg("-foo"));
- BOOST_CHECK(!GetBoolArg("-foo", false));
- BOOST_CHECK(!GetBoolArg("-foo", true));
-
- // New 0.6 feature: treat -- same as -:
- ResetArgs("--foo=1");
- BOOST_CHECK(GetBoolArg("-foo"));
- BOOST_CHECK(GetBoolArg("-foo", false));
- BOOST_CHECK(GetBoolArg("-foo", true));
-
- ResetArgs("--nofoo=1");
- BOOST_CHECK(!GetBoolArg("-foo"));
- BOOST_CHECK(!GetBoolArg("-foo", false));
- BOOST_CHECK(!GetBoolArg("-foo", true));
-
-}
-
-BOOST_AUTO_TEST_CASE(stringarg)
-{
- ResetArgs("");
- BOOST_CHECK_EQUAL(GetArg("-foo", ""), "");
- BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "eleven");
-
- ResetArgs("-foo -bar");
- BOOST_CHECK_EQUAL(GetArg("-foo", ""), "");
- BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "");
-
- ResetArgs("-foo=");
- BOOST_CHECK_EQUAL(GetArg("-foo", ""), "");
- BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "");
-
- ResetArgs("-foo=11");
- BOOST_CHECK_EQUAL(GetArg("-foo", ""), "11");
- BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "11");
-
- ResetArgs("-foo=eleven");
- BOOST_CHECK_EQUAL(GetArg("-foo", ""), "eleven");
- BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "eleven");
-
-}
-
-BOOST_AUTO_TEST_CASE(intarg)
-{
- ResetArgs("");
- BOOST_CHECK_EQUAL(GetArg("-foo", 11), 11);
- BOOST_CHECK_EQUAL(GetArg("-foo", 0), 0);
-
- ResetArgs("-foo -bar");
- BOOST_CHECK_EQUAL(GetArg("-foo", 11), 0);
- BOOST_CHECK_EQUAL(GetArg("-bar", 11), 0);
-
- ResetArgs("-foo=11 -bar=12");
- BOOST_CHECK_EQUAL(GetArg("-foo", 0), 11);
- BOOST_CHECK_EQUAL(GetArg("-bar", 11), 12);
-
- ResetArgs("-foo=NaN -bar=NotANumber");
- BOOST_CHECK_EQUAL(GetArg("-foo", 1), 0);
- BOOST_CHECK_EQUAL(GetArg("-bar", 11), 0);
-}
-
-BOOST_AUTO_TEST_CASE(doubledash)
-{
- ResetArgs("--foo");
- BOOST_CHECK_EQUAL(GetBoolArg("-foo"), true);
-
- ResetArgs("--foo=verbose --bar=1");
- BOOST_CHECK_EQUAL(GetArg("-foo", ""), "verbose");
- BOOST_CHECK_EQUAL(GetArg("-bar", 0), 1);
-}
-
-BOOST_AUTO_TEST_CASE(boolargno)
-{
- ResetArgs("-nofoo");
- BOOST_CHECK(!GetBoolArg("-foo"));
- BOOST_CHECK(!GetBoolArg("-foo", true));
- BOOST_CHECK(!GetBoolArg("-foo", false));
-
- ResetArgs("-nofoo=1");
- BOOST_CHECK(!GetBoolArg("-foo"));
- BOOST_CHECK(!GetBoolArg("-foo", true));
- BOOST_CHECK(!GetBoolArg("-foo", false));
-
- ResetArgs("-nofoo=0");
- BOOST_CHECK(GetBoolArg("-foo"));
- BOOST_CHECK(GetBoolArg("-foo", true));
- BOOST_CHECK(GetBoolArg("-foo", false));
-
- ResetArgs("-foo --nofoo");
- BOOST_CHECK(GetBoolArg("-foo"));
-
- ResetArgs("-nofoo -foo"); // foo always wins:
- BOOST_CHECK(GetBoolArg("-foo"));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-#include <vector>
-
-#include "key.h"
-#include "base58.h"
-#include "uint256.h"
-#include "util.h"
-
-using namespace std;
-
-static const string strSecret1 ("5HxWvvfubhXpYYpS3tJkw6fq9jE9j18THftkZjHHfmFiWtmAbrj");
-static const string strSecret2 ("5KC4ejrDjv152FGwP386VD1i2NYc5KkfSMyv1nGy1VGDxGHqVY3");
-static const string strSecret1C ("Kwr371tjA9u2rFSMZjTNun2PXXP3WPZu2afRHTcta6KxEUdm1vEw");
-static const string strSecret2C ("L3Hq7a8FEQwJkW1M2GNKDW28546Vp5miewcCzSqUD9kCAXrJdS3g");
-static const CBitcoinAddress addr1 ("1QFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ");
-static const CBitcoinAddress addr2 ("1F5y5E5FMc5YzdJtB9hLaUe43GDxEKXENJ");
-static const CBitcoinAddress addr1C("1NoJrossxPBKfCHuJXT4HadJrXRE9Fxiqs");
-static const CBitcoinAddress addr2C("1CRj2HyM1CXWzHAXLQtiGLyggNT9WQqsDs");
-
-
-static const string strAddressBad("1HV9Lc3sNHZxwj4Zk6fB38tEmBryq2cBiF");
-
-
-#ifdef KEY_TESTS_DUMPINFO
-void dumpKeyInfo(uint256 privkey)
-{
- CSecret secret;
- secret.resize(32);
- memcpy(&secret[0], &privkey, 32);
- vector<unsigned char> sec;
- sec.resize(32);
- memcpy(&sec[0], &secret[0], 32);
- printf(" * secret (hex): %s\n", HexStr(sec).c_str());
-
- for (int nCompressed=0; nCompressed<2; nCompressed++)
- {
- bool fCompressed = nCompressed == 1;
- printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed");
- CBitcoinSecret bsecret;
- bsecret.SetSecret(secret, fCompressed);
- printf(" * secret (base58): %s\n", bsecret.ToString().c_str());
- CKey key;
- key.SetSecret(secret, fCompressed);
- vector<unsigned char> vchPubKey = key.GetPubKey();
- printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str());
- printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str());
- }
-}
-#endif
-
-
-BOOST_AUTO_TEST_SUITE(key_tests)
-
-BOOST_AUTO_TEST_CASE(key_test1)
-{
- CBitcoinSecret bsecret1, bsecret2, bsecret1C, bsecret2C, baddress1;
- BOOST_CHECK( bsecret1.SetString (strSecret1));
- BOOST_CHECK( bsecret2.SetString (strSecret2));
- BOOST_CHECK( bsecret1C.SetString(strSecret1C));
- BOOST_CHECK( bsecret2C.SetString(strSecret2C));
- BOOST_CHECK(!baddress1.SetString(strAddressBad));
-
- bool fCompressed;
- CSecret secret1 = bsecret1.GetSecret (fCompressed);
- BOOST_CHECK(fCompressed == false);
- CSecret secret2 = bsecret2.GetSecret (fCompressed);
- BOOST_CHECK(fCompressed == false);
- CSecret secret1C = bsecret1C.GetSecret(fCompressed);
- BOOST_CHECK(fCompressed == true);
- CSecret secret2C = bsecret2C.GetSecret(fCompressed);
- BOOST_CHECK(fCompressed == true);
-
- BOOST_CHECK(secret1 == secret1C);
- BOOST_CHECK(secret2 == secret2C);
-
- CKey key1, key2, key1C, key2C;
- key1.SetSecret(secret1, false);
- key2.SetSecret(secret2, false);
- key1C.SetSecret(secret1, true);
- key2C.SetSecret(secret2, true);
-
- BOOST_CHECK(addr1.Get() == CTxDestination(key1.GetPubKey().GetID()));
- BOOST_CHECK(addr2.Get() == CTxDestination(key2.GetPubKey().GetID()));
- BOOST_CHECK(addr1C.Get() == CTxDestination(key1C.GetPubKey().GetID()));
- BOOST_CHECK(addr2C.Get() == CTxDestination(key2C.GetPubKey().GetID()));
-
- for (int n=0; n<16; n++)
- {
- string strMsg = strprintf("Very secret message %i: 11", n);
- uint256 hashMsg = Hash(strMsg.begin(), strMsg.end());
-
- // normal signatures
-
- vector<unsigned char> sign1, sign2, sign1C, sign2C;
-
- BOOST_CHECK(key1.Sign (hashMsg, sign1));
- BOOST_CHECK(key2.Sign (hashMsg, sign2));
- BOOST_CHECK(key1C.Sign(hashMsg, sign1C));
- BOOST_CHECK(key2C.Sign(hashMsg, sign2C));
-
- BOOST_CHECK( key1.Verify(hashMsg, sign1));
- BOOST_CHECK(!key1.Verify(hashMsg, sign2));
- BOOST_CHECK( key1.Verify(hashMsg, sign1C));
- BOOST_CHECK(!key1.Verify(hashMsg, sign2C));
-
- BOOST_CHECK(!key2.Verify(hashMsg, sign1));
- BOOST_CHECK( key2.Verify(hashMsg, sign2));
- BOOST_CHECK(!key2.Verify(hashMsg, sign1C));
- BOOST_CHECK( key2.Verify(hashMsg, sign2C));
-
- BOOST_CHECK( key1C.Verify(hashMsg, sign1));
- BOOST_CHECK(!key1C.Verify(hashMsg, sign2));
- BOOST_CHECK( key1C.Verify(hashMsg, sign1C));
- BOOST_CHECK(!key1C.Verify(hashMsg, sign2C));
-
- BOOST_CHECK(!key2C.Verify(hashMsg, sign1));
- BOOST_CHECK( key2C.Verify(hashMsg, sign2));
- BOOST_CHECK(!key2C.Verify(hashMsg, sign1C));
- BOOST_CHECK( key2C.Verify(hashMsg, sign2C));
-
- // compact signatures (with key recovery)
-
- vector<unsigned char> csign1, csign2, csign1C, csign2C;
-
- BOOST_CHECK(key1.SignCompact (hashMsg, csign1));
- BOOST_CHECK(key2.SignCompact (hashMsg, csign2));
- BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C));
- BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C));
-
- CKey rkey1, rkey2, rkey1C, rkey2C;
-
- BOOST_CHECK(rkey1.SetCompactSignature (hashMsg, csign1));
- BOOST_CHECK(rkey2.SetCompactSignature (hashMsg, csign2));
- BOOST_CHECK(rkey1C.SetCompactSignature(hashMsg, csign1C));
- BOOST_CHECK(rkey2C.SetCompactSignature(hashMsg, csign2C));
-
-
- BOOST_CHECK(rkey1.GetPubKey() == key1.GetPubKey());
- BOOST_CHECK(rkey2.GetPubKey() == key2.GetPubKey());
- BOOST_CHECK(rkey1C.GetPubKey() == key1C.GetPubKey());
- BOOST_CHECK(rkey2C.GetPubKey() == key2C.GetPubKey());
- }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include "init.h"
-#include "main.h"
-#include "uint256.h"
-#include "util.h"
-#include "wallet.h"
-
-extern void SHA256Transform(void* pstate, void* pinput, const void* pinit);
-
-BOOST_AUTO_TEST_SUITE(miner_tests)
-
-static
-struct {
- unsigned char extranonce;
- unsigned int nonce;
-} blockinfo[] = {
- {4, 0xa4a3e223}, {2, 0x15c32f9e}, {1, 0x0375b547}, {1, 0x7004a8a5},
- {2, 0xce440296}, {2, 0x52cfe198}, {1, 0x77a72cd0}, {2, 0xbb5d6f84},
- {2, 0x83f30c2c}, {1, 0x48a73d5b}, {1, 0xef7dcd01}, {2, 0x6809c6c4},
- {2, 0x0883ab3c}, {1, 0x087bbbe2}, {2, 0x2104a814}, {2, 0xdffb6daa},
- {1, 0xee8a0a08}, {2, 0xba4237c1}, {1, 0xa70349dc}, {1, 0x344722bb},
- {3, 0xd6294733}, {2, 0xec9f5c94}, {2, 0xca2fbc28}, {1, 0x6ba4f406},
- {2, 0x015d4532}, {1, 0x6e119b7c}, {2, 0x43e8f314}, {2, 0x27962f38},
- {2, 0xb571b51b}, {2, 0xb36bee23}, {2, 0xd17924a8}, {2, 0x6bc212d9},
- {1, 0x630d4948}, {2, 0x9a4c4ebb}, {2, 0x554be537}, {1, 0xd63ddfc7},
- {2, 0xa10acc11}, {1, 0x759a8363}, {2, 0xfb73090d}, {1, 0xe82c6a34},
- {1, 0xe33e92d7}, {3, 0x658ef5cb}, {2, 0xba32ff22}, {5, 0x0227a10c},
- {1, 0xa9a70155}, {5, 0xd096d809}, {1, 0x37176174}, {1, 0x830b8d0f},
- {1, 0xc6e3910e}, {2, 0x823f3ca8}, {1, 0x99850849}, {1, 0x7521fb81},
- {1, 0xaacaabab}, {1, 0xd645a2eb}, {5, 0x7aea1781}, {5, 0x9d6e4b78},
- {1, 0x4ce90fd8}, {1, 0xabdc832d}, {6, 0x4a34f32a}, {2, 0xf2524c1c},
- {2, 0x1bbeb08a}, {1, 0xad47f480}, {1, 0x9f026aeb}, {1, 0x15a95049},
- {2, 0xd1cb95b2}, {2, 0xf84bbda5}, {1, 0x0fa62cd1}, {1, 0xe05f9169},
- {1, 0x78d194a9}, {5, 0x3e38147b}, {5, 0x737ba0d4}, {1, 0x63378e10},
- {1, 0x6d5f91cf}, {2, 0x88612eb8}, {2, 0xe9639484}, {1, 0xb7fabc9d},
- {2, 0x19b01592}, {1, 0x5a90dd31}, {2, 0x5bd7e028}, {2, 0x94d00323},
- {1, 0xa9b9c01a}, {1, 0x3a40de61}, {1, 0x56e7eec7}, {5, 0x859f7ef6},
- {1, 0xfd8e5630}, {1, 0x2b0c9f7f}, {1, 0xba700e26}, {1, 0x7170a408},
- {1, 0x70de86a8}, {1, 0x74d64cd5}, {1, 0x49e738a1}, {2, 0x6910b602},
- {0, 0x643c565f}, {1, 0x54264b3f}, {2, 0x97ea6396}, {2, 0x55174459},
- {2, 0x03e8779a}, {1, 0x98f34d8f}, {1, 0xc07b2b07}, {1, 0xdfe29668},
- {1, 0x3141c7c1}, {1, 0xb3b595f4}, {1, 0x735abf08}, {5, 0x623bfbce},
- {2, 0xd351e722}, {1, 0xf4ca48c9}, {1, 0x5b19c670}, {1, 0xa164bf0e},
- {2, 0xbbbeb305}, {2, 0xfe1c810a},
-};
-
-// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
-BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
-{
- CReserveKey reservekey(pwalletMain);
- CBlock *pblock;
- CTransaction tx;
- CScript script;
- uint256 hash;
-
- // Simple block creation, nothing special yet:
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
-
- // We can't make transactions until we have inputs
- // Therefore, load 100 blocks :)
- std::vector<CTransaction*>txFirst;
- for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
- {
- pblock->nVersion = 1;
- pblock->nTime = pindexBest->GetMedianTimePast()+1;
- pblock->vtx[0].vin[0].scriptSig = CScript();
- pblock->vtx[0].vin[0].scriptSig.push_back(blockinfo[i].extranonce);
- pblock->vtx[0].vin[0].scriptSig.push_back(pindexBest->nHeight);
- pblock->vtx[0].vout[0].scriptPubKey = CScript();
- if (txFirst.size() < 2)
- txFirst.push_back(new CTransaction(pblock->vtx[0]));
- pblock->hashMerkleRoot = pblock->BuildMerkleTree();
- pblock->nNonce = blockinfo[i].nonce;
- assert(ProcessBlock(NULL, pblock));
- pblock->hashPrevBlock = pblock->GetHash();
- }
- delete pblock;
-
- // Just to make sure we can still make simple blocks
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
-
- // block sigops > limit: 1000 CHECKMULTISIG + 1
- tx.vin.resize(1);
- // NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG
- tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP << OP_CHECKMULTISIG << OP_1;
- tx.vin[0].prevout.hash = txFirst[0]->GetHash();
- tx.vin[0].prevout.n = 0;
- tx.vout.resize(1);
- tx.vout[0].nValue = 5000000000LL;
- for (unsigned int i = 0; i < 1001; ++i)
- {
- tx.vout[0].nValue -= 1000000;
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- tx.vin[0].prevout.hash = hash;
- }
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- mempool.clear();
-
- // block size > limit
- tx.vin[0].scriptSig = CScript();
- // 18 * (520char + DROP) + OP_1 = 9433 bytes
- std::vector<unsigned char> vchData(520);
- for (unsigned int i = 0; i < 18; ++i)
- tx.vin[0].scriptSig << vchData << OP_DROP;
- tx.vin[0].scriptSig << OP_1;
- tx.vin[0].prevout.hash = txFirst[0]->GetHash();
- tx.vout[0].nValue = 5000000000LL;
- for (unsigned int i = 0; i < 128; ++i)
- {
- tx.vout[0].nValue -= 10000000;
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- tx.vin[0].prevout.hash = hash;
- }
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- mempool.clear();
-
- // orphan in mempool
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- mempool.clear();
-
- // child with higher priority than parent
- tx.vin[0].scriptSig = CScript() << OP_1;
- tx.vin[0].prevout.hash = txFirst[1]->GetHash();
- tx.vout[0].nValue = 4900000000LL;
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- tx.vin[0].prevout.hash = hash;
- tx.vin.resize(2);
- tx.vin[1].scriptSig = CScript() << OP_1;
- tx.vin[1].prevout.hash = txFirst[0]->GetHash();
- tx.vin[1].prevout.n = 0;
- tx.vout[0].nValue = 5900000000LL;
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- mempool.clear();
-
- // coinbase in mempool
- tx.vin.resize(1);
- tx.vin[0].prevout.SetNull();
- tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
- tx.vout[0].nValue = 0;
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- mempool.clear();
-
- // invalid (pre-p2sh) txn in mempool
- tx.vin[0].prevout.hash = txFirst[0]->GetHash();
- tx.vin[0].prevout.n = 0;
- tx.vin[0].scriptSig = CScript() << OP_1;
- tx.vout[0].nValue = 4900000000LL;
- script = CScript() << OP_0;
- tx.vout[0].scriptPubKey.SetDestination(script.GetID());
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- tx.vin[0].prevout.hash = hash;
- tx.vin[0].scriptSig = CScript() << (std::vector<unsigned char>)script;
- tx.vout[0].nValue -= 1000000;
- hash = tx.GetHash();
- mempool.addUnchecked(hash,tx);
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- mempool.clear();
-
- // double spend txn pair in mempool
- tx.vin[0].prevout.hash = txFirst[0]->GetHash();
- tx.vin[0].scriptSig = CScript() << OP_1;
- tx.vout[0].nValue = 4900000000LL;
- tx.vout[0].scriptPubKey = CScript() << OP_1;
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- tx.vout[0].scriptPubKey = CScript() << OP_2;
- hash = tx.GetHash();
- mempool.addUnchecked(hash, tx);
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- mempool.clear();
-
- // subsidy changing
- int nHeight = pindexBest->nHeight;
- pindexBest->nHeight = 209999;
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- pindexBest->nHeight = 210000;
- BOOST_CHECK(pblock = CreateNewBlock(reservekey));
- delete pblock;
- pindexBest->nHeight = nHeight;
-}
-
-BOOST_AUTO_TEST_CASE(sha256transform_equality)
-{
- unsigned int pSHA256InitState[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
-
-
- // unsigned char pstate[32];
- unsigned char pinput[64];
-
- int i;
-
- for (i = 0; i < 32; i++) {
- pinput[i] = i;
- pinput[i+32] = 0;
- }
-
- uint256 hash;
-
- SHA256Transform(&hash, pinput, pSHA256InitState);
-
- BOOST_TEST_MESSAGE(hash.GetHex());
-
- uint256 hash_reference("0x2df5e1c65ef9f8cde240d23cae2ec036d31a15ec64bc68f64be242b1da6631f3");
-
- BOOST_CHECK(hash == hash_reference);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-using namespace std;
-
-#include "mruset.h"
-#include "util.h"
-
-#define NUM_TESTS 16
-#define MAX_SIZE 100
-
-class mrutester
-{
-private:
- mruset<int> mru;
- std::set<int> set;
-
-public:
- mrutester() { mru.max_size(MAX_SIZE); }
- int size() const { return set.size(); }
-
- void insert(int n)
- {
- mru.insert(n);
- set.insert(n);
- BOOST_CHECK(mru == set);
- }
-};
-
-BOOST_AUTO_TEST_SUITE(mruset_tests)
-
-// Test that an mruset behaves like a set, as long as no more than MAX_SIZE elements are in it
-BOOST_AUTO_TEST_CASE(mruset_like_set)
-{
-
- for (int nTest=0; nTest<NUM_TESTS; nTest++)
- {
- mrutester tester;
- while (tester.size() < MAX_SIZE)
- tester.insert(GetRandInt(2 * MAX_SIZE));
- }
-
-}
-
-// Test that an mruset's size never exceeds its max_size
-BOOST_AUTO_TEST_CASE(mruset_limited_size)
-{
- for (int nTest=0; nTest<NUM_TESTS; nTest++)
- {
- mruset<int> mru(MAX_SIZE);
- for (int nAction=0; nAction<3*MAX_SIZE; nAction++)
- {
- int n = GetRandInt(2 * MAX_SIZE);
- mru.insert(n);
- BOOST_CHECK(mru.size() <= MAX_SIZE);
- }
- }
-}
-
-// 16-bit permutation function
-int static permute(int n)
-{
- // hexadecimals of pi; verified to be linearly independent
- static const int table[16] = {0x243F, 0x6A88, 0x85A3, 0x08D3, 0x1319, 0x8A2E, 0x0370, 0x7344,
- 0xA409, 0x3822, 0x299F, 0x31D0, 0x082E, 0xFA98, 0xEC4E, 0x6C89};
-
- int ret = 0;
- for (int bit=0; bit<16; bit++)
- if (n & (1<<bit))
- ret ^= table[bit];
-
- return ret;
-}
-
-// Test that an mruset acts like a moving window, if no duplicate elements are added
-BOOST_AUTO_TEST_CASE(mruset_window)
-{
- mruset<int> mru(MAX_SIZE);
- for (int n=0; n<10*MAX_SIZE; n++)
- {
- mru.insert(permute(n));
-
- set<int> tester;
- for (int m=max(0,n-MAX_SIZE+1); m<=n; m++)
- tester.insert(permute(m));
-
- BOOST_CHECK(mru == tester);
- }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/assert.hpp>
-#include <boost/assign/list_of.hpp>
-#include <boost/assign/list_inserter.hpp>
-#include <boost/assign/std/vector.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
-#include <boost/tuple/tuple.hpp>
-
-#include <openssl/ec.h>
-#include <openssl/err.h>
-
-#include "keystore.h"
-#include "main.h"
-#include "script.h"
-#include "wallet.h"
-
-using namespace std;
-using namespace boost::assign;
-
-typedef vector<unsigned char> valtype;
-
-extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
-extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn,
- bool fValidatePayToScriptHash, int nHashType);
-
-BOOST_AUTO_TEST_SUITE(multisig_tests)
-
-CScript
-sign_multisig(CScript scriptPubKey, vector<CKey> keys, CTransaction transaction, int whichIn)
-{
- uint256 hash = SignatureHash(scriptPubKey, transaction, whichIn, SIGHASH_ALL);
-
- CScript result;
- result << OP_0; // CHECKMULTISIG bug workaround
- BOOST_FOREACH(CKey key, keys)
- {
- vector<unsigned char> vchSig;
- BOOST_CHECK(key.Sign(hash, vchSig));
- vchSig.push_back((unsigned char)SIGHASH_ALL);
- result << vchSig;
- }
- return result;
-}
-
-BOOST_AUTO_TEST_CASE(multisig_verify)
-{
- CKey key[4];
- for (int i = 0; i < 4; i++)
- key[i].MakeNewKey(true);
-
- CScript a_and_b;
- a_and_b << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
-
- CScript a_or_b;
- a_or_b << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
-
- CScript escrow;
- escrow << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << key[2].GetPubKey() << OP_3 << OP_CHECKMULTISIG;
-
- CTransaction txFrom; // Funding transaction
- txFrom.vout.resize(3);
- txFrom.vout[0].scriptPubKey = a_and_b;
- txFrom.vout[1].scriptPubKey = a_or_b;
- txFrom.vout[2].scriptPubKey = escrow;
-
- CTransaction txTo[3]; // Spending transaction
- for (int i = 0; i < 3; i++)
- {
- txTo[i].vin.resize(1);
- txTo[i].vout.resize(1);
- txTo[i].vin[0].prevout.n = i;
- txTo[i].vin[0].prevout.hash = txFrom.GetHash();
- txTo[i].vout[0].nValue = 1;
- }
-
- vector<CKey> keys;
- CScript s;
-
- // Test a AND b:
- keys.clear();
- keys += key[0],key[1]; // magic operator+= from boost.assign
- s = sign_multisig(a_and_b, keys, txTo[0], 0);
- BOOST_CHECK(VerifyScript(s, a_and_b, txTo[0], 0, true, 0));
-
- for (int i = 0; i < 4; i++)
- {
- keys.clear();
- keys += key[i];
- s = sign_multisig(a_and_b, keys, txTo[0], 0);
- BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, true, 0), strprintf("a&b 1: %d", i));
-
- keys.clear();
- keys += key[1],key[i];
- s = sign_multisig(a_and_b, keys, txTo[0], 0);
- BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, true, 0), strprintf("a&b 2: %d", i));
- }
-
- // Test a OR b:
- for (int i = 0; i < 4; i++)
- {
- keys.clear();
- keys += key[i];
- s = sign_multisig(a_or_b, keys, txTo[1], 0);
- if (i == 0 || i == 1)
- BOOST_CHECK_MESSAGE(VerifyScript(s, a_or_b, txTo[1], 0, true, 0), strprintf("a|b: %d", i));
- else
- BOOST_CHECK_MESSAGE(!VerifyScript(s, a_or_b, txTo[1], 0, true, 0), strprintf("a|b: %d", i));
- }
- s.clear();
- s << OP_0 << OP_0;
- BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, true, 0));
- s.clear();
- s << OP_0 << OP_1;
- BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, true, 0));
-
-
- for (int i = 0; i < 4; i++)
- for (int j = 0; j < 4; j++)
- {
- keys.clear();
- keys += key[i],key[j];
- s = sign_multisig(escrow, keys, txTo[2], 0);
- if (i < j && i < 3 && j < 3)
- BOOST_CHECK_MESSAGE(VerifyScript(s, escrow, txTo[2], 0, true, 0), strprintf("escrow 1: %d %d", i, j));
- else
- BOOST_CHECK_MESSAGE(!VerifyScript(s, escrow, txTo[2], 0, true, 0), strprintf("escrow 2: %d %d", i, j));
- }
-}
-
-BOOST_AUTO_TEST_CASE(multisig_IsStandard)
-{
- CKey key[4];
- for (int i = 0; i < 4; i++)
- key[i].MakeNewKey(true);
-
- CScript a_and_b;
- a_and_b << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
- BOOST_CHECK(::IsStandard(a_and_b));
-
- CScript a_or_b;
- a_or_b << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
- BOOST_CHECK(::IsStandard(a_or_b));
-
- CScript escrow;
- escrow << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << key[2].GetPubKey() << OP_3 << OP_CHECKMULTISIG;
- BOOST_CHECK(::IsStandard(escrow));
-
- CScript one_of_four;
- one_of_four << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << key[2].GetPubKey() << key[3].GetPubKey() << OP_4 << OP_CHECKMULTISIG;
- BOOST_CHECK(!::IsStandard(one_of_four));
-
- CScript malformed[6];
- malformed[0] << OP_3 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
- malformed[1] << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << OP_3 << OP_CHECKMULTISIG;
- malformed[2] << OP_0 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
- malformed[3] << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << OP_0 << OP_CHECKMULTISIG;
- malformed[4] << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << OP_CHECKMULTISIG;
- malformed[5] << OP_1 << key[0].GetPubKey() << key[1].GetPubKey();
-
- for (int i = 0; i < 6; i++)
- BOOST_CHECK(!::IsStandard(malformed[i]));
-}
-
-BOOST_AUTO_TEST_CASE(multisig_Solver1)
-{
- // Tests Solver() that returns lists of keys that are
- // required to satisfy a ScriptPubKey
- //
- // Also tests IsMine() and ExtractAddress()
- //
- // Note: ExtractAddress for the multisignature transactions
- // always returns false for this release, even if you have
- // one key that would satisfy an (a|b) or 2-of-3 keys needed
- // to spend an escrow transaction.
- //
- CBasicKeyStore keystore, emptykeystore, partialkeystore;
- CKey key[3];
- CTxDestination keyaddr[3];
- for (int i = 0; i < 3; i++)
- {
- key[i].MakeNewKey(true);
- keystore.AddKey(key[i]);
- keyaddr[i] = key[i].GetPubKey().GetID();
- }
- partialkeystore.AddKey(key[0]);
-
- {
- vector<valtype> solutions;
- txnouttype whichType;
- CScript s;
- s << key[0].GetPubKey() << OP_CHECKSIG;
- BOOST_CHECK(Solver(s, whichType, solutions));
- BOOST_CHECK(solutions.size() == 1);
- CTxDestination addr;
- BOOST_CHECK(ExtractDestination(s, addr));
- BOOST_CHECK(addr == keyaddr[0]);
- BOOST_CHECK(IsMine(keystore, s));
- BOOST_CHECK(!IsMine(emptykeystore, s));
- }
- {
- vector<valtype> solutions;
- txnouttype whichType;
- CScript s;
- s << OP_DUP << OP_HASH160 << key[0].GetPubKey().GetID() << OP_EQUALVERIFY << OP_CHECKSIG;
- BOOST_CHECK(Solver(s, whichType, solutions));
- BOOST_CHECK(solutions.size() == 1);
- CTxDestination addr;
- BOOST_CHECK(ExtractDestination(s, addr));
- BOOST_CHECK(addr == keyaddr[0]);
- BOOST_CHECK(IsMine(keystore, s));
- BOOST_CHECK(!IsMine(emptykeystore, s));
- }
- {
- vector<valtype> solutions;
- txnouttype whichType;
- CScript s;
- s << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
- BOOST_CHECK(Solver(s, whichType, solutions));
- BOOST_CHECK_EQUAL(solutions.size(), 4);
- CTxDestination addr;
- BOOST_CHECK(!ExtractDestination(s, addr));
- BOOST_CHECK(IsMine(keystore, s));
- BOOST_CHECK(!IsMine(emptykeystore, s));
- BOOST_CHECK(!IsMine(partialkeystore, s));
- }
- {
- vector<valtype> solutions;
- txnouttype whichType;
- CScript s;
- s << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
- BOOST_CHECK(Solver(s, whichType, solutions));
- BOOST_CHECK_EQUAL(solutions.size(), 4);
- vector<CTxDestination> addrs;
- int nRequired;
- BOOST_CHECK(ExtractDestinations(s, whichType, addrs, nRequired));
- BOOST_CHECK(addrs[0] == keyaddr[0]);
- BOOST_CHECK(addrs[1] == keyaddr[1]);
- BOOST_CHECK(nRequired == 1);
- BOOST_CHECK(IsMine(keystore, s));
- BOOST_CHECK(!IsMine(emptykeystore, s));
- BOOST_CHECK(!IsMine(partialkeystore, s));
- }
- {
- vector<valtype> solutions;
- txnouttype whichType;
- CScript s;
- s << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << key[2].GetPubKey() << OP_3 << OP_CHECKMULTISIG;
- BOOST_CHECK(Solver(s, whichType, solutions));
- BOOST_CHECK(solutions.size() == 5);
- }
-}
-
-BOOST_AUTO_TEST_CASE(multisig_Sign)
-{
- // Test SignSignature() (and therefore the version of Solver() that signs transactions)
- CBasicKeyStore keystore;
- CKey key[4];
- for (int i = 0; i < 4; i++)
- {
- key[i].MakeNewKey(true);
- keystore.AddKey(key[i]);
- }
-
- CScript a_and_b;
- a_and_b << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
-
- CScript a_or_b;
- a_or_b << OP_1 << key[0].GetPubKey() << key[1].GetPubKey() << OP_2 << OP_CHECKMULTISIG;
-
- CScript escrow;
- escrow << OP_2 << key[0].GetPubKey() << key[1].GetPubKey() << key[2].GetPubKey() << OP_3 << OP_CHECKMULTISIG;
-
- CTransaction txFrom; // Funding transaction
- txFrom.vout.resize(3);
- txFrom.vout[0].scriptPubKey = a_and_b;
- txFrom.vout[1].scriptPubKey = a_or_b;
- txFrom.vout[2].scriptPubKey = escrow;
-
- CTransaction txTo[3]; // Spending transaction
- for (int i = 0; i < 3; i++)
- {
- txTo[i].vin.resize(1);
- txTo[i].vout.resize(1);
- txTo[i].vin[0].prevout.n = i;
- txTo[i].vin[0].prevout.hash = txFrom.GetHash();
- txTo[i].vout[0].nValue = 1;
- }
-
- for (int i = 0; i < 3; i++)
- {
- BOOST_CHECK_MESSAGE(SignSignature(keystore, txFrom, txTo[i], 0), strprintf("SignSignature %d", i));
- }
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-#include <vector>
-
-#include "netbase.h"
-
-using namespace std;
-
-BOOST_AUTO_TEST_SUITE(netbase_tests)
-
-BOOST_AUTO_TEST_CASE(netbase_networks)
-{
- BOOST_CHECK(CNetAddr("127.0.0.1").GetNetwork() == NET_UNROUTABLE);
- BOOST_CHECK(CNetAddr("::1").GetNetwork() == NET_UNROUTABLE);
- BOOST_CHECK(CNetAddr("8.8.8.8").GetNetwork() == NET_IPV4);
- BOOST_CHECK(CNetAddr("2001::8888").GetNetwork() == NET_IPV6);
- BOOST_CHECK(CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetNetwork() == NET_TOR);
-}
-
-BOOST_AUTO_TEST_CASE(netbase_properties)
-{
- BOOST_CHECK(CNetAddr("127.0.0.1").IsIPv4());
- BOOST_CHECK(CNetAddr("::FFFF:192.168.1.1").IsIPv4());
- BOOST_CHECK(CNetAddr("::1").IsIPv6());
- BOOST_CHECK(CNetAddr("10.0.0.1").IsRFC1918());
- BOOST_CHECK(CNetAddr("192.168.1.1").IsRFC1918());
- BOOST_CHECK(CNetAddr("172.31.255.255").IsRFC1918());
- BOOST_CHECK(CNetAddr("2001:0DB8::").IsRFC3849());
- BOOST_CHECK(CNetAddr("169.254.1.1").IsRFC3927());
- BOOST_CHECK(CNetAddr("2002::1").IsRFC3964());
- BOOST_CHECK(CNetAddr("FC00::").IsRFC4193());
- BOOST_CHECK(CNetAddr("2001::2").IsRFC4380());
- BOOST_CHECK(CNetAddr("2001:10::").IsRFC4843());
- BOOST_CHECK(CNetAddr("FE80::").IsRFC4862());
- BOOST_CHECK(CNetAddr("64:FF9B::").IsRFC6052());
- BOOST_CHECK(CNetAddr("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").IsTor());
- BOOST_CHECK(CNetAddr("127.0.0.1").IsLocal());
- BOOST_CHECK(CNetAddr("::1").IsLocal());
- BOOST_CHECK(CNetAddr("8.8.8.8").IsRoutable());
- BOOST_CHECK(CNetAddr("2001::1").IsRoutable());
- BOOST_CHECK(CNetAddr("127.0.0.1").IsValid());
-}
-
-bool static TestSplitHost(string test, string host, int port)
-{
- string hostOut;
- int portOut = -1;
- SplitHostPort(test, portOut, hostOut);
- return hostOut == host && port == portOut;
-}
-
-BOOST_AUTO_TEST_CASE(netbase_splithost)
-{
- BOOST_CHECK(TestSplitHost("www.bitcoin.org", "www.bitcoin.org", -1));
- BOOST_CHECK(TestSplitHost("[www.bitcoin.org]", "www.bitcoin.org", -1));
- BOOST_CHECK(TestSplitHost("www.bitcoin.org:80", "www.bitcoin.org", 80));
- BOOST_CHECK(TestSplitHost("[www.bitcoin.org]:80", "www.bitcoin.org", 80));
- BOOST_CHECK(TestSplitHost("127.0.0.1", "127.0.0.1", -1));
- BOOST_CHECK(TestSplitHost("127.0.0.1:8333", "127.0.0.1", 8333));
- BOOST_CHECK(TestSplitHost("[127.0.0.1]", "127.0.0.1", -1));
- BOOST_CHECK(TestSplitHost("[127.0.0.1]:8333", "127.0.0.1", 8333));
- BOOST_CHECK(TestSplitHost("::ffff:127.0.0.1", "::ffff:127.0.0.1", -1));
- BOOST_CHECK(TestSplitHost("[::ffff:127.0.0.1]:8333", "::ffff:127.0.0.1", 8333));
- BOOST_CHECK(TestSplitHost("[::]:8333", "::", 8333));
- BOOST_CHECK(TestSplitHost("::8333", "::8333", -1));
- BOOST_CHECK(TestSplitHost(":8333", "", 8333));
- BOOST_CHECK(TestSplitHost("[]:8333", "", 8333));
- BOOST_CHECK(TestSplitHost("", "", -1));
-}
-
-bool static TestParse(string src, string canon)
-{
- CService addr;
- if (!LookupNumeric(src.c_str(), addr, 65535))
- return canon == "";
- return canon == addr.ToString();
-}
-
-BOOST_AUTO_TEST_CASE(netbase_lookupnumeric)
-{
- BOOST_CHECK(TestParse("127.0.0.1", "127.0.0.1:65535"));
- BOOST_CHECK(TestParse("127.0.0.1:8333", "127.0.0.1:8333"));
- BOOST_CHECK(TestParse("::ffff:127.0.0.1", "127.0.0.1:65535"));
- BOOST_CHECK(TestParse("::", "[::]:65535"));
- BOOST_CHECK(TestParse("[::]:8333", "[::]:8333"));
- BOOST_CHECK(TestParse("[127.0.0.1]", "127.0.0.1:65535"));
- BOOST_CHECK(TestParse(":::", ""));
-}
-
-BOOST_AUTO_TEST_CASE(onioncat_test)
-{
- // values from http://www.cypherpunk.at/onioncat/wiki/OnionCat
- CNetAddr addr1("5wyqrzbvrdsumnok.onion");
- CNetAddr addr2("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca");
- BOOST_CHECK(addr1 == addr2);
- BOOST_CHECK(addr1.IsTor());
- BOOST_CHECK(addr1.ToStringIP() == "5wyqrzbvrdsumnok.onion");
- BOOST_CHECK(addr1.IsRoutable());
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
-
-#include "base58.h"
-#include "util.h"
-#include "bitcoinrpc.h"
-
-using namespace std;
-using namespace json_spirit;
-
-BOOST_AUTO_TEST_SUITE(rpc_tests)
-
-static Array
-createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL)
-{
- Array result;
- result.push_back(nRequired);
- Array addresses;
- if (address1) addresses.push_back(address1);
- if (address2) addresses.push_back(address2);
- result.push_back(addresses);
- return result;
-}
-
-BOOST_AUTO_TEST_CASE(rpc_addmultisig)
-{
- rpcfn_type addmultisig = tableRPC["addmultisigaddress"]->actor;
-
- // old, 65-byte-long:
- const char address1Hex[] = "0434e3e09f49ea168c5bbf53f877ff4206923858aab7c7e1df25bc263978107c95e35065a27ef6f1b27222db0ec97e0e895eaca603d3ee0d4c060ce3d8a00286c8";
- // new, compressed:
- const char address2Hex[] = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4";
-
- Value v;
- CBitcoinAddress address;
- BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex), false));
- address.SetString(v.get_str());
- BOOST_CHECK(address.IsValid() && address.IsScript());
-
- BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex, address2Hex), false));
- address.SetString(v.get_str());
- BOOST_CHECK(address.IsValid() && address.IsScript());
-
- BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(2, address1Hex, address2Hex), false));
- address.SetString(v.get_str());
- BOOST_CHECK(address.IsValid() && address.IsScript());
-
- BOOST_CHECK_THROW(addmultisig(createArgs(0), false), runtime_error);
- BOOST_CHECK_THROW(addmultisig(createArgs(1), false), runtime_error);
- BOOST_CHECK_THROW(addmultisig(createArgs(2, address1Hex), false), runtime_error);
-
- BOOST_CHECK_THROW(addmultisig(createArgs(1, ""), false), runtime_error);
- BOOST_CHECK_THROW(addmultisig(createArgs(1, "NotAValidPubkey"), false), runtime_error);
-
- string short1(address1Hex, address1Hex+sizeof(address1Hex)-2); // last byte missing
- BOOST_CHECK_THROW(addmultisig(createArgs(2, short1.c_str()), false), runtime_error);
-
- string short2(address1Hex+1, address1Hex+sizeof(address1Hex)); // first byte missing
- BOOST_CHECK_THROW(addmultisig(createArgs(2, short2.c_str()), false), runtime_error);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/assert.hpp>
-#include <boost/assign/list_of.hpp>
-#include <boost/assign/list_inserter.hpp>
-#include <boost/assign/std/vector.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
-
-#include "../main.h"
-#include "../script.h"
-#include "../wallet.h"
-
-using namespace std;
-
-// Test routines internal to script.cpp:
-extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
-extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn,
- bool fValidatePayToScriptHash, int nHashType);
-
-// Helpers:
-static std::vector<unsigned char>
-Serialize(const CScript& s)
-{
- std::vector<unsigned char> sSerialized(s);
- return sSerialized;
-}
-
-static bool
-Verify(const CScript& scriptSig, const CScript& scriptPubKey, bool fStrict)
-{
- // Create dummy to/from transactions:
- CTransaction txFrom;
- txFrom.vout.resize(1);
- txFrom.vout[0].scriptPubKey = scriptPubKey;
-
- CTransaction txTo;
- txTo.vin.resize(1);
- txTo.vout.resize(1);
- txTo.vin[0].prevout.n = 0;
- txTo.vin[0].prevout.hash = txFrom.GetHash();
- txTo.vin[0].scriptSig = scriptSig;
- txTo.vout[0].nValue = 1;
-
- return VerifyScript(scriptSig, scriptPubKey, txTo, 0, fStrict, 0);
-}
-
-
-BOOST_AUTO_TEST_SUITE(script_P2SH_tests)
-
-BOOST_AUTO_TEST_CASE(sign)
-{
- // Pay-to-script-hash looks like this:
- // scriptSig: <sig> <sig...> <serialized_script>
- // scriptPubKey: HASH160 <hash> EQUAL
-
- // Test SignSignature() (and therefore the version of Solver() that signs transactions)
- CBasicKeyStore keystore;
- CKey key[4];
- for (int i = 0; i < 4; i++)
- {
- key[i].MakeNewKey(true);
- keystore.AddKey(key[i]);
- }
-
- // 8 Scripts: checking all combinations of
- // different keys, straight/P2SH, pubkey/pubkeyhash
- CScript standardScripts[4];
- standardScripts[0] << key[0].GetPubKey() << OP_CHECKSIG;
- standardScripts[1].SetDestination(key[1].GetPubKey().GetID());
- standardScripts[2] << key[1].GetPubKey() << OP_CHECKSIG;
- standardScripts[3].SetDestination(key[2].GetPubKey().GetID());
- CScript evalScripts[4];
- for (int i = 0; i < 4; i++)
- {
- keystore.AddCScript(standardScripts[i]);
- evalScripts[i].SetDestination(standardScripts[i].GetID());
- }
-
- CTransaction txFrom; // Funding transaction:
- txFrom.vout.resize(8);
- for (int i = 0; i < 4; i++)
- {
- txFrom.vout[i].scriptPubKey = evalScripts[i];
- txFrom.vout[i+4].scriptPubKey = standardScripts[i];
- }
- BOOST_CHECK(txFrom.IsStandard());
-
- CTransaction txTo[8]; // Spending transactions
- for (int i = 0; i < 8; i++)
- {
- txTo[i].vin.resize(1);
- txTo[i].vout.resize(1);
- txTo[i].vin[0].prevout.n = i;
- txTo[i].vin[0].prevout.hash = txFrom.GetHash();
- txTo[i].vout[0].nValue = 1;
- BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("IsMine %d", i));
- }
- for (int i = 0; i < 8; i++)
- {
- BOOST_CHECK_MESSAGE(SignSignature(keystore, txFrom, txTo[i], 0), strprintf("SignSignature %d", i));
- }
- // All of the above should be OK, and the txTos have valid signatures
- // Check to make sure signature verification fails if we use the wrong ScriptSig:
- for (int i = 0; i < 8; i++)
- for (int j = 0; j < 8; j++)
- {
- CScript sigSave = txTo[i].vin[0].scriptSig;
- txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig;
- bool sigOK = VerifySignature(txFrom, txTo[i], 0, true, 0);
- if (i == j)
- BOOST_CHECK_MESSAGE(sigOK, strprintf("VerifySignature %d %d", i, j));
- else
- BOOST_CHECK_MESSAGE(!sigOK, strprintf("VerifySignature %d %d", i, j));
- txTo[i].vin[0].scriptSig = sigSave;
- }
-}
-
-BOOST_AUTO_TEST_CASE(norecurse)
-{
- // Make sure only the outer pay-to-script-hash does the
- // extra-validation thing:
- CScript invalidAsScript;
- invalidAsScript << OP_INVALIDOPCODE << OP_INVALIDOPCODE;
-
- CScript p2sh;
- p2sh.SetDestination(invalidAsScript.GetID());
-
- CScript scriptSig;
- scriptSig << Serialize(invalidAsScript);
-
- // Should not verify, because it will try to execute OP_INVALIDOPCODE
- BOOST_CHECK(!Verify(scriptSig, p2sh, true));
-
- // Try to recur, and verification should succeed because
- // the inner HASH160 <> EQUAL should only check the hash:
- CScript p2sh2;
- p2sh2.SetDestination(p2sh.GetID());
- CScript scriptSig2;
- scriptSig2 << Serialize(invalidAsScript) << Serialize(p2sh);
-
- BOOST_CHECK(Verify(scriptSig2, p2sh2, true));
-}
-
-BOOST_AUTO_TEST_CASE(set)
-{
- // Test the CScript::Set* methods
- CBasicKeyStore keystore;
- CKey key[4];
- std::vector<CKey> keys;
- for (int i = 0; i < 4; i++)
- {
- key[i].MakeNewKey(true);
- keystore.AddKey(key[i]);
- keys.push_back(key[i]);
- }
-
- CScript inner[4];
- inner[0].SetDestination(key[0].GetPubKey().GetID());
- inner[1].SetMultisig(2, std::vector<CKey>(keys.begin(), keys.begin()+2));
- inner[2].SetMultisig(1, std::vector<CKey>(keys.begin(), keys.begin()+2));
- inner[3].SetMultisig(2, std::vector<CKey>(keys.begin(), keys.begin()+3));
-
- CScript outer[4];
- for (int i = 0; i < 4; i++)
- {
- outer[i].SetDestination(inner[i].GetID());
- keystore.AddCScript(inner[i]);
- }
-
- CTransaction txFrom; // Funding transaction:
- txFrom.vout.resize(4);
- for (int i = 0; i < 4; i++)
- {
- txFrom.vout[i].scriptPubKey = outer[i];
- }
- BOOST_CHECK(txFrom.IsStandard());
-
- CTransaction txTo[4]; // Spending transactions
- for (int i = 0; i < 4; i++)
- {
- txTo[i].vin.resize(1);
- txTo[i].vout.resize(1);
- txTo[i].vin[0].prevout.n = i;
- txTo[i].vin[0].prevout.hash = txFrom.GetHash();
- txTo[i].vout[0].nValue = 1;
- txTo[i].vout[0].scriptPubKey = inner[i];
- BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("IsMine %d", i));
- }
- for (int i = 0; i < 4; i++)
- {
- BOOST_CHECK_MESSAGE(SignSignature(keystore, txFrom, txTo[i], 0), strprintf("SignSignature %d", i));
- BOOST_CHECK_MESSAGE(txTo[i].IsStandard(), strprintf("txTo[%d].IsStandard", i));
- }
-}
-
-BOOST_AUTO_TEST_CASE(is)
-{
- // Test CScript::IsPayToScriptHash()
- uint160 dummy;
- CScript p2sh;
- p2sh << OP_HASH160 << dummy << OP_EQUAL;
- BOOST_CHECK(p2sh.IsPayToScriptHash());
-
- // Not considered pay-to-script-hash if using one of the OP_PUSHDATA opcodes:
- static const unsigned char direct[] = { OP_HASH160, 20, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, OP_EQUAL };
- BOOST_CHECK(CScript(direct, direct+sizeof(direct)).IsPayToScriptHash());
- static const unsigned char pushdata1[] = { OP_HASH160, OP_PUSHDATA1, 20, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, OP_EQUAL };
- BOOST_CHECK(!CScript(pushdata1, pushdata1+sizeof(pushdata1)).IsPayToScriptHash());
- static const unsigned char pushdata2[] = { OP_HASH160, OP_PUSHDATA2, 20,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, OP_EQUAL };
- BOOST_CHECK(!CScript(pushdata2, pushdata2+sizeof(pushdata2)).IsPayToScriptHash());
- static const unsigned char pushdata4[] = { OP_HASH160, OP_PUSHDATA4, 20,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, OP_EQUAL };
- BOOST_CHECK(!CScript(pushdata4, pushdata4+sizeof(pushdata4)).IsPayToScriptHash());
-
- CScript not_p2sh;
- BOOST_CHECK(!not_p2sh.IsPayToScriptHash());
-
- not_p2sh.clear(); not_p2sh << OP_HASH160 << dummy << dummy << OP_EQUAL;
- BOOST_CHECK(!not_p2sh.IsPayToScriptHash());
-
- not_p2sh.clear(); not_p2sh << OP_NOP << dummy << OP_EQUAL;
- BOOST_CHECK(!not_p2sh.IsPayToScriptHash());
-
- not_p2sh.clear(); not_p2sh << OP_HASH160 << dummy << OP_CHECKSIG;
- BOOST_CHECK(!not_p2sh.IsPayToScriptHash());
-}
-
-BOOST_AUTO_TEST_CASE(switchover)
-{
- // Test switch over code
- CScript notValid;
- notValid << OP_11 << OP_12 << OP_EQUALVERIFY;
- CScript scriptSig;
- scriptSig << Serialize(notValid);
-
- CScript fund;
- fund.SetDestination(notValid.GetID());
-
-
- // Validation should succeed under old rules (hash is correct):
- BOOST_CHECK(Verify(scriptSig, fund, false));
- // Fail under new:
- BOOST_CHECK(!Verify(scriptSig, fund, true));
-}
-
-BOOST_AUTO_TEST_CASE(AreInputsStandard)
-{
- std::map<uint256, std::pair<CTxIndex, CTransaction> > mapInputs;
- CBasicKeyStore keystore;
- CKey key[3];
- vector<CKey> keys;
- for (int i = 0; i < 3; i++)
- {
- key[i].MakeNewKey(true);
- keystore.AddKey(key[i]);
- keys.push_back(key[i]);
- }
-
- CTransaction txFrom;
- txFrom.vout.resize(6);
-
- // First three are standard:
- CScript pay1; pay1.SetDestination(key[0].GetPubKey().GetID());
- keystore.AddCScript(pay1);
- CScript payScriptHash1; payScriptHash1.SetDestination(pay1.GetID());
- CScript pay1of3; pay1of3.SetMultisig(1, keys);
-
- txFrom.vout[0].scriptPubKey = payScriptHash1;
- txFrom.vout[1].scriptPubKey = pay1;
- txFrom.vout[2].scriptPubKey = pay1of3;
-
- // Last three non-standard:
- CScript empty;
- keystore.AddCScript(empty);
- txFrom.vout[3].scriptPubKey = empty;
- // Can't use SetPayToScriptHash, it checks for the empty Script. So:
- txFrom.vout[4].scriptPubKey << OP_HASH160 << Hash160(empty) << OP_EQUAL;
- CScript oneOfEleven;
- oneOfEleven << OP_1;
- for (int i = 0; i < 11; i++)
- oneOfEleven << key[0].GetPubKey();
- oneOfEleven << OP_11 << OP_CHECKMULTISIG;
- txFrom.vout[5].scriptPubKey.SetDestination(oneOfEleven.GetID());
-
- mapInputs[txFrom.GetHash()] = make_pair(CTxIndex(), txFrom);
-
- CTransaction txTo;
- txTo.vout.resize(1);
- txTo.vout[0].scriptPubKey.SetDestination(key[1].GetPubKey().GetID());
-
- txTo.vin.resize(3);
- txTo.vin[0].prevout.n = 0;
- txTo.vin[0].prevout.hash = txFrom.GetHash();
- BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 0));
- txTo.vin[1].prevout.n = 1;
- txTo.vin[1].prevout.hash = txFrom.GetHash();
- BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 1));
- txTo.vin[2].prevout.n = 2;
- txTo.vin[2].prevout.hash = txFrom.GetHash();
- BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 2));
-
- BOOST_CHECK(txTo.AreInputsStandard(mapInputs));
- BOOST_CHECK_EQUAL(txTo.GetP2SHSigOpCount(mapInputs), 1);
-
- // Make sure adding crap to the scriptSigs makes them non-standard:
- for (int i = 0; i < 3; i++)
- {
- CScript t = txTo.vin[i].scriptSig;
- txTo.vin[i].scriptSig = (CScript() << 11) + t;
- BOOST_CHECK(!txTo.AreInputsStandard(mapInputs));
- txTo.vin[i].scriptSig = t;
- }
-
- CTransaction txToNonStd;
- txToNonStd.vout.resize(1);
- txToNonStd.vout[0].scriptPubKey.SetDestination(key[1].GetPubKey().GetID());
- txToNonStd.vin.resize(2);
- txToNonStd.vin[0].prevout.n = 4;
- txToNonStd.vin[0].prevout.hash = txFrom.GetHash();
- txToNonStd.vin[0].scriptSig << Serialize(empty);
- txToNonStd.vin[1].prevout.n = 5;
- txToNonStd.vin[1].prevout.hash = txFrom.GetHash();
- txToNonStd.vin[1].scriptSig << OP_0 << Serialize(oneOfEleven);
-
- BOOST_CHECK(!txToNonStd.AreInputsStandard(mapInputs));
- BOOST_CHECK_EQUAL(txToNonStd.GetP2SHSigOpCount(mapInputs), 11);
-
- txToNonStd.vin[0].scriptSig.clear();
- BOOST_CHECK(!txToNonStd.AreInputsStandard(mapInputs));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/algorithm/string/replace.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/foreach.hpp>
-#include <boost/preprocessor/stringize.hpp>
-#include <boost/test/unit_test.hpp>
-#include "json/json_spirit_reader_template.h"
-#include "json/json_spirit_writer_template.h"
-#include "json/json_spirit_utils.h"
-
-#include "main.h"
-#include "wallet.h"
-
-using namespace std;
-using namespace json_spirit;
-using namespace boost::algorithm;
-
-extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
-extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn,
- bool fValidatePayToScriptHash, int nHashType);
-
-CScript
-ParseScript(string s)
-{
- CScript result;
-
- static map<string, opcodetype> mapOpNames;
-
- if (mapOpNames.size() == 0)
- {
- for (int op = OP_NOP; op <= OP_NOP10; op++)
- {
- const char* name = GetOpName((opcodetype)op);
- if (strcmp(name, "OP_UNKNOWN") == 0)
- continue;
- string strName(name);
- mapOpNames[strName] = (opcodetype)op;
- // Convenience: OP_ADD and just ADD are both recognized:
- replace_first(strName, "OP_", "");
- mapOpNames[strName] = (opcodetype)op;
- }
- }
-
- vector<string> words;
- split(words, s, is_any_of(" \t\n"), token_compress_on);
-
- BOOST_FOREACH(string w, words)
- {
- if (all(w, is_digit()) ||
- (starts_with(w, "-") && all(string(w.begin()+1, w.end()), is_digit())))
- {
- // Number
- int64 n = atoi64(w);
- result << n;
- }
- else if (starts_with(w, "0x") && IsHex(string(w.begin()+2, w.end())))
- {
- // Raw hex data, inserted NOT pushed onto stack:
- std::vector<unsigned char> raw = ParseHex(string(w.begin()+2, w.end()));
- result.insert(result.end(), raw.begin(), raw.end());
- }
- else if (w.size() >= 2 && starts_with(w, "'") && ends_with(w, "'"))
- {
- // Single-quoted string, pushed as data. NOTE: this is poor-man's
- // parsing, spaces/tabs/newlines in single-quoted strings won't work.
- std::vector<unsigned char> value(w.begin()+1, w.end()-1);
- result << value;
- }
- else if (mapOpNames.count(w))
- {
- // opcode, e.g. OP_ADD or OP_1:
- result << mapOpNames[w];
- }
- else
- {
- BOOST_ERROR("Parse error: " << s);
- return CScript();
- }
- }
-
- return result;
-}
-
-Array
-read_json(const std::string& filename)
-{
- namespace fs = boost::filesystem;
- fs::path testFile = fs::current_path() / "test" / "data" / filename;
-
-#ifdef TEST_DATA_DIR
- if (!fs::exists(testFile))
- {
- testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename;
- }
-#endif
-
- ifstream ifs(testFile.string().c_str(), ifstream::in);
- Value v;
- if (!read_stream(ifs, v))
- {
- if (ifs.fail())
- BOOST_ERROR("Cound not find/open " << filename);
- else
- BOOST_ERROR("JSON syntax error in " << filename);
- return Array();
- }
- if (v.type() != array_type)
- {
- BOOST_ERROR(filename << " does not contain a json array");
- return Array();
- }
-
- return v.get_array();
-}
-
-BOOST_AUTO_TEST_SUITE(script_tests)
-
-BOOST_AUTO_TEST_CASE(script_valid)
-{
- // Read tests from test/data/script_valid.json
- // Format is an array of arrays
- // Inner arrays are [ "scriptSig", "scriptPubKey" ]
- // ... where scriptSig and scriptPubKey are stringified
- // scripts.
- Array tests = read_json("script_valid.json");
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
- if (test.size() < 2) // Allow size > 2; extra stuff ignored (useful for comments)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
- string scriptSigString = test[0].get_str();
- CScript scriptSig = ParseScript(scriptSigString);
- string scriptPubKeyString = test[1].get_str();
- CScript scriptPubKey = ParseScript(scriptPubKeyString);
-
- CTransaction tx;
- BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, true, SIGHASH_NONE), strTest);
- }
-}
-
-BOOST_AUTO_TEST_CASE(script_invalid)
-{
- // Scripts that should evaluate as invalid
- Array tests = read_json("script_invalid.json");
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
- if (test.size() < 2) // Allow size > 2; extra stuff ignored (useful for comments)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
- string scriptSigString = test[0].get_str();
- CScript scriptSig = ParseScript(scriptSigString);
- string scriptPubKeyString = test[1].get_str();
- CScript scriptPubKey = ParseScript(scriptPubKeyString);
-
- CTransaction tx;
- BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, true, SIGHASH_NONE), strTest);
- }
-}
-
-BOOST_AUTO_TEST_CASE(script_PushData)
-{
- // Check that PUSHDATA1, PUSHDATA2, and PUSHDATA4 create the same value on
- // the stack as the 1-75 opcodes do.
- static const unsigned char direct[] = { 1, 0x5a };
- static const unsigned char pushdata1[] = { OP_PUSHDATA1, 1, 0x5a };
- static const unsigned char pushdata2[] = { OP_PUSHDATA2, 1, 0, 0x5a };
- static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a };
-
- vector<vector<unsigned char> > directStack;
- BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, 0));
-
- vector<vector<unsigned char> > pushdata1Stack;
- BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, 0));
- BOOST_CHECK(pushdata1Stack == directStack);
-
- vector<vector<unsigned char> > pushdata2Stack;
- BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, 0));
- BOOST_CHECK(pushdata2Stack == directStack);
-
- vector<vector<unsigned char> > pushdata4Stack;
- BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, 0));
- BOOST_CHECK(pushdata4Stack == directStack);
-}
-
-CScript
-sign_multisig(CScript scriptPubKey, std::vector<CKey> keys, CTransaction transaction)
-{
- uint256 hash = SignatureHash(scriptPubKey, transaction, 0, SIGHASH_ALL);
-
- CScript result;
- //
- // NOTE: CHECKMULTISIG has an unfortunate bug; it requires
- // one extra item on the stack, before the signatures.
- // Putting OP_0 on the stack is the workaround;
- // fixing the bug would mean splitting the blockchain (old
- // clients would not accept new CHECKMULTISIG transactions,
- // and vice-versa)
- //
- result << OP_0;
- BOOST_FOREACH(CKey key, keys)
- {
- vector<unsigned char> vchSig;
- BOOST_CHECK(key.Sign(hash, vchSig));
- vchSig.push_back((unsigned char)SIGHASH_ALL);
- result << vchSig;
- }
- return result;
-}
-CScript
-sign_multisig(CScript scriptPubKey, CKey key, CTransaction transaction)
-{
- std::vector<CKey> keys;
- keys.push_back(key);
- return sign_multisig(scriptPubKey, keys, transaction);
-}
-
-BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG12)
-{
- CKey key1, key2, key3;
- key1.MakeNewKey(true);
- key2.MakeNewKey(false);
- key3.MakeNewKey(true);
-
- CScript scriptPubKey12;
- scriptPubKey12 << OP_1 << key1.GetPubKey() << key2.GetPubKey() << OP_2 << OP_CHECKMULTISIG;
-
- CTransaction txFrom12;
- txFrom12.vout.resize(1);
- txFrom12.vout[0].scriptPubKey = scriptPubKey12;
-
- CTransaction txTo12;
- txTo12.vin.resize(1);
- txTo12.vout.resize(1);
- txTo12.vin[0].prevout.n = 0;
- txTo12.vin[0].prevout.hash = txFrom12.GetHash();
- txTo12.vout[0].nValue = 1;
-
- CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12);
- BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, true, 0));
- txTo12.vout[0].nValue = 2;
- BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, true, 0));
-
- CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12);
- BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, true, 0));
-
- CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12);
- BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, true, 0));
-}
-
-BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23)
-{
- CKey key1, key2, key3, key4;
- key1.MakeNewKey(true);
- key2.MakeNewKey(false);
- key3.MakeNewKey(true);
- key4.MakeNewKey(false);
-
- CScript scriptPubKey23;
- scriptPubKey23 << OP_2 << key1.GetPubKey() << key2.GetPubKey() << key3.GetPubKey() << OP_3 << OP_CHECKMULTISIG;
-
- CTransaction txFrom23;
- txFrom23.vout.resize(1);
- txFrom23.vout[0].scriptPubKey = scriptPubKey23;
-
- CTransaction txTo23;
- txTo23.vin.resize(1);
- txTo23.vout.resize(1);
- txTo23.vin[0].prevout.n = 0;
- txTo23.vin[0].prevout.hash = txFrom23.GetHash();
- txTo23.vout[0].nValue = 1;
-
- std::vector<CKey> keys;
- keys.push_back(key1); keys.push_back(key2);
- CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear();
- keys.push_back(key1); keys.push_back(key3);
- CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear();
- keys.push_back(key2); keys.push_back(key3);
- CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear();
- keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
- CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear();
- keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order
- CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear();
- keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order
- CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear();
- keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys
- CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear();
- keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys
- CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, true, 0));
-
- keys.clear(); // Must have signatures
- CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23);
- BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, true, 0));
-}
-
-BOOST_AUTO_TEST_CASE(script_combineSigs)
-{
- // Test the CombineSignatures function
- CBasicKeyStore keystore;
- vector<CKey> keys;
- for (int i = 0; i < 3; i++)
- {
- CKey key;
- key.MakeNewKey(i%2 == 1);
- keys.push_back(key);
- keystore.AddKey(key);
- }
-
- CTransaction txFrom;
- txFrom.vout.resize(1);
- txFrom.vout[0].scriptPubKey.SetDestination(keys[0].GetPubKey().GetID());
- CScript& scriptPubKey = txFrom.vout[0].scriptPubKey;
- CTransaction txTo;
- txTo.vin.resize(1);
- txTo.vout.resize(1);
- txTo.vin[0].prevout.n = 0;
- txTo.vin[0].prevout.hash = txFrom.GetHash();
- CScript& scriptSig = txTo.vin[0].scriptSig;
- txTo.vout[0].nValue = 1;
-
- CScript empty;
- CScript combined = CombineSignatures(scriptPubKey, txTo, 0, empty, empty);
- BOOST_CHECK(combined.empty());
-
- // Single signature case:
- SignSignature(keystore, txFrom, txTo, 0); // changes scriptSig
- combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSig, empty);
- BOOST_CHECK(combined == scriptSig);
- combined = CombineSignatures(scriptPubKey, txTo, 0, empty, scriptSig);
- BOOST_CHECK(combined == scriptSig);
- CScript scriptSigCopy = scriptSig;
- // Signing again will give a different, valid signature:
- SignSignature(keystore, txFrom, txTo, 0);
- combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSigCopy, scriptSig);
- BOOST_CHECK(combined == scriptSigCopy || combined == scriptSig);
-
- // P2SH, single-signature case:
- CScript pkSingle; pkSingle << keys[0].GetPubKey() << OP_CHECKSIG;
- keystore.AddCScript(pkSingle);
- scriptPubKey.SetDestination(pkSingle.GetID());
- SignSignature(keystore, txFrom, txTo, 0);
- combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSig, empty);
- BOOST_CHECK(combined == scriptSig);
- combined = CombineSignatures(scriptPubKey, txTo, 0, empty, scriptSig);
- BOOST_CHECK(combined == scriptSig);
- scriptSigCopy = scriptSig;
- SignSignature(keystore, txFrom, txTo, 0);
- combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSigCopy, scriptSig);
- BOOST_CHECK(combined == scriptSigCopy || combined == scriptSig);
- // dummy scriptSigCopy with placeholder, should always choose non-placeholder:
- scriptSigCopy = CScript() << OP_0 << static_cast<vector<unsigned char> >(pkSingle);
- combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSigCopy, scriptSig);
- BOOST_CHECK(combined == scriptSig);
- combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSig, scriptSigCopy);
- BOOST_CHECK(combined == scriptSig);
-
- // Hardest case: Multisig 2-of-3
- scriptPubKey.SetMultisig(2, keys);
- keystore.AddCScript(scriptPubKey);
- SignSignature(keystore, txFrom, txTo, 0);
- combined = CombineSignatures(scriptPubKey, txTo, 0, scriptSig, empty);
- BOOST_CHECK(combined == scriptSig);
- combined = CombineSignatures(scriptPubKey, txTo, 0, empty, scriptSig);
- BOOST_CHECK(combined == scriptSig);
-
- // A couple of partially-signed versions:
- vector<unsigned char> sig1;
- uint256 hash1 = SignatureHash(scriptPubKey, txTo, 0, SIGHASH_ALL);
- BOOST_CHECK(keys[0].Sign(hash1, sig1));
- sig1.push_back(SIGHASH_ALL);
- vector<unsigned char> sig2;
- uint256 hash2 = SignatureHash(scriptPubKey, txTo, 0, SIGHASH_NONE);
- BOOST_CHECK(keys[1].Sign(hash2, sig2));
- sig2.push_back(SIGHASH_NONE);
- vector<unsigned char> sig3;
- uint256 hash3 = SignatureHash(scriptPubKey, txTo, 0, SIGHASH_SINGLE);
- BOOST_CHECK(keys[2].Sign(hash3, sig3));
- sig3.push_back(SIGHASH_SINGLE);
-
- // Not fussy about order (or even existence) of placeholders or signatures:
- CScript partial1a = CScript() << OP_0 << sig1 << OP_0;
- CScript partial1b = CScript() << OP_0 << OP_0 << sig1;
- CScript partial2a = CScript() << OP_0 << sig2;
- CScript partial2b = CScript() << sig2 << OP_0;
- CScript partial3a = CScript() << sig3;
- CScript partial3b = CScript() << OP_0 << OP_0 << sig3;
- CScript partial3c = CScript() << OP_0 << sig3 << OP_0;
- CScript complete12 = CScript() << OP_0 << sig1 << sig2;
- CScript complete13 = CScript() << OP_0 << sig1 << sig3;
- CScript complete23 = CScript() << OP_0 << sig2 << sig3;
-
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial1a, partial1b);
- BOOST_CHECK(combined == partial1a);
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial1a, partial2a);
- BOOST_CHECK(combined == complete12);
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial2a, partial1a);
- BOOST_CHECK(combined == complete12);
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial1b, partial2b);
- BOOST_CHECK(combined == complete12);
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial3b, partial1b);
- BOOST_CHECK(combined == complete13);
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial2a, partial3a);
- BOOST_CHECK(combined == complete23);
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial3b, partial2b);
- BOOST_CHECK(combined == complete23);
- combined = CombineSignatures(scriptPubKey, txTo, 0, partial3b, partial3a);
- BOOST_CHECK(combined == partial3c);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <vector>
-#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
-
-#include "script.h"
-#include "key.h"
-
-using namespace std;
-
-// Helpers:
-static std::vector<unsigned char>
-Serialize(const CScript& s)
-{
- std::vector<unsigned char> sSerialized(s);
- return sSerialized;
-}
-
-BOOST_AUTO_TEST_SUITE(sigopcount_tests)
-
-BOOST_AUTO_TEST_CASE(GetSigOpCount)
-{
- // Test CScript::GetSigOpCount()
- CScript s1;
- BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 0);
- BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 0);
-
- uint160 dummy;
- s1 << OP_1 << dummy << dummy << OP_2 << OP_CHECKMULTISIG;
- BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 2);
- s1 << OP_IF << OP_CHECKSIG << OP_ENDIF;
- BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 3);
- BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 21);
-
- CScript p2sh;
- p2sh.SetDestination(s1.GetID());
- CScript scriptSig;
- scriptSig << OP_0 << Serialize(s1);
- BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig), 3);
-
- std::vector<CKey> keys;
- for (int i = 0; i < 3; i++)
- {
- CKey k;
- k.MakeNewKey(true);
- keys.push_back(k);
- }
- CScript s2;
- s2.SetMultisig(1, keys);
- BOOST_CHECK_EQUAL(s2.GetSigOpCount(true), 3);
- BOOST_CHECK_EQUAL(s2.GetSigOpCount(false), 20);
-
- p2sh.SetDestination(s2.GetID());
- BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(true), 0);
- BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(false), 0);
- CScript scriptSig2;
- scriptSig2 << OP_1 << dummy << dummy << Serialize(s2);
- BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig2), 3);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#define BOOST_TEST_MODULE Bitcoin Test Suite
-#include <boost/test/unit_test.hpp>
-
-#include "db.h"
-#include "main.h"
-#include "wallet.h"
-
-CWallet* pwalletMain;
-CClientUIInterface uiInterface;
-
-extern bool fPrintToConsole;
-extern void noui_connect();
-
-struct TestingSetup {
- TestingSetup() {
- fPrintToDebugger = true; // don't want to write to debug.log file
- noui_connect();
- bitdb.MakeMock();
- LoadBlockIndex(true);
- bool fFirstRun;
- pwalletMain = new CWallet("wallet.dat");
- pwalletMain->LoadWallet(fFirstRun);
- RegisterWallet(pwalletMain);
- }
- ~TestingSetup()
- {
- delete pwalletMain;
- pwalletMain = NULL;
- bitdb.Flush(true);
- }
-};
-
-BOOST_GLOBAL_FIXTURE(TestingSetup);
-
-void Shutdown(void* parg)
-{
- exit(0);
-}
-
-void StartShutdown()
-{
- exit(0);
-}
-
+++ /dev/null
-#include <map>
-#include <string>
-#include <boost/test/unit_test.hpp>
-#include "json/json_spirit_writer_template.h"
-
-#include "main.h"
-#include "wallet.h"
-
-using namespace std;
-using namespace json_spirit;
-
-// In script_tests.cpp
-extern Array read_json(const std::string& filename);
-extern CScript ParseScript(string s);
-
-BOOST_AUTO_TEST_SUITE(transaction_tests)
-
-BOOST_AUTO_TEST_CASE(tx_valid)
-{
- // Read tests from test/data/tx_valid.json
- // Format is an array of arrays
- // Inner arrays are either [ "comment" ]
- // or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, enforceP2SH
- // ... where all scripts are stringified scripts.
- Array tests = read_json("tx_valid.json");
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
- if (test[0].type() == array_type)
- {
- if (test.size() != 3 || test[1].type() != str_type || test[2].type() != bool_type)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
-
- map<COutPoint, CScript> mapprevOutScriptPubKeys;
- Array inputs = test[0].get_array();
- bool fValid = true;
- BOOST_FOREACH(Value& input, inputs)
- {
- if (input.type() != array_type)
- {
- fValid = false;
- break;
- }
- Array vinput = input.get_array();
- if (vinput.size() != 3)
- {
- fValid = false;
- break;
- }
-
- mapprevOutScriptPubKeys[COutPoint(uint256(vinput[0].get_str()), vinput[1].get_int())] = ParseScript(vinput[2].get_str());
- }
- if (!fValid)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
-
- string transaction = test[1].get_str();
- CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION);
- CTransaction tx;
- stream >> tx;
-
- BOOST_CHECK_MESSAGE(tx.CheckTransaction(), strTest);
-
- for (unsigned int i = 0; i < tx.vin.size(); i++)
- {
- if (!mapprevOutScriptPubKeys.count(tx.vin[i].prevout))
- {
- BOOST_ERROR("Bad test: " << strTest);
- break;
- }
-
- BOOST_CHECK_MESSAGE(VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool(), 0), strTest);
- }
- }
- }
-}
-
-BOOST_AUTO_TEST_CASE(tx_invalid)
-{
- // Read tests from test/data/tx_invalid.json
- // Format is an array of arrays
- // Inner arrays are either [ "comment" ]
- // or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, enforceP2SH
- // ... where all scripts are stringified scripts.
- Array tests = read_json("tx_invalid.json");
-
- BOOST_FOREACH(Value& tv, tests)
- {
- Array test = tv.get_array();
- string strTest = write_string(tv, false);
- if (test[0].type() == array_type)
- {
- if (test.size() != 3 || test[1].type() != str_type || test[2].type() != bool_type)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
-
- map<COutPoint, CScript> mapprevOutScriptPubKeys;
- Array inputs = test[0].get_array();
- bool fValid = true;
- BOOST_FOREACH(Value& input, inputs)
- {
- if (input.type() != array_type)
- {
- fValid = false;
- break;
- }
- Array vinput = input.get_array();
- if (vinput.size() != 3)
- {
- fValid = false;
- break;
- }
-
- mapprevOutScriptPubKeys[COutPoint(uint256(vinput[0].get_str()), vinput[1].get_int())] = ParseScript(vinput[2].get_str());
- }
- if (!fValid)
- {
- BOOST_ERROR("Bad test: " << strTest);
- continue;
- }
-
- string transaction = test[1].get_str();
- CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION);
- CTransaction tx;
- stream >> tx;
-
- fValid = tx.CheckTransaction();
-
- for (unsigned int i = 0; i < tx.vin.size() && fValid; i++)
- {
- if (!mapprevOutScriptPubKeys.count(tx.vin[i].prevout))
- {
- BOOST_ERROR("Bad test: " << strTest);
- break;
- }
-
- fValid = VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool(), 0);
- }
-
- BOOST_CHECK_MESSAGE(!fValid, strTest);
- }
- }
-}
-
-BOOST_AUTO_TEST_CASE(basic_transaction_tests)
-{
- // Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436)
- unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x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x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00};
- vector<unsigned char> vch(ch, ch + sizeof(ch) -1);
- CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
- CTransaction tx;
- stream >> tx;
- BOOST_CHECK_MESSAGE(tx.CheckTransaction(), "Simple deserialized transaction should be valid.");
-
- // Check that duplicate txins fail
- tx.vin.push_back(tx.vin[0]);
- BOOST_CHECK_MESSAGE(!tx.CheckTransaction(), "Transaction with duplicate txins should be invalid.");
-}
-
-//
-// Helper: create two dummy transactions, each with
-// two outputs. The first has 11 and 50 CENT outputs
-// paid to a TX_PUBKEY, the second 21 and 22 CENT outputs
-// paid to a TX_PUBKEYHASH.
-//
-static std::vector<CTransaction>
-SetupDummyInputs(CBasicKeyStore& keystoreRet, MapPrevTx& inputsRet)
-{
- std::vector<CTransaction> dummyTransactions;
- dummyTransactions.resize(2);
-
- // Add some keys to the keystore:
- CKey key[4];
- for (int i = 0; i < 4; i++)
- {
- key[i].MakeNewKey(i % 2);
- keystoreRet.AddKey(key[i]);
- }
-
- // Create some dummy input transactions
- dummyTransactions[0].vout.resize(2);
- dummyTransactions[0].vout[0].nValue = 11*CENT;
- dummyTransactions[0].vout[0].scriptPubKey << key[0].GetPubKey() << OP_CHECKSIG;
- dummyTransactions[0].vout[1].nValue = 50*CENT;
- dummyTransactions[0].vout[1].scriptPubKey << key[1].GetPubKey() << OP_CHECKSIG;
- inputsRet[dummyTransactions[0].GetHash()] = make_pair(CTxIndex(), dummyTransactions[0]);
-
- dummyTransactions[1].vout.resize(2);
- dummyTransactions[1].vout[0].nValue = 21*CENT;
- dummyTransactions[1].vout[0].scriptPubKey.SetDestination(key[2].GetPubKey().GetID());
- dummyTransactions[1].vout[1].nValue = 22*CENT;
- dummyTransactions[1].vout[1].scriptPubKey.SetDestination(key[3].GetPubKey().GetID());
- inputsRet[dummyTransactions[1].GetHash()] = make_pair(CTxIndex(), dummyTransactions[1]);
-
- return dummyTransactions;
-}
-
-BOOST_AUTO_TEST_CASE(test_Get)
-{
- CBasicKeyStore keystore;
- MapPrevTx dummyInputs;
- std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, dummyInputs);
-
- CTransaction t1;
- t1.vin.resize(3);
- t1.vin[0].prevout.hash = dummyTransactions[0].GetHash();
- t1.vin[0].prevout.n = 1;
- t1.vin[0].scriptSig << std::vector<unsigned char>(65, 0);
- t1.vin[1].prevout.hash = dummyTransactions[1].GetHash();
- t1.vin[1].prevout.n = 0;
- t1.vin[1].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
- t1.vin[2].prevout.hash = dummyTransactions[1].GetHash();
- t1.vin[2].prevout.n = 1;
- t1.vin[2].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
- t1.vout.resize(2);
- t1.vout[0].nValue = 90*CENT;
- t1.vout[0].scriptPubKey << OP_1;
-
- BOOST_CHECK(t1.AreInputsStandard(dummyInputs));
- BOOST_CHECK_EQUAL(t1.GetValueIn(dummyInputs), (50+21+22)*CENT);
-
- // Adding extra junk to the scriptSig should make it non-standard:
- t1.vin[0].scriptSig << OP_11;
- BOOST_CHECK(!t1.AreInputsStandard(dummyInputs));
-
- // ... as should not having enough:
- t1.vin[0].scriptSig = CScript();
- BOOST_CHECK(!t1.AreInputsStandard(dummyInputs));
-}
-
-BOOST_AUTO_TEST_CASE(test_GetThrow)
-{
- CBasicKeyStore keystore;
- MapPrevTx dummyInputs;
- std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, dummyInputs);
-
- MapPrevTx missingInputs;
-
- CTransaction t1;
- t1.vin.resize(3);
- t1.vin[0].prevout.hash = dummyTransactions[0].GetHash();
- t1.vin[0].prevout.n = 0;
- t1.vin[1].prevout.hash = dummyTransactions[1].GetHash();;
- t1.vin[1].prevout.n = 0;
- t1.vin[2].prevout.hash = dummyTransactions[1].GetHash();;
- t1.vin[2].prevout.n = 1;
- t1.vout.resize(2);
- t1.vout[0].nValue = 90*CENT;
- t1.vout[0].scriptPubKey << OP_1;
-
- BOOST_CHECK_THROW(t1.AreInputsStandard(missingInputs), runtime_error);
- BOOST_CHECK_THROW(t1.GetValueIn(missingInputs), runtime_error);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include "uint256.h"
-
-BOOST_AUTO_TEST_SUITE(uint160_tests)
-
-BOOST_AUTO_TEST_CASE(uint160_equality)
-{
- uint160 num1 = 10;
- uint160 num2 = 11;
- BOOST_CHECK(num1+1 == num2);
-
- uint64 num3 = 10;
- BOOST_CHECK(num1 == num3);
- BOOST_CHECK(num1+num2 == num3+num2);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include "uint256.h"
-
-BOOST_AUTO_TEST_SUITE(uint256_tests)
-
-BOOST_AUTO_TEST_CASE(uint256_equality)
-{
- uint256 num1 = 10;
- uint256 num2 = 11;
- BOOST_CHECK(num1+1 == num2);
-
- uint64 num3 = 10;
- BOOST_CHECK(num1 == num3);
- BOOST_CHECK(num1+num2 == num3+num2);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <vector>
-#include <boost/test/unit_test.hpp>
-#include <boost/foreach.hpp>
-
-#include "main.h"
-#include "wallet.h"
-#include "util.h"
-
-using namespace std;
-
-BOOST_AUTO_TEST_SUITE(util_tests)
-
-BOOST_AUTO_TEST_CASE(util_criticalsection)
-{
- CCriticalSection cs;
-
- do {
- LOCK(cs);
- break;
-
- BOOST_ERROR("break was swallowed!");
- } while(0);
-
- do {
- TRY_LOCK(cs, lockTest);
- if (lockTest)
- break;
-
- BOOST_ERROR("break was swallowed!");
- } while(0);
-}
-
-BOOST_AUTO_TEST_CASE(util_MedianFilter)
-{
- CMedianFilter<int> filter(5, 15);
-
- BOOST_CHECK_EQUAL(filter.median(), 15);
-
- filter.input(20); // [15 20]
- BOOST_CHECK_EQUAL(filter.median(), 17);
-
- filter.input(30); // [15 20 30]
- BOOST_CHECK_EQUAL(filter.median(), 20);
-
- filter.input(3); // [3 15 20 30]
- BOOST_CHECK_EQUAL(filter.median(), 17);
-
- filter.input(7); // [3 7 15 20 30]
- BOOST_CHECK_EQUAL(filter.median(), 15);
-
- filter.input(18); // [3 7 18 20 30]
- BOOST_CHECK_EQUAL(filter.median(), 18);
-
- filter.input(0); // [0 3 7 18 30]
- BOOST_CHECK_EQUAL(filter.median(), 7);
-}
-
-static const unsigned char ParseHex_expected[65] = {
- 0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7,
- 0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde,
- 0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12,
- 0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d,
- 0x5f
-};
-BOOST_AUTO_TEST_CASE(util_ParseHex)
-{
- std::vector<unsigned char> result;
- std::vector<unsigned char> expected(ParseHex_expected, ParseHex_expected + sizeof(ParseHex_expected));
- // Basic test vector
- result = ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f");
- BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end());
-
- // Spaces between bytes must be supported
- result = ParseHex("12 34 56 78");
- BOOST_CHECK(result.size() == 4 && result[0] == 0x12 && result[1] == 0x34 && result[2] == 0x56 && result[3] == 0x78);
-
- // Stop parsing at invalid value
- result = ParseHex("1234 invalid 1234");
- BOOST_CHECK(result.size() == 2 && result[0] == 0x12 && result[1] == 0x34);
-}
-
-BOOST_AUTO_TEST_CASE(util_HexStr)
-{
- BOOST_CHECK_EQUAL(
- HexStr(ParseHex_expected, ParseHex_expected + sizeof(ParseHex_expected)),
- "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f");
-
- BOOST_CHECK_EQUAL(
- HexStr(ParseHex_expected, ParseHex_expected + 5, true),
- "04 67 8a fd b0");
-
- BOOST_CHECK_EQUAL(
- HexStr(ParseHex_expected, ParseHex_expected, true),
- "");
-
- std::vector<unsigned char> ParseHex_vec(ParseHex_expected, ParseHex_expected + 5);
-
- BOOST_CHECK_EQUAL(
- HexStr(ParseHex_vec, true),
- "04 67 8a fd b0");
-}
-
-
-BOOST_AUTO_TEST_CASE(util_DateTimeStrFormat)
-{
-/*These are platform-dependant and thus removed to avoid useless test failures
- BOOST_CHECK_EQUAL(DateTimeStrFormat("%x %H:%M:%S", 0), "01/01/70 00:00:00");
- BOOST_CHECK_EQUAL(DateTimeStrFormat("%x %H:%M:%S", 0x7FFFFFFF), "01/19/38 03:14:07");
- // Formats used within Bitcoin
- BOOST_CHECK_EQUAL(DateTimeStrFormat("%x %H:%M:%S", 1317425777), "09/30/11 23:36:17");
- BOOST_CHECK_EQUAL(DateTimeStrFormat("%x %H:%M", 1317425777), "09/30/11 23:36");
-*/
-}
-
-BOOST_AUTO_TEST_CASE(util_ParseParameters)
-{
- const char *argv_test[] = {"-ignored", "-a", "-b", "-ccc=argument", "-ccc=multiple", "f", "-d=e"};
-
- ParseParameters(0, (char**)argv_test);
- BOOST_CHECK(mapArgs.empty() && mapMultiArgs.empty());
-
- ParseParameters(1, (char**)argv_test);
- BOOST_CHECK(mapArgs.empty() && mapMultiArgs.empty());
-
- ParseParameters(5, (char**)argv_test);
- // expectation: -ignored is ignored (program name argument),
- // -a, -b and -ccc end up in map, -d ignored because it is after
- // a non-option argument (non-GNU option parsing)
- BOOST_CHECK(mapArgs.size() == 3 && mapMultiArgs.size() == 3);
- BOOST_CHECK(mapArgs.count("-a") && mapArgs.count("-b") && mapArgs.count("-ccc")
- && !mapArgs.count("f") && !mapArgs.count("-d"));
- BOOST_CHECK(mapMultiArgs.count("-a") && mapMultiArgs.count("-b") && mapMultiArgs.count("-ccc")
- && !mapMultiArgs.count("f") && !mapMultiArgs.count("-d"));
-
- BOOST_CHECK(mapArgs["-a"] == "" && mapArgs["-ccc"] == "multiple");
- BOOST_CHECK(mapMultiArgs["-ccc"].size() == 2);
-}
-
-BOOST_AUTO_TEST_CASE(util_GetArg)
-{
- mapArgs.clear();
- mapArgs["strtest1"] = "string...";
- // strtest2 undefined on purpose
- mapArgs["inttest1"] = "12345";
- mapArgs["inttest2"] = "81985529216486895";
- // inttest3 undefined on purpose
- mapArgs["booltest1"] = "";
- // booltest2 undefined on purpose
- mapArgs["booltest3"] = "0";
- mapArgs["booltest4"] = "1";
-
- BOOST_CHECK_EQUAL(GetArg("strtest1", "default"), "string...");
- BOOST_CHECK_EQUAL(GetArg("strtest2", "default"), "default");
- BOOST_CHECK_EQUAL(GetArg("inttest1", -1), 12345);
- BOOST_CHECK_EQUAL(GetArg("inttest2", -1), 81985529216486895LL);
- BOOST_CHECK_EQUAL(GetArg("inttest3", -1), -1);
- BOOST_CHECK_EQUAL(GetBoolArg("booltest1"), true);
- BOOST_CHECK_EQUAL(GetBoolArg("booltest2"), false);
- BOOST_CHECK_EQUAL(GetBoolArg("booltest3"), false);
- BOOST_CHECK_EQUAL(GetBoolArg("booltest4"), true);
-}
-
-BOOST_AUTO_TEST_CASE(util_WildcardMatch)
-{
- BOOST_CHECK(WildcardMatch("127.0.0.1", "*"));
- BOOST_CHECK(WildcardMatch("127.0.0.1", "127.*"));
- BOOST_CHECK(WildcardMatch("abcdef", "a?cde?"));
- BOOST_CHECK(!WildcardMatch("abcdef", "a?cde??"));
- BOOST_CHECK(WildcardMatch("abcdef", "a*f"));
- BOOST_CHECK(!WildcardMatch("abcdef", "a*x"));
- BOOST_CHECK(WildcardMatch("", "*"));
-}
-
-BOOST_AUTO_TEST_CASE(util_FormatMoney)
-{
- BOOST_CHECK_EQUAL(FormatMoney(0, false), "0.00");
- BOOST_CHECK_EQUAL(FormatMoney((COIN/10000)*123456789, false), "12345.6789");
- BOOST_CHECK_EQUAL(FormatMoney(COIN, true), "+1.00");
- BOOST_CHECK_EQUAL(FormatMoney(-COIN, false), "-1.00");
- BOOST_CHECK_EQUAL(FormatMoney(-COIN, true), "-1.00");
-
- BOOST_CHECK_EQUAL(FormatMoney(COIN*100000000, false), "100000000.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN*10000000, false), "10000000.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN*1000000, false), "1000000.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN*100000, false), "100000.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN*10000, false), "10000.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN*1000, false), "1000.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN*100, false), "100.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN*10, false), "10.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN, false), "1.00");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/10, false), "0.10");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/100, false), "0.01");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/1000, false), "0.001");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/10000, false), "0.0001");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/100000, false), "0.00001");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/1000000, false), "0.000001");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/10000000, false), "0.0000001");
- BOOST_CHECK_EQUAL(FormatMoney(COIN/100000000, false), "0.00000001");
-}
-
-BOOST_AUTO_TEST_CASE(util_ParseMoney)
-{
- int64 ret = 0;
- BOOST_CHECK(ParseMoney("0.0", ret));
- BOOST_CHECK_EQUAL(ret, 0);
-
- BOOST_CHECK(ParseMoney("12345.6789", ret));
- BOOST_CHECK_EQUAL(ret, (COIN/10000)*123456789);
-
- BOOST_CHECK(ParseMoney("100000000.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*100000000);
- BOOST_CHECK(ParseMoney("10000000.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*10000000);
- BOOST_CHECK(ParseMoney("1000000.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*1000000);
- BOOST_CHECK(ParseMoney("100000.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*100000);
- BOOST_CHECK(ParseMoney("10000.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*10000);
- BOOST_CHECK(ParseMoney("1000.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*1000);
- BOOST_CHECK(ParseMoney("100.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*100);
- BOOST_CHECK(ParseMoney("10.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN*10);
- BOOST_CHECK(ParseMoney("1.00", ret));
- BOOST_CHECK_EQUAL(ret, COIN);
- BOOST_CHECK(ParseMoney("0.1", ret));
- BOOST_CHECK_EQUAL(ret, COIN/10);
- BOOST_CHECK(ParseMoney("0.01", ret));
- BOOST_CHECK_EQUAL(ret, COIN/100);
- BOOST_CHECK(ParseMoney("0.001", ret));
- BOOST_CHECK_EQUAL(ret, COIN/1000);
- BOOST_CHECK(ParseMoney("0.0001", ret));
- BOOST_CHECK_EQUAL(ret, COIN/10000);
- BOOST_CHECK(ParseMoney("0.00001", ret));
- BOOST_CHECK_EQUAL(ret, COIN/100000);
- BOOST_CHECK(ParseMoney("0.000001", ret));
- BOOST_CHECK_EQUAL(ret, COIN/1000000);
- BOOST_CHECK(ParseMoney("0.0000001", ret));
- BOOST_CHECK_EQUAL(ret, COIN/10000000);
- BOOST_CHECK(ParseMoney("0.00000001", ret));
- BOOST_CHECK_EQUAL(ret, COIN/100000000);
-
- // Attempted 63 bit overflow should fail
- BOOST_CHECK(!ParseMoney("92233720368.54775808", ret));
-}
-
-BOOST_AUTO_TEST_CASE(util_IsHex)
-{
- BOOST_CHECK(IsHex("00"));
- BOOST_CHECK(IsHex("00112233445566778899aabbccddeeffAABBCCDDEEFF"));
- BOOST_CHECK(IsHex("ff"));
- BOOST_CHECK(IsHex("FF"));
-
- BOOST_CHECK(!IsHex(""));
- BOOST_CHECK(!IsHex("0"));
- BOOST_CHECK(!IsHex("a"));
- BOOST_CHECK(!IsHex("eleven"));
- BOOST_CHECK(!IsHex("00xx00"));
- BOOST_CHECK(!IsHex("0x0000"));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
+++ /dev/null
-#include <boost/test/unit_test.hpp>
-
-#include "main.h"
-#include "wallet.h"
-
-// how many times to run all the tests to have a chance to catch errors that only show up with particular random shuffles
-#define RUN_TESTS 100
-
-// some tests fail 1% of the time due to bad luck.
-// we repeat those tests this many times and only complain if all iterations of the test fail
-#define RANDOM_REPEATS 5
-
-using namespace std;
-
-typedef set<pair<const CWalletTx*,unsigned int> > CoinSet;
-
-BOOST_AUTO_TEST_SUITE(wallet_tests)
-
-static CWallet wallet;
-static vector<COutput> vCoins;
-
-static void add_coin(int64 nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0)
-{
- static int i;
- CTransaction* tx = new CTransaction;
- tx->nLockTime = i++; // so all transactions get different hashes
- tx->vout.resize(nInput+1);
- tx->vout[nInput].nValue = nValue;
- CWalletTx* wtx = new CWalletTx(&wallet, *tx);
- delete tx;
- if (fIsFromMe)
- {
- // IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if vin.empty(),
- // so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe()
- wtx->vin.resize(1);
- wtx->fDebitCached = true;
- wtx->nDebitCached = 1;
- }
- COutput output(wtx, nInput, nAge);
- vCoins.push_back(output);
-}
-
-static void empty_wallet(void)
-{
- BOOST_FOREACH(COutput output, vCoins)
- delete output.tx;
- vCoins.clear();
-}
-
-static bool equal_sets(CoinSet a, CoinSet b)
-{
- pair<CoinSet::iterator, CoinSet::iterator> ret = mismatch(a.begin(), a.end(), b.begin());
- return ret.first == a.end() && ret.second == b.end();
-}
-
-BOOST_AUTO_TEST_CASE(coin_selection_tests)
-{
- static CoinSet setCoinsRet, setCoinsRet2;
- static int64 nValueRet;
-
- // test multiple times to allow for differences in the shuffle order
- for (int i = 0; i < RUN_TESTS; i++)
- {
- empty_wallet();
-
- // with an empty wallet we can't even pay one cent
- BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
-
- add_coin(1*CENT, 4); // add a new 1 cent coin
-
- // with a new 1 cent coin, we still can't find a mature 1 cent
- BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
-
- // but we can find a new 1 cent
- BOOST_CHECK( wallet.SelectCoinsMinConf( 1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1 * CENT);
-
- add_coin(2*CENT); // add a mature 2 cent coin
-
- // we can't make 3 cents of mature coins
- BOOST_CHECK(!wallet.SelectCoinsMinConf( 3 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
-
- // we can make 3 cents of new coins
- BOOST_CHECK( wallet.SelectCoinsMinConf( 3 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 3 * CENT);
-
- add_coin(5*CENT); // add a mature 5 cent coin,
- add_coin(10*CENT, 3, true); // a new 10 cent coin sent from one of our own addresses
- add_coin(20*CENT); // and a mature 20 cent coin
-
- // now we have new: 1+10=11 (of which 10 was self-sent), and mature: 2+5+20=27. total = 38
-
- // we can't make 38 cents only if we disallow new coins:
- BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
- // we can't even make 37 cents if we don't allow new coins even if they're from us
- BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 6, 6, vCoins, setCoinsRet, nValueRet));
- // but we can make 37 cents if we accept new coins from ourself
- BOOST_CHECK( wallet.SelectCoinsMinConf(37 * CENT, 1, 6, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 37 * CENT);
- // and we can make 38 cents if we accept all new coins
- BOOST_CHECK( wallet.SelectCoinsMinConf(38 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 38 * CENT);
-
- // try making 34 cents from 1,2,5,10,20 - we can't do it exactly
- BOOST_CHECK( wallet.SelectCoinsMinConf(34 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_GT(nValueRet, 34 * CENT); // but should get more than 34 cents
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 3); // the best should be 20+10+5. it's incredibly unlikely the 1 or 2 got included (but possible)
-
- // when we try making 7 cents, the smaller coins (1,2,5) are enough. We should see just 2+5
- BOOST_CHECK( wallet.SelectCoinsMinConf( 7 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 7 * CENT);
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 2);
-
- // when we try making 8 cents, the smaller coins (1,2,5) are exactly enough.
- BOOST_CHECK( wallet.SelectCoinsMinConf( 8 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK(nValueRet == 8 * CENT);
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 3);
-
- // when we try making 9 cents, no subset of smaller coins is enough, and we get the next bigger coin (10)
- BOOST_CHECK( wallet.SelectCoinsMinConf( 9 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 10 * CENT);
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 1);
-
- // now clear out the wallet and start again to test choosing between subsets of smaller coins and the next biggest coin
- empty_wallet();
-
- add_coin( 6*CENT);
- add_coin( 7*CENT);
- add_coin( 8*CENT);
- add_coin(20*CENT);
- add_coin(30*CENT); // now we have 6+7+8+20+30 = 71 cents total
-
- // check that we have 71 and not 72
- BOOST_CHECK( wallet.SelectCoinsMinConf(71 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK(!wallet.SelectCoinsMinConf(72 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
-
- // now try making 16 cents. the best smaller coins can do is 6+7+8 = 21; not as good at the next biggest coin, 20
- BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 20 * CENT); // we should get 20 in one coin
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 1);
-
- add_coin( 5*CENT); // now we have 5+6+7+8+20+30 = 75 cents total
-
- // now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, better than the next biggest coin, 20
- BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 3 coins
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 3);
-
- add_coin( 18*CENT); // now we have 5+6+7+8+18+20+30
-
- // and now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, the same as the next biggest coin, 18
- BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 1 coin
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 1); // because in the event of a tie, the biggest coin wins
-
- // now try making 11 cents. we should get 5+6
- BOOST_CHECK( wallet.SelectCoinsMinConf(11 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 11 * CENT);
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 2);
-
- // check that the smallest bigger coin is used
- add_coin( 1*COIN);
- add_coin( 2*COIN);
- add_coin( 3*COIN);
- add_coin( 4*COIN); // now we have 5+6+7+8+18+20+30+100+200+300+400 = 1094 cents
- BOOST_CHECK( wallet.SelectCoinsMinConf(95 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1 * COIN); // we should get 1 BTC in 1 coin
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 1);
-
- BOOST_CHECK( wallet.SelectCoinsMinConf(195 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 2 * COIN); // we should get 2 BTC in 1 coin
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 1);
-
- // empty the wallet and start again, now with fractions of a cent, to test sub-cent change avoidance
- empty_wallet();
- add_coin(0.1*CENT);
- add_coin(0.2*CENT);
- add_coin(0.3*CENT);
- add_coin(0.4*CENT);
- add_coin(0.5*CENT);
-
- // try making 1 cent from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 = 1.5 cents
- // we'll get sub-cent change whatever happens, so can expect 1.0 exactly
- BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1 * CENT);
-
- // but if we add a bigger coin, making it possible to avoid sub-cent change, things change:
- add_coin(1111*CENT);
-
- // try making 1 cent from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 + 1111 = 1112.5 cents
- BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount
-
- // if we add more sub-cent coins:
- add_coin(0.6*CENT);
- add_coin(0.7*CENT);
-
- // and try again to make 1.0 cents, we can still make 1.0 cents
- BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount
-
- // run the 'mtgox' test (see http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf)
- // they tried to consolidate 10 50k coins into one 500k coin, and ended up with 50k in change
- empty_wallet();
- for (int i = 0; i < 20; i++)
- add_coin(50000 * COIN);
-
- BOOST_CHECK( wallet.SelectCoinsMinConf(500000 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 500000 * COIN); // we should get the exact amount
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 10); // in ten coins
-
- // if there's not enough in the smaller coins to make at least 1 cent change (0.5+0.6+0.7 < 1.0+1.0),
- // we need to try finding an exact subset anyway
-
- // sometimes it will fail, and so we use the next biggest coin:
- empty_wallet();
- add_coin(0.5 * CENT);
- add_coin(0.6 * CENT);
- add_coin(0.7 * CENT);
- add_coin(1111 * CENT);
- BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1111 * CENT); // we get the bigger coin
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 1);
-
- // but sometimes it's possible, and we use an exact subset (0.4 + 0.6 = 1.0)
- empty_wallet();
- add_coin(0.4 * CENT);
- add_coin(0.6 * CENT);
- add_coin(0.8 * CENT);
- add_coin(1111 * CENT);
- BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 2); // in two coins 0.4+0.6
-
- // test avoiding sub-cent change
- empty_wallet();
- add_coin(0.0005 * COIN);
- add_coin(0.01 * COIN);
- add_coin(1 * COIN);
-
- // trying to make 1.0001 from these three coins
- BOOST_CHECK( wallet.SelectCoinsMinConf(1.0001 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1.0105 * COIN); // we should get all coins
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 3);
-
- // but if we try to make 0.999, we should take the bigger of the two small coins to avoid sub-cent change
- BOOST_CHECK( wallet.SelectCoinsMinConf(0.999 * COIN, 1, 1, vCoins, setCoinsRet, nValueRet));
- BOOST_CHECK_EQUAL(nValueRet, 1.01 * COIN); // we should get 1 + 0.01
- BOOST_CHECK_EQUAL(setCoinsRet.size(), 2);
-
- // test randomness
- {
- empty_wallet();
- for (int i2 = 0; i2 < 100; i2++)
- add_coin(COIN);
-
- // picking 50 from 100 coins doesn't depend on the shuffle,
- // but does depend on randomness in the stochastic approximation code
- BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet , nValueRet));
- BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, vCoins, setCoinsRet2, nValueRet));
- BOOST_CHECK(!equal_sets(setCoinsRet, setCoinsRet2));
-
- int fails = 0;
- for (int i = 0; i < RANDOM_REPEATS; i++)
- {
- // selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
- // run the test RANDOM_REPEATS times and only complain if all of them fail
- BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet , nValueRet));
- BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, vCoins, setCoinsRet2, nValueRet));
- if (equal_sets(setCoinsRet, setCoinsRet2))
- fails++;
- }
- BOOST_CHECK_NE(fails, RANDOM_REPEATS);
-
- // add 75 cents in small change. not enough to make 90 cents,
- // then try making 90 cents. there are multiple competing "smallest bigger" coins,
- // one of which should be picked at random
- add_coin( 5*CENT); add_coin(10*CENT); add_coin(15*CENT); add_coin(20*CENT); add_coin(25*CENT);
-
- fails = 0;
- for (int i = 0; i < RANDOM_REPEATS; i++)
- {
- // selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
- // run the test RANDOM_REPEATS times and only complain if all of them fail
- BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet , nValueRet));
- BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, vCoins, setCoinsRet2, nValueRet));
- if (equal_sets(setCoinsRet, setCoinsRet2))
- fails++;
- }
- BOOST_CHECK_NE(fails, RANDOM_REPEATS);
- }
- }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
// ppcoin: calculate stake modifier checksum
pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex);
if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum))
- return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016" PRI64x, pindex->nHeight, pindex->nStakeModifier);
+ return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016" PRIx64, pindex->nHeight, pindex->nStakeModifier);
}
// Load hashBestChain pointer to end of best chain
// NovaCoin: calculate stake modifier checksum
pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex);
if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum))
- return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016" PRI64x, pindex->nHeight, pindex->nStakeModifier);
+ return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016" PRIx64, pindex->nHeight, pindex->nStakeModifier);
}
// Load hashBestChain pointer to end of best chain
#define BITCOIN_UI_INTERFACE_H
#include <string>
-#include "util.h" // for int64
#include <boost/signals2/signal.hpp>
#include <boost/signals2/last_value.hpp>
+#include "util.h"
+
class CBasicKeyStore;
class CWallet;
class uint256;
boost::signals2::signal<void (const std::string& message, const std::string& caption, int style)> ThreadSafeMessageBox;
/** Ask the user whether they want to pay a fee or not. */
- boost::signals2::signal<bool (int64 nFeeRequired, const std::string& strCaption), boost::signals2::last_value<bool> > ThreadSafeAskFee;
+ boost::signals2::signal<bool (int64_t nFeeRequired, const std::string& strCaption), boost::signals2::last_value<bool> > ThreadSafeAskFee;
/** Handle a URL passed at the command line. */
boost::signals2::signal<void (const std::string& strURI)> ThreadSafeHandleURI;
#include <string.h>
#include <string>
#include <vector>
-
-typedef long long int64;
-typedef unsigned long long uint64;
-
+#include <stdint.h>
inline int Testuint256AdHoc(std::vector<std::string> vArg);
return ret;
}
- base_uint& operator=(uint64 b)
+ base_uint& operator=(uint64_t b)
{
pn[0] = (unsigned int)b;
pn[1] = (unsigned int)(b >> 32);
return *this;
}
- base_uint& operator^=(uint64 b)
+ base_uint& operator^=(uint64_t b)
{
pn[0] ^= (unsigned int)b;
pn[1] ^= (unsigned int)(b >> 32);
return *this;
}
- base_uint& operator|=(uint64 b)
+ base_uint& operator|=(uint64_t b)
{
pn[0] |= (unsigned int)b;
pn[1] |= (unsigned int)(b >> 32);
base_uint& operator+=(const base_uint& b)
{
- uint64 carry = 0;
+ uint64_t carry = 0;
for (int i = 0; i < WIDTH; i++)
{
- uint64 n = carry + pn[i] + b.pn[i];
+ uint64_t n = carry + pn[i] + b.pn[i];
pn[i] = n & 0xffffffff;
carry = n >> 32;
}
return *this;
}
- base_uint& operator+=(uint64 b64)
+ base_uint& operator+=(uint64_t b64)
{
base_uint b;
b = b64;
return *this;
}
- base_uint& operator-=(uint64 b64)
+ base_uint& operator-=(uint64_t b64)
{
base_uint b;
b = b64;
return true;
}
- friend inline bool operator==(const base_uint& a, uint64 b)
+ friend inline bool operator==(const base_uint& a, uint64_t b)
{
if (a.pn[0] != (unsigned int)b)
return false;
return (!(a == b));
}
- friend inline bool operator!=(const base_uint& a, uint64 b)
+ friend inline bool operator!=(const base_uint& a, uint64_t b)
{
return (!(a == b));
}
return sizeof(pn);
}
- uint64 Get64(int n=0) const
+ uint64_t Get64(int n=0) const
{
- return pn[2*n] | (uint64)pn[2*n+1] << 32;
+ return pn[2*n] | (uint64_t)pn[2*n+1] << 32;
}
unsigned int GetSerializeSize(int nType, int nVersion) const
return *this;
}
- uint160(uint64 b)
+ uint160(uint64_t b)
{
pn[0] = (unsigned int)b;
pn[1] = (unsigned int)(b >> 32);
pn[i] = 0;
}
- uint160& operator=(uint64 b)
+ uint160& operator=(uint64_t b)
{
pn[0] = (unsigned int)b;
pn[1] = (unsigned int)(b >> 32);
}
};
-inline bool operator==(const uint160& a, uint64 b) { return (base_uint160)a == b; }
-inline bool operator!=(const uint160& a, uint64 b) { return (base_uint160)a != b; }
+inline bool operator==(const uint160& a, uint64_t b) { return (base_uint160)a == b; }
+inline bool operator!=(const uint160& a, uint64_t b) { return (base_uint160)a != b; }
inline const uint160 operator<<(const base_uint160& a, unsigned int shift) { return uint160(a) <<= shift; }
inline const uint160 operator>>(const base_uint160& a, unsigned int shift) { return uint160(a) >>= shift; }
inline const uint160 operator<<(const uint160& a, unsigned int shift) { return uint160(a) <<= shift; }
return *this;
}
- uint256(uint64 b)
+ uint256(uint64_t b)
{
pn[0] = (unsigned int)b;
pn[1] = (unsigned int)(b >> 32);
pn[i] = 0;
}
- uint256& operator=(uint64 b)
+ uint256& operator=(uint64_t b)
{
pn[0] = (unsigned int)b;
pn[1] = (unsigned int)(b >> 32);
}
};
-inline bool operator==(const uint256& a, uint64 b) { return (base_uint256)a == b; }
-inline bool operator!=(const uint256& a, uint64 b) { return (base_uint256)a != b; }
+inline bool operator==(const uint256& a, uint64_t b) { return (base_uint256)a == b; }
+inline bool operator!=(const uint256& a, uint64_t b) { return (base_uint256)a != b; }
inline const uint256 operator<<(const base_uint256& a, unsigned int shift) { return uint256(a) <<= shift; }
inline const uint256 operator>>(const base_uint256& a, unsigned int shift) { return uint256(a) >>= shift; }
inline const uint256 operator<<(const uint256& a, unsigned int shift) { return uint256(a) <<= shift; }
inline const uint256 operator+(const uint256& a, const uint256& b) { return (base_uint256)a + (base_uint256)b; }
inline const uint256 operator-(const uint256& a, const uint256& b) { return (base_uint256)a - (base_uint256)b; }
-
-
-
-
-
-
-
-
-
-#ifdef TEST_UINT256
-
-inline int Testuint256AdHoc(std::vector<std::string> vArg)
-{
- uint256 g(0);
-
-
- printf("%s\n", g.ToString().c_str());
- g--; printf("g--\n");
- printf("%s\n", g.ToString().c_str());
- g--; printf("g--\n");
- printf("%s\n", g.ToString().c_str());
- g++; printf("g++\n");
- printf("%s\n", g.ToString().c_str());
- g++; printf("g++\n");
- printf("%s\n", g.ToString().c_str());
- g++; printf("g++\n");
- printf("%s\n", g.ToString().c_str());
- g++; printf("g++\n");
- printf("%s\n", g.ToString().c_str());
-
-
-
- uint256 a(7);
- printf("a=7\n");
- printf("%s\n", a.ToString().c_str());
-
- uint256 b;
- printf("b undefined\n");
- printf("%s\n", b.ToString().c_str());
- int c = 3;
-
- a = c;
- a.pn[3] = 15;
- printf("%s\n", a.ToString().c_str());
- uint256 k(c);
-
- a = 5;
- a.pn[3] = 15;
- printf("%s\n", a.ToString().c_str());
- b = 1;
- b <<= 52;
-
- a |= b;
-
- a ^= 0x500;
-
- printf("a %s\n", a.ToString().c_str());
-
- a = a | b | (uint256)0x1000;
-
-
- printf("a %s\n", a.ToString().c_str());
- printf("b %s\n", b.ToString().c_str());
-
- a = 0xfffffffe;
- a.pn[4] = 9;
-
- printf("%s\n", a.ToString().c_str());
- a++;
- printf("%s\n", a.ToString().c_str());
- a++;
- printf("%s\n", a.ToString().c_str());
- a++;
- printf("%s\n", a.ToString().c_str());
- a++;
- printf("%s\n", a.ToString().c_str());
-
- a--;
- printf("%s\n", a.ToString().c_str());
- a--;
- printf("%s\n", a.ToString().c_str());
- a--;
- printf("%s\n", a.ToString().c_str());
- uint256 d = a--;
- printf("%s\n", d.ToString().c_str());
- printf("%s\n", a.ToString().c_str());
- a--;
- printf("%s\n", a.ToString().c_str());
- a--;
- printf("%s\n", a.ToString().c_str());
-
- d = a;
-
- printf("%s\n", d.ToString().c_str());
- for (int i = uint256::WIDTH-1; i >= 0; i--) printf("%08x", d.pn[i]); printf("\n");
-
- uint256 neg = d;
- neg = ~neg;
- printf("%s\n", neg.ToString().c_str());
-
-
- uint256 e = uint256("0xABCDEF123abcdef12345678909832180000011111111");
- printf("\n");
- printf("%s\n", e.ToString().c_str());
-
-
- printf("\n");
- uint256 x1 = uint256("0xABCDEF123abcdef12345678909832180000011111111");
- uint256 x2;
- printf("%s\n", x1.ToString().c_str());
- for (int i = 0; i < 270; i += 4)
- {
- x2 = x1 << i;
- printf("%s\n", x2.ToString().c_str());
- }
-
- printf("\n");
- printf("%s\n", x1.ToString().c_str());
- for (int i = 0; i < 270; i += 4)
- {
- x2 = x1;
- x2 >>= i;
- printf("%s\n", x2.ToString().c_str());
- }
-
-
- for (int i = 0; i < 100; i++)
- {
- uint256 k = (~uint256(0) >> i);
- printf("%s\n", k.ToString().c_str());
- }
-
- for (int i = 0; i < 100; i++)
- {
- uint256 k = (~uint256(0) << i);
- printf("%s\n", k.ToString().c_str());
- }
-
- return (0);
-}
-
-#endif
-
#endif
bool fTestNet = false;
bool fNoListen = false;
bool fLogTimestamps = false;
-CMedianFilter<int64> vTimeOffsets(200,0);
+CMedianFilter<int64_t> vTimeOffsets(200,0);
bool fReopenDebugLog = false;
// Extended DecodeDumpTime implementation, see this page for details:
void RandAddSeed()
{
// Seed with CPU performance counter
- int64 nCounter = GetPerformanceCounter();
+ int64_t nCounter = GetPerformanceCounter();
RAND_add(&nCounter, sizeof(nCounter), 1.5);
memset(&nCounter, 0, sizeof(nCounter));
}
RandAddSeed();
// This can take up to 2 seconds, so only do it every 10 minutes
- static int64 nLastPerfmon;
+ static int64_t nLastPerfmon;
if (GetTime() < nLastPerfmon + 10 * 60)
return;
nLastPerfmon = GetTime();
#endif
}
-uint64 GetRand(uint64 nMax)
+uint64_t GetRand(uint64_t nMax)
{
if (nMax == 0)
return 0;
// The range of the random source must be a multiple of the modulus
// to give every possible output value an equal possibility
- uint64 nRange = (std::numeric_limits<uint64>::max() / nMax) * nMax;
- uint64 nRand = 0;
+ uint64_t nRange = (std::numeric_limits<uint64_t>::max() / nMax) * nMax;
+ uint64_t nRand = 0;
do
RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
while (nRand >= nRange);
}
-string FormatMoney(int64 n, bool fPlus)
+string FormatMoney(int64_t n, bool fPlus)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
- int64 n_abs = (n > 0 ? n : -n);
- int64 quotient = n_abs/COIN;
- int64 remainder = n_abs%COIN;
- string str = strprintf("%" PRI64d ".%06" PRI64d, quotient, remainder);
+ int64_t n_abs = (n > 0 ? n : -n);
+ int64_t quotient = n_abs/COIN;
+ int64_t remainder = n_abs%COIN;
+ string str = strprintf("%" PRId64 ".%06" PRId64, quotient, remainder);
// Right-trim excess zeros before the decimal point:
int nTrim = 0;
}
-bool ParseMoney(const string& str, int64& nRet)
+bool ParseMoney(const string& str, int64_t& nRet)
{
return ParseMoney(str.c_str(), nRet);
}
-bool ParseMoney(const char* pszIn, int64& nRet)
+bool ParseMoney(const char* pszIn, int64_t& nRet)
{
string strWhole;
- int64 nUnits = 0;
+ int64_t nUnits = 0;
const char* p = pszIn;
while (isspace(*p))
p++;
if (*p == '.')
{
p++;
- int64 nMult = CENT*10;
+ int64_t nMult = CENT*10;
while (isdigit(*p) && (nMult > 0))
{
nUnits += nMult * (*p++ - '0');
return false;
if (nUnits < 0 || nUnits > COIN)
return false;
- int64 nWhole = atoi64(strWhole);
- int64 nValue = nWhole*COIN + nUnits;
+ int64_t nWhole = atoi64(strWhole);
+ int64_t nValue = nWhole*COIN + nUnits;
nRet = nValue;
return true;
return strDefault;
}
-int64 GetArg(const std::string& strArg, int64 nDefault)
+int64_t GetArg(const std::string& strArg, int64_t nDefault)
{
if (mapArgs.count(strArg))
return atoi64(mapArgs[strArg]);
}
-int64 DecodeDumpTime(const std::string& s)
+int64_t DecodeDumpTime(const std::string& s)
{
bt::ptime pt;
return pt_to_time_t(pt);
}
-std::string EncodeDumpTime(int64 nTime) {
+std::string EncodeDumpTime(int64_t nTime) {
return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime);
}
// - Median of other nodes clocks
// - The user (asking the user to fix the system clock if the first two disagree)
//
-static int64 nMockTime = 0; // For unit testing
+static int64_t nMockTime = 0; // For unit testing
-int64 GetTime()
+int64_t GetTime()
{
if (nMockTime) return nMockTime;
return time(NULL);
}
-void SetMockTime(int64 nMockTimeIn)
+void SetMockTime(int64_t nMockTimeIn)
{
nMockTime = nMockTimeIn;
}
-static int64 nTimeOffset = 0;
+static int64_t nTimeOffset = 0;
-int64 GetTimeOffset()
+int64_t GetTimeOffset()
{
return nTimeOffset;
}
-int64 GetAdjustedTime()
+int64_t GetAdjustedTime()
{
return GetTime() + GetTimeOffset();
}
-void AddTimeData(const CNetAddr& ip, int64 nTime)
+void AddTimeData(const CNetAddr& ip, int64_t nTime)
{
- int64 nOffsetSample = nTime - GetTime();
+ int64_t nOffsetSample = nTime - GetTime();
// Ignore duplicates
static set<CNetAddr> setKnown;
// Add data
vTimeOffsets.input(nOffsetSample);
- printf("Added time data, samples %d, offset %+" PRI64d " (%+" PRI64d " minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
+ printf("Added time data, samples %d, offset %+" PRId64 " (%+" PRId64 " minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
{
- int64 nMedian = vTimeOffsets.median();
- std::vector<int64> vSorted = vTimeOffsets.sorted();
+ int64_t nMedian = vTimeOffsets.median();
+ std::vector<int64_t> vSorted = vTimeOffsets.sorted();
// Only let other nodes change our time by so much
if (abs64(nMedian) < 70 * 60)
{
{
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
bool fMatch = false;
- BOOST_FOREACH(int64 nOffset, vSorted)
+ BOOST_FOREACH(int64_t nOffset, vSorted)
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
fMatch = true;
}
}
if (fDebug) {
- BOOST_FOREACH(int64 n, vSorted)
- printf("%+" PRI64d " ", n);
+ BOOST_FOREACH(int64_t n, vSorted)
+ printf("%+" PRId64 " ", n);
printf("| ");
}
- printf("nTimeOffset = %+" PRI64d " (%+" PRI64d " minutes)\n", nTimeOffset, nTimeOffset/60);
+ printf("nTimeOffset = %+" PRId64 " (%+" PRId64 " minutes)\n", nTimeOffset, nTimeOffset/60);
}
}
#ifndef BITCOIN_UTIL_H
#define BITCOIN_UTIL_H
+#include <inttypes.h>
#include "uint256.h"
#ifndef WIN32
#include "netbase.h" // for AddTimeData
-typedef long long int64;
-typedef unsigned long long uint64;
-static const int64 COIN = 1000000;
-static const int64 CENT = 10000;
+static const int64_t COIN = 1000000;
+static const int64_t CENT = 10000;
#define BEGIN(a) ((char*)&(a))
#define END(a) ((char*)&((&(a))[1]))
#define UINTBEGIN(a) ((uint32_t*)&(a))
#define CUINTBEGIN(a) ((const uint32_t*)&(a))
-#ifndef PRI64d
-#if defined(_MSC_VER) || defined(__MSVCRT__)
-#define PRI64d "I64d"
-#define PRI64u "I64u"
-#define PRI64x "I64x"
-#else
-#define PRI64d "lld"
-#define PRI64u "llu"
-#define PRI64x "llx"
-#endif
-#endif
-
#ifndef THROW_WITH_STACKTRACE
#define THROW_WITH_STACKTRACE(exception) \
{ \
#endif
#else
#define MAX_PATH 1024
-inline void Sleep(int64 n)
+inline void Sleep(int64_t n)
{
/*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly.
So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/
void PrintException(std::exception* pex, const char* pszThread);
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
void ParseString(const std::string& str, char c, std::vector<std::string>& v);
-std::string FormatMoney(int64 n, bool fPlus=false);
-bool ParseMoney(const std::string& str, int64& nRet);
-bool ParseMoney(const char* pszIn, int64& nRet);
+std::string FormatMoney(int64_t n, bool fPlus=false);
+bool ParseMoney(const std::string& str, int64_t& nRet);
+bool ParseMoney(const char* pszIn, int64_t& nRet);
std::vector<unsigned char> ParseHex(const char* psz);
std::vector<unsigned char> ParseHex(const std::string& str);
bool IsHex(const std::string& str);
std::string DecodeBase32(const std::string& str);
std::string EncodeBase32(const unsigned char* pch, size_t len);
std::string EncodeBase32(const std::string& str);
-std::string EncodeDumpTime(int64 nTime);
-int64 DecodeDumpTime(const std::string& s);
+std::string EncodeDumpTime(int64_t nTime);
+int64_t DecodeDumpTime(const std::string& s);
std::string EncodeDumpString(const std::string &str);
std::string DecodeDumpString(const std::string &str);
void ParseParameters(int argc, const char*const argv[]);
#endif
void ShrinkDebugFile();
int GetRandInt(int nMax);
-uint64 GetRand(uint64 nMax);
+uint64_t GetRand(uint64_t nMax);
uint256 GetRandHash();
-int64 GetTime();
-void SetMockTime(int64 nMockTimeIn);
-int64 GetAdjustedTime();
-int64 GetTimeOffset();
+int64_t GetTime();
+void SetMockTime(int64_t nMockTimeIn);
+int64_t GetAdjustedTime();
+int64_t GetTimeOffset();
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
-void AddTimeData(const CNetAddr& ip, int64 nTime);
+void AddTimeData(const CNetAddr& ip, int64_t nTime);
void runCommand(std::string strCommand);
-inline std::string i64tostr(int64 n)
+inline std::string i64tostr(int64_t n)
{
- return strprintf("%" PRI64d, n);
+ return strprintf("%" PRId64, n);
}
inline std::string itostr(int n)
return strprintf("%d", n);
}
-inline int64 atoi64(const char* psz)
+inline int64_t atoi64(const char* psz)
{
#ifdef _MSC_VER
return _atoi64(psz);
#endif
}
-inline int64 atoi64(const std::string& str)
+inline int64_t atoi64(const std::string& str)
{
#ifdef _MSC_VER
return _atoi64(str.c_str());
return (int)(d > 0 ? d + 0.5 : d - 0.5);
}
-inline int64 roundint64(double d)
+inline int64_t roundint64(double d)
{
- return (int64)(d > 0 ? d + 0.5 : d - 0.5);
+ return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
}
-inline int64 abs64(int64 n)
+inline int64_t abs64(int64_t n)
{
return (n >= 0 ? n : -n);
}
printf(pszFormat, HexStr(vch, fSpaces).c_str());
}
-inline int64 GetPerformanceCounter()
+inline int64_t GetPerformanceCounter()
{
- int64 nCounter = 0;
+ int64_t nCounter = 0;
#ifdef WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
#else
timeval t;
gettimeofday(&t, NULL);
- nCounter = (int64) t.tv_sec * 1000000 + t.tv_usec;
+ nCounter = (int64_t) t.tv_sec * 1000000 + t.tv_usec;
#endif
return nCounter;
}
-inline int64 GetTimeMillis()
+inline int64_t GetTimeMillis()
{
return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
}
-inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime)
+inline std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
{
time_t n = nTime;
struct tm* ptmTime = gmtime(&n);
}
static const std::string strTimestampFormat = "%Y-%m-%d %H:%M:%S UTC";
-inline std::string DateTimeStrFormat(int64 nTime)
+inline std::string DateTimeStrFormat(int64_t nTime)
{
return DateTimeStrFormat(strTimestampFormat.c_str(), nTime);
}
* @param default (e.g. 1)
* @return command-line argument (0 if invalid number) or default value
*/
-int64 GetArg(const std::string& strArg, int64 nDefault);
+int64_t GetArg(const std::string& strArg, int64_t nDefault);
/**
* Return boolean argument or default value
struct CompareValueOnly
{
- bool operator()(const pair<int64, pair<const CWalletTx*, unsigned int> >& t1,
- const pair<int64, pair<const CWalletTx*, unsigned int> >& t2) const
+ bool operator()(const pair<int64_t, pair<const CWalletTx*, unsigned int> >& t1,
+ const pair<int64_t, pair<const CWalletTx*, unsigned int> >& t2) const
{
return t1.first < t2.first;
}
CPubKey pubkey = key.GetPubKey();
// Create new metadata
- int64 nCreationTime = GetTime();
+ int64_t nCreationTime = GetTime();
mapKeyMetadata[pubkey.GetID()] = CKeyMetadata(nCreationTime);
if (!nTimeFirstKey || nCreationTime < nTimeFirstKey)
nTimeFirstKey = nCreationTime;
return false;
if (CCryptoKeyStore::Unlock(vMasterKey))
{
- int64 nStartTime = GetTimeMillis();
+ int64_t nStartTime = GetTimeMillis();
crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod);
pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIterations * (100 / ((double)(GetTimeMillis() - nStartTime)));
RAND_bytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE);
CCrypter crypter;
- int64 nStartTime = GetTimeMillis();
+ int64_t nStartTime = GetTimeMillis();
crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod);
kMasterKey.nDeriveIterations = 2500000 / ((double)(GetTimeMillis() - nStartTime));
return true;
}
-int64 CWallet::IncOrderPosNext(CWalletDB *pwalletdb)
+int64_t CWallet::IncOrderPosNext(CWalletDB *pwalletdb)
{
- int64 nRet = nOrderPosNext++;
+ int64_t nRet = nOrderPosNext++;
if (pwalletdb) {
pwalletdb->WriteOrderPosNext(nOrderPosNext);
} else {
unsigned int latestEntry = 0;
{
// Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future
- int64 latestTolerated = latestNow + 300;
+ int64_t latestTolerated = latestNow + 300;
std::list<CAccountingEntry> acentries;
TxItems txOrdered = OrderedTxItems(acentries);
for (TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
if (pwtx == &wtx)
continue;
CAccountingEntry *const pacentry = (*it).second.second;
- int64 nSmartTime;
+ int64_t nSmartTime;
if (pwtx)
{
nSmartTime = pwtx->nTimeSmart;
return MINE_NO;
}
-int64 CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
+int64_t CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
{
{
LOCK(cs_wallet);
return false;
}
-int64 CWalletTx::GetTxTime() const
+int64_t CWalletTx::GetTxTime() const
{
return nTime;
}
return nRequests;
}
-void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, list<pair<CTxDestination, int64> >& listReceived,
- list<pair<CTxDestination, int64> >& listSent, int64& nFee, string& strSentAccount, const isminefilter& filter) const
+void CWalletTx::GetAmounts(int64_t& nGeneratedImmature, int64_t& nGeneratedMature, list<pair<CTxDestination, int64_t> >& listReceived,
+ list<pair<CTxDestination, int64_t> >& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const
{
nGeneratedImmature = nGeneratedMature = nFee = 0;
listReceived.clear();
}
// Compute fee:
- int64 nDebit = GetDebit(filter);
+ int64_t nDebit = GetDebit(filter);
if (nDebit > 0) // debit>0 means we signed/sent this transaction
{
- int64 nValueOut = GetValueOut();
+ int64_t nValueOut = GetValueOut();
nFee = nDebit - nValueOut;
}
}
-void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived,
- int64& nSent, int64& nFee, const isminefilter& filter) const
+void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nGenerated, int64_t& nReceived,
+ int64_t& nSent, int64_t& nFee, const isminefilter& filter) const
{
nGenerated = nReceived = nSent = nFee = 0;
- int64 allGeneratedImmature, allGeneratedMature, allFee;
+ int64_t allGeneratedImmature, allGeneratedMature, allFee;
allGeneratedImmature = allGeneratedMature = allFee = 0;
string strSentAccount;
- list<pair<CTxDestination, int64> > listReceived;
- list<pair<CTxDestination, int64> > listSent;
+ list<pair<CTxDestination, int64_t> > listReceived;
+ list<pair<CTxDestination, int64_t> > listSent;
GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount, filter);
if (strAccount == "")
nGenerated = allGeneratedMature;
if (strAccount == strSentAccount)
{
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& s, listSent)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& s, listSent)
nSent += s.second;
nFee = allFee;
}
{
LOCK(pwallet->cs_wallet);
- BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64)& r, listReceived)
+ BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived)
{
if (pwallet->mapAddressBook.count(r.first))
{
{
// Do this infrequently and randomly to avoid giving away
// that these are our transactions.
- static int64 nNextTime;
+ static int64_t nNextTime;
if (GetTime() < nNextTime)
return;
bool fFirst = (nNextTime == 0);
return;
// Only do it if there's been a new block since last time
- static int64 nLastTime;
+ static int64_t nLastTime;
if (nTimeBestReceived < nLastTime)
return;
nLastTime = GetTime();
CWalletTx& wtx = item.second;
// Don't rebroadcast until it's had plenty of time that
// it should have gotten in already by now.
- if (nTimeBestReceived - (int64)wtx.nTimeReceived > 5 * 60)
+ if (nTimeBestReceived - (int64_t)wtx.nTimeReceived > 5 * 60)
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
}
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
//
-int64 CWallet::GetBalance() const
+int64_t CWallet::GetBalance() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
return nTotal;
}
-int64 CWallet::GetWatchOnlyBalance() const
+int64_t CWallet::GetWatchOnlyBalance() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
return nTotal;
}
-int64 CWallet::GetUnconfirmedBalance() const
+int64_t CWallet::GetUnconfirmedBalance() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
return nTotal;
}
-int64 CWallet::GetUnconfirmedWatchOnlyBalance() const
+int64_t CWallet::GetUnconfirmedWatchOnlyBalance() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
return nTotal;
}
-int64 CWallet::GetImmatureBalance() const
+int64_t CWallet::GetImmatureBalance() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
return nTotal;
}
-int64 CWallet::GetImmatureWatchOnlyBalance() const
+int64_t CWallet::GetImmatureWatchOnlyBalance() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
{
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
}
}
-void CWallet::AvailableCoinsMinConf(vector<COutput>& vCoins, int nConf, int64 nMinValue, int64 nMaxValue) const
+void CWallet::AvailableCoinsMinConf(vector<COutput>& vCoins, int nConf, int64_t nMinValue, int64_t nMaxValue) const
{
vCoins.clear();
}
}
-static void ApproximateBestSubset(vector<pair<int64, pair<const CWalletTx*,unsigned int> > >vValue, int64 nTotalLower, int64 nTargetValue,
- vector<char>& vfBest, int64& nBest, int iterations = 1000)
+static void ApproximateBestSubset(vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > >vValue, int64_t nTotalLower, int64_t nTargetValue,
+ vector<char>& vfBest, int64_t& nBest, int iterations = 1000)
{
vector<char> vfIncluded;
for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++)
{
vfIncluded.assign(vValue.size(), false);
- int64 nTotal = 0;
+ int64_t nTotal = 0;
bool fReachedTarget = false;
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
{
}
}
-int64 CWallet::GetStake() const
+int64_t CWallet::GetStake() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
return nTotal;
}
-int64 CWallet::GetWatchOnlyStake() const
+int64_t CWallet::GetWatchOnlyStake() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
return nTotal;
}
-int64 CWallet::GetNewMint() const
+int64_t CWallet::GetNewMint() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
return nTotal;
}
-int64 CWallet::GetWatchOnlyNewMint() const
+int64_t CWallet::GetWatchOnlyNewMint() const
{
- int64 nTotal = 0;
+ int64_t nTotal = 0;
LOCK(cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
return nTotal;
}
-bool CWallet::SelectCoinsMinConf(int64 nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, vector<COutput> vCoins, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const
+bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, vector<COutput> vCoins, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
{
setCoinsRet.clear();
nValueRet = 0;
// List of values less than target
- pair<int64, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
- coinLowestLarger.first = std::numeric_limits<int64>::max();
+ pair<int64_t, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
+ coinLowestLarger.first = std::numeric_limits<int64_t>::max();
coinLowestLarger.second.first = NULL;
- vector<pair<int64, pair<const CWalletTx*,unsigned int> > > vValue;
- int64 nTotalLower = 0;
+ vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > > vValue;
+ int64_t nTotalLower = 0;
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);
if (pcoin->nTime > nSpendTime)
continue;
- int64 n = pcoin->vout[i].nValue;
+ int64_t n = pcoin->vout[i].nValue;
- pair<int64,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
+ pair<int64_t,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
if (n == nTargetValue)
{
// Solve subset sum by stochastic approximation
sort(vValue.rbegin(), vValue.rend(), CompareValueOnly());
vector<char> vfBest;
- int64 nBest;
+ int64_t nBest;
ApproximateBestSubset(vValue, nTotalLower, nTargetValue, vfBest, nBest, 1000);
if (nBest != nTargetValue && nTotalLower >= nTargetValue + CENT)
return true;
}
-bool CWallet::SelectCoins(int64 nTargetValue, unsigned int nSpendTime, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet, const CCoinControl* coinControl) const
+bool CWallet::SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl) const
{
vector<COutput> vCoins;
AvailableCoins(vCoins, true, coinControl);
}
// Select some coins without random shuffle or best subset approximation
-bool CWallet::SelectCoinsSimple(int64 nTargetValue, int64 nMinValue, int64 nMaxValue, unsigned int nSpendTime, int nMinConf, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const
+bool CWallet::SelectCoinsSimple(int64_t nTargetValue, int64_t nMinValue, int64_t nMaxValue, unsigned int nSpendTime, int nMinConf, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
{
vector<COutput> vCoins;
AvailableCoinsMinConf(vCoins, nMinConf, nMinValue, nMaxValue);
if (pcoin->nTime > nSpendTime)
continue;
- int64 n = pcoin->vout[i].nValue;
+ int64_t n = pcoin->vout[i].nValue;
- pair<int64,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
+ pair<int64_t,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
if (n >= nTargetValue)
{
return true;
}
-bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl* coinControl)
+bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl)
{
- int64 nValue = 0;
- BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)
+ int64_t nValue = 0;
+ BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
{
if (nValue < 0)
return false;
wtxNew.vout.clear();
wtxNew.fFromMe = true;
- int64 nTotalValue = nValue + nFeeRet;
+ int64_t nTotalValue = nValue + nFeeRet;
double dPriority = 0;
// vouts to the payees
- BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)
+ BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
wtxNew.vout.push_back(CTxOut(s.second, s.first));
// Choose coins to use
set<pair<const CWalletTx*,unsigned int> > setCoins;
- int64 nValueIn = 0;
+ int64_t nValueIn = 0;
if (!SelectCoins(nTotalValue, wtxNew.nTime, setCoins, nValueIn, coinControl))
return false;
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
- int64 nCredit = pcoin.first->vout[pcoin.second].nValue;
+ int64_t nCredit = pcoin.first->vout[pcoin.second].nValue;
dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain();
}
- int64 nChange = nValueIn - nValue - nFeeRet;
+ int64_t nChange = nValueIn - nValue - nFeeRet;
// if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE
// or until nChange becomes zero
// NOTE: this depends on the exact behaviour of GetMinFee
{
if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT)
{
- int64 nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
+ int64_t nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
nChange -= nMoveToFee;
nFeeRet += nMoveToFee;
}
dPriority /= nBytes;
// Check that enough fee is included
- int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);
+ int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
bool fAllowFree = CTransaction::AllowFree(dPriority);
// Disable free transactions until 1 July 2014
fAllowFree = false;
}
- int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
+ int64_t nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
if (nFeeRet < max(nPayFee, nMinFee))
{
return true;
}
-bool CWallet::CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl* coinControl)
+bool CWallet::CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl* coinControl)
{
- vector< pair<CScript, int64> > vecSend;
+ vector< pair<CScript, int64_t> > vecSend;
vecSend.push_back(make_pair(scriptPubKey, nValue));
return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, coinControl);
}
-void CWallet::GetStakeWeightFromValue(const int64& nTime, const int64& nValue, uint64& nWeight)
+void CWallet::GetStakeWeightFromValue(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight)
{
- int64 nTimeWeight = GetWeight(nTime, (int64)GetTime());
+ int64_t nTimeWeight = GetWeight(nTime, (int64_t)GetTime());
// If time weight is lower or equal to zero then weight is zero.
if (nTimeWeight <= 0)
// NovaCoin: get current stake miner statistics
void CWallet::GetStakeStats(float &nKernelsRate, float &nCoinDaysRate)
{
- static uint64 nLastKernels = 0, nLastCoinDays = 0;
+ static uint64_t nLastKernels = 0, nLastCoinDays = 0;
static float nLastKernelsRate = 0, nLastCoinDaysRate = 0;
- static int64 nLastTime = GetTime();
+ static int64_t nLastTime = GetTime();
if (nKernelsTried < nLastKernels)
{
nLastTime = GetTime();
}
- int64 nInterval = GetTime() - nLastTime;
+ int64_t nInterval = GetTime() - nLastTime;
//if (nKernelsTried > 1000 && nInterval > 5)
if (nInterval > 10)
{
}
}
-bool CWallet::MergeCoins(const int64& nAmount, const int64& nMinValue, const int64& nOutputValue, list<uint256>& listMerged)
+bool CWallet::MergeCoins(const int64_t& nAmount, const int64_t& nMinValue, const int64_t& nOutputValue, list<uint256>& listMerged)
{
- int64 nBalance = GetBalance();
+ int64_t nBalance = GetBalance();
if (nAmount > nBalance)
return false;
listMerged.clear();
- int64 nValueIn = 0;
+ int64_t nValueIn = 0;
set<pair<const CWalletTx*,unsigned int> > setCoins;
// Simple coins selection - no randomization
double dWeight = 0;
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
- int64 nCredit = pcoin.first->vout[pcoin.second].nValue;
+ int64_t nCredit = pcoin.first->vout[pcoin.second].nValue;
// Add current coin to inputs list and add its credit to transaction output
wtxNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second));
*/
// Assuming that average scriptsig size is 110 bytes
- int64 nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK, PROTOCOL_VERSION) + wtxNew.vin.size() * 110;
+ int64_t nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK, PROTOCOL_VERSION) + wtxNew.vin.size() * 110;
dWeight += (double)nCredit * pcoin.first->GetDepthInMainChain();
double dFinalPriority = dWeight /= nBytes;
bool fAllowFree = CTransaction::AllowFree(dFinalPriority);
// Get actual transaction fee according to its estimated size and priority
- int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
+ int64_t nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
// Prepare transaction for commit if sum is enough ot its size is too big
if (nBytes >= MAX_BLOCK_SIZE_GEN/6 || wtxNew.vout[0].nValue >= nOutputValue)
// Create transactions if there are some unhandled coins left
if (wtxNew.vout[0].nValue > 0) {
- int64 nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK, PROTOCOL_VERSION) + wtxNew.vin.size() * 110;
+ int64_t nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK, PROTOCOL_VERSION) + wtxNew.vin.size() * 110;
double dFinalPriority = dWeight /= nBytes;
bool fAllowFree = CTransaction::AllowFree(dFinalPriority);
// Get actual transaction fee according to its size and priority
- int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
+ int64_t nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes);
wtxNew.vout[0].nValue -= nMinFee; // Set actual fee
}
-bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew, CKey& key)
+bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CTransaction& txNew, CKey& key)
{
// The following combine threshold is important to security
// Should not be adjusted if you don't understand the consequences
- int64 nCombineThreshold = GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits) / 3;
+ int64_t nCombineThreshold = GetProofOfWorkReward(GetLastBlockIndex(pindexBest, false)->nBits) / 3;
CBigNum bnTargetPerCoinDay;
bnTargetPerCoinDay.SetCompact(nBits);
txNew.vout.push_back(CTxOut(0, scriptEmpty));
// Choose coins to use
- int64 nBalance = GetBalance();
- int64 nReserveBalance = 0;
+ int64_t nBalance = GetBalance();
+ int64_t nReserveBalance = 0;
if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
return error("CreateCoinStake : invalid reserve balance amount");
if (!fCoinsDataActual)
{
mapMeta.clear();
- int64 nValueIn = 0;
+ int64_t nValueIn = 0;
CoinsSet setCoins;
if (!SelectCoinsSimple(nBalance - nReserveBalance, MIN_TX_FEE, MAX_MONEY, txNew.nTime, nCoinbaseMaturity * 10, setCoins, nValueIn))
return false;
if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
continue;
- uint64 nStakeModifier = 0;
+ uint64_t nStakeModifier = 0;
if (!GetKernelStakeModifier(block.GetHash(), nStakeModifier))
continue;
}
}
- int64 nCredit = 0;
+ int64_t nCredit = 0;
CScript scriptPubKeyKernel;
KernelSearchSettings settings;
vwtxPrev.push_back(kernelcoin.first);
txNew.vout.push_back(CTxOut(0, scriptPubKeyOut));
- if (GetWeight((int64)nBlockTime, (int64)txNew.nTime) < nStakeMaxAge)
+ if (GetWeight((int64_t)nBlockTime, (int64_t)txNew.nTime) < nStakeMaxAge)
txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); //split stake
if (fDebug && GetBoolArg("-printcoinstake"))
printf("CreateCoinStake : added kernel type=%d\n", whichType);
if (txNew.vout.size() == 2 && ((pcoin.first->vout[pcoin.second].scriptPubKey == scriptPubKeyKernel || pcoin.first->vout[pcoin.second].scriptPubKey == txNew.vout[1].scriptPubKey))
&& pcoin.first->GetHash() != txNew.vin[0].prevout.hash)
{
- int64 nTimeWeight = GetWeight((int64)pcoin.first->nTime, (int64)txNew.nTime);
+ int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)txNew.nTime);
// Stop adding more inputs if already too many inputs
if (txNew.vin.size() >= 100)
// Calculate coin age reward
{
- uint64 nCoinAge;
+ uint64_t nCoinAge;
CTxDB txdb("r");
if (!txNew.GetCoinAge(txdb, nCoinAge))
return error("CreateCoinStake : failed to calculate coin age");
- int64 nReward = GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
+ int64_t nReward = GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime);
// Refuse to create mint that has zero or negative reward
if(nReward <= 0)
return false;
nCredit += nReward;
}
- int64 nMinFee = 0;
+ int64_t nMinFee = 0;
while (true)
{
// Set output amount
-string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
+string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee)
{
CReserveKey reservekey(this);
- int64 nFeeRequired;
+ int64_t nFeeRequired;
if (IsLocked())
{
-string CWallet::SendMoneyToDestination(const CTxDestination& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
+string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee)
{
// Check amount
if (nValue <= 0)
if (block.IsProofOfWork() && mapWallet.count(block.vtx[0].GetHash()))
{
CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()];
- printf(" mine: %d %d %" PRI64d "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
+ printf(" mine: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
}
if (block.IsProofOfStake() && mapWallet.count(block.vtx[1].GetHash()))
{
CWalletTx& wtx = mapWallet[block.vtx[1].GetHash()];
- printf(" stake: %d %d %" PRI64d "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
+ printf(" stake: %d %d %" PRId64 "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit());
}
}
{
LOCK(cs_wallet);
CWalletDB walletdb(strWalletFile);
- BOOST_FOREACH(int64 nIndex, setKeyPool)
+ BOOST_FOREACH(int64_t nIndex, setKeyPool)
walletdb.ErasePool(nIndex);
setKeyPool.clear();
if (IsLocked())
return false;
- int64 nKeys = max(GetArg("-keypool", 100), (int64)0);
+ int64_t nKeys = max(GetArg("-keypool", 100), (int64_t)0);
for (int i = 0; i < nKeys; i++)
{
- int64 nIndex = i+1;
+ int64_t nIndex = i+1;
walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey()));
setKeyPool.insert(nIndex);
}
- printf("CWallet::NewKeyPool wrote %" PRI64d " new keys\n", nKeys);
+ printf("CWallet::NewKeyPool wrote %" PRId64 " new keys\n", nKeys);
}
return true;
}
if (nSize > 0)
nTargetSize = nSize;
else
- nTargetSize = max(GetArg("-keypool", 100), 0LL);
+ nTargetSize = max<unsigned int>(GetArg("-keypool", 100), 0LL);
while (setKeyPool.size() < (nTargetSize + 1))
{
- int64 nEnd = 1;
+ int64_t nEnd = 1;
if (!setKeyPool.empty())
nEnd = *(--setKeyPool.end()) + 1;
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
throw runtime_error("TopUpKeyPool() : writing generated key failed");
setKeyPool.insert(nEnd);
- printf("keypool added key %" PRI64d ", size=%" PRIszu "\n", nEnd, setKeyPool.size());
+ printf("keypool added key %" PRId64 ", size=%" PRIszu "\n", nEnd, setKeyPool.size());
}
}
return true;
}
-void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool)
+void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool)
{
nIndex = -1;
keypool.vchPubKey = CPubKey();
throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool");
assert(keypool.vchPubKey.IsValid());
if (fDebug && GetBoolArg("-printkeypool"))
- printf("keypool reserve %" PRI64d "\n", nIndex);
+ printf("keypool reserve %" PRId64 "\n", nIndex);
}
}
-int64 CWallet::AddReserveKey(const CKeyPool& keypool)
+int64_t CWallet::AddReserveKey(const CKeyPool& keypool)
{
{
LOCK2(cs_main, cs_wallet);
CWalletDB walletdb(strWalletFile);
- int64 nIndex = 1 + *(--setKeyPool.end());
+ int64_t nIndex = 1 + *(--setKeyPool.end());
if (!walletdb.WritePool(nIndex, keypool))
throw runtime_error("AddReserveKey() : writing added key failed");
setKeyPool.insert(nIndex);
return -1;
}
-void CWallet::KeepKey(int64 nIndex)
+void CWallet::KeepKey(int64_t nIndex)
{
// Remove from key pool
if (fFileBacked)
walletdb.ErasePool(nIndex);
}
if(fDebug)
- printf("keypool keep %" PRI64d "\n", nIndex);
+ printf("keypool keep %" PRId64 "\n", nIndex);
}
-void CWallet::ReturnKey(int64 nIndex)
+void CWallet::ReturnKey(int64_t nIndex)
{
// Return to key pool
{
setKeyPool.insert(nIndex);
}
if(fDebug)
- printf("keypool return %" PRI64d "\n", nIndex);
+ printf("keypool return %" PRId64 "\n", nIndex);
}
bool CWallet::GetKeyFromPool(CPubKey& result, bool fAllowReuse)
{
- int64 nIndex = 0;
+ int64_t nIndex = 0;
CKeyPool keypool;
{
LOCK(cs_wallet);
return true;
}
-int64 CWallet::GetOldestKeyPoolTime()
+int64_t CWallet::GetOldestKeyPoolTime()
{
- int64 nIndex = 0;
+ int64_t nIndex = 0;
CKeyPool keypool;
ReserveKeyFromKeyPool(nIndex, keypool);
if (nIndex == -1)
return keypool.nTime;
}
-std::map<CTxDestination, int64> CWallet::GetAddressBalances()
+std::map<CTxDestination, int64_t> CWallet::GetAddressBalances()
{
- map<CTxDestination, int64> balances;
+ map<CTxDestination, int64_t> balances;
{
LOCK(cs_wallet);
if(!ExtractDestination(pcoin->vout[i].scriptPubKey, addr))
continue;
- int64 n = pcoin->IsSpent(i) ? 0 : pcoin->vout[i].nValue;
+ int64_t n = pcoin->IsSpent(i) ? 0 : pcoin->vout[i].nValue;
if (!balances.count(addr))
balances[addr] = 0;
// ppcoin: check 'spent' consistency between wallet and txindex
// ppcoin: fix wallet spent state according to txindex
-void CWallet::FixSpentCoins(int& nMismatchFound, int64& nBalanceInQuestion, bool fCheckOnly)
+void CWallet::FixSpentCoins(int& nMismatchFound, int64_t& nBalanceInQuestion, bool fCheckOnly)
{
nMismatchFound = 0;
nBalanceInQuestion = 0;
CWalletDB walletdb(strWalletFile);
LOCK2(cs_main, cs_wallet);
- BOOST_FOREACH(const int64& id, setKeyPool)
+ BOOST_FOREACH(const int64_t& id, setKeyPool)
{
CKeyPool keypool;
if (!walletdb.ReadPool(id, keypool))
}
}
-void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64> &mapKeyBirth) const {
+void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
mapKeyBirth.clear();
// get birth times for keys with metadata
class CKeyPool
{
public:
- int64 nTime;
+ int64_t nTime;
CPubKey vchPubKey;
CKeyPool()
class CWallet : public CCryptoKeyStore
{
private:
- bool SelectCoinsSimple(int64 nTargetValue, int64 nMinValue, int64 nMaxValue, unsigned int nSpendTime, int nMinConf, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const;
- bool SelectCoins(int64 nTargetValue, unsigned int nSpendTime, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet, const CCoinControl *coinControl=NULL) const;
+ bool SelectCoinsSimple(int64_t nTargetValue, int64_t nMinValue, int64_t nMaxValue, unsigned int nSpendTime, int nMinConf, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
+ bool SelectCoins(int64_t nTargetValue, unsigned int nSpendTime, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl=NULL) const;
CWalletDB *pwalletdbEncryption;
int nWalletMaxVersion;
// selected coins metadata
- std::map<std::pair<uint256, unsigned int>, std::pair<std::pair<CTxIndex, std::pair<const CWalletTx*,unsigned int> >, std::pair<CBlock, uint64> > > mapMeta;
+ std::map<std::pair<uint256, unsigned int>, std::pair<std::pair<CTxIndex, std::pair<const CWalletTx*,unsigned int> >, std::pair<CBlock, uint64_t> > > mapMeta;
// stake mining statistics
- uint64 nKernelsTried;
- uint64 nCoinDaysTried;
+ uint64_t nKernelsTried;
+ uint64_t nCoinDaysTried;
public:
mutable CCriticalSection cs_wallet;
bool fFileBacked;
std::string strWalletFile;
- std::set<int64> setKeyPool;
+ std::set<int64_t> setKeyPool;
std::map<CKeyID, CKeyMetadata> mapKeyMetadata;
std::map<uint256, CWalletTx> mapWallet;
std::vector<uint256> vMintingWalletUpdated;
- int64 nOrderPosNext;
+ int64_t nOrderPosNext;
std::map<uint256, int> mapRequestCount;
std::map<CTxDestination, std::string> mapAddressBook;
CPubKey vchDefaultKey;
- int64 nTimeFirstKey;
+ int64_t nTimeFirstKey;
// check whether we are allowed to upgrade (or already support) to the named feature
bool CanSupportFeature(enum WalletFeature wf) { return nWalletMaxVersion >= wf; }
- void AvailableCoinsMinConf(std::vector<COutput>& vCoins, int nConf, int64 nMinValue, int64 nMaxValue) const;
+ void AvailableCoinsMinConf(std::vector<COutput>& vCoins, int nConf, int64_t nMinValue, int64_t nMaxValue) const;
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const;
- bool SelectCoinsMinConf(int64 nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const;
+ bool SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
// keystore implementation
// Generate a new key
CPubKey GenerateNewKey();
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
bool EncryptWallet(const SecureString& strWalletPassphrase);
- void GetKeyBirthTimes(std::map<CKeyID, int64> &mapKeyBirth) const;
+ void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const;
/** Increment the next transaction order id
@return next transaction order id
*/
- int64 IncOrderPosNext(CWalletDB *pwalletdb = NULL);
+ int64_t IncOrderPosNext(CWalletDB *pwalletdb = NULL);
typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair;
- typedef std::multimap<int64, TxPair > TxItems;
+ typedef std::multimap<int64_t, TxPair > TxItems;
/** Get the wallet's activity log
@return multimap of ordered transactions and accounting entries
int ScanForWalletTransaction(const uint256& hashTx);
void ReacceptWalletTransactions();
void ResendWalletTransactions();
- int64 GetBalance() const;
- int64 GetWatchOnlyBalance() const;
- int64 GetUnconfirmedBalance() const;
- int64 GetUnconfirmedWatchOnlyBalance() const;
- int64 GetImmatureBalance() const;
- int64 GetImmatureWatchOnlyBalance() const;
- int64 GetStake() const;
- int64 GetNewMint() const;
- int64 GetWatchOnlyStake() const;
- int64 GetWatchOnlyNewMint() const;
- bool CreateTransaction(const std::vector<std::pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl *coinControl=NULL);
- bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl *coinControl=NULL);
+ int64_t GetBalance() const;
+ int64_t GetWatchOnlyBalance() const;
+ int64_t GetUnconfirmedBalance() const;
+ int64_t GetUnconfirmedWatchOnlyBalance() const;
+ int64_t GetImmatureBalance() const;
+ int64_t GetImmatureWatchOnlyBalance() const;
+ int64_t GetStake() const;
+ int64_t GetNewMint() const;
+ int64_t GetWatchOnlyStake() const;
+ int64_t GetWatchOnlyNewMint() const;
+ bool CreateTransaction(const std::vector<std::pair<CScript, int64_t> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL);
+ bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, const CCoinControl *coinControl=NULL);
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
void GetStakeStats(float &nKernelsRate, float &nCoinDaysRate);
- void GetStakeWeightFromValue(const int64& nTime, const int64& nValue, uint64& nWeight);
- bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew, CKey& key);
- bool MergeCoins(const int64& nAmount, const int64& nMinValue, const int64& nMaxValue, std::list<uint256>& listMerged);
+ void GetStakeWeightFromValue(const int64_t& nTime, const int64_t& nValue, uint64_t& nWeight);
+ bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CTransaction& txNew, CKey& key);
+ bool MergeCoins(const int64_t& nAmount, const int64_t& nMinValue, const int64_t& nMaxValue, std::list<uint256>& listMerged);
- std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
- std::string SendMoneyToDestination(const CTxDestination &address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
+ std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);
+ std::string SendMoneyToDestination(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);
bool NewKeyPool();
bool TopUpKeyPool(unsigned int nSize = 0);
- int64 AddReserveKey(const CKeyPool& keypool);
- void ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool);
- void KeepKey(int64 nIndex);
- void ReturnKey(int64 nIndex);
+ int64_t AddReserveKey(const CKeyPool& keypool);
+ void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool);
+ void KeepKey(int64_t nIndex);
+ void ReturnKey(int64_t nIndex);
bool GetKeyFromPool(CPubKey &key, bool fAllowReuse=true);
- int64 GetOldestKeyPoolTime();
+ int64_t GetOldestKeyPoolTime();
void GetAllReserveKeys(std::set<CKeyID>& setAddress) const;
std::set< std::set<CTxDestination> > GetAddressGroupings();
- std::map<CTxDestination, int64> GetAddressBalances();
+ std::map<CTxDestination, int64_t> GetAddressBalances();
isminetype IsMine(const CTxIn& txin) const;
- int64 GetDebit(const CTxIn& txin, const isminefilter& filter) const;
+ int64_t GetDebit(const CTxIn& txin, const isminefilter& filter) const;
isminetype IsMine(const CTxOut& txout) const
{
return ::IsMine(*this, txout.scriptPubKey);
}
- int64 GetCredit(const CTxOut& txout, const isminefilter& filter) const
+ int64_t GetCredit(const CTxOut& txout, const isminefilter& filter) const
{
if (!MoneyRange(txout.nValue))
throw std::runtime_error("CWallet::GetCredit() : value out of range");
return (IsMine(txout) & filter ? txout.nValue : 0);
}
bool IsChange(const CTxOut& txout) const;
- int64 GetChange(const CTxOut& txout) const
+ int64_t GetChange(const CTxOut& txout) const
{
if (!MoneyRange(txout.nValue))
throw std::runtime_error("CWallet::GetChange() : value out of range");
{
return (GetDebit(tx, MINE_ALL) > 0);
}
- int64 GetDebit(const CTransaction& tx, const isminefilter& filter) const
+ int64_t GetDebit(const CTransaction& tx, const isminefilter& filter) const
{
- int64 nDebit = 0;
+ int64_t nDebit = 0;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
nDebit += GetDebit(txin, filter);
}
return nDebit;
}
- int64 GetCredit(const CTransaction& tx, const isminefilter& filter) const
+ int64_t GetCredit(const CTransaction& tx, const isminefilter& filter) const
{
- int64 nCredit = 0;
+ int64_t nCredit = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
{
nCredit += GetCredit(txout, filter);
}
return nCredit;
}
- int64 GetChange(const CTransaction& tx) const
+ int64_t GetChange(const CTransaction& tx) const
{
- int64 nChange = 0;
+ int64_t nChange = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
{
nChange += GetChange(txout);
// get the current wallet format (the oldest client version guaranteed to understand this wallet)
int GetVersion() { return nWalletVersion; }
- void FixSpentCoins(int& nMismatchSpent, int64& nBalanceInQuestion, bool fCheckOnly = false);
+ void FixSpentCoins(int& nMismatchSpent, int64_t& nBalanceInQuestion, bool fCheckOnly = false);
void DisableTransaction(const CTransaction &tx);
/** Address book entry changed.
{
protected:
CWallet* pwallet;
- int64 nIndex;
+ int64_t nIndex;
CPubKey vchPubKey;
public:
CReserveKey(CWallet* pwalletIn)
typedef std::map<std::string, std::string> mapValue_t;
-static void ReadOrderPos(int64& nOrderPos, mapValue_t& mapValue)
+static void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue)
{
if (!mapValue.count("n"))
{
}
-static void WriteOrderPos(const int64& nOrderPos, mapValue_t& mapValue)
+static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
{
if (nOrderPos == -1)
return;
char fFromMe;
std::string strFromAccount;
std::vector<char> vfSpent; // which outputs are already spent
- int64 nOrderPos; // position in ordered transaction list
+ int64_t nOrderPos; // position in ordered transaction list
// memory only
mutable bool fDebitCached;
mutable bool fImmatureWatchCreditCached;
mutable bool fAvailableWatchCreditCached;
mutable bool fChangeCached;
- mutable int64 nDebitCached;
- mutable int64 nWatchDebitCached;
- mutable int64 nCreditCached;
- mutable int64 nWatchCreditCached;
- mutable int64 nAvailableCreditCached;
- mutable int64 nImmatureCreditCached;
- mutable int64 nImmatureWatchCreditCached;
- mutable int64 nAvailableWatchCreditCached;
- mutable int64 nChangeCached;
+ mutable int64_t nDebitCached;
+ mutable int64_t nWatchDebitCached;
+ mutable int64_t nCreditCached;
+ mutable int64_t nWatchCreditCached;
+ mutable int64_t nAvailableCreditCached;
+ mutable int64_t nImmatureCreditCached;
+ mutable int64_t nImmatureWatchCreditCached;
+ mutable int64_t nAvailableWatchCreditCached;
+ mutable int64_t nChangeCached;
CWalletTx()
{
return (!!vfSpent[nOut]);
}
- int64 GetDebit(const isminefilter& filter) const
+ int64_t GetDebit(const isminefilter& filter) const
{
if (vin.empty())
return 0;
- int64 nDebit = 0;
+ int64_t nDebit = 0;
if (filter & MINE_SPENDABLE)
{
if (fDebitCached)
return nDebit;
}
- int64 GetCredit(bool fUseCache=true) const
+ int64_t GetCredit(bool fUseCache=true) const
{
// Must wait until coinbase is safely deep enough in the chain before valuing it
if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0)
return nCreditCached;
}
- int64 GetImmatureCredit(bool fUseCache=true) const
+ int64_t GetImmatureCredit(bool fUseCache=true) const
{
if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain())
{
return 0;
}
- int64 GetImmatureWatchOnlyCredit(bool fUseCache=true) const
+ int64_t GetImmatureWatchOnlyCredit(bool fUseCache=true) const
{
if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain())
{
}
- int64 GetAvailableCredit(bool fUseCache=true) const
+ int64_t GetAvailableCredit(bool fUseCache=true) const
{
// Must wait until coinbase is safely deep enough in the chain before valuing it
if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0)
return nAvailableCreditCached;
}
- int64 nCredit = 0;
+ int64_t nCredit = 0;
for (unsigned int i = 0; i < vout.size(); i++)
{
if (!IsSpent(i))
return nCredit;
}
- int64 GetAvailableWatchCredit(bool fUseCache=true) const
+ int64_t GetAvailableWatchCredit(bool fUseCache=true) const
{
// Must wait until coinbase is safely deep enough in the chain before valuing it
if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0)
return nAvailableWatchCreditCached;
}
- int64 nCredit = 0;
+ int64_t nCredit = 0;
for (unsigned int i = 0; i < vout.size(); i++)
{
if (!IsSpent(i))
return nCredit;
}
- int64 GetChange() const
+ int64_t GetChange() const
{
if (fChangeCached)
return nChangeCached;
return nChangeCached;
}
- void GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, std::list<std::pair<CTxDestination, int64> >& listReceived,
- std::list<std::pair<CTxDestination, int64> >& listSent, int64& nFee, std::string& strSentAccount, const isminefilter& filter) const;
+ void GetAmounts(int64_t& nGeneratedImmature, int64_t& nGeneratedMature, std::list<std::pair<CTxDestination, int64_t> >& listReceived,
+ std::list<std::pair<CTxDestination, int64_t> >& listSent, int64_t& nFee, std::string& strSentAccount, const isminefilter& filter) const;
- void GetAccountAmounts(const std::string& strAccount, int64& nGenerated, int64& nReceived,
- int64& nSent, int64& nFee, const isminefilter& filter) const;
+ void GetAccountAmounts(const std::string& strAccount, int64_t& nGenerated, int64_t& nReceived,
+ int64_t& nSent, int64_t& nFee, const isminefilter& filter) const;
bool IsFromMe(const isminefilter& filter) const
{
bool WriteToDisk();
- int64 GetTxTime() const;
+ int64_t GetTxTime() const;
int GetRequestCount() const;
void AddSupportingTransactions(CTxDB& txdb);
{
public:
CPrivKey vchPrivKey;
- int64 nTimeCreated;
- int64 nTimeExpires;
+ int64_t nTimeCreated;
+ int64_t nTimeExpires;
std::string strComment;
//// todo: add something to note what created it (user, getnewaddress, change)
//// maybe should have a map<string, string> property map
- CWalletKey(int64 nExpires=0)
+ CWalletKey(int64_t nExpires=0)
{
nTimeCreated = (nExpires ? GetTime() : 0);
nTimeExpires = nExpires;
{
public:
std::string strAccount;
- int64 nCreditDebit;
- int64 nTime;
+ int64_t nCreditDebit;
+ int64_t nTime;
std::string strOtherAccount;
std::string strComment;
mapValue_t mapValue;
- int64 nOrderPos; // position in ordered transaction list
- uint64 nEntryNo;
+ int64_t nOrderPos; // position in ordered transaction list
+ uint64_t nEntryNo;
CAccountingEntry()
{
using namespace boost;
-static uint64 nAccountingEntryNumber = 0;
+static uint64_t nAccountingEntryNumber = 0;
extern bool fWalletUnlockMintOnly;
//
return Write(make_pair(string("acc"), strAccount), account);
}
-bool CWalletDB::WriteAccountingEntry(const uint64 nAccEntryNum, const CAccountingEntry& acentry)
+bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry)
{
return Write(boost::make_tuple(string("acentry"), acentry.strAccount, nAccEntryNum), acentry);
}
return WriteAccountingEntry(++nAccountingEntryNumber, acentry);
}
-int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
+int64_t CWalletDB::GetAccountCreditDebit(const string& strAccount)
{
list<CAccountingEntry> entries;
ListAccountCreditDebit(strAccount, entries);
- int64 nCreditDebit = 0;
+ int64_t nCreditDebit = 0;
BOOST_FOREACH (const CAccountingEntry& entry, entries)
nCreditDebit += entry.nCreditDebit;
// Read next record
CDataStream ssKey(SER_DISK, CLIENT_VERSION);
if (fFlags == DB_SET_RANGE)
- ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));
+ ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64_t(0));
CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
// First: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap.
typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
- typedef multimap<int64, TxPair > TxItems;
+ typedef multimap<int64_t, TxPair > TxItems;
TxItems txByTime;
for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it)
txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
}
- int64& nOrderPosNext = pwallet->nOrderPosNext;
+ int64_t& nOrderPosNext = pwallet->nOrderPosNext;
nOrderPosNext = 0;
- std::vector<int64> nOrderPosOffsets;
+ std::vector<int64_t> nOrderPosOffsets;
for (TxItems::iterator it = txByTime.begin(); it != txByTime.end(); ++it)
{
CWalletTx *const pwtx = (*it).second.first;
CAccountingEntry *const pacentry = (*it).second.second;
- int64& nOrderPos = (pwtx != 0) ? pwtx->nOrderPos : pacentry->nOrderPos;
+ int64_t& nOrderPos = (pwtx != 0) ? pwtx->nOrderPos : pacentry->nOrderPos;
if (nOrderPos == -1)
{
}
else
{
- int64 nOrderPosOff = 0;
- BOOST_FOREACH(const int64& nOffsetStart, nOrderPosOffsets)
+ int64_t nOrderPosOff = 0;
+ BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets)
{
if (nOrderPos >= nOffsetStart)
++nOrderPosOff;
//// debug print
//printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str());
- //printf(" %12"PRI64d" %s %s %s\n",
+ //printf(" %12"PRId64" %s %s %s\n",
// wtx.vout[0].nValue,
// DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(),
// wtx.hashBlock.ToString().substr(0,20).c_str(),
{
string strAccount;
ssKey >> strAccount;
- uint64 nNumber;
+ uint64_t nNumber;
ssKey >> nNumber;
if (nNumber > nAccountingEntryNumber)
nAccountingEntryNumber = nNumber;
}
else if (strType == "pool")
{
- int64 nIndex;
+ int64_t nIndex;
ssKey >> nIndex;
CKeyPool keypool;
ssValue >> keypool;
unsigned int nLastSeen = nWalletDBUpdated;
unsigned int nLastFlushed = nWalletDBUpdated;
- int64 nLastWalletUpdate = GetTime();
+ int64_t nLastWalletUpdate = GetTime();
while (!fShutdown)
{
Sleep(500);
{
printf("Flushing wallet.dat\n");
nLastFlushed = nWalletDBUpdated;
- int64 nStart = GetTimeMillis();
+ int64_t nStart = GetTimeMillis();
// Flush wallet.dat so it's self contained
bitdb.CloseDb(strFile);
bitdb.CheckpointLSN(strFile);
bitdb.mapFileUseCount.erase(mi++);
- printf("Flushed wallet.dat %" PRI64d "ms\n", GetTimeMillis() - nStart);
+ printf("Flushed wallet.dat %" PRId64 "ms\n", GetTimeMillis() - nStart);
}
}
}
while (!fShutdown)
{
// Populate maps
- std::map<CKeyID, int64> mapKeyBirth;
+ std::map<CKeyID, int64_t> mapKeyBirth;
std::set<CKeyID> setKeyPool;
pwallet->GetKeyBirthTimes(mapKeyBirth);
pwallet->GetAllReserveKeys(setKeyPool);
// sort time/key pairs
- std::vector<std::pair<int64, CKeyID> > vKeyBirth;
- for (std::map<CKeyID, int64>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) {
+ std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
+ for (std::map<CKeyID, int64_t>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) {
vKeyBirth.push_back(std::make_pair(it->second, it->first));
}
mapKeyBirth.clear();
file << strprintf("# * Best block at time of backup was %i (%s),\n", nBestHeight, hashBestChain.ToString().c_str());
file << strprintf("# mined on %s\n", EncodeDumpTime(pindexBest->nTime).c_str());
file << "\n";
- for (std::vector<std::pair<int64, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
+ for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
const CKeyID &keyid = it->second;
std::string strTime = EncodeDumpTime(it->first);
std::string strAddr = CBitcoinAddress(keyid).ToString();
if (!file.is_open())
return false;
- int64 nTimeBegin = pindexBest->nTime;
+ int64_t nTimeBegin = pindexBest->nTime;
bool fGood = true;
printf("Skipping import of %s (key already present)\n", CBitcoinAddress(keyid).ToString().c_str());
continue;
}
- int64 nTime = DecodeDumpTime(vstr[1]);
+ int64_t nTime = DecodeDumpTime(vstr[1]);
std::string strLabel;
bool fLabel = true;
for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) {
// Rewrite salvaged data to wallet.dat
// Set -rescan so any missing transactions will be
// found.
- int64 now = GetTime();
- std::string newFilename = strprintf("wallet.%" PRI64d ".bak", now);
+ int64_t now = GetTime();
+ std::string newFilename = strprintf("wallet.%" PRId64 ".bak", now);
int result = dbenv.dbenv.dbrename(NULL, filename.c_str(), NULL,
newFilename.c_str(), DB_AUTO_COMMIT);
public:
static const int CURRENT_VERSION=1;
int nVersion;
- int64 nCreateTime; // 0 means unknown
+ int64_t nCreateTime; // 0 means unknown
CKeyMetadata()
{
SetNull();
}
- CKeyMetadata(int64 nCreateTime_)
+ CKeyMetadata(int64_t nCreateTime_)
{
nVersion = CKeyMetadata::CURRENT_VERSION;
nCreateTime = nCreateTime_;
return Read(std::string("bestblock"), locator);
}
- bool WriteOrderPosNext(int64 nOrderPosNext)
+ bool WriteOrderPosNext(int64_t nOrderPosNext)
{
nWalletDBUpdated++;
return Write(std::string("orderposnext"), nOrderPosNext);
return Write(std::string("defaultkey"), vchPubKey.Raw());
}
- bool ReadPool(int64 nPool, CKeyPool& keypool)
+ bool ReadPool(int64_t nPool, CKeyPool& keypool)
{
return Read(std::make_pair(std::string("pool"), nPool), keypool);
}
- bool WritePool(int64 nPool, const CKeyPool& keypool)
+ bool WritePool(int64_t nPool, const CKeyPool& keypool)
{
nWalletDBUpdated++;
return Write(std::make_pair(std::string("pool"), nPool), keypool);
}
- bool ErasePool(int64 nPool)
+ bool ErasePool(int64_t nPool)
{
nWalletDBUpdated++;
return Erase(std::make_pair(std::string("pool"), nPool));
bool ReadAccount(const std::string& strAccount, CAccount& account);
bool WriteAccount(const std::string& strAccount, const CAccount& account);
private:
- bool WriteAccountingEntry(const uint64 nAccEntryNum, const CAccountingEntry& acentry);
+ bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
public:
bool WriteAccountingEntry(const CAccountingEntry& acentry);
- int64 GetAccountCreditDebit(const std::string& strAccount);
+ int64_t GetAccountCreditDebit(const std::string& strAccount);
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
DBErrors ReorderTransactions(CWallet*);