Browse Source

Revert "Use standard C99 (and Qt) types for 64-bit integers"

This reverts commit 21d9f36781.
tags/v0.15.1
Wladimir J. van der Laan 10 years ago
parent
commit
bde280b9a4
58 changed files with 442 additions and 526 deletions
  1. 1
    1
      doc/coding.txt
  2. 0
    2
      src/base58.h
  3. 5
    7
      src/bignum.h
  4. 51
    53
      src/bitcoinrpc.cpp
  5. 1
    3
      src/checkpoints.cpp
  6. 8
    10
      src/db.cpp
  7. 5
    7
      src/db.h
  8. 1
    4
      src/init.cpp
  9. 1
    3
      src/irc.cpp
  10. 0
    2
      src/keystore.cpp
  11. 0
    2
      src/keystore.h
  12. 43
    46
      src/main.cpp
  13. 32
    34
      src/main.h
  14. 25
    27
      src/net.cpp
  15. 18
    20
      src/net.h
  16. 1
    3
      src/noui.h
  17. 6
    8
      src/protocol.cpp
  18. 7
    9
      src/protocol.h
  19. 1
    2
      src/qt/bitcoin.cpp
  20. 0
    1
      src/qt/bitcoinamountfield.cpp
  21. 0
    1
      src/qt/bitcoinamountfield.h
  22. 0
    1
      src/qt/bitcoingui.cpp
  23. 0
    1
      src/qt/bitcoingui.h
  24. 1
    1
      src/qt/bitcoinstrings.cpp
  25. 0
    1
      src/qt/bitcoinunits.cpp
  26. 0
    1
      src/qt/bitcoinunits.h
  27. 0
    1
      src/qt/guiutil.cpp
  28. 0
    1
      src/qt/guiutil.h
  29. 0
    1
      src/qt/notificator.cpp
  30. 0
    2
      src/qt/optionsmodel.cpp
  31. 0
    1
      src/qt/optionsmodel.h
  32. 0
    1
      src/qt/overviewpage.cpp
  33. 0
    1
      src/qt/overviewpage.h
  34. 0
    1
      src/qt/sendcoinsdialog.cpp
  35. 0
    1
      src/qt/sendcoinsdialog.h
  36. 8
    9
      src/qt/transactiondesc.cpp
  37. 0
    1
      src/qt/transactionfilterproxy.cpp
  38. 0
    1
      src/qt/transactionfilterproxy.h
  39. 9
    11
      src/qt/transactionrecord.cpp
  40. 8
    9
      src/qt/transactionrecord.h
  41. 0
    1
      src/qt/transactionview.cpp
  42. 2
    3
      src/qt/walletmodel.cpp
  43. 0
    1
      src/qt/walletmodel.h
  44. 1
    3
      src/qtui.h
  45. 1
    3
      src/rpcdump.cpp
  46. 6
    8
      src/script.h
  47. 17
    16
      src/serialize.h
  48. 4
    6
      src/test/DoS_tests.cpp
  49. 0
    2
      src/test/base58_tests.cpp
  50. 0
    2
      src/test/script_op_eval_tests.cpp
  51. 1
    3
      src/test/uint160_tests.cpp
  52. 1
    3
      src/test/uint256_tests.cpp
  53. 1
    3
      src/test/util_tests.cpp
  54. 21
    20
      src/uint256.h
  55. 27
    30
      src/util.cpp
  56. 23
    22
      src/util.h
  57. 62
    64
      src/wallet.cpp
  58. 43
    45
      src/wallet.h

+ 1
- 1
doc/coding.txt View File

@@ -28,7 +28,7 @@ someVariable.
Common types:
n integer number: short, unsigned short, int, unsigned int,
int64_t, uint64_t, sometimes char if used as a number
int64, uint64, sometimes char if used as a number
d double, float
f flag
hash uint256

+ 0
- 2
src/base58.h View File

@@ -15,8 +15,6 @@
#ifndef BITCOIN_BASE58_H
#define BITCOIN_BASE58_H

#include <stdint.h>

#include <string>
#include <vector>
#include "bignum.h"

+ 5
- 7
src/bignum.h View File

@@ -5,8 +5,6 @@
#ifndef BITCOIN_BIGNUM_H
#define BITCOIN_BIGNUM_H

#include <stdint.h>

#include <stdexcept>
#include <vector>
#include <openssl/bn.h>
@@ -83,12 +81,12 @@ public:
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
CBigNum(int64_t n) { BN_init(this); setint64(n); }
CBigNum(int64 n) { BN_init(this); setint64(n); }
CBigNum(unsigned char n) { BN_init(this); setulong(n); }
CBigNum(unsigned short n) { BN_init(this); setulong(n); }
CBigNum(unsigned int n) { BN_init(this); setulong(n); }
CBigNum(unsigned long n) { BN_init(this); setulong(n); }
CBigNum(uint64_t n) { BN_init(this); setuint64(n); }
CBigNum(uint64 n) { BN_init(this); setuint64(n); }
explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }

explicit CBigNum(const std::vector<unsigned char>& vch)
@@ -122,12 +120,12 @@ public:
return (n > std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
}

void setint64(int64_t n)
void setint64(int64 n)
{
unsigned char pch[sizeof(n) + 6];
unsigned char* p = pch + 4;
bool fNegative = false;
if (n < (int64_t)0)
if (n < (int64)0)
{
n = -n;
fNegative = true;
@@ -157,7 +155,7 @@ public:
BN_mpi2bn(pch, p - pch, this);
}

void setuint64(uint64_t n)
void setuint64(uint64 n)
{
unsigned char pch[sizeof(n) + 6];
unsigned char* p = pch + 4;

+ 51
- 53
src/bitcoinrpc.cpp View File

@@ -3,8 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "headers.h"
#include "db.h"
#include "net.h"
@@ -42,7 +40,7 @@ extern map<string, rpcfn_type> mapCallTable;

static std::string strRPCUserColonPass;

static int64_t nWalletUnlockTime;
static int64 nWalletUnlockTime;
static CCriticalSection cs_nWalletUnlockTime;

extern Value dumpprivkey(const Array& params, bool fHelp);
@@ -75,18 +73,18 @@ void PrintConsole(const std::string &format, ...)
}


int64_t AmountFromValue(const Value& value)
int64 AmountFromValue(const Value& value)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > 21000000.0)
throw JSONRPCError(-3, "Invalid amount");
int64_t nAmount = roundint64(dAmount * COIN);
int64 nAmount = roundint64(dAmount * COIN);
if (!MoneyRange(nAmount))
throw JSONRPCError(-3, "Invalid amount");
return nAmount;
}

Value ValueFromAmount(int64_t amount)
Value ValueFromAmount(int64 amount)
{
return (double)amount / (double)COIN;
}
@@ -501,7 +499,7 @@ Value settxfee(const Array& params, bool fHelp)
"<amount> is a real and is rounded to the nearest 0.00000001");

// Amount
int64_t nAmount = 0;
int64 nAmount = 0;
if (params[0].get_real() != 0.0)
nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts

@@ -526,7 +524,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
throw JSONRPCError(-5, "Invalid bitcoin address");

// Amount
int64_t nAmount = AmountFromValue(params[1]);
int64 nAmount = AmountFromValue(params[1]);

// Wallet comments
CWalletTx wtx;
@@ -634,7 +632,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
nMinDepth = params[1].get_int();

// Tally
int64_t nAmount = 0;
int64 nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
@@ -681,7 +679,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
GetAccountAddresses(strAccount, setAddress);

// Tally
int64_t nAmount = 0;
int64 nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
@@ -701,9 +699,9 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
}


int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth)
int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth)
{
int64_t nBalance = 0;
int64 nBalance = 0;

// Tally wallet transactions
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
@@ -712,7 +710,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
if (!wtx.IsFinal())
continue;

int64_t nGenerated, nReceived, nSent, nFee;
int64 nGenerated, nReceived, nSent, nFee;
wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee);

if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
@@ -726,7 +724,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
return nBalance;
}

