#include <list>
#include <map>
-using namespace std;
class CWallet;
class CBlock;
static const int64_t MIN_TX_FEE = CENT/10;
static const int64_t MIN_RELAY_TX_FEE = CENT/50;
-static const int64_t MAX_MONEY = numeric_limits<int64_t>::max();
+static const int64_t MAX_MONEY = std::numeric_limits<int64_t>::max();
static const int64_t MAX_MINT_PROOF_OF_WORK = 100 * COIN;
static const int64_t MAX_MINT_PROOF_OF_STAKE = 1 * COIN;
static const int64_t MIN_TXOUT_AMOUNT = CENT/100;
extern CScript COINBASE_FLAGS;
extern CCriticalSection cs_main;
-extern map<uint256, CBlockIndex*> mapBlockIndex;
-extern set<pair<COutPoint, unsigned int> > setStakeSeen;
+extern std::map<uint256, CBlockIndex*> mapBlockIndex;
+extern std::set<std::pair<COutPoint, unsigned int> > setStakeSeen;
extern CBlockIndex* pindexGenesisBlock;
extern unsigned int nNodeLifespan;
extern unsigned int nStakeMinAge;
extern uint64_t nLastBlockTx;
extern uint64_t nLastBlockSize;
extern uint32_t nLastCoinStakeSearchInterval;
-extern const string strMessageMagic;
+extern const std::string strMessageMagic;
extern int64_t nTimeBestReceived;
extern CCriticalSection cs_setpwalletRegistered;
-extern set<CWallet*> setpwalletRegistered;
+extern std::set<CWallet*> setpwalletRegistered;
extern uint32_t nNetworkID;
-extern map<uint256, CBlock*> mapOrphanBlocks;
+extern std::map<uint256, CBlock*> mapOrphanBlocks;
// Settings
extern int64_t nTransactionFee;
unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime);
int GetNumBlocksOfPeers();
bool IsInitialBlockDownload();
-string GetWarnings(string strFor);
+std::string GetWarnings(std::string strFor);
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock);
uint256 WantedByOrphan(const CBlock* pblockOrphan);
const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake);
-bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut);
+bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut);
// Position on disk for a particular transaction.
class CDiskTxPos
CDiskTxPos(unsigned int nFileIn, unsigned int nBlockPosIn, unsigned int nTxPosIn) : nFile(nFileIn), nBlockPos(nBlockPosIn), nTxPos(nTxPosIn) {}
IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); )
- void SetNull() { nFile = numeric_limits<uint32_t>::max(); nBlockPos = 0; nTxPos = 0; }
- bool IsNull() const { return (nFile == numeric_limits<uint32_t>::max()); }
+ void SetNull() { nFile = std::numeric_limits<uint32_t>::max(); nBlockPos = 0; nTxPos = 0; }
+ bool IsNull() const { return (nFile == std::numeric_limits<uint32_t>::max()); }
friend bool operator==(const CDiskTxPos& a, const CDiskTxPos& b)
{
}
- string ToString() const
+ std::string ToString() const
{
if (IsNull())
return "null";
CInPoint() { SetNull(); }
CInPoint(CTransaction* ptxIn, uint32_t nIn) : ptx(ptxIn), n(nIn) {}
- void SetNull() { ptx = NULL; n = numeric_limits<uint32_t>::max(); }
- bool IsNull() const { return (ptx == NULL && n == numeric_limits<uint32_t>::max()); }
+ void SetNull() { ptx = NULL; n = std::numeric_limits<uint32_t>::max(); }
+ bool IsNull() const { return (ptx == NULL && n == std::numeric_limits<uint32_t>::max()); }
};
COutPoint() { SetNull(); }
COutPoint(uint256 hashIn, uint32_t nIn) : hash(hashIn), n(nIn) {}
IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); )
- void SetNull() { hash = 0; n = numeric_limits<uint32_t>::max(); }
- bool IsNull() const { return (hash == 0 && n == numeric_limits<uint32_t>::max()); }
+ void SetNull() { hash = 0; n = std::numeric_limits<uint32_t>::max(); }
+ bool IsNull() const { return (hash == 0 && n == std::numeric_limits<uint32_t>::max()); }
friend bool operator<(const COutPoint& a, const COutPoint& b)
{
return !(a == b);
}
- string ToString() const
+ std::string ToString() const
{
return strprintf("COutPoint(%s, %" PRIu32 ")", hash.ToString().substr(0,10).c_str(), n);
}
CScript scriptSig;
uint32_t nSequence;
- CTxIn() : nSequence(numeric_limits<unsigned int>::max()) {}
- explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=numeric_limits<unsigned int>::max())
+ CTxIn() : nSequence(std::numeric_limits<unsigned int>::max()) {}
+ explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits<unsigned int>::max())
: prevout(prevoutIn), scriptSig(scriptSigIn), nSequence(nSequenceIn) {}
- CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=numeric_limits<unsigned int>::max())
+ CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn=CScript(), unsigned int nSequenceIn=std::numeric_limits<unsigned int>::max())
: prevout(COutPoint(hashPrevTx, nOut)), scriptSig(scriptSigIn), nSequence(nSequenceIn) {}
IMPLEMENT_SERIALIZE
bool IsFinal() const
{
- return (nSequence == numeric_limits<unsigned int>::max());
+ return (nSequence == std::numeric_limits<unsigned int>::max());
}
friend bool operator==(const CTxIn& a, const CTxIn& b)
return !(a == b);
}
- string ToStringShort() const
+ std::string ToStringShort() const
{
return strprintf(" %s %d", prevout.hash.ToString().c_str(), prevout.n);
}
- string ToString() const;
+ std::string ToString() const;
void print() const
{
return !(a == b);
}
- string ToStringShort() const
+ std::string ToStringShort() const
{
return strprintf(" out %s %s", FormatMoney(nValue).c_str(), scriptPubKey.ToString(true).c_str());
}
- string ToString() const
+ std::string ToString() const
{
if (IsEmpty()) return "CTxOut(empty)";
if (scriptPubKey.size() < 6)
GMF_SEND
};
-typedef map<uint256, pair<CTxIndex, CTransaction> > MapPrevTx;
+typedef std::map<uint256, std::pair<CTxIndex, CTransaction> > MapPrevTx;
/** The basic transaction that is broadcasted on the network and contained in
* blocks. A transaction can contain multiple inputs and outputs.
static const int CURRENT_VERSION=1;
int nVersion;
uint32_t nTime;
- vector<CTxIn> vin;
- vector<CTxOut> vout;
+ std::vector<CTxIn> vin;
+ std::vector<CTxOut> vout;
uint32_t nLockTime;
// Denial-of-service detection:
/** Check for standard transaction types
@return True if all outputs (scriptPubKeys) use only standard transaction forms
*/
- bool IsStandard(string& strReason) const;
+ bool IsStandard(std::string& strReason) const;
bool IsStandard() const
{
- string strReason;
+ std::string strReason;
return IsStandard(strReason);
}
return !(a == b);
}
- string ToStringShort() const;
- string ToString() const;
+ std::string ToStringShort() const;
+ std::string ToString() const;
void print() const
{
@param[out] fInvalid returns true if transaction is invalid
@return Returns true if all inputs are in txdb or mapTestPool
*/
- bool FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTestPool,
+ bool FetchInputs(CTxDB& txdb, const std::map<uint256, CTxIndex>& mapTestPool,
bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid);
/** Sanity check previous transactions, then, if all checks succeed,
@param[in] pvChecks NULL If pvChecks is not NULL, script checks are pushed onto it instead of being performed inline.
@return Returns true if all checks succeed
*/
- bool ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx, const CBlockIndex* pindexBlock,
+ bool ConnectInputs(CTxDB& txdb, MapPrevTx inputs, std::map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx, const CBlockIndex* pindexBlock,
bool fBlock, bool fMiner, bool fScriptChecks=true,
- unsigned int flags=STRICT_FLAGS, vector<CScriptCheck> *pvChecks = NULL);
+ unsigned int flags=STRICT_FLAGS, std::vector<CScriptCheck> *pvChecks = NULL);
bool ClientConnectInputs();
bool CheckTransaction() const;
bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
{
public:
uint256 hashBlock;
- vector<uint256> vMerkleBranch;
+ std::vector<uint256> vMerkleBranch;
int32_t nIndex;
// memory only
{
public:
CDiskTxPos pos;
- vector<CDiskTxPos> vSpent;
+ std::vector<CDiskTxPos> vSpent;
CTxIndex()
{
uint32_t nNonce;
// network and disk
- vector<CTransaction> vtx;
+ std::vector<CTransaction> vtx;
// ppcoin: block signature - signed by one of the coin base txout[N]'s owner
- vector<unsigned char> vchBlockSig;
+ std::vector<unsigned char> vchBlockSig;
// memory only
- mutable vector<uint256> vMerkleTree;
+ mutable std::vector<uint256> vMerkleTree;
// Denial-of-service detection:
mutable int nDoS;
return !IsProofOfStake();
}
- pair<COutPoint, unsigned int> GetProofOfStake() const
+ std::pair<COutPoint, unsigned int> GetProofOfStake() const
{
if (IsProofOfStake())
return { vtx[1].vin[0].prevout, vtx[1].nTime };
// ppcoin: get max transaction timestamp
int64_t GetMaxTransactionTime() const;
uint256 BuildMerkleTree() const;
- vector<uint256> GetMerkleBranch(int nIndex) const;
- static uint256 CheckMerkleBranch(uint256 hash, const vector<uint256>& vMerkleBranch, int nIndex);
+ std::vector<uint256> GetMerkleBranch(int nIndex) const;
+ static uint256 CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex);
bool WriteToDisk(unsigned int& nFileRet, unsigned int& nBlockPosRet);
bool ReadFromDisk(unsigned int nFile, unsigned int nBlockPos, bool fReadTransactions=true);
void print() const;
}
void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier);
- string ToString() const;
+ std::string ToString() const;
void print() const
{
)
uint256 GetBlockHash() const;
- string ToString() const;
+ std::string ToString() const;
void print() const
{
class CBlockLocator
{
protected:
- vector<uint256> vHave;
+ std::vector<uint256> vHave;
public:
CBlockLocator() { }
- CBlockLocator(const vector<uint256>& vHaveIn) : vHave(vHaveIn) { }
+ CBlockLocator(const std::vector<uint256>& vHaveIn) : vHave(vHaveIn) { }
explicit CBlockLocator(const CBlockIndex* pindex)
{
{
public:
mutable CCriticalSection cs;
- map<uint256, CTransaction> mapTx;
- map<COutPoint, CInPoint> mapNextTx;
+ std::map<uint256, CTransaction> mapTx;
+ std::map<COutPoint, CInPoint> mapNextTx;
bool accept(CTxDB& txdb, CTransaction &tx,
bool fCheckInputs, bool* pfMissingInputs);
bool addUnchecked(const uint256& hash, CTransaction &tx);
bool remove(CTransaction &tx);
void clear();
- void queryHashes(vector<uint256>& vtxid);
+ void queryHashes(std::vector<uint256>& vtxid);
size_t size()
{
// Set of selected transactions
typedef std::set<std::pair<const CWalletTx*,unsigned int> > CoinsSet;
-/** (client) version numbers for particular wallet features */
+// (client) version numbers for particular wallet features
enum WalletFeature
{
FEATURE_BASE = 10500, // the earliest version new wallets supports (only useful for getinfo's clientversion output)
FEATURE_LATEST = 60017
};
-/** A key pool entry */
+// A key pool entry
class CKeyPool
{
public:
int64_t nTime;
CPubKey vchPubKey;
- CKeyPool()
- {
- nTime = GetTime();
- }
-
- CKeyPool(const CPubKey& vchPubKeyIn)
- {
- nTime = GetTime();
- vchPubKey = vchPubKeyIn;
- }
+ CKeyPool() : nTime(GetTime()) {}
+ CKeyPool(const CPubKey& vchPubKeyIn) : nTime(GetTime()), vchPubKey(vchPubKeyIn) {}
IMPLEMENT_SERIALIZE
(
)
};
-/** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,
- * and provides the ability to create new transactions.
- */
+// A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,
+// and provides the ability to create new transactions.
+//
class CWallet : public CCryptoKeyStore
{
private:
bool LoadKey(const CMalleableKeyView &keyView, const CSecret &vchSecretH) { return CCryptoKeyStore::AddMalleableKey(keyView, vchSecretH); }
bool LoadCryptedKey(const CMalleableKeyView &keyView, const std::vector<unsigned char> &vchCryptedSecretH) { return CCryptoKeyStore::AddCryptedMalleableKey(keyView, vchCryptedSecretH); }
- bool LoadMinVersion(int nVersion) { nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
+ bool LoadMinVersion(int nVersion);
// Adds an encrypted key to the store, and saves it to disk.
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
bool DelAddressBookName(const CBitcoinAddress& address);
void UpdatedTransaction(const uint256 &hashTx);
void PrintWallet(const CBlock& block);
-
- void Inventory(const uint256 &hash)
- {
- {
- LOCK(cs_wallet);
- auto mi = mapRequestCount.find(hash);
- if (mi != mapRequestCount.end())
- (*mi).second++;
- }
- }
+ void Inventory(const uint256 &hash);
unsigned int GetKeyPoolSize()
{
int64_t nIndex;
CPubKey vchPubKey;
public:
- CReserveKey(CWallet* pwalletIn)
- {
- nIndex = -1;
- pwallet = pwalletIn;
- }
+ CReserveKey(CWallet* pwalletIn) : pwallet(pwalletIn), nIndex(-1) {}
~CReserveKey()
{
typedef std::map<std::string, std::string> mapValue_t;
-
static void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue)
{
if (!mapValue.count("n"))
nOrderPos = strtoll(mapValue["n"]);
}
-
static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
{
if (nOrderPos == -1)
}
-/** A transaction with a bunch of additional info that only the owner cares about.
- * It includes any unrecorded transactions needed to link it back to the block chain.
- */
+// A transaction with a bunch of additional info that only the owner cares about.
+// It includes any unrecorded transactions needed to link it back to the block chain.
+//
class CWalletTx : public CMerkleTx
{
private:
int nDepth;
bool fSpendable;
- COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn)
- {
- tx = txIn; i = iIn; nDepth = nDepthIn; fSpendable = fSpendableIn;
- }
+ COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn) :
+ tx(txIn), i(iIn), nDepth(nDepthIn), fSpendable(fSpendableIn) {}
std::string ToString() const
{
-/** Private key that includes an expiration date in case it never gets used. */
+// Private key that includes an expiration date in case it never gets used.
class CWalletKey
{
public:
//// todo: add something to note what created it (user, getnewaddress, change)
//// maybe should have a map<string, string> property map
- CWalletKey(int64_t nExpires=0)
- {
- nTimeCreated = (nExpires ? GetTime() : 0);
- nTimeExpires = nExpires;
- }
+ CWalletKey(int64_t nExpires=0) : nTimeCreated(nExpires ? GetTime() : 0), nTimeExpires(nExpires) {}
IMPLEMENT_SERIALIZE
(
-
-
/** Account information.
* Stored in wallet with key "acc"+string account name.
*/