Browse Source

Use a typedef for monetary values

pull/1/head
Mark Friedenbach 9 years ago committed by Mark Friedenbach
parent
commit
a372168e77
  1. 1
      src/Makefile.am
  2. 13
      src/amount.h
  3. 4
      src/bitcoin-tx.cpp
  4. 4
      src/coins.cpp
  5. 4
      src/coins.h
  6. 12
      src/core.cpp
  7. 21
      src/core.h
  8. 6
      src/init.cpp
  9. 26
      src/main.cpp
  10. 6
      src/main.h
  11. 10
      src/miner.cpp
  12. 28
      src/qt/bitcoinamountfield.cpp
  13. 10
      src/qt/bitcoinamountfield.h
  14. 2
      src/qt/bitcoingui.cpp
  15. 4
      src/qt/bitcoingui.h
  16. 13
      src/qt/bitcoinunits.cpp
  17. 12
      src/qt/bitcoinunits.h
  18. 16
      src/qt/coincontroldialog.cpp
  19. 4
      src/qt/coincontroldialog.h
  20. 2
      src/qt/guiutil.cpp
  21. 4
      src/qt/guiutil.h
  22. 4
      src/qt/optionsmodel.cpp
  23. 4
      src/qt/optionsmodel.h
  24. 4
      src/qt/overviewpage.cpp
  25. 18
      src/qt/overviewpage.h
  26. 4
      src/qt/paymentrequestplus.cpp
  27. 2
      src/qt/paymentrequestplus.h
  28. 4
      src/qt/paymentserver.cpp
  29. 10
      src/qt/sendcoinsdialog.cpp
  30. 4
      src/qt/sendcoinsdialog.h
  31. 14
      src/qt/transactiondesc.cpp
  32. 2
      src/qt/transactionfilterproxy.cpp
  33. 6
      src/qt/transactionfilterproxy.h
  34. 12
      src/qt/transactionrecord.cpp
  35. 7
      src/qt/transactionrecord.h
  36. 4
      src/qt/transactiontablemodel.cpp
  37. 2
      src/qt/transactionview.cpp
  38. 40
      src/qt/walletmodel.cpp
  39. 32
      src/qt/walletmodel.h
  40. 8
      src/qt/walletmodeltransaction.cpp
  41. 8
      src/qt/walletmodeltransaction.h
  42. 2
      src/qt/walletview.cpp
  43. 4
      src/qt/walletview.h
  44. 2
      src/rpcmining.cpp
  45. 4
      src/rpcrawtransaction.cpp
  46. 6
      src/rpcserver.cpp
  47. 5
      src/rpcserver.h
  48. 62
      src/rpcwallet.cpp
  49. 4
      src/test/accounting_tests.cpp
  50. 4
      src/test/main_tests.cpp
  51. 2
      src/test/util_tests.cpp
  52. 4
      src/test/wallet_tests.cpp
  53. 2
      src/txdb.cpp
  54. 17
      src/txmempool.cpp
  55. 12
      src/txmempool.h
  56. 1
      src/util.h
  57. 8
      src/utilmoneystr.cpp
  58. 8
      src/utilmoneystr.h
  59. 108
      src/wallet.cpp
  60. 100
      src/wallet.h
  61. 4
      src/walletdb.cpp
  62. 3
      src/walletdb.h

1
src/Makefile.am

@ -65,6 +65,7 @@ BITCOIN_CORE_H = \ @@ -65,6 +65,7 @@ BITCOIN_CORE_H = \
addrman.h \
alert.h \
allocators.h \
amount.h \
base58.h \
bloom.h \
chainparams.h \

13
src/amount.h

@ -0,0 +1,13 @@ @@ -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

4
src/bitcoin-tx.cpp

@ -214,7 +214,7 @@ static void MutateTxAddOutAddr(CMutableTransaction& tx, const string& strInput) @@ -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 @@ -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");

4
src/coins.cpp

@ -171,12 +171,12 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const @@ -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;

4
src/coins.h

