From 50c7b7bccd85b440caec734cc2cca4a40fa8496b Mon Sep 17 00:00:00 2001 From: MASM fan Date: Sun, 11 Jan 2015 06:49:02 -0800 Subject: [PATCH] Remove legacy code and timestamps. --- src/main.cpp | 57 +++++++++++++++-------------------------- src/qt/coincontroldialog.cpp | 36 +++---------------------- src/rpcblockchain.cpp | 2 +- src/timestamps.h | 2 - src/wallet.cpp | 29 +-------------------- 5 files changed, 28 insertions(+), 98 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1b435d5..473e5bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -551,13 +551,9 @@ bool CTransaction::CheckTransaction() const int64_t CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum GetMinFee_mode mode, unsigned int nBytes) const { - // Use new fees approach if we are on test network or - // switch date has been reached - bool fNewApproach = fTestNet || nTime > FEE_SWITCH_TIME; - int64_t nMinTxFee = MIN_TX_FEE, nMinRelayTxFee = MIN_RELAY_TX_FEE; - if(!fNewApproach || IsCoinStake()) + if(IsCoinStake()) { // Enforce 0.01 as minimum fee for old approach or coinstake nMinTxFee = CENT; @@ -570,42 +566,31 @@ int64_t CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum G unsigned int nNewBlockSize = nBlockSize + nBytes; int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee; - if (fNewApproach) + if (fAllowFree) { - if (fAllowFree) + if (nBlockSize == 1) { - if (nBlockSize == 1) - { - // Transactions under 1K are free - if (nBytes < 1000) - nMinFee = 0; - } - else - { - // Free transaction area - if (nNewBlockSize < 27000) - nMinFee = 0; - } + // Transactions under 1K are free + if (nBytes < 1000) + nMinFee = 0; + } + else + { + // Free transaction area + if (nNewBlockSize < 27000) + nMinFee = 0; } - - // To limit dust spam, require additional MIN_TX_FEE/MIN_RELAY_TX_FEE for - // each non empty output which is less than 0.01 - // - // It's safe to ignore empty outputs here, because these inputs are allowed - // only for coinbase and coinstake transactions. - BOOST_FOREACH(const CTxOut& txout, vout) - if (txout.nValue < CENT && !txout.IsEmpty()) - nMinFee += nBaseFee; - } - else if (nMinFee < nBaseFee) - { - // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if - // any output is less than 0.01 - BOOST_FOREACH(const CTxOut& txout, vout) - if (txout.nValue < CENT) - nMinFee = nBaseFee; } + // To limit dust spam, require additional MIN_TX_FEE/MIN_RELAY_TX_FEE for + // each non empty output which is less than 0.01 + // + // It's safe to ignore empty outputs here, because these inputs are allowed + // only for coinbase and coinstake transactions. + BOOST_FOREACH(const CTxOut& txout, vout) + if (txout.nValue < CENT && !txout.IsEmpty()) + nMinFee += nBaseFee; + // Raise the price as the block approaches full if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2) { diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index fc50c95..f5a8c6a 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -491,19 +491,11 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) // Priority dPriority = dPriorityInputs / nBytes; sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority); + bool fAllowFree = CTransaction::AllowFree(dPriority); // Fee int64_t nFee = nTransactionFee * (1 + (int64_t)nBytes / 1000); - // Min Fee - bool fAllowFree = CTransaction::AllowFree(dPriority); - - // Disable free transactions until 1 July 2014 - if (!fTestNet && txDummy.nTime < FEE_SWITCH_TIME) - { - fAllowFree = false; - } - int64_t nMinFee = txDummy.GetMinFee(1, fAllowFree, GMF_SEND, nBytes); nPayFee = max(nFee, nMinFee); @@ -512,24 +504,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) { nChange = nAmount - nPayFee - nPayAmount; - // if sub-cent change is required, the fee must be raised to at least CTransaction::nMinTxFee - if (txDummy.nTime < FEE_SWITCH_TIME && !fTestNet) - { - if (nPayFee < CENT && nChange > 0 && nChange < CENT) - { - if (nChange < CENT) // change < 0.01 => simply move all change to fees - { - nPayFee = nChange; - nChange = 0; - } - else - { - nChange = nChange + nPayFee - CENT; - nPayFee = CENT; - } - } - } - if (nChange == 0) nBytes -= 34; } @@ -577,10 +551,10 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) l8->setStyleSheet((nChange > 0 && nChange < CENT) ? "color:red;" : ""); // Change < 0.01BTC // tool tips - l5->setToolTip(tr("This label turns red, if the transaction size is bigger than 1000 bytes.\n\n This means a fee of at least %1 per kb is required.\n\n Can vary +/- 1 Byte per input.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, fTestNet || FEE_SWITCH_TIME < GetTime() ? MIN_TX_FEE : CENT))); - l6->setToolTip(tr("Transactions with higher priority get more likely into a block.\n\nThis label turns red, if the priority is smaller than \"medium\".\n\n This means a fee of at least %1 per kb is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, fTestNet || FEE_SWITCH_TIME < GetTime() ? MIN_TX_FEE : CENT))); - l7->setToolTip(tr("This label turns red, if any recipient receives an amount smaller than %1.\n\n This means a fee of at least %2 is required. \n\n Amounts below the minimum fee are shown as DUST.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, fTestNet || FEE_SWITCH_TIME < GetTime() ? MIN_RELAY_TX_FEE : CENT))); - l8->setToolTip(tr("This label turns red, if the change is smaller than %1.\n\n This means a fee of at least %2 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, fTestNet || FEE_SWITCH_TIME < GetTime() ? MIN_TX_FEE : CENT))); + l5->setToolTip(tr("This label turns red, if the transaction size is bigger than 1000 bytes.\n\n This means a fee of at least %1 per kb is required.\n\n Can vary +/- 1 Byte per input.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, MIN_TX_FEE))); + l6->setToolTip(tr("Transactions with higher priority get more likely into a block.\n\nThis label turns red, if the priority is smaller than \"medium\".\n\n This means a fee of at least %1 per kb is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, MIN_TX_FEE))); + l7->setToolTip(tr("This label turns red, if any recipient receives an amount smaller than %1.\n\n This means a fee of at least %2 is required. \n\n Amounts below the minimum fee are shown as DUST.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, MIN_RELAY_TX_FEE))); + l8->setToolTip(tr("This label turns red, if the change is smaller than %1.\n\n This means a fee of at least %2 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, MIN_TX_FEE))); dialog->findChild("labelCoinControlBytesText") ->setToolTip(l5->toolTip()); dialog->findChild("labelCoinControlPriorityText") ->setToolTip(l6->toolTip()); dialog->findChild("labelCoinControlLowOutputText")->setToolTip(l7->toolTip()); diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index be92a59..3414a00 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -140,7 +140,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri result.push_back(Pair("tx", txinfo)); - if ( block.IsProofOfStake() || (!fTestNet && block.GetBlockTime() < ENTROPY_SWITCH_TIME) ) + if ( block.IsProofOfStake() ) result.push_back(Pair("signature", HexStr(block.vchBlockSig.begin(), block.vchBlockSig.end()))); return result; diff --git a/src/timestamps.h b/src/timestamps.h index 027f220..4fbd7e4 100644 --- a/src/timestamps.h +++ b/src/timestamps.h @@ -1,12 +1,10 @@ #ifndef BITCOIN_TIMESTAMPS_H #define BITCOIN_TIMESTAMPS_H -static const unsigned int ENTROPY_SWITCH_TIME = 1362791041; // Sat, 09 Mar 2013 01:04:01 GMT static const unsigned int STAKE_SWITCH_TIME = 1371686400; // Thu, 20 Jun 2013 00:00:00 GMT static const unsigned int TARGETS_SWITCH_TIME = 1374278400; // Sat, 20 Jul 2013 00:00:00 GMT static const unsigned int CHAINCHECKS_SWITCH_TIME = 1379635200; // Fri, 20 Sep 2013 00:00:00 GMT static const unsigned int STAKECURVE_SWITCH_TIME = 1382227200; // Sun, 20 Oct 2013 00:00:00 GMT -static const unsigned int FEE_SWITCH_TIME = 1405814400; // Sun, 20 Jul 2014 00:00:00 GMT static const unsigned int VALIDATION_SWITCH_TIME = 1408492800; // Wed, 20 Aug 2014 00:00:00 GMT static const unsigned int SIG_SWITCH_TIME = 1411171200; // Sat, 20 Sep 2014 00:00:00 GMT diff --git a/src/wallet.cpp b/src/wallet.cpp index a0214fa..9972627 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1542,26 +1542,6 @@ bool CWallet::CreateTransaction(const vector >& vecSend, } int64_t nChange = nValueIn - nValue - nFeeRet; - // if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE - // or until nChange becomes zero - // NOTE: this depends on the exact behaviour of GetMinFee - if (wtxNew.nTime < FEE_SWITCH_TIME && !fTestNet) - { - if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT) - { - int64_t nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet); - nChange -= nMoveToFee; - nFeeRet += nMoveToFee; - } - - // sub-cent change is moved to fee - if (nChange > 0 && nChange < CENT) - { - nFeeRet += nChange; - nChange = 0; - } - } - if (nChange > 0) { // Fill a vout to ourself @@ -1613,15 +1593,8 @@ bool CWallet::CreateTransaction(const vector >& vecSend, dPriority /= nBytes; // Check that enough fee is included - int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000); bool fAllowFree = CTransaction::AllowFree(dPriority); - - // Disable free transactions until 1 July 2014 - if (!fTestNet && wtxNew.nTime < FEE_SWITCH_TIME) - { - fAllowFree = false; - } - + int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000); int64_t nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND, nBytes); if (nFeeRet < max(nPayFee, nMinFee)) -- 1.7.1