mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-03 02:34:14 +00:00
Revert "Use standard C99 (and Qt) types for 64-bit integers"
This reverts commit 21d9f36781604e4ca9fc35dc65265593423b73e9.
This commit is contained in:
parent
21d9f36781
commit
bde280b9a4
@ -28,7 +28,7 @@ someVariable.
|
|||||||
|
|
||||||
Common types:
|
Common types:
|
||||||
n integer number: short, unsigned short, int, unsigned int,
|
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
|
d double, float
|
||||||
f flag
|
f flag
|
||||||
hash uint256
|
hash uint256
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
#ifndef BITCOIN_BASE58_H
|
#ifndef BITCOIN_BASE58_H
|
||||||
#define BITCOIN_BASE58_H
|
#define BITCOIN_BASE58_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "bignum.h"
|
#include "bignum.h"
|
||||||
|
12
src/bignum.h
12
src/bignum.h
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_BIGNUM_H
|
#ifndef BITCOIN_BIGNUM_H
|
||||||
#define BITCOIN_BIGNUM_H
|
#define BITCOIN_BIGNUM_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
@ -83,12 +81,12 @@ public:
|
|||||||
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
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(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(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 char n) { BN_init(this); setulong(n); }
|
||||||
CBigNum(unsigned short 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 int n) { BN_init(this); setulong(n); }
|
||||||
CBigNum(unsigned long 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(uint256 n) { BN_init(this); setuint256(n); }
|
||||||
|
|
||||||
explicit CBigNum(const std::vector<unsigned char>& vch)
|
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);
|
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 pch[sizeof(n) + 6];
|
||||||
unsigned char* p = pch + 4;
|
unsigned char* p = pch + 4;
|
||||||
bool fNegative = false;
|
bool fNegative = false;
|
||||||
if (n < (int64_t)0)
|
if (n < (int64)0)
|
||||||
{
|
{
|
||||||
n = -n;
|
n = -n;
|
||||||
fNegative = true;
|
fNegative = true;
|
||||||
@ -157,7 +155,7 @@ public:
|
|||||||
BN_mpi2bn(pch, p - pch, this);
|
BN_mpi2bn(pch, p - pch, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setuint64(uint64_t n)
|
void setuint64(uint64 n)
|
||||||
{
|
{
|
||||||
unsigned char pch[sizeof(n) + 6];
|
unsigned char pch[sizeof(n) + 6];
|
||||||
unsigned char* p = pch + 4;
|
unsigned char* p = pch + 4;
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
@ -42,7 +40,7 @@ extern map<string, rpcfn_type> mapCallTable;
|
|||||||
|
|
||||||
static std::string strRPCUserColonPass;
|
static std::string strRPCUserColonPass;
|
||||||
|
|
||||||
static int64_t nWalletUnlockTime;
|
static int64 nWalletUnlockTime;
|
||||||
static CCriticalSection cs_nWalletUnlockTime;
|
static CCriticalSection cs_nWalletUnlockTime;
|
||||||
|
|
||||||
extern Value dumpprivkey(const Array& params, bool fHelp);
|
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();
|
double dAmount = value.get_real();
|
||||||
if (dAmount <= 0.0 || dAmount > 21000000.0)
|
if (dAmount <= 0.0 || dAmount > 21000000.0)
|
||||||
throw JSONRPCError(-3, "Invalid amount");
|
throw JSONRPCError(-3, "Invalid amount");
|
||||||
int64_t nAmount = roundint64(dAmount * COIN);
|
int64 nAmount = roundint64(dAmount * COIN);
|
||||||
if (!MoneyRange(nAmount))
|
if (!MoneyRange(nAmount))
|
||||||
throw JSONRPCError(-3, "Invalid amount");
|
throw JSONRPCError(-3, "Invalid amount");
|
||||||
return nAmount;
|
return nAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ValueFromAmount(int64_t amount)
|
Value ValueFromAmount(int64 amount)
|
||||||
{
|
{
|
||||||
return (double)amount / (double)COIN;
|
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> is a real and is rounded to the nearest 0.00000001");
|
||||||
|
|
||||||
// Amount
|
// Amount
|
||||||
int64_t nAmount = 0;
|
int64 nAmount = 0;
|
||||||
if (params[0].get_real() != 0.0)
|
if (params[0].get_real() != 0.0)
|
||||||
nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts
|
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");
|
throw JSONRPCError(-5, "Invalid bitcoin address");
|
||||||
|
|
||||||
// Amount
|
// Amount
|
||||||
int64_t nAmount = AmountFromValue(params[1]);
|
int64 nAmount = AmountFromValue(params[1]);
|
||||||
|
|
||||||
// Wallet comments
|
// Wallet comments
|
||||||
CWalletTx wtx;
|
CWalletTx wtx;
|
||||||
@ -634,7 +632,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
|
|||||||
nMinDepth = params[1].get_int();
|
nMinDepth = params[1].get_int();
|
||||||
|
|
||||||
// Tally
|
// Tally
|
||||||
int64_t nAmount = 0;
|
int64 nAmount = 0;
|
||||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||||
{
|
{
|
||||||
const CWalletTx& wtx = (*it).second;
|
const CWalletTx& wtx = (*it).second;
|
||||||
@ -681,7 +679,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
|
|||||||
GetAccountAddresses(strAccount, setAddress);
|
GetAccountAddresses(strAccount, setAddress);
|
||||||
|
|
||||||
// Tally
|
// Tally
|
||||||
int64_t nAmount = 0;
|
int64 nAmount = 0;
|
||||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||||
{
|
{
|
||||||
const CWalletTx& wtx = (*it).second;
|
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
|
// Tally wallet transactions
|
||||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
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())
|
if (!wtx.IsFinal())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int64_t nGenerated, nReceived, nSent, nFee;
|
int64 nGenerated, nReceived, nSent, nFee;
|
||||||
wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee);
|
wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee);
|
||||||
|
|
||||||
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
||||||
@ -726,7 +724,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
|
|||||||
return nBalance;
|
return nBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetAccountBalance(const string& strAccount, int nMinDepth)
|
int64 GetAccountBalance(const string& strAccount, int nMinDepth)
|
||||||
{
|
{
|
||||||
CWalletDB walletdb(pwalletMain->strWalletFile);
|
CWalletDB walletdb(pwalletMain->strWalletFile);
|
||||||
return GetAccountBalance(walletdb, strAccount, nMinDepth);
|
return GetAccountBalance(walletdb, strAccount, nMinDepth);
|
||||||
@ -752,23 +750,23 @@ Value getbalance(const Array& params, bool fHelp)
|
|||||||
// Calculate total balance a different way from GetBalance()
|
// Calculate total balance a different way from GetBalance()
|
||||||
// (GetBalance() sums up all unspent TxOuts)
|
// (GetBalance() sums up all unspent TxOuts)
|
||||||
// getbalance and getbalance '*' should always return the same number.
|
// 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)
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||||
{
|
{
|
||||||
const CWalletTx& wtx = (*it).second;
|
const CWalletTx& wtx = (*it).second;
|
||||||
if (!wtx.IsFinal())
|
if (!wtx.IsFinal())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int64_t allGeneratedImmature, allGeneratedMature, allFee;
|
int64 allGeneratedImmature, allGeneratedMature, allFee;
|
||||||
allGeneratedImmature = allGeneratedMature = allFee = 0;
|
allGeneratedImmature = allGeneratedMature = allFee = 0;
|
||||||
string strSentAccount;
|
string strSentAccount;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listReceived;
|
list<pair<CBitcoinAddress, int64> > listReceived;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listSent;
|
list<pair<CBitcoinAddress, int64> > listSent;
|
||||||
wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);
|
wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);
|
||||||
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
||||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listReceived)
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listReceived)
|
||||||
nBalance += r.second;
|
nBalance += r.second;
|
||||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listSent)
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listSent)
|
||||||
nBalance -= r.second;
|
nBalance -= r.second;
|
||||||
nBalance -= allFee;
|
nBalance -= allFee;
|
||||||
nBalance += allGeneratedMature;
|
nBalance += allGeneratedMature;
|
||||||
@ -778,7 +776,7 @@ Value getbalance(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
string strAccount = AccountFromValue(params[0]);
|
string strAccount = AccountFromValue(params[0]);
|
||||||
|
|
||||||
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
|
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
|
||||||
|
|
||||||
return ValueFromAmount(nBalance);
|
return ValueFromAmount(nBalance);
|
||||||
}
|
}
|
||||||
@ -793,7 +791,7 @@ Value movecmd(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
string strFrom = AccountFromValue(params[0]);
|
string strFrom = AccountFromValue(params[0]);
|
||||||
string strTo = AccountFromValue(params[1]);
|
string strTo = AccountFromValue(params[1]);
|
||||||
int64_t nAmount = AmountFromValue(params[2]);
|
int64 nAmount = AmountFromValue(params[2]);
|
||||||
if (params.size() > 3)
|
if (params.size() > 3)
|
||||||
// unused parameter, used to be nMinDepth, keep type-checking it though
|
// unused parameter, used to be nMinDepth, keep type-checking it though
|
||||||
(void)params[3].get_int();
|
(void)params[3].get_int();
|
||||||
@ -804,7 +802,7 @@ Value movecmd(const Array& params, bool fHelp)
|
|||||||
CWalletDB walletdb(pwalletMain->strWalletFile);
|
CWalletDB walletdb(pwalletMain->strWalletFile);
|
||||||
walletdb.TxnBegin();
|
walletdb.TxnBegin();
|
||||||
|
|
||||||
int64_t nNow = GetAdjustedTime();
|
int64 nNow = GetAdjustedTime();
|
||||||
|
|
||||||
// Debit
|
// Debit
|
||||||
CAccountingEntry debit;
|
CAccountingEntry debit;
|
||||||
@ -846,7 +844,7 @@ Value sendfrom(const Array& params, bool fHelp)
|
|||||||
CBitcoinAddress address(params[1].get_str());
|
CBitcoinAddress address(params[1].get_str());
|
||||||
if (!address.IsValid())
|
if (!address.IsValid())
|
||||||
throw JSONRPCError(-5, "Invalid bitcoin address");
|
throw JSONRPCError(-5, "Invalid bitcoin address");
|
||||||
int64_t nAmount = AmountFromValue(params[2]);
|
int64 nAmount = AmountFromValue(params[2]);
|
||||||
int nMinDepth = 1;
|
int nMinDepth = 1;
|
||||||
if (params.size() > 3)
|
if (params.size() > 3)
|
||||||
nMinDepth = params[3].get_int();
|
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.");
|
throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
|
||||||
|
|
||||||
// Check funds
|
// Check funds
|
||||||
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
|
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
|
||||||
if (nAmount > nBalance)
|
if (nAmount > nBalance)
|
||||||
throw JSONRPCError(-6, "Account has insufficient funds");
|
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();
|
wtx.mapValue["comment"] = params[3].get_str();
|
||||||
|
|
||||||
set<CBitcoinAddress> setAddress;
|
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)
|
BOOST_FOREACH(const Pair& s, sendTo)
|
||||||
{
|
{
|
||||||
CBitcoinAddress address(s.name_);
|
CBitcoinAddress address(s.name_);
|
||||||
@ -914,7 +912,7 @@ Value sendmany(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
CScript scriptPubKey;
|
CScript scriptPubKey;
|
||||||
scriptPubKey.SetBitcoinAddress(address);
|
scriptPubKey.SetBitcoinAddress(address);
|
||||||
int64_t nAmount = AmountFromValue(s.value_);
|
int64 nAmount = AmountFromValue(s.value_);
|
||||||
totalAmount += nAmount;
|
totalAmount += nAmount;
|
||||||
|
|
||||||
vecSend.push_back(make_pair(scriptPubKey, 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.");
|
throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
|
||||||
|
|
||||||
// Check funds
|
// Check funds
|
||||||
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth);
|
int64 nBalance = GetAccountBalance(strAccount, nMinDepth);
|
||||||
if (totalAmount > nBalance)
|
if (totalAmount > nBalance)
|
||||||
throw JSONRPCError(-6, "Account has insufficient funds");
|
throw JSONRPCError(-6, "Account has insufficient funds");
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
CReserveKey keyChange(pwalletMain);
|
CReserveKey keyChange(pwalletMain);
|
||||||
int64_t nFeeRequired = 0;
|
int64 nFeeRequired = 0;
|
||||||
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired);
|
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired);
|
||||||
if (!fCreated)
|
if (!fCreated)
|
||||||
{
|
{
|
||||||
@ -1009,7 +1007,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
struct tallyitem
|
struct tallyitem
|
||||||
{
|
{
|
||||||
int64_t nAmount;
|
int64 nAmount;
|
||||||
int nConf;
|
int nConf;
|
||||||
tallyitem()
|
tallyitem()
|
||||||
{
|
{
|
||||||
@ -1065,7 +1063,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
|
|||||||
if (it == mapTally.end() && !fIncludeEmpty)
|
if (it == mapTally.end() && !fIncludeEmpty)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int64_t nAmount = 0;
|
int64 nAmount = 0;
|
||||||
int nConf = std::numeric_limits<int>::max();
|
int nConf = std::numeric_limits<int>::max();
|
||||||
if (it != mapTally.end())
|
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)
|
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;
|
int nConf = (*it).second.nConf;
|
||||||
Object obj;
|
Object obj;
|
||||||
obj.push_back(Pair("account", (*it).first));
|
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)
|
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;
|
string strSentAccount;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listReceived;
|
list<pair<CBitcoinAddress, int64> > listReceived;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listSent;
|
list<pair<CBitcoinAddress, int64> > listSent;
|
||||||
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);
|
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);
|
||||||
|
|
||||||
bool fAllAccounts = (strAccount == string("*"));
|
bool fAllAccounts = (strAccount == string("*"));
|
||||||
@ -1171,7 +1169,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
|||||||
// Sent
|
// Sent
|
||||||
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
|
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;
|
Object entry;
|
||||||
entry.push_back(Pair("account", strSentAccount));
|
entry.push_back(Pair("account", strSentAccount));
|
||||||
@ -1187,7 +1185,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
|
|||||||
|
|
||||||
// Received
|
// Received
|
||||||
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
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;
|
string account;
|
||||||
if (pwalletMain->mapAddressBook.count(r.first))
|
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:
|
// Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap:
|
||||||
typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
|
typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
|
||||||
typedef multimap<int64_t, TxPair > TxItems;
|
typedef multimap<int64, TxPair > TxItems;
|
||||||
TxItems txByTime;
|
TxItems txByTime;
|
||||||
|
|
||||||
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
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)
|
if (params.size() > 0)
|
||||||
nMinDepth = params[0].get_int();
|
nMinDepth = params[0].get_int();
|
||||||
|
|
||||||
map<string, int64_t> mapAccountBalances;
|
map<string, int64> mapAccountBalances;
|
||||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& entry, pwalletMain->mapAddressBook) {
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& entry, pwalletMain->mapAddressBook) {
|
||||||
if (pwalletMain->HaveKey(entry.first)) // This address belongs to me
|
if (pwalletMain->HaveKey(entry.first)) // This address belongs to me
|
||||||
mapAccountBalances[entry.second] = 0;
|
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)
|
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
|
||||||
{
|
{
|
||||||
const CWalletTx& wtx = (*it).second;
|
const CWalletTx& wtx = (*it).second;
|
||||||
int64_t nGeneratedImmature, nGeneratedMature, nFee;
|
int64 nGeneratedImmature, nGeneratedMature, nFee;
|
||||||
string strSentAccount;
|
string strSentAccount;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listReceived;
|
list<pair<CBitcoinAddress, int64> > listReceived;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listSent;
|
list<pair<CBitcoinAddress, int64> > listSent;
|
||||||
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);
|
wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount);
|
||||||
mapAccountBalances[strSentAccount] -= nFee;
|
mapAccountBalances[strSentAccount] -= nFee;
|
||||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64_t)& s, listSent)
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& s, listSent)
|
||||||
mapAccountBalances[strSentAccount] -= s.second;
|
mapAccountBalances[strSentAccount] -= s.second;
|
||||||
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
||||||
{
|
{
|
||||||
mapAccountBalances[""] += nGeneratedMature;
|
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))
|
if (pwalletMain->mapAddressBook.count(r.first))
|
||||||
mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second;
|
mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second;
|
||||||
else
|
else
|
||||||
@ -1333,7 +1331,7 @@ Value listaccounts(const Array& params, bool fHelp)
|
|||||||
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
|
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
|
||||||
|
|
||||||
Object ret;
|
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)));
|
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -1419,10 +1417,10 @@ Value gettransaction(const Array& params, bool fHelp)
|
|||||||
throw JSONRPCError(-5, "Invalid or non-wallet transaction id");
|
throw JSONRPCError(-5, "Invalid or non-wallet transaction id");
|
||||||
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
|
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
|
||||||
|
|
||||||
int64_t nCredit = wtx.GetCredit();
|
int64 nCredit = wtx.GetCredit();
|
||||||
int64_t nDebit = wtx.GetDebit();
|
int64 nDebit = wtx.GetDebit();
|
||||||
int64_t nNet = nCredit - nDebit;
|
int64 nNet = nCredit - nDebit;
|
||||||
int64_t nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0);
|
int64 nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0);
|
||||||
|
|
||||||
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
|
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
|
||||||
if (wtx.IsFromMe())
|
if (wtx.IsFromMe())
|
||||||
@ -1482,7 +1480,7 @@ void ThreadTopUpKeyPool(void* parg)
|
|||||||
|
|
||||||
void ThreadCleanWalletPassphrase(void* parg)
|
void ThreadCleanWalletPassphrase(void* parg)
|
||||||
{
|
{
|
||||||
int64_t nMyWakeTime = GetTime() + *((int*)parg);
|
int64 nMyWakeTime = GetTime() + *((int*)parg);
|
||||||
|
|
||||||
if (nWalletUnlockTime == 0)
|
if (nWalletUnlockTime == 0)
|
||||||
{
|
{
|
||||||
@ -1729,7 +1727,7 @@ Value getwork(const Array& params, bool fHelp)
|
|||||||
// Update block
|
// Update block
|
||||||
static unsigned int nTransactionsUpdatedLast;
|
static unsigned int nTransactionsUpdatedLast;
|
||||||
static CBlockIndex* pindexPrev;
|
static CBlockIndex* pindexPrev;
|
||||||
static int64_t nStart;
|
static int64 nStart;
|
||||||
static CBlock* pblock;
|
static CBlock* pblock;
|
||||||
if (pindexPrev != pindexBest ||
|
if (pindexPrev != pindexBest ||
|
||||||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
|
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60))
|
||||||
@ -1833,7 +1831,7 @@ Value getmemorypool(const Array& params, bool fHelp)
|
|||||||
// Update block
|
// Update block
|
||||||
static unsigned int nTransactionsUpdatedLast;
|
static unsigned int nTransactionsUpdatedLast;
|
||||||
static CBlockIndex* pindexPrev;
|
static CBlockIndex* pindexPrev;
|
||||||
static int64_t nStart;
|
static int64 nStart;
|
||||||
static CBlock* pblock;
|
static CBlock* pblock;
|
||||||
if (pindexPrev != pindexBest ||
|
if (pindexPrev != pindexBest ||
|
||||||
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5))
|
(nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5))
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// 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/assign/list_of.hpp> // for 'map_list_of()'
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
@ -54,7 +52,7 @@ namespace Checkpoints
|
|||||||
{
|
{
|
||||||
if (fTestNet) return NULL;
|
if (fTestNet) return NULL;
|
||||||
|
|
||||||
int64_t nResult;
|
int64 nResult;
|
||||||
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
|
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
|
||||||
{
|
{
|
||||||
const uint256& hash = i.second;
|
const uint256& hash = i.second;
|
||||||
|
18
src/db.cpp
18
src/db.cpp
@ -3,8 +3,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
@ -16,7 +14,7 @@ using namespace boost;
|
|||||||
|
|
||||||
|
|
||||||
unsigned int nWalletDBUpdated;
|
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);
|
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;
|
list<CAccountingEntry> entries;
|
||||||
ListAccountCreditDebit(strAccount, entries);
|
ListAccountCreditDebit(strAccount, entries);
|
||||||
|
|
||||||
int64_t nCreditDebit = 0;
|
int64 nCreditDebit = 0;
|
||||||
BOOST_FOREACH (const CAccountingEntry& entry, entries)
|
BOOST_FOREACH (const CAccountingEntry& entry, entries)
|
||||||
nCreditDebit += entry.nCreditDebit;
|
nCreditDebit += entry.nCreditDebit;
|
||||||
|
|
||||||
@ -732,7 +730,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
|
|||||||
// Read next record
|
// Read next record
|
||||||
CDataStream ssKey;
|
CDataStream ssKey;
|
||||||
if (fFlags == DB_SET_RANGE)
|
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;
|
CDataStream ssValue;
|
||||||
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
||||||
fFlags = DB_NEXT;
|
fFlags = DB_NEXT;
|
||||||
@ -848,7 +846,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
{
|
{
|
||||||
string strAccount;
|
string strAccount;
|
||||||
ssKey >> strAccount;
|
ssKey >> strAccount;
|
||||||
uint64_t nNumber;
|
uint64 nNumber;
|
||||||
ssKey >> nNumber;
|
ssKey >> nNumber;
|
||||||
if (nNumber > nAccountingEntryNumber)
|
if (nNumber > nAccountingEntryNumber)
|
||||||
nAccountingEntryNumber = nNumber;
|
nAccountingEntryNumber = nNumber;
|
||||||
@ -901,7 +899,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
|
|||||||
}
|
}
|
||||||
else if (strType == "pool")
|
else if (strType == "pool")
|
||||||
{
|
{
|
||||||
int64_t nIndex;
|
int64 nIndex;
|
||||||
ssKey >> nIndex;
|
ssKey >> nIndex;
|
||||||
pwallet->setKeyPool.insert(nIndex);
|
pwallet->setKeyPool.insert(nIndex);
|
||||||
}
|
}
|
||||||
@ -991,7 +989,7 @@ void ThreadFlushWalletDB(void* parg)
|
|||||||
|
|
||||||
unsigned int nLastSeen = nWalletDBUpdated;
|
unsigned int nLastSeen = nWalletDBUpdated;
|
||||||
unsigned int nLastFlushed = nWalletDBUpdated;
|
unsigned int nLastFlushed = nWalletDBUpdated;
|
||||||
int64_t nLastWalletUpdate = GetTime();
|
int64 nLastWalletUpdate = GetTime();
|
||||||
while (!fShutdown)
|
while (!fShutdown)
|
||||||
{
|
{
|
||||||
Sleep(500);
|
Sleep(500);
|
||||||
@ -1023,7 +1021,7 @@ void ThreadFlushWalletDB(void* parg)
|
|||||||
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
|
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
|
||||||
printf("Flushing wallet.dat\n");
|
printf("Flushing wallet.dat\n");
|
||||||
nLastFlushed = nWalletDBUpdated;
|
nLastFlushed = nWalletDBUpdated;
|
||||||
int64_t nStart = GetTimeMillis();
|
int64 nStart = GetTimeMillis();
|
||||||
|
|
||||||
// Flush wallet.dat so it's self contained
|
// Flush wallet.dat so it's self contained
|
||||||
CloseDb(strFile);
|
CloseDb(strFile);
|
||||||
|
12
src/db.h
12
src/db.h
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_DB_H
|
#ifndef BITCOIN_DB_H
|
||||||
#define BITCOIN_DB_H
|
#define BITCOIN_DB_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -319,7 +317,7 @@ bool LoadAddresses();
|
|||||||
class CKeyPool
|
class CKeyPool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int64_t nTime;
|
int64 nTime;
|
||||||
std::vector<unsigned char> vchPubKey;
|
std::vector<unsigned char> vchPubKey;
|
||||||
|
|
||||||
CKeyPool()
|
CKeyPool()
|
||||||
@ -458,18 +456,18 @@ public:
|
|||||||
return Write(std::string("defaultkey"), vchPubKey);
|
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);
|
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++;
|
nWalletDBUpdated++;
|
||||||
return Write(std::make_pair(std::string("pool"), nPool), keypool);
|
return Write(std::make_pair(std::string("pool"), nPool), keypool);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ErasePool(int64_t nPool)
|
bool ErasePool(int64 nPool)
|
||||||
{
|
{
|
||||||
nWalletDBUpdated++;
|
nWalletDBUpdated++;
|
||||||
return Erase(std::make_pair(std::string("pool"), nPool));
|
return Erase(std::make_pair(std::string("pool"), nPool));
|
||||||
@ -491,7 +489,7 @@ public:
|
|||||||
bool ReadAccount(const std::string& strAccount, CAccount& account);
|
bool ReadAccount(const std::string& strAccount, CAccount& account);
|
||||||
bool WriteAccount(const std::string& strAccount, const CAccount& account);
|
bool WriteAccount(const std::string& strAccount, const CAccount& account);
|
||||||
bool WriteAccountingEntry(const CAccountingEntry& acentry);
|
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);
|
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
|
||||||
|
|
||||||
int LoadWallet(CWallet* pwallet);
|
int LoadWallet(CWallet* pwallet);
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
// Copyright (c) 2011 The Bitcoin developers
|
// Copyright (c) 2011 The Bitcoin developers
|
||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "bitcoinrpc.h"
|
#include "bitcoinrpc.h"
|
||||||
@ -352,7 +349,7 @@ bool AppInit2(int argc, char* argv[])
|
|||||||
//
|
//
|
||||||
if (fDaemon)
|
if (fDaemon)
|
||||||
fprintf(stdout, "bitcoin server starting\n");
|
fprintf(stdout, "bitcoin server starting\n");
|
||||||
int64_t nStart;
|
int64 nStart;
|
||||||
|
|
||||||
InitMessage(_("Loading addresses..."));
|
InitMessage(_("Loading addresses..."));
|
||||||
printf("Loading addresses...\n");
|
printf("Loading addresses...\n");
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
@ -356,7 +354,7 @@ void ThreadIRCSeed2(void* parg)
|
|||||||
Send(hSocket, strprintf("WHO #bitcoin%02d\r", channel_number).c_str());
|
Send(hSocket, strprintf("WHO #bitcoin%02d\r", channel_number).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nStart = GetTime();
|
int64 nStart = GetTime();
|
||||||
string strLine;
|
string strLine;
|
||||||
strLine.reserve(10000);
|
strLine.reserve(10000);
|
||||||
while (!fShutdown && RecvLineIRC(hSocket, strLine))
|
while (!fShutdown && RecvLineIRC(hSocket, strLine))
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "crypter.h"
|
#include "crypter.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_KEYSTORE_H
|
#ifndef BITCOIN_KEYSTORE_H
|
||||||
#define BITCOIN_KEYSTORE_H
|
#define BITCOIN_KEYSTORE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "crypter.h"
|
#include "crypter.h"
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
|
||||||
|
89
src/main.cpp
89
src/main.cpp
@ -2,9 +2,6 @@
|
|||||||
// Copyright (c) 2011 The Bitcoin developers
|
// Copyright (c) 2011 The Bitcoin developers
|
||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "checkpoints.h"
|
#include "checkpoints.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
@ -45,7 +42,7 @@ CBigNum bnBestChainWork = 0;
|
|||||||
CBigNum bnBestInvalidWork = 0;
|
CBigNum bnBestInvalidWork = 0;
|
||||||
uint256 hashBestChain = 0;
|
uint256 hashBestChain = 0;
|
||||||
CBlockIndex* pindexBest = NULL;
|
CBlockIndex* pindexBest = NULL;
|
||||||
int64_t nTimeBestReceived = 0;
|
int64 nTimeBestReceived = 0;
|
||||||
|
|
||||||
CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
|
CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
|
||||||
|
|
||||||
@ -57,11 +54,11 @@ multimap<uint256, CDataStream*> mapOrphanTransactionsByPrev;
|
|||||||
|
|
||||||
|
|
||||||
double dHashesPerSec;
|
double dHashesPerSec;
|
||||||
int64_t nHPSTimerStart;
|
int64 nHPSTimerStart;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
int fGenerateBitcoins = false;
|
int fGenerateBitcoins = false;
|
||||||
int64_t nTransactionFee = 0;
|
int64 nTransactionFee = 0;
|
||||||
int fLimitProcessors = false;
|
int fLimitProcessors = false;
|
||||||
int nLimitProcessors = 1;
|
int nLimitProcessors = 1;
|
||||||
int fMinimizeToTray = true;
|
int fMinimizeToTray = true;
|
||||||
@ -381,7 +378,7 @@ bool CTransaction::CheckTransaction() const
|
|||||||
return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
|
return DoS(100, error("CTransaction::CheckTransaction() : size limits failed"));
|
||||||
|
|
||||||
// Check for negative or overflow output values
|
// Check for negative or overflow output values
|
||||||
int64_t nValueOut = 0;
|
int64 nValueOut = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, vout)
|
BOOST_FOREACH(const CTxOut& txout, vout)
|
||||||
{
|
{
|
||||||
if (txout.nValue < 0)
|
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"));
|
return DoS(100, error("AcceptToMemoryPool() : coinbase as individual tx"));
|
||||||
|
|
||||||
// To help v0.1.5 clients who would see it as a negative number
|
// 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");
|
return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet");
|
||||||
|
|
||||||
// Rather not work on nonstandard transactions (unless -testnet)
|
// 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");
|
return error("AcceptToMemoryPool() : nonstandard transaction input");
|
||||||
|
|
||||||
// Check against previous transactions
|
// Check against previous transactions
|
||||||
int64_t nFees = 0;
|
int64 nFees = 0;
|
||||||
int nSigOps = 0;
|
int nSigOps = 0;
|
||||||
if (!ConnectInputs(mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, nSigOps))
|
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 CCriticalSection cs;
|
||||||
static double dFreeCount;
|
static double dFreeCount;
|
||||||
static int64_t nLastTime;
|
static int64 nLastTime;
|
||||||
int64_t nNow = GetTime();
|
int64 nNow = GetTime();
|
||||||
|
|
||||||
CRITICAL_BLOCK(cs)
|
CRITICAL_BLOCK(cs)
|
||||||
{
|
{
|
||||||
@ -728,9 +725,9 @@ uint256 static GetOrphanRoot(const CBlock* pblock)
|
|||||||
return pblock->GetHash();
|
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
|
// Subsidy is cut in half every 4 years
|
||||||
nSubsidy >>= (nHeight / 210000);
|
nSubsidy >>= (nHeight / 210000);
|
||||||
@ -738,15 +735,15 @@ int64_t static GetBlockValue(int nHeight, int64_t nFees)
|
|||||||
return nSubsidy + nFees;
|
return nSubsidy + nFees;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int64_t nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
static const int64 nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
||||||
static const int64_t nTargetSpacing = 10 * 60;
|
static const int64 nTargetSpacing = 10 * 60;
|
||||||
static const int64_t nInterval = nTargetTimespan / nTargetSpacing;
|
static const int64 nInterval = nTargetTimespan / nTargetSpacing;
|
||||||
|
|
||||||
//
|
//
|
||||||
// minimum amount of work that could possibly be required nTime after
|
// minimum amount of work that could possibly be required nTime after
|
||||||
// minimum work required was nBase
|
// minimum work required was nBase
|
||||||
//
|
//
|
||||||
unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime)
|
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
|
||||||
{
|
{
|
||||||
CBigNum bnResult;
|
CBigNum bnResult;
|
||||||
bnResult.SetCompact(nBase);
|
bnResult.SetCompact(nBase);
|
||||||
@ -780,7 +777,7 @@ unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast)
|
|||||||
assert(pindexFirst);
|
assert(pindexFirst);
|
||||||
|
|
||||||
// Limit adjustment step
|
// Limit adjustment step
|
||||||
int64_t nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
|
int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
|
||||||
printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
|
printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
|
||||||
if (nActualTimespan < nTargetTimespan/4)
|
if (nActualTimespan < nTargetTimespan/4)
|
||||||
nActualTimespan = nTargetTimespan/4;
|
nActualTimespan = nTargetTimespan/4;
|
||||||
@ -831,7 +828,7 @@ bool IsInitialBlockDownload()
|
|||||||
{
|
{
|
||||||
if (pindexBest == NULL || nBestHeight < (Checkpoints::GetTotalBlocksEstimate()-nInitialBlockThreshold))
|
if (pindexBest == NULL || nBestHeight < (Checkpoints::GetTotalBlocksEstimate()-nInitialBlockThreshold))
|
||||||
return true;
|
return true;
|
||||||
static int64_t nLastUpdate;
|
static int64 nLastUpdate;
|
||||||
static CBlockIndex* pindexLastBest;
|
static CBlockIndex* pindexLastBest;
|
||||||
if (pindexBest != 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,
|
bool CTransaction::ConnectInputs(map<uint256, pair<CTxIndex, CTransaction> > inputs,
|
||||||
map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,
|
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
|
// 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
|
// 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
|
// ... both are false when called from CTransaction::AcceptToMemoryPool
|
||||||
if (!IsCoinBase())
|
if (!IsCoinBase())
|
||||||
{
|
{
|
||||||
int64_t nValueIn = 0;
|
int64 nValueIn = 0;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
COutPoint prevout = vin[i].prevout;
|
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,
|
// To avoid being on the short end of a block-chain split,
|
||||||
// interpret OP_EVAL as a NO_OP until blocks with timestamps
|
// interpret OP_EVAL as a NO_OP until blocks with timestamps
|
||||||
// after opevaltime:
|
// after opevaltime:
|
||||||
int64_t nEvalSwitchTime = GetArg("opevaltime", 1328054400); // Feb 1, 2012
|
int64 nEvalSwitchTime = GetArg("opevaltime", 1328054400); // Feb 1, 2012
|
||||||
fStrictOpEval = (pindexBlock->nTime >= nEvalSwitchTime);
|
fStrictOpEval = (pindexBlock->nTime >= nEvalSwitchTime);
|
||||||
}
|
}
|
||||||
// if !fBlock, then always be strict-- don't accept
|
// 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()));
|
return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
|
||||||
|
|
||||||
// Tally transaction fees
|
// Tally transaction fees
|
||||||
int64_t nTxFee = nValueIn - GetValueOut();
|
int64 nTxFee = nValueIn - GetValueOut();
|
||||||
if (nTxFee < 0)
|
if (nTxFee < 0)
|
||||||
return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
|
return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
|
||||||
if (nTxFee < nMinFee)
|
if (nTxFee < nMinFee)
|
||||||
@ -1063,7 +1060,7 @@ bool CTransaction::ClientConnectInputs()
|
|||||||
// Take over previous transactions' spent pointers
|
// Take over previous transactions' spent pointers
|
||||||
CRITICAL_BLOCK(cs_mapTransactions)
|
CRITICAL_BLOCK(cs_mapTransactions)
|
||||||
{
|
{
|
||||||
int64_t nValueIn = 0;
|
int64 nValueIn = 0;
|
||||||
for (int i = 0; i < vin.size(); i++)
|
for (int i = 0; i < vin.size(); i++)
|
||||||
{
|
{
|
||||||
// Get prev tx from single transactions in memory
|
// 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());
|
unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size());
|
||||||
|
|
||||||
map<uint256, CTxIndex> mapQueuedChanges;
|
map<uint256, CTxIndex> mapQueuedChanges;
|
||||||
int64_t nFees = 0;
|
int64 nFees = 0;
|
||||||
int nSigOps = 0;
|
int nSigOps = 0;
|
||||||
BOOST_FOREACH(CTransaction& tx, vtx)
|
BOOST_FOREACH(CTransaction& tx, vtx)
|
||||||
{
|
{
|
||||||
@ -1502,7 +1499,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
|
|||||||
if (pcheckpoint && pblock->hashPrevBlock != hashBestChain)
|
if (pcheckpoint && pblock->hashPrevBlock != hashBestChain)
|
||||||
{
|
{
|
||||||
// Extra checks to prevent "fill up memory by spamming with bogus blocks"
|
// 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)
|
if (deltaTime < 0)
|
||||||
{
|
{
|
||||||
pfrom->Misbehaving(100);
|
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
|
// 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;
|
fShutdown = true;
|
||||||
string strMessage = _("Warning: Disk space is low ");
|
string strMessage = _("Warning: Disk space is low ");
|
||||||
@ -1948,10 +1945,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nTime;
|
int64 nTime;
|
||||||
CAddress addrMe;
|
CAddress addrMe;
|
||||||
CAddress addrFrom;
|
CAddress addrFrom;
|
||||||
uint64_t nNonce = 1;
|
uint64 nNonce = 1;
|
||||||
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
|
vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe;
|
||||||
if (pfrom->nVersion == 10300)
|
if (pfrom->nVersion == 10300)
|
||||||
pfrom->nVersion = 300;
|
pfrom->nVersion = 300;
|
||||||
@ -2062,8 +2059,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
// Store the new addresses
|
// Store the new addresses
|
||||||
CAddrDB addrDB;
|
CAddrDB addrDB;
|
||||||
addrDB.TxnBegin();
|
addrDB.TxnBegin();
|
||||||
int64_t nNow = GetAdjustedTime();
|
int64 nNow = GetAdjustedTime();
|
||||||
int64_t nSince = nNow - 10 * 60;
|
int64 nSince = nNow - 10 * 60;
|
||||||
BOOST_FOREACH(CAddress& addr, vAddr)
|
BOOST_FOREACH(CAddress& addr, vAddr)
|
||||||
{
|
{
|
||||||
if (fShutdown)
|
if (fShutdown)
|
||||||
@ -2085,7 +2082,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
static uint256 hashSalt;
|
static uint256 hashSalt;
|
||||||
if (hashSalt == 0)
|
if (hashSalt == 0)
|
||||||
RAND_bytes((unsigned char*)&hashSalt, sizeof(hashSalt));
|
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));
|
hashRand = Hash(BEGIN(hashRand), END(hashRand));
|
||||||
multimap<uint256, CNode*> mapMix;
|
multimap<uint256, CNode*> mapMix;
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
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
|
// Nodes rebroadcast an addr every 24 hours
|
||||||
pfrom->vAddrToSend.clear();
|
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)
|
CRITICAL_BLOCK(cs_mapAddresses)
|
||||||
{
|
{
|
||||||
unsigned int nCount = 0;
|
unsigned int nCount = 0;
|
||||||
@ -2585,7 +2582,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
ResendWalletTransactions();
|
ResendWalletTransactions();
|
||||||
|
|
||||||
// Address refresh broadcast
|
// Address refresh broadcast
|
||||||
static int64_t nLastRebroadcast;
|
static int64 nLastRebroadcast;
|
||||||
if (GetTime() - nLastRebroadcast > 24 * 60 * 60)
|
if (GetTime() - nLastRebroadcast > 24 * 60 * 60)
|
||||||
{
|
{
|
||||||
nLastRebroadcast = GetTime();
|
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
|
// Clear out old addresses periodically so it's not too much work at once
|
||||||
static int64_t nLastClear;
|
static int64 nLastClear;
|
||||||
if (nLastClear == 0)
|
if (nLastClear == 0)
|
||||||
nLastClear = GetTime();
|
nLastClear = GetTime();
|
||||||
if (GetTime() - nLastClear > 10 * 60 && vNodes.size() >= 3)
|
if (GetTime() - nLastClear > 10 * 60 && vNodes.size() >= 3)
|
||||||
@ -2617,7 +2614,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
CRITICAL_BLOCK(cs_mapAddresses)
|
CRITICAL_BLOCK(cs_mapAddresses)
|
||||||
{
|
{
|
||||||
CAddrDB addrdb;
|
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();
|
for (map<vector<unsigned char>, CAddress>::iterator mi = mapAddresses.begin();
|
||||||
mi != mapAddresses.end();)
|
mi != mapAddresses.end();)
|
||||||
{
|
{
|
||||||
@ -2725,7 +2722,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
// Message: getdata
|
// Message: getdata
|
||||||
//
|
//
|
||||||
vector<CInv> vGetData;
|
vector<CInv> vGetData;
|
||||||
int64_t nNow = GetTime() * 1000000;
|
int64 nNow = GetTime() * 1000000;
|
||||||
CTxDB txdb("r");
|
CTxDB txdb("r");
|
||||||
while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)
|
while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)
|
||||||
{
|
{
|
||||||
@ -2880,7 +2877,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
|||||||
pblock->vtx.push_back(txNew);
|
pblock->vtx.push_back(txNew);
|
||||||
|
|
||||||
// Collect memory pool transactions into the block
|
// Collect memory pool transactions into the block
|
||||||
int64_t nFees = 0;
|
int64 nFees = 0;
|
||||||
CRITICAL_BLOCK(cs_main)
|
CRITICAL_BLOCK(cs_main)
|
||||||
CRITICAL_BLOCK(cs_mapTransactions)
|
CRITICAL_BLOCK(cs_mapTransactions)
|
||||||
{
|
{
|
||||||
@ -2916,7 +2913,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
|||||||
porphan->setDependsOn.insert(txin.prevout.hash);
|
porphan->setDependsOn.insert(txin.prevout.hash);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
|
int64 nValueIn = txPrev.vout[txin.prevout.n].nValue;
|
||||||
|
|
||||||
// Read block header
|
// Read block header
|
||||||
int nConf = txindex.GetDepthInMainChain();
|
int nConf = txindex.GetDepthInMainChain();
|
||||||
@ -2946,7 +2943,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
|||||||
|
|
||||||
// Collect transactions into block
|
// Collect transactions into block
|
||||||
map<uint256, CTxIndex> mapTestPool;
|
map<uint256, CTxIndex> mapTestPool;
|
||||||
uint64_t nBlockSize = 1000;
|
uint64 nBlockSize = 1000;
|
||||||
int nBlockSigOps = 100;
|
int nBlockSigOps = 100;
|
||||||
while (!mapPriority.empty())
|
while (!mapPriority.empty())
|
||||||
{
|
{
|
||||||
@ -2962,7 +2959,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
|
|||||||
|
|
||||||
// Transaction fee required depends on block size
|
// Transaction fee required depends on block size
|
||||||
bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority));
|
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
|
// Connecting shouldn't fail due to dependency on other memory pool transactions
|
||||||
// because we're already processing them in order of dependency
|
// because we're already processing them in order of dependency
|
||||||
@ -3172,7 +3169,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
//
|
//
|
||||||
// Search
|
// Search
|
||||||
//
|
//
|
||||||
int64_t nStart = GetTime();
|
int64 nStart = GetTime();
|
||||||
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
|
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
|
||||||
uint256 hashbuf[2];
|
uint256 hashbuf[2];
|
||||||
uint256& hash = *alignup<16>(hashbuf);
|
uint256& hash = *alignup<16>(hashbuf);
|
||||||
@ -3205,7 +3202,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Meter hashes/sec
|
// Meter hashes/sec
|
||||||
static int64_t nHashCounter;
|
static int64 nHashCounter;
|
||||||
if (nHPSTimerStart == 0)
|
if (nHPSTimerStart == 0)
|
||||||
{
|
{
|
||||||
nHPSTimerStart = GetTimeMillis();
|
nHPSTimerStart = GetTimeMillis();
|
||||||
@ -3225,7 +3222,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
nHashCounter = 0;
|
nHashCounter = 0;
|
||||||
string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);
|
string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0);
|
||||||
UIThreadCall(boost::bind(CalledSetStatusBar, strStatus, 0));
|
UIThreadCall(boost::bind(CalledSetStatusBar, strStatus, 0));
|
||||||
static int64_t nLogTime;
|
static int64 nLogTime;
|
||||||
if (GetTime() - nLogTime > 30 * 60)
|
if (GetTime() - nLogTime > 30 * 60)
|
||||||
{
|
{
|
||||||
nLogTime = GetTime();
|
nLogTime = GetTime();
|
||||||
|
66
src/main.h
66
src/main.h
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_MAIN_H
|
#ifndef BITCOIN_MAIN_H
|
||||||
#define BITCOIN_MAIN_H
|
#define BITCOIN_MAIN_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "bignum.h"
|
#include "bignum.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "key.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 = 1000000;
|
||||||
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
|
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
|
||||||
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
|
static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
|
||||||
static const int64_t COIN = 100000000;
|
static const int64 COIN = 100000000;
|
||||||
static const int64_t CENT = 1000000;
|
static const int64 CENT = 1000000;
|
||||||
static const int64_t MIN_TX_FEE = 50000;
|
static const int64 MIN_TX_FEE = 50000;
|
||||||
static const int64_t MIN_RELAY_TX_FEE = 10000;
|
static const int64 MIN_RELAY_TX_FEE = 10000;
|
||||||
static const int64_t MAX_MONEY = 21000000 * COIN;
|
static const int64 MAX_MONEY = 21000000 * COIN;
|
||||||
inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
||||||
static const int COINBASE_MATURITY = 100;
|
static const int COINBASE_MATURITY = 100;
|
||||||
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
|
// 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
|
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 CBlockIndex* pindexBest;
|
||||||
extern unsigned int nTransactionsUpdated;
|
extern unsigned int nTransactionsUpdated;
|
||||||
extern double dHashesPerSec;
|
extern double dHashesPerSec;
|
||||||
extern int64_t nHPSTimerStart;
|
extern int64 nHPSTimerStart;
|
||||||
extern int64_t nTimeBestReceived;
|
extern int64 nTimeBestReceived;
|
||||||
extern CCriticalSection cs_setpwalletRegistered;
|
extern CCriticalSection cs_setpwalletRegistered;
|
||||||
extern std::set<CWallet*> setpwalletRegistered;
|
extern std::set<CWallet*> setpwalletRegistered;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
extern int fGenerateBitcoins;
|
extern int fGenerateBitcoins;
|
||||||
extern int64_t nTransactionFee;
|
extern int64 nTransactionFee;
|
||||||
extern int fLimitProcessors;
|
extern int fLimitProcessors;
|
||||||
extern int nLimitProcessors;
|
extern int nLimitProcessors;
|
||||||
extern int fMinimizeToTray;
|
extern int fMinimizeToTray;
|
||||||
@ -92,7 +90,7 @@ class CTxIndex;
|
|||||||
void RegisterWallet(CWallet* pwalletIn);
|
void RegisterWallet(CWallet* pwalletIn);
|
||||||
void UnregisterWallet(CWallet* pwalletIn);
|
void UnregisterWallet(CWallet* pwalletIn);
|
||||||
bool ProcessBlock(CNode* pfrom, CBlock* pblock);
|
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* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
|
||||||
FILE* AppendBlockFile(unsigned int& nFileRet);
|
FILE* AppendBlockFile(unsigned int& nFileRet);
|
||||||
bool LoadBlockIndex(bool fAllowNew=true);
|
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);
|
void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1);
|
||||||
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
|
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
|
||||||
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
|
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();
|
int GetNumBlocksOfPeers();
|
||||||
bool IsInitialBlockDownload();
|
bool IsInitialBlockDownload();
|
||||||
std::string GetWarnings(std::string strFor);
|
std::string GetWarnings(std::string strFor);
|
||||||
@ -332,7 +330,7 @@ public:
|
|||||||
class CTxOut
|
class CTxOut
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int64_t nValue;
|
int64 nValue;
|
||||||
CScript scriptPubKey;
|
CScript scriptPubKey;
|
||||||
|
|
||||||
CTxOut()
|
CTxOut()
|
||||||
@ -340,7 +338,7 @@ public:
|
|||||||
SetNull();
|
SetNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
|
CTxOut(int64 nValueIn, CScript scriptPubKeyIn)
|
||||||
{
|
{
|
||||||
nValue = nValueIn;
|
nValue = nValueIn;
|
||||||
scriptPubKey = scriptPubKeyIn;
|
scriptPubKey = scriptPubKeyIn;
|
||||||
@ -451,7 +449,7 @@ public:
|
|||||||
return SerializeHash(*this);
|
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
|
// Time based nLockTime implemented in 0.1.6
|
||||||
if (nLockTime == 0)
|
if (nLockTime == 0)
|
||||||
@ -460,7 +458,7 @@ public:
|
|||||||
nBlockHeight = nBestHeight;
|
nBlockHeight = nBestHeight;
|
||||||
if (nBlockTime == 0)
|
if (nBlockTime == 0)
|
||||||
nBlockTime = GetAdjustedTime();
|
nBlockTime = GetAdjustedTime();
|
||||||
if ((int64_t)nLockTime < (nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
|
if ((int64)nLockTime < (nLockTime < LOCKTIME_THRESHOLD ? (int64)nBlockHeight : nBlockTime))
|
||||||
return true;
|
return true;
|
||||||
BOOST_FOREACH(const CTxIn& txin, vin)
|
BOOST_FOREACH(const CTxIn& txin, vin)
|
||||||
if (!txin.IsFinal())
|
if (!txin.IsFinal())
|
||||||
@ -505,9 +503,9 @@ public:
|
|||||||
bool IsStandard() const;
|
bool IsStandard() const;
|
||||||
bool AreInputsStandard(std::map<uint256, std::pair<CTxIndex, CTransaction> > mapInputs) 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)
|
BOOST_FOREACH(const CTxOut& txout, vout)
|
||||||
{
|
{
|
||||||
nValueOut += txout.nValue;
|
nValueOut += txout.nValue;
|
||||||
@ -524,14 +522,14 @@ public:
|
|||||||
return dPriority > COIN * 144 / 250;
|
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
|
// 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 nBytes = ::GetSerializeSize(*this, SER_NETWORK);
|
||||||
unsigned int nNewBlockSize = nBlockSize + nBytes;
|
unsigned int nNewBlockSize = nBlockSize + nBytes;
|
||||||
int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee;
|
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
|
||||||
|
|
||||||
if (fAllowFree)
|
if (fAllowFree)
|
||||||
{
|
{
|
||||||
@ -637,7 +635,7 @@ public:
|
|||||||
bool fBlock, bool fMiner, std::map<uint256, std::pair<CTxIndex, CTransaction> >& inputsRet);
|
bool fBlock, bool fMiner, std::map<uint256, std::pair<CTxIndex, CTransaction> >& inputsRet);
|
||||||
bool ConnectInputs(std::map<uint256, std::pair<CTxIndex, CTransaction> > inputs,
|
bool ConnectInputs(std::map<uint256, std::pair<CTxIndex, CTransaction> > inputs,
|
||||||
std::map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,
|
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 ClientConnectInputs();
|
||||||
bool CheckTransaction() const;
|
bool CheckTransaction() const;
|
||||||
bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
|
bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
|
||||||
@ -842,9 +840,9 @@ public:
|
|||||||
return Hash(BEGIN(nVersion), END(nNonce));
|
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;
|
return *phashBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetBlockTime() const
|
int64 GetBlockTime() const
|
||||||
{
|
{
|
||||||
return (int64_t)nTime;
|
return (int64)nTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBigNum GetBlockWork() const
|
CBigNum GetBlockWork() const
|
||||||
@ -1109,11 +1107,11 @@ public:
|
|||||||
|
|
||||||
enum { nMedianTimeSpan=11 };
|
enum { nMedianTimeSpan=11 };
|
||||||
|
|
||||||
int64_t GetMedianTimePast() const
|
int64 GetMedianTimePast() const
|
||||||
{
|
{
|
||||||
int64_t pmedian[nMedianTimeSpan];
|
int64 pmedian[nMedianTimeSpan];
|
||||||
int64_t* pbegin = &pmedian[nMedianTimeSpan];
|
int64* pbegin = &pmedian[nMedianTimeSpan];
|
||||||
int64_t* pend = &pmedian[nMedianTimeSpan];
|
int64* pend = &pmedian[nMedianTimeSpan];
|
||||||
|
|
||||||
const CBlockIndex* pindex = this;
|
const CBlockIndex* pindex = this;
|
||||||
for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
|
for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev)
|
||||||
@ -1123,7 +1121,7 @@ public:
|
|||||||
return pbegin[(pend - pbegin)/2];
|
return pbegin[(pend - pbegin)/2];
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetMedianTime() const
|
int64 GetMedianTime() const
|
||||||
{
|
{
|
||||||
const CBlockIndex* pindex = this;
|
const CBlockIndex* pindex = this;
|
||||||
for (int i = 0; i < nMedianTimeSpan/2; i++)
|
for (int i = 0; i < nMedianTimeSpan/2; i++)
|
||||||
@ -1377,8 +1375,8 @@ class CUnsignedAlert
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int nVersion;
|
int nVersion;
|
||||||
int64_t nRelayUntil; // when newer nodes stop relaying to newer nodes
|
int64 nRelayUntil; // when newer nodes stop relaying to newer nodes
|
||||||
int64_t nExpiration;
|
int64 nExpiration;
|
||||||
int nID;
|
int nID;
|
||||||
int nCancel;
|
int nCancel;
|
||||||
std::set<int> setCancel;
|
std::set<int> setCancel;
|
||||||
|
52
src/net.cpp
52
src/net.cpp
@ -3,8 +3,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "irc.h"
|
#include "irc.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
@ -46,10 +44,10 @@ bool OpenNetworkConnection(const CAddress& addrConnect);
|
|||||||
//
|
//
|
||||||
bool fClient = false;
|
bool fClient = false;
|
||||||
bool fAllowDNS = 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);
|
CAddress addrLocalHost("0.0.0.0", 0, false, nLocalServices);
|
||||||
static CNode* pnodeLocalHost = NULL;
|
static CNode* pnodeLocalHost = NULL;
|
||||||
uint64_t nLocalHostNonce = 0;
|
uint64 nLocalHostNonce = 0;
|
||||||
array<int, 10> vnThreadsRunning;
|
array<int, 10> vnThreadsRunning;
|
||||||
static SOCKET hListenSocket = INVALID_SOCKET;
|
static SOCKET hListenSocket = INVALID_SOCKET;
|
||||||
|
|
||||||
@ -58,9 +56,9 @@ CCriticalSection cs_vNodes;
|
|||||||
map<vector<unsigned char>, CAddress> mapAddresses;
|
map<vector<unsigned char>, CAddress> mapAddresses;
|
||||||
CCriticalSection cs_mapAddresses;
|
CCriticalSection cs_mapAddresses;
|
||||||
map<CInv, CDataStream> mapRelay;
|
map<CInv, CDataStream> mapRelay;
|
||||||
deque<pair<int64_t, CInv> > vRelayExpiration;
|
deque<pair<int64, CInv> > vRelayExpiration;
|
||||||
CCriticalSection cs_mapRelay;
|
CCriticalSection cs_mapRelay;
|
||||||
map<CInv, int64_t> mapAlreadyAskedFor;
|
map<CInv, int64> mapAlreadyAskedFor;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
int fUseProxy = false;
|
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())
|
if (!addr.IsRoutable())
|
||||||
return false;
|
return false;
|
||||||
if (addr.ip == addrLocalHost.ip)
|
if (addr.ip == addrLocalHost.ip)
|
||||||
return false;
|
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 fUpdated = false;
|
||||||
bool fNew = false;
|
bool fNew = false;
|
||||||
CAddress addrFound = addr;
|
CAddress addrFound = addr;
|
||||||
@ -471,7 +469,7 @@ bool AddAddress(CAddress addr, int64_t nTimePenalty, CAddrDB *pAddrDB)
|
|||||||
fUpdated = true;
|
fUpdated = true;
|
||||||
}
|
}
|
||||||
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
|
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)
|
if (addrFound.nTime < addr.nTime - nUpdateInterval)
|
||||||
{
|
{
|
||||||
// Periodically update most recently seen time
|
// Periodically update most recently seen time
|
||||||
@ -505,7 +503,7 @@ void AddressCurrentlyConnected(const CAddress& addr)
|
|||||||
if (it != mapAddresses.end())
|
if (it != mapAddresses.end())
|
||||||
{
|
{
|
||||||
CAddress& addrFound = (*it).second;
|
CAddress& addrFound = (*it).second;
|
||||||
int64_t nUpdateInterval = 20 * 60;
|
int64 nUpdateInterval = 20 * 60;
|
||||||
if (addrFound.nTime < GetAdjustedTime() - nUpdateInterval)
|
if (addrFound.nTime < GetAdjustedTime() - nUpdateInterval)
|
||||||
{
|
{
|
||||||
// Periodically update most recently seen time
|
// Periodically update most recently seen time
|
||||||
@ -644,7 +642,7 @@ CNode* FindNode(CAddress addr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CNode* ConnectNode(CAddress addrConnect, int64_t nTimeout)
|
CNode* ConnectNode(CAddress addrConnect, int64 nTimeout)
|
||||||
{
|
{
|
||||||
if (addrConnect.ip == addrLocalHost.ip)
|
if (addrConnect.ip == addrLocalHost.ip)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -732,7 +730,7 @@ void CNode::Cleanup()
|
|||||||
void CNode::PushVersion()
|
void CNode::PushVersion()
|
||||||
{
|
{
|
||||||
/// when NTP implemented, change to just nTime = GetAdjustedTime()
|
/// 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 addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
|
||||||
CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
|
CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
|
||||||
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
|
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;
|
CCriticalSection CNode::cs_setBanned;
|
||||||
|
|
||||||
void CNode::ClearBanned()
|
void CNode::ClearBanned()
|
||||||
@ -757,10 +755,10 @@ bool CNode::IsBanned(unsigned int ip)
|
|||||||
bool fResult = false;
|
bool fResult = false;
|
||||||
CRITICAL_BLOCK(cs_setBanned)
|
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())
|
if (i != setBanned.end())
|
||||||
{
|
{
|
||||||
int64_t t = (*i).second;
|
int64 t = (*i).second;
|
||||||
if (GetTime() < t)
|
if (GetTime() < t)
|
||||||
fResult = true;
|
fResult = true;
|
||||||
}
|
}
|
||||||
@ -779,7 +777,7 @@ bool CNode::Misbehaving(int howmuch)
|
|||||||
nMisbehavior += howmuch;
|
nMisbehavior += howmuch;
|
||||||
if (nMisbehavior >= GetArg("-banscore", 100))
|
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)
|
CRITICAL_BLOCK(cs_setBanned)
|
||||||
if (setBanned[addr.ip] < banTime)
|
if (setBanned[addr.ip] < banTime)
|
||||||
setBanned[addr.ip] = banTime;
|
setBanned[addr.ip] = banTime;
|
||||||
@ -1405,7 +1403,7 @@ void ThreadOpenConnections2(void* parg)
|
|||||||
// Connect to specific addresses
|
// Connect to specific addresses
|
||||||
if (mapArgs.count("-connect"))
|
if (mapArgs.count("-connect"))
|
||||||
{
|
{
|
||||||
for (int64_t nLoop = 0;; nLoop++)
|
for (int64 nLoop = 0;; nLoop++)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
|
BOOST_FOREACH(string strAddr, mapMultiArgs["-connect"])
|
||||||
{
|
{
|
||||||
@ -1439,7 +1437,7 @@ void ThreadOpenConnections2(void* parg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initiate network connections
|
// Initiate network connections
|
||||||
int64_t nStart = GetTime();
|
int64 nStart = GetTime();
|
||||||
loop
|
loop
|
||||||
{
|
{
|
||||||
// Limit outbound connections
|
// Limit outbound connections
|
||||||
@ -1476,7 +1474,7 @@ void ThreadOpenConnections2(void* parg)
|
|||||||
// it'll get a pile of addresses with newer timestamps.
|
// it'll get a pile of addresses with newer timestamps.
|
||||||
// Seed nodes are given a random 'last seen time' of between one and two
|
// Seed nodes are given a random 'last seen time' of between one and two
|
||||||
// weeks ago.
|
// weeks ago.
|
||||||
const int64_t nOneWeek = 7*24*60*60;
|
const int64 nOneWeek = 7*24*60*60;
|
||||||
CAddress addr;
|
CAddress addr;
|
||||||
addr.ip = pnSeed[i];
|
addr.ip = pnSeed[i];
|
||||||
addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
|
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
|
// Choose an address to connect to based on most recently seen
|
||||||
//
|
//
|
||||||
CAddress addrConnect;
|
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.
|
// Only connect to one address per a.b.?.? range.
|
||||||
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
|
// 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)
|
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||||
setConnected.insert(pnode->addr.ip & 0x0000ffff);
|
setConnected.insert(pnode->addr.ip & 0x0000ffff);
|
||||||
|
|
||||||
int64_t nANow = GetAdjustedTime();
|
int64 nANow = GetAdjustedTime();
|
||||||
|
|
||||||
CRITICAL_BLOCK(cs_mapAddresses)
|
CRITICAL_BLOCK(cs_mapAddresses)
|
||||||
{
|
{
|
||||||
@ -1508,11 +1506,11 @@ void ThreadOpenConnections2(void* parg)
|
|||||||
const CAddress& addr = item.second;
|
const CAddress& addr = item.second;
|
||||||
if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff))
|
if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff))
|
||||||
continue;
|
continue;
|
||||||
int64_t nSinceLastSeen = nANow - addr.nTime;
|
int64 nSinceLastSeen = nANow - addr.nTime;
|
||||||
int64_t nSinceLastTry = nANow - addr.nLastTry;
|
int64 nSinceLastTry = nANow - addr.nLastTry;
|
||||||
|
|
||||||
// Randomize the order in a deterministic way, putting the standard port first
|
// 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()))
|
if (addr.port != htons(GetDefaultPort()))
|
||||||
nRandomizer += 2 * 60 * 60;
|
nRandomizer += 2 * 60 * 60;
|
||||||
|
|
||||||
@ -1526,7 +1524,7 @@ void ThreadOpenConnections2(void* parg)
|
|||||||
// 30 days 27 hours
|
// 30 days 27 hours
|
||||||
// 90 days 46 hours
|
// 90 days 46 hours
|
||||||
// 365 days 93 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
|
// Fast reconnect for one hour after last seen
|
||||||
if (nSinceLastSeen < 60 * 60)
|
if (nSinceLastSeen < 60 * 60)
|
||||||
@ -1547,7 +1545,7 @@ void ThreadOpenConnections2(void* parg)
|
|||||||
|
|
||||||
// If multiple addresses are ready, prioritize by time since
|
// If multiple addresses are ready, prioritize by time since
|
||||||
// last seen and time since last tried.
|
// 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)
|
if (nScore > nBest)
|
||||||
{
|
{
|
||||||
nBest = nScore;
|
nBest = nScore;
|
||||||
@ -1854,7 +1852,7 @@ bool StopNode()
|
|||||||
printf("StopNode()\n");
|
printf("StopNode()\n");
|
||||||
fShutdown = true;
|
fShutdown = true;
|
||||||
nTransactionsUpdated++;
|
nTransactionsUpdated++;
|
||||||
int64_t nStart = GetTime();
|
int64 nStart = GetTime();
|
||||||
while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0
|
while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0
|
||||||
#ifdef USE_UPNP
|
#ifdef USE_UPNP
|
||||||
|| vnThreadsRunning[5] > 0
|
|| vnThreadsRunning[5] > 0
|
||||||
|
38
src/net.h
38
src/net.h
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_NET_H
|
#ifndef BITCOIN_NET_H
|
||||||
#define BITCOIN_NET_H
|
#define BITCOIN_NET_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
#include <boost/foreach.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, 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 Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
|
||||||
bool GetMyExternalIP(unsigned int& ipRet);
|
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);
|
void AddressCurrentlyConnected(const CAddress& addr);
|
||||||
CNode* FindNode(unsigned int ip);
|
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);
|
void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1);
|
||||||
bool AnySubscribed(unsigned int nChannel);
|
bool AnySubscribed(unsigned int nChannel);
|
||||||
void MapPort(bool fMapPort);
|
void MapPort(bool fMapPort);
|
||||||
@ -76,9 +74,9 @@ public:
|
|||||||
|
|
||||||
extern bool fClient;
|
extern bool fClient;
|
||||||
extern bool fAllowDNS;
|
extern bool fAllowDNS;
|
||||||
extern uint64_t nLocalServices;
|
extern uint64 nLocalServices;
|
||||||
extern CAddress addrLocalHost;
|
extern CAddress addrLocalHost;
|
||||||
extern uint64_t nLocalHostNonce;
|
extern uint64 nLocalHostNonce;
|
||||||
extern boost::array<int, 10> vnThreadsRunning;
|
extern boost::array<int, 10> vnThreadsRunning;
|
||||||
|
|
||||||
extern std::vector<CNode*> vNodes;
|
extern std::vector<CNode*> vNodes;
|
||||||
@ -86,9 +84,9 @@ extern CCriticalSection cs_vNodes;
|
|||||||
extern std::map<std::vector<unsigned char>, CAddress> mapAddresses;
|
extern std::map<std::vector<unsigned char>, CAddress> mapAddresses;
|
||||||
extern CCriticalSection cs_mapAddresses;
|
extern CCriticalSection cs_mapAddresses;
|
||||||
extern std::map<CInv, CDataStream> mapRelay;
|
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 CCriticalSection cs_mapRelay;
|
||||||
extern std::map<CInv, int64_t> mapAlreadyAskedFor;
|
extern std::map<CInv, int64> mapAlreadyAskedFor;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
extern int fUseProxy;
|
extern int fUseProxy;
|
||||||
@ -103,16 +101,16 @@ class CNode
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// socket
|
// socket
|
||||||
uint64_t nServices;
|
uint64 nServices;
|
||||||
SOCKET hSocket;
|
SOCKET hSocket;
|
||||||
CDataStream vSend;
|
CDataStream vSend;
|
||||||
CDataStream vRecv;
|
CDataStream vRecv;
|
||||||
CCriticalSection cs_vSend;
|
CCriticalSection cs_vSend;
|
||||||
CCriticalSection cs_vRecv;
|
CCriticalSection cs_vRecv;
|
||||||
int64_t nLastSend;
|
int64 nLastSend;
|
||||||
int64_t nLastRecv;
|
int64 nLastRecv;
|
||||||
int64_t nLastSendEmpty;
|
int64 nLastSendEmpty;
|
||||||
int64_t nTimeConnected;
|
int64 nTimeConnected;
|
||||||
unsigned int nHeaderStart;
|
unsigned int nHeaderStart;
|
||||||
unsigned int nMessageStart;
|
unsigned int nMessageStart;
|
||||||
CAddress addr;
|
CAddress addr;
|
||||||
@ -128,12 +126,12 @@ protected:
|
|||||||
|
|
||||||
// Denial-of-service detection/prevention
|
// Denial-of-service detection/prevention
|
||||||
// Key is ip address, value is banned-until-time
|
// 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;
|
static CCriticalSection cs_setBanned;
|
||||||
int nMisbehavior;
|
int nMisbehavior;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int64_t nReleaseTime;
|
int64 nReleaseTime;
|
||||||
std::map<uint256, CRequestTracker> mapRequests;
|
std::map<uint256, CRequestTracker> mapRequests;
|
||||||
CCriticalSection cs_mapRequests;
|
CCriticalSection cs_mapRequests;
|
||||||
uint256 hashContinue;
|
uint256 hashContinue;
|
||||||
@ -151,7 +149,7 @@ public:
|
|||||||
std::set<CInv> setInventoryKnown;
|
std::set<CInv> setInventoryKnown;
|
||||||
std::vector<CInv> vInventoryToSend;
|
std::vector<CInv> vInventoryToSend;
|
||||||
CCriticalSection cs_inventory;
|
CCriticalSection cs_inventory;
|
||||||
std::multimap<int64_t, CInv> mapAskFor;
|
std::multimap<int64, CInv> mapAskFor;
|
||||||
|
|
||||||
// publish and subscription
|
// publish and subscription
|
||||||
std::vector<char> vfSubscribe;
|
std::vector<char> vfSubscribe;
|
||||||
@ -219,7 +217,7 @@ public:
|
|||||||
return std::max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);
|
return std::max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CNode* AddRef(int64_t nTimeout=0)
|
CNode* AddRef(int64 nTimeout=0)
|
||||||
{
|
{
|
||||||
if (nTimeout != 0)
|
if (nTimeout != 0)
|
||||||
nReleaseTime = std::max(nReleaseTime, GetTime() + nTimeout);
|
nReleaseTime = std::max(nReleaseTime, GetTime() + nTimeout);
|
||||||
@ -267,12 +265,12 @@ public:
|
|||||||
{
|
{
|
||||||
// We're using mapAskFor as a priority queue,
|
// We're using mapAskFor as a priority queue,
|
||||||
// the key is the earliest time the request can be sent
|
// 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);
|
printf("askfor %s %"PRI64d"\n", inv.ToString().c_str(), nRequestTime);
|
||||||
|
|
||||||
// Make sure not to reuse time indexes to keep things in the same order
|
// Make sure not to reuse time indexes to keep things in the same order
|
||||||
int64_t nNow = (GetTime() - 1) * 1000000;
|
int64 nNow = (GetTime() - 1) * 1000000;
|
||||||
static int64_t nLastTime;
|
static int64 nLastTime;
|
||||||
nLastTime = nNow = std::max(nNow, ++nLastTime);
|
nLastTime = nNow = std::max(nNow, ++nLastTime);
|
||||||
|
|
||||||
// Each retry is 2 minutes after the last
|
// Each retry is 2 minutes after the last
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_NOUI_H
|
#ifndef BITCOIN_NOUI_H
|
||||||
#define BITCOIN_NOUI_H
|
#define BITCOIN_NOUI_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include "wallet.h"
|
#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);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -84,7 +82,7 @@ CAddress::CAddress()
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAddress::CAddress(unsigned int ipIn, unsigned short portIn, uint64_t nServicesIn)
|
CAddress::CAddress(unsigned int ipIn, unsigned short portIn, uint64 nServicesIn)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
ip = ipIn;
|
ip = ipIn;
|
||||||
@ -92,7 +90,7 @@ CAddress::CAddress(unsigned int ipIn, unsigned short portIn, uint64_t nServicesI
|
|||||||
nServices = nServicesIn;
|
nServices = nServicesIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAddress::CAddress(const struct sockaddr_in& sockaddr, uint64_t nServicesIn)
|
CAddress::CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
ip = sockaddr.sin_addr.s_addr;
|
ip = sockaddr.sin_addr.s_addr;
|
||||||
@ -100,25 +98,25 @@ CAddress::CAddress(const struct sockaddr_in& sockaddr, uint64_t nServicesIn)
|
|||||||
nServices = 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();
|
Init();
|
||||||
Lookup(pszIn, *this, nServicesIn, fNameLookup, portIn);
|
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();
|
Init();
|
||||||
Lookup(pszIn, *this, nServicesIn, fNameLookup, 0, true);
|
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();
|
Init();
|
||||||
Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, portIn);
|
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();
|
Init();
|
||||||
Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, 0, true);
|
Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, 0, true);
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
#ifndef __INCLUDED_PROTOCOL_H__
|
#ifndef __INCLUDED_PROTOCOL_H__
|
||||||
#define __INCLUDED_PROTOCOL_H__
|
#define __INCLUDED_PROTOCOL_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
@ -67,12 +65,12 @@ class CAddress
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAddress();
|
CAddress();
|
||||||
CAddress(unsigned int ipIn, unsigned short portIn=0, 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_t 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_t 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_t 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_t 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_t nServicesIn=NODE_NETWORK);
|
explicit CAddress(std::string strIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK);
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
@ -111,7 +109,7 @@ class CAddress
|
|||||||
|
|
||||||
// TODO: make private (improves encapsulation)
|
// TODO: make private (improves encapsulation)
|
||||||
public:
|
public:
|
||||||
uint64_t nServices;
|
uint64 nServices;
|
||||||
unsigned char pchReserved[12];
|
unsigned char pchReserved[12];
|
||||||
unsigned int ip;
|
unsigned int ip;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
@ -57,7 +56,7 @@ int ThreadSafeMessageBox(const std::string& message, const std::string& caption,
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadSafeAskFee(qint64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
|
bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
|
||||||
{
|
{
|
||||||
if(!guiref)
|
if(!guiref)
|
||||||
return false;
|
return false;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "guiconstants.h"
|
#include "guiconstants.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegExpValidator>
|
#include <QRegExpValidator>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef BITCOINFIELD_H
|
#ifndef BITCOINFIELD_H
|
||||||
#define BITCOINFIELD_H
|
#define BITCOINFIELD_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "macdockiconhandler.h"
|
#include "macdockiconhandler.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef BITCOINGUI_H
|
#ifndef BITCOINGUI_H
|
||||||
#define BITCOINGUI_H
|
#define BITCOINGUI_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "bitcoinunits.h"
|
#include "bitcoinunits.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
BitcoinUnits::BitcoinUnits(QObject *parent):
|
BitcoinUnits::BitcoinUnits(QObject *parent):
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef BITCOINUNITS_H
|
#ifndef BITCOINUNITS_H
|
||||||
#define BITCOINUNITS_H
|
#define BITCOINUNITS_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDoubleValidator>
|
#include <QDoubleValidator>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef GUIUTIL_H
|
#ifndef GUIUTIL_H
|
||||||
#define GUIUTIL_H
|
#define GUIUTIL_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "notificator.h"
|
#include "notificator.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "optionsmodel.h"
|
#include "optionsmodel.h"
|
||||||
#include "bitcoinunits.h"
|
#include "bitcoinunits.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef OPTIONSMODEL_H
|
#ifndef OPTIONSMODEL_H
|
||||||
#define OPTIONSMODEL_H
|
#define OPTIONSMODEL_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
class CWallet;
|
class CWallet;
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "guiutil.h"
|
#include "guiutil.h"
|
||||||
#include "guiconstants.h"
|
#include "guiconstants.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef OVERVIEWPAGE_H
|
#ifndef OVERVIEWPAGE_H
|
||||||
#define OVERVIEWPAGE_H
|
#define OVERVIEWPAGE_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "guiutil.h"
|
#include "guiutil.h"
|
||||||
#include "askpassphrasedialog.h"
|
#include "askpassphrasedialog.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef SENDCOINSDIALOG_H
|
#ifndef SENDCOINSDIALOG_H
|
||||||
#define SENDCOINSDIALOG_H
|
#define SENDCOINSDIALOG_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "qtui.h"
|
#include "qtui.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTextDocument> // For Qt::escape
|
#include <QTextDocument> // For Qt::escape
|
||||||
|
|
||||||
@ -56,10 +55,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
|||||||
strHTML.reserve(4000);
|
strHTML.reserve(4000);
|
||||||
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
|
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
|
||||||
|
|
||||||
qint64 nTime = wtx.GetTxTime();
|
int64 nTime = wtx.GetTxTime();
|
||||||
qint64 nCredit = wtx.GetCredit();
|
int64 nCredit = wtx.GetCredit();
|
||||||
qint64 nDebit = wtx.GetDebit();
|
int64 nDebit = wtx.GetDebit();
|
||||||
qint64 nNet = nCredit - nDebit;
|
int64 nNet = nCredit - nDebit;
|
||||||
|
|
||||||
strHTML += tr("<b>Status:</b> ") + FormatTxStatus(wtx);
|
strHTML += tr("<b>Status:</b> ") + FormatTxStatus(wtx);
|
||||||
int nRequests = wtx.GetRequestCount();
|
int nRequests = wtx.GetRequestCount();
|
||||||
@ -142,7 +141,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
|||||||
//
|
//
|
||||||
// Coinbase
|
// Coinbase
|
||||||
//
|
//
|
||||||
qint64 nUnmatured = 0;
|
int64 nUnmatured = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||||
nUnmatured += wallet->GetCredit(txout);
|
nUnmatured += wallet->GetCredit(txout);
|
||||||
strHTML += tr("<b>Credit:</b> ");
|
strHTML += tr("<b>Credit:</b> ");
|
||||||
@ -201,13 +200,13 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
|
|||||||
if (fAllToMe)
|
if (fAllToMe)
|
||||||
{
|
{
|
||||||
// Payment to self
|
// Payment to self
|
||||||
qint64 nChange = wtx.GetChange();
|
int64 nChange = wtx.GetChange();
|
||||||
qint64 nValue = nCredit - nChange;
|
int64 nValue = nCredit - nChange;
|
||||||
strHTML += tr("<b>Debit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
|
strHTML += tr("<b>Debit:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, -nValue) + "<br>";
|
||||||
strHTML += tr("<b>Credit:</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)
|
if (nTxFee > 0)
|
||||||
strHTML += tr("<b>Transaction fee:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-nTxFee) + "<br>";
|
strHTML += tr("<b>Transaction fee:</b> ") + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC,-nTxFee) + "<br>";
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "transactionfilterproxy.h"
|
#include "transactionfilterproxy.h"
|
||||||
#include "transactiontablemodel.h"
|
#include "transactiontablemodel.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef TRANSACTIONFILTERPROXY_H
|
#ifndef TRANSACTIONFILTERPROXY_H
|
||||||
#define TRANSACTIONFILTERPROXY_H
|
#define TRANSACTIONFILTERPROXY_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#include "transactionrecord.h"
|
#include "transactionrecord.h"
|
||||||
|
|
||||||
#include "headers.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> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
|
||||||
{
|
{
|
||||||
QList<TransactionRecord> parts;
|
QList<TransactionRecord> parts;
|
||||||
qint64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();
|
int64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();
|
||||||
qint64 nCredit = wtx.GetCredit(true);
|
int64 nCredit = wtx.GetCredit(true);
|
||||||
qint64 nDebit = wtx.GetDebit();
|
int64 nDebit = wtx.GetDebit();
|
||||||
qint64 nNet = nCredit - nDebit;
|
int64 nNet = nCredit - nDebit;
|
||||||
uint256 hash = wtx.GetHash();
|
uint256 hash = wtx.GetHash();
|
||||||
std::map<std::string, std::string> mapValue = wtx.mapValue;
|
std::map<std::string, std::string> mapValue = wtx.mapValue;
|
||||||
|
|
||||||
@ -60,7 +58,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
|||||||
|
|
||||||
if (nCredit == 0)
|
if (nCredit == 0)
|
||||||
{
|
{
|
||||||
qint64 nUnmatured = 0;
|
int64 nUnmatured = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
|
||||||
nUnmatured += wallet->GetCredit(txout);
|
nUnmatured += wallet->GetCredit(txout);
|
||||||
sub.credit = nUnmatured;
|
sub.credit = nUnmatured;
|
||||||
@ -105,7 +103,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
|||||||
if (fAllFromMe && fAllToMe)
|
if (fAllFromMe && fAllToMe)
|
||||||
{
|
{
|
||||||
// Payment to self
|
// Payment to self
|
||||||
qint64 nChange = wtx.GetChange();
|
int64 nChange = wtx.GetChange();
|
||||||
|
|
||||||
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
|
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
|
||||||
-(nDebit - nChange), nCredit - nChange));
|
-(nDebit - nChange), nCredit - nChange));
|
||||||
@ -115,7 +113,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
|||||||
//
|
//
|
||||||
// Debit
|
// Debit
|
||||||
//
|
//
|
||||||
qint64 nTxFee = nDebit - wtx.GetValueOut();
|
int64 nTxFee = nDebit - wtx.GetValueOut();
|
||||||
|
|
||||||
for (int nOut = 0; nOut < wtx.vout.size(); nOut++)
|
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 */
|
/* Add fee to first output */
|
||||||
if (nTxFee > 0)
|
if (nTxFee > 0)
|
||||||
{
|
{
|
||||||
@ -229,7 +227,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
|||||||
// For generated transactions, determine maturity
|
// For generated transactions, determine maturity
|
||||||
if(type == TransactionRecord::Generated)
|
if(type == TransactionRecord::Generated)
|
||||||
{
|
{
|
||||||
qint64 nCredit = wtx.GetCredit(true);
|
int64 nCredit = wtx.GetCredit(true);
|
||||||
if (nCredit == 0)
|
if (nCredit == 0)
|
||||||
{
|
{
|
||||||
status.maturity = TransactionStatus::Immature;
|
status.maturity = TransactionStatus::Immature;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
class CWallet;
|
class CWallet;
|
||||||
@ -47,8 +46,8 @@ public:
|
|||||||
/** @name Reported status
|
/** @name Reported status
|
||||||
@{*/
|
@{*/
|
||||||
Status status;
|
Status status;
|
||||||
qint64 depth;
|
int64 depth;
|
||||||
qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */
|
int64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** Current number of blocks (to know whether cached status is still valid) */
|
/** 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),
|
hash(hash), time(time), type(Other), address(""), debit(0),
|
||||||
credit(0), idx(0)
|
credit(0), idx(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionRecord(uint256 hash, qint64 time,
|
TransactionRecord(uint256 hash, int64 time,
|
||||||
Type type, const std::string &address,
|
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),
|
hash(hash), time(time), type(type), address(address), debit(debit), credit(credit),
|
||||||
idx(0)
|
idx(0)
|
||||||
{
|
{
|
||||||
@ -102,11 +101,11 @@ public:
|
|||||||
/** @name Immutable transaction attributes
|
/** @name Immutable transaction attributes
|
||||||
@{*/
|
@{*/
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
qint64 time;
|
int64 time;
|
||||||
Type type;
|
Type type;
|
||||||
std::string address;
|
std::string address;
|
||||||
qint64 debit;
|
int64 debit;
|
||||||
qint64 credit;
|
int64 credit;
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** Subtransaction index, for sort key */
|
/** Subtransaction index, for sort key */
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "editaddressdialog.h"
|
#include "editaddressdialog.h"
|
||||||
#include "optionsmodel.h"
|
#include "optionsmodel.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDoubleValidator>
|
#include <QDoubleValidator>
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
@ -121,7 +120,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
|
|||||||
CRITICAL_BLOCK(wallet->cs_wallet)
|
CRITICAL_BLOCK(wallet->cs_wallet)
|
||||||
{
|
{
|
||||||
// Sendmany
|
// Sendmany
|
||||||
std::vector<std::pair<CScript, qint64> > vecSend;
|
std::vector<std::pair<CScript, int64> > vecSend;
|
||||||
foreach(const SendCoinsRecipient &rcp, recipients)
|
foreach(const SendCoinsRecipient &rcp, recipients)
|
||||||
{
|
{
|
||||||
CScript scriptPubKey;
|
CScript scriptPubKey;
|
||||||
@ -131,7 +130,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
|
|||||||
|
|
||||||
CWalletTx wtx;
|
CWalletTx wtx;
|
||||||
CReserveKey keyChange(wallet);
|
CReserveKey keyChange(wallet);
|
||||||
qint64 nFeeRequired = 0;
|
int64 nFeeRequired = 0;
|
||||||
bool fCreated = wallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired);
|
bool fCreated = wallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired);
|
||||||
|
|
||||||
if(!fCreated)
|
if(!fCreated)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef WALLETMODEL_H
|
#ifndef WALLETMODEL_H
|
||||||
#define WALLETMODEL_H
|
#define WALLETMODEL_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#ifndef BITCOIN_EXTERNUI_H
|
#ifndef BITCOIN_EXTERNUI_H
|
||||||
#define BITCOIN_EXTERNUI_H
|
#define BITCOIN_EXTERNUI_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/function/function0.hpp>
|
#include <boost/function/function0.hpp>
|
||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
@ -41,7 +39,7 @@ typedef void wxWindow;
|
|||||||
extern int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
|
extern int MyMessageBox(const std::string& message, const std::string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
|
||||||
#define wxMessageBox MyMessageBox
|
#define wxMessageBox MyMessageBox
|
||||||
extern int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
|
extern int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
|
||||||
extern bool ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption, wxWindow* parent);
|
extern bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent);
|
||||||
extern void CalledSetStatusBar(const std::string& strText, int nField);
|
extern void CalledSetStatusBar(const std::string& strText, int nField);
|
||||||
extern void UIThreadCall(boost::function0<void> fn);
|
extern void UIThreadCall(boost::function0<void> fn);
|
||||||
extern void MainFrameRepaint();
|
extern void MainFrameRepaint();
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "init.h" // for pwalletMain
|
#include "init.h" // for pwalletMain
|
||||||
#include "bitcoinrpc.h"
|
#include "bitcoinrpc.h"
|
||||||
@ -33,7 +31,7 @@ class CTxDump
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBlockIndex *pindex;
|
CBlockIndex *pindex;
|
||||||
int64_t nValue;
|
int64 nValue;
|
||||||
bool fSpent;
|
bool fSpent;
|
||||||
CWalletTx* ptx;
|
CWalletTx* ptx;
|
||||||
int nOut;
|
int nOut;
|
||||||
|
14
src/script.h
14
src/script.h
@ -5,8 +5,6 @@
|
|||||||
#ifndef H_BITCOIN_SCRIPT
|
#ifndef H_BITCOIN_SCRIPT
|
||||||
#define H_BITCOIN_SCRIPT
|
#define H_BITCOIN_SCRIPT
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -221,7 +219,7 @@ inline std::string StackString(const std::vector<std::vector<unsigned char> >& v
|
|||||||
class CScript : public std::vector<unsigned char>
|
class CScript : public std::vector<unsigned char>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
CScript& push_int64(int64_t n)
|
CScript& push_int64(int64 n)
|
||||||
{
|
{
|
||||||
if (n == -1 || (n >= 1 && n <= 16))
|
if (n == -1 || (n >= 1 && n <= 16))
|
||||||
{
|
{
|
||||||
@ -235,7 +233,7 @@ protected:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CScript& push_uint64(uint64_t n)
|
CScript& push_uint64(uint64 n)
|
||||||
{
|
{
|
||||||
if (n >= 1 && n <= 16)
|
if (n >= 1 && n <= 16)
|
||||||
{
|
{
|
||||||
@ -275,12 +273,12 @@ public:
|
|||||||
explicit CScript(short b) { operator<<(b); }
|
explicit CScript(short b) { operator<<(b); }
|
||||||
explicit CScript(int b) { operator<<(b); }
|
explicit CScript(int b) { operator<<(b); }
|
||||||
explicit CScript(long b) { operator<<(b); }
|
explicit CScript(long b) { operator<<(b); }
|
||||||
explicit CScript(int64_t b) { operator<<(b); }
|
explicit CScript(int64 b) { operator<<(b); }
|
||||||
explicit CScript(unsigned char b) { operator<<(b); }
|
explicit CScript(unsigned char b) { operator<<(b); }
|
||||||
explicit CScript(unsigned int b) { operator<<(b); }
|
explicit CScript(unsigned int b) { operator<<(b); }
|
||||||
explicit CScript(unsigned short b) { operator<<(b); }
|
explicit CScript(unsigned short b) { operator<<(b); }
|
||||||
explicit CScript(unsigned long b) { operator<<(b); }
|
explicit CScript(unsigned long b) { operator<<(b); }
|
||||||
explicit CScript(uint64_t b) { operator<<(b); }
|
explicit CScript(uint64 b) { operator<<(b); }
|
||||||
|
|
||||||
explicit CScript(opcodetype b) { operator<<(b); }
|
explicit CScript(opcodetype b) { operator<<(b); }
|
||||||
explicit CScript(const uint256& b) { operator<<(b); }
|
explicit CScript(const uint256& b) { operator<<(b); }
|
||||||
@ -292,12 +290,12 @@ public:
|
|||||||
CScript& operator<<(short b) { return push_int64(b); }
|
CScript& operator<<(short b) { return push_int64(b); }
|
||||||
CScript& operator<<(int b) { return push_int64(b); }
|
CScript& operator<<(int b) { return push_int64(b); }
|
||||||
CScript& operator<<(long b) { return push_int64(b); }
|
CScript& operator<<(long b) { return push_int64(b); }
|
||||||
CScript& operator<<(int64_t 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 char b) { return push_uint64(b); }
|
||||||
CScript& operator<<(unsigned int 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 short b) { return push_uint64(b); }
|
||||||
CScript& operator<<(unsigned long b) { return push_uint64(b); }
|
CScript& operator<<(unsigned long b) { return push_uint64(b); }
|
||||||
CScript& operator<<(uint64_t b) { return push_uint64(b); }
|
CScript& operator<<(uint64 b) { return push_uint64(b); }
|
||||||
|
|
||||||
CScript& operator<<(opcodetype opcode)
|
CScript& operator<<(opcodetype opcode)
|
||||||
{
|
{
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_SERIALIZE_H
|
#ifndef BITCOIN_SERIALIZE_H
|
||||||
#define BITCOIN_SERIALIZE_H
|
#define BITCOIN_SERIALIZE_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -21,6 +19,9 @@
|
|||||||
#include <boost/tuple/tuple_comparison.hpp>
|
#include <boost/tuple/tuple_comparison.hpp>
|
||||||
#include <boost/tuple/tuple_io.hpp>
|
#include <boost/tuple/tuple_io.hpp>
|
||||||
|
|
||||||
|
typedef long long int64;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
// This is used to attempt to keep keying material out of swap
|
// This is used to attempt to keep keying material out of swap
|
||||||
@ -136,8 +137,8 @@ inline unsigned int GetSerializeSize(signed int a, int, int=0) { return size
|
|||||||
inline unsigned int GetSerializeSize(unsigned 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(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(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(int64 a, int, int=0) { return sizeof(a); }
|
||||||
inline unsigned int GetSerializeSize(uint64_t a, int, int=0) { return sizeof(a); }
|
inline unsigned int GetSerializeSize(uint64 a, int, int=0) { return sizeof(a); }
|
||||||
inline unsigned int GetSerializeSize(float 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); }
|
inline unsigned int GetSerializeSize(double a, int, int=0) { return sizeof(a); }
|
||||||
|
|
||||||
@ -150,8 +151,8 @@ template<typename Stream> inline void Serialize(Stream& s, signed int a, int
|
|||||||
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, 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, 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, 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, int64 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, uint64 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, 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 Serialize(Stream& s, double a, int, int=0) { WRITEDATA(s, a); }
|
||||||
|
|
||||||
@ -164,8 +165,8 @@ template<typename Stream> inline void Unserialize(Stream& s, signed int& 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, 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, 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, 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, int64& 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, uint64& 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, float& a, int, int=0) { READDATA(s, a); }
|
||||||
template<typename Stream> inline void Unserialize(Stream& s, double& a, int, int=0) { READDATA(s, a); }
|
template<typename Stream> inline void Unserialize(Stream& s, double& a, int, int=0) { READDATA(s, a); }
|
||||||
|
|
||||||
@ -185,16 +186,16 @@ template<typename Stream> inline void Unserialize(Stream& s, bool& a, int, int=0
|
|||||||
// size <= UINT_MAX -- 5 bytes (254 + 4 bytes)
|
// size <= UINT_MAX -- 5 bytes (254 + 4 bytes)
|
||||||
// size > UINT_MAX -- 9 bytes (255 + 8 bytes)
|
// size > UINT_MAX -- 9 bytes (255 + 8 bytes)
|
||||||
//
|
//
|
||||||
inline unsigned int GetSizeOfCompactSize(uint64_t nSize)
|
inline unsigned int GetSizeOfCompactSize(uint64 nSize)
|
||||||
{
|
{
|
||||||
if (nSize < 253) return sizeof(unsigned char);
|
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 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 if (nSize <= std::numeric_limits<unsigned int>::max()) return sizeof(unsigned char) + sizeof(unsigned int);
|
||||||
else return sizeof(unsigned char) + sizeof(uint64_t);
|
else return sizeof(unsigned char) + sizeof(uint64);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
void WriteCompactSize(Stream& os, uint64_t nSize)
|
void WriteCompactSize(Stream& os, uint64 nSize)
|
||||||
{
|
{
|
||||||
if (nSize < 253)
|
if (nSize < 253)
|
||||||
{
|
{
|
||||||
@ -218,7 +219,7 @@ void WriteCompactSize(Stream& os, uint64_t nSize)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned char chSize = 255;
|
unsigned char chSize = 255;
|
||||||
uint64_t xSize = nSize;
|
uint64 xSize = nSize;
|
||||||
WRITEDATA(os, chSize);
|
WRITEDATA(os, chSize);
|
||||||
WRITEDATA(os, xSize);
|
WRITEDATA(os, xSize);
|
||||||
}
|
}
|
||||||
@ -226,11 +227,11 @@ void WriteCompactSize(Stream& os, uint64_t nSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename Stream>
|
template<typename Stream>
|
||||||
uint64_t ReadCompactSize(Stream& is)
|
uint64 ReadCompactSize(Stream& is)
|
||||||
{
|
{
|
||||||
unsigned char chSize;
|
unsigned char chSize;
|
||||||
READDATA(is, chSize);
|
READDATA(is, chSize);
|
||||||
uint64_t nSizeRet = 0;
|
uint64 nSizeRet = 0;
|
||||||
if (chSize < 253)
|
if (chSize < 253)
|
||||||
{
|
{
|
||||||
nSizeRet = chSize;
|
nSizeRet = chSize;
|
||||||
@ -249,11 +250,11 @@ uint64_t ReadCompactSize(Stream& is)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint64_t xSize;
|
uint64 xSize;
|
||||||
READDATA(is, xSize);
|
READDATA(is, xSize);
|
||||||
nSizeRet = xSize;
|
nSizeRet = xSize;
|
||||||
}
|
}
|
||||||
if (nSizeRet > (uint64_t)MAX_SIZE)
|
if (nSizeRet > (uint64)MAX_SIZE)
|
||||||
throw std::ios_base::failure("ReadCompactSize() : size too large");
|
throw std::ios_base::failure("ReadCompactSize() : size too large");
|
||||||
return nSizeRet;
|
return nSizeRet;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Unit tests for denial-of-service detection/prevention code
|
// Unit tests for denial-of-service detection/prevention code
|
||||||
//
|
//
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
|
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
@ -52,7 +50,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
|
|||||||
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||||
{
|
{
|
||||||
CNode::ClearBanned();
|
CNode::ClearBanned();
|
||||||
int64_t nStartTime = GetTime();
|
int64 nStartTime = GetTime();
|
||||||
SetMockTime(nStartTime); // Overrides future calls to GetTime()
|
SetMockTime(nStartTime); // Overrides future calls to GetTime()
|
||||||
|
|
||||||
CAddress addr(0xa0b0c001);
|
CAddress addr(0xa0b0c001);
|
||||||
@ -68,11 +66,11 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
|||||||
BOOST_CHECK(!CNode::IsBanned(addr.ip));
|
BOOST_CHECK(!CNode::IsBanned(addr.ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CheckNBits(unsigned int nbits1, int64_t time1, unsigned int nbits2, int64_t time2)
|
static bool CheckNBits(unsigned int nbits1, int64 time1, unsigned int nbits2, int64 time2)
|
||||||
{
|
{
|
||||||
if (time1 > time2)
|
if (time1 > time2)
|
||||||
return CheckNBits(nbits2, time2, nbits1, time1);
|
return CheckNBits(nbits2, time2, nbits1, time1);
|
||||||
int64_t deltaTime = time2-time1;
|
int64 deltaTime = time2-time1;
|
||||||
|
|
||||||
CBigNum required;
|
CBigNum required;
|
||||||
required.SetCompact(ComputeMinWork(nbits1, deltaTime));
|
required.SetCompact(ComputeMinWork(nbits1, deltaTime));
|
||||||
@ -87,7 +85,7 @@ BOOST_AUTO_TEST_CASE(DoS_checknbits)
|
|||||||
|
|
||||||
// Timestamps,nBits from the bitcoin blockchain.
|
// Timestamps,nBits from the bitcoin blockchain.
|
||||||
// These are the block-chain checkpoint blocks
|
// These are the block-chain checkpoint blocks
|
||||||
typedef std::map<int64_t, unsigned int> BlockData;
|
typedef std::map<int64, unsigned int> BlockData;
|
||||||
BlockData chainData =
|
BlockData chainData =
|
||||||
map_list_of(1239852051,486604799)(1262749024,486594666)
|
map_list_of(1239852051,486604799)(1262749024,486594666)
|
||||||
(1279305360,469854461)(1280200847,469830746)(1281678674,469809688)
|
(1279305360,469854461)(1280200847,469830746)(1281678674,469809688)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/assign/list_of.hpp>
|
#include <boost/assign/list_of.hpp>
|
||||||
#include <boost/assign/list_inserter.hpp>
|
#include <boost/assign/list_inserter.hpp>
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
@ -12,7 +10,7 @@ BOOST_AUTO_TEST_CASE(uint160_equality)
|
|||||||
uint160 num2 = 11;
|
uint160 num2 = 11;
|
||||||
BOOST_CHECK(num1+1 == num2);
|
BOOST_CHECK(num1+1 == num2);
|
||||||
|
|
||||||
uint64_t num3 = 10;
|
uint64 num3 = 10;
|
||||||
BOOST_CHECK(num1 == num3);
|
BOOST_CHECK(num1 == num3);
|
||||||
BOOST_CHECK(num1+num2 == num3+num2);
|
BOOST_CHECK(num1+num2 == num3+num2);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
@ -12,7 +10,7 @@ BOOST_AUTO_TEST_CASE(uint256_equality)
|
|||||||
uint256 num2 = 11;
|
uint256 num2 = 11;
|
||||||
BOOST_CHECK(num1+1 == num2);
|
BOOST_CHECK(num1+1 == num2);
|
||||||
|
|
||||||
uint64_t num3 = 10;
|
uint64 num3 = 10;
|
||||||
BOOST_CHECK(num1 == num3);
|
BOOST_CHECK(num1 == num3);
|
||||||
BOOST_CHECK(num1+num2 == num3+num2);
|
BOOST_CHECK(num1+num2 == num3+num2);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
@ -188,7 +186,7 @@ BOOST_AUTO_TEST_CASE(util_FormatMoney)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(util_ParseMoney)
|
BOOST_AUTO_TEST_CASE(util_ParseMoney)
|
||||||
{
|
{
|
||||||
int64_t ret = 0;
|
int64 ret = 0;
|
||||||
BOOST_CHECK(ParseMoney("0.0", ret));
|
BOOST_CHECK(ParseMoney("0.0", ret));
|
||||||
BOOST_CHECK_EQUAL(ret, 0);
|
BOOST_CHECK_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
@ -5,14 +5,15 @@
|
|||||||
#ifndef BITCOIN_UINT256_H
|
#ifndef BITCOIN_UINT256_H
|
||||||
#define BITCOIN_UINT256_H
|
#define BITCOIN_UINT256_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "serialize.h"
|
#include "serialize.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
typedef long long int64;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
|
||||||
|
|
||||||
inline int Testuint256AdHoc(std::vector<std::string> vArg);
|
inline int Testuint256AdHoc(std::vector<std::string> vArg);
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
base_uint& operator=(uint64_t b)
|
base_uint& operator=(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] = (unsigned int)b;
|
pn[0] = (unsigned int)b;
|
||||||
pn[1] = (unsigned int)(b >> 32);
|
pn[1] = (unsigned int)(b >> 32);
|
||||||
@ -84,21 +85,21 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint& operator^=(uint64_t b)
|
base_uint& operator^=(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] ^= (unsigned int)b;
|
pn[0] ^= (unsigned int)b;
|
||||||
pn[1] ^= (unsigned int)(b >> 32);
|
pn[1] ^= (unsigned int)(b >> 32);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint& operator&=(uint64_t b)
|
base_uint& operator&=(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] &= (unsigned int)b;
|
pn[0] &= (unsigned int)b;
|
||||||
pn[1] &= (unsigned int)(b >> 32);
|
pn[1] &= (unsigned int)(b >> 32);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint& operator|=(uint64_t b)
|
base_uint& operator|=(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] |= (unsigned int)b;
|
pn[0] |= (unsigned int)b;
|
||||||
pn[1] |= (unsigned int)(b >> 32);
|
pn[1] |= (unsigned int)(b >> 32);
|
||||||
@ -141,10 +142,10 @@ public:
|
|||||||
|
|
||||||
base_uint& operator+=(const base_uint& b)
|
base_uint& operator+=(const base_uint& b)
|
||||||
{
|
{
|
||||||
uint64_t carry = 0;
|
uint64 carry = 0;
|
||||||
for (int i = 0; i < WIDTH; i++)
|
for (int i = 0; i < WIDTH; i++)
|
||||||
{
|
{
|
||||||
uint64_t n = carry + pn[i] + b.pn[i];
|
uint64 n = carry + pn[i] + b.pn[i];
|
||||||
pn[i] = n & 0xffffffff;
|
pn[i] = n & 0xffffffff;
|
||||||
carry = n >> 32;
|
carry = n >> 32;
|
||||||
}
|
}
|
||||||
@ -157,7 +158,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint& operator+=(uint64_t b64)
|
base_uint& operator+=(uint64 b64)
|
||||||
{
|
{
|
||||||
base_uint b;
|
base_uint b;
|
||||||
b = b64;
|
b = b64;
|
||||||
@ -165,7 +166,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_uint& operator-=(uint64_t b64)
|
base_uint& operator-=(uint64 b64)
|
||||||
{
|
{
|
||||||
base_uint b;
|
base_uint b;
|
||||||
b = b64;
|
b = b64;
|
||||||
@ -265,7 +266,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend inline bool operator==(const base_uint& a, uint64_t b)
|
friend inline bool operator==(const base_uint& a, uint64 b)
|
||||||
{
|
{
|
||||||
if (a.pn[0] != (unsigned int)b)
|
if (a.pn[0] != (unsigned int)b)
|
||||||
return false;
|
return false;
|
||||||
@ -282,7 +283,7 @@ public:
|
|||||||
return (!(a == b));
|
return (!(a == b));
|
||||||
}
|
}
|
||||||
|
|
||||||
friend inline bool operator!=(const base_uint& a, uint64_t b)
|
friend inline bool operator!=(const base_uint& a, uint64 b)
|
||||||
{
|
{
|
||||||
return (!(a == b));
|
return (!(a == b));
|
||||||
}
|
}
|
||||||
@ -419,7 +420,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint160(uint64_t b)
|
uint160(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] = (unsigned int)b;
|
pn[0] = (unsigned int)b;
|
||||||
pn[1] = (unsigned int)(b >> 32);
|
pn[1] = (unsigned int)(b >> 32);
|
||||||
@ -427,7 +428,7 @@ public:
|
|||||||
pn[i] = 0;
|
pn[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint160& operator=(uint64_t b)
|
uint160& operator=(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] = (unsigned int)b;
|
pn[0] = (unsigned int)b;
|
||||||
pn[1] = (unsigned int)(b >> 32);
|
pn[1] = (unsigned int)(b >> 32);
|
||||||
@ -450,8 +451,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const uint160& a, uint64_t 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 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 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; }
|
inline const uint160 operator<<(const uint160& a, unsigned int shift) { return uint160(a) <<= shift; }
|
||||||
@ -533,7 +534,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256(uint64_t b)
|
uint256(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] = (unsigned int)b;
|
pn[0] = (unsigned int)b;
|
||||||
pn[1] = (unsigned int)(b >> 32);
|
pn[1] = (unsigned int)(b >> 32);
|
||||||
@ -541,7 +542,7 @@ public:
|
|||||||
pn[i] = 0;
|
pn[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256& operator=(uint64_t b)
|
uint256& operator=(uint64 b)
|
||||||
{
|
{
|
||||||
pn[0] = (unsigned int)b;
|
pn[0] = (unsigned int)b;
|
||||||
pn[1] = (unsigned int)(b >> 32);
|
pn[1] = (unsigned int)(b >> 32);
|
||||||
@ -564,8 +565,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const uint256& a, uint64_t 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 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 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, unsigned int shift) { return uint256(a) <<= shift; }
|
||||||
|
57
src/util.cpp
57
src/util.cpp
@ -2,9 +2,6 @@
|
|||||||
// Copyright (c) 2011 The Bitcoin developers
|
// Copyright (c) 2011 The Bitcoin developers
|
||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "strlcpy.h"
|
#include "strlcpy.h"
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
@ -34,7 +31,7 @@ string strMiscWarning;
|
|||||||
bool fTestNet = false;
|
bool fTestNet = false;
|
||||||
bool fNoListen = false;
|
bool fNoListen = false;
|
||||||
bool fLogTimestamps = false;
|
bool fLogTimestamps = false;
|
||||||
CMedianFilter<int64_t> vTimeOffsets(200,0);
|
CMedianFilter<int64> vTimeOffsets(200,0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +94,7 @@ instance_of_cinit;
|
|||||||
void RandAddSeed()
|
void RandAddSeed()
|
||||||
{
|
{
|
||||||
// Seed with CPU performance counter
|
// Seed with CPU performance counter
|
||||||
int64_t nCounter = GetPerformanceCounter();
|
int64 nCounter = GetPerformanceCounter();
|
||||||
RAND_add(&nCounter, sizeof(nCounter), 1.5);
|
RAND_add(&nCounter, sizeof(nCounter), 1.5);
|
||||||
memset(&nCounter, 0, sizeof(nCounter));
|
memset(&nCounter, 0, sizeof(nCounter));
|
||||||
}
|
}
|
||||||
@ -107,7 +104,7 @@ void RandAddSeedPerfmon()
|
|||||||
RandAddSeed();
|
RandAddSeed();
|
||||||
|
|
||||||
// This can take up to 2 seconds, so only do it every 10 minutes
|
// This can take up to 2 seconds, so only do it every 10 minutes
|
||||||
static int64_t nLastPerfmon;
|
static int64 nLastPerfmon;
|
||||||
if (GetTime() < nLastPerfmon + 10 * 60)
|
if (GetTime() < nLastPerfmon + 10 * 60)
|
||||||
return;
|
return;
|
||||||
nLastPerfmon = GetTime();
|
nLastPerfmon = GetTime();
|
||||||
@ -129,15 +126,15 @@ void RandAddSeedPerfmon()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetRand(uint64_t nMax)
|
uint64 GetRand(uint64 nMax)
|
||||||
{
|
{
|
||||||
if (nMax == 0)
|
if (nMax == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// The range of the random source must be a multiple of the modulus
|
// The range of the random source must be a multiple of the modulus
|
||||||
// to give every possible output value an equal possibility
|
// to give every possible output value an equal possibility
|
||||||
uint64_t nRange = (std::numeric_limits<uint64_t>::max() / nMax) * nMax;
|
uint64 nRange = (std::numeric_limits<uint64>::max() / nMax) * nMax;
|
||||||
uint64_t nRand = 0;
|
uint64 nRand = 0;
|
||||||
do
|
do
|
||||||
RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
|
RAND_bytes((unsigned char*)&nRand, sizeof(nRand));
|
||||||
while (nRand >= nRange);
|
while (nRand >= nRange);
|
||||||
@ -333,13 +330,13 @@ void ParseString(const string& str, char c, vector<string>& v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string FormatMoney(int64_t n, bool fPlus)
|
string FormatMoney(int64 n, bool fPlus)
|
||||||
{
|
{
|
||||||
// Note: not using straight sprintf here because we do NOT want
|
// Note: not using straight sprintf here because we do NOT want
|
||||||
// localized number formatting.
|
// localized number formatting.
|
||||||
int64_t n_abs = (n > 0 ? n : -n);
|
int64 n_abs = (n > 0 ? n : -n);
|
||||||
int64_t quotient = n_abs/COIN;
|
int64 quotient = n_abs/COIN;
|
||||||
int64_t remainder = n_abs%COIN;
|
int64 remainder = n_abs%COIN;
|
||||||
string str = strprintf("%"PRI64d".%08"PRI64d, quotient, remainder);
|
string str = strprintf("%"PRI64d".%08"PRI64d, quotient, remainder);
|
||||||
|
|
||||||
// Right-trim excess 0's before the decimal point:
|
// Right-trim excess 0's before the decimal point:
|
||||||
@ -357,15 +354,15 @@ string FormatMoney(int64_t n, bool fPlus)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ParseMoney(const string& str, int64_t& nRet)
|
bool ParseMoney(const string& str, int64& nRet)
|
||||||
{
|
{
|
||||||
return ParseMoney(str.c_str(), nRet);
|
return ParseMoney(str.c_str(), nRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParseMoney(const char* pszIn, int64_t& nRet)
|
bool ParseMoney(const char* pszIn, int64& nRet)
|
||||||
{
|
{
|
||||||
string strWhole;
|
string strWhole;
|
||||||
int64_t nUnits = 0;
|
int64 nUnits = 0;
|
||||||
const char* p = pszIn;
|
const char* p = pszIn;
|
||||||
while (isspace(*p))
|
while (isspace(*p))
|
||||||
p++;
|
p++;
|
||||||
@ -374,7 +371,7 @@ bool ParseMoney(const char* pszIn, int64_t& nRet)
|
|||||||
if (*p == '.')
|
if (*p == '.')
|
||||||
{
|
{
|
||||||
p++;
|
p++;
|
||||||
int64_t nMult = CENT*10;
|
int64 nMult = CENT*10;
|
||||||
while (isdigit(*p) && (nMult > 0))
|
while (isdigit(*p) && (nMult > 0))
|
||||||
{
|
{
|
||||||
nUnits += nMult * (*p++ - '0');
|
nUnits += nMult * (*p++ - '0');
|
||||||
@ -395,8 +392,8 @@ bool ParseMoney(const char* pszIn, int64_t& nRet)
|
|||||||
return false;
|
return false;
|
||||||
if (nUnits < 0 || nUnits > COIN)
|
if (nUnits < 0 || nUnits > COIN)
|
||||||
return false;
|
return false;
|
||||||
int64_t nWhole = atoi64(strWhole);
|
int64 nWhole = atoi64(strWhole);
|
||||||
int64_t nValue = nWhole*COIN + nUnits;
|
int64 nValue = nWhole*COIN + nUnits;
|
||||||
|
|
||||||
nRet = nValue;
|
nRet = nValue;
|
||||||
return true;
|
return true;
|
||||||
@ -913,30 +910,30 @@ void ShrinkDebugFile()
|
|||||||
// - Median of other nodes's clocks
|
// - Median of other nodes's clocks
|
||||||
// - The user (asking the user to fix the system clock if the first two disagree)
|
// - The user (asking the user to fix the system clock if the first two disagree)
|
||||||
//
|
//
|
||||||
static int64_t nMockTime = 0; // For unit testing
|
static int64 nMockTime = 0; // For unit testing
|
||||||
|
|
||||||
int64_t GetTime()
|
int64 GetTime()
|
||||||
{
|
{
|
||||||
if (nMockTime) return nMockTime;
|
if (nMockTime) return nMockTime;
|
||||||
|
|
||||||
return time(NULL);
|
return time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMockTime(int64_t nMockTimeIn)
|
void SetMockTime(int64 nMockTimeIn)
|
||||||
{
|
{
|
||||||
nMockTime = nMockTimeIn;
|
nMockTime = nMockTimeIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t nTimeOffset = 0;
|
static int64 nTimeOffset = 0;
|
||||||
|
|
||||||
int64_t GetAdjustedTime()
|
int64 GetAdjustedTime()
|
||||||
{
|
{
|
||||||
return GetTime() + nTimeOffset;
|
return GetTime() + nTimeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTimeData(unsigned int ip, int64_t nTime)
|
void AddTimeData(unsigned int ip, int64 nTime)
|
||||||
{
|
{
|
||||||
int64_t nOffsetSample = nTime - GetTime();
|
int64 nOffsetSample = nTime - GetTime();
|
||||||
|
|
||||||
// Ignore duplicates
|
// Ignore duplicates
|
||||||
static set<unsigned int> setKnown;
|
static set<unsigned int> setKnown;
|
||||||
@ -948,8 +945,8 @@ void AddTimeData(unsigned int ip, int64_t nTime)
|
|||||||
printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
|
printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);
|
||||||
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
|
if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
|
||||||
{
|
{
|
||||||
int64_t nMedian = vTimeOffsets.median();
|
int64 nMedian = vTimeOffsets.median();
|
||||||
std::vector<int64_t> vSorted = vTimeOffsets.sorted();
|
std::vector<int64> vSorted = vTimeOffsets.sorted();
|
||||||
// Only let other nodes change our time by so much
|
// Only let other nodes change our time by so much
|
||||||
if (abs64(nMedian) < 70 * 60)
|
if (abs64(nMedian) < 70 * 60)
|
||||||
{
|
{
|
||||||
@ -964,7 +961,7 @@ void AddTimeData(unsigned int ip, int64_t nTime)
|
|||||||
{
|
{
|
||||||
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
|
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
|
||||||
bool fMatch = false;
|
bool fMatch = false;
|
||||||
BOOST_FOREACH(int64_t nOffset, vSorted)
|
BOOST_FOREACH(int64 nOffset, vSorted)
|
||||||
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
|
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
|
||||||
fMatch = true;
|
fMatch = true;
|
||||||
|
|
||||||
@ -979,7 +976,7 @@ void AddTimeData(unsigned int ip, int64_t nTime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fDebug) {
|
if (fDebug) {
|
||||||
BOOST_FOREACH(int64_t n, vSorted)
|
BOOST_FOREACH(int64 n, vSorted)
|
||||||
printf("%+"PRI64d" ", n);
|
printf("%+"PRI64d" ", n);
|
||||||
printf("| ");
|
printf("| ");
|
||||||
}
|
}
|
||||||
|
45
src/util.h
45
src/util.h
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_UTIL_H
|
#ifndef BITCOIN_UTIL_H
|
||||||
#define BITCOIN_UTIL_H
|
#define BITCOIN_UTIL_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@ -27,6 +25,9 @@
|
|||||||
#include <openssl/ripemd.h>
|
#include <openssl/ripemd.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef long long int64;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
|
||||||
#define loop for (;;)
|
#define loop for (;;)
|
||||||
#define BEGIN(a) ((char*)&(a))
|
#define BEGIN(a) ((char*)&(a))
|
||||||
#define END(a) ((char*)&((&(a))[1]))
|
#define END(a) ((char*)&((&(a))[1]))
|
||||||
@ -97,7 +98,7 @@ typedef u_int SOCKET;
|
|||||||
#define _strlwr(psz) to_lower(psz)
|
#define _strlwr(psz) to_lower(psz)
|
||||||
#define MAX_PATH 1024
|
#define MAX_PATH 1024
|
||||||
#define Beep(n1,n2) (0)
|
#define Beep(n1,n2) (0)
|
||||||
inline void Sleep(int64_t n)
|
inline void Sleep(int64 n)
|
||||||
{
|
{
|
||||||
boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n));
|
boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n));
|
||||||
}
|
}
|
||||||
@ -157,9 +158,9 @@ void LogException(std::exception* pex, const char* pszThread);
|
|||||||
void PrintException(std::exception* pex, const char* pszThread);
|
void PrintException(std::exception* pex, const char* pszThread);
|
||||||
void PrintExceptionContinue(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);
|
void ParseString(const std::string& str, char c, std::vector<std::string>& v);
|
||||||
std::string FormatMoney(int64_t n, bool fPlus=false);
|
std::string FormatMoney(int64 n, bool fPlus=false);
|
||||||
bool ParseMoney(const std::string& str, int64_t& nRet);
|
bool ParseMoney(const std::string& str, int64& nRet);
|
||||||
bool ParseMoney(const char* pszIn, int64_t& nRet);
|
bool ParseMoney(const char* pszIn, int64& nRet);
|
||||||
std::vector<unsigned char> ParseHex(const char* psz);
|
std::vector<unsigned char> ParseHex(const char* psz);
|
||||||
std::vector<unsigned char> ParseHex(const std::string& str);
|
std::vector<unsigned char> ParseHex(const std::string& str);
|
||||||
std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid = NULL);
|
std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid = NULL);
|
||||||
@ -182,11 +183,11 @@ std::string GetDefaultDataDir();
|
|||||||
std::string GetDataDir();
|
std::string GetDataDir();
|
||||||
void ShrinkDebugFile();
|
void ShrinkDebugFile();
|
||||||
int GetRandInt(int nMax);
|
int GetRandInt(int nMax);
|
||||||
uint64_t GetRand(uint64_t nMax);
|
uint64 GetRand(uint64 nMax);
|
||||||
int64_t GetTime();
|
int64 GetTime();
|
||||||
void SetMockTime(int64_t nMockTimeIn);
|
void SetMockTime(int64 nMockTimeIn);
|
||||||
int64_t GetAdjustedTime();
|
int64 GetAdjustedTime();
|
||||||
void AddTimeData(unsigned int ip, int64_t nTime);
|
void AddTimeData(unsigned int ip, int64 nTime);
|
||||||
std::string FormatFullVersion();
|
std::string FormatFullVersion();
|
||||||
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
|
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
|
||||||
|
|
||||||
@ -283,7 +284,7 @@ typedef std::basic_string<char, std::char_traits<char>, secure_allocator<char> >
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline std::string i64tostr(int64_t n)
|
inline std::string i64tostr(int64 n)
|
||||||
{
|
{
|
||||||
return strprintf("%"PRI64d, n);
|
return strprintf("%"PRI64d, n);
|
||||||
}
|
}
|
||||||
@ -293,7 +294,7 @@ inline std::string itostr(int n)
|
|||||||
return strprintf("%d", n);
|
return strprintf("%d", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int64_t atoi64(const char* psz)
|
inline int64 atoi64(const char* psz)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
return _atoi64(psz);
|
return _atoi64(psz);
|
||||||
@ -302,7 +303,7 @@ inline int64_t atoi64(const char* psz)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int64_t atoi64(const std::string& str)
|
inline int64 atoi64(const std::string& str)
|
||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
return _atoi64(str.c_str());
|
return _atoi64(str.c_str());
|
||||||
@ -321,12 +322,12 @@ inline int roundint(double d)
|
|||||||
return (int)(d > 0 ? d + 0.5 : d - 0.5);
|
return (int)(d > 0 ? d + 0.5 : d - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int64_t roundint64(double d)
|
inline int64 roundint64(double d)
|
||||||
{
|
{
|
||||||
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
|
return (int64)(d > 0 ? d + 0.5 : d - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int64_t abs64(int64_t n)
|
inline int64 abs64(int64 n)
|
||||||
{
|
{
|
||||||
return (n >= 0 ? n : -n);
|
return (n >= 0 ? n : -n);
|
||||||
}
|
}
|
||||||
@ -380,9 +381,9 @@ inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszForma
|
|||||||
printf(pszFormat, HexStr(vch, fSpaces).c_str());
|
printf(pszFormat, HexStr(vch, fSpaces).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int64_t GetPerformanceCounter()
|
inline int64 GetPerformanceCounter()
|
||||||
{
|
{
|
||||||
int64_t nCounter = 0;
|
int64 nCounter = 0;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
|
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
|
||||||
#else
|
#else
|
||||||
@ -393,13 +394,13 @@ inline int64_t GetPerformanceCounter()
|
|||||||
return nCounter;
|
return nCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int64_t GetTimeMillis()
|
inline int64 GetTimeMillis()
|
||||||
{
|
{
|
||||||
return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -
|
return (boost::posix_time::ptime(boost::posix_time::microsec_clock::universal_time()) -
|
||||||
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
|
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
|
inline std::string DateTimeStrFormat(const char* pszFormat, int64 nTime)
|
||||||
{
|
{
|
||||||
time_t n = nTime;
|
time_t n = nTime;
|
||||||
struct tm* ptmTime = gmtime(&n);
|
struct tm* ptmTime = gmtime(&n);
|
||||||
@ -431,7 +432,7 @@ inline std::string GetArg(const std::string& strArg, const std::string& strDefau
|
|||||||
return strDefault;
|
return strDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int64_t GetArg(const std::string& strArg, int64_t nDefault)
|
inline int64 GetArg(const std::string& strArg, int64 nDefault)
|
||||||
{
|
{
|
||||||
if (mapArgs.count(strArg))
|
if (mapArgs.count(strArg))
|
||||||
return atoi64(mapArgs[strArg]);
|
return atoi64(mapArgs[strArg]);
|
||||||
|
126
src/wallet.cpp
126
src/wallet.cpp
@ -3,8 +3,6 @@
|
|||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "crypter.h"
|
#include "crypter.h"
|
||||||
@ -92,7 +90,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
|
|||||||
return false;
|
return false;
|
||||||
if (CCryptoKeyStore::Unlock(vMasterKey))
|
if (CCryptoKeyStore::Unlock(vMasterKey))
|
||||||
{
|
{
|
||||||
int64_t nStartTime = GetTimeMillis();
|
int64 nStartTime = GetTimeMillis();
|
||||||
crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod);
|
crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod);
|
||||||
pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIterations * (100 / ((double)(GetTimeMillis() - nStartTime)));
|
pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIterations * (100 / ((double)(GetTimeMillis() - nStartTime)));
|
||||||
|
|
||||||
@ -151,7 +149,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
|
|||||||
RAND_bytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE);
|
RAND_bytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE);
|
||||||
|
|
||||||
CCrypter crypter;
|
CCrypter crypter;
|
||||||
int64_t nStartTime = GetTimeMillis();
|
int64 nStartTime = GetTimeMillis();
|
||||||
crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod);
|
crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod);
|
||||||
kMasterKey.nDeriveIterations = 2500000 / ((double)(GetTimeMillis() - nStartTime));
|
kMasterKey.nDeriveIterations = 2500000 / ((double)(GetTimeMillis() - nStartTime));
|
||||||
|
|
||||||
@ -369,7 +367,7 @@ bool CWallet::IsMine(const CTxIn &txin) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CWallet::GetDebit(const CTxIn &txin) const
|
int64 CWallet::GetDebit(const CTxIn &txin) const
|
||||||
{
|
{
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
{
|
{
|
||||||
@ -403,7 +401,7 @@ bool CWallet::IsChange(const CTxOut& txout) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CWalletTx::GetTxTime() const
|
int64 CWalletTx::GetTxTime() const
|
||||||
{
|
{
|
||||||
return nTimeReceived;
|
return nTimeReceived;
|
||||||
}
|
}
|
||||||
@ -447,8 +445,8 @@ int CWalletTx::GetRequestCount() const
|
|||||||
return nRequests;
|
return nRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWalletTx::GetAmounts(int64_t& nGeneratedImmature, int64_t& nGeneratedMature, list<pair<CBitcoinAddress, int64_t> >& listReceived,
|
void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, list<pair<CBitcoinAddress, int64> >& listReceived,
|
||||||
list<pair<CBitcoinAddress, int64_t> >& listSent, int64_t& nFee, string& strSentAccount) const
|
list<pair<CBitcoinAddress, int64> >& listSent, int64& nFee, string& strSentAccount) const
|
||||||
{
|
{
|
||||||
nGeneratedImmature = nGeneratedMature = nFee = 0;
|
nGeneratedImmature = nGeneratedMature = nFee = 0;
|
||||||
listReceived.clear();
|
listReceived.clear();
|
||||||
@ -465,10 +463,10 @@ void CWalletTx::GetAmounts(int64_t& nGeneratedImmature, int64_t& nGeneratedMatur
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute fee:
|
// Compute fee:
|
||||||
int64_t nDebit = GetDebit();
|
int64 nDebit = GetDebit();
|
||||||
if (nDebit > 0) // debit>0 means we signed/sent this transaction
|
if (nDebit > 0) // debit>0 means we signed/sent this transaction
|
||||||
{
|
{
|
||||||
int64_t nValueOut = GetValueOut();
|
int64 nValueOut = GetValueOut();
|
||||||
nFee = nDebit - nValueOut;
|
nFee = nDebit - nValueOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,29 +495,29 @@ void CWalletTx::GetAmounts(int64_t& nGeneratedImmature, int64_t& nGeneratedMatur
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nGenerated, int64_t& nReceived,
|
void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived,
|
||||||
int64_t& nSent, int64_t& nFee) const
|
int64& nSent, int64& nFee) const
|
||||||
{
|
{
|
||||||
nGenerated = nReceived = nSent = nFee = 0;
|
nGenerated = nReceived = nSent = nFee = 0;
|
||||||
|
|
||||||
int64_t allGeneratedImmature, allGeneratedMature, allFee;
|
int64 allGeneratedImmature, allGeneratedMature, allFee;
|
||||||
allGeneratedImmature = allGeneratedMature = allFee = 0;
|
allGeneratedImmature = allGeneratedMature = allFee = 0;
|
||||||
string strSentAccount;
|
string strSentAccount;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listReceived;
|
list<pair<CBitcoinAddress, int64> > listReceived;
|
||||||
list<pair<CBitcoinAddress, int64_t> > listSent;
|
list<pair<CBitcoinAddress, int64> > listSent;
|
||||||
GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);
|
GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount);
|
||||||
|
|
||||||
if (strAccount == "")
|
if (strAccount == "")
|
||||||
nGenerated = allGeneratedMature;
|
nGenerated = allGeneratedMature;
|
||||||
if (strAccount == strSentAccount)
|
if (strAccount == strSentAccount)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& s, listSent)
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& s, listSent)
|
||||||
nSent += s.second;
|
nSent += s.second;
|
||||||
nFee = allFee;
|
nFee = allFee;
|
||||||
}
|
}
|
||||||
CRITICAL_BLOCK(pwallet->cs_wallet)
|
CRITICAL_BLOCK(pwallet->cs_wallet)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64_t)& r, listReceived)
|
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listReceived)
|
||||||
{
|
{
|
||||||
if (pwallet->mapAddressBook.count(r.first))
|
if (pwallet->mapAddressBook.count(r.first))
|
||||||
{
|
{
|
||||||
@ -722,7 +720,7 @@ void CWallet::ResendWalletTransactions()
|
|||||||
{
|
{
|
||||||
// Do this infrequently and randomly to avoid giving away
|
// Do this infrequently and randomly to avoid giving away
|
||||||
// that these are our transactions.
|
// that these are our transactions.
|
||||||
static int64_t nNextTime;
|
static int64 nNextTime;
|
||||||
if (GetTime() < nNextTime)
|
if (GetTime() < nNextTime)
|
||||||
return;
|
return;
|
||||||
bool fFirst = (nNextTime == 0);
|
bool fFirst = (nNextTime == 0);
|
||||||
@ -731,7 +729,7 @@ void CWallet::ResendWalletTransactions()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Only do it if there's been a new block since last time
|
// Only do it if there's been a new block since last time
|
||||||
static int64_t nLastTime;
|
static int64 nLastTime;
|
||||||
if (nTimeBestReceived < nLastTime)
|
if (nTimeBestReceived < nLastTime)
|
||||||
return;
|
return;
|
||||||
nLastTime = GetTime();
|
nLastTime = GetTime();
|
||||||
@ -748,7 +746,7 @@ void CWallet::ResendWalletTransactions()
|
|||||||
CWalletTx& wtx = item.second;
|
CWalletTx& wtx = item.second;
|
||||||
// Don't rebroadcast until it's had plenty of time that
|
// Don't rebroadcast until it's had plenty of time that
|
||||||
// it should have gotten in already by now.
|
// it should have gotten in already by now.
|
||||||
if (nTimeBestReceived - (int64_t)wtx.nTimeReceived > 5 * 60)
|
if (nTimeBestReceived - (int64)wtx.nTimeReceived > 5 * 60)
|
||||||
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
|
mapSorted.insert(make_pair(wtx.nTimeReceived, &wtx));
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
|
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted)
|
||||||
@ -770,9 +768,9 @@ void CWallet::ResendWalletTransactions()
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
int64_t CWallet::GetBalance() const
|
int64 CWallet::GetBalance() const
|
||||||
{
|
{
|
||||||
int64_t nTotal = 0;
|
int64 nTotal = 0;
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
{
|
{
|
||||||
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||||
@ -787,9 +785,9 @@ int64_t CWallet::GetBalance() const
|
|||||||
return nTotal;
|
return nTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CWallet::GetUnconfirmedBalance() const
|
int64 CWallet::GetUnconfirmedBalance() const
|
||||||
{
|
{
|
||||||
int64_t nTotal = 0;
|
int64 nTotal = 0;
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
{
|
{
|
||||||
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||||
@ -803,17 +801,17 @@ int64_t CWallet::GetUnconfirmedBalance() const
|
|||||||
return nTotal;
|
return nTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
|
bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const
|
||||||
{
|
{
|
||||||
setCoinsRet.clear();
|
setCoinsRet.clear();
|
||||||
nValueRet = 0;
|
nValueRet = 0;
|
||||||
|
|
||||||
// List of values less than target
|
// List of values less than target
|
||||||
pair<int64_t, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
|
pair<int64, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
|
||||||
coinLowestLarger.first = std::numeric_limits<int64_t>::max();
|
coinLowestLarger.first = std::numeric_limits<int64>::max();
|
||||||
coinLowestLarger.second.first = NULL;
|
coinLowestLarger.second.first = NULL;
|
||||||
vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > > vValue;
|
vector<pair<int64, pair<const CWalletTx*,unsigned int> > > vValue;
|
||||||
int64_t nTotalLower = 0;
|
int64 nTotalLower = 0;
|
||||||
|
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
{
|
{
|
||||||
@ -840,12 +838,12 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
|
|||||||
if (pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]))
|
if (pcoin->IsSpent(i) || !IsMine(pcoin->vout[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int64_t n = pcoin->vout[i].nValue;
|
int64 n = pcoin->vout[i].nValue;
|
||||||
|
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pair<int64_t,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin,i));
|
pair<int64,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin,i));
|
||||||
|
|
||||||
if (n == nTargetValue)
|
if (n == nTargetValue)
|
||||||
{
|
{
|
||||||
@ -892,12 +890,12 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
|
|||||||
sort(vValue.rbegin(), vValue.rend());
|
sort(vValue.rbegin(), vValue.rend());
|
||||||
vector<char> vfIncluded;
|
vector<char> vfIncluded;
|
||||||
vector<char> vfBest(vValue.size(), true);
|
vector<char> vfBest(vValue.size(), true);
|
||||||
int64_t nBest = nTotalLower;
|
int64 nBest = nTotalLower;
|
||||||
|
|
||||||
for (int nRep = 0; nRep < 1000 && nBest != nTargetValue; nRep++)
|
for (int nRep = 0; nRep < 1000 && nBest != nTargetValue; nRep++)
|
||||||
{
|
{
|
||||||
vfIncluded.assign(vValue.size(), false);
|
vfIncluded.assign(vValue.size(), false);
|
||||||
int64_t nTotal = 0;
|
int64 nTotal = 0;
|
||||||
bool fReachedTarget = false;
|
bool fReachedTarget = false;
|
||||||
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
|
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
|
||||||
{
|
{
|
||||||
@ -948,7 +946,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
|
bool CWallet::SelectCoins(int64 nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const
|
||||||
{
|
{
|
||||||
return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet, nValueRet) ||
|
return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet, nValueRet) ||
|
||||||
SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet, nValueRet) ||
|
SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet, nValueRet) ||
|
||||||
@ -958,10 +956,10 @@ bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsign
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet)
|
bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet)
|
||||||
{
|
{
|
||||||
int64_t nValue = 0;
|
int64 nValue = 0;
|
||||||
BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
|
BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)
|
||||||
{
|
{
|
||||||
if (nValue < 0)
|
if (nValue < 0)
|
||||||
return false;
|
return false;
|
||||||
@ -985,30 +983,30 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
|
|||||||
wtxNew.vout.clear();
|
wtxNew.vout.clear();
|
||||||
wtxNew.fFromMe = true;
|
wtxNew.fFromMe = true;
|
||||||
|
|
||||||
int64_t nTotalValue = nValue + nFeeRet;
|
int64 nTotalValue = nValue + nFeeRet;
|
||||||
double dPriority = 0;
|
double dPriority = 0;
|
||||||
// vouts to the payees
|
// vouts to the payees
|
||||||
BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
|
BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)
|
||||||
wtxNew.vout.push_back(CTxOut(s.second, s.first));
|
wtxNew.vout.push_back(CTxOut(s.second, s.first));
|
||||||
|
|
||||||
// Choose coins to use
|
// Choose coins to use
|
||||||
set<pair<const CWalletTx*,unsigned int> > setCoins;
|
set<pair<const CWalletTx*,unsigned int> > setCoins;
|
||||||
int64_t nValueIn = 0;
|
int64 nValueIn = 0;
|
||||||
if (!SelectCoins(nTotalValue, setCoins, nValueIn))
|
if (!SelectCoins(nTotalValue, setCoins, nValueIn))
|
||||||
return false;
|
return false;
|
||||||
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
|
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
|
||||||
{
|
{
|
||||||
int64_t nCredit = pcoin.first->vout[pcoin.second].nValue;
|
int64 nCredit = pcoin.first->vout[pcoin.second].nValue;
|
||||||
dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain();
|
dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nChange = nValueIn - nValue - nFeeRet;
|
int64 nChange = nValueIn - nValue - nFeeRet;
|
||||||
// if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE
|
// if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE
|
||||||
// or until nChange becomes zero
|
// or until nChange becomes zero
|
||||||
// NOTE: this depends on the exact behaviour of GetMinFee
|
// NOTE: this depends on the exact behaviour of GetMinFee
|
||||||
if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT)
|
if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT)
|
||||||
{
|
{
|
||||||
int64_t nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
|
int64 nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
|
||||||
nChange -= nMoveToFee;
|
nChange -= nMoveToFee;
|
||||||
nFeeRet += nMoveToFee;
|
nFeeRet += nMoveToFee;
|
||||||
}
|
}
|
||||||
@ -1056,9 +1054,9 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
|
|||||||
dPriority /= nBytes;
|
dPriority /= nBytes;
|
||||||
|
|
||||||
// Check that enough fee is included
|
// Check that enough fee is included
|
||||||
int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
|
int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);
|
||||||
bool fAllowFree = CTransaction::AllowFree(dPriority);
|
bool fAllowFree = CTransaction::AllowFree(dPriority);
|
||||||
int64_t nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND);
|
int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND);
|
||||||
if (nFeeRet < max(nPayFee, nMinFee))
|
if (nFeeRet < max(nPayFee, nMinFee))
|
||||||
{
|
{
|
||||||
nFeeRet = max(nPayFee, nMinFee);
|
nFeeRet = max(nPayFee, nMinFee);
|
||||||
@ -1076,9 +1074,9 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet)
|
bool CWallet::CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet)
|
||||||
{
|
{
|
||||||
vector< pair<CScript, int64_t> > vecSend;
|
vector< pair<CScript, int64> > vecSend;
|
||||||
vecSend.push_back(make_pair(scriptPubKey, nValue));
|
vecSend.push_back(make_pair(scriptPubKey, nValue));
|
||||||
return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet);
|
return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet);
|
||||||
}
|
}
|
||||||
@ -1137,10 +1135,10 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee)
|
string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
|
||||||
{
|
{
|
||||||
CReserveKey reservekey(this);
|
CReserveKey reservekey(this);
|
||||||
int64_t nFeeRequired;
|
int64 nFeeRequired;
|
||||||
|
|
||||||
if (IsLocked())
|
if (IsLocked())
|
||||||
{
|
{
|
||||||
@ -1171,7 +1169,7 @@ string CWallet::SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNe
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
string CWallet::SendMoneyToBitcoinAddress(const CBitcoinAddress& address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee)
|
string CWallet::SendMoneyToBitcoinAddress(const CBitcoinAddress& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
|
||||||
{
|
{
|
||||||
// Check amount
|
// Check amount
|
||||||
if (nValue <= 0)
|
if (nValue <= 0)
|
||||||
@ -1301,17 +1299,17 @@ bool CWallet::NewKeyPool()
|
|||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
{
|
{
|
||||||
CWalletDB walletdb(strWalletFile);
|
CWalletDB walletdb(strWalletFile);
|
||||||
BOOST_FOREACH(int64_t nIndex, setKeyPool)
|
BOOST_FOREACH(int64 nIndex, setKeyPool)
|
||||||
walletdb.ErasePool(nIndex);
|
walletdb.ErasePool(nIndex);
|
||||||
setKeyPool.clear();
|
setKeyPool.clear();
|
||||||
|
|
||||||
if (IsLocked())
|
if (IsLocked())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int64_t nKeys = max(GetArg("-keypool", 100), (int64_t)0);
|
int64 nKeys = max(GetArg("-keypool", 100), (int64)0);
|
||||||
for (int i = 0; i < nKeys; i++)
|
for (int i = 0; i < nKeys; i++)
|
||||||
{
|
{
|
||||||
int64_t nIndex = i+1;
|
int64 nIndex = i+1;
|
||||||
walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey()));
|
walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey()));
|
||||||
setKeyPool.insert(nIndex);
|
setKeyPool.insert(nIndex);
|
||||||
}
|
}
|
||||||
@ -1330,10 +1328,10 @@ bool CWallet::TopUpKeyPool()
|
|||||||
CWalletDB walletdb(strWalletFile);
|
CWalletDB walletdb(strWalletFile);
|
||||||
|
|
||||||
// Top up key pool
|
// Top up key pool
|
||||||
int64_t nTargetSize = max(GetArg("-keypool", 100), (int64_t)0);
|
int64 nTargetSize = max(GetArg("-keypool", 100), (int64)0);
|
||||||
while (setKeyPool.size() < nTargetSize+1)
|
while (setKeyPool.size() < nTargetSize+1)
|
||||||
{
|
{
|
||||||
int64_t nEnd = 1;
|
int64 nEnd = 1;
|
||||||
if (!setKeyPool.empty())
|
if (!setKeyPool.empty())
|
||||||
nEnd = *(--setKeyPool.end()) + 1;
|
nEnd = *(--setKeyPool.end()) + 1;
|
||||||
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
|
if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey())))
|
||||||
@ -1345,7 +1343,7 @@ bool CWallet::TopUpKeyPool()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool)
|
void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool)
|
||||||
{
|
{
|
||||||
nIndex = -1;
|
nIndex = -1;
|
||||||
keypool.vchPubKey.clear();
|
keypool.vchPubKey.clear();
|
||||||
@ -1371,14 +1369,14 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CWallet::AddReserveKey(const CKeyPool& keypool)
|
int64 CWallet::AddReserveKey(const CKeyPool& keypool)
|
||||||
{
|
{
|
||||||
CRITICAL_BLOCK(cs_main)
|
CRITICAL_BLOCK(cs_main)
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
{
|
{
|
||||||
CWalletDB walletdb(strWalletFile);
|
CWalletDB walletdb(strWalletFile);
|
||||||
|
|
||||||
int64_t nIndex = 1 + *(--setKeyPool.end());
|
int64 nIndex = 1 + *(--setKeyPool.end());
|
||||||
if (!walletdb.WritePool(nIndex, keypool))
|
if (!walletdb.WritePool(nIndex, keypool))
|
||||||
throw runtime_error("AddReserveKey() : writing added key failed");
|
throw runtime_error("AddReserveKey() : writing added key failed");
|
||||||
setKeyPool.insert(nIndex);
|
setKeyPool.insert(nIndex);
|
||||||
@ -1387,7 +1385,7 @@ int64_t CWallet::AddReserveKey(const CKeyPool& keypool)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::KeepKey(int64_t nIndex)
|
void CWallet::KeepKey(int64 nIndex)
|
||||||
{
|
{
|
||||||
// Remove from key pool
|
// Remove from key pool
|
||||||
if (fFileBacked)
|
if (fFileBacked)
|
||||||
@ -1398,7 +1396,7 @@ void CWallet::KeepKey(int64_t nIndex)
|
|||||||
printf("keypool keep %"PRI64d"\n", nIndex);
|
printf("keypool keep %"PRI64d"\n", nIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::ReturnKey(int64_t nIndex)
|
void CWallet::ReturnKey(int64 nIndex)
|
||||||
{
|
{
|
||||||
// Return to key pool
|
// Return to key pool
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
@ -1408,7 +1406,7 @@ void CWallet::ReturnKey(int64_t nIndex)
|
|||||||
|
|
||||||
bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
|
bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
|
||||||
{
|
{
|
||||||
int64_t nIndex = 0;
|
int64 nIndex = 0;
|
||||||
CKeyPool keypool;
|
CKeyPool keypool;
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
{
|
{
|
||||||
@ -1430,9 +1428,9 @@ bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t CWallet::GetOldestKeyPoolTime()
|
int64 CWallet::GetOldestKeyPoolTime()
|
||||||
{
|
{
|
||||||
int64_t nIndex = 0;
|
int64 nIndex = 0;
|
||||||
CKeyPool keypool;
|
CKeyPool keypool;
|
||||||
ReserveKeyFromKeyPool(nIndex, keypool);
|
ReserveKeyFromKeyPool(nIndex, keypool);
|
||||||
if (nIndex == -1)
|
if (nIndex == -1)
|
||||||
@ -1483,7 +1481,7 @@ void CWallet::GetAllReserveAddresses(set<CBitcoinAddress>& setAddress)
|
|||||||
|
|
||||||
CRITICAL_BLOCK(cs_main)
|
CRITICAL_BLOCK(cs_main)
|
||||||
CRITICAL_BLOCK(cs_wallet)
|
CRITICAL_BLOCK(cs_wallet)
|
||||||
BOOST_FOREACH(const int64_t& id, setKeyPool)
|
BOOST_FOREACH(const int64& id, setKeyPool)
|
||||||
{
|
{
|
||||||
CKeyPool keypool;
|
CKeyPool keypool;
|
||||||
if (!walletdb.ReadPool(id, keypool))
|
if (!walletdb.ReadPool(id, keypool))
|
||||||
|
88
src/wallet.h
88
src/wallet.h
@ -5,8 +5,6 @@
|
|||||||
#ifndef BITCOIN_WALLET_H
|
#ifndef BITCOIN_WALLET_H
|
||||||
#define BITCOIN_WALLET_H
|
#define BITCOIN_WALLET_H
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "bignum.h"
|
#include "bignum.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "keystore.h"
|
#include "keystore.h"
|
||||||
@ -22,8 +20,8 @@ class CWalletDB;
|
|||||||
class CWallet : public CCryptoKeyStore
|
class CWallet : public CCryptoKeyStore
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
|
bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const;
|
||||||
bool SelectCoins(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
|
bool SelectCoins(int64 nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const;
|
||||||
|
|
||||||
CWalletDB *pwalletdbEncryption;
|
CWalletDB *pwalletdbEncryption;
|
||||||
|
|
||||||
@ -33,7 +31,7 @@ public:
|
|||||||
bool fFileBacked;
|
bool fFileBacked;
|
||||||
std::string strWalletFile;
|
std::string strWalletFile;
|
||||||
|
|
||||||
std::set<int64_t> setKeyPool;
|
std::set<int64> setKeyPool;
|
||||||
|
|
||||||
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
|
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
|
||||||
MasterKeyMap mapMasterKeys;
|
MasterKeyMap mapMasterKeys;
|
||||||
@ -88,39 +86,39 @@ public:
|
|||||||
int ScanForWalletTransaction(const uint256& hashTx);
|
int ScanForWalletTransaction(const uint256& hashTx);
|
||||||
void ReacceptWalletTransactions();
|
void ReacceptWalletTransactions();
|
||||||
void ResendWalletTransactions();
|
void ResendWalletTransactions();
|
||||||
int64_t GetBalance() const;
|
int64 GetBalance() const;
|
||||||
int64_t GetUnconfirmedBalance() const;
|
int64 GetUnconfirmedBalance() const;
|
||||||
bool CreateTransaction(const std::vector<std::pair<CScript, int64_t> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet);
|
bool CreateTransaction(const std::vector<std::pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
|
||||||
bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet);
|
bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet);
|
||||||
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
|
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
|
||||||
bool BroadcastTransaction(CWalletTx& wtxNew);
|
bool BroadcastTransaction(CWalletTx& wtxNew);
|
||||||
std::string SendMoney(CScript scriptPubKey, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);
|
std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
|
||||||
std::string SendMoneyToBitcoinAddress(const CBitcoinAddress& address, int64_t nValue, CWalletTx& wtxNew, bool fAskFee=false);
|
std::string SendMoneyToBitcoinAddress(const CBitcoinAddress& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
|
||||||
|
|
||||||
bool NewKeyPool();
|
bool NewKeyPool();
|
||||||
bool TopUpKeyPool();
|
bool TopUpKeyPool();
|
||||||
int64_t AddReserveKey(const CKeyPool& keypool);
|
int64 AddReserveKey(const CKeyPool& keypool);
|
||||||
void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool);
|
void ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool);
|
||||||
void KeepKey(int64_t nIndex);
|
void KeepKey(int64 nIndex);
|
||||||
void ReturnKey(int64_t nIndex);
|
void ReturnKey(int64 nIndex);
|
||||||
bool GetKeyFromPool(std::vector<unsigned char> &key, bool fAllowReuse=true);
|
bool GetKeyFromPool(std::vector<unsigned char> &key, bool fAllowReuse=true);
|
||||||
int64_t GetOldestKeyPoolTime();
|
int64 GetOldestKeyPoolTime();
|
||||||
void GetAllReserveAddresses(std::set<CBitcoinAddress>& setAddress);
|
void GetAllReserveAddresses(std::set<CBitcoinAddress>& setAddress);
|
||||||
|
|
||||||
bool IsMine(const CTxIn& txin) const;
|
bool IsMine(const CTxIn& txin) const;
|
||||||
int64_t GetDebit(const CTxIn& txin) const;
|
int64 GetDebit(const CTxIn& txin) const;
|
||||||
bool IsMine(const CTxOut& txout) const
|
bool IsMine(const CTxOut& txout) const
|
||||||
{
|
{
|
||||||
return ::IsMine(*this, txout.scriptPubKey);
|
return ::IsMine(*this, txout.scriptPubKey);
|
||||||
}
|
}
|
||||||
int64_t GetCredit(const CTxOut& txout) const
|
int64 GetCredit(const CTxOut& txout) const
|
||||||
{
|
{
|
||||||
if (!MoneyRange(txout.nValue))
|
if (!MoneyRange(txout.nValue))
|
||||||
throw std::runtime_error("CWallet::GetCredit() : value out of range");
|
throw std::runtime_error("CWallet::GetCredit() : value out of range");
|
||||||
return (IsMine(txout) ? txout.nValue : 0);
|
return (IsMine(txout) ? txout.nValue : 0);
|
||||||
}
|
}
|
||||||
bool IsChange(const CTxOut& txout) const;
|
bool IsChange(const CTxOut& txout) const;
|
||||||
int64_t GetChange(const CTxOut& txout) const
|
int64 GetChange(const CTxOut& txout) const
|
||||||
{
|
{
|
||||||
if (!MoneyRange(txout.nValue))
|
if (!MoneyRange(txout.nValue))
|
||||||
throw std::runtime_error("CWallet::GetChange() : value out of range");
|
throw std::runtime_error("CWallet::GetChange() : value out of range");
|
||||||
@ -137,9 +135,9 @@ public:
|
|||||||
{
|
{
|
||||||
return (GetDebit(tx) > 0);
|
return (GetDebit(tx) > 0);
|
||||||
}
|
}
|
||||||
int64_t GetDebit(const CTransaction& tx) const
|
int64 GetDebit(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
int64_t nDebit = 0;
|
int64 nDebit = 0;
|
||||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||||
{
|
{
|
||||||
nDebit += GetDebit(txin);
|
nDebit += GetDebit(txin);
|
||||||
@ -148,9 +146,9 @@ public:
|
|||||||
}
|
}
|
||||||
return nDebit;
|
return nDebit;
|
||||||
}
|
}
|
||||||
int64_t GetCredit(const CTransaction& tx) const
|
int64 GetCredit(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
int64_t nCredit = 0;
|
int64 nCredit = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
||||||
{
|
{
|
||||||
nCredit += GetCredit(txout);
|
nCredit += GetCredit(txout);
|
||||||
@ -159,9 +157,9 @@ public:
|
|||||||
}
|
}
|
||||||
return nCredit;
|
return nCredit;
|
||||||
}
|
}
|
||||||
int64_t GetChange(const CTransaction& tx) const
|
int64 GetChange(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
int64_t nChange = 0;
|
int64 nChange = 0;
|
||||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
||||||
{
|
{
|
||||||
nChange += GetChange(txout);
|
nChange += GetChange(txout);
|
||||||
@ -216,7 +214,7 @@ class CReserveKey
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
CWallet* pwallet;
|
CWallet* pwallet;
|
||||||
int64_t nIndex;
|
int64 nIndex;
|
||||||
std::vector<unsigned char> vchPubKey;
|
std::vector<unsigned char> vchPubKey;
|
||||||
public:
|
public:
|
||||||
CReserveKey(CWallet* pwalletIn)
|
CReserveKey(CWallet* pwalletIn)
|
||||||
@ -262,10 +260,10 @@ public:
|
|||||||
mutable char fCreditCached;
|
mutable char fCreditCached;
|
||||||
mutable char fAvailableCreditCached;
|
mutable char fAvailableCreditCached;
|
||||||
mutable char fChangeCached;
|
mutable char fChangeCached;
|
||||||
mutable int64_t nDebitCached;
|
mutable int64 nDebitCached;
|
||||||
mutable int64_t nCreditCached;
|
mutable int64 nCreditCached;
|
||||||
mutable int64_t nAvailableCreditCached;
|
mutable int64 nAvailableCreditCached;
|
||||||
mutable int64_t nChangeCached;
|
mutable int64 nChangeCached;
|
||||||
|
|
||||||
// memory only UI hints
|
// memory only UI hints
|
||||||
mutable unsigned int nTimeDisplayed;
|
mutable unsigned int nTimeDisplayed;
|
||||||
@ -418,7 +416,7 @@ public:
|
|||||||
return (!!vfSpent[nOut]);
|
return (!!vfSpent[nOut]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetDebit() const
|
int64 GetDebit() const
|
||||||
{
|
{
|
||||||
if (vin.empty())
|
if (vin.empty())
|
||||||
return 0;
|
return 0;
|
||||||
@ -429,7 +427,7 @@ public:
|
|||||||
return nDebitCached;
|
return nDebitCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetCredit(bool fUseCache=true) const
|
int64 GetCredit(bool fUseCache=true) const
|
||||||
{
|
{
|
||||||
// Must wait until coinbase is safely deep enough in the chain before valuing it
|
// Must wait until coinbase is safely deep enough in the chain before valuing it
|
||||||
if (IsCoinBase() && GetBlocksToMaturity() > 0)
|
if (IsCoinBase() && GetBlocksToMaturity() > 0)
|
||||||
@ -443,7 +441,7 @@ public:
|
|||||||
return nCreditCached;
|
return nCreditCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t GetAvailableCredit(bool fUseCache=true) const
|
int64 GetAvailableCredit(bool fUseCache=true) const
|
||||||
{
|
{
|
||||||
// Must wait until coinbase is safely deep enough in the chain before valuing it
|
// Must wait until coinbase is safely deep enough in the chain before valuing it
|
||||||
if (IsCoinBase() && GetBlocksToMaturity() > 0)
|
if (IsCoinBase() && GetBlocksToMaturity() > 0)
|
||||||
@ -452,7 +450,7 @@ public:
|
|||||||
if (fUseCache && fAvailableCreditCached)
|
if (fUseCache && fAvailableCreditCached)
|
||||||
return nAvailableCreditCached;
|
return nAvailableCreditCached;
|
||||||
|
|
||||||
int64_t nCredit = 0;
|
int64 nCredit = 0;
|
||||||
for (int i = 0; i < vout.size(); i++)
|
for (int i = 0; i < vout.size(); i++)
|
||||||
{
|
{
|
||||||
if (!IsSpent(i))
|
if (!IsSpent(i))
|
||||||
@ -470,7 +468,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t GetChange() const
|
int64 GetChange() const
|
||||||
{
|
{
|
||||||
if (fChangeCached)
|
if (fChangeCached)
|
||||||
return nChangeCached;
|
return nChangeCached;
|
||||||
@ -479,11 +477,11 @@ public:
|
|||||||
return nChangeCached;
|
return nChangeCached;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetAmounts(int64_t& nGeneratedImmature, int64_t& nGeneratedMature, std::list<std::pair<CBitcoinAddress, int64_t> >& listReceived,
|
void GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, std::list<std::pair<CBitcoinAddress, int64> >& listReceived,
|
||||||
std::list<std::pair<CBitcoinAddress, int64_t> >& listSent, int64_t& nFee, std::string& strSentAccount) const;
|
std::list<std::pair<CBitcoinAddress, int64> >& listSent, int64& nFee, std::string& strSentAccount) const;
|
||||||
|
|
||||||
void GetAccountAmounts(const std::string& strAccount, int64_t& nGenerated, int64_t& nReceived,
|
void GetAccountAmounts(const std::string& strAccount, int64& nGenerated, int64& nReceived,
|
||||||
int64_t& nSent, int64_t& nFee) const;
|
int64& nSent, int64& nFee) const;
|
||||||
|
|
||||||
bool IsFromMe() const
|
bool IsFromMe() const
|
||||||
{
|
{
|
||||||
@ -533,7 +531,7 @@ public:
|
|||||||
|
|
||||||
bool WriteToDisk();
|
bool WriteToDisk();
|
||||||
|
|
||||||
int64_t GetTxTime() const;
|
int64 GetTxTime() const;
|
||||||
int GetRequestCount() const;
|
int GetRequestCount() const;
|
||||||
|
|
||||||
void AddSupportingTransactions(CTxDB& txdb);
|
void AddSupportingTransactions(CTxDB& txdb);
|
||||||
@ -553,13 +551,13 @@ class CWalletKey
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPrivKey vchPrivKey;
|
CPrivKey vchPrivKey;
|
||||||
int64_t nTimeCreated;
|
int64 nTimeCreated;
|
||||||
int64_t nTimeExpires;
|
int64 nTimeExpires;
|
||||||
std::string strComment;
|
std::string strComment;
|
||||||
//// todo: add something to note what created it (user, getnewaddress, change)
|
//// todo: add something to note what created it (user, getnewaddress, change)
|
||||||
//// maybe should have a map<string, string> property map
|
//// maybe should have a map<string, string> property map
|
||||||
|
|
||||||
CWalletKey(int64_t nExpires=0)
|
CWalletKey(int64 nExpires=0)
|
||||||
{
|
{
|
||||||
nTimeCreated = (nExpires ? GetTime() : 0);
|
nTimeCreated = (nExpires ? GetTime() : 0);
|
||||||
nTimeExpires = nExpires;
|
nTimeExpires = nExpires;
|
||||||
@ -618,8 +616,8 @@ class CAccountingEntry
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string strAccount;
|
std::string strAccount;
|
||||||
int64_t nCreditDebit;
|
int64 nCreditDebit;
|
||||||
int64_t nTime;
|
int64 nTime;
|
||||||
std::string strOtherAccount;
|
std::string strOtherAccount;
|
||||||
std::string strComment;
|
std::string strComment;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user