@ -266,7 +266,7 @@ struct CCoinsStats @@ -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: @@ -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;

12
src/core.cpp

@ -43,7 +43,7 @@ std::string CTxIn::ToString() const @@ -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 @@ -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) @@ -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) { @@ -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;

21
src/core.h

@ -6,6 +6,7 @@ @@ -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; @@ -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: @@ -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: @@ -161,7 +162,7 @@ public:
class CTxOut
{
public:
int64_t nValue;
CAmount nValue;
CScript scriptPubKey;
CTxOut()
@ -169,7 +170,7 @@ public: @@ -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: @@ -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.

6
src/init.cpp

@ -662,7 +662,7 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -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) @@ -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) @@ -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)

26
src/main.cpp

@ -781,7 +781,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) @@ -781,7 +781,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)
@ -823,19 +823,19 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) @@ -823,19 +823,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)
{
@ -898,7 +898,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa @@ -898,7 +898,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);
@ -950,15 +950,15 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa @@ -950,15 +950,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),
@ -1178,7 +1178,7 @@ void static PruneOrphanBlocks() @@ -1178,7 +1178,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();
@ -1389,8 +1389,8 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi @@ -1389,8 +1389,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;
@ -1418,7 +1418,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi @@ -1418,7 +1418,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");
@ -1658,7 +1658,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C @@ -1658,7 +1658,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()));

6
src/main.h

@ -172,7 +172,7 @@ std::string GetWarnings(std::string strFor); @@ -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);
@ -260,7 +260,7 @@ struct CDiskTxPos : public CDiskBlockPos @@ -260,7 +260,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
@ -970,7 +970,7 @@ extern CBlockTreeDB *pblocktree; @@ -970,7 +970,7 @@ extern CBlockTreeDB *pblocktree;
struct CBlockTemplate
{
CBlock block;
std::vector<int64_t> vTxFees;
std::vector<CAmount> vTxFees;
std::vector<int64_t> vTxSigOps;
};

10
src/miner.cpp

@ -111,7 +111,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)

28
src/qt/bitcoinamountfield.cpp

