Use a typedef for monetary values
This commit is contained in:
committed by
Mark Friedenbach
parent
64cfaf891f
commit
a372168e77
100
src/wallet.h
100
src/wallet.h
@@ -30,9 +30,9 @@ extern unsigned int nTxConfirmTarget;
|
||||
extern bool bSpendZeroConfChange;
|
||||
|
||||
// -paytxfee default
|
||||
static const int64_t DEFAULT_TRANSACTION_FEE = 0;
|
||||
static const CAmount DEFAULT_TRANSACTION_FEE = 0;
|
||||
// -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
|
||||
static const int nHighTransactionFeeWarning = 0.01 * COIN;
|
||||
static const CAmount nHighTransactionFeeWarning = 0.01 * COIN;
|
||||
// Largest (in bytes) free transaction we're willing to create
|
||||
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
class CWallet : public CCryptoKeyStore, public CWalletInterface
|
||||
{
|
||||
private:
|
||||
bool SelectCoins(int64_t nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL) const;
|
||||
bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL) const;
|
||||
|
||||
CWalletDB *pwalletdbEncryption;
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
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;
|
||||
bool SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const;
|
||||
bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const;
|
||||
|
||||
bool IsSpent(const uint256& hash, unsigned int n) const;
|
||||
|
||||
@@ -253,21 +253,21 @@ public:
|
||||
int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false);
|
||||
void ReacceptWalletTransactions();
|
||||
void ResendWalletTransactions();
|
||||
int64_t GetBalance() const;
|
||||
int64_t GetUnconfirmedBalance() const;
|
||||
int64_t GetImmatureBalance() const;
|
||||
int64_t GetWatchOnlyBalance() const;
|
||||
int64_t GetUnconfirmedWatchOnlyBalance() const;
|
||||
int64_t GetImmatureWatchOnlyBalance() const;
|
||||
bool CreateTransaction(const std::vector<std::pair<CScript, int64_t> >& vecSend,
|
||||
CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);
|
||||
bool CreateTransaction(CScript scriptPubKey, int64_t nValue,
|
||||
CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);
|
||||
CAmount GetBalance() const;
|
||||
CAmount GetUnconfirmedBalance() const;
|
||||
CAmount GetImmatureBalance() const;
|
||||
CAmount GetWatchOnlyBalance() const;
|
||||
CAmount GetUnconfirmedWatchOnlyBalance() const;
|
||||
CAmount GetImmatureWatchOnlyBalance() const;
|
||||
bool CreateTransaction(const std::vector<std::pair<CScript, CAmount> >& vecSend,
|
||||
CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);
|
||||
bool CreateTransaction(CScript scriptPubKey, const CAmount& nValue,
|
||||
CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);
|
||||
bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey);
|
||||
std::string SendMoney(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew);
|
||||
std::string SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew);
|
||||
|
||||
static CFeeRate minTxFee;
|
||||
static int64_t GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
|
||||
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool);
|
||||
|
||||
bool NewKeyPool();
|
||||
bool TopUpKeyPool(unsigned int kpSize = 0);
|
||||
@@ -279,24 +279,24 @@ public:
|
||||
void GetAllReserveKeys(std::set<CKeyID>& setAddress) const;
|
||||
|
||||
std::set< std::set<CTxDestination> > GetAddressGroupings();
|
||||
std::map<CTxDestination, int64_t> GetAddressBalances();
|
||||
std::map<CTxDestination, CAmount> GetAddressBalances();
|
||||
|
||||
std::set<CTxDestination> GetAccountAddresses(std::string strAccount) const;
|
||||
|
||||
isminetype IsMine(const CTxIn& txin) const;
|
||||
int64_t GetDebit(const CTxIn& txin, const isminefilter& filter) const;
|
||||
CAmount GetDebit(const CTxIn& txin, const isminefilter& filter) const;
|
||||
isminetype IsMine(const CTxOut& txout) const
|
||||
{
|
||||
return ::IsMine(*this, txout.scriptPubKey);
|
||||
}
|
||||
int64_t GetCredit(const CTxOut& txout, const isminefilter& filter) const
|
||||
CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const
|
||||
{
|
||||
if (!MoneyRange(txout.nValue))
|
||||
throw std::runtime_error("CWallet::GetCredit() : value out of range");
|
||||
return ((IsMine(txout) & filter) ? txout.nValue : 0);
|
||||
}
|
||||
bool IsChange(const CTxOut& txout) const;
|
||||
int64_t GetChange(const CTxOut& txout) const
|
||||
CAmount GetChange(const CTxOut& txout) const
|
||||
{
|
||||
if (!MoneyRange(txout.nValue))
|
||||
throw std::runtime_error("CWallet::GetChange() : value out of range");
|
||||
@@ -313,9 +313,9 @@ public:
|
||||
{
|
||||
return (GetDebit(tx, ISMINE_ALL) > 0);
|
||||
}
|
||||
int64_t GetDebit(const CTransaction& tx, const isminefilter& filter) const
|
||||
CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const
|
||||
{
|
||||
int64_t nDebit = 0;
|
||||
CAmount nDebit = 0;
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
{
|
||||
nDebit += GetDebit(txin, filter);
|
||||
@@ -324,9 +324,9 @@ public:
|
||||
}
|
||||
return nDebit;
|
||||
}
|
||||
int64_t GetCredit(const CTransaction& tx, const isminefilter& filter) const
|
||||
CAmount GetCredit(const CTransaction& tx, const isminefilter& filter) const
|
||||
{
|
||||
int64_t nCredit = 0;
|
||||
CAmount nCredit = 0;
|
||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
||||
{
|
||||
nCredit += GetCredit(txout, filter);
|
||||
@@ -335,9 +335,9 @@ public:
|
||||
}
|
||||
return nCredit;
|
||||
}
|
||||
int64_t GetChange(const CTransaction& tx) const
|
||||
CAmount GetChange(const CTransaction& tx) const
|
||||
{
|
||||
int64_t nChange = 0;
|
||||
CAmount nChange = 0;
|
||||
BOOST_FOREACH(const CTxOut& txout, tx.vout)
|
||||
{
|
||||
nChange += GetChange(txout);
|
||||
@@ -457,7 +457,7 @@ static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
|
||||
struct COutputEntry
|
||||
{
|
||||
CTxDestination destination;
|
||||
int64_t amount;
|
||||
CAmount amount;
|
||||
int vout;
|
||||
};
|
||||
|
||||
@@ -545,15 +545,15 @@ public:
|
||||
mutable bool fImmatureWatchCreditCached;
|
||||
mutable bool fAvailableWatchCreditCached;
|
||||
mutable bool fChangeCached;
|
||||
mutable int64_t nDebitCached;
|
||||
mutable int64_t nCreditCached;
|
||||
mutable int64_t nImmatureCreditCached;
|
||||
mutable int64_t nAvailableCreditCached;
|
||||
mutable int64_t nWatchDebitCached;
|
||||
mutable int64_t nWatchCreditCached;
|
||||
mutable int64_t nImmatureWatchCreditCached;
|
||||
mutable int64_t nAvailableWatchCreditCached;
|
||||
mutable int64_t nChangeCached;
|
||||
mutable CAmount nDebitCached;
|
||||
mutable CAmount nCreditCached;
|
||||
mutable CAmount nImmatureCreditCached;
|
||||
mutable CAmount nAvailableCreditCached;
|
||||
mutable CAmount nWatchDebitCached;
|
||||
mutable CAmount nWatchCreditCached;
|
||||
mutable CAmount nImmatureWatchCreditCached;
|
||||
mutable CAmount nAvailableWatchCreditCached;
|
||||
mutable CAmount nChangeCached;
|
||||
|
||||
CWalletTx()
|
||||
{
|
||||
@@ -670,12 +670,12 @@ public:
|
||||
}
|
||||
|
||||
// filter decides which addresses will count towards the debit
|
||||
int64_t GetDebit(const isminefilter& filter) const
|
||||
CAmount GetDebit(const isminefilter& filter) const
|
||||
{
|
||||
if (vin.empty())
|
||||
return 0;
|
||||
|
||||
int64_t debit = 0;
|
||||
CAmount debit = 0;
|
||||
if(filter & ISMINE_SPENDABLE)
|
||||
{
|
||||
if (fDebitCached)
|
||||
@@ -701,7 +701,7 @@ public:
|
||||
return debit;
|
||||
}
|
||||
|
||||
int64_t GetCredit(bool fUseCache=true) const
|
||||
CAmount GetCredit(bool fUseCache=true) const
|
||||
{
|
||||
// Must wait until coinbase is safely deep enough in the chain before valuing it
|
||||
if (IsCoinBase() && GetBlocksToMaturity() > 0)
|
||||
@@ -715,7 +715,7 @@ public:
|
||||
return nCreditCached;
|
||||
}
|
||||
|
||||
int64_t GetImmatureCredit(bool fUseCache=true) const
|
||||
CAmount GetImmatureCredit(bool fUseCache=true) const
|
||||
{
|
||||
if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain())
|
||||
{
|
||||
@@ -729,7 +729,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t GetAvailableCredit(bool fUseCache=true) const
|
||||
CAmount GetAvailableCredit(bool fUseCache=true) const
|
||||
{
|
||||
if (pwallet == 0)
|
||||
return 0;
|
||||
@@ -741,7 +741,7 @@ public:
|
||||
if (fUseCache && fAvailableCreditCached)
|
||||
return nAvailableCreditCached;
|
||||
|
||||
int64_t nCredit = 0;
|
||||
CAmount nCredit = 0;
|
||||
uint256 hashTx = GetHash();
|
||||
for (unsigned int i = 0; i < vout.size(); i++)
|
||||
{
|
||||
@@ -759,7 +759,7 @@ public:
|
||||
return nCredit;
|
||||
}
|
||||
|
||||
int64_t GetImmatureWatchOnlyCredit(const bool& fUseCache=true) const
|
||||
CAmount GetImmatureWatchOnlyCredit(const bool& fUseCache=true) const
|
||||
{
|
||||
if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain())
|
||||
{
|
||||
@@ -773,7 +773,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t GetAvailableWatchOnlyCredit(const bool& fUseCache=true) const
|
||||
CAmount GetAvailableWatchOnlyCredit(const bool& fUseCache=true) const
|
||||
{
|
||||
if (pwallet == 0)
|
||||
return 0;
|
||||
@@ -785,7 +785,7 @@ public:
|
||||
if (fUseCache && fAvailableWatchCreditCached)
|
||||
return nAvailableWatchCreditCached;
|
||||
|
||||
int64_t nCredit = 0;
|
||||
CAmount nCredit = 0;
|
||||
for (unsigned int i = 0; i < vout.size(); i++)
|
||||
{
|
||||
if (!pwallet->IsSpent(GetHash(), i))
|
||||
@@ -802,7 +802,7 @@ public:
|
||||
return nCredit;
|
||||
}
|
||||
|
||||
int64_t GetChange() const
|
||||
CAmount GetChange() const
|
||||
{
|
||||
if (fChangeCached)
|
||||
return nChangeCached;
|
||||
@@ -812,10 +812,10 @@ public:
|
||||
}
|
||||
|
||||
void GetAmounts(std::list<COutputEntry>& listReceived,
|
||||
std::list<COutputEntry>& listSent, int64_t& nFee, std::string& strSentAccount, const isminefilter& filter) const;
|
||||
std::list<COutputEntry>& listSent, CAmount& nFee, std::string& strSentAccount, const isminefilter& filter) const;
|
||||
|
||||
void GetAccountAmounts(const std::string& strAccount, int64_t& nReceived,
|
||||
int64_t& nSent, int64_t& nFee, const isminefilter& filter) const;
|
||||
void GetAccountAmounts(const std::string& strAccount, CAmount& nReceived,
|
||||
CAmount& nSent, CAmount& nFee, const isminefilter& filter) const;
|
||||
|
||||
bool IsFromMe(const isminefilter& filter) const
|
||||
{
|
||||
@@ -949,7 +949,7 @@ class CAccountingEntry
|
||||
{
|
||||
public:
|
||||
std::string strAccount;
|
||||
int64_t nCreditDebit;
|
||||
CAmount nCreditDebit;
|
||||
int64_t nTime;
|
||||
std::string strOtherAccount;
|
||||
std::string strComment;
|
||||
|
||||
Reference in New Issue
Block a user