aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bignum.h2
-rw-r--r--src/bitcoinrpc.cpp13
-rw-r--r--src/init.cpp15
-rw-r--r--src/main.h8
-rw-r--r--src/makefile.linux-mingw4
-rw-r--r--src/makefile.mingw3
-rw-r--r--src/makefile.osx4
-rw-r--r--src/makefile.unix4
-rw-r--r--src/net.cpp2
-rw-r--r--src/netbase.cpp4
-rw-r--r--src/netbase.h2
-rw-r--r--src/qt/addressbookpage.cpp2
-rw-r--r--src/qt/bitcoinamountfield.h2
-rw-r--r--src/qt/bitcoingui.cpp121
-rw-r--r--src/qt/bitcoingui.h5
-rw-r--r--src/qt/forms/addressbookpage.ui4
-rw-r--r--src/qt/forms/sendcoinsdialog.ui4
-rw-r--r--src/qt/macdockiconhandler.mm4
-rw-r--r--src/qt/notificator.cpp8
-rw-r--r--src/qt/notificator.h2
-rw-r--r--src/qt/optionsdialog.cpp2
-rw-r--r--src/qt/rpcconsole.cpp34
-rw-r--r--src/qt/sendcoinsdialog.cpp2
-rw-r--r--src/qt/sendcoinsdialog.h2
-rw-r--r--src/qt/sendcoinsentry.cpp2
-rw-r--r--src/qt/sendcoinsentry.h2
-rw-r--r--src/qt/transactionrecord.cpp14
-rw-r--r--src/qt/transactionview.cpp10
-rw-r--r--src/script.cpp24
-rw-r--r--src/sync.h2
-rw-r--r--src/uint256.h2
-rw-r--r--src/util.cpp21
-rw-r--r--src/util.h60
-rw-r--r--src/wallet.cpp2
34 files changed, 217 insertions, 175 deletions
diff --git a/src/bignum.h b/src/bignum.h
index 9fea3f70fb..96b1b2e6ae 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -305,7 +305,7 @@ public:
psz++;
// hex string to bignum
- static signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
+ static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
*this = 0;
while (isxdigit(*psz))
{
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 6072b270b0..16260ef1f7 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -9,6 +9,7 @@
#include "ui_interface.h"
#include "base58.h"
#include "bitcoinrpc.h"
+#include "db.h"
#undef printf
#include <boost/asio.hpp>
@@ -178,11 +179,14 @@ Value help(const Array& params, bool fHelp)
Value stop(const Array& params, bool fHelp)
{
- if (fHelp || params.size() != 0)
+ if (fHelp || params.size() > 1)
throw runtime_error(
- "stop\n"
- "Stop Bitcoin server.");
+ "stop <detach>\n"
+ "<detach> is true or false to detach the database or not for this stop only\n"
+ "Stop Bitcoin server (and possibly override the detachdb config value).");
// Shutdown will take long enough that the response should get back
+ if (params.size() > 0)
+ bitdb.SetDetach(params[0].get_bool());
StartShutdown();
return "Bitcoin server stopping";
}
@@ -821,7 +825,7 @@ void ThreadRPCServer2(void* parg)
}
catch(boost::system::system_error &e)
{
- strerr = strprintf(_("An error occurred while setting up the RPC port %i for listening on IPv4: %s"), endpoint.port(), e.what());
+ strerr = strprintf(_("An error occurred while setting up the RPC port %u for listening on IPv4: %s"), endpoint.port(), e.what());
}
if (!fListening) {
@@ -1131,6 +1135,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
//
// Special case non-string parameter types
//
+ if (strMethod == "stop" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);
diff --git a/src/init.cpp b/src/init.cpp
index 8910ed0711..7ed2613f76 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -722,7 +722,8 @@ bool AppInit2()
if (mapArgs.count("-loadblock"))
{
- uiInterface.InitMessage(_("Importing blocks..."));
+ uiInterface.InitMessage(_("Importing blockchain data file."));
+
BOOST_FOREACH(string strFile, mapMultiArgs["-loadblock"])
{
FILE *file = fopen(strFile.c_str(), "rb");
@@ -731,6 +732,18 @@ bool AppInit2()
}
}
+ filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
+ if (filesystem::exists(pathBootstrap)) {
+ uiInterface.InitMessage(_("Importing bootstrap blockchain data file."));
+
+ FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
+ if (file) {
+ filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
+ LoadExternalBlockFile(file);
+ RenameOver(pathBootstrap, pathBootstrapOld);
+ }
+ }
+
// ********************************************************* Step 9: load peers
uiInterface.InitMessage(_("Loading addresses..."));
diff --git a/src/main.h b/src/main.h
index 2e208fed4f..770c202338 100644
--- a/src/main.h
+++ b/src/main.h
@@ -158,7 +158,7 @@ public:
if (IsNull())
return "null";
else
- return strprintf("(nFile=%d, nBlockPos=%d, nTxPos=%d)", nFile, nBlockPos, nTxPos);
+ return strprintf("(nFile=%u, nBlockPos=%u, nTxPos=%u)", nFile, nBlockPos, nTxPos);
}
void print() const
@@ -214,7 +214,7 @@ public:
std::string ToString() const
{
- return strprintf("COutPoint(%s, %d)", hash.ToString().substr(0,10).c_str(), n);
+ return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10).c_str(), n);
}
void print() const
@@ -586,7 +586,7 @@ public:
std::string ToString() const
{
std::string str;
- str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%d, vout.size=%d, nLockTime=%d)\n",
+ str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
GetHash().ToString().substr(0,10).c_str(),
nVersion,
vin.size(),
@@ -1128,7 +1128,7 @@ public:
std::string ToString() const
{
- return strprintf("CBlockIndex(pprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%-6d nHeight=%d, merkle=%s, hashBlock=%s)",
+ return strprintf("CBlockIndex(pprev=%08x, pnext=%08x, nFile=%u, nBlockPos=%-6u nHeight=%d, merkle=%s, hashBlock=%s)",
pprev, pnext, nFile, nBlockPos, nHeight,
hashMerkleRoot.ToString().substr(0,10).c_str(),
GetBlockHash().ToString().substr(0,20).c_str());
diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw
index 4ba0cf06f0..634a47b752 100644
--- a/src/makefile.linux-mingw
+++ b/src/makefile.linux-mingw
@@ -32,7 +32,7 @@ LIBS= \
DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
-CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+CFLAGS=-O2 -w -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
@@ -111,6 +111,6 @@ clean:
-rm -f bitcoind.exe
-rm -f obj-test/*.o
-rm -f test_bitcoin.exe
- -rm -f src/build.h
+ -rm -f obj/build.h
FORCE:
diff --git a/src/makefile.mingw b/src/makefile.mingw
index 9bbd739365..fbd8c1b2dd 100644
--- a/src/makefile.mingw
+++ b/src/makefile.mingw
@@ -27,7 +27,7 @@ LIBS= \
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
-CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
@@ -104,6 +104,5 @@ clean:
-del /Q bitcoind test_bitcoin
-del /Q obj\*
-del /Q obj-test\*
- -del /Q build.h
FORCE:
diff --git a/src/makefile.osx b/src/makefile.osx
index 547f751aba..a0de217c01 100644
--- a/src/makefile.osx
+++ b/src/makefile.osx
@@ -66,7 +66,7 @@ CFLAGS = -g
endif
# ppc doesn't work because we don't support big-endian
-CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
+CFLAGS += -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter \
$(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
OBJS= \
@@ -156,6 +156,6 @@ clean:
-rm -f obj-test/*.o
-rm -f obj/*.P
-rm -f obj-test/*.P
- -rm -f src/build.h
+ -rm -f obj/build.h
FORCE:
diff --git a/src/makefile.unix b/src/makefile.unix
index 6f8f96e3af..b73ce2833b 100644
--- a/src/makefile.unix
+++ b/src/makefile.unix
@@ -93,7 +93,7 @@ DEBUGFLAGS=-g
# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
-xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
+xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wno-format -Wno-format-security -Wno-unused-parameter \
$(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
@@ -172,6 +172,6 @@ clean:
-rm -f obj-test/*.o
-rm -f obj/*.P
-rm -f obj-test/*.P
- -rm -f src/build.h
+ -rm -f obj/build.h
FORCE:
diff --git a/src/net.cpp b/src/net.cpp
index c0693306af..651f4a974c 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1025,7 +1025,7 @@ void ThreadMapPort2(void* parg)
{
printf("ThreadMapPort started\n");
- std::string port = strprintf("%d", GetListenPort());
+ std::string port = strprintf("%u", GetListenPort());
const char * multicastif = 0;
const char * minissdpdpath = 0;
struct UPNPDev * devlist = 0;
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 76a3d25d3a..daa8a8d07e 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -599,7 +599,7 @@ CNetAddr::CNetAddr(const std::string &strIp, bool fAllowLookup)
*this = vIP[0];
}
-int CNetAddr::GetByte(int n) const
+unsigned int CNetAddr::GetByte(int n) const
{
return ip[15-n];
}
@@ -1135,7 +1135,7 @@ std::vector<unsigned char> CService::GetKey() const
std::string CService::ToStringPort() const
{
- return strprintf("%i", port);
+ return strprintf("%u", port);
}
std::string CService::ToStringIPPort() const
diff --git a/src/netbase.h b/src/netbase.h
index 07ca12cb96..560e2182df 100644
--- a/src/netbase.h
+++ b/src/netbase.h
@@ -66,7 +66,7 @@ class CNetAddr
enum Network GetNetwork() const;
std::string ToString() const;
std::string ToStringIP() const;
- int GetByte(int n) const;
+ unsigned int GetByte(int n) const;
uint64 GetHash() const;
bool GetInAddr(struct in_addr* pipv4Addr) const;
std::vector<unsigned char> GetGroup() const;
diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp
index 8a74a47f58..e20358c70e 100644
--- a/src/qt/addressbookpage.cpp
+++ b/src/qt/addressbookpage.cpp
@@ -27,7 +27,7 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
{
ui->setupUi(this);
-#ifdef Q_WS_MAC // Icons on push buttons are very uncommon on Mac
+#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
ui->newAddressButton->setIcon(QIcon());
ui->copyToClipboard->setIcon(QIcon());
ui->deleteButton->setIcon(QIcon());
diff --git a/src/qt/bitcoinamountfield.h b/src/qt/bitcoinamountfield.h
index ca4a888e4e..66792e00a9 100644
--- a/src/qt/bitcoinamountfield.h
+++ b/src/qt/bitcoinamountfield.h
@@ -31,7 +31,7 @@ public:
/** Make field empty and ready for new input. */
void clear();
- /** Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907),
+ /** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907),
in these cases we have to set it up manually.
*/
QWidget *setupTabChain(QWidget *prev);
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 27b974b5c6..19a6a65a1b 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -26,7 +26,7 @@
#include "guiutil.h"
#include "rpcconsole.h"
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
@@ -70,7 +70,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
{
resize(850, 550);
setWindowTitle(tr("Bitcoin") + " - " + tr("Wallet"));
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
qApp->setWindowIcon(QIcon(":icons/bitcoin"));
setWindowIcon(QIcon(":icons/bitcoin"));
#else
@@ -115,9 +115,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
centralWidget->addWidget(addressBookPage);
centralWidget->addWidget(receiveCoinsPage);
centralWidget->addWidget(sendCoinsPage);
-#ifdef FIRST_CLASS_MESSAGING
- centralWidget->addWidget(signVerifyMessageDialog);
-#endif
setCentralWidget(centralWidget);
// Create status bar
@@ -186,7 +183,7 @@ BitcoinGUI::~BitcoinGUI()
{
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
delete appMenuBar;
#endif
}
@@ -201,6 +198,18 @@ void BitcoinGUI::createActions()
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
tabGroup->addAction(overviewAction);
+ sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
+ sendCoinsAction->setToolTip(tr("Send coins to a Bitcoin address"));
+ sendCoinsAction->setCheckable(true);
+ sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
+ tabGroup->addAction(sendCoinsAction);
+
+ receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
+ receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
+ receiveCoinsAction->setCheckable(true);
+ receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
+ tabGroup->addAction(receiveCoinsAction);
+
historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setToolTip(tr("Browse transaction history"));
historyAction->setCheckable(true);
@@ -213,52 +222,16 @@ void BitcoinGUI::createActions()
addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
tabGroup->addAction(addressBookAction);
- receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
- receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
- receiveCoinsAction->setCheckable(true);
- receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
- tabGroup->addAction(receiveCoinsAction);
-
- sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
- sendCoinsAction->setToolTip(tr("Send coins to a Bitcoin address"));
- sendCoinsAction->setCheckable(true);
- sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
- tabGroup->addAction(sendCoinsAction);
-
- signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
- signMessageAction->setToolTip(tr("Sign a message to prove you own a Bitcoin address"));
- tabGroup->addAction(signMessageAction);
-
- verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
- verifyMessageAction->setToolTip(tr("Verify a message to ensure it was signed with a specified Bitcoin address"));
- tabGroup->addAction(verifyMessageAction);
-
-#ifdef FIRST_CLASS_MESSAGING
- firstClassMessagingAction = new QAction(QIcon(":/icons/edit"), tr("S&ignatures"), this);
- firstClassMessagingAction->setToolTip(signMessageAction->toolTip() + QString(". / ") + verifyMessageAction->toolTip() + QString("."));
- firstClassMessagingAction->setCheckable(true);
- tabGroup->addAction(firstClassMessagingAction);
-#endif
-
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
+ connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
+ connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
+ connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
+ connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
- connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
- connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
- connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
- connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
- connect(signMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
- connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
- connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
- connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
-#ifdef FIRST_CLASS_MESSAGING
- connect(firstClassMessagingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
- // Always start with the sign message tab for FIRST_CLASS_MESSAGING
- connect(firstClassMessagingAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
-#endif
quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setToolTip(tr("Quit application"));
@@ -274,8 +247,6 @@ void BitcoinGUI::createActions()
optionsAction->setToolTip(tr("Modify configuration options for Bitcoin"));
optionsAction->setMenuRole(QAction::PreferencesRole);
toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
- exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
- exportAction->setToolTip(tr("Export the data in the current tab to a file"));
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
encryptWalletAction->setCheckable(true);
@@ -283,22 +254,29 @@ void BitcoinGUI::createActions()
backupWalletAction->setToolTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
+ signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
+ verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
+
+ exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
+ exportAction->setToolTip(tr("Export the data in the current tab to a file"));
openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
- connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+ connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
+ connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
+ connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
}
void BitcoinGUI::createMenuBar()
{
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
// Create a decoupled menu bar on Mac which stays even if the window is closed
appMenuBar = new QMenuBar();
#else
@@ -310,10 +288,8 @@ void BitcoinGUI::createMenuBar()
QMenu *file = appMenuBar->addMenu(tr("&File"));
file->addAction(backupWalletAction);
file->addAction(exportAction);
-#ifndef FIRST_CLASS_MESSAGING
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
-#endif
file->addSeparator();
file->addAction(quitAction);
@@ -339,9 +315,6 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(addressBookAction);
-#ifdef FIRST_CLASS_MESSAGING
- toolbar->addAction(firstClassMessagingAction);
-#endif
QToolBar *toolbar2 = addToolBar(tr("Actions toolbar"));
toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@@ -357,7 +330,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
if(clientModel->isTestNet())
{
setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]"));
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
qApp->setWindowIcon(QIcon(":icons/bitcoin_testnet"));
setWindowIcon(QIcon(":icons/bitcoin_testnet"));
#else
@@ -421,7 +394,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel)
void BitcoinGUI::createTrayIcon()
{
QMenu *trayIconMenu;
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
@@ -441,15 +414,13 @@ void BitcoinGUI::createTrayIcon()
trayIconMenu->addSeparator();
trayIconMenu->addAction(sendCoinsAction);
trayIconMenu->addAction(receiveCoinsAction);
-#ifndef FIRST_CLASS_MESSAGING
trayIconMenu->addSeparator();
-#endif
trayIconMenu->addAction(signMessageAction);
trayIconMenu->addAction(verifyMessageAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(optionsAction);
trayIconMenu->addAction(openRPCConsoleAction);
-#ifndef Q_WS_MAC // This is built-in on Mac
+#ifndef Q_OS_MAC // This is built-in on Mac
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
#endif
@@ -457,7 +428,7 @@ void BitcoinGUI::createTrayIcon()
notificator = new Notificator(qApp->applicationName(), trayIcon);
}
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::Trigger)
@@ -501,7 +472,7 @@ void BitcoinGUI::setNumConnections(int count)
void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
{
- // don't show / hide progressBar and its label if we have no connection(s) to the network
+ // don't show / hide progress bar and its label if we have no connection to the network
if (!clientModel || clientModel->getNumConnections() == 0)
{
progressBarLabel->setVisible(false);
@@ -539,7 +510,7 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
}
- // Override progressBarLabel text and hide progressBar, when we have warnings to display
+ // Override progressBarLabel text and hide progress bar, when we have warnings to display
if (!strStatusBarWarnings.isEmpty())
{
progressBarLabel->setText(strStatusBarWarnings);
@@ -618,7 +589,7 @@ void BitcoinGUI::error(const QString &title, const QString &message, bool modal)
void BitcoinGUI::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
-#ifndef Q_WS_MAC // Ignored on Mac
+#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
@@ -638,7 +609,7 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
{
if(clientModel)
{
-#ifndef Q_WS_MAC // Ignored on Mac
+#ifndef Q_OS_MAC // Ignored on Mac
if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
!clientModel->getOptionsModel()->getMinimizeOnClose())
{
@@ -747,18 +718,8 @@ void BitcoinGUI::gotoSendCoinsPage()
void BitcoinGUI::gotoSignMessageTab(QString addr)
{
-#ifdef FIRST_CLASS_MESSAGING
- firstClassMessagingAction->setChecked(true);
- centralWidget->setCurrentWidget(signVerifyMessageDialog);
-
- exportAction->setEnabled(false);
- disconnect(exportAction, SIGNAL(triggered()), 0, 0);
-
- signVerifyMessageDialog->showTab_SM(false);
-#else
// call show() in showTab_SM()
signVerifyMessageDialog->showTab_SM(true);
-#endif
if(!addr.isEmpty())
signVerifyMessageDialog->setAddress_SM(addr);
@@ -766,18 +727,8 @@ void BitcoinGUI::gotoSignMessageTab(QString addr)
void BitcoinGUI::gotoVerifyMessageTab(QString addr)
{
-#ifdef FIRST_CLASS_MESSAGING
- firstClassMessagingAction->setChecked(true);
- centralWidget->setCurrentWidget(signVerifyMessageDialog);
-
- exportAction->setEnabled(false);
- disconnect(exportAction, SIGNAL(triggered()), 0, 0);
-
- signVerifyMessageDialog->showTab_VM(false);
-#else
// call show() in showTab_VM()
signVerifyMessageDialog->showTab_VM(true);
-#endif
if(!addr.isEmpty())
signVerifyMessageDialog->setAddress_VM(addr);
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index acf84eb941..c67e887c0f 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -80,7 +80,6 @@ private:
QAction *addressBookAction;
QAction *signMessageAction;
QAction *verifyMessageAction;
- QAction *firstClassMessagingAction;
QAction *aboutAction;
QAction *receiveCoinsAction;
QAction *optionsAction;
@@ -124,7 +123,7 @@ public slots:
/** Asks the user whether to pay the transaction fee or to cancel the transaction.
It is currently not possible to pass a return value to another thread through
BlockingQueuedConnection, so an indirected pointer is used.
- http://bugreports.qt.nokia.com/browse/QTBUG-10440
+ https://bugreports.qt-project.org/browse/QTBUG-10440
@param[in] nFeeRequired the required fee
@param[out] payFee true to pay the fee, false to not pay the fee
@@ -153,7 +152,7 @@ private slots:
void optionsClicked();
/** Show about dialog */
void aboutClicked();
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
/** Handle tray icon clicked */
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
#endif
diff --git a/src/qt/forms/addressbookpage.ui b/src/qt/forms/addressbookpage.ui
index eac35c27ae..71ab75ca3f 100644
--- a/src/qt/forms/addressbookpage.ui
+++ b/src/qt/forms/addressbookpage.ui
@@ -102,7 +102,7 @@
<string>Sign a message to prove you own a Bitcoin address</string>
</property>
<property name="text">
- <string>&amp;Sign Message</string>
+ <string>Sign &amp;Message</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
@@ -127,7 +127,7 @@
<item>
<widget class="QPushButton" name="deleteButton">
<property name="toolTip">
- <string>Delete the currently selected address from the list. Only sending addresses can be deleted.</string>
+ <string>Delete the currently selected address from the list</string>
</property>
<property name="text">
<string>&amp;Delete</string>
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui
index 10a1586d4a..6e17565ab0 100644
--- a/src/qt/forms/sendcoinsdialog.ui
+++ b/src/qt/forms/sendcoinsdialog.ui
@@ -64,7 +64,7 @@
<string>Send to multiple recipients at once</string>
</property>
<property name="text">
- <string>&amp;Add Recipient</string>
+ <string>Add &amp;Recipient</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
@@ -153,7 +153,7 @@
<string>Confirm the send action</string>
</property>
<property name="text">
- <string>&amp;Send</string>
+ <string>S&amp;end</string>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
diff --git a/src/qt/macdockiconhandler.mm b/src/qt/macdockiconhandler.mm
index df56e6949d..75684403eb 100644
--- a/src/qt/macdockiconhandler.mm
+++ b/src/qt/macdockiconhandler.mm
@@ -1,8 +1,8 @@
#include "macdockiconhandler.h"
-#include <QtGui/QMenu>
-#include <QtGui/QWidget>
+#include <QMenu>
+#include <QWidget>
extern void qt_mac_set_dock_menu(QMenu*);
diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp
index c1c177dbfe..8028190b82 100644
--- a/src/qt/notificator.cpp
+++ b/src/qt/notificator.cpp
@@ -16,7 +16,7 @@
#include <stdint.h>
#endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
#include <ApplicationServices/ApplicationServices.h>
extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);
#endif
@@ -46,7 +46,7 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
mode = Freedesktop;
}
#endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
// Check if Growl is installed (based on Qt's tray icon implementation)
CFURLRef cfurl;
OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
@@ -225,7 +225,7 @@ void Notificator::notifySystray(Class cls, const QString &title, const QString &
}
// Based on Qt's tray icon implementation
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
void Notificator::notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon)
{
const QString script(
@@ -285,7 +285,7 @@ void Notificator::notify(Class cls, const QString &title, const QString &text, c
case QSystemTray:
notifySystray(cls, title, text, icon, millisTimeout);
break;
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
case Growl12:
case Growl13:
notifyGrowl(cls, title, text, icon);
diff --git a/src/qt/notificator.h b/src/qt/notificator.h
index 8abc0b2ec2..abb47109b3 100644
--- a/src/qt/notificator.h
+++ b/src/qt/notificator.h
@@ -61,7 +61,7 @@ private:
void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
#endif
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
#endif
};
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index f8d1fe56fb..8025126c25 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -46,7 +46,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
ui->proxyIp->installEventFilter(this);
/* Window elements init */
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
ui->tabWindow->setVisible(false);
#endif
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 7d5b6fed53..2b8a0c049b 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -192,13 +192,14 @@ RPCConsole::RPCConsole(QWidget *parent) :
{
ui->setupUi(this);
-#ifndef Q_WS_MAC
+#ifndef Q_OS_MAC
ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export"));
ui->showCLOptionsButton->setIcon(QIcon(":/icons/options"));
#endif
// Install event filter for up and down arrow
ui->lineEdit->installEventFilter(this);
+ ui->messagesWidget->installEventFilter(this);
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
@@ -218,15 +219,34 @@ RPCConsole::~RPCConsole()
bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
{
- if(obj == ui->lineEdit)
+ if(event->type() == QEvent::KeyPress) // Special key handling
{
- if(event->type() == QEvent::KeyPress)
+ QKeyEvent *keyevt = static_cast<QKeyEvent*>(event);
+ int key = keyevt->key();
+ Qt::KeyboardModifiers mod = keyevt->modifiers();
+ switch(key)
{
- QKeyEvent *key = static_cast<QKeyEvent*>(event);
- switch(key->key())
+ case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } break;
+ case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } break;
+ case Qt::Key_PageUp: /* pass paging keys to messages widget */
+ case Qt::Key_PageDown:
+ if(obj == ui->lineEdit)
{
- case Qt::Key_Up: browseHistory(-1); return true;
- case Qt::Key_Down: browseHistory(1); return true;
+ QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt));
+ return true;
+ }
+ break;
+ default:
+ // Typing in messages widget brings focus to line edit, and redirects key there
+ // Exclude most combinations and keys that emit no text, except paste shortcuts
+ if(obj == ui->messagesWidget && (
+ (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
+ ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
+ ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
+ {
+ ui->lineEdit->setFocus();
+ QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
+ return true;
}
}
}
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 789681ad90..ca2c615333 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -21,7 +21,7 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
{
ui->setupUi(this);
-#ifdef Q_WS_MAC // Icons on push buttons are very uncommon on Mac
+#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
ui->addButton->setIcon(QIcon());
ui->clearButton->setIcon(QIcon());
ui->sendButton->setIcon(QIcon());
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index def2f83c30..8a6e050c11 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -25,7 +25,7 @@ public:
void setModel(WalletModel *model);
- /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907).
+ /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
*/
QWidget *setupTabChain(QWidget *prev);
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 71891e79ca..c4d84c388c 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -17,7 +17,7 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) :
{
ui->setupUi(this);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
ui->payToLayout->setSpacing(4);
#endif
#if QT_VERSION >= 0x040700
diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h
index db6cba0d80..0ac14c1472 100644
--- a/src/qt/sendcoinsentry.h
+++ b/src/qt/sendcoinsentry.h
@@ -27,7 +27,7 @@ public:
void setValue(const SendCoinsRecipient &value);
- /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907).
+ /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
*/
QWidget *setupTabChain(QWidget *prev);
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index cc60e2732b..4c3071984f 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -9,18 +9,8 @@ bool TransactionRecord::showTransaction(const CWalletTx &wtx)
{
if (wtx.IsCoinBase())
{
- // Don't show generated coin until confirmed by at least one block after it
- // so we don't get the user's hopes up until it looks like it's probably accepted.
- //
- // It is not an error when generated blocks are not accepted. By design,
- // some percentage of blocks, like 10% or more, will end up not accepted.
- // This is the normal mechanism by which the network copes with latency.
- //
- // We display regular transactions right away before any confirmation
- // because they can always get into some block eventually. Generated coins
- // are special because if their block is not accepted, they are not valid.
- //
- if (wtx.GetDepthInMainChain() < 2)
+ // Ensures we show generated coins / mined transactions at depth 1
+ if (!wtx.IsInMainChain())
{
return false;
}
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index ed2a70a350..7acf5deaa3 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -38,7 +38,7 @@ TransactionView::TransactionView(QWidget *parent) :
QHBoxLayout *hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0,0,0,0);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
hlayout->setSpacing(5);
hlayout->addSpacing(26);
#else
@@ -47,7 +47,7 @@ TransactionView::TransactionView(QWidget *parent) :
#endif
dateWidget = new QComboBox(this);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
dateWidget->setFixedWidth(121);
#else
dateWidget->setFixedWidth(120);
@@ -62,7 +62,7 @@ TransactionView::TransactionView(QWidget *parent) :
hlayout->addWidget(dateWidget);
typeWidget = new QComboBox(this);
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
typeWidget->setFixedWidth(121);
#else
typeWidget->setFixedWidth(120);
@@ -91,7 +91,7 @@ TransactionView::TransactionView(QWidget *parent) :
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
amountWidget->setPlaceholderText(tr("Min amount"));
#endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
amountWidget->setFixedWidth(97);
#else
amountWidget->setFixedWidth(100);
@@ -110,7 +110,7 @@ TransactionView::TransactionView(QWidget *parent) :
vlayout->setSpacing(0);
int width = view->verticalScrollBar()->sizeHint().width();
// Cover scroll bar width with spacing
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
hlayout->addSpacing(width+2);
#else
hlayout->addSpacing(width);
diff --git a/src/script.cpp b/src/script.cpp
index c34fbec82d..4357a9a1b3 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -54,12 +54,29 @@ bool CastToBool(const valtype& vch)
return false;
}
+//
+// WARNING: This does not work as expected for signed integers; the sign-bit
+// is left in place as the integer is zero-extended. The correct behavior
+// would be to move the most significant bit of the last byte during the
+// resize process. MakeSameSize() is currently only used by the disabled
+// opcodes OP_AND, OP_OR, and OP_XOR.
+//
void MakeSameSize(valtype& vch1, valtype& vch2)
{
// Lengthen the shorter one
if (vch1.size() < vch2.size())
+ // PATCH:
+ // +unsigned char msb = vch1[vch1.size()-1];
+ // +vch1[vch1.size()-1] &= 0x7f;
+ // vch1.resize(vch2.size(), 0);
+ // +vch1[vch1.size()-1] = msb;
vch1.resize(vch2.size(), 0);
if (vch2.size() < vch1.size())
+ // PATCH:
+ // +unsigned char msb = vch2[vch2.size()-1];
+ // +vch2[vch2.size()-1] &= 0x7f;
+ // vch2.resize(vch1.size(), 0);
+ // +vch2[vch2.size()-1] = msb;
vch2.resize(vch1.size(), 0);
}
@@ -663,6 +680,11 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
}
break;
+ //
+ // WARNING: These disabled opcodes exhibit unexpected behavior
+ // when used on signed integers due to a bug in MakeSameSize()
+ // [see definition of MakeSameSize() above].
+ //
case OP_AND:
case OP_OR:
case OP_XOR:
@@ -672,7 +694,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
return false;
valtype& vch1 = stacktop(-2);
valtype& vch2 = stacktop(-1);
- MakeSameSize(vch1, vch2);
+ MakeSameSize(vch1, vch2); // <-- NOT SAFE FOR SIGNED VALUES
if (opcode == OP_AND)
{
for (unsigned int i = 0; i < vch1.size(); i++)
diff --git a/src/sync.h b/src/sync.h
index 98640e6eab..e80efbe001 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -31,7 +31,7 @@ void static inline LeaveCritical() {}
void PrintLockContention(const char* pszName, const char* pszFile, int nLine);
#endif
-/** Wrapper around boost::interprocess::scoped_lock */
+/** Wrapper around boost::unique_lock<Mutex> */
template<typename Mutex>
class CMutexLock
{
diff --git a/src/uint256.h b/src/uint256.h
index fc5ed26592..abd0b71e6f 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -306,7 +306,7 @@ public:
psz += 2;
// hex string to uint
- static unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
+ static const unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
const char* pbegin = psz;
while (phexdigit[(unsigned char)*psz] || *psz == '0')
psz++;
diff --git a/src/util.cpp b/src/util.cpp
index d1270348e0..a8bd8228e5 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -274,7 +274,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
return ret;
}
-string vstrprintf(const std::string &format, va_list ap)
+string vstrprintf(const char *format, va_list ap)
{
char buffer[50000];
char* p = buffer;
@@ -284,7 +284,11 @@ string vstrprintf(const std::string &format, va_list ap)
{
va_list arg_ptr;
va_copy(arg_ptr, ap);
- ret = _vsnprintf(p, limit, format.c_str(), arg_ptr);
+#ifdef WIN32
+ ret = _vsnprintf(p, limit, format, arg_ptr);
+#else
+ ret = vsnprintf(p, limit, format, arg_ptr);
+#endif
va_end(arg_ptr);
if (ret >= 0 && ret < limit)
break;
@@ -301,7 +305,7 @@ string vstrprintf(const std::string &format, va_list ap)
return str;
}
-string real_strprintf(const std::string &format, int dummy, ...)
+string real_strprintf(const char *format, int dummy, ...)
{
va_list arg_ptr;
va_start(arg_ptr, dummy);
@@ -310,6 +314,15 @@ string real_strprintf(const std::string &format, int dummy, ...)
return str;
}
+string real_strprintf(const std::string &format, int dummy, ...)
+{
+ va_list arg_ptr;
+ va_start(arg_ptr, dummy);
+ string str = vstrprintf(format.c_str(), arg_ptr);
+ va_end(arg_ptr);
+ return str;
+}
+
bool error(const char *format, ...)
{
va_list arg_ptr;
@@ -411,7 +424,7 @@ bool ParseMoney(const char* pszIn, int64& nRet)
}
-static signed char phexdigit[256] =
+static const signed char phexdigit[256] =
{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
diff --git a/src/util.h b/src/util.h
index 2409ccb79c..54b53582b5 100644
--- a/src/util.h
+++ b/src/util.h
@@ -41,7 +41,6 @@ static const int64 CENT = 1000000;
#define UBEGIN(a) ((unsigned char*)&(a))
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
-#define printf OutputDebugStringF
#ifndef PRI64d
#if defined(_MSC_VER) || defined(__MSVCRT__)
@@ -55,6 +54,17 @@ static const int64 CENT = 1000000;
#endif
#endif
+/* Format characters for (s)size_t and ptrdiff_t */
+#if defined(_MSC_VER) || defined(__MSVCRT__)
+ #define PRIszx "%Ix"
+ #define PRIszu "%Iu"
+ #define PRIszd "%Id"
+#else
+ #define PRIszx "%zx"
+ #define PRIszu "%zu"
+ #define PRIszd "%zd"
+#endif
+
// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
@@ -80,11 +90,7 @@ T* alignup(T* p)
#define S_IRUSR 0400
#define S_IWUSR 0200
#endif
-#define unlink _unlink
#else
-#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
-#define strlwr(psz) to_lower(psz)
-#define _strlwr(psz) to_lower(psz)
#define MAX_PATH 1024
inline void Sleep(int64 n)
{
@@ -94,6 +100,15 @@ inline void Sleep(int64 n)
}
#endif
+/* This GNU C extension enables the compiler to check the format string against the parameters provided.
+ * X is the number of the "format string" parameter, and Y is the number of the first variadic parameter.
+ * Parameters count from 1.
+ */
+#ifdef __GNUC__
+#define ATTR_WARN_PRINTF(X,Y) __attribute__((format(printf,X,Y)))
+#else
+#define ATTR_WARN_PRINTF(X,Y)
+#endif
@@ -121,16 +136,31 @@ extern bool fReopenDebugLog;
void RandAddSeed();
void RandAddSeedPerfmon();
-int OutputDebugStringF(const char* pszFormat, ...);
-int my_snprintf(char* buffer, size_t limit, const char* format, ...);
+int ATTR_WARN_PRINTF(1,2) OutputDebugStringF(const char* pszFormat, ...);
-/* It is not allowed to use va_start with a pass-by-reference argument.
- (C++ standard, 18.7, paragraph 3). Use a dummy argument to work around this, and use a
- macro to keep similar semantics.
+/*
+ Rationale for the real_strprintf / strprintf construction:
+ It is not allowed to use va_start with a pass-by-reference argument.
+ (C++ standard, 18.7, paragraph 3). Use a dummy argument to work around this, and use a
+ macro to keep similar semantics.
*/
+
+/** Overload strprintf for char*, so that GCC format type warnings can be given */
+std::string ATTR_WARN_PRINTF(1,3) real_strprintf(const char *format, int dummy, ...);
+/** Overload strprintf for std::string, to be able to use it with _ (translation).
+ * This will not support GCC format type warnings (-Wformat) so be careful.
+ */
std::string real_strprintf(const std::string &format, int dummy, ...);
#define strprintf(format, ...) real_strprintf(format, 0, __VA_ARGS__)
-std::string vstrprintf(const std::string &format, va_list ap);
+std::string vstrprintf(const char *format, va_list ap);
+
+/* Redefine printf so that it directs output to debug.log
+ *
+ * Do this *after* defining the other printf-like functions, because otherwise the
+ * __attribute__((format(printf,X,Y))) gets expanded to __attribute__((format(OutputDebugStringF,X,Y)))
+ * which confuses gcc.
+ */
+#define printf OutputDebugStringF
bool error(const char *format, ...);
void LogException(std::exception* pex, const char* pszThread);
@@ -237,9 +267,9 @@ inline int64 abs64(int64 n)
template<typename T>
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
{
- std::vector<char> rv;
- static char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ std::string rv;
+ static const char hexmap[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
rv.reserve((itend-itbegin)*3);
for(T it = itbegin; it < itend; ++it)
{
@@ -250,7 +280,7 @@ std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
rv.push_back(hexmap[val&15]);
}
- return std::string(rv.begin(), rv.end());
+ return rv;
}
inline std::string HexStr(const std::vector<unsigned char>& vch, bool fSpaces=false)
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 880f7aa8bd..a10f187309 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -960,7 +960,7 @@ int64 CWallet::GetImmatureBalance() const
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{
const CWalletTx& pcoin = (*it).second;
- if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.GetDepthInMainChain() >= 2)
+ if (pcoin.IsCoinBase() && pcoin.GetBlocksToMaturity() > 0 && pcoin.IsInMainChain())
nTotal += GetCredit(pcoin);
}
}