@ -44,7 +44,7 @@ public: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -102,7 +102,7 @@ public:
clear();
}
void setSingleStep(qint64 step)
void setSingleStep(const CAmount& step)
{
singleStep = step;
}
@ -140,7 +140,7 @@ public: @@ -140,7 +140,7 @@ public:
}
private:
int currentUnit;
qint64 singleStep;
CAmount singleStep;
mutable QSize cachedMinimumSizeHint;
/**
@ -148,9 +148,9 @@ private: @@ -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) @@ -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) @@ -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);
}

10
src/qt/bitcoinamountfield.h

@ -5,6 +5,8 @@ @@ -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 @@ -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);

2
src/qt/bitcoingui.cpp

@ -864,7 +864,7 @@ void BitcoinGUI::closeEvent(QCloseEvent *event) @@ -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"),

4
src/qt/bitcoingui.h

@ -9,6 +9,8 @@ @@ -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: @@ -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:

13
src/qt/bitcoinunits.cpp

@ -91,12 +91,13 @@ int BitcoinUnits::decimals(int unit) @@ -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 @@ -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, @@ -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) @@ -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 @@ -226,7 +227,7 @@ QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
return QVariant();
}
qint64 BitcoinUnits::maxMoney()
CAmount BitcoinUnits::maxMoney()
{
return MAX_MONEY;
}

12
src/qt/bitcoinunits.h

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
#ifndef BITCOINUNITS_H
#define BITCOINUNITS_H
#include "amount.h"
#include <QAbstractListModel>
#include <QString>
@ -85,12 +87,12 @@ public: @@ -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: @@ -117,7 +119,7 @@ public:
}
//! Return maximum number of base units (Satoshis)
static qint64 maxMoney();
static CAmount maxMoney();
private:
QList<BitcoinUnits::Unit> unitlist;

16
src/qt/coincontroldialog.cpp

@ -29,7 +29,7 @@ @@ -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) @@ -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) @@ -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() @@ -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;

4
src/qt/coincontroldialog.h

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
#ifndef COINCONTROLDIALOG_H
#define COINCONTROLDIALOG_H
#include "amount.h"
#include <QAbstractButton>
#include <QAction>
#include <QDialog>
@ -37,7 +39,7 @@ public: @@ -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:

2
src/qt/guiutil.cpp

@ -221,7 +221,7 @@ QString formatBitcoinURI(const SendCoinsRecipient &info) @@ -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);

4
src/qt/guiutil.h

@ -5,6 +5,8 @@ @@ -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 @@ -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);

4
src/qt/optionsmodel.cpp

@ -275,9 +275,9 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in @@ -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;
}

4
src/qt/optionsmodel.h

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
#ifndef OPTIONSMODEL_H
#define OPTIONSMODEL_H
#include "amount.h"
#include <QAbstractListModel>
QT_BEGIN_NAMESPACE
@ -82,7 +84,7 @@ private: @@ -82,7 +84,7 @@ private:
signals:
void displayUnitChanged(int unit);
void transactionFeeChanged(qint64);
void transactionFeeChanged(const CAmount&);
void coinControlFeaturesChanged(bool);
};

4
src/qt/overviewpage.cpp

@ -146,7 +146,7 @@ OverviewPage::~OverviewPage() @@ -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) @@ -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(const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&)), this, SLOT(setBalance(const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));

18
src/qt/overviewpage.h

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
#ifndef OVERVIEWPAGE_H
#define OVERVIEWPAGE_H
#include "amount.h"
#include <QWidget>
class ClientModel;
@ -34,8 +36,8 @@ public: @@ -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: @@ -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;

4
src/qt/paymentrequestplus.cpp

@ -196,9 +196,9 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c @@ -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();

2
src/qt/paymentrequestplus.h

@ -33,7 +33,7 @@ public: @@ -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; }

4
src/qt/paymentserver.cpp

@ -532,10 +532,10 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins @@ -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)) {

10
src/qt/sendcoinsdialog.cpp

@ -92,7 +92,7 @@ void SendCoinsDialog::setModel(WalletModel *model) @@ -92,7 +92,7 @@ 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(const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&)), this, SLOT(setBalance(const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&, const CAmount&)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
// Coin Control
@ -203,7 +203,7 @@ void SendCoinsDialog::on_sendButton_clicked() @@ -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() @@ -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) @@ -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);

4
src/qt/sendcoinsdialog.h

@ -47,8 +47,8 @@ public slots: @@ -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;

14
src/qt/transactiondesc.cpp

@ -56,9 +56,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco @@ -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 @@ -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 @@ -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>";
}

2
src/qt/transactionfilterproxy.cpp

@ -78,7 +78,7 @@ void TransactionFilterProxy::setTypeFilter(quint32 modes) @@ -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();

6
src/qt/transactionfilterproxy.h

@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
#ifndef TRANSACTIONFILTERPROXY_H
#define TRANSACTIONFILTERPROXY_H
#include "amount.h"
#include <QDateTime>
#include <QSortFilterProxyModel>
@ -38,7 +40,7 @@ public: @@ -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: @@ -58,7 +60,7 @@ private:
QString addrPrefix;
quint32 typeFilter;
WatchOnlyFilter watchOnlyFilter;
qint64 minAmount;
CAmount minAmount;
int limitRows;
bool showInactive;
};

12
src/qt/transactionrecord.cpp

@ -32,9 +32,9 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet * @@ -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 * @@ -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 * @@ -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 * @@ -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)
{

7
src/qt/transactionrecord.h

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
#ifndef TRANSACTIONRECORD_H
#define TRANSACTIONRECORD_H
#include "amount.h"
#include "uint256.h"
#include <QList>
@ -94,7 +95,7 @@ public: @@ -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: @@ -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 */

4
src/qt/transactiontablemodel.cpp

@ -546,7 +546,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const @@ -546,7 +546,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case ToAddress:
return formatTxToAddress(rec, true);
case Amount: