aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base58.cpp3
-rw-r--r--src/bitcoind.cpp1
-rw-r--r--src/init.cpp8
-rw-r--r--src/qt/bitcoin.cpp13
-rw-r--r--src/qt/bitcoinamountfield.h4
-rw-r--r--src/qt/bitcoingui.cpp19
-rw-r--r--src/qt/coincontroldialog.h8
-rw-r--r--src/qt/intro.h2
-rw-r--r--src/qt/openuridialog.h2
-rw-r--r--src/qt/optionsdialog.cpp2
-rw-r--r--src/qt/optionsmodel.cpp1
-rw-r--r--src/qt/paymentrequestplus.cpp1
-rw-r--r--src/qt/receivecoinsdialog.h7
-rw-r--r--src/qt/rpcconsole.cpp4
-rw-r--r--src/qt/rpcconsole.h8
-rw-r--r--src/qt/sendcoinsdialog.h8
-rw-r--r--src/qt/splashscreen.cpp63
-rw-r--r--src/qt/splashscreen.h22
-rw-r--r--src/qt/transactiondesc.cpp4
-rw-r--r--src/qt/utilitydialog.cpp26
-rw-r--r--src/qt/utilitydialog.h6
-rw-r--r--src/rpcnet.cpp3
-rw-r--r--src/script/script.h2
-rw-r--r--src/serialize.h2
-rw-r--r--src/test/crypto_tests.cpp2
-rw-r--r--src/test/data/script_invalid.json27
-rw-r--r--src/test/data/script_valid.json26
-rw-r--r--src/test/script_tests.cpp49
-rw-r--r--src/util.cpp2
-rw-r--r--src/util.h2
-rw-r--r--src/wallet.cpp50
-rw-r--r--src/wallet.h2
32 files changed, 273 insertions, 106 deletions
diff --git a/src/base58.cpp b/src/base58.cpp
index 9750f0a161..d94db2c51b 100644
--- a/src/base58.cpp
+++ b/src/base58.cpp
@@ -288,7 +288,8 @@ void CBitcoinSecret::SetKey(const CKey& vchSecret)
CKey CBitcoinSecret::GetKey()
{
CKey ret;
- ret.Set(&vchData[0], &vchData[32], vchData.size() > 32 && vchData[32] == 1);
+ assert(vchData.size() >= 32);
+ ret.Set(vchData.begin(), vchData.begin() + 32, vchData.size() > 32 && vchData[32] == 1);
return ret;
}
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 5be8708979..0737b5a83d 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -129,7 +129,6 @@ bool AppInit(int argc, char* argv[])
}
if (pid > 0) // Parent process, pid is child process id
{
- CreatePidFile(GetPidFile(), pid);
return true;
}
// Child process falls through to rest of initialization
diff --git a/src/init.cpp b/src/init.cpp
index 67f53e044c..7299bd0f4a 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -160,7 +160,9 @@ void Shutdown()
if (pwalletMain)
bitdb.Flush(true);
#endif
+#ifndef WIN32
boost::filesystem::remove(GetPidFile());
+#endif
UnregisterAllWallets();
#ifdef ENABLE_WALLET
if (pwalletMain)
@@ -228,7 +230,9 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -maxorphanblocks=<n> " + strprintf(_("Keep at most <n> unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n";
strUsage += " -maxorphantx=<n> " + strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS) + "\n";
strUsage += " -par=<n> " + strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), -(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS) + "\n";
+#ifndef WIN32
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
+#endif
strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n";
#if !defined(WIN32)
strUsage += " -sysperms " + _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)") + "\n";
@@ -714,7 +718,9 @@ bool AppInit2(boost::thread_group& threadGroup)
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
if (!lock.try_lock())
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin Core is probably already running."), strDataDir));
-
+#ifndef WIN32
+ CreatePidFile(GetPidFile(), getpid());
+#endif
if (GetBoolArg("-shrinkdebugfile", !fDebug))
ShrinkDebugFile();
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 6cc6b99ceb..bd686041c1 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -16,6 +16,7 @@
#include "splashscreen.h"
#include "utilitydialog.h"
#include "winshutdownmonitor.h"
+
#ifdef ENABLE_WALLET
#include "paymentserver.h"
#include "walletmodel.h"
@@ -26,6 +27,7 @@
#include "rpcserver.h"
#include "ui_interface.h"
#include "util.h"
+
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif
@@ -34,15 +36,16 @@
#include <boost/filesystem/operations.hpp>
#include <boost/thread.hpp>
+
#include <QApplication>
#include <QDebug>
#include <QLibraryInfo>
#include <QLocale>
#include <QMessageBox>
#include <QSettings>
+#include <QThread>
#include <QTimer>
#include <QTranslator>
-#include <QThread>
#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
@@ -338,7 +341,9 @@ void BitcoinApplication::createWindow(bool isaTestNet)
void BitcoinApplication::createSplashScreen(bool isaTestNet)
{
- SplashScreen *splash = new SplashScreen(QPixmap(), 0, isaTestNet);
+ SplashScreen *splash = new SplashScreen(0, isaTestNet);
+ // We don't hold a direct pointer to the splash screen after creation, so use
+ // Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
splash->setAttribute(Qt::WA_DeleteOnClose);
splash->show();
connect(this, SIGNAL(splashFinished(QWidget*)), splash, SLOT(slotFinish(QWidget*)));
@@ -423,8 +428,6 @@ void BitcoinApplication::initializeResult(int retval)
}
#endif
- emit splashFinished(window);
-
// If -min option passed, start window minimized.
if(GetBoolArg("-min", false))
{
@@ -434,6 +437,8 @@ void BitcoinApplication::initializeResult(int retval)
{
window->show();
}
+ emit splashFinished(window);
+
#ifdef ENABLE_WALLET
// Now that initialization/startup is done, process any command-line
// bitcoin: URIs or payment requests:
diff --git a/src/qt/bitcoinamountfield.h b/src/qt/bitcoinamountfield.h
index c713f5d687..84795a7e7a 100644
--- a/src/qt/bitcoinamountfield.h
+++ b/src/qt/bitcoinamountfield.h
@@ -7,12 +7,12 @@
#include <QWidget>
+class AmountSpinBox;
+
QT_BEGIN_NAMESPACE
class QValueComboBox;
QT_END_NAMESPACE
-class AmountSpinBox;
-
/** Widget for entering bitcoin amounts.
*/
class BitcoinAmountField: public QWidget
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 790301a1eb..443bed14d7 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -14,6 +14,7 @@
#include "optionsmodel.h"
#include "rpcconsole.h"
#include "utilitydialog.h"
+
#ifdef ENABLE_WALLET
#include "walletframe.h"
#include "walletmodel.h"
@@ -24,8 +25,8 @@
#endif
#include "init.h"
-#include "util.h"
#include "ui_interface.h"
+#include "util.h"
#include <iostream>
@@ -50,8 +51,8 @@
#include <QVBoxLayout>
#if QT_VERSION < 0x050000
-#include <QUrl>
#include <QTextDocument>
+#include <QUrl>
#else
#include <QUrlQuery>
#endif
@@ -661,6 +662,9 @@ void BitcoinGUI::setNumConnections(int count)
void BitcoinGUI::setNumBlocks(int count)
{
+ if(!clientModel)
+ return;
+
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
statusBar()->clearMessage();
@@ -831,7 +835,7 @@ void BitcoinGUI::changeEvent(QEvent *e)
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
- if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
+ if(clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray())
{
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
@@ -846,16 +850,16 @@ void BitcoinGUI::changeEvent(QEvent *e)
void BitcoinGUI::closeEvent(QCloseEvent *event)
{
- if(clientModel)
- {
#ifndef Q_OS_MAC // Ignored on Mac
+ if(clientModel && clientModel->getOptionsModel())
+ {
if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
!clientModel->getOptionsModel()->getMinimizeOnClose())
{
QApplication::quit();
}
-#endif
}
+#endif
QMainWindow::closeEvent(event);
}
@@ -916,8 +920,7 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
gotoSendCoinsPage();
return true;
}
- else
- return false;
+ return false;
}
void BitcoinGUI::setEncryptionStatus(int status)
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
index 4f7422642f..a6f239a898 100644
--- a/src/qt/coincontroldialog.h
+++ b/src/qt/coincontroldialog.h
@@ -14,13 +14,15 @@
#include <QString>
#include <QTreeWidgetItem>
-namespace Ui {
- class CoinControlDialog;
-}
class WalletModel;
+
class CCoinControl;
class CTxMemPool;
+namespace Ui {
+ class CoinControlDialog;
+}
+
class CoinControlDialog : public QDialog
{
Q_OBJECT
diff --git a/src/qt/intro.h b/src/qt/intro.h
index 295a75562f..e3e396d369 100644
--- a/src/qt/intro.h
+++ b/src/qt/intro.h
@@ -12,7 +12,7 @@
class FreespaceChecker;
namespace Ui {
-class Intro;
+ class Intro;
}
/** Introduction screen (pre-GUI startup).
diff --git a/src/qt/openuridialog.h b/src/qt/openuridialog.h
index 28da7d6d9d..67a5f167d1 100644
--- a/src/qt/openuridialog.h
+++ b/src/qt/openuridialog.h
@@ -8,7 +8,7 @@
#include <QDialog>
namespace Ui {
-class OpenURIDialog;
+ class OpenURIDialog;
}
class OpenURIDialog : public QDialog
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index c775a7f8d6..279467129f 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -17,11 +17,13 @@
#include "main.h" // for MAX_SCRIPTCHECK_THREADS
#include "netbase.h"
#include "txdb.h" // for -dbcache defaults
+
#ifdef ENABLE_WALLET
#include "wallet.h" // for CWallet::minTxFee
#endif
#include <boost/thread.hpp>
+
#include <QDir>
#include <QIntValidator>
#include <QLocale>
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 99928ebe4d..bd747faeb6 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -15,6 +15,7 @@
#include "main.h"
#include "net.h"
#include "txdb.h" // for -dbcache defaults
+
#ifdef ENABLE_WALLET
#include "wallet.h"
#include "walletdb.h"
diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index acce42e203..7b7de49831 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -13,6 +13,7 @@
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
+
#include <QDateTime>
#include <QDebug>
#include <QSslCertificate>
diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h
index 663cb157a4..7a7e38e25e 100644
--- a/src/qt/receivecoinsdialog.h
+++ b/src/qt/receivecoinsdialog.h
@@ -5,6 +5,8 @@
#ifndef RECEIVECOINSDIALOG_H
#define RECEIVECOINSDIALOG_H
+#include "guiutil.h"
+
#include <QDialog>
#include <QHeaderView>
#include <QItemSelection>
@@ -13,13 +15,12 @@
#include <QPoint>
#include <QVariant>
-#include "guiutil.h"
+class OptionsModel;
+class WalletModel;
namespace Ui {
class ReceiveCoinsDialog;
}
-class OptionsModel;
-class WalletModel;
QT_BEGIN_NAMESPACE
class QModelIndex;
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 11089b2497..8129353d4b 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -16,10 +16,12 @@
#include "util.h"
#include "json/json_spirit_value.h"
+
+#include <openssl/crypto.h>
+
#ifdef ENABLE_WALLET
#include <db_cxx.h>
#endif
-#include <openssl/crypto.h>
#include <QKeyEvent>
#include <QScrollBar>
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 64bb5c29b3..1ffff92758 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -14,14 +14,14 @@
class ClientModel;
-QT_BEGIN_NAMESPACE
-class QItemSelection;
-QT_END_NAMESPACE
-
namespace Ui {
class RPCConsole;
}
+QT_BEGIN_NAMESPACE
+class QItemSelection;
+QT_END_NAMESPACE
+
/** Local Bitcoin RPC console. */
class RPCConsole: public QDialog
{
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index 6cdf4a00c8..a090fa42d5 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -14,14 +14,14 @@ class OptionsModel;
class SendCoinsEntry;
class SendCoinsRecipient;
-QT_BEGIN_NAMESPACE
-class QUrl;
-QT_END_NAMESPACE
-
namespace Ui {
class SendCoinsDialog;
}
+QT_BEGIN_NAMESPACE
+class QUrl;
+QT_END_NAMESPACE
+
/** Dialog for sending bitcoins */
class SendCoinsDialog : public QDialog
{
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 5dd110b36a..673e984691 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -4,22 +4,25 @@
#include "splashscreen.h"
-#include "version.h"
#include "clientversion.h"
#include "init.h"
#include "ui_interface.h"
#include "util.h"
+#include "version.h"
+
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif
#include <QApplication>
+#include <QCloseEvent>
+#include <QDesktopWidget>
#include <QPainter>
-SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
- QSplashScreen(pixmap, f)
+SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
+ QWidget(0, f), curAlignment(0)
{
- setAutoFillBackground(true);
+ //setAutoFillBackground(true);
// set reference point, paddings
int paddingRight = 50;
@@ -38,15 +41,14 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
QString font = "Arial";
// load the bitmap for writing some text over it
- QPixmap newPixmap;
if(isTestNet) {
- newPixmap = QPixmap(":/images/splash_testnet");
+ pixmap = QPixmap(":/images/splash_testnet");
}
else {
- newPixmap = QPixmap(":/images/splash");
+ pixmap = QPixmap(":/images/splash");
}
- QPainter pixPaint(&newPixmap);
+ QPainter pixPaint(&pixmap);
pixPaint.setPen(QColor(100,100,100));
// check font size and drawing with
@@ -61,7 +63,7 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
pixPaint.setFont(QFont(font, 33*fontFactor));
fm = pixPaint.fontMetrics();
titleTextWidth = fm.width(titleText);
- pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);
+ pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);
pixPaint.setFont(QFont(font, 15*fontFactor));
@@ -72,11 +74,11 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
pixPaint.setFont(QFont(font, 10*fontFactor));
titleVersionVSpace -= 5;
}
- pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
+ pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
// draw copyright stuff
pixPaint.setFont(QFont(font, 10*fontFactor));
- pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
+ pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
// draw testnet string if testnet is on
if(isTestNet) {
@@ -85,12 +87,22 @@ SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTest
pixPaint.setFont(boldFont);
fm = pixPaint.fontMetrics();
int testnetAddTextWidth = fm.width(testnetAddText);
- pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
+ pixPaint.drawText(pixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
}
pixPaint.end();
- this->setPixmap(newPixmap);
+ // Set window title
+ if(isTestNet)
+ setWindowTitle(titleText + " " + testnetAddText);
+ else
+ setWindowTitle(titleText);
+
+ // Resize window and move to center of desktop, disallow resizing
+ QRect r(QPoint(), pixmap.size());
+ resize(r.size());
+ setFixedSize(r.size());
+ move(QApplication::desktop()->screenGeometry().center() - r.center());
subscribeToCoreSignals();
}
@@ -102,7 +114,7 @@ SplashScreen::~SplashScreen()
void SplashScreen::slotFinish(QWidget *mainWin)
{
- finish(mainWin);
+ hide();
}
static void InitMessage(SplashScreen *splash, const std::string &message)
@@ -146,3 +158,26 @@ void SplashScreen::unsubscribeFromCoreSignals()
pwalletMain->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
#endif
}
+
+void SplashScreen::showMessage(const QString &message, int alignment, const QColor &color)
+{
+ curMessage = message;
+ curAlignment = alignment;
+ curColor = color;
+ update();
+}
+
+void SplashScreen::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(this);
+ painter.drawPixmap(0, 0, pixmap);
+ QRect r = rect().adjusted(5, 5, -5, -5);
+ painter.setPen(curColor);
+ painter.drawText(r, curAlignment, curMessage);
+}
+
+void SplashScreen::closeEvent(QCloseEvent *event)
+{
+ event->ignore();
+}
+
diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h
index d79038d81d..89c21e6457 100644
--- a/src/qt/splashscreen.h
+++ b/src/qt/splashscreen.h
@@ -7,25 +7,41 @@
#include <QSplashScreen>
-/** class for the splashscreen with information of the running client
+/** Class for the splashscreen with information of the running client.
+ *
+ * @note this is intentionally not a QSplashScreen. Bitcoin Core initialization
+ * can take a long time, and in that case a progress window that cannot be
+ * moved around and minimized has turned out to be frustrating to the user.
*/
-class SplashScreen : public QSplashScreen
+class SplashScreen : public QWidget
{
Q_OBJECT
public:
- explicit SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet);
+ explicit SplashScreen(Qt::WindowFlags f, bool isTestNet);
~SplashScreen();
+protected:
+ void paintEvent(QPaintEvent *event);
+ void closeEvent(QCloseEvent *event);
+
public slots:
/** Slot to call finish() method as it's not defined as slot */
void slotFinish(QWidget *mainWin);
+ /** Show message and progress */
+ void showMessage(const QString &message, int alignment, const QColor &color);
+
private:
/** Connect core signals to splash screen */
void subscribeToCoreSignals();
/** Disconnect core signals to splash screen */
void unsubscribeFromCoreSignals();
+
+ QPixmap pixmap;
+ QString curMessage;
+ QColor curColor;
+ int curAlignment;
};
#endif // SPLASHSCREEN_H
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 727b8dc66d..4923718341 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -6,13 +6,13 @@
#include "bitcoinunits.h"
#include "guiutil.h"
+#include "paymentserver.h"
+#include "transactionrecord.h"
#include "base58.h"
#include "db.h"
#include "main.h"
-#include "paymentserver.h"
#include "script/script.h"
-#include "transactionrecord.h"
#include "timedata.h"
#include "ui_interface.h"
#include "util.h"
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
index 7df9d1bc2d..84f88dff5a 100644
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -15,6 +15,7 @@
#include <stdio.h>
+#include <QCloseEvent>
#include <QLabel>
#include <QRegExp>
#include <QVBoxLayout>
@@ -106,18 +107,26 @@ void HelpMessageDialog::on_okButton_accepted()
/** "Shutdown" window */
+ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
+ QWidget(parent, f)
+{
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addWidget(new QLabel(
+ tr("Bitcoin Core is shutting down...") + "<br /><br />" +
+ tr("Do not shut down the computer until this window disappears.")));
+ setLayout(layout);
+}
+
void ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
{
if (!window)
return;
// Show a simple window indicating shutdown status
- QWidget *shutdownWindow = new QWidget();
- QVBoxLayout *layout = new QVBoxLayout();
- layout->addWidget(new QLabel(
- tr("Bitcoin Core is shutting down...") + "<br /><br />" +
- tr("Do not shut down the computer until this window disappears.")));
- shutdownWindow->setLayout(layout);
+ QWidget *shutdownWindow = new ShutdownWindow();
+ // We don't hold a direct pointer to the shutdown window after creation, so use
+ // Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
+ shutdownWindow->setAttribute(Qt::WA_DeleteOnClose);
shutdownWindow->setWindowTitle(window->windowTitle());
// Center shutdown window at where main window was
@@ -125,3 +134,8 @@ void ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2);
shutdownWindow->show();
}
+
+void ShutdownWindow::closeEvent(QCloseEvent *event)
+{
+ event->ignore();
+}
diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h
index 154bb70b8b..ae5045cca9 100644
--- a/src/qt/utilitydialog.h
+++ b/src/qt/utilitydialog.h
@@ -37,12 +37,16 @@ private slots:
/** "Shutdown" window */
-class ShutdownWindow : public QObject
+class ShutdownWindow : public QWidget
{
Q_OBJECT
public:
+ ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
static void showShutdownWindow(BitcoinGUI *window);
+
+protected:
+ void closeEvent(QCloseEvent *event);
};
#endif // UTILITYDIALOG_H
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 95f42eb47f..fb159d96f6 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -11,6 +11,7 @@
#include "sync.h"
#include "timedata.h"
#include "util.h"
+#include "version.h"
#include <boost/foreach.hpp>
@@ -393,6 +394,8 @@ Value getnetworkinfo(const Array& params, bool fHelp)
Object obj;
obj.push_back(Pair("version", (int)CLIENT_VERSION));
+ obj.push_back(Pair("subversion",
+ FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>())));
obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION));
obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices)));
obj.push_back(Pair("timeoffset", GetTimeOffset()));
diff --git a/src/script/script.h b/src/script/script.h
index 07a4229f85..4c9ac74b78 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -340,9 +340,7 @@ public:
CScript() { }
CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }
CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { }
-#ifndef _MSC_VER
CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { }
-#endif
CScript& operator+=(const CScript& b)
{
diff --git a/src/serialize.h b/src/serialize.h
index 57f5fd069b..447d808dee 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -921,7 +921,7 @@ public:
Init(nTypeIn, nVersionIn);
}
- CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch((char*)&vchIn.begin()[0], (char*)&vchIn.end()[0])
+ CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
{
Init(nTypeIn, nVersionIn);
}
diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp
index a3eec270ee..68232a2ff1 100644
--- a/src/test/crypto_tests.cpp
+++ b/src/test/crypto_tests.cpp
@@ -32,7 +32,7 @@ void TestVector(const Hasher &h, const In &in, const Out &out) {
size_t len = insecure_rand() % ((in.size() - pos + 1) / 2 + 1);
hasher.Write((unsigned char*)&in[pos], len);
pos += len;
- if (pos > 0 && pos + 2 * out.size() > in.size()) {
+ if (pos > 0 && pos + 2 * out.size() > in.size() && pos < in.size()) {
// Test that writing the rest at once to a copy of a hasher works.
Hasher(hasher).Write((unsigned char*)&in[pos], in.size() - pos).Finalize(&hash[0]);
BOOST_CHECK(hash == out);
diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json
index 75de4716f8..401031ad12 100644
--- a/src/test/data/script_invalid.json
+++ b/src/test/data/script_invalid.json
@@ -1,4 +1,13 @@
[
+["
+Format is: [scriptPubKey, scriptSig, flags, ... comments]
+It is evaluated as if there was a crediting coinbase transaction with two 0
+pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,
+followed by a spending transaction which spends this output as only input (and
+correct prevout hash), using the given scriptSig. All nLockTimes are 0, all
+nSequences are max.
+"],
+
["", "DEPTH", "P2SH,STRICTENC", "Test the test: we should have an empty stack after scriptSig evaluation"],
[" ", "DEPTH", "P2SH,STRICTENC", "and multiple spaces should not change that."],
[" ", "DEPTH", "P2SH,STRICTENC"],
@@ -373,5 +382,21 @@
["0 0x01 0x50", "HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL", "P2SH,STRICTENC", "OP_RESERVED in P2SH should fail"],
["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "P2SH,STRICTENC", "OP_VER in P2SH should fail"],
-["0x00", "'00' EQUAL", "P2SH,STRICTENC", "Basic OP_0 execution"]
+["0x00", "'00' EQUAL", "P2SH,STRICTENC", "Basic OP_0 execution"],
+
+["0x48 0x3045022100ea4d62e1fb351ad977596457bb01dfce58e050541784277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with wrong signature"],
+["0x47 0x304402207d09de5e34968c3f8b27d8217f173629f1106ee5216aa11d6b1f9813b3a214060220610a6ed25c704f901c6278f4f57fb11eadefdf0b22df298cfb6ce7ea84c86bf401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash using an anyonecanpay sighash"],
+["0x47 0x3044022028686fb3c8d3e5068cc9924c494fb5026df201d23340896da62fe9bb73fd9d5f02202a239609524959c4ca3651fd0cc48245b0b240862146fc579f3a962a4f46942b01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkey with wrong signature"],
+["0x47 0x3044022054cb0a3fca8694a0c231848ed9f965078148fd653e49dd4b6981fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "P2SH,STRICTENC", "P2SH with a pay to pubkeyhash inside with wrong signature"],
+["0 0x48 0x3045022100e1c4e8800bd00c9ec3cd3df0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC", "Raw multisig with one pubkey with wrong signature"],
+["0x49 0x304602220000ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with non-DER signature (too much R padding)"],
+["0x47 0x30440220ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with non-DER signature (too little R padding)"],
+["0x49 0x3046022100ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a950221003003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash with non-DER signature (too much S padding)"],
+["0x48 0x3045022100e6eda3fd34862078233463cae19f0b47995e3f892102e5b175175e92a9163cc402204bf58445819093638481084322b61a2d49b68c96fd6fea17ed494722d0d67b4f01", "0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG", "P2SH,STRICTENC", "Pay to pubkey with hybrid pubkey encoding"],
+["0x48 0x304502203b56d65863e0cdb89313043c2402f46f518c31658648151b01ec6b5b6c89206a022100d71efefb4c24fab36abb44ade106963d8114c5af1bda033faa1923f54ec4ea6a01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC,LOW_S", "Pay to pubkey with high S"],
+["0x47 0x3044022054cb0a3fca8694a0c231848fd9f965078148fd653e49dd4b6980fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "P2SH,STRICTENC", "P2SH with a pay to pubkeyhash inside with invalid signature"],
+["1 0x48 0x3045022100e1c4e8800bd00c9ec3cd3de0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC,NULLDUMMY", "Raw multisig with one pubkey with non-zero dummy"],
+
+["The End"]
+
]
diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json
index c1db4c6061..e0b527996c 100644
--- a/src/test/data/script_valid.json
+++ b/src/test/data/script_valid.json
@@ -1,4 +1,13 @@
[
+["
+Format is: [scriptPubKey, scriptSig, flags, ... comments]
+It is evaluated as if there was a crediting coinbase transaction with two 0
+pushes as scriptSig, and one output of 0 satoshi and given scriptPubKey,
+followed by a spending transaction which spends this output as only input (and
+correct prevout hash), using the given scriptSig. All nLockTimes are 0, all
+nSequences are max.
+"],
+
["", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "Test the test: we should have an empty stack after scriptSig evaluation"],
[" ", "DEPTH 0 EQUAL", "P2SH,STRICTENC", "and multiple spaces should not change that."],
[" ", "DEPTH 0 EQUAL", "P2SH,STRICTENC"],
@@ -518,5 +527,20 @@
"P2SH,STRICTENC",
"Basic PUSHDATA1 signedness check"],
-["0x00", "SIZE 0 EQUAL", "P2SH,STRICTENC", "Basic OP_0 execution"]
+["0x00", "SIZE 0 EQUAL", "P2SH,STRICTENC", "Basic OP_0 execution"],
+
+["0x48 0x3045022100ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkeyhash"],
+["0x47 0x304402207d09de5e34968c3f8b27d8217f173629f1106ee5216aa11d6b1f9813b3a214060220610a6ed25c704f901c6278f4f57fb11eadefdf0b22df298cfb6ce7ea84c86bf481 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH,STRICTENC", "Anyonecanpay pay to pubkeyhash"],
+["0x47 0x3044022028686fb3c8d3e5069cc9924c494fb5026df201d23340896da62fe9bb73fd9d5f02202a239609524959c4ca3651fd0cc48245b0b240862146fc579f3a962a4f46942b01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC", "Normal pay to pubkey"],
+["0x47 0x3044022054cb0a3fca8694a0c231848ed9f965078148fd653e49dd4b6980fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "P2SH,STRICTENC", "P2SH with a pay to pubkeyhash inside"],
+["0 0x48 0x3045022100e1c4e8800bd00c9ec3cd3de0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC", "Raw multisig with one pubkey"],
+["0x49 0x304602220000ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH", "Normal pay to pubkeyhash with non-DER signature (too much R padding)"],
+["0x47 0x30440220ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a9502203003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH", "Normal pay to pubkeyhash with non-DER signature (too little R padding)"],
+["0x49 0x3046022100ea4d62e1fb351ad977596457bb01dfce58e050541774277bd825c33bd98c2a950221003003347cf04573be4dc786c3fc5e7db09821565bf45c7d60160709b962f0398401 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "DUP HASH160 0x14 0x751e76e8199196d454941c45d1b3a323f1433bd6 EQUALVERIFY CHECKSIG", "P2SH", "Normal pay to pubkeyhash with non-DER signature (too much S padding)"],
+["0x48 0x3045022100e6eda3fd34862078233463cae19f0b47995e3f892102e5b175175e92a9163cc402204bf58445819093638481084322b61a2d49b68c96fd6fea17ed494722d0d67b4f01", "0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG", "P2SH", "Pay to pubkey with hybrid pubkey encoding"],
+["0x48 0x304502203b56d65863e0cdb89313043c2402f46f518c31658648151b01ec6b5b6c89206a022100d71efefb4c24fab36abb44ade106963d8114c5af1bda033faa1923f54ec4ea6a01", "0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG", "P2SH,STRICTENC", "Pay to pubkey with high S"],
+["0x47 0x3044022054cb0a3fca8694a0c231848fd9f965078148fd653e49dd4b6980fadac0f5ba0702204085be5af427d4561f13a07fd5a1c5ab0ff02126e9ba191448f5a9dae0da585301 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x19 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac", "HASH160 0x14 0xcd7b44d0b03f2d026d1e586d7ae18903b0d385f6 EQUAL", "STRICTENC", "P2SH with a pay to pubkeyhash inside with invalid signature"],
+["1 0x48 0x3045022100e1c4e8800bd00c9ec3cd3de0e53e63bc5e8c018d0b68099a652f0b121f1a7e020220108dab275be7d1358530d3451d48aed747af77cc54e0423cbae5c572b2e1abb801", "1 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 1 CHECKMULTISIG", "P2SH,STRICTENC", "Raw multisig with one pubkey with non-zero dummy"],
+
+["The End"]
]
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index cb543a0cf1..178b35fa2d 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -52,6 +52,41 @@ read_json(const std::string& jsondata)
BOOST_AUTO_TEST_SUITE(script_tests)
+CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey)
+{
+ CMutableTransaction txCredit;
+ txCredit.nVersion = 1;
+ txCredit.nLockTime = 0;
+ txCredit.vin.resize(1);
+ txCredit.vout.resize(1);
+ txCredit.vin[0].prevout.SetNull();
+ txCredit.vin[0].scriptSig = CScript() << CScriptNum(0) << CScriptNum(0);
+ txCredit.vin[0].nSequence = std::numeric_limits<unsigned int>::max();
+ txCredit.vout[0].scriptPubKey = scriptPubKey;
+ txCredit.vout[0].nValue = 0;
+
+ return txCredit;
+}
+
+CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScript& scriptPubKey)
+{
+ CMutableTransaction txCredit = BuildCreditingTransaction(scriptPubKey);
+
+ CMutableTransaction txSpend;
+ txSpend.nVersion = 1;
+ txSpend.nLockTime = 0;
+ txSpend.vin.resize(1);
+ txSpend.vout.resize(1);
+ txSpend.vin[0].prevout.hash = txCredit.GetHash();
+ txSpend.vin[0].prevout.n = 0;
+ txSpend.vin[0].scriptSig = scriptSig;
+ txSpend.vin[0].nSequence = std::numeric_limits<unsigned int>::max();
+ txSpend.vout[0].scriptPubKey = CScript();
+ txSpend.vout[0].nValue = 0;
+
+ return txSpend;
+}
+
BOOST_AUTO_TEST_CASE(script_valid)
{
// Read tests from test/data/script_valid.json
@@ -67,7 +102,9 @@ BOOST_AUTO_TEST_CASE(script_valid)
string strTest = write_string(tv, false);
if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
{
- BOOST_ERROR("Bad test: " << strTest);
+ if (test.size() != 1) {
+ BOOST_ERROR("Bad test: " << strTest);
+ }
continue;
}
string scriptSigString = test[0].get_str();
@@ -77,7 +114,7 @@ BOOST_AUTO_TEST_CASE(script_valid)
unsigned int scriptflags = ParseScriptFlags(test[2].get_str());
CTransaction tx;
- BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags), strTest);
+ BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, BuildSpendingTransaction(scriptSig, scriptPubKey), 0, scriptflags), strTest);
}
}
@@ -90,9 +127,11 @@ BOOST_AUTO_TEST_CASE(script_invalid)
{
Array test = tv.get_array();
string strTest = write_string(tv, false);
- if (test.size() < 2) // Allow size > 2; extra stuff ignored (useful for comments)
+ if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments)
{
- BOOST_ERROR("Bad test: " << strTest);
+ if (test.size() != 1) {
+ BOOST_ERROR("Bad test: " << strTest);
+ }
continue;
}
string scriptSigString = test[0].get_str();
@@ -102,7 +141,7 @@ BOOST_AUTO_TEST_CASE(script_invalid)
unsigned int scriptflags = ParseScriptFlags(test[2].get_str());
CTransaction tx;
- BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags), strTest);
+ BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, BuildSpendingTransaction(scriptSig, scriptPubKey), 0, scriptflags), strTest);
}
}
diff --git a/src/util.cpp b/src/util.cpp
index 0ac0f70a79..f387fce8c7 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -472,6 +472,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
ClearDatadirCache();
}
+#ifndef WIN32
boost::filesystem::path GetPidFile()
{
boost::filesystem::path pathPidFile(GetArg("-pid", "bitcoind.pid"));
@@ -479,7 +480,6 @@ boost::filesystem::path GetPidFile()
return pathPidFile;
}
-#ifndef WIN32
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
{
FILE* file = fopen(path.string().c_str(), "w");
diff --git a/src/util.h b/src/util.h
index e72c99adc7..4b2415278b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -93,8 +93,8 @@ bool TryCreateDirectory(const boost::filesystem::path& p);
boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
boost::filesystem::path GetConfigFile();
-boost::filesystem::path GetPidFile();
#ifndef WIN32
+boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 6bfaec3681..e69f59aacd 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -646,7 +646,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
CWalletTx wtx(this,tx);
// Get merkle branch if transaction was found in a block
if (pblock)
- wtx.SetMerkleBranch(pblock);
+ wtx.SetMerkleBranch(*pblock);
return AddToWallet(wtx);
}
}
@@ -2229,48 +2229,34 @@ CWalletKey::CWalletKey(int64_t nExpires)
nTimeExpires = nExpires;
}
-int CMerkleTx::SetMerkleBranch(const CBlock* pblock)
+int CMerkleTx::SetMerkleBranch(const CBlock& block)
{
AssertLockHeld(cs_main);
CBlock blockTmp;
- if (pblock == NULL) {
- CCoins coins;
- if (pcoinsTip->GetCoins(GetHash(), coins)) {
- CBlockIndex *pindex = chainActive[coins.nHeight];
- if (pindex) {
- if (!ReadBlockFromDisk(blockTmp, pindex))
- return 0;
- pblock = &blockTmp;
- }
- }
- }
-
- if (pblock) {
- // Update the tx's hashBlock
- hashBlock = pblock->GetHash();
-
- // Locate the transaction
- for (nIndex = 0; nIndex < (int)pblock->vtx.size(); nIndex++)
- if (pblock->vtx[nIndex] == *(CTransaction*)this)
- break;
- if (nIndex == (int)pblock->vtx.size())
- {
- vMerkleBranch.clear();
- nIndex = -1;
- LogPrintf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
- return 0;
- }
+ // Update the tx's hashBlock
+ hashBlock = block.GetHash();
- // Fill in merkle branch
- vMerkleBranch = pblock->GetMerkleBranch(nIndex);
+ // Locate the transaction
+ for (nIndex = 0; nIndex < (int)block.vtx.size(); nIndex++)
+ if (block.vtx[nIndex] == *(CTransaction*)this)
+ break;
+ if (nIndex == (int)block.vtx.size())
+ {
+ vMerkleBranch.clear();
+ nIndex = -1;
+ LogPrintf("ERROR: SetMerkleBranch() : couldn't find tx in block\n");
+ return 0;
}
+ // Fill in merkle branch
+ vMerkleBranch = block.GetMerkleBranch(nIndex);
+
// Is the tx in a block that's in the main chain
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end())
return 0;
- CBlockIndex* pindex = (*mi).second;
+ const CBlockIndex* pindex = (*mi).second;
if (!pindex || !chainActive.Contains(pindex))
return 0;
diff --git a/src/wallet.h b/src/wallet.h
index 3461446b8b..fde87a8a2f 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -504,7 +504,7 @@ public:
READWRITE(nIndex);
}
- int SetMerkleBranch(const CBlock* pblock=NULL);
+ int SetMerkleBranch(const CBlock& block);
// Return depth of transaction in blockchain:
// -1 : not in blockchain, and not in memory pool (conflicted transaction)