diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/addrman.cpp | 1 | ||||
-rw-r--r-- | src/bignum.h | 4 | ||||
-rw-r--r-- | src/bitcoinrpc.cpp | 1 | ||||
-rw-r--r-- | src/hash.h | 116 | ||||
-rw-r--r-- | src/init.cpp | 6 | ||||
-rw-r--r-- | src/key.h | 2 | ||||
-rw-r--r-- | src/main.cpp | 12 | ||||
-rw-r--r-- | src/main.h | 2 | ||||
-rw-r--r-- | src/net.h | 1 | ||||
-rw-r--r-- | src/netbase.cpp | 1 | ||||
-rw-r--r-- | src/qt/bitcoinstrings.cpp | 9 | ||||
-rw-r--r-- | src/qt/clientmodel.cpp | 7 | ||||
-rw-r--r-- | src/qt/forms/optionsdialog.ui | 34 | ||||
-rw-r--r-- | src/qt/forms/signverifymessagedialog.ui | 4 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_en.ts | 225 | ||||
-rw-r--r-- | src/qt/optionsdialog.cpp | 27 | ||||
-rw-r--r-- | src/qt/optionsdialog.h | 1 | ||||
-rw-r--r-- | src/qt/optionsmodel.cpp | 18 | ||||
-rw-r--r-- | src/qt/optionsmodel.h | 1 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 9 | ||||
-rw-r--r-- | src/test/util_tests.cpp | 8 | ||||
-rw-r--r-- | src/util.cpp | 2 | ||||
-rw-r--r-- | src/util.h | 106 | ||||
-rw-r--r-- | src/walletdb.cpp | 2 |
24 files changed, 359 insertions, 240 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index 4428cd169a..780edde90f 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "addrman.h" +#include "hash.h" using namespace std; diff --git a/src/bignum.h b/src/bignum.h index ad98613f5f..1ee7a99934 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -131,7 +131,9 @@ public: if (sn < (int64)0) { - // Since the minimum signed integer cannot be represented as positive so long as its type is signed, and it's not well-defined what happens if you make it unsigned before negating it, we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate + // Since the minimum signed integer cannot be represented as positive so long as its type is signed, + // and it's not well-defined what happens if you make it unsigned before negating it, + // we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate n = -(sn + 1); ++n; fNegative = true; diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index bfb696da3d..41850d8bb8 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1219,6 +1219,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri if (strMethod == "gettxout" && n > 2) ConvertTo<bool>(params[2]); if (strMethod == "lockunspent" && n > 0) ConvertTo<bool>(params[0]); if (strMethod == "lockunspent" && n > 1) ConvertTo<Array>(params[1]); + if (strMethod == "importprivkey" && n > 2) ConvertTo<bool>(params[2]); return params; } diff --git a/src/hash.h b/src/hash.h new file mode 100644 index 0000000000..bc013139bb --- /dev/null +++ b/src/hash.h @@ -0,0 +1,116 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 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_HASH_H +#define BITCOIN_HASH_H + +#include "uint256.h" +#include "serialize.h" + +#include <openssl/sha.h> +#include <openssl/ripemd.h> + +template<typename T1> +inline uint256 Hash(const T1 pbegin, const T1 pend) +{ + static unsigned char pblank[1]; + uint256 hash1; + SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +class CHashWriter +{ +private: + SHA256_CTX ctx; + +public: + int nType; + int nVersion; + + void Init() { + SHA256_Init(&ctx); + } + + CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) { + Init(); + } + + CHashWriter& write(const char *pch, size_t size) { + SHA256_Update(&ctx, pch, size); + return (*this); + } + + // invalidates the object + uint256 GetHash() { + uint256 hash1; + SHA256_Final((unsigned char*)&hash1, &ctx); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; + } + + template<typename T> + CHashWriter& operator<<(const T& obj) { + // Serialize to this stream + ::Serialize(*this, obj, nType, nVersion); + return (*this); + } +}; + + +template<typename T1, typename T2> +inline uint256 Hash(const T1 p1begin, const T1 p1end, + const T2 p2begin, const T2 p2end) +{ + static unsigned char pblank[1]; + uint256 hash1; + SHA256_CTX ctx; + SHA256_Init(&ctx); + SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0])); + SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0])); + SHA256_Final((unsigned char*)&hash1, &ctx); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +template<typename T1, typename T2, typename T3> +inline uint256 Hash(const T1 p1begin, const T1 p1end, + const T2 p2begin, const T2 p2end, + const T3 p3begin, const T3 p3end) +{ + static unsigned char pblank[1]; + uint256 hash1; + SHA256_CTX ctx; + SHA256_Init(&ctx); + SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0])); + SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0])); + SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0])); + SHA256_Final((unsigned char*)&hash1, &ctx); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +template<typename T> +uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION) +{ + CHashWriter ss(nType, nVersion); + ss << obj; + return ss.GetHash(); +} + +inline uint160 Hash160(const std::vector<unsigned char>& vch) +{ + uint256 hash1; + SHA256(&vch[0], vch.size(), (unsigned char*)&hash1); + uint160 hash2; + RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; +} + +#endif diff --git a/src/init.cpp b/src/init.cpp index 74533e49e1..557c23fc92 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -258,7 +258,7 @@ std::string HelpMessage() " -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") + "\n" + " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" + " -irc " + _("Find peers using internet relay chat (default: 0)") + "\n" + - " -checkpoints " + _("Lock in block chain with compiled-in checkpoints (default: 1)") + "\n" + + " -checkpoints " + _("Only accept block chain matching built-in checkpoints (default: 1)") + "\n" + " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" + " -bind=<addr> " + _("Bind to given address and always listen on it. Use [host]:port notation for IPv6") + "\n" + " -dnsseed " + _("Find peers using DNS lookup (default: 1 unless -connect)") + "\n" + @@ -301,7 +301,7 @@ std::string HelpMessage() " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n" + " -checkblocks=<n> " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n" + " -checklevel=<n> " + _("How thorough the block verification is (0-6, default: 1)") + "\n" + - " -loadblock=<file> " + _("Imports blocks from external blk000?.dat file") + "\n" + + " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + "\n" + " -reindex " + _("Rebuild blockchain index from current blk000??.dat files") + "\n" + "\n" + _("Block creation options:") + "\n" + @@ -571,7 +571,7 @@ bool AppInit2() printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str()); printf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION)); if (!fLogTimestamps) - printf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", GetTime()).c_str()); + printf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str()); printf("Default data directory %s\n", GetDefaultDataDir().string().c_str()); printf("Used data directory %s\n", strDataDir.c_str()); std::ostringstream strErrors; @@ -11,7 +11,7 @@ #include "allocators.h" #include "serialize.h" #include "uint256.h" -#include "util.h" +#include "hash.h" #include <openssl/ec.h> // for EC_KEY definition diff --git a/src/main.cpp b/src/main.cpp index 96bdabd586..28fbc8b450 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,7 +45,7 @@ bool fReindex = false; bool fBenchmark = false; unsigned int nCoinCacheSize = 5000; -CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have +CMedianFilter<int> cPeerBlockCounts(8, 0); // Amount of blocks that other nodes claim to have map<uint256, CBlock*> mapOrphanBlocks; multimap<uint256, CBlock*> mapOrphanBlocksByPrev; @@ -1187,11 +1187,11 @@ void static InvalidChainFound(CBlockIndex* pindexNew) } printf("InvalidChainFound: invalid block=%s height=%d work=%s date=%s\n", BlockHashStr(pindexNew->GetBlockHash()).c_str(), pindexNew->nHeight, - pindexNew->bnChainWork.ToString().c_str(), DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", + pindexNew->bnChainWork.ToString().c_str(), DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexNew->GetBlockTime()).c_str()); printf("InvalidChainFound: current best=%s height=%d work=%s date=%s\n", BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), - DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", pindexBest->GetBlockTime()).c_str()); + DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str()); if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6) printf("InvalidChainFound: Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); } @@ -1828,7 +1828,7 @@ bool SetBestChain(CBlockIndex* pindexNew) nTransactionsUpdated++; printf("SetBestChain: new best=%s height=%d work=%s tx=%lu date=%s\n", BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), (unsigned long)pindexNew->nChainTx, - DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", pindexBest->GetBlockTime()).c_str()); + DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str()); // Check the version of the last 100 blocks to see if we need to upgrade: if (!fIsInitialDownload) @@ -2375,7 +2375,7 @@ bool static LoadBlockIndexDB() } printf("LoadBlockIndex(): hashBestChain=%s height=%d date=%s\n", BlockHashStr(hashBestChain).c_str(), nBestHeight, - DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", pindexBest->GetBlockTime()).c_str()); + DateTimeStrFormat("%Y-%m-%d %H:%M:%S", pindexBest->GetBlockTime()).c_str()); // Verify blocks in the best chain int nCheckLevel = GetArg("-checklevel", 1); @@ -2538,7 +2538,7 @@ void PrintBlockTree() printf("%d (blk%05u.dat:0x%x) %s tx %"PRIszu"", pindex->nHeight, pindex->GetBlockPos().nFile, pindex->GetBlockPos().nPos, - DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", block.GetBlockTime()).c_str(), + DateTimeStrFormat("%Y-%m-%d %H:%M:%S", block.GetBlockTime()).c_str(), block.vtx.size()); PrintWallets(block); diff --git a/src/main.h b/src/main.h index fdaec3469e..8bceffbaf9 100644 --- a/src/main.h +++ b/src/main.h @@ -152,7 +152,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits); unsigned int ComputeMinWork(unsigned int nBase, int64 nTime); /** Get the number of active peers */ int GetNumBlocksOfPeers(); -/** Check whether we are doin an inital block download (synchronizing from disk or network) */ +/** Check whether we are doing an initial block download (synchronizing from disk or network) */ bool IsInitialBlockDownload(); /** Format a string that describes several potential problems detected by the core */ std::string GetWarnings(std::string strFor); @@ -18,6 +18,7 @@ #include "netbase.h" #include "protocol.h" #include "addrman.h" +#include "hash.h" class CNode; class CBlockIndex; diff --git a/src/netbase.cpp b/src/netbase.cpp index 9e7307204a..4f31ce9cf3 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -6,6 +6,7 @@ #include "netbase.h" #include "util.h" #include "sync.h" +#include "hash.h" #ifndef WIN32 #include <sys/fcntl.h> diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp index 497c05976b..7fcb7acf0e 100644 --- a/src/qt/bitcoinstrings.cpp +++ b/src/qt/bitcoinstrings.cpp @@ -84,7 +84,6 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Allow DNS lookups for -addnode, -seednode and QT_TRANSLATE_NOOP("bitcoin-core", "Allow JSON-RPC connections from specified IP address"), QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to recover private keys from a corrupt wallet.dat"), QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin version"), -QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin"), QT_TRANSLATE_NOOP("bitcoin-core", "Block creation options:"), QT_TRANSLATE_NOOP("bitcoin-core", "Cannot downgrade wallet"), QT_TRANSLATE_NOOP("bitcoin-core", "Cannot initialize keypool"), @@ -102,6 +101,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat"), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet corrupted"), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet requires newer version of Bitcoin"), QT_TRANSLATE_NOOP("bitcoin-core", "Error"), +QT_TRANSLATE_NOOP("bitcoin-core", "Error: Disk space is low!"), QT_TRANSLATE_NOOP("bitcoin-core", "Error: Transaction creation failed!"), QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet locked, unable to create transaction!"), QT_TRANSLATE_NOOP("bitcoin-core", "Error: could not start node"), @@ -114,7 +114,8 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command"), QT_TRANSLATE_NOOP("bitcoin-core", "How many blocks to check at startup (default: 2500, 0 = all)"), QT_TRANSLATE_NOOP("bitcoin-core", "How thorough the block verification is (0-6, default: 1)"), QT_TRANSLATE_NOOP("bitcoin-core", "Importing blocks from block database..."), -QT_TRANSLATE_NOOP("bitcoin-core", "Imports blocks from external blk000?.dat file"), +QT_TRANSLATE_NOOP("bitcoin-core", "Imports blocks from external blk000??.dat file"), +QT_TRANSLATE_NOOP("bitcoin-core", "Information"), QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address: '%s'"), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -tor address: '%s'"), @@ -128,6 +129,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Loading wallet..."), QT_TRANSLATE_NOOP("bitcoin-core", "Maintain at most <n> connections to peers (default: 125)"), QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)"), QT_TRANSLATE_NOOP("bitcoin-core", "Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Only accept block chain matching built-in checkpoints (default: 1)"), QT_TRANSLATE_NOOP("bitcoin-core", "Only connect to nodes in network <net> (IPv4, IPv6 or Tor)"), QT_TRANSLATE_NOOP("bitcoin-core", "Options:"), QT_TRANSLATE_NOOP("bitcoin-core", "Output extra debugging information. Implies all other -debug* options"), @@ -144,7 +146,6 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Send command to -server or bitcoind"), QT_TRANSLATE_NOOP("bitcoin-core", "Send commands to node running on <ip> (default: 127.0.0.1)"), QT_TRANSLATE_NOOP("bitcoin-core", "Send trace/debug info to console instead of debug.log file"), QT_TRANSLATE_NOOP("bitcoin-core", "Send trace/debug info to debugger"), -QT_TRANSLATE_NOOP("bitcoin-core", "Sending..."), QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: server.cert)"), QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: server.pem)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set database cache size in megabytes (default: 25)"), @@ -173,7 +174,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network"), QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections"), QT_TRANSLATE_NOOP("bitcoin-core", "Verifying database integrity..."), QT_TRANSLATE_NOOP("bitcoin-core", "Wallet needed to be rewritten: restart Bitcoin to complete"), -QT_TRANSLATE_NOOP("bitcoin-core", "Warning: Disk space is low!"), +QT_TRANSLATE_NOOP("bitcoin-core", "Warning"), QT_TRANSLATE_NOOP("bitcoin-core", "Warning: This version is obsolete, upgrade required!"), QT_TRANSLATE_NOOP("bitcoin-core", "wallet.dat corrupt, salvage failed"), };
\ No newline at end of file diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index ce112803f8..12bd989338 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -15,10 +15,8 @@ static const int64 nClientStartupTime = GetTime(); ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : QObject(parent), optionsModel(optionsModel), - cachedNumBlocks(0), cachedNumBlocksOfPeers(0), pollTimer(0) + cachedNumBlocks(0), cachedNumBlocksOfPeers(0), numBlocksAtStartup(-1), pollTimer(0) { - numBlocksAtStartup = -1; - pollTimer = new QTimer(this); pollTimer->setInterval(MODEL_UPDATE_DELAY); pollTimer->start(); @@ -65,7 +63,8 @@ void ClientModel::updateTimer() cachedNumBlocks = newNumBlocks; cachedNumBlocksOfPeers = newNumBlocksOfPeers; - emit numBlocksChanged(newNumBlocks, newNumBlocksOfPeers); + // ensure we return the maximum of newNumBlocksOfPeers and newNumBlocks to not create weird displays in the GUI + emit numBlocksChanged(newNumBlocks, std::max(newNumBlocksOfPeers, newNumBlocks)); } } diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 6a13361974..3771f9de63 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -44,7 +44,7 @@ </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_Main"> + <layout class="QHBoxLayout" name="horizontalLayout_1_Main"> <item> <widget class="QLabel" name="transactionFeeLabel"> <property name="text"> @@ -62,7 +62,7 @@ <widget class="BitcoinAmountField" name="transactionFee"/> </item> <item> - <spacer name="horizontalSpacer_Main"> + <spacer name="horizontalSpacer_1_Main"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -99,6 +99,36 @@ </property> </spacer> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2_Main"> + <item> + <spacer name="horizontalSpacer_2_Main"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="resetButton"> + <property name="toolTip"> + <string>Reset all client options to default.</string> + </property> + <property name="text"> + <string>&Reset Options</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> <widget class="QWidget" name="tabNetwork"> diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui index 8128bdf457..48871108a5 100644 --- a/src/qt/forms/signverifymessagedialog.ui +++ b/src/qt/forms/signverifymessagedialog.ui @@ -148,7 +148,7 @@ <string>Sign the message to prove you own this Bitcoin address</string> </property> <property name="text"> - <string>&Sign Message</string> + <string>Sign &Message</string> </property> <property name="icon"> <iconset resource="../bitcoin.qrc"> @@ -294,7 +294,7 @@ <string>Verify the message to ensure it was signed with the specified Bitcoin address</string> </property> <property name="text"> - <string>&Verify Message</string> + <string>Verify &Message</string> </property> <property name="icon"> <iconset resource="../bitcoin.qrc"> diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index c70ea652de..cb6f982d32 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -300,17 +300,17 @@ This product includes software developed by the OpenSSL Project for use in the O <context> <name>BitcoinGUI</name> <message> - <location filename="../bitcoingui.cpp" line="+266"/> + <location filename="../bitcoingui.cpp" line="+267"/> <source>Sign &message...</source> <translation>Sign &message...</translation> </message> <message> - <location line="+241"/> + <location line="+254"/> <source>Synchronizing with network...</source> <translation>Synchronizing with network...</translation> </message> <message> - <location line="-309"/> + <location line="-322"/> <source>&Overview</source> <translation>&Overview</translation> </message> @@ -400,7 +400,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>&Change Passphrase...</translation> </message> <message> - <location line="+246"/> + <location line="+259"/> <source>Importing blocks from disk...</source> <translation>Importing blocks from disk...</translation> </message> @@ -418,7 +418,7 @@ This product includes software developed by the OpenSSL Project for use in the O </translation> </message> <message> - <location line="-252"/> + <location line="-265"/> <source>&Export...</source> <translation>&Export...</translation> </message> @@ -464,11 +464,12 @@ This product includes software developed by the OpenSSL Project for use in the O </message> <message> <location line="-196"/> + <location line="+538"/> <source>Bitcoin</source> <translation>Bitcoin</translation> </message> <message> - <location line="+0"/> + <location line="-538"/> <source>Wallet</source> <translation>Wallet</translation> </message> @@ -534,12 +535,12 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>[testnet]</translation> </message> <message> - <location line="+60"/> + <location line="+63"/> <source>Bitcoin client</source> <translation>Bitcoin client</translation> </message> <message numerus="yes"> - <location line="+69"/> + <location line="+79"/> <source>%n active connection(s) to Bitcoin network</source> <translation> <numerusform>%n active connection to Bitcoin network</numerusform> @@ -557,12 +558,37 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Processed %1 blocks of transaction history.</translation> </message> <message> - <location line="+107"/> + <location line="+70"/> + <source>Error</source> + <translation>Error</translation> + </message> + <message> + <location line="+3"/> + <source>Warning</source> + <translation>Warning</translation> + </message> + <message> + <location line="+3"/> + <source>Information</source> + <translation>Information</translation> + </message> + <message> + <location line="+66"/> <source>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</source> <translation>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</translation> </message> + <message> + <location line="+210"/> + <source>Backup Successful</source> + <translation>Backup Successful</translation> + </message> + <message> + <location line="+0"/> + <source>The wallet data was successfully saved to the new location.</source> + <translation>The wallet data was successfully saved to the new location.</translation> + </message> <message numerus="yes"> - <location line="-93"/> + <location line="-338"/> <source>%n second(s) ago</source> <translation> <numerusform>%n second ago</numerusform> @@ -609,17 +635,17 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Last received block was generated %1.</translation> </message> <message> - <location line="+62"/> + <location line="+97"/> <source>Confirm transaction fee</source> <translation>Confirm transaction fee</translation> </message> <message> - <location line="+27"/> + <location line="+23"/> <source>Sent transaction</source> <translation>Sent transaction</translation> </message> <message> - <location line="+1"/> + <location line="+0"/> <source>Incoming transaction</source> <translation>Incoming transaction</translation> </message> @@ -637,19 +663,19 @@ Address: %4 </translation> </message> <message> - <location line="+100"/> - <location line="+27"/> + <location line="+99"/> + <location line="+28"/> <source>URI handling</source> <translation>URI handling</translation> </message> <message> - <location line="-27"/> - <location line="+27"/> + <location line="-28"/> + <location line="+28"/> <source>URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters.</source> <translation>URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters.</translation> </message> <message> - <location line="+16"/> + <location line="+17"/> <source>Wallet is <b>encrypted</b> and currently <b>unlocked</b></source> <translation>Wallet is <b>encrypted</b> and currently <b>unlocked</b></translation> </message> @@ -1447,12 +1473,11 @@ Address: %4 </message> <message> <location line="+13"/> - <location line="+124"/> <source>&Sign Message</source> <translation>&Sign Message</translation> </message> <message> - <location line="-118"/> + <location line="+6"/> <source>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</source> <translation>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</translation> </message> @@ -1499,7 +1524,12 @@ Address: %4 <translation>Sign the message to prove you own this Bitcoin address</translation> </message> <message> - <location line="+17"/> + <location line="+3"/> + <source>Sign &Message</source> + <translation>Sign &Message</translation> + </message> + <message> + <location line="+14"/> <source>Reset all sign message fields</source> <translation>Reset all sign message fields</translation> </message> @@ -1511,12 +1541,11 @@ Address: %4 </message> <message> <location line="-87"/> - <location line="+70"/> <source>&Verify Message</source> <translation>&Verify Message</translation> </message> <message> - <location line="-64"/> + <location line="+6"/> <source>Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack.</source> <translation>Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack.</translation> </message> @@ -1531,7 +1560,12 @@ Address: %4 <translation>Verify the message to ensure it was signed with the specified Bitcoin address</translation> </message> <message> - <location line="+17"/> + <location line="+3"/> + <source>Verify &Message</source> + <translation>Verify &Message</translation> + </message> + <message> + <location line="+14"/> <source>Reset all verify message fields</source> <translation>Reset all verify message fields</translation> </message> @@ -2103,14 +2137,6 @@ Address: %4 </message> </context> <context> - <name>WalletModel</name> - <message> - <location filename="../walletmodel.cpp" line="+192"/> - <source>Sending...</source> - <translation>Sending...</translation> - </message> -</context> -<context> <name>bitcoin-core</name> <message> <location filename="../bitcoinstrings.cpp" line="+86"/> @@ -2118,32 +2144,32 @@ Address: %4 <translation>Bitcoin version</translation> </message> <message> - <location line="+81"/> + <location line="+82"/> <source>Usage:</source> <translation>Usage:</translation> </message> <message> - <location line="-24"/> + <location line="-23"/> <source>Send command to -server or bitcoind</source> <translation>Send command to -server or bitcoind</translation> </message> <message> - <location line="-20"/> + <location line="-21"/> <source>List commands</source> <translation>List commands</translation> </message> <message> - <location line="-10"/> + <location line="-11"/> <source>Get help for a command</source> <translation>Get help for a command</translation> </message> <message> - <location line="+19"/> + <location line="+21"/> <source>Options:</source> <translation>Options:</translation> </message> <message> - <location line="+23"/> + <location line="+22"/> <source>Specify configuration file (default: bitcoin.conf)</source> <translation>Specify configuration file (default: bitcoin.conf)</translation> </message> @@ -2153,17 +2179,17 @@ Address: %4 <translation>Specify pid file (default: bitcoind.pid)</translation> </message> <message> - <location line="-46"/> + <location line="-47"/> <source>Generate coins</source> <translation>Generate coins</translation> </message> <message> - <location line="-14"/> + <location line="-15"/> <source>Don't generate coins</source> <translation>Don't generate coins</translation> </message> <message> - <location line="+59"/> + <location line="+61"/> <source>Specify data directory</source> <translation>Specify data directory</translation> </message> @@ -2183,12 +2209,12 @@ Address: %4 <translation>Maintain at most <n> connections to peers (default: 125)</translation> </message> <message> - <location line="-32"/> + <location line="-34"/> <source>Connect to a node to retrieve peer addresses, and disconnect</source> <translation>Connect to a node to retrieve peer addresses, and disconnect</translation> </message> <message> - <location line="+63"/> + <location line="+65"/> <source>Specify your own public address</source> <translation>Specify your own public address</translation> </message> @@ -2198,7 +2224,7 @@ Address: %4 <translation>Threshold for disconnecting misbehaving peers (default: 100)</translation> </message> <message> - <location line="-113"/> + <location line="-114"/> <source>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</source> <translation>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</translation> </message> @@ -2218,17 +2244,17 @@ Address: %4 <translation>Accept command line and JSON-RPC commands</translation> </message> <message> - <location line="+60"/> + <location line="+62"/> <source>Run in the background as a daemon and accept commands</source> <translation>Run in the background as a daemon and accept commands</translation> </message> <message> - <location line="+32"/> + <location line="+31"/> <source>Use the test network</source> <translation>Use the test network</translation> </message> <message> - <location line="-91"/> + <location line="-92"/> <source>Accept connections from outside (default: 1 if no -proxy or -connect)</source> <translation>Accept connections from outside (default: 1 if no -proxy or -connect)</translation> </message> @@ -2323,7 +2349,7 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Attempt to recover private keys from a corrupt wallet.dat</translation> </message> <message> - <location line="+3"/> + <location line="+2"/> <source>Block creation options:</source> <translation>Block creation options:</translation> </message> @@ -2339,6 +2365,11 @@ If the file does not exist, create it with owner-readable-only file permissions. </message> <message> <location line="+8"/> + <source>Error: Disk space is low!</source> + <translation>Error: Disk space is low!</translation> + </message> + <message> + <location line="+1"/> <source>Error: Transaction creation failed!</source> <translation>Error: Transaction creation failed!</translation> </message> @@ -2363,7 +2394,17 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Importing blocks from block database...</translation> </message> <message> - <location line="+4"/> + <location line="+1"/> + <source>Imports blocks from external blk000??.dat file</source> + <translation>Imports blocks from external blk000??.dat file</translation> + </message> + <message> + <location line="+1"/> + <source>Information</source> + <translation>Information</translation> + </message> + <message> + <location line="+3"/> <source>Invalid -tor address: '%s'</source> <translation>Invalid -tor address: '%s'</translation> </message> @@ -2379,6 +2420,11 @@ If the file does not exist, create it with owner-readable-only file permissions. </message> <message> <location line="+1"/> + <source>Only accept block chain matching built-in checkpoints (default: 1)</source> + <translation>Only accept block chain matching built-in checkpoints (default: 1)</translation> + </message> + <message> + <location line="+1"/> <source>Only connect to nodes in network <net> (IPv4, IPv6 or Tor)</source> <translation>Only connect to nodes in network <net> (IPv4, IPv6 or Tor)</translation> </message> @@ -2423,7 +2469,7 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Send trace/debug info to debugger</translation> </message> <message> - <location line="+6"/> + <location line="+5"/> <source>Set maximum block size in bytes (default: 250000)</source> <translation>Set maximum block size in bytes (default: 250000)</translation> </message> @@ -2469,8 +2515,8 @@ If the file does not exist, create it with owner-readable-only file permissions. </message> <message> <location line="+2"/> - <source>Warning: Disk space is low!</source> - <translation>Warning: Disk space is low!</translation> + <source>Warning</source> + <translation>Warning</translation> </message> <message> <location line="+1"/> @@ -2483,27 +2529,27 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>wallet.dat corrupt, salvage failed</translation> </message> <message> - <location line="-43"/> + <location line="-42"/> <source>Password for JSON-RPC connections</source> <translation>Password for JSON-RPC connections</translation> </message> <message> - <location line="-51"/> + <location line="-53"/> <source>Allow JSON-RPC connections from specified IP address</source> <translation>Allow JSON-RPC connections from specified IP address</translation> </message> <message> - <location line="+60"/> + <location line="+62"/> <source>Send commands to node running on <ip> (default: 127.0.0.1)</source> <translation>Send commands to node running on <ip> (default: 127.0.0.1)</translation> </message> <message> - <location line="-101"/> + <location line="-103"/> <source>Execute command when the best block changes (%s in cmd is replaced by block hash)</source> <translation>Execute command when the best block changes (%s in cmd is replaced by block hash)</translation> </message> <message> - <location line="+123"/> + <location line="+124"/> <source>Upgrade wallet to latest format</source> <translation>Upgrade wallet to latest format</translation> </message> @@ -2513,12 +2559,12 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Set key pool size to <n> (default: 100)</translation> </message> <message> - <location line="-13"/> + <location line="-12"/> <source>Rescan the block chain for missing wallet transactions</source> <translation>Rescan the block chain for missing wallet transactions</translation> </message> <message> - <location line="-24"/> + <location line="-26"/> <source>How many blocks to check at startup (default: 2500, 0 = all)</source> <translation>How many blocks to check at startup (default: 2500, 0 = all)</translation> </message> @@ -2528,12 +2574,7 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>How thorough the block verification is (0-6, default: 1)</translation> </message> <message> - <location line="+2"/> - <source>Imports blocks from external blk000?.dat file</source> - <translation>Imports blocks from external blk000?.dat file</translation> - </message> - <message> - <location line="+51"/> + <location line="+54"/> <source>Use OpenSSL (https) for JSON-RPC connections</source> <translation>Use OpenSSL (https) for JSON-RPC connections</translation> </message> @@ -2548,42 +2589,37 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Server private key (default: server.pem)</translation> </message> <message> - <location line="-130"/> + <location line="-131"/> <source>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</source> <translation>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</translation> </message> <message> - <location line="+141"/> + <location line="+142"/> <source>This help message</source> <translation>This help message</translation> </message> <message> - <location line="-73"/> - <source>Bitcoin</source> - <translation>Bitcoin</translation> - </message> - <message> - <location line="+76"/> + <location line="+3"/> <source>Unable to bind to %s on this computer (bind returned error %d, %s)</source> <translation>Unable to bind to %s on this computer (bind returned error %d, %s)</translation> </message> <message> - <location line="-68"/> + <location line="-70"/> <source>Connect through socks proxy</source> <translation>Connect through socks proxy</translation> </message> <message> - <location line="-12"/> + <location line="-11"/> <source>Allow DNS lookups for -addnode, -seednode and -connect</source> <translation>Allow DNS lookups for -addnode, -seednode and -connect</translation> </message> <message> - <location line="+42"/> + <location line="+43"/> <source>Loading addresses...</source> <translation>Loading addresses...</translation> </message> <message> - <location line="-25"/> + <location line="-27"/> <source>Error loading blkindex.dat</source> <translation>Error loading blkindex.dat</translation> </message> @@ -2598,17 +2634,17 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Error loading wallet.dat: Wallet requires newer version of Bitcoin</translation> </message> <message> - <location line="+72"/> + <location line="+74"/> <source>Wallet needed to be rewritten: restart Bitcoin to complete</source> <translation>Wallet needed to be rewritten: restart Bitcoin to complete</translation> </message> <message> - <location line="-74"/> + <location line="-76"/> <source>Error loading wallet.dat</source> <translation>Error loading wallet.dat</translation> </message> <message> - <location line="+18"/> + <location line="+20"/> <source>Invalid -proxy address: '%s'</source> <translation>Invalid -proxy address: '%s'</translation> </message> @@ -2623,7 +2659,7 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Unknown -socks proxy version requested: %i</translation> </message> <message> - <location line="-73"/> + <location line="-75"/> <source>Cannot resolve -bind address: '%s'</source> <translation>Cannot resolve -bind address: '%s'</translation> </message> @@ -2633,22 +2669,17 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Cannot resolve -externalip address: '%s'</translation> </message> <message> - <location line="+29"/> + <location line="+31"/> <source>Invalid amount for -paytxfee=<amount>: '%s'</source> <translation>Invalid amount for -paytxfee=<amount>: '%s'</translation> </message> <message> - <location line="-14"/> + <location line="-15"/> <source>Error: could not start node</source> <translation>Error: could not start node</translation> </message> <message> - <location line="+40"/> - <source>Sending...</source> - <translation>Sending...</translation> - </message> - <message> - <location line="-25"/> + <location line="+16"/> <source>Invalid amount</source> <translation>Invalid amount</translation> </message> @@ -2663,7 +2694,7 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Loading block index...</translation> </message> <message> - <location line="-44"/> + <location line="-45"/> <source>Add a node to connect to and attempt to keep the connection open</source> <translation>Add a node to connect to and attempt to keep the connection open</translation> </message> @@ -2683,12 +2714,12 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Fee per KB to add to transactions you send</translation> </message> <message> - <location line="+18"/> + <location line="+19"/> <source>Loading wallet...</source> <translation>Loading wallet...</translation> </message> <message> - <location line="-38"/> + <location line="-40"/> <source>Cannot downgrade wallet</source> <translation>Cannot downgrade wallet</translation> </message> @@ -2703,27 +2734,27 @@ If the file does not exist, create it with owner-readable-only file permissions. <translation>Cannot write default address</translation> </message> <message> - <location line="+46"/> + <location line="+49"/> <source>Rescanning...</source> <translation>Rescanning...</translation> </message> <message> - <location line="-40"/> + <location line="-43"/> <source>Done loading</source> <translation>Done loading</translation> </message> <message> - <location line="+63"/> + <location line="+65"/> <source>To use the %s option</source> <translation>To use the %s option</translation> </message> <message> - <location line="-58"/> + <location line="-60"/> <source>Error</source> <translation>Error</translation> </message> <message> - <location line="-29"/> + <location line="-28"/> <source>You must set rpcpassword=<password> in the configuration file: %s If the file does not exist, create it with owner-readable-only file permissions.</source> diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 03dcb0b538..6b98ab1929 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -177,6 +177,33 @@ void OptionsDialog::setSaveButtonState(bool fState) ui->okButton->setEnabled(fState); } +void OptionsDialog::on_resetButton_clicked() +{ + if(model) + { + // confirmation dialog + QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"), + tr("Some settings may require a client restart to take effect.") + "<br><br>" + tr("Do you want to proceed?"), + QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); + + if(btnRetVal == QMessageBox::Cancel) + return; + + disableApplyButton(); + + /* disable restart warning messages display */ + fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = true; + + /* reset all options and save the default values (QSettings) */ + model->Reset(); + mapper->toFirst(); + mapper->submit(); + + /* re-enable restart warning messages display */ + fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = false; + } +} + void OptionsDialog::on_okButton_clicked() { mapper->submit(); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 18469f509d..d64ed0b57f 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -36,6 +36,7 @@ private slots: void disableSaveButtons(); /* set apply button and OK button state (enabled / disabled) */ void setSaveButtonState(bool fState); + void on_resetButton_clicked(); void on_okButton_clicked(); void on_cancelButton_clicked(); void on_applyButton_clicked(); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 5dac5a6c45..2457e38742 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -60,6 +60,24 @@ void OptionsModel::Init() SoftSetArg("-lang", language.toStdString()); } +void OptionsModel::Reset() +{ + QSettings settings; + + // Remove all entries in this QSettings object + settings.clear(); + + // default setting for OptionsModel::StartAtStartup - disabled + if (GUIUtil::GetStartOnSystemStartup()) + GUIUtil::SetStartOnSystemStartup(false); + + // Re-Init to get default values + Init(); + + // Ensure Upgrade() is not running again by setting the bImportFinished flag + settings.setValue("bImportFinished", true); +} + bool OptionsModel::Upgrade() { QSettings settings; diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 4f893bb44e..d25d898d9c 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -33,6 +33,7 @@ public: }; void Init(); + void Reset(); /* Migrate settings from wallet.dat after app initialization */ bool Upgrade(); /* returns true if settings upgraded */ diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 3dc32d0e47..7cf2d41962 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -269,8 +269,6 @@ void RPCConsole::setClientModel(ClientModel *model) setNumConnections(model->getNumConnections()); ui->isTestNet->setChecked(model->isTestNet()); - - setNumBlocks(model->getNumBlocks(), model->getNumBlocksOfPeers()); } } @@ -342,13 +340,10 @@ void RPCConsole::setNumConnections(int count) void RPCConsole::setNumBlocks(int count, int countOfPeers) { ui->numberOfBlocks->setText(QString::number(count)); - ui->totalBlocks->setText(QString::number(countOfPeers)); + // If there is no current countOfPeers available display N/A instead of 0, which can't ever be true + ui->totalBlocks->setText(countOfPeers == 0 ? tr("N/A") : QString::number(countOfPeers)); if(clientModel) - { - // If there is no current number available display N/A instead of 0, which can't ever be true - ui->totalBlocks->setText(clientModel->getNumBlocksOfPeers() == 0 ? tr("N/A") : QString::number(clientModel->getNumBlocksOfPeers())); ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString()); - } } void RPCConsole::on_lineEdit_returnPressed() diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index c47d25bbe9..f56969cba6 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -104,11 +104,11 @@ BOOST_AUTO_TEST_CASE(util_HexStr) BOOST_AUTO_TEST_CASE(util_DateTimeStrFormat) { /*These are platform-dependant and thus removed to avoid useless test failures - BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", 0), "1970-01-01T00:00:00"); - BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", 0x7FFFFFFF), "2038-01-19T03:14:07"); + BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%d %H:%M:%S", 0), "1970-01-01 00:00:00"); + BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%d %H:%M:%S", 0x7FFFFFFF), "2038-01-19 03:14:07"); // Formats used within Bitcoin - BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", 1317425777), "2011-09-30T23:36:17"); - BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%dT%H:%M", 1317425777), "2011-09-30T23:36"); + BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%d %H:%M:%S", 1317425777), "2011-09-30 23:36:17"); + BOOST_CHECK_EQUAL(DateTimeStrFormat("%Y-%m-%d %H:%M", 1317425777), "2011-09-30 23:36"); */ } diff --git a/src/util.cpp b/src/util.cpp index 806f3ebcf6..576ba50dbb 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -240,7 +240,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...) // Debug print useful for profiling if (fLogTimestamps && fStartedNewLine) - fprintf(fileout, "%s ", DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", GetTime()).c_str()); + fprintf(fileout, "%s ", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str()); if (pszFormat[strlen(pszFormat) - 1] == '\n') fStartedNewLine = true; else diff --git a/src/util.h b/src/util.h index ab921e6f05..8bea0dd2b3 100644 --- a/src/util.h +++ b/src/util.h @@ -24,9 +24,6 @@ typedef int pid_t; /* define for Windows compatibility */ #include <boost/date_time/gregorian/gregorian_types.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> -#include <openssl/sha.h> -#include <openssl/ripemd.h> - #include "netbase.h" // for AddTimeData typedef long long int64; @@ -414,109 +411,6 @@ bool SoftSetBoolArg(const std::string& strArg, bool fValue); -template<typename T1> -inline uint256 Hash(const T1 pbegin, const T1 pend) -{ - static unsigned char pblank[1]; - uint256 hash1; - SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1); - uint256 hash2; - SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); - return hash2; -} - -class CHashWriter -{ -private: - SHA256_CTX ctx; - -public: - int nType; - int nVersion; - - void Init() { - SHA256_Init(&ctx); - } - - CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) { - Init(); - } - - CHashWriter& write(const char *pch, size_t size) { - SHA256_Update(&ctx, pch, size); - return (*this); - } - - // invalidates the object - uint256 GetHash() { - uint256 hash1; - SHA256_Final((unsigned char*)&hash1, &ctx); - uint256 hash2; - SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); - return hash2; - } - - template<typename T> - CHashWriter& operator<<(const T& obj) { - // Serialize to this stream - ::Serialize(*this, obj, nType, nVersion); - return (*this); - } -}; - - -template<typename T1, typename T2> -inline uint256 Hash(const T1 p1begin, const T1 p1end, - const T2 p2begin, const T2 p2end) -{ - static unsigned char pblank[1]; - uint256 hash1; - SHA256_CTX ctx; - SHA256_Init(&ctx); - SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0])); - SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0])); - SHA256_Final((unsigned char*)&hash1, &ctx); - uint256 hash2; - SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); - return hash2; -} - -template<typename T1, typename T2, typename T3> -inline uint256 Hash(const T1 p1begin, const T1 p1end, - const T2 p2begin, const T2 p2end, - const T3 p3begin, const T3 p3end) -{ - static unsigned char pblank[1]; - uint256 hash1; - SHA256_CTX ctx; - SHA256_Init(&ctx); - SHA256_Update(&ctx, (p1begin == p1end ? pblank : (unsigned char*)&p1begin[0]), (p1end - p1begin) * sizeof(p1begin[0])); - SHA256_Update(&ctx, (p2begin == p2end ? pblank : (unsigned char*)&p2begin[0]), (p2end - p2begin) * sizeof(p2begin[0])); - SHA256_Update(&ctx, (p3begin == p3end ? pblank : (unsigned char*)&p3begin[0]), (p3end - p3begin) * sizeof(p3begin[0])); - SHA256_Final((unsigned char*)&hash1, &ctx); - uint256 hash2; - SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); - return hash2; -} - -template<typename T> -uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION) -{ - CHashWriter ss(nType, nVersion); - ss << obj; - return ss.GetHash(); -} - -inline uint160 Hash160(const std::vector<unsigned char>& vch) -{ - uint256 hash1; - SHA256(&vch[0], vch.size(), (unsigned char*)&hash1); - uint160 hash2; - RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); - return hash2; -} - - /** Median filter over a stream of values. * Returns the median of the last N numbers */ diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 4419cbb5f7..2282bed18a 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -238,7 +238,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str()); //printf(" %12"PRI64d" %s %s %s\n", // wtx.vout[0].nValue, - // DateTimeStrFormat("%Y-%m-%dT%H:%M:%S", wtx.GetBlockTime()).c_str(), + // DateTimeStrFormat("%Y-%m-%d %H:%M:%S", wtx.GetBlockTime()).c_str(), // wtx.hashBlock.ToString().substr(0,20).c_str(), // wtx.mapValue["message"].c_str()); } |