diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro
index c6b489680..6e9c26b84 100644
--- a/bitcoin-qt.pro
+++ b/bitcoin-qt.pro
@@ -3,7 +3,8 @@ TARGET = litecoin-qt
macx:TARGET = "Litecoin-Qt"
VERSION = 0.8.3
INCLUDEPATH += src src/json src/qt
-QT += network
+QT += core gui network
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
CONFIG += thread
@@ -212,6 +213,7 @@ HEADERS += src/qt/bitcoingui.h \
src/leveldb.h \
src/threadsafety.h \
src/limitedmap.h \
+ src/qt/macnotificationhandler.h \
src/qt/splashscreen.h
SOURCES += src/qt/bitcoin.cpp \
@@ -314,6 +316,7 @@ DEFINES += BITCOIN_QT_TEST
macx: CONFIG -= app_bundle
}
+# Todo: Remove this line when switching to Qt5, as that option was removed
CODECFORTR = UTF-8
# for lrelease/lupdate
@@ -337,6 +340,7 @@ QMAKE_EXTRA_COMPILERS += TSQM
OTHER_FILES += README.md \
doc/*.rst \
doc/*.txt \
+ doc/*.md \
src/qt/res/bitcoin-qt.rc \
src/test/*.cpp \
src/test/*.h \
@@ -394,9 +398,9 @@ win32:!contains(MINGW_THREAD_BUGFIX, 0) {
DEFINES += _FILE_OFFSET_BITS=64
}
-macx:HEADERS += src/qt/macdockiconhandler.h
-macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm
-macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
+macx:HEADERS += src/qt/macdockiconhandler.h src/qt/macnotificationhandler.h
+macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm src/qt/macnotificationhandler.mm
+macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit -framework CoreServices
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:ICON = src/qt/res/icons/litecoin.icns
macx:QMAKE_CFLAGS_THREAD += -pthread
diff --git a/contrib/debian/README b/contrib/debian/README
new file mode 100644
index 000000000..1cb9b75fb
--- /dev/null
+++ b/contrib/debian/README
@@ -0,0 +1,20 @@
+This directory contains files used to package bitcoind/bitcoin-qt
+for Debian-based Linux systems.
+
+If you compile bitcoind/bitcoin-qt yourself, there are some
+useful files here:
+
+bitcoin: URI support
+--------------------
+
+bitcoin-qt.desktop (Gnome / Open Desktop)
+To install:
+ sudo desktop-file-install bitcoin-qt.desktop
+ sudo update-desktop-database
+
+If you build yourself, you will either need to modify the paths in
+the .desktop file or copy or symlink your bitcoin-qt binary to /usr/bin
+and the ../../share/pixmaps/bitcoin128.png to /usr/share/pixmaps
+
+bitcoin-qt.protocol (KDE)
+
diff --git a/contrib/debian/bitcoin-qt.desktop b/contrib/debian/bitcoin-qt.desktop
index 5d6f781e4..b2a2cef62 100644
--- a/contrib/debian/bitcoin-qt.desktop
+++ b/contrib/debian/bitcoin-qt.desktop
@@ -4,7 +4,7 @@ Name=Bitcoin
Comment=Bitcoin P2P Cryptocurrency
Comment[fr]=Bitcoin, monnaie virtuelle cryptographique pair à pair
Comment[tr]=Bitcoin, eşten eşe kriptografik sanal para birimi
-Exec=/usr/bin/bitcoin-qt
+Exec=/usr/bin/bitcoin-qt %u
Terminal=false
Type=Application
Icon=/usr/share/pixmaps/bitcoin128.png
diff --git a/share/qt/Info.plist b/share/qt/Info.plist
index 9c1545e5c..3c8531cf0 100644
--- a/share/qt/Info.plist
+++ b/share/qt/Info.plist
@@ -31,5 +31,7 @@
+ NSHighResolutionCapable
+
diff --git a/src/alert.cpp b/src/alert.cpp
index ea9de70b8..80e01844d 100644
--- a/src/alert.cpp
+++ b/src/alert.cpp
@@ -144,9 +144,7 @@ bool CAlert::RelayTo(CNode* pnode) const
bool CAlert::CheckSignature() const
{
- CKey key;
- if (!key.SetPubKey(ParseHex(fTestNet ? pszTestKey : pszMainKey)))
- return error("CAlert::CheckSignature() : SetPubKey failed");
+ CPubKey key(ParseHex(fTestNet ? pszTestKey : pszMainKey));
if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
return error("CAlert::CheckSignature() : verify signature failed");
diff --git a/src/allocators.h b/src/allocators.h
index eb2aed672..85af8fe37 100644
--- a/src/allocators.h
+++ b/src/allocators.h
@@ -176,6 +176,19 @@ private:
{}
};
+//
+// Functions for directly locking/unlocking memory objects.
+// Intended for non-dynamically allocated structures.
+//
+template void LockObject(const T &t) {
+ LockedPageManager::instance.LockRange((void*)(&t), sizeof(T));
+}
+
+template void UnlockObject(const T &t) {
+ OPENSSL_cleanse((void*)(&t), sizeof(T));
+ LockedPageManager::instance.UnlockRange((void*)(&t), sizeof(T));
+}
+
//
// Allocator that locks its contents from being paged
// out of memory and clears its contents before deletion.
diff --git a/src/base58.h b/src/base58.h
index 9f4b70c55..d376490ab 100644
--- a/src/base58.h
+++ b/src/base58.h
@@ -404,21 +404,19 @@ public:
PRIVKEY_ADDRESS_TEST = CBitcoinAddress::PUBKEY_ADDRESS_TEST + 128,
};
- void SetSecret(const CSecret& vchSecret, bool fCompressed)
+ void SetKey(const CKey& vchSecret)
{
- assert(vchSecret.size() == 32);
- SetData(fTestNet ? PRIVKEY_ADDRESS_TEST : PRIVKEY_ADDRESS, &vchSecret[0], vchSecret.size());
- if (fCompressed)
+ assert(vchSecret.IsValid());
+ SetData(fTestNet ? PRIVKEY_ADDRESS_TEST : PRIVKEY_ADDRESS, vchSecret.begin(), vchSecret.size());
+ if (vchSecret.IsCompressed())
vchData.push_back(1);
}
- CSecret GetSecret(bool &fCompressedOut)
+ CKey GetKey()
{
- CSecret vchSecret;
- vchSecret.resize(32);
- memcpy(&vchSecret[0], &vchData[0], 32);
- fCompressedOut = vchData.size() == 33;
- return vchSecret;
+ CKey ret;
+ ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1);
+ return ret;
}
bool IsValid() const
@@ -449,9 +447,9 @@ public:
return SetString(strSecret.c_str());
}
- CBitcoinSecret(const CSecret& vchSecret, bool fCompressed)
+ CBitcoinSecret(const CKey& vchSecret)
{
- SetSecret(vchSecret, fCompressed);
+ SetKey(vchSecret);
}
CBitcoinSecret()
diff --git a/src/crypter.cpp b/src/crypter.cpp
index a2b62a87c..32baabd67 100644
--- a/src/crypter.cpp
+++ b/src/crypter.cpp
@@ -100,17 +100,17 @@ bool CCrypter::Decrypt(const std::vector& vchCiphertext, CKeyingM
}
-bool EncryptSecret(CKeyingMaterial& vMasterKey, const CSecret &vchPlaintext, const uint256& nIV, std::vector &vchCiphertext)
+bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256& nIV, std::vector &vchCiphertext)
{
CCrypter cKeyCrypter;
std::vector chIV(WALLET_CRYPTO_KEY_SIZE);
memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE);
if(!cKeyCrypter.SetKey(vMasterKey, chIV))
return false;
- return cKeyCrypter.Encrypt((CKeyingMaterial)vchPlaintext, vchCiphertext);
+ return cKeyCrypter.Encrypt(*((const CKeyingMaterial*)&vchPlaintext), vchCiphertext);
}
-bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector& vchCiphertext, const uint256& nIV, CSecret& vchPlaintext)
+bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector& vchCiphertext, const uint256& nIV, CKeyingMaterial& vchPlaintext)
{
CCrypter cKeyCrypter;
std::vector chIV(WALLET_CRYPTO_KEY_SIZE);
diff --git a/src/crypter.h b/src/crypter.h
index 6f75170ba..4134c1b49 100644
--- a/src/crypter.h
+++ b/src/crypter.h
@@ -101,7 +101,7 @@ public:
}
};
-bool EncryptSecret(CKeyingMaterial& vMasterKey, const CSecret &vchPlaintext, const uint256& nIV, std::vector &vchCiphertext);
-bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector &vchCiphertext, const uint256& nIV, CSecret &vchPlaintext);
+bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256& nIV, std::vector &vchCiphertext);
+bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector& vchCiphertext, const uint256& nIV, CKeyingMaterial& vchPlaintext);
#endif
diff --git a/src/db.cpp b/src/db.cpp
index 3133d99bf..fd4c67d55 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -541,6 +541,8 @@ bool CAddrDB::Read(CAddrMan& addr)
// use file size to size memory buffer
int fileSize = GetFilesize(filein);
int dataSize = fileSize - sizeof(uint256);
+ //Don't try to resize to a negative number if file is small
+ if ( dataSize < 0 ) dataSize = 0;
vector vchData;
vchData.resize(dataSize);
uint256 hashIn;
diff --git a/src/hash.h b/src/hash.h
index eaa1780c0..536ab7116 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -105,15 +105,22 @@ uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL
return ss.GetHash();
}
-inline uint160 Hash160(const std::vector& vch)
+template
+inline uint160 Hash160(const T1 pbegin, const T1 pend)
{
+ static unsigned char pblank[1];
uint256 hash1;
- SHA256(&vch[0], vch.size(), (unsigned char*)&hash1);
+ SHA256((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), (unsigned char*)&hash1);
uint160 hash2;
RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2);
return hash2;
}
+inline uint160 Hash160(const std::vector& vch)
+{
+ return Hash160(vch.begin(), vch.end());
+}
+
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector& vDataToHash);
#endif
diff --git a/src/init.cpp b/src/init.cpp
index 038e03d4f..2145d29fe 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -531,7 +531,7 @@ bool AppInit2(boost::thread_group& threadGroup)
// Make sure enough file descriptors are available
int nBind = std::max((int)mapArgs.count("-bind"), 1);
nMaxConnections = GetArg("-maxconnections", 125);
- nMaxConnections = std::max(std::min(nMaxConnections, FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS), 0);
+ nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS);
if (nFD < MIN_CORE_FILEDESCRIPTORS)
return InitError(_("Not enough file descriptors available."));
@@ -870,12 +870,23 @@ bool AppInit2(boost::thread_group& threadGroup)
break;
}
+ // If the loaded chain has a wrong genesis, bail out immediately
+ // (we're likely using a testnet datadir, or the other way around).
+ if (!mapBlockIndex.empty() && pindexGenesisBlock == NULL)
+ return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
+
// Initialize the block index (no-op if non-empty database was already loaded)
if (!InitBlockIndex()) {
strLoadError = _("Error initializing block database");
break;
}
+ // Check for changed -txindex state
+ if (fTxIndex != GetBoolArg("-txindex", false)) {
+ strLoadError = _("You need to rebuild the database using -reindex to change -txindex");
+ break;
+ }
+
uiInterface.InitMessage(_("Verifying blocks..."));
if (!VerifyDB()) {
strLoadError = _("Corrupted block database detected");
@@ -893,7 +904,7 @@ bool AppInit2(boost::thread_group& threadGroup)
// first suggest a reindex
if (!fReset) {
bool fRet = uiInterface.ThreadSafeMessageBox(
- strLoadError + ".\n" + _("Do you want to rebuild the block database now?"),
+ strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?"),
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
if (fRet) {
fReindex = true;
@@ -907,9 +918,6 @@ bool AppInit2(boost::thread_group& threadGroup)
}
}
- if (mapArgs.count("-txindex") && fTxIndex != GetBoolArg("-txindex", false))
- return InitError(_("You need to rebuild the databases using -reindex to change -txindex"));
-
// as LoadBlockIndex can take several minutes, it's possible the user
// requested to kill bitcoin-qt during the last operation. If so, exit.
// As the program has not fully started yet, Shutdown() is possibly overkill.
diff --git a/src/key.cpp b/src/key.cpp
index 20114e6bb..1ab4c62eb 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -2,13 +2,16 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include