aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-06-06 18:50:32 +0200
committerWladimir J. van der Laan <[email protected]>2014-06-06 18:51:00 +0200
commit95d68c48d7ae45cb2a7303152816e9391cfbd0c9 (patch)
tree0a25f1f328ca66177c79afcf4422ea99d221f981 /src/wallet.cpp
parentMerge pull request #4297 (diff)
parentestimatefee / estimatepriority RPC methods (diff)
downloaddiscoin-95d68c48d7ae45cb2a7303152816e9391cfbd0c9.tar.xz
discoin-95d68c48d7ae45cb2a7303152816e9391cfbd0c9.zip
Merge pull request #3959
171ca77 estimatefee / estimatepriority RPC methods (Gavin Andresen) 0193fb8 Allow multiple regression tests to run at once (Gavin Andresen) c6cb21d Type-safe CFeeRate class (Gavin Andresen)
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 89604f96a..ef0b442e1 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -16,7 +16,7 @@
using namespace std;
// Settings
-int64_t nTransactionFee = DEFAULT_TRANSACTION_FEE;
+CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE);
bool bSpendZeroConfChange = true;
//////////////////////////////////////////////////////////////////////////////
@@ -1233,7 +1233,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
{
LOCK2(cs_main, cs_wallet);
{
- nFeeRet = nTransactionFee;
+ nFeeRet = payTxFee.GetFeePerK();
while (true)
{
wtxNew.vin.clear();
@@ -1246,7 +1246,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
BOOST_FOREACH (const PAIRTYPE(CScript, int64_t)& s, vecSend)
{
CTxOut txout(s.second, s.first);
- if (txout.IsDust(CTransaction::nMinRelayTxFee))
+ if (txout.IsDust(CTransaction::minRelayTxFee))
{
strFailReason = _("Transaction amount too small");
return false;
@@ -1272,16 +1272,6 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
}
int64_t nChange = nValueIn - nValue - nFeeRet;
- // The following if statement should be removed once enough miners
- // have upgraded to the 0.9 GetMinFee() rules. Until then, this avoids
- // creating free transactions that have change outputs less than
- // CENT bitcoins.
- if (nFeeRet < CTransaction::nMinTxFee && nChange > 0 && nChange < CENT)
- {
- int64_t nMoveToFee = min(nChange, CTransaction::nMinTxFee - nFeeRet);
- nChange -= nMoveToFee;
- nFeeRet += nMoveToFee;
- }
if (nChange > 0)
{
@@ -1317,7 +1307,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
// Never create dust outputs; if we would, just
// add the dust to the fee.
- if (newTxOut.IsDust(CTransaction::nMinRelayTxFee))
+ if (newTxOut.IsDust(CTransaction::minRelayTxFee))
{
nFeeRet += nChange;
reservekey.ReturnKey();
@@ -1355,7 +1345,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
dPriority = wtxNew.ComputePriority(dPriority, nBytes);
// Check that enough fee is included
- int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
+ int64_t nPayFee = payTxFee.GetFee(nBytes);
bool fAllowFree = AllowFree(dPriority);
int64_t nMinFee = GetMinFee(wtxNew, nBytes, fAllowFree, GMF_SEND);
if (nFeeRet < max(nPayFee, nMinFee))
@@ -1464,7 +1454,7 @@ string CWallet::SendMoneyToDestination(const CTxDestination& address, int64_t nV
// Check amount
if (nValue <= 0)
return _("Invalid amount");
- if (nValue + nTransactionFee > GetBalance())
+ if (nValue > GetBalance())
return _("Insufficient funds");
// Parse Bitcoin address