int64_t GetAccountBalance(const string& strAccount, int nMinDepth)
int64 GetAccountBalance(const string& strAccount, int nMinDepth)
{
CWalletDB walletdb(pwalletMain->strWalletFile);
return GetAccountBalance(walletdb, strAccount, nMinDepth);
@@ -752,23 +750,23 @@ Value getbalance(const Array& params, bool fHelp)
// Calculate total balance a different way from GetBalance()
// (GetBalance() sums up all unspent TxOuts)
// getbalance and getbalance '*' should always return the same number.
int64_t nBalance = 0;
int64 nBalance = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (!wtx.IsFinal())
continue;

int64_t allGeneratedImmature, allGeneratedMature, allFee;
int64 allGeneratedImmature, allGeneratedMature, allFee;
allGeneratedImmature = allGeneratedMature = allFee = 0;
string strSentAccount;
list<pair<CBitcoinAddress, int64_t> > listReceived;
list<pair<CBitcoinAddress, int64_t> > listSent;
list<pair<CBitcoinAddress, int64> > listReceived;
list<pair<CBitcoinAddress, int64> > listSent;
wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);
if (wtx.GetDepthInMainChain() >= nMinDepth)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listReceived)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listReceived)
nBalance += r.second;
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listSent)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listSent)
nBalance -= r.second;
nBalance -= allFee;
nBalance += allGeneratedMature;
@@ -778,7 +776,7 @@ Value getbalance(const Array& params, bool fHelp)

string strAccount = AccountFromValue(params[0]);

int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);

return ValueFromAmount(nBalance);
}
@@ -793,7 +791,7 @@ Value movecmd(const Array& params, bool fHelp)

string strFrom = AccountFromValue(params[0]);
string strTo = AccountFromValue(params[1]);
int64_t nAmount = AmountFromValue(params[2]);
int64 nAmount = AmountFromValue(params[2]);
if (params.size() > 3)
// unused parameter, used to be nMinDepth, keep type-checking it though
(void)params[3].get_int();
@@ -804,7 +802,7 @@ Value movecmd(const Array& params, bool fHelp)
CWalletDB walletdb(pwalletMain->strWalletFile);
walletdb.TxnBegin();

int64_t nNow = GetAdjustedTime();
int64 nNow = GetAdjustedTime();

// Debit
CAccountingEntry debit;
@@ -846,7 +844,7 @@ Value sendfrom(const Array& params, bool fHelp)
CBitcoinAddress address(params[1].get_str());
if (!address.IsValid())
throw JSONRPCError(-5, "Invalid bitcoin address");
int64_t nAmount = AmountFromValue(params[2]);
int64 nAmount = AmountFromValue(params[2]);
int nMinDepth = 1;
if (params.size() > 3)
nMinDepth = params[3].get_int();
@@ -862,7 +860,7 @@ Value sendfrom(const Array& params, bool fHelp)
throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");

// Check funds
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
if (nAmount > nBalance)
throw JSONRPCError(-6, "Account has insufficient funds");

@@ -899,9 +897,9 @@ Value sendmany(const Array& params, bool fHelp)
wtx.mapValue["comment"] = params[3].get_str();

set<CBitcoinAddress> setAddress;
vector<pair<CScript, int64_t> > vecSend;
vector<pair<CScript, int64> > vecSend;

int64_t totalAmount = 0;
int64 totalAmount = 0;
BOOST_FOREACH(const Pair& s, sendTo)
{
CBitcoinAddress address(s.name_);
@@ -914,7 +912,7 @@ Value sendmany(const Array& params, bool fHelp)

CScript scriptPubKey;
scriptPubKey.SetBitcoinAddress(address);
int64_t nAmount = AmountFromValue(s.value_);
int64 nAmount = AmountFromValue(s.value_);
totalAmount += nAmount;

vecSend.push_back(make_pair(scriptPubKey, nAmount));
@@ -924,13 +922,13 @@ Value sendmany(const Array& params, bool fHelp)
throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");

// Check funds
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
if (totalAmount > nBalance)
throw JSONRPCError(-6, "Account has insufficient funds");

// Send
CReserveKey keyChange(pwalletMain);
int64_t nFeeRequired = 0;
int64 nFeeRequired = 0;
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired);
if (!fCreated)
{
@@ -1009,7 +1007,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)

struct tallyitem
{
int64_t nAmount;
int64 nAmount;
int nConf;
tallyitem()
{
@@ -1065,7 +1063,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
if (it == mapTally.end() && !fIncludeEmpty)
continue;

int64_t nAmount = 0;
int64 nAmount = 0;
int nConf = std::numeric_limits<int>::max();
if (it != mapTally.end())
{
@@ -1094,7 +1092,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
{
for (map<string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it)
{
int64_t nAmount = (*it).second.nAmount;
int64 nAmount = (*it).second.nAmount;
int nConf = (*it).second.nConf;
Object obj;
obj.push_back(Pair("account", (*it).first));
@@ -1140,10 +1138,10 @@ Value listreceivedbyaccount(const Array& params, bool fHelp)

void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret)
{
int64_t nGeneratedImmature, nGeneratedMature, nFee;
int64 nGeneratedImmature, nGeneratedMature, nFee;
string strSentAccount;
list<pair<CBitcoinAddress, int64_t> > listReceived;
list<pair<CBitcoinAddress, int64_t> > listSent;
list<pair<CBitcoinAddress, int64> > listReceived;
list<pair<CBitcoinAddress, int64> > listSent;
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);

bool fAllAccounts = (strAccount == string("*"));
@@ -1171,7 +1169,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
// Sent
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
{
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& s, listSent)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& s, listSent)
{
Object entry;
entry.push_back(Pair("account", strSentAccount));
@@ -1187,7 +1185,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe

// Received
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& r, listReceived)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& r, listReceived)
{
string account;
if (pwalletMain->mapAddressBook.count(r.first))
@@ -1245,7 +1243,7 @@ Value listtransactions(const Array& params, bool fHelp)

// Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap:
typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
typedef multimap<int64_t, TxPair > TxItems;
typedef multimap<int64, TxPair > TxItems;
TxItems txByTime;

for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
@@ -1299,7 +1297,7 @@ Value listaccounts(const Array& params, bool fHelp)
if (params.size() > 0)
nMinDepth = params[0].get_int();

map<string, int64_t> mapAccountBalances;
map<string, int64> mapAccountBalances;
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& entry, pwalletMain->mapAddressBook) {
if (pwalletMain->HaveKey(entry.first)) // This address belongs to me
mapAccountBalances[entry.second] = 0;
@@ -1308,18 +1306,18 @@ Value listaccounts(const Array& params, bool fHelp)
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
int64_t nGeneratedImmature, nGeneratedMature, nFee;
int64 nGeneratedImmature, nGeneratedMature, nFee;
string strSentAccount;
list<pair<CBitcoinAddress, int64_t> > listReceived;
list<pair<CBitcoinAddress, int64_t> > listSent;
list<pair<CBitcoinAddress, int64> > listReceived;
list<pair<CBitcoinAddress, int64> > listSent;
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);
mapAccountBalances[strSentAccount] -= nFee;
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& s, listSent)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& s, listSent)
mapAccountBalances[strSentAccount] -= s.second;
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
mapAccountBalances[""] += nGeneratedMature;
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& r, listReceived)
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& r, listReceived)
if (pwalletMain->mapAddressBook.count(r.first))
mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second;
else
@@ -1333,7 +1331,7 @@ Value listaccounts(const Array& params, bool fHelp)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;

Object ret;
BOOST_FOREACH(const PAIRTYPE(string, int64_t)& accountBalance, mapAccountBalances) {
BOOST_FOREACH(const PAIRTYPE(string, int64)& accountBalance, mapAccountBalances) {
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
}
return ret;
@@ -1419,10 +1417,10 @@ Value gettransaction(const Array& params, bool fHelp)
throw JSONRPCError(-5, "Invalid or non-wallet transaction id");
const CWalletTx& wtx = pwalletMain->mapWallet[hash];

int64_t nCredit = wtx.GetCredit();
int64_t nDebit = wtx.GetDebit();
int64_t nNet = nCredit - nDebit;
int64_t nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0);
int64 nCredit = wtx.GetCredit();
int64 nDebit = wtx.GetDebit();
int64 nNet = nCredit - nDebit;
int64 nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0);

entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
if (wtx.IsFromMe())
@@ -1482,7 +1480,7 @@ void ThreadTopUpKeyPool(void* parg)

