aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am1
-rw-r--r--src/amount.h13
-rw-r--r--src/bitcoin-tx.cpp4
-rw-r--r--src/coins.cpp4
-rw-r--r--src/coins.h4
-rw-r--r--src/core.cpp12
-rw-r--r--src/core.h21
-rw-r--r--src/init.cpp6
-rw-r--r--src/main.cpp26
-rw-r--r--src/main.h6
-rw-r--r--src/miner.cpp10
-rw-r--r--src/qt/bitcoin.cpp4
-rw-r--r--src/qt/bitcoinamountfield.cpp28
-rw-r--r--src/qt/bitcoinamountfield.h10
-rw-r--r--src/qt/bitcoingui.cpp2
-rw-r--r--src/qt/bitcoingui.h4
-rw-r--r--src/qt/bitcoinunits.cpp13
-rw-r--r--src/qt/bitcoinunits.h12
-rw-r--r--src/qt/coincontroldialog.cpp16
-rw-r--r--src/qt/coincontroldialog.h4
-rw-r--r--src/qt/guiutil.cpp2
-rw-r--r--src/qt/guiutil.h4
-rw-r--r--src/qt/optionsmodel.cpp4
-rw-r--r--src/qt/optionsmodel.h4
-rw-r--r--src/qt/overviewpage.cpp4
-rw-r--r--src/qt/overviewpage.h18
-rw-r--r--src/qt/paymentrequestplus.cpp4
-rw-r--r--src/qt/paymentrequestplus.h2
-rw-r--r--src/qt/paymentserver.cpp4
-rw-r--r--src/qt/sendcoinsdialog.cpp12
-rw-r--r--src/qt/sendcoinsdialog.h4
-rw-r--r--src/qt/transactiondesc.cpp14
-rw-r--r--src/qt/transactionfilterproxy.cpp2
-rw-r--r--src/qt/transactionfilterproxy.h6
-rw-r--r--src/qt/transactionrecord.cpp12
-rw-r--r--src/qt/transactionrecord.h7
-rw-r--r--src/qt/transactiontablemodel.cpp4
-rw-r--r--src/qt/transactionview.cpp2
-rw-r--r--src/qt/walletmodel.cpp40
-rw-r--r--src/qt/walletmodel.h32
-rw-r--r--src/qt/walletmodeltransaction.cpp8
-rw-r--r--src/qt/walletmodeltransaction.h8
-rw-r--r--src/qt/walletview.cpp2
-rw-r--r--src/qt/walletview.h4
-rw-r--r--src/rpcmining.cpp2
-rw-r--r--src/rpcrawtransaction.cpp4
-rw-r--r--src/rpcserver.cpp6
-rw-r--r--src/rpcserver.h5
-rw-r--r--src/rpcwallet.cpp62
-rw-r--r--src/test/accounting_tests.cpp4
-rw-r--r--src/test/main_tests.cpp4
-rw-r--r--src/test/util_tests.cpp2
-rw-r--r--src/test/wallet_tests.cpp4
-rw-r--r--src/txdb.cpp2
-rw-r--r--src/txmempool.cpp17
-rw-r--r--src/txmempool.h12
-rw-r--r--src/util.h1
-rw-r--r--src/utilmoneystr.cpp8
-rw-r--r--src/utilmoneystr.h8
-rw-r--r--src/wallet.cpp108
-rw-r--r--src/wallet.h100
-rw-r--r--src/walletdb.cpp4
-rw-r--r--src/walletdb.h3
63 files changed, 402 insertions, 357 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2c64cb74a0..bd6f1ba0d5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,6 +65,7 @@ BITCOIN_CORE_H = \
addrman.h \
alert.h \
allocators.h \
+ amount.h \
base58.h \
bloom.h \
chain.h \
diff --git a/src/amount.h b/src/amount.h
new file mode 100644
index 0000000000..42006a0388
--- /dev/null
+++ b/src/amount.h
@@ -0,0 +1,13 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2014 The Bitcoin developers
+// Distributed under the MIT/X11 software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_AMOUNT_H
+#define BITCOIN_AMOUNT_H
+
+#include <stdint.h>
+
+typedef int64_t CAmount;
+
+#endif
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index b6e7a6c540..a61b4fe29d 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -214,7 +214,7 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const string& strInput)
// extract and validate VALUE
string strValue = strInput.substr(0, pos);
- int64_t value;
+ CAmount value;
if (!ParseMoney(strValue, value))
throw runtime_error("invalid TX output value");
@@ -242,7 +242,7 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const string& strInput
// extract and validate VALUE
string strValue = strInput.substr(0, pos);
- int64_t value;
+ CAmount value;
if (!ParseMoney(strValue, value))
throw runtime_error("invalid TX output value");
diff --git a/src/coins.cpp b/src/coins.cpp
index 34485db2bd..9b8d63d4e4 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -171,12 +171,12 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const
return coins->vout[input.prevout.n];
}
-int64_t CCoinsViewCache::GetValueIn(const CTransaction& tx) const
+CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const
{
if (tx.IsCoinBase())
return 0;
- int64_t nResult = 0;
+ CAmount nResult = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
nResult += GetOutputFor(tx.vin[i]).nValue;
diff --git a/src/coins.h b/src/coins.h
index bf61f55aac..2583475323 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -266,7 +266,7 @@ struct CCoinsStats
uint64_t nTransactionOutputs;
uint64_t nSerializedSize;
uint256 hashSerialized;
- int64_t nTotalAmount;
+ CAmount nTotalAmount;
CCoinsStats() : nHeight(0), hashBlock(0), nTransactions(0), nTransactionOutputs(0), nSerializedSize(0), hashSerialized(0), nTotalAmount(0) {}
};
@@ -367,7 +367,7 @@ public:
@param[in] tx transaction for which we are checking input total
@return Sum of value of all inputs (scriptSigs)
*/
- int64_t GetValueIn(const CTransaction& tx) const;
+ CAmount GetValueIn(const CTransaction& tx) const;
// Check whether all prevouts of the transaction are present in the UTXO set represented by this view
bool HaveInputs(const CTransaction& tx) const;
diff --git a/src/core.cpp b/src/core.cpp
index e52327ba8e..1489d77bb3 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -43,7 +43,7 @@ std::string CTxIn::ToString() const
return str;
}
-CTxOut::CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
+CTxOut::CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn)
{
nValue = nValueIn;
scriptPubKey = scriptPubKeyIn;
@@ -59,7 +59,7 @@ std::string CTxOut::ToString() const
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30));
}
-CFeeRate::CFeeRate(int64_t nFeePaid, size_t nSize)
+CFeeRate::CFeeRate(const CAmount& nFeePaid, size_t nSize)
{
if (nSize > 0)
nSatoshisPerK = nFeePaid*1000/nSize;
@@ -67,9 +67,9 @@ CFeeRate::CFeeRate(int64_t nFeePaid, size_t nSize)
nSatoshisPerK = 0;
}
-int64_t CFeeRate::GetFee(size_t nSize) const
+CAmount CFeeRate::GetFee(size_t nSize) const
{
- int64_t nFee = nSatoshisPerK*nSize / 1000;
+ CAmount nFee = nSatoshisPerK*nSize / 1000;
if (nFee == 0 && nSatoshisPerK > 0)
nFee = nSatoshisPerK;
@@ -110,9 +110,9 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) {
return *this;
}
-int64_t CTransaction::GetValueOut() const
+CAmount CTransaction::GetValueOut() const
{
- int64_t nValueOut = 0;
+ CAmount nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, vout)
{
nValueOut += txout.nValue;
diff --git a/src/core.h b/src/core.h
index 9a2ac47487..e8435c8b0d 100644
--- a/src/core.h
+++ b/src/core.h
@@ -6,6 +6,7 @@
#ifndef BITCOIN_CORE_H
#define BITCOIN_CORE_H
+#include "amount.h"
#include "script/compressor.h"
#include "script/script.h"
#include "serialize.h"
@@ -19,8 +20,8 @@ static const int64_t COIN = 100000000;
static const int64_t CENT = 1000000;
/** No amount larger than this (in satoshi) is valid */
-static const int64_t MAX_MONEY = 21000000 * COIN;
-inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
+static const CAmount MAX_MONEY = 21000000 * COIN;
+inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
/** An outpoint - a combination of a transaction hash and an index n into its vout */
class COutPoint
@@ -129,15 +130,15 @@ public:
class CFeeRate
{
private:
- int64_t nSatoshisPerK; // unit is satoshis-per-1,000-bytes
+ CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes
public:
CFeeRate() : nSatoshisPerK(0) { }
- explicit CFeeRate(int64_t _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { }
- CFeeRate(int64_t nFeePaid, size_t nSize);
+ explicit CFeeRate(const CAmount& _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { }
+ CFeeRate(const CAmount& nFeePaid, size_t nSize);
CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; }
- int64_t GetFee(size_t size) const; // unit returned is satoshis
- int64_t GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes
+ CAmount GetFee(size_t size) const; // unit returned is satoshis
+ CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
@@ -161,7 +162,7 @@ public:
class CTxOut
{
public:
- int64_t nValue;
+ CAmount nValue;
CScript scriptPubKey;
CTxOut()
@@ -169,7 +170,7 @@ public:
SetNull();
}
- CTxOut(int64_t nValueIn, CScript scriptPubKeyIn);
+ CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn);
ADD_SERIALIZE_METHODS;
@@ -276,7 +277,7 @@ public:
}
// Return sum of txouts.
- int64_t GetValueOut() const;
+ CAmount GetValueOut() const;
// GetValueIn() is a method on CCoinsViewCache, because
// inputs must be known to compute value in.
diff --git a/src/init.cpp b/src/init.cpp
index 85f4d360d2..503df7ad3f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -662,7 +662,7 @@ bool AppInit2(boost::thread_group& threadGroup)
// cost to you of processing a transaction.
if (mapArgs.count("-minrelaytxfee"))
{
- int64_t n = 0;
+ CAmount n = 0;
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
::minRelayTxFee = CFeeRate(n);
else
@@ -672,7 +672,7 @@ bool AppInit2(boost::thread_group& threadGroup)
#ifdef ENABLE_WALLET
if (mapArgs.count("-mintxfee"))
{
- int64_t n = 0;
+ CAmount n = 0;
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
CWallet::minTxFee = CFeeRate(n);
else
@@ -680,7 +680,7 @@ bool AppInit2(boost::thread_group& threadGroup)
}
if (mapArgs.count("-paytxfee"))
{
- int64_t nFeePerK = 0;
+ CAmount nFeePerK = 0;
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"]));
if (nFeePerK > nHighTransactionFeeWarning)
diff --git a/src/main.cpp b/src/main.cpp
index 9a4271eda2..5a5c700574 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -728,7 +728,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
REJECT_INVALID, "bad-txns-oversize");
// Check for negative or overflow output values
- int64_t nValueOut = 0;
+ CAmount nValueOut = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
{
if (txout.nValue < 0)
@@ -770,19 +770,19 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
return true;
}
-int64_t GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree)
+CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree)
{
{
LOCK(mempool.cs);
uint256 hash = tx.GetHash();
double dPriorityDelta = 0;
- int64_t nFeeDelta = 0;
+ CAmount nFeeDelta = 0;
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
if (dPriorityDelta > 0 || nFeeDelta > 0)
return 0;
}
- int64_t nMinFee = ::minRelayTxFee.GetFee(nBytes);
+ CAmount nMinFee = ::minRelayTxFee.GetFee(nBytes);
if (fAllowFree)
{
@@ -845,7 +845,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
CCoinsView dummy;
CCoinsViewCache view(dummy);
- int64_t nValueIn = 0;
+ CAmount nValueIn = 0;
{
LOCK(pool.cs);
CCoinsViewMemPool viewMemPool(*pcoinsTip, pool);
@@ -897,15 +897,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
hash.ToString(), nSigOps, MAX_TX_SIGOPS),
REJECT_NONSTANDARD, "bad-txns-too-many-sigops");
- int64_t nValueOut = tx.GetValueOut();
- int64_t nFees = nValueIn-nValueOut;
+ CAmount nValueOut = tx.GetValueOut();
+ CAmount nFees = nValueIn-nValueOut;
double dPriority = view.GetPriority(tx, chainActive.Height());
CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height());
unsigned int nSize = entry.GetTxSize();
// Don't accept it if it can't get into a block
- int64_t txMinFee = GetMinRelayFee(tx, nSize, true);
+ CAmount txMinFee = GetMinRelayFee(tx, nSize, true);
if (fLimitFree && nFees < txMinFee)
return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %d < %d",
hash.ToString(), nFees, txMinFee),
@@ -1125,7 +1125,7 @@ void static PruneOrphanBlocks()
mapOrphanBlocks.erase(hash);
}
-int64_t GetBlockValue(int nHeight, int64_t nFees)
+CAmount GetBlockValue(int nHeight, const CAmount& nFees)
{
int64_t nSubsidy = 50 * COIN;
int halvings = nHeight / Params().SubsidyHalvingInterval();
@@ -1336,8 +1336,8 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
// This is also true for mempool checks.
CBlockIndex *pindexPrev = mapBlockIndex.find(inputs.GetBestBlock())->second;
int nSpendHeight = pindexPrev->nHeight + 1;
- int64_t nValueIn = 0;
- int64_t nFees = 0;
+ CAmount nValueIn = 0;
+ CAmount nFees = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
const COutPoint &prevout = tx.vin[i].prevout;
@@ -1365,7 +1365,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
REJECT_INVALID, "bad-txns-in-belowout");
// Tally transaction fees
- int64_t nTxFee = nValueIn - tx.GetValueOut();
+ CAmount nTxFee = nValueIn - tx.GetValueOut();
if (nTxFee < 0)
return state.DoS(100, error("CheckInputs() : %s nTxFee < 0", tx.GetHash().ToString()),
REJECT_INVALID, "bad-txns-fee-negative");
@@ -1605,7 +1605,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
CCheckQueueControl<CScriptCheck> control(fScriptChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL);
int64_t nTimeStart = GetTimeMicros();
- int64_t nFees = 0;
+ CAmount nFees = 0;
int nInputs = 0;
unsigned int nSigOps = 0;
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
diff --git a/src/main.h b/src/main.h
index c75841538f..7e849505dd 100644
--- a/src/main.h
+++ b/src/main.h
@@ -172,7 +172,7 @@ std::string GetWarnings(std::string strFor);
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow = false);
/** Find the best known block, and make it the tip of the block chain */
bool ActivateBestChain(CValidationState &state, CBlock *pblock = NULL);
-int64_t GetBlockValue(int nHeight, int64_t nFees);
+CAmount GetBlockValue(int nHeight, const CAmount& nFees);
/** Create a new block index entry for a given block hash */
CBlockIndex * InsertBlockIndex(uint256 hash);
@@ -220,7 +220,7 @@ struct CDiskTxPos : public CDiskBlockPos
};
-int64_t GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree);
+CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree);
//
// Check transaction inputs, and make sure any
@@ -591,7 +591,7 @@ extern CBlockTreeDB *pblocktree;
struct CBlockTemplate
{
CBlock block;
- std::vector<int64_t> vTxFees;
+ std::vector<CAmount> vTxFees;
std::vector<int64_t> vTxSigOps;
};
diff --git a/src/miner.cpp b/src/miner.cpp
index d05ddbeb1f..361a2bea41 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -111,7 +111,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
// Collect memory pool transactions into the block
- int64_t nFees = 0;
+ CAmount nFees = 0;
{
LOCK2(cs_main, mempool.cs);
@@ -135,7 +135,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
COrphan* porphan = NULL;
double dPriority = 0;
- int64_t nTotalIn = 0;
+ CAmount nTotalIn = 0;
bool fMissingInputs = false;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
@@ -170,7 +170,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
const CCoins* coins = view.AccessCoins(txin.prevout.hash);
assert(coins);
- int64_t nValueIn = coins->vout[txin.prevout.n].nValue;
+ CAmount nValueIn = coins->vout[txin.prevout.n].nValue;
nTotalIn += nValueIn;
int nConf = pindexPrev->nHeight - coins->nHeight + 1;
@@ -229,7 +229,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
// Skip free transactions if we're past the minimum block size:
const uint256& hash = tx.GetHash();
double dPriorityDelta = 0;
- int64_t nFeeDelta = 0;
+ CAmount nFeeDelta = 0;
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize))
continue;
@@ -247,7 +247,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if (!view.HaveInputs(tx))
continue;
- int64_t nTxFees = view.GetValueIn(tx)-tx.GetValueOut();
+ CAmount nTxFees = view.GetValueIn(tx)-tx.GetValueOut();
nTxSigOps += GetP2SHSigOpCount(tx, view);
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index bd686041c1..5e2fdc6c30 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -73,6 +73,7 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
// Declare meta types used for QMetaObject::invokeMethod
Q_DECLARE_METATYPE(bool*)
+Q_DECLARE_METATYPE(CAmount)
static void InitMessage(const std::string &message)
{
@@ -509,6 +510,9 @@ int main(int argc, char *argv[])
// Register meta types used for QMetaObject::invokeMethod
qRegisterMetaType< bool* >();
+ // Need to pass name here as CAmount is a typedef (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
+ // IMPORTANT if it is no longer a typedef use the normal variant above
+ qRegisterMetaType< CAmount >("CAmount");
/// 3. Application identification
// must be set before OptionsModel is initialized or translations are loaded,
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp
index 6466039013..6e35bf17b3 100644
--- a/src/qt/bitcoinamountfield.cpp
+++ b/src/qt/bitcoinamountfield.cpp
@@ -44,7 +44,7 @@ public:
void fixup(QString &input) const
{
bool valid = false;
- qint64 val = parse(input, &valid);
+ CAmount val = parse(input, &valid);
if(valid)
{
input = BitcoinUnits::format(currentUnit, val, false, BitcoinUnits::separatorAlways);
@@ -52,12 +52,12 @@ public:
}
}
- qint64 value(bool *valid_out=0) const
+ CAmount value(bool *valid_out=0) const
{
return parse(text(), valid_out);
}
- void setValue(qint64 value)
+ void setValue(const CAmount& value)
{
lineEdit()->setText(BitcoinUnits::format(currentUnit, value, false, BitcoinUnits::separatorAlways));
emit valueChanged();
@@ -66,9 +66,9 @@ public:
void stepBy(int steps)
{
bool valid = false;
- qint64 val = value(&valid);
+ CAmount val = value(&valid);
val = val + steps * singleStep;
- val = qMin(qMax(val, Q_INT64_C(0)), BitcoinUnits::maxMoney());
+ val = qMin(qMax(val, CAmount(0)), BitcoinUnits::maxMoney());
setValue(val);
}
@@ -78,7 +78,7 @@ public:
if(text().isEmpty()) // Allow step-up with empty field
return StepUpEnabled;
bool valid = false;
- qint64 val = value(&valid);
+ CAmount val = value(&valid);
if(valid)
{
if(val > 0)
@@ -92,7 +92,7 @@ public:
void setDisplayUnit(int unit)
{
bool valid = false;
- qint64 val = value(&valid);
+ CAmount val = value(&valid);
currentUnit = unit;
@@ -102,7 +102,7 @@ public:
clear();
}
- void setSingleStep(qint64 step)
+ void setSingleStep(const CAmount& step)
{
singleStep = step;
}
@@ -140,7 +140,7 @@ public:
}
private:
int currentUnit;
- qint64 singleStep;
+ CAmount singleStep;
mutable QSize cachedMinimumSizeHint;
/**
@@ -148,9 +148,9 @@ private:
* return validity.
* @note Must return 0 if !valid.
*/
- qint64 parse(const QString &text, bool *valid_out=0) const
+ CAmount parse(const QString &text, bool *valid_out=0) const
{
- qint64 val = 0;
+ CAmount val = 0;
bool valid = BitcoinUnits::parse(currentUnit, text, &val);
if(valid)
{
@@ -253,12 +253,12 @@ QWidget *BitcoinAmountField::setupTabChain(QWidget *prev)
return unit;
}
-qint64 BitcoinAmountField::value(bool *valid_out) const
+CAmount BitcoinAmountField::value(bool *valid_out) const
{
return amount->value(valid_out);
}
-void BitcoinAmountField::setValue(qint64 value)
+void BitcoinAmountField::setValue(const CAmount& value)
{
amount->setValue(value);
}
@@ -285,7 +285,7 @@ void BitcoinAmountField::setDisplayUnit(int newUnit)
unit->setValue(newUnit);
}
-void BitcoinAmountField::setSingleStep(qint64 step)
+void BitcoinAmountField::setSingleStep(const CAmount& step)
{
amount->setSingleStep(step);
}
diff --git a/src/qt/bitcoinamountfield.h b/src/qt/bitcoinamountfield.h
index 84795a7e7a..e52feeb46e 100644
--- a/src/qt/bitcoinamountfield.h
+++ b/src/qt/bitcoinamountfield.h
@@ -5,6 +5,8 @@
#ifndef BITCOINAMOUNTFIELD_H
#define BITCOINAMOUNTFIELD_H
+#include "amount.h"
+
#include <QWidget>
class AmountSpinBox;
@@ -19,16 +21,16 @@ class BitcoinAmountField: public QWidget
{
Q_OBJECT
- Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY valueChanged USER true)
+ Q_PROPERTY(CAmount value READ value WRITE setValue NOTIFY valueChanged USER true)
public:
explicit BitcoinAmountField(QWidget *parent = 0);
- qint64 value(bool *valid=0) const;
- void setValue(qint64 value);
+ CAmount value(bool *value=0) const;
+ void setValue(const CAmount& value);
/** Set single step in satoshis **/
- void setSingleStep(qint64 step);
+ void setSingleStep(const CAmount& step);
/** Make read-only **/
void setReadOnly(bool fReadOnly);
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 443bed14d7..7380fbd240 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -864,7 +864,7 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
}
#ifdef ENABLE_WALLET
-void BitcoinGUI::incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address)
+void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address)
{
// On new transaction, make an info balloon
message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 30b05cb7d9..8af6eda867 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -9,6 +9,8 @@
#include "config/bitcoin-config.h"
#endif
+#include "amount.h"
+
#include <QLabel>
#include <QMainWindow>
#include <QMap>
@@ -159,7 +161,7 @@ public slots:
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
/** Show incoming transaction notification for new transactions. */
- void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address);
+ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address);
#endif
private slots:
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp
index 3215363fa0..423b559bf7 100644
--- a/src/qt/bitcoinunits.cpp
+++ b/src/qt/bitcoinunits.cpp
@@ -91,12 +91,13 @@ int BitcoinUnits::decimals(int unit)
}
}
-QString BitcoinUnits::format(int unit, qint64 n, bool fPlus, SeparatorStyle separators)
+QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
if(!valid(unit))
return QString(); // Refuse to format invalid unit
+ qint64 n = (qint64)nIn;
qint64 coin = factor(unit);
int num_decimals = decimals(unit);
qint64 n_abs = (n > 0 ? n : -n);
@@ -138,12 +139,12 @@ QString BitcoinUnits::format(int unit, qint64 n, bool fPlus, SeparatorStyle sepa
// Please take care to use formatHtmlWithUnit instead, when
// appropriate.
-QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign, SeparatorStyle separators)
+QString BitcoinUnits::formatWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
return format(unit, amount, plussign, separators) + QString(" ") + name(unit);
}
-QString BitcoinUnits::formatHtmlWithUnit(int unit, qint64 amount, bool plussign, SeparatorStyle separators)
+QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
QString str(formatWithUnit(unit, amount, plussign, separators));
str.replace(QChar(THIN_SP_CP), QString(THIN_SP_HTML));
@@ -151,7 +152,7 @@ QString BitcoinUnits::formatHtmlWithUnit(int unit, qint64 amount, bool plussign,
}
-bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out)
+bool BitcoinUnits::parse(int unit, const QString &value, CAmount *val_out)
{
if(!valid(unit) || value.isEmpty())
return false; // Refuse to parse invalid unit or empty string
@@ -182,7 +183,7 @@ bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out)
{
return false; // Longer numbers will exceed 63 bits
}
- qint64 retvalue = str.toLongLong(&ok);
+ CAmount retvalue(str.toLongLong(&ok));
if(val_out)
{
*val_out = retvalue;
@@ -226,7 +227,7 @@ QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
return QVariant();
}
-qint64 BitcoinUnits::maxMoney()
+CAmount BitcoinUnits::maxMoney()
{
return MAX_MONEY;
}
diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h
index be9dca6012..a392c42b9b 100644
--- a/src/qt/bitcoinunits.h
+++ b/src/qt/bitcoinunits.h
@@ -5,6 +5,8 @@
#ifndef BITCOINUNITS_H
#define BITCOINUNITS_H
+#include "amount.h"
+
#include <QAbstractListModel>
#include <QString>
@@ -85,12 +87,12 @@ public:
//! Number of decimals left
static int decimals(int unit);
//! Format as string
- static QString format(int unit, qint64 amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
+ static QString format(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
//! Format as string (with unit)
- static QString formatWithUnit(int unit, qint64 amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
- static QString formatHtmlWithUnit(int unit, qint64 amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
+ static QString formatWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
+ static QString formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
//! Parse string to coin amount
- static bool parse(int unit, const QString &value, qint64 *val_out);
+ static bool parse(int unit, const QString &value, CAmount *val_out);
//! Gets title for amount column including current display unit if optionsModel reference available */
static QString getAmountColumnTitle(int unit);
///@}
@@ -117,7 +119,7 @@ public:
}
//! Return maximum number of base units (Satoshis)
- static qint64 maxMoney();
+ static CAmount maxMoney();
private:
QList<BitcoinUnits::Unit> unitlist;
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index d10463fd8f..ba0febe546 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -29,7 +29,7 @@
#include <QTreeWidgetItem>
using namespace std;
-QList<qint64> CoinControlDialog::payAmounts;
+QList<CAmount> CoinControlDialog::payAmounts;
CCoinControl* CoinControlDialog::coinControl = new CCoinControl();
CoinControlDialog::CoinControlDialog(QWidget *parent) :
@@ -443,10 +443,10 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
return;
// nPayAmount
- qint64 nPayAmount = 0;
+ CAmount nPayAmount = 0;
bool fDust = false;
CMutableTransaction txDummy;
- foreach(const qint64 &amount, CoinControlDialog::payAmounts)
+ foreach(const CAmount &amount, CoinControlDialog::payAmounts)
{
nPayAmount += amount;
@@ -460,10 +460,10 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
}
QString sPriorityLabel = tr("none");
- int64_t nAmount = 0;
- int64_t nPayFee = 0;
- int64_t nAfterFee = 0;
- int64_t nChange = 0;
+ CAmount nAmount = 0;
+ CAmount nPayFee = 0;
+ CAmount nAfterFee = 0;
+ CAmount nChange = 0;
unsigned int nBytes = 0;
unsigned int nBytesInputs = 0;
double dPriority = 0;
@@ -684,7 +684,7 @@ void CoinControlDialog::updateView()
itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress);
}
- int64_t nSum = 0;
+ CAmount nSum = 0;
double dPrioritySum = 0;
int nChildren = 0;
int nInputSum = 0;
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
index a6f239a898..9eaa8eb41d 100644
--- a/src/qt/coincontroldialog.h
+++ b/src/qt/coincontroldialog.h
@@ -5,6 +5,8 @@
#ifndef COINCONTROLDIALOG_H
#define COINCONTROLDIALOG_H
+#include "amount.h"
+
#include <QAbstractButton>
#include <QAction>
#include <QDialog>
@@ -37,7 +39,7 @@ public:
static void updateLabels(WalletModel*, QDialog*);
static QString getPriorityLabel(const CTxMemPool& pool, double);
- static QList<qint64> payAmounts;
+ static QList<CAmount> payAmounts;
static CCoinControl *coinControl;
private:
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index fc22871a6b..91bb10755a 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -221,7 +221,7 @@ QString formatBitcoinURI(const SendCoinsRecipient &info)
return ret;
}
-bool isDust(const QString& address, qint64 amount)
+bool isDust(const QString& address, const CAmount& amount)
{
CTxDestination dest = CBitcoinAddress(address.toStdString()).Get();
CScript script = GetScriptForDestination(dest);
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 67e11e59a0..0939c78f64 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -5,6 +5,8 @@
#ifndef GUIUTIL_H
#define GUIUTIL_H
+#include "amount.h"
+
#include <QHeaderView>
#include <QMessageBox>
#include <QObject>
@@ -46,7 +48,7 @@ namespace GUIUtil
QString formatBitcoinURI(const SendCoinsRecipient &info);
// Returns true if given address+amount meets "dust" definition
- bool isDust(const QString& address, qint64 amount);
+ bool isDust(const QString& address, const CAmount& amount);
// HTML escaping for rich text controls
QString HtmlEscape(const QString& str, bool fMultiLine=false);
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index bd747faeb6..cb80bd0e3d 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -275,9 +275,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
#ifdef ENABLE_WALLET
case Fee: { // core option - can be changed on-the-fly
// Todo: Add is valid check and warn via message, if not
- qint64 nTransactionFee = value.toLongLong();
+ CAmount nTransactionFee(value.toLongLong());
payTxFee = CFeeRate(nTransactionFee, 1000);
- settings.setValue("nTransactionFee", nTransactionFee);
+ settings.setValue("nTransactionFee", qint64(nTransactionFee));
emit transactionFeeChanged(nTransactionFee);
break;
}
diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h
index 80adab89c8..42ea3bf8e5 100644
--- a/src/qt/optionsmodel.h
+++ b/src/qt/optionsmodel.h
@@ -5,6 +5,8 @@
#ifndef OPTIONSMODEL_H
#define OPTIONSMODEL_H
+#include "amount.h"
+
#include <QAbstractListModel>
QT_BEGIN_NAMESPACE
@@ -82,7 +84,7 @@ private:
signals:
void displayUnitChanged(int unit);
- void transactionFeeChanged(qint64);
+ void transactionFeeChanged(const CAmount&);
void coinControlFeaturesChanged(bool);
};
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index 90762bea5d..669d5474fd 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -146,7 +146,7 @@ OverviewPage::~OverviewPage()
delete ui;
}
-void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 watchOnlyBalance, qint64 watchUnconfBalance, qint64 watchImmatureBalance)
+void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance)
{
int unit = walletModel->getOptionsModel()->getDisplayUnit();
currentBalance = balance;
@@ -220,7 +220,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
// Keep up to date with wallet
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(),
model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
- connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64, qint64, qint64)));
+ connect(model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h
index f46374efba..03f239008f 100644
--- a/src/qt/overviewpage.h
+++ b/src/qt/overviewpage.h
@@ -5,6 +5,8 @@
#ifndef OVERVIEWPAGE_H
#define OVERVIEWPAGE_H
+#include "amount.h"
+
#include <QWidget>
class ClientModel;
@@ -34,8 +36,8 @@ public:
void showOutOfSyncWarning(bool fShow);
public slots:
- void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance,
- qint64 watchOnlyBalance, qint64 watchUnconfBalance, qint64 watchImmatureBalance);
+ void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
+ const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
signals:
void transactionClicked(const QModelIndex &index);
@@ -44,12 +46,12 @@ private:
Ui::OverviewPage *ui;
ClientModel *clientModel;
WalletModel *walletModel;
- qint64 currentBalance;
- qint64 currentUnconfirmedBalance;
- qint64 currentImmatureBalance;
- qint64 currentWatchOnlyBalance;
- qint64 currentWatchUnconfBalance;
- qint64 currentWatchImmatureBalance;
+ CAmount currentBalance;
+ CAmount currentUnconfirmedBalance;
+ CAmount currentImmatureBalance;
+ CAmount currentWatchOnlyBalance;
+ CAmount currentWatchUnconfBalance;
+ CAmount currentWatchImmatureBalance;
TxViewDelegate *txdelegate;
TransactionFilterProxy *filter;
diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index 7b7de49831..7aefffe24a 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -196,9 +196,9 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
return fResult;
}
-QList<std::pair<CScript,qint64> > PaymentRequestPlus::getPayTo() const
+QList<std::pair<CScript,CAmount> > PaymentRequestPlus::getPayTo() const
{
- QList<std::pair<CScript,qint64> > result;
+ QList<std::pair<CScript,CAmount> > result;
for (int i = 0; i < details.outputs_size(); i++)
{
const unsigned char* scriptStr = (const unsigned char*)details.outputs(i).script().data();
diff --git a/src/qt/paymentrequestplus.h b/src/qt/paymentrequestplus.h
index 3c4861a4d4..3d94d93269 100644
--- a/src/qt/paymentrequestplus.h
+++ b/src/qt/paymentrequestplus.h
@@ -33,7 +33,7 @@ public:
bool getMerchant(X509_STORE* certStore, QString& merchant) const;
// Returns list of outputs, amount
- QList<std::pair<CScript,qint64> > getPayTo() const;
+ QList<std::pair<CScript,CAmount> > getPayTo() const;
const payments::PaymentDetails& getDetails() const { return details; }
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index cc4478f39f..707de55290 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -532,10 +532,10 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins
request.getMerchant(PaymentServer::certStore, recipient.authenticatedMerchant);
- QList<std::pair<CScript, qint64> > sendingTos = request.getPayTo();
+ QList<std::pair<CScript, CAmount> > sendingTos = request.getPayTo();
QStringList addresses;
- foreach(const PAIRTYPE(CScript, qint64)& sendingTo, sendingTos) {
+ foreach(const PAIRTYPE(CScript, CAmount)& sendingTo, sendingTos) {
// Extract and check destination addresses
CTxDestination dest;
if (ExtractDestination(sendingTo.first, dest)) {
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 25e3d2a0dc..ce94131cce 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -92,13 +92,13 @@ void SendCoinsDialog::setModel(WalletModel *model)
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(),
model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
- connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64, qint64, qint64)));
+ connect(model, SIGNAL(balanceChanged(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)), this, SLOT(setBalance(CAmount,CAmount,CAmount,CAmount,CAmount,CAmount)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
// Coin Control
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels()));
connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool)));
- connect(model->getOptionsModel(), SIGNAL(transactionFeeChanged(qint64)), this, SLOT(coinControlUpdateLabels()));
+ connect(model->getOptionsModel(), SIGNAL(transactionFeeChanged(CAmount)), this, SLOT(coinControlUpdateLabels()));
ui->frameCoinControl->setVisible(model->getOptionsModel()->getCoinControlFeatures());
coinControlUpdateLabels();
}
@@ -203,7 +203,7 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}
- qint64 txFee = currentTransaction.getTransactionFee();
+ CAmount txFee = currentTransaction.getTransactionFee();
QString questionString = tr("Are you sure you want to send?");
questionString.append("<br /><br />%1");
@@ -218,7 +218,7 @@ void SendCoinsDialog::on_sendButton_clicked()
// add total amount in all subdivision units
questionString.append("<hr />");
- qint64 totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
+ CAmount totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
QStringList alternativeUnits;
foreach(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
{
@@ -384,8 +384,8 @@ bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv)
return true;
}
-void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance,
- qint64 watchBalance, qint64 watchUnconfirmedBalance, qint64 watchImmatureBalance)
+void SendCoinsDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
+ const CAmount& watchBalance, const CAmount& watchUnconfirmedBalance, const CAmount& watchImmatureBalance)
{
Q_UNUSED(unconfirmedBalance);
Q_UNUSED(immatureBalance);
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index a090fa42d5..74cc4bde56 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -47,8 +47,8 @@ public slots:
void accept();
SendCoinsEntry *addEntry();
void updateTabsAndLabels();
- void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance,
- qint64 watchOnlyBalance, qint64 watchUnconfBalance, qint64 watchImmatureBalance);
+ void setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
+ const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
private:
Ui::SendCoinsDialog *ui;
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 4923718341..1efad8259b 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -56,9 +56,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
int64_t nTime = wtx.GetTxTime();
- int64_t nCredit = wtx.GetCredit(ISMINE_ALL);
- int64_t nDebit = wtx.GetDebit(ISMINE_ALL);
- int64_t nNet = nCredit - nDebit;
+ CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
+ CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
+ CAmount nNet = nCredit - nDebit;
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
int nRequests = wtx.GetRequestCount();
@@ -132,7 +132,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
//
// Coinbase
//
- int64_t nUnmatured = 0;
+ CAmount nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout, ISMINE_ALL);
strHTML += "<b>" + tr("Credit") + ":</b> ";
@@ -206,13 +206,13 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
if (fAllToMe)
{
// Payment to self
- int64_t nChange = wtx.GetChange();
- int64_t nValue = nCredit - nChange;
+ CAmount nChange = wtx.GetChange();
+ CAmount nValue = nCredit - nChange;
strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nValue) + "<br>";
strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, nValue) + "<br>";
}
- int64_t nTxFee = nDebit - wtx.GetValueOut();
+ CAmount nTxFee = nDebit - wtx.GetValueOut();
if (nTxFee > 0)
strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nTxFee) + "<br>";
}
diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp
index 6ab029173b..2a0f621d1e 100644
--- a/src/qt/transactionfilterproxy.cpp
+++ b/src/qt/transactionfilterproxy.cpp
@@ -78,7 +78,7 @@ void TransactionFilterProxy::setTypeFilter(quint32 modes)
invalidateFilter();
}
-void TransactionFilterProxy::setMinAmount(qint64 minimum)
+void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
{
this->minAmount = minimum;
invalidateFilter();
diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h
index f408317b53..ca31ee8f87 100644
--- a/src/qt/transactionfilterproxy.h
+++ b/src/qt/transactionfilterproxy.h
@@ -5,6 +5,8 @@
#ifndef TRANSACTIONFILTERPROXY_H
#define TRANSACTIONFILTERPROXY_H
+#include "amount.h"
+
#include <QDateTime>
#include <QSortFilterProxyModel>
@@ -38,7 +40,7 @@ public:
@note Type filter takes a bit field created with TYPE() or ALL_TYPES
*/
void setTypeFilter(quint32 modes);
- void setMinAmount(qint64 minimum);
+ void setMinAmount(const CAmount& minimum);
void setWatchOnlyFilter(WatchOnlyFilter filter);
/** Set maximum number of rows returned, -1 if unlimited. */
@@ -58,7 +60,7 @@ private:
QString addrPrefix;
quint32 typeFilter;
WatchOnlyFilter watchOnlyFilter;
- qint64 minAmount;
+ CAmount minAmount;
int limitRows;
bool showInactive;
};
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index 20c1449c92..afb343f349 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -32,9 +32,9 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
{
QList<TransactionRecord> parts;
int64_t nTime = wtx.GetTxTime();
- int64_t nCredit = wtx.GetCredit(true);
- int64_t nDebit = wtx.GetDebit(ISMINE_ALL);
- int64_t nNet = nCredit - nDebit;
+ CAmount nCredit = wtx.GetCredit(true);
+ CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
+ CAmount nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;
@@ -97,7 +97,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
if (fAllFromMe && fAllToMe)
{
// Payment to self
- int64_t nChange = wtx.GetChange();
+ CAmount nChange = wtx.GetChange();
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
@@ -108,7 +108,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
//
// Debit
//
- int64_t nTxFee = nDebit - wtx.GetValueOut();
+ CAmount nTxFee = nDebit - wtx.GetValueOut();
for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)
{
@@ -138,7 +138,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
sub.address = mapValue["to"];
}
- int64_t nValue = txout.nValue;
+ CAmount nValue = txout.nValue;
/* Add fee to first output */
if (nTxFee > 0)
{
diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h
index 626b7654c6..9276c9f0af 100644
--- a/src/qt/transactionrecord.h
+++ b/src/qt/transactionrecord.h
@@ -5,6 +5,7 @@
#ifndef TRANSACTIONRECORD_H
#define TRANSACTIONRECORD_H
+#include "amount.h"
#include "uint256.h"
#include <QList>
@@ -94,7 +95,7 @@ public:
TransactionRecord(uint256 hash, qint64 time,
Type type, const std::string &address,
- qint64 debit, qint64 credit):
+ const CAmount& debit, const CAmount& credit):
hash(hash), time(time), type(type), address(address), debit(debit), credit(credit),
idx(0)
{
@@ -111,8 +112,8 @@ public:
qint64 time;
Type type;
std::string address;
- qint64 debit;
- qint64 credit;
+ CAmount debit;
+ CAmount credit;
/**@}*/
/** Subtransaction index, for sort key */
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 2b869b4ea5..e34d776818 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -546,7 +546,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case ToAddress:
return formatTxToAddress(rec, true);
case Amount:
- return rec->credit + rec->debit;
+ return qint64(rec->credit + rec->debit);
}
break;
case Qt::ToolTipRole:
@@ -583,7 +583,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case LabelRole:
return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
case AmountRole:
- return rec->credit + rec->debit;
+ return qint64(rec->credit + rec->debit);
case TxIDRole:
return rec->getTxID();
case TxHashRole:
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index a7ba100cd2..d153973872 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -304,7 +304,7 @@ void TransactionView::changedAmount(const QString &amount)
{
if(!transactionProxyModel)
return;
- qint64 amount_parsed = 0;
+ CAmount amount_parsed = 0;
if(BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed))
{
transactionProxyModel->setMinAmount(amount_parsed);
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index ed90914ba7..b8701a23a6 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -55,11 +55,11 @@ WalletModel::~WalletModel()
unsubscribeFromCoreSignals();
}
-qint64 WalletModel::getBalance(const CCoinControl *coinControl) const
+CAmount WalletModel::getBalance(const CCoinControl *coinControl) const
{
if (coinControl)
{
- qint64 nBalance = 0;
+ CAmount nBalance = 0;
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins, true, coinControl);
BOOST_FOREACH(const COutput& out, vCoins)
@@ -72,12 +72,12 @@ qint64 WalletModel::getBalance(const CCoinControl *coinControl) const
return wallet->GetBalance();
}
-qint64 WalletModel::getUnconfirmedBalance() const
+CAmount WalletModel::getUnconfirmedBalance() const
{
return wallet->GetUnconfirmedBalance();
}
-qint64 WalletModel::getImmatureBalance() const
+CAmount WalletModel::getImmatureBalance() const
{
return wallet->GetImmatureBalance();
}
@@ -87,17 +87,17 @@ bool WalletModel::haveWatchOnly() const
return fHaveWatchOnly;
}
-qint64 WalletModel::getWatchBalance() const
+CAmount WalletModel::getWatchBalance() const
{
return wallet->GetWatchOnlyBalance();
}
-qint64 WalletModel::getWatchUnconfirmedBalance() const
+CAmount WalletModel::getWatchUnconfirmedBalance() const
{
return wallet->GetUnconfirmedWatchOnlyBalance();
}
-qint64 WalletModel::getWatchImmatureBalance() const
+CAmount WalletModel::getWatchImmatureBalance() const
{
return wallet->GetImmatureWatchOnlyBalance();
}
@@ -137,12 +137,12 @@ void WalletModel::pollBalanceChanged()
void WalletModel::checkBalanceChanged()
{
- qint64 newBalance = getBalance();
- qint64 newUnconfirmedBalance = getUnconfirmedBalance();
- qint64 newImmatureBalance = getImmatureBalance();
- qint64 newWatchOnlyBalance = 0;
- qint64 newWatchUnconfBalance = 0;
- qint64 newWatchImmatureBalance = 0;
+ CAmount newBalance = getBalance();
+ CAmount newUnconfirmedBalance = getUnconfirmedBalance();
+ CAmount newImmatureBalance = getImmatureBalance();
+ CAmount newWatchOnlyBalance = 0;
+ CAmount newWatchUnconfBalance = 0;
+ CAmount newWatchImmatureBalance = 0;
if (haveWatchOnly())
{
newWatchOnlyBalance = getWatchBalance();
@@ -194,9 +194,9 @@ bool WalletModel::validateAddress(const QString &address)
WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl)
{
- qint64 total = 0;
+ CAmount total = 0;
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
- std::vector<std::pair<CScript, int64_t> > vecSend;
+ std::vector<std::pair<CScript, CAmount> > vecSend;
if(recipients.empty())
{
@@ -211,7 +211,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
{
if (rcp.paymentRequest.IsInitialized())
{ // PaymentRequest...
- int64_t subtotal = 0;
+ CAmount subtotal = 0;
const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
for (int i = 0; i < details.outputs_size(); i++)
{
@@ -220,7 +220,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
subtotal += out.amount();
const unsigned char* scriptStr = (const unsigned char*)out.script().data();
CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
- vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, out.amount()));
+ vecSend.push_back(std::pair<CScript, CAmount>(scriptPubKey, out.amount()));
}
if (subtotal <= 0)
{
@@ -242,7 +242,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
++nAddresses;
CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
- vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, rcp.amount));
+ vecSend.push_back(std::pair<CScript, CAmount>(scriptPubKey, rcp.amount));
total += rcp.amount;
}
@@ -252,7 +252,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
return DuplicateAddress;
}
- qint64 nBalance = getBalance(coinControl);
+ CAmount nBalance = getBalance(coinControl);
if(total > nBalance)
{
@@ -263,7 +263,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
LOCK2(cs_main, wallet->cs_wallet);
transaction.newPossibleKeyChange(wallet);
- int64_t nFeeRequired = 0;
+ CAmount nFeeRequired = 0;
std::string strFailReason;
CWalletTx *newTx = transaction.getTransaction();
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 111ae2178c..b1d0f28f12 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -37,7 +37,7 @@ class SendCoinsRecipient
{
public:
explicit SendCoinsRecipient() : amount(0), nVersion(SendCoinsRecipient::CURRENT_VERSION) { }
- explicit SendCoinsRecipient(const QString &addr, const QString &label, quint64 amount, const QString &message):
+ explicit SendCoinsRecipient(const QString &addr, const QString &label, const CAmount& amount, const QString &message):
address(addr), label(label), amount(amount), message(message), nVersion(SendCoinsRecipient::CURRENT_VERSION) {}
// If from an insecure payment request, this is used for storing
@@ -47,7 +47,7 @@ public:
// Todo: This is a hack, should be replaced with a cleaner solution!
QString address;
QString label;
- qint64 amount;
+ CAmount amount;
// If from a payment request, this is used for storing the memo
QString message;
@@ -125,13 +125,13 @@ public:
TransactionTableModel *getTransactionTableModel();
RecentRequestsTableModel *getRecentRequestsTableModel();
- qint64 getBalance(const CCoinControl *coinControl = NULL) const;
- qint64 getUnconfirmedBalance() const;
- qint64 getImmatureBalance() const;
+ CAmount getBalance(const CCoinControl *coinControl = NULL) const;
+ CAmount getUnconfirmedBalance() const;
+ CAmount getImmatureBalance() const;
bool haveWatchOnly() const;
- qint64 getWatchBalance() const;
- qint64 getWatchUnconfirmedBalance() const;
- qint64 getWatchImmatureBalance() const;
+ CAmount getWatchBalance() const;
+ CAmount getWatchUnconfirmedBalance() const;
+ CAmount getWatchImmatureBalance() const;
EncryptionStatus getEncryptionStatus() const;
bool processingQueuedTransactions() { return fProcessingQueuedTransactions; }
@@ -210,12 +210,12 @@ private:
RecentRequestsTableModel *recentRequestsTableModel;
// Cache some values to be able to detect changes
- qint64 cachedBalance;
- qint64 cachedUnconfirmedBalance;
- qint64 cachedImmatureBalance;
- qint64 cachedWatchOnlyBalance;
- qint64 cachedWatchUnconfBalance;
- qint64 cachedWatchImmatureBalance;
+ CAmount cachedBalance;
+ CAmount cachedUnconfirmedBalance;
+ CAmount cachedImmatureBalance;
+ CAmount cachedWatchOnlyBalance;
+ CAmount cachedWatchUnconfBalance;
+ CAmount cachedWatchImmatureBalance;
EncryptionStatus cachedEncryptionStatus;
int cachedNumBlocks;
@@ -227,8 +227,8 @@ private:
signals:
// Signal that balance in wallet changed
- void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance,
- qint64 watchOnlyBalance, qint64 watchUnconfBalance, qint64 watchImmatureBalance);
+ void balanceChanged(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance,
+ const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance);
// Encryption status of wallet changed
void encryptionStatusChanged(int status);
diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp
index 943f13e208..ddd2d09bb5 100644
--- a/src/qt/walletmodeltransaction.cpp
+++ b/src/qt/walletmodeltransaction.cpp
@@ -31,19 +31,19 @@ CWalletTx *WalletModelTransaction::getTransaction()
return walletTransaction;
}
-qint64 WalletModelTransaction::getTransactionFee()
+CAmount WalletModelTransaction::getTransactionFee()
{
return fee;
}
-void WalletModelTransaction::setTransactionFee(qint64 newFee)
+void WalletModelTransaction::setTransactionFee(const CAmount& newFee)
{
fee = newFee;
}
-qint64 WalletModelTransaction::getTotalTransactionAmount()
+CAmount WalletModelTransaction::getTotalTransactionAmount()
{
- qint64 totalTransactionAmount = 0;
+ CAmount totalTransactionAmount = 0;
foreach(const SendCoinsRecipient &rcp, recipients)
{
totalTransactionAmount += rcp.amount;
diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h
index b7e85bcd11..4eadfbe4d1 100644
--- a/src/qt/walletmodeltransaction.h
+++ b/src/qt/walletmodeltransaction.h
@@ -26,10 +26,10 @@ public:
CWalletTx *getTransaction();
- void setTransactionFee(qint64 newFee);
- qint64 getTransactionFee();
+ void setTransactionFee(const CAmount& newFee);
+ CAmount getTransactionFee();
- qint64 getTotalTransactionAmount();
+ CAmount getTotalTransactionAmount();
void newPossibleKeyChange(CWallet *wallet);
CReserveKey *getPossibleKeyChange();
@@ -38,7 +38,7 @@ private:
const QList<SendCoinsRecipient> recipients;
CWalletTx *walletTransaction;
CReserveKey *keyChange;
- qint64 fee;
+ CAmount fee;
};
#endif // WALLETMODELTRANSACTION_H
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
index b40ddc0a2f..eff50593bd 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -92,7 +92,7 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui)
connect(this, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(setEncryptionStatus(int)));
// Pass through transaction notifications
- connect(this, SIGNAL(incomingTransaction(QString,int,qint64,QString,QString)), gui, SLOT(incomingTransaction(QString,int,qint64,QString,QString)));
+ connect(this, SIGNAL(incomingTransaction(QString,int,CAmount,QString,QString)), gui, SLOT(incomingTransaction(QString,int,CAmount,QString,QString)));
}
}
diff --git a/src/qt/walletview.h b/src/qt/walletview.h
index 9cfa8d6760..cafba517fd 100644
--- a/src/qt/walletview.h
+++ b/src/qt/walletview.h
@@ -5,6 +5,8 @@
#ifndef WALLETVIEW_H
#define WALLETVIEW_H
+#include "amount.h"
+
#include <QStackedWidget>
class BitcoinGUI;
@@ -111,7 +113,7 @@ signals:
/** Encryption status of wallet changed */
void encryptionStatusChanged(int status);
/** Notify that a new transaction appeared */
- void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address);
+ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address);
};
#endif // WALLETVIEW_H
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 82eaf5d037..e794bf69e0 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -273,7 +273,7 @@ Value prioritisetransaction(const Array& params, bool fHelp)
uint256 hash;
hash.SetHex(params[0].get_str());
- int64_t nAmount = 0;
+ CAmount nAmount = 0;
if (params[2].get_real() != 0.0)
nAmount = AmountFromValue(params[2]);
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index dbb0966ae2..bd87d77704 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -269,7 +269,7 @@ Value listunspent(const Array& params, bool fHelp)
continue;
}
- int64_t nValue = out.tx->vout[out.i].nValue;
+ CAmount nValue = out.tx->vout[out.i].nValue;
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
Object entry;
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
@@ -367,7 +367,7 @@ Value createrawtransaction(const Array& params, bool fHelp)
setAddress.insert(address);
CScript scriptPubKey = GetScriptForDestination(address.Get());
- int64_t nAmount = AmountFromValue(s.value_);
+ CAmount nAmount = AmountFromValue(s.value_);
CTxOut out(nAmount, scriptPubKey);
rawTx.vout.push_back(out);
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index 190de62282..1a41344da5 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -88,18 +88,18 @@ static inline int64_t roundint64(double d)
return (int64_t)(d > 0 ? d + 0.5 : d - 0.5);
}
-int64_t AmountFromValue(const Value& value)
+CAmount AmountFromValue(const Value& value)
{
double dAmount = value.get_real();
if (dAmount <= 0.0 || dAmount > 21000000.0)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
- int64_t nAmount = roundint64(dAmount * COIN);
+ CAmount nAmount = roundint64(dAmount * COIN);
if (!MoneyRange(nAmount))
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
return nAmount;
}
-Value ValueFromAmount(int64_t amount)
+Value ValueFromAmount(const CAmount& amount)
{
return (double)amount / (double)COIN;
}
diff --git a/src/rpcserver.h b/src/rpcserver.h
index 820c1bc081..d440035f15 100644
--- a/src/rpcserver.h
+++ b/src/rpcserver.h
@@ -6,6 +6,7 @@
#ifndef _BITCOINRPC_SERVER_H_
#define _BITCOINRPC_SERVER_H_
+#include "amount.h"
#include "uint256.h"
#include "rpcprotocol.h"
@@ -116,8 +117,8 @@ extern void InitRPCMining();
extern void ShutdownRPCMining();
extern int64_t nWalletUnlockTime;
-extern int64_t AmountFromValue(const json_spirit::Value& value);
-extern json_spirit::Value ValueFromAmount(int64_t amount);
+extern CAmount AmountFromValue(const json_spirit::Value& value);
+extern json_spirit::Value ValueFromAmount(const CAmount& amount);
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
extern std::string HelpRequiringPassphrase();
extern std::string HelpExampleCli(std::string methodname, std::string args);
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 35637362a4..632c46acd5 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -331,7 +331,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
// Amount
- int64_t nAmount = AmountFromValue(params[1]);
+ CAmount nAmount = AmountFromValue(params[1]);
// Wallet comments
CWalletTx wtx;
@@ -375,7 +375,7 @@ Value listaddressgroupings(const Array& params, bool fHelp)
);
Array jsonGroupings;
- map<CTxDestination, int64_t> balances = pwalletMain->GetAddressBalances();
+ map<CTxDestination, CAmount> balances = pwalletMain->GetAddressBalances();
BOOST_FOREACH(set<CTxDestination> grouping, pwalletMain->GetAddressGroupings())
{
Array jsonGrouping;
@@ -483,7 +483,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
nMinDepth = params[1].get_int();
// Tally
- int64_t nAmount = 0;
+ CAmount nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
@@ -532,7 +532,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
set<CTxDestination> setAddress = pwalletMain->GetAccountAddresses(strAccount);
// Tally
- int64_t nAmount = 0;
+ CAmount nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
@@ -552,9 +552,9 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
}
-int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth, const isminefilter& filter)
+CAmount GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth, const isminefilter& filter)
{
- int64_t nBalance = 0;
+ CAmount nBalance = 0;
// Tally wallet transactions
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
@@ -563,7 +563,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
if (!IsFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 0)
continue;
- int64_t nReceived, nSent, nFee;
+ CAmount nReceived, nSent, nFee;
wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee, filter);
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
@@ -577,7 +577,7 @@ int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
return nBalance;
}
-int64_t GetAccountBalance(const string& strAccount, int nMinDepth, const isminefilter& filter)
+CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminefilter& filter)
{
CWalletDB walletdb(pwalletMain->strWalletFile);
return GetAccountBalance(walletdb, strAccount, nMinDepth, filter);
@@ -627,14 +627,14 @@ Value getbalance(const Array& params, bool fHelp)
// Calculate total balance a different way from GetBalance()
// (GetBalance() sums up all unspent TxOuts)
// getbalance and getbalance '*' 0 should return the same number
- int64_t nBalance = 0;
+ CAmount nBalance = 0;
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
if (!wtx.IsTrusted() || wtx.GetBlocksToMaturity() > 0)
continue;
- int64_t allFee;
+ CAmount allFee;
string strSentAccount;
list<COutputEntry> listReceived;
list<COutputEntry> listSent;
@@ -653,7 +653,7 @@ Value getbalance(const Array& params, bool fHelp)
string strAccount = AccountFromValue(params[0]);
- int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, filter);
+ CAmount nBalance = GetAccountBalance(strAccount, nMinDepth, filter);
return ValueFromAmount(nBalance);
}
@@ -692,7 +692,7 @@ Value movecmd(const Array& params, bool fHelp)
string strFrom = AccountFromValue(params[0]);
string strTo = AccountFromValue(params[1]);
- int64_t nAmount = AmountFromValue(params[2]);
+ CAmount nAmount = AmountFromValue(params[2]);
if (params.size() > 3)
// unused parameter, used to be nMinDepth, keep type-checking it though
(void)params[3].get_int();
@@ -766,7 +766,7 @@ Value sendfrom(const Array& params, bool fHelp)
CBitcoinAddress address(params[1].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
- int64_t nAmount = AmountFromValue(params[2]);
+ CAmount nAmount = AmountFromValue(params[2]);
int nMinDepth = 1;
if (params.size() > 3)
nMinDepth = params[3].get_int();
@@ -781,7 +781,7 @@ Value sendfrom(const Array& params, bool fHelp)
EnsureWalletIsUnlocked();
// Check funds
- int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE);
+ CAmount nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE);
if (nAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
@@ -834,9 +834,9 @@ Value sendmany(const Array& params, bool fHelp)
wtx.mapValue["comment"] = params[3].get_str();
set<CBitcoinAddress> setAddress;
- vector<pair<CScript, int64_t> > vecSend;
+ vector<pair<CScript, CAmount> > vecSend;
- int64_t totalAmount = 0;
+ CAmount totalAmount = 0;
BOOST_FOREACH(const Pair& s, sendTo)
{
CBitcoinAddress address(s.name_);
@@ -848,7 +848,7 @@ Value sendmany(const Array& params, bool fHelp)
setAddress.insert(address);
CScript scriptPubKey = GetScriptForDestination(address.Get());
- int64_t nAmount = AmountFromValue(s.value_);
+ CAmount nAmount = AmountFromValue(s.value_);
totalAmount += nAmount;
vecSend.push_back(make_pair(scriptPubKey, nAmount));
@@ -857,13 +857,13 @@ Value sendmany(const Array& params, bool fHelp)
EnsureWalletIsUnlocked();
// Check funds
- int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE);
+ CAmount nBalance = GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE);
if (totalAmount > nBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
// Send
CReserveKey keyChange(pwalletMain);
- int64_t nFeeRequired = 0;
+ CAmount nFeeRequired = 0;
string strFailReason;
bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, strFailReason);
if (!fCreated)
@@ -923,7 +923,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)
struct tallyitem
{
- int64_t nAmount;
+ CAmount nAmount;
int nConf;
vector<uint256> txids;
bool fIsWatchonly;
@@ -995,7 +995,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
if (it == mapTally.end() && !fIncludeEmpty)
continue;
- int64_t nAmount = 0;
+ CAmount nAmount = 0;
int nConf = std::numeric_limits<int>::max();
bool fIsWatchonly = false;
if (it != mapTally.end())
@@ -1038,7 +1038,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
{
for (map<string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it)
{
- int64_t nAmount = (*it).second.nAmount;
+ CAmount nAmount = (*it).second.nAmount;
int nConf = (*it).second.nConf;
Object obj;
if((*it).second.fIsWatchonly)
@@ -1125,7 +1125,7 @@ static void MaybePushAddress(Object & entry, const CTxDestination &dest)
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret, const isminefilter& filter)
{
- int64_t nFee;
+ CAmount nFee;
string strSentAccount;
list<COutputEntry> listReceived;
list<COutputEntry> listSent;
@@ -1355,7 +1355,7 @@ Value listaccounts(const Array& params, bool fHelp)
if(params[1].get_bool())
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY;
- map<string, int64_t> mapAccountBalances;
+ map<string, CAmount> mapAccountBalances;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwalletMain->mapAddressBook) {
if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me
mapAccountBalances[entry.second.name] = 0;
@@ -1364,7 +1364,7 @@ Value listaccounts(const Array& params, bool fHelp)
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
{
const CWalletTx& wtx = (*it).second;
- int64_t nFee;
+ CAmount nFee;
string strSentAccount;
list<COutputEntry> listReceived;
list<COutputEntry> listSent;
@@ -1391,7 +1391,7 @@ Value listaccounts(const Array& params, bool fHelp)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
Object ret;
- BOOST_FOREACH(const PAIRTYPE(string, int64_t)& accountBalance, mapAccountBalances) {
+ BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) {
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
}
return ret;
@@ -1534,10 +1534,10 @@ Value gettransaction(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
const CWalletTx& wtx = pwalletMain->mapWallet[hash];
- int64_t nCredit = wtx.GetCredit(filter != 0);
- int64_t nDebit = wtx.GetDebit(filter);
- int64_t nNet = nCredit - nDebit;
- int64_t nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);
+ CAmount nCredit = wtx.GetCredit(filter != 0);
+ CAmount nDebit = wtx.GetDebit(filter);
+ CAmount nNet = nCredit - nDebit;
+ CAmount nFee = (wtx.IsFromMe(filter) ? wtx.GetValueOut() - nDebit : 0);
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
if (wtx.IsFromMe(filter))
@@ -1937,7 +1937,7 @@ Value settxfee(const Array& params, bool fHelp)
);
// Amount
- int64_t nAmount = 0;
+ CAmount nAmount = 0;
if (params[0].get_real() != 0.0)
nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts
diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp
index 4bee0f6b6e..af2a9a214f 100644
--- a/src/test/accounting_tests.cpp
+++ b/src/test/accounting_tests.cpp
@@ -15,7 +15,7 @@ extern CWallet* pwalletMain;
BOOST_AUTO_TEST_SUITE(accounting_tests)
static void
-GetResults(CWalletDB& walletdb, std::map<int64_t, CAccountingEntry>& results)
+GetResults(CWalletDB& walletdb, std::map<CAmount, CAccountingEntry>& results)
{
std::list<CAccountingEntry> aes;
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
std::vector<CWalletTx*> vpwtx;
CWalletTx wtx;
CAccountingEntry ae;
- std::map<int64_t, CAccountingEntry> results;
+ std::map<CAmount, CAccountingEntry> results;
LOCK(pwalletMain->cs_wallet);
diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp
index 8863ba4004..70a800af51 100644
--- a/src/test/main_tests.cpp
+++ b/src/test/main_tests.cpp
@@ -11,9 +11,9 @@ BOOST_AUTO_TEST_SUITE(main_tests)
BOOST_AUTO_TEST_CASE(subsidy_limit_test)
{
- uint64_t nSum = 0;
+ CAmount nSum = 0;
for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
- uint64_t nSubsidy = GetBlockValue(nHeight, 0);
+ CAmount nSubsidy = GetBlockValue(nHeight, 0);
BOOST_CHECK(nSubsidy <= 50 * COIN);
nSum += nSubsidy * 1000;
BOOST_CHECK(MoneyRange(nSum));
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index e077c9de3b..6378bd0941 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(util_FormatMoney)
BOOST_AUTO_TEST_CASE(util_ParseMoney)
{
- int64_t ret = 0;
+ CAmount ret = 0;
BOOST_CHECK(ParseMoney("0.0", ret));
BOOST_CHECK_EQUAL(ret, 0);
diff --git a/src/test/wallet_tests.cpp b/src/test/wallet_tests.cpp
index 3887efbd0d..90fc470e06 100644
--- a/src/test/wallet_tests.cpp
+++ b/src/test/wallet_tests.cpp
@@ -28,7 +28,7 @@ BOOST_AUTO_TEST_SUITE(wallet_tests)
static CWallet wallet;
static vector<COutput> vCoins;
-static void add_coin(int64_t nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0)
+static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0)
{
static int nextLockTime = 0;
CMutableTransaction tx;
@@ -66,7 +66,7 @@ static bool equal_sets(CoinSet a, CoinSet b)
BOOST_AUTO_TEST_CASE(coin_selection_tests)
{
CoinSet setCoinsRet, setCoinsRet2;
- int64_t nValueRet;
+ CAmount nValueRet;
LOCK(wallet.cs_wallet);
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 79838b6116..d5f424fabd 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -117,7 +117,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
stats.hashBlock = GetBestBlock();
ss << stats.hashBlock;
- int64_t nTotalAmount = 0;
+ CAmount nTotalAmount = 0;
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
try {
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 52d07bf6a0..d923c2204a 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -7,6 +7,7 @@
#include "core.h"
#include "util.h"
+#include "utilmoneystr.h"
#include <boost/circular_buffer.hpp>
@@ -18,7 +19,7 @@ CTxMemPoolEntry::CTxMemPoolEntry():
nHeight = MEMPOOL_HEIGHT;
}
-CTxMemPoolEntry::CTxMemPoolEntry(const CTransaction& _tx, int64_t _nFee,
+CTxMemPoolEntry::CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee,
int64_t _nTime, double _dPriority,
unsigned int _nHeight):
tx(_tx), nFee(_nFee), nTime(_nTime), dPriority(_dPriority), nHeight(_nHeight)
@@ -36,7 +37,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTxMemPoolEntry& other)
double
CTxMemPoolEntry::GetPriority(unsigned int currentHeight) const
{
- int64_t nValueIn = tx.GetValueOut()+nFee;
+ CAmount nValueIn = tx.GetValueOut()+nFee;
double deltaPriority = ((double)(currentHeight-nHeight)*nValueIn)/nModSize;
double dResult = dPriority + deltaPriority;
return dResult;
@@ -601,24 +602,24 @@ CTxMemPool::ReadFeeEstimates(CAutoFile& filein)
return true;
}
-void CTxMemPool::PrioritiseTransaction(const uint256 hash, const string strHash, double dPriorityDelta, int64_t nFeeDelta)
+void CTxMemPool::PrioritiseTransaction(const uint256 hash, const string strHash, double dPriorityDelta, const CAmount& nFeeDelta)
{
{
LOCK(cs);
- std::pair<double, int64_t> &deltas = mapDeltas[hash];
+ std::pair<double, CAmount> &deltas = mapDeltas[hash];
deltas.first += dPriorityDelta;
deltas.second += nFeeDelta;
}
- LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, nFeeDelta);
+ LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, FormatMoney(nFeeDelta));
}
-void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, int64_t &nFeeDelta)
+void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta)
{
LOCK(cs);
- std::map<uint256, std::pair<double, int64_t> >::iterator pos = mapDeltas.find(hash);
+ std::map<uint256, std::pair<double, CAmount> >::iterator pos = mapDeltas.find(hash);
if (pos == mapDeltas.end())
return;
- const std::pair<double, int64_t> &deltas = pos->second;
+ const std::pair<double, CAmount> &deltas = pos->second;
dPriorityDelta += deltas.first;
nFeeDelta += deltas.second;
}
diff --git a/src/txmempool.h b/src/txmempool.h
index b9d50ee0bc..c35ea52d4e 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -29,7 +29,7 @@ class CTxMemPoolEntry
{
private:
CTransaction tx;
- int64_t nFee; // Cached to avoid expensive parent-transaction lookups
+ CAmount nFee; // Cached to avoid expensive parent-transaction lookups
size_t nTxSize; // ... and avoid recomputing tx size
size_t nModSize; // ... and modified size for priority
int64_t nTime; // Local time when entering the mempool
@@ -37,14 +37,14 @@ private:
unsigned int nHeight; // Chain height when entering the mempool
public:
- CTxMemPoolEntry(const CTransaction& _tx, int64_t _nFee,
+ CTxMemPoolEntry(const CTransaction& _tx, const CAmount& _nFee,
int64_t _nTime, double _dPriority, unsigned int _nHeight);
CTxMemPoolEntry();
CTxMemPoolEntry(const CTxMemPoolEntry& other);
const CTransaction& GetTx() const { return this->tx; }
double GetPriority(unsigned int currentHeight) const;
- int64_t GetFee() const { return nFee; }
+ CAmount GetFee() const { return nFee; }
size_t GetTxSize() const { return nTxSize; }
int64_t GetTime() const { return nTime; }
unsigned int GetHeight() const { return nHeight; }
@@ -76,7 +76,7 @@ public:
mutable CCriticalSection cs;
std::map<uint256, CTxMemPoolEntry> mapTx;
std::map<COutPoint, CInPoint> mapNextTx;
- std::map<uint256, std::pair<double, int64_t> > mapDeltas;
+ std::map<uint256, std::pair<double, CAmount> > mapDeltas;
CTxMemPool(const CFeeRate& _minRelayFee);
~CTxMemPool();
@@ -102,8 +102,8 @@ public:
void AddTransactionsUpdated(unsigned int n);
/** Affect CreateNewBlock prioritisation of transactions */
- void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, int64_t nFeeDelta);
- void ApplyDeltas(const uint256 hash, double &dPriorityDelta, int64_t &nFeeDelta);
+ void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta);
+ void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta);
void ClearPrioritisation(const uint256 hash);
unsigned long size()
diff --git a/src/util.h b/src/util.h
index 4b2415278b..fb1d3eacb5 100644
--- a/src/util.h
+++ b/src/util.h
@@ -14,6 +14,7 @@
#include "config/bitcoin-config.h"
#endif
+#include "amount.h"
#include "compat.h"
#include "tinyformat.h"
#include "utiltime.h"
diff --git a/src/utilmoneystr.cpp b/src/utilmoneystr.cpp
index c169355f05..1a5635bfb8 100644
--- a/src/utilmoneystr.cpp
+++ b/src/utilmoneystr.cpp
@@ -10,7 +10,7 @@
using namespace std;
-string FormatMoney(int64_t n, bool fPlus)
+string FormatMoney(const CAmount& n, bool fPlus)
{
// Note: not using straight sprintf here because we do NOT want
// localized number formatting.
@@ -34,12 +34,12 @@ string FormatMoney(int64_t n, bool fPlus)
}
-bool ParseMoney(const string& str, int64_t& nRet)
+bool ParseMoney(const string& str, CAmount& nRet)
{
return ParseMoney(str.c_str(), nRet);
}
-bool ParseMoney(const char* pszIn, int64_t& nRet)
+bool ParseMoney(const char* pszIn, CAmount& nRet)
{
string strWhole;
int64_t nUnits = 0;
@@ -73,7 +73,7 @@ bool ParseMoney(const char* pszIn, int64_t& nRet)
if (nUnits < 0 || nUnits > COIN)
return false;
int64_t nWhole = atoi64(strWhole);
- int64_t nValue = nWhole*COIN + nUnits;
+ CAmount nValue = nWhole*COIN + nUnits;
nRet = nValue;
return true;
diff --git a/src/utilmoneystr.h b/src/utilmoneystr.h
index f0c61aa138..65415afd3f 100644
--- a/src/utilmoneystr.h
+++ b/src/utilmoneystr.h
@@ -12,8 +12,10 @@
#include <stdint.h>
#include <string>
-std::string FormatMoney(int64_t n, bool fPlus=false);
-bool ParseMoney(const std::string& str, int64_t& nRet);
-bool ParseMoney(const char* pszIn, int64_t& nRet);
+#include "amount.h"
+
+std::string FormatMoney(const CAmount& n, bool fPlus=false);
+bool ParseMoney(const std::string& str, CAmount& nRet);
+bool ParseMoney(const char* pszIn, CAmount& nRet);
#endif // BITCOIN_UTILMONEYSTR_H
diff --git a/src/wallet.cpp b/src/wallet.cpp
index e69f59aacd..b20b0007ce 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -35,8 +35,8 @@ CFeeRate CWallet::minTxFee = CFeeRate(10000); // Override with -mintxfee
struct CompareValueOnly
{
- bool operator()(const pair<int64_t, pair<const CWalletTx*, unsigned int> >& t1,
- const pair<int64_t, pair<const CWalletTx*, unsigned int> >& t2) const
+ bool operator()(const pair<CAmount, pair<const CWalletTx*, unsigned int> >& t1,
+ const pair<CAmount, pair<const CWalletTx*, unsigned int> >& t2) const
{
return t1.first < t2.first;
}
@@ -697,7 +697,7 @@ isminetype CWallet::IsMine(const CTxIn &txin) const
return ISMINE_NO;
}
-int64_t CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
+CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
{
{
LOCK(cs_wallet);
@@ -781,7 +781,7 @@ int CWalletTx::GetRequestCount() const
}
void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
- list<COutputEntry>& listSent, int64_t& nFee, string& strSentAccount, const isminefilter& filter) const
+ list<COutputEntry>& listSent, CAmount& nFee, string& strSentAccount, const isminefilter& filter) const
{
nFee = 0;
listReceived.clear();
@@ -789,10 +789,10 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
strSentAccount = strFromAccount;
// Compute fee:
- int64_t nDebit = GetDebit(filter);
+ CAmount nDebit = GetDebit(filter);
if (nDebit > 0) // debit>0 means we signed/sent this transaction
{
- int64_t nValueOut = GetValueOut();
+ CAmount nValueOut = GetValueOut();
nFee = nDebit - nValueOut;
}
@@ -835,12 +835,12 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
}
-void CWalletTx::GetAccountAmounts(const string& strAccount, int64_t& nReceived,
- int64_t& nSent, int64_t& nFee, const isminefilter& filter) const
+void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived,
+ CAmount& nSent, CAmount& nFee, const isminefilter& filter) const
{
nReceived = nSent = nFee = 0;
- int64_t allFee;
+ CAmount allFee;
string strSentAccount;
list<COutputEntry> listReceived;
list<COutputEntry> listSent;
@@ -1011,9 +1011,9 @@ void CWallet::ResendWalletTransactions()
//
-int64_t CWallet::GetBalance() const
+CAmount CWallet::GetBalance() const
{
- int64_t nTotal = 0;
+ CAmount nTotal = 0;
{
LOCK2(cs_main, cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
@@ -1027,9 +1027,9 @@ int64_t CWallet::GetBalance() const
return nTotal;
}
-int64_t CWallet::GetUnconfirmedBalance() const
+CAmount CWallet::GetUnconfirmedBalance() const
{
- int64_t nTotal = 0;
+ CAmount nTotal = 0;
{
LOCK2(cs_main, cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
@@ -1042,9 +1042,9 @@ int64_t CWallet::GetUnconfirmedBalance() const
return nTotal;
}
-int64_t CWallet::GetImmatureBalance() const
+CAmount CWallet::GetImmatureBalance() const
{
- int64_t nTotal = 0;
+ CAmount nTotal = 0;
{
LOCK2(cs_main, cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
@@ -1056,9 +1056,9 @@ int64_t CWallet::GetImmatureBalance() const
return nTotal;
}
-int64_t CWallet::GetWatchOnlyBalance() const
+CAmount CWallet::GetWatchOnlyBalance() const
{
- int64_t nTotal = 0;
+ CAmount nTotal = 0;
{
LOCK2(cs_main, cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
@@ -1072,9 +1072,9 @@ int64_t CWallet::GetWatchOnlyBalance() const
return nTotal;
}
-int64_t CWallet::GetUnconfirmedWatchOnlyBalance() const
+CAmount CWallet::GetUnconfirmedWatchOnlyBalance() const
{
- int64_t nTotal = 0;
+ CAmount nTotal = 0;
{
LOCK2(cs_main, cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
@@ -1087,9 +1087,9 @@ int64_t CWallet::GetUnconfirmedWatchOnlyBalance() const
return nTotal;
}
-int64_t CWallet::GetImmatureWatchOnlyBalance() const
+CAmount CWallet::GetImmatureWatchOnlyBalance() const
{
- int64_t nTotal = 0;
+ CAmount nTotal = 0;
{
LOCK2(cs_main, cs_wallet);
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
@@ -1137,8 +1137,8 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
}
}
-static void ApproximateBestSubset(vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > >vValue, int64_t nTotalLower, int64_t nTargetValue,
- vector<char>& vfBest, int64_t& nBest, int iterations = 1000)
+static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > >vValue, const CAmount& nTotalLower, const CAmount& nTargetValue,
+ vector<char>& vfBest, CAmount& nBest, int iterations = 1000)
{
vector<char> vfIncluded;
@@ -1150,7 +1150,7 @@ static void ApproximateBestSubset(vector<pair<int64_t, pair<const CWalletTx*,uns
for (int nRep = 0; nRep < iterations && nBest != nTargetValue; nRep++)
{
vfIncluded.assign(vValue.size(), false);
- int64_t nTotal = 0;
+ CAmount nTotal = 0;
bool fReachedTarget = false;
for (int nPass = 0; nPass < 2 && !fReachedTarget; nPass++)
{
@@ -1183,18 +1183,18 @@ static void ApproximateBestSubset(vector<pair<int64_t, pair<const CWalletTx*,uns
}
}
-bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,
- set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet) const
+bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,
+ set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const
{
setCoinsRet.clear();
nValueRet = 0;
// List of values less than target
- pair<int64_t, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
- coinLowestLarger.first = std::numeric_limits<int64_t>::max();
+ pair<CAmount, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
+ coinLowestLarger.first = std::numeric_limits<CAmount>::max();
coinLowestLarger.second.first = NULL;
- vector<pair<int64_t, pair<const CWalletTx*,unsigned int> > > vValue;
- int64_t nTotalLower = 0;
+ vector<pair<CAmount, pair<const CWalletTx*,unsigned int> > > vValue;
+ CAmount nTotalLower = 0;
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);
@@ -1209,9 +1209,9 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
continue;
int i = output.i;
- int64_t n = pcoin->vout[i].nValue;
+ CAmount n = pcoin->vout[i].nValue;
- pair<int64_t,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
+ pair<CAmount,pair<const CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin, i));
if (n == nTargetValue)
{
@@ -1252,7 +1252,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
// Solve subset sum by stochastic approximation
sort(vValue.rbegin(), vValue.rend(), CompareValueOnly());
vector<char> vfBest;
- int64_t nBest;
+ CAmount nBest;
ApproximateBestSubset(vValue, nTotalLower, nTargetValue, vfBest, nBest, 1000);
if (nBest != nTargetValue && nTotalLower >= nTargetValue + CENT)
@@ -1284,7 +1284,7 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, int nConfMine, int nConfT
return true;
}
-bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl) const
+bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl) const
{
vector<COutput> vCoins;
AvailableCoins(vCoins, true, coinControl);
@@ -1310,11 +1310,11 @@ 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, std::string& strFailReason, const CCoinControl* coinControl)
+bool CWallet::CreateTransaction(const vector<pair<CScript, CAmount> >& vecSend,
+ CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl)
{
- int64_t nValue = 0;
- BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
+ CAmount nValue = 0;
+ BOOST_FOREACH (const PAIRTYPE(CScript, CAmount)& s, vecSend)
{
if (nValue < 0)
{
@@ -1343,10 +1343,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
txNew.vout.clear();
wtxNew.fFromMe = true;
- int64_t nTotalValue = nValue + nFeeRet;
+ CAmount nTotalValue = nValue + nFeeRet;
double dPriority = 0;
// vouts to the payees
- BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
+ BOOST_FOREACH (const PAIRTYPE(CScript, CAmount)& s, vecSend)
{
CTxOut txout(s.second, s.first);
if (txout.IsDust(::minRelayTxFee))
@@ -1359,7 +1359,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
// Choose coins to use
set<pair<const CWalletTx*,unsigned int> > setCoins;
- int64_t nValueIn = 0;
+ CAmount nValueIn = 0;
if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl))
{
strFailReason = _("Insufficient funds");
@@ -1367,14 +1367,14 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
}
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
- int64_t nCredit = pcoin.first->vout[pcoin.second].nValue;
+ CAmount nCredit = pcoin.first->vout[pcoin.second].nValue;
//The priority after the next block (depth+1) is used instead of the current,
//reflecting an assumption the user would accept a bit more delay for
//a chance at a free transaction.
dPriority += (double)nCredit * (pcoin.first->GetDepthInMainChain()+1);
}
- int64_t nChange = nValueIn - nValue - nFeeRet;
+ CAmount nChange = nValueIn - nValue - nFeeRet;
if (nChange > 0)
{
@@ -1450,7 +1450,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
}
dPriority = wtxNew.ComputePriority(dPriority, nBytes);
- int64_t nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
+ CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
if (nFeeRet >= nFeeNeeded)
break; // Done, enough fee included.
@@ -1481,10 +1481,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
return true;
}
-bool CWallet::CreateTransaction(CScript scriptPubKey, int64_t nValue,
- CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl)
+bool CWallet::CreateTransaction(CScript scriptPubKey, const CAmount& nValue,
+ CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl)
{
- vector< pair<CScript, int64_t> > vecSend;
+ vector< pair<CScript, CAmount> > vecSend;
vecSend.push_back(make_pair(scriptPubKey, nValue));
return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, strFailReason, coinControl);
}
@@ -1539,7 +1539,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
-string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWalletTx& wtxNew)
+string CWallet::SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew)
{
// Check amount
if (nValue <= 0)
@@ -1560,7 +1560,7 @@ string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWallet
// Create and send the transaction
CReserveKey reservekey(this);
- int64_t nFeeRequired;
+ CAmount nFeeRequired;
if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError))
{
if (nValue + nFeeRequired > GetBalance())
@@ -1576,10 +1576,10 @@ string CWallet::SendMoney(const CTxDestination &address, int64_t nValue, CWallet
-int64_t CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
+CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool& pool)
{
// payTxFee is user-set "I want to pay this much"
- int64_t nFeeNeeded = payTxFee.GetFee(nTxBytes);
+ CAmount nFeeNeeded = payTxFee.GetFee(nTxBytes);
// User didn't set: use -txconfirmtarget to estimate...
if (nFeeNeeded == 0)
nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes);
@@ -1838,9 +1838,9 @@ int64_t CWallet::GetOldestKeyPoolTime()
return keypool.nTime;
}
-std::map<CTxDestination, int64_t> CWallet::GetAddressBalances()
+std::map<CTxDestination, CAmount> CWallet::GetAddressBalances()
{
- map<CTxDestination, int64_t> balances;
+ map<CTxDestination, CAmount> balances;
{
LOCK(cs_wallet);
@@ -1866,7 +1866,7 @@ std::map<CTxDestination, int64_t> CWallet::GetAddressBalances()
if(!ExtractDestination(pcoin->vout[i].scriptPubKey, addr))
continue;
- int64_t n = IsSpent(walletEntry.first, i) ? 0 : pcoin->vout[i].nValue;
+ CAmount n = IsSpent(walletEntry.first, i) ? 0 : pcoin->vout[i].nValue;
if (!balances.count(addr))
balances[addr] = 0;
diff --git a/src/wallet.h b/src/wallet.h
index fde87a8a2f..f3fffb2253 100644
--- a/src/wallet.h
+++ b/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;
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index a84f44db01..67218bf2c8 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -187,12 +187,12 @@ bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry)
return WriteAccountingEntry(++nAccountingEntryNumber, acentry);
}
-int64_t CWalletDB::GetAccountCreditDebit(const string& strAccount)
+CAmount CWalletDB::GetAccountCreditDebit(const string& strAccount)
{
list<CAccountingEntry> entries;
ListAccountCreditDebit(strAccount, entries);
- int64_t nCreditDebit = 0;
+ CAmount nCreditDebit = 0;
BOOST_FOREACH (const CAccountingEntry& entry, entries)
nCreditDebit += entry.nCreditDebit;
diff --git a/src/walletdb.h b/src/walletdb.h
index 2c5b608f3d..f3d6e61f8b 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -6,6 +6,7 @@
#ifndef BITCOIN_WALLETDB_H
#define BITCOIN_WALLETDB_H
+#include "amount.h"
#include "db.h"
#include "key.h"
#include "keystore.h"
@@ -118,7 +119,7 @@ public:
bool EraseDestData(const std::string &address, const std::string &key);
bool WriteAccountingEntry(const CAccountingEntry& acentry);
- int64_t GetAccountCreditDebit(const std::string& strAccount);
+ CAmount GetAccountCreditDebit(const std::string& strAccount);
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
DBErrors ReorderTransactions(CWallet* pwallet);