diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoinrpc.cpp | 25 | ||||
-rw-r--r-- | src/clientversion.h | 2 | ||||
-rw-r--r-- | src/key.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 9 | ||||
-rw-r--r-- | src/rpcwallet.cpp | 4 | ||||
-rw-r--r-- | src/test/accounting_tests.cpp | 2 | ||||
-rw-r--r-- | src/wallet.cpp | 9 | ||||
-rw-r--r-- | src/wallet.h | 7 | ||||
-rw-r--r-- | src/walletdb.cpp | 4 | ||||
-rw-r--r-- | src/walletdb.h | 6 |
10 files changed, 56 insertions, 14 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 84a6d6f896..fa39236361 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -761,17 +761,19 @@ void ThreadRPCServer2(void* parg) const bool loopback = !mapArgs.count("-rpcallowip"); asio::ip::address bindAddress = loopback ? asio::ip::address_v6::loopback() : asio::ip::address_v6::any(); ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332)); + boost::system::error_code v6_only_error; + boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(io_service)); boost::signals2::signal<void ()> StopRequests; + bool fListening = false; + std::string strerr; try { - boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(io_service)); acceptor->open(endpoint.protocol()); acceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); // Try making the socket dual IPv6/IPv4 (if listening on the "any" address) - boost::system::error_code v6_only_error; acceptor->set_option(boost::asio::ip::v6_only(loopback), v6_only_error); acceptor->bind(endpoint); @@ -783,8 +785,16 @@ void ThreadRPCServer2(void* parg) static_cast<void (ip::tcp::acceptor::*)()>(&ip::tcp::acceptor::close), acceptor.get()) .track(acceptor)); + fListening = true; + } + catch(boost::system::system_error &e) + { + strerr = strprintf(_("An error occurred while setting up the RPC port %i for listening on IPv6, falling back to IPv4: %s"), endpoint.port(), e.what()); + } + + try { // If dual IPv6/IPv4 failed (or we're opening loopback interfaces only), open IPv4 separately - if (loopback || v6_only_error) + if (!fListening || loopback || v6_only_error) { bindAddress = loopback ? asio::ip::address_v4::loopback() : asio::ip::address_v4::any(); endpoint.address(bindAddress); @@ -800,12 +810,17 @@ void ThreadRPCServer2(void* parg) StopRequests.connect(signals2::slot<void ()>( static_cast<void (ip::tcp::acceptor::*)()>(&ip::tcp::acceptor::close), acceptor.get()) .track(acceptor)); + + fListening = true; } } catch(boost::system::system_error &e) { - uiInterface.ThreadSafeMessageBox(strprintf(_("An error occurred while setting up the RPC port %i for listening: %s"), endpoint.port(), e.what()), - _("Error"), CClientUIInterface::OK | CClientUIInterface::MODAL); + strerr = strprintf(_("An error occurred while setting up the RPC port %i for listening on IPv4: %s"), endpoint.port(), e.what()); + } + + if (!fListening) { + uiInterface.ThreadSafeMessageBox(strerr, _("Error"), CClientUIInterface::OK | CClientUIInterface::MODAL); StartShutdown(); return; } diff --git a/src/clientversion.h b/src/clientversion.h index 844eaa37bb..548105383c 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -9,7 +9,7 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 7 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 2 +#define CLIENT_VERSION_BUILD 99 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! @@ -99,7 +99,7 @@ public: }; -// secure_allocator is defined in serialize.h +// secure_allocator is defined in allocators.h // CPrivKey is a serialized private key, with all parameters included (279 bytes) typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey; // CSecret is a serialization of just the secret parameter (32 bytes) diff --git a/src/main.cpp b/src/main.cpp index 35b666beb4..1479df6712 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1412,9 +1412,12 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) // See BIP30 and http://r6.ca/blog/20120206T005236Z.html for more information. // This logic is not necessary for memory pool transactions, as AcceptToMemoryPool // already refuses previously-known transaction ids entirely. - // This rule applies to all blocks whose timestamp is after March 15, 2012, 0:00 UTC. - int64 nBIP30SwitchTime = 1331769600; - bool fEnforceBIP30 = (pindex->nTime > nBIP30SwitchTime); + // This rule was originally applied all blocks whose timestamp was after March 15, 2012, 0:00 UTC. + // Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the + // two in the chain that violate it. This prevents exploiting the issue against nodes in their + // initial block download. + bool fEnforceBIP30 = !((pindex->nHeight==91842 && pindex->GetBlockHash() == uint256("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) || + (pindex->nHeight==91880 && pindex->GetBlockHash() == uint256("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"))); // BIP16 didn't become active until Apr 1 2012 int64 nBIP16SwitchTime = 1333238400; diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 929dde9c15..3d0d05de84 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -573,7 +573,7 @@ Value movecmd(const Array& params, bool fHelp) // Debit CAccountingEntry debit; - debit.nOrderPos = pwalletMain->nOrderPosNext++; + debit.nOrderPos = pwalletMain->IncOrderPosNext(); debit.strAccount = strFrom; debit.nCreditDebit = -nAmount; debit.nTime = nNow; @@ -583,7 +583,7 @@ Value movecmd(const Array& params, bool fHelp) // Credit CAccountingEntry credit; - credit.nOrderPos = pwalletMain->nOrderPosNext++; + credit.nOrderPos = pwalletMain->IncOrderPosNext(); credit.strAccount = strTo; credit.nCreditDebit = nAmount; credit.nTime = nNow; diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp index c474fd65c1..8ac657288b 100644 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) ae.nTime = 1333333330; ae.strOtherAccount = "d"; - ae.nOrderPos = pwalletMain->nOrderPosNext++; + ae.nOrderPos = pwalletMain->IncOrderPosNext(); walletdb.WriteAccountingEntry(ae); GetResults(walletdb, results); diff --git a/src/wallet.cpp b/src/wallet.cpp index f88a0e1413..880f7aa8bd 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -291,6 +291,13 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) return true; } +int64 CWallet::IncOrderPosNext() +{ + int64 nRet = nOrderPosNext; + CWalletDB(strWalletFile).WriteOrderPosNext(++nOrderPosNext); + return nRet; +} + CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries, std::string strAccount) { CWalletDB walletdb(strWalletFile); @@ -362,7 +369,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) if (fInsertedNew) { wtx.nTimeReceived = GetAdjustedTime(); - wtx.nOrderPos = nOrderPosNext++; + wtx.nOrderPos = IncOrderPosNext(); wtx.nTimeSmart = wtx.nTimeReceived; if (wtxIn.hashBlock != 0) diff --git a/src/wallet.h b/src/wallet.h index 7fd33629fe..516ad3fa50 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -98,6 +98,7 @@ public: fFileBacked = false; nMasterKeyMaxID = 0; pwalletdbEncryption = NULL; + nOrderPosNext = 0; } CWallet(std::string strWalletFileIn) { @@ -107,6 +108,7 @@ public: fFileBacked = true; nMasterKeyMaxID = 0; pwalletdbEncryption = NULL; + nOrderPosNext = 0; } std::map<uint256, CWalletTx> mapWallet; @@ -144,6 +146,11 @@ public: bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); bool EncryptWallet(const SecureString& strWalletPassphrase); + /** Increment the next transaction order id + @return next transaction order id + */ + int64 IncOrderPosNext(); + typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair; typedef std::multimap<int64, TxPair > TxItems; diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 164b68e11f..0fac0109c8 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -392,6 +392,10 @@ int CWalletDB::LoadWallet(CWallet* pwallet) return DB_CORRUPT; } } + else if (strType == "orderposnext") + { + ssValue >> pwallet->nOrderPosNext; + } } pcursor->close(); } diff --git a/src/walletdb.h b/src/walletdb.h index 187be65a97..d339d4c3f1 100644 --- a/src/walletdb.h +++ b/src/walletdb.h @@ -115,6 +115,12 @@ public: return Read(std::string("bestblock"), locator); } + bool WriteOrderPosNext(int64 nOrderPosNext) + { + nWalletDBUpdated++; + return Write(std::string("orderposnext"), nOrderPosNext); + } + bool ReadDefaultKey(std::vector<unsigned char>& vchPubKey) { vchPubKey.clear(); |