void ThreadCleanWalletPassphrase(void* parg)
{
int64_t nMyWakeTime = GetTime() + *((int*)parg);
int64 nMyWakeTime = GetTime() + *((int*)parg);

if (nWalletUnlockTime == 0)
{
@@ -1729,7 +1727,7 @@ Value getwork(const Array& params, bool fHelp)
// Update block
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
static int64_t nStart;
static int64 nStart;
static CBlock* pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
@@ -1833,7 +1831,7 @@ Value getmemorypool(const Array& params, bool fHelp)
// Update block
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
static int64_t nStart;
static int64 nStart;
static CBlock* pblock;
if (pindexPrev != pindexBest ||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5))

+ 1
- 3
src/checkpoints.cpp View File

@@ -2,8 +2,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <boost/foreach.hpp>

@@ -54,7 +52,7 @@ namespace Checkpoints
{
if (fTestNet) return NULL;

int64_t nResult;
int64 nResult;
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
{
const uint256& hash = i.second;

+ 8
- 10
src/db.cpp View File

@@ -3,8 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "headers.h"
#include "db.h"
#include "net.h"
@@ -16,7 +14,7 @@ using namespace boost;


unsigned int nWalletDBUpdated;
uint64_t nAccountingEntryNumber = 0;
uint64 nAccountingEntryNumber = 0;



@@ -707,12 +705,12 @@ bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry)
return Write(boost::make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry);
}

int64_t CWalletDB::GetAccountCreditDebit(const string& strAccount)
int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
{
list<CAccountingEntry> entries;
ListAccountCreditDebit(strAccount, entries);

int64_t nCreditDebit = 0;
int64 nCreditDebit = 0;
BOOST_FOREACH (const CAccountingEntry& entry, entries)
nCreditDebit += entry.nCreditDebit;

@@ -732,7 +730,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
// Read next record
CDataStream ssKey;
if (fFlags == DB_SET_RANGE)
ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64_t(0));
ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));
CDataStream ssValue;
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
fFlags = DB_NEXT;
@@ -848,7 +846,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
{
string strAccount;
ssKey >> strAccount;
uint64_t nNumber;
uint64 nNumber;
ssKey >> nNumber;
if (nNumber > nAccountingEntryNumber)
nAccountingEntryNumber = nNumber;
@@ -901,7 +899,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
}
else if (strType == "pool")
{
int64_t nIndex;
int64 nIndex;
ssKey >> nIndex;
pwallet->setKeyPool.insert(nIndex);
}
@@ -991,7 +989,7 @@ void ThreadFlushWalletDB(void* parg)

unsigned int nLastSeen = nWalletDBUpdated;
unsigned int nLastFlushed = nWalletDBUpdated;
int64_t nLastWalletUpdate = GetTime();
int64 nLastWalletUpdate = GetTime();
while (!fShutdown)
{
Sleep(500);
@@ -1023,7 +1021,7 @@ void ThreadFlushWalletDB(void* parg)
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("Flushing wallet.dat\n");
nLastFlushed = nWalletDBUpdated;
int64_t nStart = GetTimeMillis();
int64 nStart = GetTimeMillis();

// Flush wallet.dat so it's self contained
CloseDb(strFile);

+ 5
- 7
src/db.h View File

@@ -5,8 +5,6 @@
#ifndef BITCOIN_DB_H
#define BITCOIN_DB_H

#include <stdint.h>

#include "key.h"

#include <map>
@@ -319,7 +317,7 @@ bool LoadAddresses();
class CKeyPool
{
public:
int64_t nTime;
int64 nTime;
std::vector<unsigned char> vchPubKey;

CKeyPool()
@@ -458,18 +456,18 @@ public:
return Write(std::string("defaultkey"), vchPubKey);
}

bool ReadPool(int64_t nPool, CKeyPool& keypool)
bool ReadPool(int64 nPool, CKeyPool& keypool)
{
return Read(std::make_pair(std::string("pool"), nPool), keypool);
}

bool WritePool(int64_t nPool, const CKeyPool& keypool)
bool WritePool(int64 nPool, const CKeyPool& keypool)
{
nWalletDBUpdated++;
return Write(std::make_pair(std::string("pool"), nPool), keypool);
}

bool ErasePool(int64_t nPool)
bool ErasePool(int64 nPool)
{
nWalletDBUpdated++;
return Erase(std::make_pair(std::string("pool"), nPool));
@@ -491,7 +489,7 @@ public:
bool ReadAccount(const std::string& strAccount, CAccount& account);
bool WriteAccount(const std::string& strAccount, const CAccount& account);
bool WriteAccountingEntry(const CAccountingEntry& acentry);
int64_t GetAccountCreditDebit(const std::string& strAccount);
int64 GetAccountCreditDebit(const std::string& strAccount);
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);

int LoadWallet(CWallet* pwallet);

+ 1
- 4
src/init.cpp View File

@@ -2,9 +2,6 @@
// Copyright (c) 2011 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "headers.h"
#include "db.h"
#include "bitcoinrpc.h"
@@ -352,7 +349,7 @@ bool AppInit2(int argc, char* argv[])
//
if (fDaemon)
fprintf(stdout, "bitcoin server starting\n");
int64_t nStart;
int64 nStart;

InitMessage(_("Loading addresses..."));
printf("Loading addresses...\n");

+ 1
- 3
src/irc.cpp View File

@@ -3,8 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "headers.h"
#include "irc.h"
#include "net.h"
@@ -356,7 +354,7 @@ void ThreadIRCSeed2(void* parg)
Send(hSocket, strprintf("WHO #bitcoin%02d\r", channel_number).c_str());
}

int64_t nStart = GetTime();
int64 nStart = GetTime();
string strLine;
strLine.reserve(10000);
while (!fShutdown && RecvLineIRC(hSocket, strLine))

+ 0
- 2
src/keystore.cpp View File

@@ -3,8 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "headers.h"
#include "crypter.h"
#include "db.h"

+ 0
- 2
src/keystore.h View File

@@ -5,8 +5,6 @@
#ifndef BITCOIN_KEYSTORE_H
#define BITCOIN_KEYSTORE_H

#include <stdint.h>

#include "crypter.h"
#include "script.h"


+ 43
- 46
src/main.cpp View File

@@ -2,9 +2,6 @@
// Copyright (c) 2011 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "headers.h"
#include "checkpoints.h"
#include "db.h"
@@ -45,7 +42,7 @@ CBigNum bnBestChainWork = 0;
CBigNum bnBestInvalidWork = 0;
uint256 hashBestChain = 0;
CBlockIndex* pindexBest = NULL;
int64_t nTimeBestReceived = 0;
int64 nTimeBestReceived = 0;

CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have

@@ -57,11 +54,11 @@ multimap<uint256, CDataStream*> mapOrphanTransactionsByPrev;


double dHashesPerSec;
int64_t nHPSTimerStart;
int64 nHPSTimerStart;

// Settings
int fGenerateBitcoins = false;
int64_t nTransactionFee = 0;
int64 nTransactionFee = 0;
int fLimitProcessors = false;
int nLimitProcessors = 1;
int fMinimizeToTray = true;
@@ -381,7 +378,7 @@ bool CTransaction::CheckTransaction() const
return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));

