diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/compat/glibcxx_compat.cpp | 94 | ||||
-rw-r--r-- | src/key.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 22 | ||||
-rw-r--r-- | src/net.h | 3 | ||||
-rw-r--r-- | src/pubkey.cpp | 33 | ||||
-rw-r--r-- | src/qt/bitcoingui.cpp | 10 | ||||
-rw-r--r-- | src/qt/bitcoingui.h | 2 | ||||
-rw-r--r-- | src/qt/clientmodel.cpp | 11 | ||||
-rw-r--r-- | src/qt/clientmodel.h | 3 | ||||
-rw-r--r-- | src/qt/forms/sendcoinsdialog.ui | 20 | ||||
-rw-r--r-- | src/qt/optionsdialog.cpp | 2 | ||||
-rw-r--r-- | src/qt/utilitydialog.cpp | 2 | ||||
-rw-r--r-- | src/random.cpp | 7 | ||||
-rw-r--r-- | src/rpcwallet.cpp | 27 |
15 files changed, 44 insertions, 199 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7644f6b325..e1d467ff85 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -280,7 +280,6 @@ libbitcoin_util_a_SOURCES = \ if GLIBC_BACK_COMPAT libbitcoin_util_a_SOURCES += compat/glibc_compat.cpp -libbitcoin_util_a_SOURCES += compat/glibcxx_compat.cpp endif # cli: shared between bitcoin-cli and bitcoin-qt @@ -372,16 +371,12 @@ libbitcoinconsensus_la_SOURCES = \ if GLIBC_BACK_COMPAT libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp - libbitcoinconsensus_la_SOURCES += compat/glibcxx_compat.cpp endif libbitcoinconsensus_la_LDFLAGS = -no-undefined $(RELDFLAGS) libbitcoinconsensus_la_LIBADD = $(CRYPTO_LIBS) libbitcoinconsensus_la_CPPFLAGS = $(CRYPTO_CFLAGS) -I$(builddir)/obj -DBUILD_BITCOIN_INTERNAL -if USE_LIBSECP256K1 -libbitcoinconsensus_la_LIBADD += secp256k1/libsecp256k1.la -endif endif # diff --git a/src/compat/glibcxx_compat.cpp b/src/compat/glibcxx_compat.cpp deleted file mode 100644 index 4f2771e57a..0000000000 --- a/src/compat/glibcxx_compat.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2009-2014 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include <cstddef> -#include <istream> -#include <stdexcept> -#include <typeinfo> - -#ifndef _GLIBCXX_USE_NOEXCEPT -#define _GLIBCXX_USE_NOEXCEPT throw() -#endif - -namespace std -{ -const char* bad_exception::what() const throw() -{ - return "std::bad_exception"; -} - -const char* bad_cast::what() const throw() -{ - return "std::bad_cast"; -} - -const char* bad_alloc::what() const throw() -{ - return "std::bad_alloc"; -} - -namespace __detail -{ -struct _List_node_base { - void _M_hook(std::__detail::_List_node_base* const __position) throw() __attribute__((used)) - { - _M_next = __position; - _M_prev = __position->_M_prev; - __position->_M_prev->_M_next = this; - __position->_M_prev = this; - } - - void _M_unhook() __attribute__((used)) - { - _List_node_base* const __next_node = _M_next; - _List_node_base* const __prev_node = _M_prev; - __prev_node->_M_next = __next_node; - __next_node->_M_prev = __prev_node; - } - - _List_node_base* _M_next; - _List_node_base* _M_prev; -}; -} // namespace detail - -template ostream& ostream::_M_insert(bool); -template ostream& ostream::_M_insert(long); -template ostream& ostream::_M_insert(double); -template ostream& ostream::_M_insert(unsigned long); -template ostream& ostream::_M_insert(const void*); -template ostream& __ostream_insert(ostream&, const char*, streamsize); -template istream& istream::_M_extract(long&); -template istream& istream::_M_extract(unsigned short&); - -out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT {} - -length_error::~length_error() _GLIBCXX_USE_NOEXCEPT {} - -// Used with permission. -// See: https://github.com/madlib/madlib/commit/c3db418c0d34d6813608f2137fef1012ce03043d - -void ctype<char>::_M_widen_init() const -{ - char __tmp[sizeof(_M_widen)]; - for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i) - __tmp[__i] = __i; - do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen); - - _M_widen_ok = 1; - // Set _M_widen_ok to 2 if memcpy can't be used. - for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i) - if (__tmp[__i] != _M_widen[__i]) { - _M_widen_ok = 2; - break; - } -} - -void __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__)); -void __throw_out_of_range_fmt(const char* err, ...) -{ - // Safe and over-simplified version. Ignore the format and print it as-is. - __throw_out_of_range(err); -} - -} // namespace std diff --git a/src/key.cpp b/src/key.cpp index d8319db1a3..64c9bc7119 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -208,11 +208,9 @@ void CExtKey::Decode(const unsigned char code[74]) { } bool ECC_InitSanityCheck() { -#if !defined(USE_SECP256K1) if (!CECKey::SanityCheck()) { return false; } -#endif CKey key; key.MakeNewKey(true); CPubKey pubkey = key.GetPubKey(); diff --git a/src/main.cpp b/src/main.cpp index 34b4c51d5f..b6a61f7da1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3355,19 +3355,17 @@ void static ProcessGetData(CNode* pfrom) BlockMap::iterator mi = mapBlockIndex.find(inv.hash); if (mi != mapBlockIndex.end()) { - // If the requested block is at a height below our last - // checkpoint, only serve it if it's in the checkpointed chain - int nHeight = mi->second->nHeight; - CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(); - if (pcheckpoint && nHeight < pcheckpoint->nHeight) { - if (!chainActive.Contains(mi->second)) - { - LogPrintf("ProcessGetData(): ignoring request for old block that isn't in the main chain\n"); - } else { - send = true; - } - } else { + if (chainActive.Contains(mi->second)) { send = true; + } else { + // To prevent fingerprinting attacks, only send blocks outside of the active + // chain if they are valid, and no more than a month older than the best header + // chain we know about. + send = mi->second->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != NULL) && + (mi->second->GetBlockTime() > pindexBestHeader->GetBlockTime() - 30 * 24 * 60 * 60); + if (!send) { + LogPrintf("ProcessGetData(): ignoring request from peer=%i for old block that isn't in the main chain\n", pfrom->GetId()); + } } } if (send) @@ -570,9 +570,6 @@ public: } } - bool IsSubscribed(unsigned int nChannel); - void Subscribe(unsigned int nChannel, unsigned int nHops=0); - void CancelSubscribe(unsigned int nChannel); void CloseSocketDisconnect(); // Denial-of-service detection/prevention diff --git a/src/pubkey.cpp b/src/pubkey.cpp index 3ae67ca5fe..a4c046bff5 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -6,25 +6,16 @@ #include "eccryptoverify.h" -#ifdef USE_SECP256K1 -#include <secp256k1.h> -#else #include "ecwrapper.h" -#endif bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const { if (!IsValid()) return false; -#ifdef USE_SECP256K1 - if (secp256k1_ecdsa_verify((const unsigned char*)&hash, &vchSig[0], vchSig.size(), begin(), size()) != 1) - return false; -#else CECKey key; if (!key.SetPubKey(begin(), size())) return false; if (!key.Verify(hash, vchSig)) return false; -#endif return true; } @@ -33,52 +24,33 @@ bool CPubKey::RecoverCompact(const uint256 &hash, const std::vector<unsigned cha return false; int recid = (vchSig[0] - 27) & 3; bool fComp = ((vchSig[0] - 27) & 4) != 0; -#ifdef USE_SECP256K1 - int pubkeylen = 65; - if (!secp256k1_ecdsa_recover_compact((const unsigned char*)&hash, &vchSig[1], (unsigned char*)begin(), &pubkeylen, fComp, recid)) - return false; - assert((int)size() == pubkeylen); -#else CECKey key; if (!key.Recover(hash, &vchSig[1], recid)) return false; std::vector<unsigned char> pubkey; key.GetPubKey(pubkey, fComp); Set(pubkey.begin(), pubkey.end()); -#endif return true; } bool CPubKey::IsFullyValid() const { if (!IsValid()) return false; -#ifdef USE_SECP256K1 - if (!secp256k1_ecdsa_pubkey_verify(begin(), size())) - return false; -#else CECKey key; if (!key.SetPubKey(begin(), size())) return false; -#endif return true; } bool CPubKey::Decompress() { if (!IsValid()) return false; -#ifdef USE_SECP256K1 - int clen = size(); - int ret = secp256k1_ecdsa_pubkey_decompress((unsigned char*)begin(), &clen); - assert(ret); - assert(clen == (int)size()); -#else CECKey key; if (!key.SetPubKey(begin(), size())) return false; std::vector<unsigned char> pubkey; key.GetPubKey(pubkey, false); Set(pubkey.begin(), pubkey.end()); -#endif return true; } @@ -89,17 +61,12 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, unsigned char ccChild[32], unsigned i unsigned char out[64]; BIP32Hash(cc, nChild, *begin(), begin()+1, out); memcpy(ccChild, out+32, 32); -#ifdef USE_SECP256K1 - pubkeyChild = *this; - bool ret = secp256k1_ecdsa_pubkey_tweak_add((unsigned char*)pubkeyChild.begin(), pubkeyChild.size(), out); -#else CECKey key; bool ret = key.SetPubKey(begin(), size()); ret &= key.TweakPublic(out); std::vector<unsigned char> pubkey; key.GetPubKey(pubkey, true); pubkeyChild.Set(pubkey.begin(), pubkey.end()); -#endif return ret; } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 09f784387e..a0dcb46e27 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -151,7 +151,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) : // Create actions for the toolbar, menu bar and tray/dock icon // Needs walletFrame to be initialized - createActions(networkStyle); + createActions(); // Create application menu bar createMenuBar(); @@ -243,7 +243,7 @@ BitcoinGUI::~BitcoinGUI() delete rpcConsole; } -void BitcoinGUI::createActions(const NetworkStyle *networkStyle) +void BitcoinGUI::createActions() { QActionGroup *tabGroup = new QActionGroup(this); @@ -682,7 +682,7 @@ void BitcoinGUI::setNumBlocks(int count) QDateTime lastBlockDate = clientModel->getLastBlockDate(); QDateTime currentDate = QDateTime::currentDateTime(); - int secs = lastBlockDate.secsTo(currentDate); + qint64 secs = lastBlockDate.secsTo(currentDate); tooltip = tr("Processed %n blocks of transaction history.", "", count); @@ -722,8 +722,8 @@ void BitcoinGUI::setNumBlocks(int count) } else { - int years = secs / YEAR_IN_SECONDS; - int remainder = secs % YEAR_IN_SECONDS; + qint64 years = secs / YEAR_IN_SECONDS; + qint64 remainder = secs % YEAR_IN_SECONDS; timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS)); } diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 3216a7398e..fd776d63f8 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -118,7 +118,7 @@ private: int spinnerFrame; /** Create the main UI actions. */ - void createActions(const NetworkStyle *networkStyle); + void createActions(); /** Create the menu bar and sub-menus. */ void createMenuBar(); /** Create the toolbars */ diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 03d94f2e13..729eb84a18 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -29,8 +29,9 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : optionsModel(optionsModel), peerTableModel(0), cachedNumBlocks(0), - cachedReindexing(0), cachedImporting(0), - numBlocksAtStartup(-1), pollTimer(0) + cachedReindexing(0), + cachedImporting(0), + pollTimer(0) { peerTableModel = new PeerTableModel(this); pollTimer = new QTimer(this); @@ -65,12 +66,6 @@ int ClientModel::getNumBlocks() const return chainActive.Height(); } -int ClientModel::getNumBlocksAtStartup() -{ - if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks(); - return numBlocksAtStartup; -} - quint64 ClientModel::getTotalBytesRecv() const { return CNode::GetTotalBytesRecv(); diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index 4856a72d7d..7b74728b26 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -48,7 +48,6 @@ public: //! Return number of connections, default is in- and outbound (total) int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const; int getNumBlocks() const; - int getNumBlocksAtStartup(); quint64 getTotalBytesRecv() const; quint64 getTotalBytesSent() const; @@ -77,8 +76,6 @@ private: bool cachedReindexing; bool cachedImporting; - int numBlocksAtStartup; - QTimer *pollTimer; void subscribeToCoreSignals(); diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index eebb459327..b1ed7a27b5 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -771,16 +771,6 @@ </property> </widget> </item> - <item> - <widget class="QPushButton" name="buttonMinimizeFee"> - <property name="toolTip"> - <string>collapse fee-settings</string> - </property> - <property name="text"> - <string>Minimize</string> - </property> - </widget> - </item> </layout> </item> <item> @@ -811,6 +801,16 @@ </property> </spacer> </item> + <item> + <widget class="QPushButton" name="buttonMinimizeFee"> + <property name="toolTip"> + <string>collapse fee-settings</string> + </property> + <property name="text"> + <string>Minimize</string> + </property> + </widget> + </item> </layout> </item> <item> diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index a0f3993e69..a342b4bfea 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -38,7 +38,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : fProxyIpValid(true) { ui->setupUi(this); - GUIUtil::restoreWindowGeometry("nOptionsDialogWindow", this->size(), this); /* Main elements init */ ui->databaseCache->setMinimum(nMinDbCache); @@ -117,7 +116,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : OptionsDialog::~OptionsDialog() { - GUIUtil::saveWindowGeometry("nOptionsDialogWindow", this); delete ui; } diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index 63dd6efb52..4e7b70efe6 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -29,7 +29,6 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : ui(new Ui::HelpMessageDialog) { ui->setupUi(this); - GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this); QString version = tr("Bitcoin Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion()); /* On x86 add a bit specifier to the version so that users can distinguish between @@ -143,7 +142,6 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) : HelpMessageDialog::~HelpMessageDialog() { - GUIUtil::saveWindowGeometry("nHelpMessageDialogWindow", this); delete ui; } diff --git a/src/random.cpp b/src/random.cpp index ae25bee1b7..0ba0de908d 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -47,15 +47,16 @@ void RandAddSeedPerfmon() { RandAddSeed(); +#ifdef WIN32 + // Don't need this on Linux, OpenSSL automatically uses /dev/urandom + // Seed with the entire set of perfmon data + // This can take up to 2 seconds, so only do it every 10 minutes static int64_t nLastPerfmon; if (GetTime() < nLastPerfmon + 10 * 60) return; nLastPerfmon = GetTime(); -#ifdef WIN32 - // Don't need this on Linux, OpenSSL automatically uses /dev/urandom - // Seed with the entire set of perfmon data std::vector<unsigned char> vData(250000, 0); long ret = 0; unsigned long nSize = 0; diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 1afc3c910e..d097b6a0fa 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -19,6 +19,7 @@ #include <stdint.h> #include <boost/assign/list_of.hpp> + #include "json/json_spirit_utils.h" #include "json/json_spirit_value.h" @@ -316,35 +317,29 @@ Value getaddressesbyaccount(const Array& params, bool fHelp) return ret; } -void SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew) +static void SendMoney(const CTxDestination &address, CAmount nValue, CWalletTx& wtxNew) { + CAmount curBalance = pwalletMain->GetBalance(); + // Check amount if (nValue <= 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount"); - if (nValue > pwalletMain->GetBalance()) + if (nValue > curBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); - string strError; - if (pwalletMain->IsLocked()) - { - strError = "Error: Wallet locked, unable to create transaction!"; - LogPrintf("SendMoney(): %s", strError); - throw JSONRPCError(RPC_WALLET_ERROR, strError); - } - // Parse Bitcoin address CScript scriptPubKey = GetScriptForDestination(address); // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; - if (!pwalletMain->CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError)) - { - if (nValue + nFeeRequired > pwalletMain->GetBalance()) - strError = strprintf("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!", FormatMoney(nFeeRequired)); - LogPrintf("SendMoney(): %s\n", strError); - throw JSONRPCError(RPC_WALLET_ERROR, strError); + std::string strError; + if (!pwalletMain->CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError)) { + if (nValue + nFeeRequired > curBalance) + throw JSONRPCError(RPC_WALLET_ERROR, strprintf("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!", FormatMoney(nFeeRequired))); + else + throw JSONRPCError(RPC_WALLET_ERROR, strError); } if (!pwalletMain->CommitTransaction(wtxNew, reservekey)) throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); |