aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.h
diff options
context:
space:
mode:
authorMichael Ford <fanquake@gmail.com>2014-10-26 15:03:12 +0800
committerMichael Ford <fanquake@gmail.com>2014-10-28 11:47:49 +0800
commit5b40d8868820265adb24fec097905e84edb85762 (patch)
tree81084e25f3f0646f1052b1902de0925fb5aa9c41 /src/wallet.h
parent35ece7dd074e1cb1b00ffb89dc6a6de063145b53 (diff)
Update comments in wallet to be doxygen compatible
Diffstat (limited to 'src/wallet.h')
-rw-r--r--src/wallet.h138
1 files changed, 79 insertions, 59 deletions
diff --git a/src/wallet.h b/src/wallet.h
index 9b6895090c..6ef830f220 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2013 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_WALLET_H
@@ -24,16 +24,18 @@
#include <utility>
#include <vector>
-// Settings
+/**
+ * Settings
+ */
extern CFeeRate payTxFee;
extern unsigned int nTxConfirmTarget;
extern bool bSpendZeroConfChange;
-// -paytxfee default
+//! -paytxfee default
static const CAmount DEFAULT_TRANSACTION_FEE = 0;
-// -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
+//! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
static const CAmount nHighTransactionFeeWarning = 0.01 * COIN;
-// Largest (in bytes) free transaction we're willing to create
+//! Largest (in bytes) free transaction we're willing to create
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
class CAccountingEntry;
@@ -92,7 +94,8 @@ public:
StringMap destdata;
};
-/** A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,
+/**
+ * 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, public CValidationInterface
@@ -102,18 +105,20 @@ private:
CWalletDB *pwalletdbEncryption;
- // the current wallet version: clients below this version are not able to load the wallet
+ //! the current wallet version: clients below this version are not able to load the wallet
int nWalletVersion;
- // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
+ //! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
int nWalletMaxVersion;
int64_t nNextResend;
int64_t nLastResend;
- // Used to keep track of spent outpoints, and
- // detect and report conflicts (double-spends or
- // mutated transactions where the mutant gets mined).
+ /**
+ * Used to keep track of spent outpoints, and
+ * detect and report conflicts (double-spends or
+ * mutated transactions where the mutant gets mined).
+ */
typedef std::multimap<COutPoint, uint256> TxSpends;
TxSpends mapTxSpends;
void AddToSpends(const COutPoint& outpoint, const uint256& wtxid);
@@ -122,11 +127,13 @@ private:
void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>);
public:
- /// Main wallet lock.
- /// This lock protects all the fields added by CWallet
- /// except for:
- /// fFileBacked (immutable after instantiation)
- /// strWalletFile (immutable after instantiation)
+ /*
+ * Main wallet lock.
+ * This lock protects all the fields added by CWallet
+ * except for:
+ * fFileBacked (immutable after instantiation)
+ * strWalletFile (immutable after instantiation)
+ */
mutable CCriticalSection cs_wallet;
bool fFileBacked;
@@ -186,7 +193,7 @@ public:
const CWalletTx* GetWalletTx(const uint256& hash) const;
- // check whether we are allowed to upgrade (or already support) to the named feature
+ //! check whether we are allowed to upgrade (or already support) to the named feature
bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL) const;
@@ -200,38 +207,40 @@ public:
void UnlockAllCoins();
void ListLockedCoins(std::vector<COutPoint>& vOutpts);
- // keystore implementation
- // Generate a new key
+ /**
+ * keystore implementation
+ * Generate a new key
+ */
CPubKey GenerateNewKey();
- // Adds a key to the store, and saves it to disk.
+ //! Adds a key to the store, and saves it to disk.
bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
- // Adds a key to the store, without saving it to disk (used by LoadWallet)
+ //! Adds a key to the store, without saving it to disk (used by LoadWallet)
bool LoadKey(const CKey& key, const CPubKey &pubkey) { return CCryptoKeyStore::AddKeyPubKey(key, pubkey); }
- // Load metadata (used by LoadWallet)
+ //! Load metadata (used by LoadWallet)
bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata);
bool LoadMinVersion(int nVersion) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; nWalletMaxVersion = std::max(nWalletMaxVersion, nVersion); return true; }
- // Adds an encrypted key to the store, and saves it to disk.
+ //! Adds an encrypted key to the store, and saves it to disk.
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
- // Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
+ //! Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
bool AddCScript(const CScript& redeemScript);
bool LoadCScript(const CScript& redeemScript);
- /// Adds a destination data tuple to the store, and saves it to disk
+ //! Adds a destination data tuple to the store, and saves it to disk
bool AddDestData(const CTxDestination &dest, const std::string &key, const std::string &value);
- /// Erases a destination data tuple in the store and on disk
+ //! Erases a destination data tuple in the store and on disk
bool EraseDestData(const CTxDestination &dest, const std::string &key);
- /// Adds a destination data tuple to the store, without saving it to disk
+ //! Adds a destination data tuple to the store, without saving it to disk
bool LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value);
- /// Look up a destination data tuple in the store, return true if found false otherwise
+ //! Look up a destination data tuple in the store, return true if found false otherwise
bool GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const;
- // Adds a watch-only address to the store, and saves it to disk.
+ //! Adds a watch-only address to the store, and saves it to disk.
bool AddWatchOnly(const CScript &dest);
bool RemoveWatchOnly(const CScript &dest);
- // Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
+ //! Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
bool LoadWatchOnly(const CScript &dest);
bool Unlock(const SecureString& strWalletPassphrase);
@@ -240,17 +249,19 @@ public:
void GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const;
- /** Increment the next transaction order id
- @return next transaction order id
+ /**
+ * Increment the next transaction order id
+ * @return next transaction order id
*/
int64_t IncOrderPosNext(CWalletDB *pwalletdb = NULL);
typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair;
typedef std::multimap<int64_t, TxPair > TxItems;
- /** Get the wallet's activity log
- @return multimap of ordered transactions and accounting entries
- @warning Returned pointers are *only* valid within the scope of passed acentries
+ /**
+ * Get the wallet's activity log
+ * @return multimap of ordered transactions and accounting entries
+ * @warning Returned pointers are *only* valid within the scope of passed acentries
*/
TxItems OrderedTxItems(std::list<CAccountingEntry>& acentries, std::string strAccount = "");
@@ -318,7 +329,8 @@ public:
return true;
return false;
}
- bool IsFromMe(const CTransaction& tx) const // should probably be renamed to IsRelevantToMe
+ /** should probably be renamed to IsRelevantToMe */
+ bool IsFromMe(const CTransaction& tx) const
{
return (GetDebit(tx, ISMINE_ALL) > 0);
}
@@ -384,19 +396,20 @@ public:
bool SetDefaultKey(const CPubKey &vchPubKey);
- // signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower
+ //! signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower
bool SetMinVersion(enum WalletFeature, CWalletDB* pwalletdbIn = NULL, bool fExplicit = false);
- // change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format)
+ //! change which version we're allowed to upgrade to (note that this does not immediately imply upgrading to that format)
bool SetMaxVersion(int nVersion);
- // get the current wallet format (the oldest client version guaranteed to understand this wallet)
+ //! get the current wallet format (the oldest client version guaranteed to understand this wallet)
int GetVersion() { LOCK(cs_wallet); return nWalletVersion; }
- // Get wallet transactions that conflict with given transaction (spend same outputs)
+ //! Get wallet transactions that conflict with given transaction (spend same outputs)
std::set<uint256> GetConflicts(const uint256& txid) const;
- /** Address book entry changed.
+ /**
+ * Address book entry changed.
* @note called with lock cs_wallet held.
*/
boost::signals2::signal<void (CWallet *wallet, const CTxDestination
@@ -404,7 +417,8 @@ public:
const std::string &purpose,
ChangeType status)> NotifyAddressBookChanged;
- /** Wallet transaction added, removed or updated.
+ /**
+ * Wallet transaction added, removed or updated.
* @note called with lock cs_wallet held.
*/
boost::signals2::signal<void (CWallet *wallet, const uint256 &hashTx,
@@ -515,10 +529,13 @@ public:
int SetMerkleBranch(const CBlock& block);
- // Return depth of transaction in blockchain:
- // -1 : not in blockchain, and not in memory pool (conflicted transaction)
- // 0 : in memory pool, waiting to be included in a block
- // >=1 : this many blocks deep in the main chain
+
+ /**
+ * Return depth of transaction in blockchain:
+ * -1 : not in blockchain, and not in memory pool (conflicted transaction)
+ * 0 : in memory pool, waiting to be included in a block
+ * >=1 : this many blocks deep in the main chain
+ */
int GetDepthInMainChain(const CBlockIndex* &pindexRet) const;
int GetDepthInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
bool IsInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
@@ -526,7 +543,8 @@ public:
bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectInsaneFee=true);
};
-/** A transaction with a bunch of additional info that only the owner cares about.
+/**
+ * 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
@@ -538,11 +556,11 @@ public:
mapValue_t mapValue;
std::vector<std::pair<std::string, std::string> > vOrderForm;
unsigned int fTimeReceivedIsTxTime;
- unsigned int nTimeReceived; // time received by this node
+ unsigned int nTimeReceived; //! time received by this node
unsigned int nTimeSmart;
char fFromMe;
std::string strFromAccount;
- int64_t nOrderPos; // position in ordered transaction list
+ int64_t nOrderPos; //! position in ordered transaction list
// memory only
mutable bool fDebitCached;
@@ -634,7 +652,7 @@ public:
}
READWRITE(*(CMerkleTx*)this);
- std::vector<CMerkleTx> vUnused; // Used to be vtxPrev
+ std::vector<CMerkleTx> vUnused; //! Used to be vtxPrev
READWRITE(vUnused);
READWRITE(mapValue);
READWRITE(vOrderForm);
@@ -659,7 +677,7 @@ public:
mapValue.erase("timesmart");
}
- // make sure balances are recalculated
+ //! make sure balances are recalculated
void MarkDirty()
{
fCreditCached = false;
@@ -678,7 +696,7 @@ public:
MarkDirty();
}
- // filter decides which addresses will count towards the debit
+ //! filter decides which addresses will count towards the debit
CAmount GetDebit(const isminefilter& filter) const
{
if (vin.empty())
@@ -917,8 +935,8 @@ public:
int64_t nTimeCreated;
int64_t nTimeExpires;
std::string strComment;
- //// todo: add something to note what created it (user, getnewaddress, change)
- //// maybe should have a map<string, string> property map
+ //! 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);
@@ -940,7 +958,8 @@ public:
-/** Account information.
+/**
+ * Account information.
* Stored in wallet with key "acc"+string account name.
*/
class CAccount
@@ -970,7 +989,8 @@ public:
-/** Internal transfers.
+/**
+ * Internal transfers.
* Database key is acentry<account><counter>.
*/
class CAccountingEntry
@@ -982,7 +1002,7 @@ public:
std::string strOtherAccount;
std::string strComment;
mapValue_t mapValue;
- int64_t nOrderPos; // position in ordered transaction list
+ int64_t nOrderPos; //! position in ordered transaction list
uint64_t nEntryNo;
CAccountingEntry()
@@ -1007,7 +1027,7 @@ public:
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
- // Note: strAccount is serialized as part of the key, not here.
+ //! Note: strAccount is serialized as part of the key, not here.
READWRITE(nCreditDebit);
READWRITE(nTime);
READWRITE(LIMITED_STRING(strOtherAccount, 65536));