// Check for negative or overflow output values
int64_t nValueOut = 0;
int64 nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, vout)
{
if (txout.nValue < 0)
@@ -430,7 +427,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
return DoS(100, error("AcceptToMemoryPool() : coinbase as individual tx"));

// To help v0.1.5 clients who would see it as a negative number
if ((int64_t)nLockTime > std::numeric_limits<int>::max())
if ((int64)nLockTime > std::numeric_limits<int>::max())
return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet");

// Rather not work on nonstandard transactions (unless -testnet)
@@ -490,7 +487,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
return error("AcceptToMemoryPool() : nonstandard transaction input");

// Check against previous transactions
int64_t nFees = 0;
int64 nFees = 0;
int nSigOps = 0;
if (!ConnectInputs(mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, nSigOps))
{
@@ -516,8 +513,8 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
{
static CCriticalSection cs;
static double dFreeCount;
static int64_t nLastTime;
int64_t nNow = GetTime();
static int64 nLastTime;
int64 nNow = GetTime();

CRITICAL_BLOCK(cs)
{
@@ -728,9 +725,9 @@ uint256 static GetOrphanRoot(const CBlock* pblock)
return pblock->GetHash();
}

int64_t static GetBlockValue(int nHeight, int64_t nFees)
int64 static GetBlockValue(int nHeight, int64 nFees)
{
int64_t nSubsidy = 50 * COIN;
int64 nSubsidy = 50 * COIN;

// Subsidy is cut in half every 4 years
nSubsidy >>= (nHeight / 210000);
@@ -738,15 +735,15 @@ int64_t static GetBlockValue(int nHeight, int64_t nFees)
return nSubsidy + nFees;
}

static const int64_t nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
static const int64_t nTargetSpacing = 10 * 60;
static const int64_t nInterval = nTargetTimespan / nTargetSpacing;
static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
static const int64 nTargetSpacing = 10 * 60;
static const int64 nInterval = nTargetTimespan / nTargetSpacing;

//
// minimum amount of work that could possibly be required nTime after
// minimum work required was nBase
//
unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime)
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
{
CBigNum bnResult;
bnResult.SetCompact(nBase);
@@ -780,7 +777,7 @@ unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast)
assert(pindexFirst);

// Limit adjustment step
int64_t nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
if (nActualTimespan < nTargetTimespan/4)
nActualTimespan = nTargetTimespan/4;
@@ -831,7 +828,7 @@ bool IsInitialBlockDownload()
{
if (pindexBest == NULL || nBestHeight < (Checkpoints::GetTotalBlocksEstimate()-nInitialBlockThreshold))
return true;
static int64_t nLastUpdate;
static int64 nLastUpdate;
static CBlockIndex* pindexLastBest;
if (pindexBest != pindexLastBest)
{
@@ -954,7 +951,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes

bool CTransaction::ConnectInputs(map<uint256, pair<CTxIndex, CTransaction> > inputs,
map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,
CBlockIndex* pindexBlock, int64_t& nFees, bool fBlock, bool fMiner, int& nSigOpsRet, int64_t nMinFee)
CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int& nSigOpsRet, int64 nMinFee)
{
// Take over previous transactions' spent pointers
// fBlock is true when this is called from AcceptBlock when a new best-block is added to the blockchain
@@ -962,7 +959,7 @@ bool CTransaction::ConnectInputs(map<uint256, pair<CTxIndex, CTransaction> > inp
// ... both are false when called from CTransaction::AcceptToMemoryPool
if (!IsCoinBase())
{
int64_t nValueIn = 0;
int64 nValueIn = 0;
for (int i = 0; i < vin.size(); i++)
{
COutPoint prevout = vin[i].prevout;
@@ -992,7 +989,7 @@ bool CTransaction::ConnectInputs(map<uint256, pair<CTxIndex, CTransaction> > inp
// To avoid being on the short end of a block-chain split,
// interpret OP_EVAL as a NO_OP until blocks with timestamps
// after opevaltime:
int64_t nEvalSwitchTime = GetArg("opevaltime", 1328054400); // Feb 1, 2012
int64 nEvalSwitchTime = GetArg("opevaltime", 1328054400); // Feb 1, 2012
fStrictOpEval = (pindexBlock->nTime >= nEvalSwitchTime);
}
// if !fBlock, then always be strict-- don't accept
@@ -1030,7 +1027,7 @@ bool CTransaction::ConnectInputs(map<uint256, pair<CTxIndex, CTransaction> > inp
return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));

// Tally transaction fees
int64_t nTxFee = nValueIn - GetValueOut();
int64 nTxFee = nValueIn - GetValueOut();
if (nTxFee < 0)
return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
if (nTxFee < nMinFee)
@@ -1063,7 +1060,7 @@ bool CTransaction::ClientConnectInputs()
// Take over previous transactions' spent pointers
CRITICAL_BLOCK(cs_mapTransactions)
{
int64_t nValueIn = 0;
int64 nValueIn = 0;
for (int i = 0; i < vin.size(); i++)
{
// Get prev tx from single transactions in memory
@@ -1134,7 +1131,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size());

map<uint256, CTxIndex> mapQueuedChanges;
int64_t nFees = 0;
int64 nFees = 0;
int nSigOps = 0;
BOOST_FOREACH(CTransaction& tx, vtx)
{
@@ -1502,7 +1499,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
if (pcheckpoint && pblock->hashPrevBlock != hashBestChain)
{
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
if (deltaTime < 0)
{
pfrom->Misbehaving(100);
@@ -1568,12 +1565,12 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)



bool CheckDiskSpace(uint64_t nAdditionalBytes)
bool CheckDiskSpace(uint64 nAdditionalBytes)
{
uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available;
uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available;

// Check for 15MB because database could create another 10MB log file at any time
if (nFreeBytesAvailable < (uint64_t)15000000 + nAdditionalBytes)
if (nFreeBytesAvailable < (uint64)15000000 + nAdditionalBytes)
{
fShutdown = true;
string strMessage = _("Warning: Disk space is low ");
@@ -1948,10 +1945,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return false;
}

int64_t nTime;
int64 nTime;
CAddress addrMe;
CAddress addrFrom;
uint64_t nNonce = 1;
uint64 nNonce = 1;
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
if (pfrom->nVersion == 10300)
pfrom->nVersion = 300;
@@ -2062,8 +2059,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// Store the new addresses
CAddrDB addrDB;
addrDB.TxnBegin();
int64_t nNow = GetAdjustedTime();
int64_t nSince = nNow - 10 * 60;
int64 nNow = GetAdjustedTime();
int64 nSince = nNow - 10 * 60;
BOOST_FOREACH(CAddress& addr, vAddr)
{
if (fShutdown)
@@ -2085,7 +2082,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
static uint256 hashSalt;
if (hashSalt == 0)
RAND_bytes((unsigned char*)&hashSalt, sizeof(hashSalt));
uint256 hashRand = hashSalt ^ (((int64_t)addr.ip)<<32) ^ ((GetTime()+addr.ip)/(24*60*60));
uint256 hashRand = hashSalt ^ (((int64)addr.ip)<<32) ^ ((GetTime()+addr.ip)/(24*60*60));
hashRand = Hash(BEGIN(hashRand), END(hashRand));
multimap<uint256, CNode*> mapMix;
BOOST_FOREACH(CNode* pnode, vNodes)
@@ -2347,7 +2344,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{
// Nodes rebroadcast an addr every 24 hours
pfrom->vAddrToSend.clear();
int64_t nSince = GetAdjustedTime() - 3 * 60 * 60; // in the last 3 hours
int64 nSince = GetAdjustedTime() - 3 * 60 * 60; // in the last 3 hours
CRITICAL_BLOCK(cs_mapAddresses)
{
unsigned int nCount = 0;
@@ -2585,7 +2582,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
ResendWalletTransactions();

// Address refresh broadcast
static int64_t nLastRebroadcast;
static int64 nLastRebroadcast;
if (GetTime() - nLastRebroadcast > 24 * 60 * 60)
{
nLastRebroadcast = GetTime();
@@ -2608,7 +2605,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
}

// Clear out old addresses periodically so it's not too much work at once
static int64_t nLastClear;
static int64 nLastClear;
if (nLastClear == 0)
nLastClear = GetTime();
if (GetTime() - nLastClear > 10 * 60 && vNodes.size() >= 3)
@@ -2617,7 +2614,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
CRITICAL_BLOCK(cs_mapAddresses)
{
CAddrDB addrdb;
int64_t nSince = GetAdjustedTime() - 14 * 24 * 60 * 60;
int64 nSince = GetAdjustedTime() - 14 * 24 * 60 * 60;
for (map<vector<unsigned char>, CAddress>::iterator mi = mapAddresses.begin();
mi != mapAddresses.end();)
{
@@ -2725,7 +2722,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
// Message: getdata
//
vector<CInv> vGetData;
int64_t nNow = GetTime() * 1000000;
int64 nNow = GetTime() * 1000000;
CTxDB txdb("r");
while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)
{
@@ -2880,7 +2877,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
pblock->vtx.push_back(txNew);

// Collect memory pool transactions into the block
int64_t nFees = 0;
int64 nFees = 0;
CRITICAL_BLOCK(cs_main)
CRITICAL_BLOCK(cs_mapTransactions)
{
@@ -2916,7 +2913,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
porphan->setDependsOn.insert(txin.prevout.hash);
continue;
}
int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;

// Read block header
int nConf = txindex.GetDepthInMainChain();
@@ -2946,7 +2943,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)

// Collect transactions into block
map<uint256, CTxIndex> mapTestPool;
uint64_t nBlockSize = 1000;
uint64 nBlockSize = 1000;
int nBlockSigOps = 100;
while (!mapPriority.empty())
{
@@ -2962,7 +2959,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)

// Transaction fee required depends on block size
bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
int64_t nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, GMF_BLOCK);
int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, GMF_BLOCK);

// Connecting shouldn't fail due to dependency on other memory pool transactions
// because we're already processing them in order of dependency
@@ -3172,7 +3169,7 @@ void static BitcoinMiner(CWallet *pwallet)
//
// Search
//
int64_t nStart = GetTime();
int64 nStart = GetTime();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
uint256 hashbuf[2];
uint256& hash = *alignup<16>(hashbuf);
@@ -3205,7 +3202,7 @@ void static BitcoinMiner(CWallet *pwallet)
}

// Meter hashes/sec
static int64_t nHashCounter;
static int64 nHashCounter;
if (nHPSTimerStart == 0)
{
nHPSTimerStart = GetTimeMillis();
@@ -3225,7 +3222,7 @@ void static BitcoinMiner(CWallet *pwallet)
nHashCounter = 0;
string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);
UIThreadCall(boost::bind(CalledSetStatusBar, strStatus, 0));
static int64_t nLogTime;
static int64 nLogTime;
if (GetTime() - nLogTime > 30 * 60)
{
nLogTime = GetTime();

+ 32
- 34
src/main.h View File

@@ -5,8 +5,6 @@
#ifndef BITCOIN_MAIN_H
#define BITCOIN_MAIN_H

#include <stdint.h>

#include "bignum.h"
#include "net.h"
#include "key.h"
@@ -36,12 +34,12 @@ extern const std::string CLIENT_NAME;
static const unsigned int MAX_BLOCK_SIZE = 1000000;
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
static const int64_t COIN = 100000000;
static const int64_t CENT = 1000000;
static const int64_t MIN_TX_FEE = 50000;
static const int64_t MIN_RELAY_TX_FEE = 10000;
static const int64_t MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
static const int64 COIN = 100000000;
static const int64 CENT = 1000000;
static const int64 MIN_TX_FEE = 50000;
static const int64 MIN_RELAY_TX_FEE = 10000;
static const int64 MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
static const int COINBASE_MATURITY = 100;
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
static const int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
@@ -67,14 +65,14 @@ extern uint256 hashBestChain;
extern CBlockIndex* pindexBest;
extern unsigned int nTransactionsUpdated;
extern double dHashesPerSec;
extern int64_t nHPSTimerStart;
extern int64_t nTimeBestReceived;
extern int64 nHPSTimerStart;
extern int64 nTimeBestReceived;
extern CCriticalSection cs_setpwalletRegistered;
extern std::set<CWallet*> setpwalletRegistered;

// Settings
extern int fGenerateBitcoins;
extern int64_t nTransactionFee;
extern int64 nTransactionFee;
extern int fLimitProcessors;
extern int nLimitProcessors;
extern int fMinimizeToTray;
@@ -92,7 +90,7 @@ class CTxIndex;
void RegisterWallet(CWallet* pwalletIn);
void UnregisterWallet(CWallet* pwalletIn);
bool ProcessBlock(CNode* pfrom, CBlock* pblock);
bool CheckDiskSpace(uint64_t nAdditionalBytes=0);
bool CheckDiskSpace(uint64 nAdditionalBytes=0);
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
FILE* AppendBlockFile(unsigned int& nFileRet);
bool LoadBlockIndex(bool fAllowNew=true);
@@ -105,7 +103,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1);
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime);
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime);
int GetNumBlocksOfPeers();
bool IsInitialBlockDownload();
std::string GetWarnings(std::string strFor);
@@ -332,7 +330,7 @@ public:
class CTxOut
{
public:
int64_t nValue;
int64 nValue;
CScript scriptPubKey;

CTxOut()
@@ -340,7 +338,7 @@ public:
SetNull();
}

CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
CTxOut(int64 nValueIn, CScript scriptPubKeyIn)
{
nValue = nValueIn;
scriptPubKey = scriptPubKeyIn;
@@ -451,7 +449,7 @@ public:
return SerializeHash(*this);
}

bool IsFinal(int nBlockHeight=0, int64_t nBlockTime=0) const
bool IsFinal(int nBlockHeight=0, int64 nBlockTime=0) const
{
// Time based nLockTime implemented in 0.1.6
if (nLockTime == 0)
@@ -460,7 +458,7 @@ public:
nBlockHeight = nBestHeight;
if (nBlockTime == 0)
nBlockTime = GetAdjustedTime();
if ((int64_t)nLockTime < (nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
if ((int64)nLockTime < (nLockTime < LOCKTIME_THRESHOLD ? (int64)nBlockHeight : nBlockTime))
return true;
BOOST_FOREACH(const CTxIn& txin, vin)
if (!txin.IsFinal())
@@ -505,9 +503,9 @@ public:
bool IsStandard() const;
bool AreInputsStandard(std::map<uint256, std::pair<CTxIndex, CTransaction> > mapInputs) const;

int64_t GetValueOut() const
int64 GetValueOut() const
{
int64_t nValueOut = 0;
int64 nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, vout)
{
nValueOut += txout.nValue;
@@ -524,14 +522,14 @@ public:
return dPriority > COIN * 144 / 250;
}

int64_t GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, enum GetMinFee_mode mode=GMF_BLOCK) const
int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, enum GetMinFee_mode mode=GMF_BLOCK) const
{
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
int64_t nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE;
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE;

unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);
unsigned int nNewBlockSize = nBlockSize + nBytes;
int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee;
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;

if (fAllowFree)
{
@@ -637,7 +635,7 @@ public:
bool fBlock, bool fMiner, std::map<uint256, std::pair<CTxIndex, CTransaction> >& inputsRet);
bool ConnectInputs(std::map<uint256, std::pair<CTxIndex, CTransaction> > inputs,
std::map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,
CBlockIndex* pindexBlock, int64_t& nFees, bool fBlock, bool fMiner, int& nSigOpsRet, int64_t nMinFee=0);
CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int& nSigOpsRet, int64 nMinFee=0);
bool ClientConnectInputs();
bool CheckTransaction() const;
bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
@@ -842,9 +840,9 @@ public:
return Hash(BEGIN(nVersion), END(nNonce));
}

int64_t GetBlockTime() const
int64 GetBlockTime() const
{
return (int64_t)nTime;
return (int64)nTime;
}


@@ -1068,9 +1066,9 @@ public:
return *phashBlock;
}

int64_t GetBlockTime() const
int64 GetBlockTime() const
{
return (int64_t)nTime;
return (int64)nTime;
}

CBigNum GetBlockWork() const
@@ -1109,11 +1107,11 @@ public:

enum { nMedianTimeSpan=11 };

int64_t GetMedianTimePast() const
int64 GetMedianTimePast() const
{
int64_t pmedian[nMedianTimeSpan];
int64_t* pbegin = &pmedian[nMedianTimeSpan];
int64_t* pend = &pmedian[nMedianTimeSpan];
int64 pmedian[nMedianTimeSpan];
int64* pbegin = &pmedian[nMedianTimeSpan];
int64* pend = &pmedian[nMedianTimeSpan];

const CBlockIndex* pindex = this;
for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
@@ -1123,7 +1121,7 @@ public:
return pbegin[(pend - pbegin)/2];
}

int64_t GetMedianTime() const
int64 GetMedianTime() const
{
const CBlockIndex* pindex = this;
for (int i = 0; i < nMedianTimeSpan/2; i++)
@@ -1377,8 +1375,8 @@ class CUnsignedAlert
{
public:
int nVersion;
int64_t nRelayUntil; // when newer nodes stop relaying to newer nodes
int64_t nExpiration;
int64 nRelayUntil; // when newer nodes stop relaying to newer nodes
int64 nExpiration;
int nID;
int nCancel;
std::set<int> setCancel;

+ 25
- 27
src/net.cpp View File

@@ -3,8 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "headers.h"
#include "irc.h"
#include "db.h"
@@ -46,10 +44,10 @@ bool OpenNetworkConnection(const CAddress& addrConnect);
//
bool fClient = false;
bool fAllowDNS = false;
uint64_t nLocalServices = (fClient ? 0 : NODE_NETWORK);
uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
CAddress addrLocalHost("0.0.0.0", 0, false, nLocalServices);
static CNode* pnodeLocalHost = NULL;
uint64_t nLocalHostNonce = 0;
uint64 nLocalHostNonce = 0;
array<int, 10> vnThreadsRunning;
static SOCKET hListenSocket = INVALID_SOCKET;

@@ -58,9 +56,9 @@ CCriticalSection cs_vNodes;
map<vector<unsigned char>, CAddress> mapAddresses;
CCriticalSection cs_mapAddresses;
map<CInv, CDataStream> mapRelay;
deque<pair<int64_t, CInv> > vRelayExpiration;
deque<pair<int64, CInv> > vRelayExpiration;
CCriticalSection cs_mapRelay;
map<CInv, int64_t> mapAlreadyAskedFor;
map<CInv, int64> mapAlreadyAskedFor;

// Settings
int fUseProxy = false;
@@ -439,13 +437,13 @@ void ThreadGetMyExternalIP(void* parg)



bool AddAddress(CAddress addr, int64_t nTimePenalty, CAddrDB *pAddrDB)
bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB)
{
if (!addr.IsRoutable())
return false;
if (addr.ip == addrLocalHost.ip)
return false;
addr.nTime = max((int64_t)0, (int64_t)addr.nTime - nTimePenalty);
addr.nTime = max((int64)0, (int64)addr.nTime - nTimePenalty);
bool fUpdated = false;
bool fNew = false;
CAddress addrFound = addr;
@@ -471,7 +469,7 @@ bool AddAddress(CAddress addr, int64_t nTimePenalty, CAddrDB *pAddrDB)
fUpdated = true;
}
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
int64 nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
if (addrFound.nTime < addr.nTime - nUpdateInterval)
{
// Periodically update most recently seen time
@@ -505,7 +503,7 @@ void AddressCurrentlyConnected(const CAddress& addr)
if (it != mapAddresses.end())
{
CAddress& addrFound = (*it).second;
int64_t nUpdateInterval = 20 * 60;
int64 nUpdateInterval = 20 * 60;
if (addrFound.nTime < GetAdjustedTime() - nUpdateInterval)
{
// Periodically update most recently seen time
@@ -644,7 +642,7 @@ CNode* FindNode(CAddress addr)
return NULL;
}

CNode* ConnectNode(CAddress addrConnect, int64_t nTimeout)
CNode* ConnectNode(CAddress addrConnect, int64 nTimeout)
{
if (addrConnect.ip == addrLocalHost.ip)
return NULL;
@@ -732,7 +730,7 @@ void CNode::Cleanup()
void CNode::PushVersion()
{
/// when NTP implemented, change to just nTime = GetAdjustedTime()
int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime());
int64 nTime = (fInbound ? GetAdjustedTime() : GetTime());
CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
@@ -744,7 +742,7 @@ void CNode::PushVersion()



std::map<unsigned int, int64_t> CNode::setBanned;
std::map<unsigned int, int64> CNode::setBanned;
CCriticalSection CNode::cs_setBanned;

void CNode::ClearBanned()
@@ -757,10 +755,10 @@ bool CNode::IsBanned(unsigned int ip)
bool fResult = false;
CRITICAL_BLOCK(cs_setBanned)
{
std::map<unsigned int, int64_t>::iterator i = setBanned.find(ip);
std::map<unsigned int, int64>::iterator i = setBanned.find(ip);
if (i != setBanned.end())
{
int64_t t = (*i).second;
int64 t = (*i).second;
if (GetTime() < t)
fResult = true;
}
@@ -779,7 +777,7 @@ bool CNode::Misbehaving(int howmuch)
nMisbehavior += howmuch;
if (nMisbehavior >= GetArg("-banscore", 100))
{
int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
int64 banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
CRITICAL_BLOCK(cs_setBanned)
if (setBanned[addr.ip] < banTime)
setBanned[addr.ip] = banTime;
@@ -1405,7 +1403,7 @@ void ThreadOpenConnections2(void* parg)
// Connect to specific addresses
if (mapArgs.count("-connect"))
{
for (int64_t nLoop = 0;; nLoop++)
for (int64 nLoop = 0;; nLoop++)
{
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
{
@@ -1439,7 +1437,7 @@ void ThreadOpenConnections2(void* parg)
}

// Initiate network connections
int64_t nStart = GetTime();
int64 nStart = GetTime();
loop
{
// Limit outbound connections
@@ -1476,7 +1474,7 @@ void ThreadOpenConnections2(void* parg)
// 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_t nOneWeek = 7*24*60*60;
const int64 nOneWeek = 7*24*60*60;
CAddress addr;
addr.ip = pnSeed[i];
addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
@@ -1490,7 +1488,7 @@ void ThreadOpenConnections2(void* parg)
// Choose an address to connect to based on most recently seen
//
CAddress addrConnect;
int64_t nBest = std::numeric_limits<int64_t>::min();
int64 nBest = std::numeric_limits<int64>::min();

// Only connect to one address per a.b.?.? range.
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
@@ -1499,7 +1497,7 @@ void ThreadOpenConnections2(void* parg)
BOOST_FOREACH(CNode* pnode, vNodes)
setConnected.insert(pnode->addr.ip & 0x0000ffff);

int64_t nANow = GetAdjustedTime();
int64 nANow = GetAdjustedTime();

CRITICAL_BLOCK(cs_mapAddresses)
{
@@ -1508,11 +1506,11 @@ void ThreadOpenConnections2(void* parg)
const CAddress& addr = item.second;
if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff))
continue;
int64_t nSinceLastSeen = nANow - addr.nTime;
int64_t nSinceLastTry = nANow - addr.nLastTry;
int64 nSinceLastSeen = nANow - addr.nTime;
int64 nSinceLastTry = nANow - addr.nLastTry;

// Randomize the order in a deterministic way, putting the standard port first
int64_t nRandomizer = (uint64_t)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60);
int64 nRandomizer = (uint64)(nStart * 4951 + addr.nLastTry * 9567851 + addr.ip * 7789) % (2 * 60 * 60);
if (addr.port != htons(GetDefaultPort()))
nRandomizer += 2 * 60 * 60;

@@ -1526,7 +1524,7 @@ void ThreadOpenConnections2(void* parg)
// 30 days 27 hours
// 90 days 46 hours
// 365 days 93 hours
int64_t nDelay = (int64_t)(3600.0 * sqrt(fabs((double)nSinceLastSeen) / 3600.0) + nRandomizer);
int64 nDelay = (int64)(3600.0 * sqrt(fabs((double)nSinceLastSeen) / 3600.0) + nRandomizer);

// Fast reconnect for one hour after last seen
if (nSinceLastSeen < 60 * 60)
@@ -1547,7 +1545,7 @@ void ThreadOpenConnections2(void* parg)

// If multiple addresses are ready, prioritize by time since
// last seen and time since last tried.
int64_t nScore = min(nSinceLastTry, (int64_t)24 * 60 * 60) - nSinceLastSeen - nRandomizer;
int64 nScore = min(nSinceLastTry, (int64)24 * 60 * 60) - nSinceLastSeen - nRandomizer;
if (nScore > nBest)
{
nBest = nScore;
@@ -1854,7 +1852,7 @@ bool StopNode()
printf("StopNode()\n");
fShutdown = true;
nTransactionsUpdated++;
int64_t nStart = GetTime();
int64 nStart = GetTime();
while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0
#ifdef USE_UPNP
|| vnThreadsRunning[5] > 0

+ 18
- 20
src/net.h View File

@@ -5,8 +5,6 @@
#ifndef BITCOIN_NET_H
#define BITCOIN_NET_H

#include <stdint.h>

#include <deque>
#include <boost/array.hpp>
#include <boost/foreach.hpp>
@@ -35,10 +33,10 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout
bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
bool GetMyExternalIP(unsigned int& ipRet);
bool AddAddress(CAddress addr, int64_t nTimePenalty=0, CAddrDB *pAddrDB=NULL);
bool AddAddress(CAddress addr, int64 nTimePenalty=0, CAddrDB *pAddrDB=NULL);
void AddressCurrentlyConnected(const CAddress& addr);
CNode* FindNode(unsigned int ip);
CNode* ConnectNode(CAddress addrConnect, int64_t nTimeout=0);
CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0);
void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
bool AnySubscribed(unsigned int nChannel);
void MapPort(bool fMapPort);
@@ -76,9 +74,9 @@ public:

extern bool fClient;
extern bool fAllowDNS;
extern uint64_t nLocalServices;
extern uint64 nLocalServices;
extern CAddress addrLocalHost;
extern uint64_t nLocalHostNonce;
extern uint64 nLocalHostNonce;
extern boost::array<int, 10> vnThreadsRunning;

extern std::vector<CNode*> vNodes;
@@ -86,9 +84,9 @@ extern CCriticalSection cs_vNodes;
extern std::map<std::vector<unsigned char>, CAddress> mapAddresses;
extern CCriticalSection cs_mapAddresses;
extern std::map<CInv, CDataStream> mapRelay;
extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration;
extern std::deque<std::pair<int64, CInv> > vRelayExpiration;
extern CCriticalSection cs_mapRelay;
extern std::map<CInv, int64_t> mapAlreadyAskedFor;
extern std::map<CInv, int64> mapAlreadyAskedFor;

// Settings
extern int fUseProxy;
@@ -103,16 +101,16 @@ class CNode
{
public:
// socket
uint64_t nServices;
uint64 nServices;
SOCKET hSocket;
CDataStream vSend;
CDataStream vRecv;
CCriticalSection cs_vSend;
CCriticalSection cs_vRecv;
int64_t nLastSend;
int64_t nLastRecv;
int64_t nLastSendEmpty;
int64_t nTimeConnected;
int64 nLastSend;
int64 nLastRecv;
int64 nLastSendEmpty;
int64 nTimeConnected;
unsigned int nHeaderStart;
unsigned int nMessageStart;
CAddress addr;
@@ -128,12 +126,12 @@ protected:

// Denial-of-service detection/prevention
// Key is ip address, value is banned-until-time
static std::map<unsigned int, int64_t> setBanned;
static std::map<unsigned int, int64> setBanned;
static CCriticalSection cs_setBanned;
int nMisbehavior;

public:
int64_t nReleaseTime;
int64 nReleaseTime;
std::map<uint256, CRequestTracker> mapRequests;
CCriticalSection cs_mapRequests;
uint256 hashContinue;
@@ -151,7 +149,7 @@ public:
std::set<CInv> setInventoryKnown;
std::vector<CInv> vInventoryToSend;
CCriticalSection cs_inventory;
std::multimap<int64_t, CInv> mapAskFor;
std::multimap<int64, CInv> mapAskFor;

// publish and subscription
std::vector<char> vfSubscribe;
@@ -219,7 +217,7 @@ public:
return std::max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);
}

CNode* AddRef(int64_t nTimeout=0)
CNode* AddRef(int64 nTimeout=0)
{
if (nTimeout != 0)
nReleaseTime = std::max(nReleaseTime, GetTime() + nTimeout);
@@ -267,12 +265,12 @@ public:
{
// We're using mapAskFor as a priority queue,
// the key is the earliest time the request can be sent
int64_t& nRequestTime = mapAlreadyAskedFor[inv];
int64& nRequestTime = mapAlreadyAskedFor[inv];
printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);

// Make sure not to reuse time indexes to keep things in the same order
int64_t nNow = (GetTime() - 1) * 1000000;
static int64_t nLastTime;
int64 nNow = (GetTime() - 1) * 1000000;
static int64 nLastTime;
nLastTime = nNow = std::max(nNow, ++nLastTime);

// Each retry is 2 minutes after the last

+ 1
- 3
src/noui.h View File

@@ -5,8 +5,6 @@
#ifndef BITCOIN_NOUI_H
#define BITCOIN_NOUI_H

#include <stdint.h>

#include <string>
#include <boost/function.hpp>
#include "wallet.h"
@@ -52,7 +50,7 @@ inline int ThreadSafeMessageBox(const std::string& message, const std::string& c
return MyMessageBox(message, caption, style, parent, x, y);
}

inline bool ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption, wxWindow* parent)
inline bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
{
return true;
}

+ 6
- 8
src/protocol.cpp View File

@@ -3,8 +3,6 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.

#include <stdint.h>

#include "protocol.h"
#include "util.h"

@@ -84,7 +82,7 @@ CAddress::CAddress()
Init();
}

CAddress::CAddress(unsigned int ipIn, unsigned short portIn, uint64_t nServicesIn)
CAddress::CAddress(unsigned int ipIn, unsigned short portIn, uint64 nServicesIn)
{
Init();
ip = ipIn;
@@ -92,7 +90,7 @@ CAddress::CAddress(unsigned int ipIn, unsigned short portIn, uint64_t nServicesI
nServices = nServicesIn;
}

CAddress::CAddress(const struct sockaddr_in& sockaddr, uint64_t nServicesIn)
CAddress::CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn)
{
Init();
ip = sockaddr.sin_addr.s_addr;
@@ -100,25 +98,25 @@ CAddress::CAddress(const struct sockaddr_in& sockaddr, uint64_t nServicesIn)
nServices = nServicesIn;
}

CAddress::CAddress(const char* pszIn, int portIn, bool fNameLookup, uint64_t nServicesIn)
CAddress::CAddress(const char* pszIn, int portIn, bool fNameLookup, uint64 nServicesIn)
{
Init();
Lookup(pszIn, *this, nServicesIn, fNameLookup, portIn);
}

CAddress::CAddress(const char* pszIn, bool fNameLookup, uint64_t nServicesIn)
CAddress::CAddress(const char* pszIn, bool fNameLookup, uint64 nServicesIn)
{
Init();
Lookup(pszIn, *this, nServicesIn, fNameLookup, 0, true);
}

CAddress::CAddress(std::string strIn, int portIn, bool fNameLookup, uint64_t nServicesIn)
CAddress::CAddress(std::string strIn, int portIn, bool fNameLookup, uint64 nServicesIn)
{
Init();
Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, portIn);
}

CAddress::CAddress(std::string strIn, bool fNameLookup, uint64_t nServicesIn)
CAddress::CAddress(std::string strIn, bool fNameLookup, uint64 nServicesIn)
{
Init();
Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, 0, true);

+ 7
- 9
src/protocol.h View File

@@ -10,8 +10,6 @@
#ifndef __INCLUDED_PROTOCOL_H__
#define __INCLUDED_PROTOCOL_H__

#include <stdint.h>

#include "serialize.h"
#include <string>
#include "uint256.h"
@@ -67,12 +65,12 @@ class CAddress
{
public:
CAddress();
CAddress(unsigned int ipIn, unsigned short portIn=0, uint64_t nServicesIn=NODE_NETWORK);
explicit CAddress(const struct sockaddr_in& sockaddr, uint64_t nServicesIn=NODE_NETWORK);
explicit CAddress(const char* pszIn, int portIn, bool fNameLookup = false, uint64_t nServicesIn=NODE_NETWORK);
explicit CAddress(const char* pszIn, bool fNameLookup = false, uint64_t nServicesIn=NODE_NETWORK);
explicit CAddress(std::string strIn, int portIn, bool fNameLookup = false, uint64_t nServicesIn=NODE_NETWORK);
explicit CAddress(std::string strIn, bool fNameLookup = false, uint64_t nServicesIn=NODE_NETWORK);
CAddress(unsigned int ipIn, unsigned short portIn=0, uint64 nServicesIn=NODE_NETWORK);
explicit CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn=NODE_NETWORK);
explicit CAddress(const char* pszIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK);
explicit CAddress(const char* pszIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK);
explicit CAddress(std::string strIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK);
explicit CAddress(std::string strIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK);

void Init();

@@ -111,7 +109,7 @@ class CAddress

// TODO: make private (improves encapsulation)
public:
uint64_t nServices;
uint64 nServices;
unsigned char pchReserved[12];
unsigned int ip;
unsigned short port;

+ 1
- 2
src/qt/bitcoin.cpp View File

@@ -9,7 +9,6 @@
#include "headers.h"
#include "init.h"

#include <QtGlobal>
#include <QApplication>
#include <QMessageBox>
#include <QThread>
@@ -57,7 +56,7 @@ int ThreadSafeMessageBox(const std::string& message, const std::string& caption,
return 4;
}

bool ThreadSafeAskFee(qint64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
{
if(!guiref)
return false;

+ 0
- 1
src/qt/bitcoinamountfield.cpp View File

@@ -4,7 +4,6 @@

#include "guiconstants.h"

#include <QtGlobal>
#include <QLabel>
#include <QLineEdit>
#include <QRegExpValidator>

+ 0
- 1
src/qt/bitcoinamountfield.h View File

@@ -1,7 +1,6 @@
#ifndef BITCOINFIELD_H
#define BITCOINFIELD_H

#include <QtGlobal>
#include <QWidget>

QT_BEGIN_NAMESPACE

+ 0
- 1
src/qt/bitcoingui.cpp View File

@@ -27,7 +27,6 @@
#include "macdockiconhandler.h"
#endif

#include <QtGlobal>
#include <QApplication>
#include <QMainWindow>
#include <QMenuBar>

+ 0
- 1
src/qt/bitcoingui.h View File

@@ -1,7 +1,6 @@
#ifndef BITCOINGUI_H
#define BITCOINGUI_H

#include <QtGlobal>
#include <QMainWindow>
#include <QSystemTrayIcon>


+ 1
- 1
src/qt/bitcoinstrings.cpp View File

@@ -82,4 +82,4 @@ QT_TRANSLATE_NOOP("bitcoin-core", ""
"Warning: Please check that your computer's date and time are correct. If "
"your clock is wrong Bitcoin will not work properly."),
QT_TRANSLATE_NOOP("bitcoin-core", "beta"),
};
};

+ 0
- 1
src/qt/bitcoinunits.cpp View File

@@ -1,6 +1,5 @@
#include "bitcoinunits.h"

#include <QtGlobal>
#include <QStringList>

BitcoinUnits::BitcoinUnits(QObject *parent):

+ 0
- 1
src/qt/bitcoinunits.h View File

@@ -1,7 +1,6 @@
#ifndef BITCOINUNITS_H
#define BITCOINUNITS_H

#include <QtGlobal>
#include <QString>
#include <QAbstractListModel>


+ 0
- 1
src/qt/guiutil.cpp View File

@@ -5,7 +5,6 @@

#include "headers.h"

#include <QtGlobal>
#include <QString>
#include <QDateTime>
#include <QDoubleValidator>

+ 0
- 1
src/qt/guiutil.h View File

@@ -1,7 +1,6 @@
#ifndef GUIUTIL_H
#define GUIUTIL_H

#include <QtGlobal>
#include <QString>

QT_BEGIN_NAMESPACE

+ 0
- 1
src/qt/notificator.cpp View File

@@ -1,6 +1,5 @@
#include "notificator.h"

#include <QtGlobal>
#include <QMetaType>
#include <QVariant>
#include <QIcon>

+ 0
- 2
src/qt/optionsmodel.cpp View File

@@ -1,5 +1,3 @@
#include <QtGlobal>

#include "optionsmodel.h"
#include "bitcoinunits.h"


+ 0
- 1
src/qt/optionsmodel.h View File

@@ -1,7 +1,6 @@
#ifndef OPTIONSMODEL_H
#define OPTIONSMODEL_H

#include <QtGlobal>
#include <QAbstractListModel>

class CWallet;

+ 0
- 1
src/qt/overviewpage.cpp View File

@@ -9,7 +9,6 @@
#include "guiutil.h"
#include "guiconstants.h"

#include <QtGlobal>
#include <QAbstractItemDelegate>
#include <QPainter>


+ 0
- 1
src/qt/overviewpage.h View File

@@ -1,7 +1,6 @@
#ifndef OVERVIEWPAGE_H
#define OVERVIEWPAGE_H

#include <QtGlobal>
#include <QWidget>

QT_BEGIN_NAMESPACE

+ 0
- 1
src/qt/sendcoinsdialog.cpp View File

@@ -8,7 +8,6 @@
#include "guiutil.h"
#include "askpassphrasedialog.h"

#include <QtGlobal>
#include <QMessageBox>
#include <QLocale>
#include <QTextDocument>

+ 0
- 1
src/qt/sendcoinsdialog.h View File

@@ -1,7 +1,6 @@
#ifndef SENDCOINSDIALOG_H
#define SENDCOINSDIALOG_H

#include <QtGlobal>
#include <QDialog>

namespace Ui {

+ 8
- 9
src/qt/transactiondesc.cpp View File

@@ -6,7 +6,6 @@
#include "headers.h"
#include "qtui.h"

#include <QtGlobal>
#include <QString>
#include <QTextDocument> // For Qt::escape

@@ -56,10 +55,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";

qint64 nTime = wtx.GetTxTime();
qint64 nCredit = wtx.GetCredit();
qint64 nDebit = wtx.GetDebit();
qint64 nNet = nCredit - nDebit;
int64 nTime = wtx.GetTxTime();
int64 nCredit = wtx.GetCredit();
int64 nDebit = wtx.GetDebit();
int64 nNet = nCredit - nDebit;

strHTML += tr("<b>Status:</b> ") + FormatTxStatus(wtx);
int nRequests = wtx.GetRequestCount();
@@ -142,7 +141,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
//
// Coinbase
//
qint64 nUnmatured = 0;
int64 nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout);
strHTML += tr("<b>Credit:</b> ");
@@ -201,13 +200,13 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
if (fAllToMe)
{
// Payment to self
qint64 nChange = wtx.GetChange();
qint64 nValue = nCredit - nChange;
int64 nChange = wtx.GetChange();
int64 nValue = nCredit - nChange;
strHTML += tr("<b>Debit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
strHTML += tr("<b>Credit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nValue) + "<br>";
}

qint64 nTxFee = nDebit - wtx.GetValueOut();
int64 nTxFee = nDebit - wtx.GetValueOut();
if (nTxFee > 0)
strHTML += tr("<b>Transaction fee:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-nTxFee) + "<br>";
}

+ 0
- 1
src/qt/transactionfilterproxy.cpp View File

@@ -1,7 +1,6 @@
#include "transactionfilterproxy.h"
#include "transactiontablemodel.h"

#include <QtGlobal>
#include <QDateTime>

#include <cstdlib>

+ 0
- 1
src/qt/transactionfilterproxy.h View File

@@ -1,7 +1,6 @@
#ifndef TRANSACTIONFILTERPROXY_H
#define TRANSACTIONFILTERPROXY_H

#include <QtGlobal>
#include <QSortFilterProxyModel>
#include <QDateTime>


+ 9
- 11
src/qt/transactionrecord.cpp View File

@@ -1,5 +1,3 @@
#include <QtGlobal>

#include "transactionrecord.h"

#include "headers.h"
@@ -35,10 +33,10 @@ bool TransactionRecord::showTransaction(const CWalletTx &wtx)
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
{
QList<TransactionRecord> parts;
qint64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();
qint64 nCredit = wtx.GetCredit(true);
qint64 nDebit = wtx.GetDebit();
qint64 nNet = nCredit - nDebit;
int64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();
int64 nCredit = wtx.GetCredit(true);
int64 nDebit = wtx.GetDebit();
int64 nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;

@@ -60,7 +58,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *

if (nCredit == 0)
{
qint64 nUnmatured = 0;
int64 nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout);
sub.credit = nUnmatured;
@@ -105,7 +103,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
if (fAllFromMe && fAllToMe)
{
// Payment to self
qint64 nChange = wtx.GetChange();
int64 nChange = wtx.GetChange();

parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
@@ -115,7 +113,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
//
// Debit
//
qint64 nTxFee = nDebit - wtx.GetValueOut();
int64 nTxFee = nDebit - wtx.GetValueOut();

for (int nOut = 0; nOut < wtx.vout.size(); nOut++)
{
@@ -146,7 +144,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
}
}

qint64 nValue = txout.nValue;
int64 nValue = txout.nValue;
/* Add fee to first output */
if (nTxFee > 0)
{
@@ -229,7 +227,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
// For generated transactions, determine maturity
if(type == TransactionRecord::Generated)
{
qint64 nCredit = wtx.GetCredit(true);
int64 nCredit = wtx.GetCredit(true);
if (nCredit == 0)
{
status.maturity = TransactionStatus::Immature;

+ 8
- 9
src/qt/transactionrecord.h View File

@@ -3,7 +3,6 @@

#include "uint256.h"

#include <QtGlobal>
#include <QList>

class CWallet;
@@ -47,8 +46,8 @@ public:
/** @name Reported status
@{*/
Status status;
qint64 depth;
qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */
int64 depth;
int64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */
/**@}*/

/** Current number of blocks (to know whether cached status is still valid) */
@@ -80,15 +79,15 @@ public:
{
}

TransactionRecord(uint256 hash, qint64 time):
TransactionRecord(uint256 hash, int64 time):
hash(hash), time(time), type(Other), address(""), debit(0),
credit(0), idx(0)
{
}

TransactionRecord(uint256 hash, qint64 time,
TransactionRecord(uint256 hash, int64 time,
Type type, const std::string &address,
qint64 debit, qint64 credit):
int64 debit, int64 credit):
hash(hash), time(time), type(type), address(address), debit(debit), credit(credit),
idx(0)
{
@@ -102,11 +101,11 @@ public:
/** @name Immutable transaction attributes
@{*/
uint256 hash;
qint64 time;
int64 time;
Type type;
std::string address;
qint64 debit;
qint64 credit;
int64 debit;
int64 credit;
/**@}*/

/** Subtransaction index, for sort key */

+ 0
- 1
src/qt/transactionview.cpp View File

@@ -11,7 +11,6 @@
#include "editaddressdialog.h"
#include "optionsmodel.h"

#include <QtGlobal>
#include <QScrollBar>
#include <QComboBox>
#include <QDoubleValidator>

+ 2
- 3
src/qt/walletmodel.cpp View File

@@ -6,7 +6,6 @@