Browse Source

make genesis block valid and disable gui

miguelfreitas
Miguel Freitas 12 years ago
parent
commit
2718ee55bf
  1. 8
      src/chainparams.cpp
  2. 2
      src/main.cpp
  3. 89
      src/qt/bitcoin.cpp
  4. 169
      twister-qt.pro

8
src/chainparams.cpp

@ -32,7 +32,8 @@ public: @@ -32,7 +32,8 @@ public:
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
nDefaultPort = 28333;
nRPCPort = 28332;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 32);
//bnProofOfWorkLimit = CBigNum(~uint256(0) >> 32);
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 1);
nSubsidyHalvingInterval = 210000;
// Build the genesis block. Note that the output of the genesis coinbase cannot
@ -51,13 +52,14 @@ public: @@ -51,13 +52,14 @@ public:
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1231006505;
//genesis.nBits = 0x1d00ffff;
genesis.nBits = 0x207fffff;
genesis.nNonce = 0;
genesis.nNonce = 2;
hashGenesisBlock = genesis.GetHash();
printf("hashGenesisBlock %s\n", hashGenesisBlock.ToString().c_str());
printf("genesis.hashMerkleRoot %s\n", genesis.hashMerkleRoot.ToString().c_str());
//assert(hashGenesisBlock == uint256("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
//assert(hashGenesisBlock == uint256("0xa63d06dc9817b06f16f6ccfbe558400366eb2507825e29667c910decfaadd2b9"));
//assert(genesis.hashMerkleRoot == uint256("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
//vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be"));

2
src/main.cpp

@ -1381,6 +1381,8 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits) @@ -1381,6 +1381,8 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
CBigNum bnTarget;
bnTarget.SetCompact(nBits);
//printf("CheckProofOfWork %08x %s %s\n", nBits, bnTarget.GetHex().c_str(), Params().ProofOfWorkLimit().GetHex().c_str());
//printf("hash-bits %s\n", (hash-bnTarget.getuint256()).GetHex().c_str() );
// Check range
if (bnTarget <= 0 || bnTarget > Params().ProofOfWorkLimit())
return error("CheckProofOfWork() : nBits below minimum work");

89
src/qt/bitcoin.cpp

@ -4,17 +4,17 @@ @@ -4,17 +4,17 @@
#include <QApplication>
#include "bitcoingui.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "guiconstants.h"
//#include "bitcoingui.h"
//#include "clientmodel.h"
//#include "walletmodel.h"
//#include "optionsmodel.h"
//#include "guiutil.h"
//#include "guiconstants.h"
#include "init.h"
#include "util.h"
#include "ui_interface.h"
#include "paymentserver.h"
#include "splashscreen.h"
//#include "splashscreen.h"
#include <QMessageBox>
#if QT_VERSION < 0x050000
@ -37,16 +37,16 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets) @@ -37,16 +37,16 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif
// Declare meta types used for QMetaObject::invokeMethod
Q_DECLARE_METATYPE(bool*)
//Q_DECLARE_METATYPE(bool*)
// Need a global reference for the notifications to find the GUI
static BitcoinGUI *guiref;
static SplashScreen *splashref;
//static BitcoinGUI *guiref;
//static SplashScreen *splashref;
static bool ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
{
// Message from network thread
if(guiref)
/*if(guiref)
{
bool modal = (style & CClientUIInterface::MODAL);
bool ret = false;
@ -59,7 +59,7 @@ static bool ThreadSafeMessageBox(const std::string& message, const std::string& @@ -59,7 +59,7 @@ static bool ThreadSafeMessageBox(const std::string& message, const std::string&
Q_ARG(bool*, &ret));
return ret;
}
else
else*/
{
printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
@ -69,28 +69,30 @@ static bool ThreadSafeMessageBox(const std::string& message, const std::string& @@ -69,28 +69,30 @@ static bool ThreadSafeMessageBox(const std::string& message, const std::string&
static bool ThreadSafeAskFee(int64 nFeeRequired)
{
if(!guiref)
return false;
//if(!guiref)
// return false;
/*
if(nFeeRequired < CTransaction::nMinTxFee || nFeeRequired <= nTransactionFee || fDaemon)
return true;
*/
bool payFee = false;
/*
QMetaObject::invokeMethod(guiref, "askFee", GUIUtil::blockingGUIThreadConnection(),
Q_ARG(qint64, nFeeRequired),
Q_ARG(bool*, &payFee));
*/
return payFee;
}
static void InitMessage(const std::string &message)
{
/*
if(splashref)
{
splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(55,55,55));
qApp->processEvents();
}
*/
printf("init message: %s\n", message.c_str());
}
@ -107,13 +109,14 @@ static std::string Translate(const char* psz) @@ -107,13 +109,14 @@ static std::string Translate(const char* psz)
static void handleRunawayException(std::exception *e)
{
PrintExceptionContinue(e, "Runaway exception");
QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning));
//QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning));
exit(1);
}
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
//fHaveGUI = true;
fHaveGUI = true;
// Command-line options take precedence:
@ -129,16 +132,16 @@ int main(int argc, char *argv[]) @@ -129,16 +132,16 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
// Register meta types used for QMetaObject::invokeMethod
qRegisterMetaType< bool* >();
//qRegisterMetaType< bool* >();
// Do this early as we don't want to bother initializing if we are just calling IPC
// ... but do it after creating app, so QCoreApplication::arguments is initialized:
if (PaymentServer::ipcSendCommandLine())
exit(0);
PaymentServer* paymentServer = new PaymentServer(&app);
//if (PaymentServer::ipcSendCommandLine())
// exit(0);
//PaymentServer* paymentServer = new PaymentServer(&app);
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
//app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
// ... then bitcoin.conf:
if (!boost::filesystem::is_directory(GetDataDir(false)))
@ -161,7 +164,7 @@ int main(int argc, char *argv[]) @@ -161,7 +164,7 @@ int main(int argc, char *argv[])
QApplication::setApplicationName("Bitcoin-Qt");
// ... then GUI settings:
OptionsModel optionsModel;
//OptionsModel optionsModel;
// Get desired locale (e.g. "de_DE") from command line or use system locale
QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString()));
@ -200,11 +203,17 @@ int main(int argc, char *argv[]) @@ -200,11 +203,17 @@ int main(int argc, char *argv[])
// but before showing splash screen.
if (mapArgs.count("-?") || mapArgs.count("--help"))
{
GUIUtil::HelpMessageBox help;
help.showOrPrint();
//GUIUtil::HelpMessageBox help;
//help.showOrPrint();
QString coreOptions = QString::fromStdString(HelpMessage());
QString strUsage = QString("twister") + "\n" + coreOptions + "\n";
fprintf(stdout, "%s", strUsage.toStdString().c_str());
return 1;
}
/*
SplashScreen splash(QPixmap(), 0);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false))
{
@ -212,6 +221,7 @@ int main(int argc, char *argv[]) @@ -212,6 +221,7 @@ int main(int argc, char *argv[])
splash.setAutoFillBackground(true);
splashref = &splash;
}
*/
app.processEvents();
app.setQuitOnLastWindowClosed(false);
@ -221,30 +231,31 @@ int main(int argc, char *argv[]) @@ -221,30 +231,31 @@ int main(int argc, char *argv[])
#ifndef Q_OS_MAC
// Regenerate startup link, to fix links to old versions
// OSX: makes no sense on mac and might also scan/mount external (and sleeping) volumes (can take up some secs)
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(true);
//if (GUIUtil::GetStartOnSystemStartup())
// GUIUtil::SetStartOnSystemStartup(true);
#endif
boost::thread_group threadGroup;
/*
BitcoinGUI window(GetBoolArg("-testnet", false), 0);
guiref = &window;
QTimer* pollShutdownTimer = new QTimer(guiref);
QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
pollShutdownTimer->start(200);
*/
if(AppInit2(threadGroup))
{
{
// Put this in a block, so that the Model objects are cleaned up before
// calling Shutdown().
optionsModel.Upgrade(); // Must be done after AppInit2
//optionsModel.Upgrade(); // Must be done after AppInit2
/*
if (splashref)
splash.finish(&window);
*/
/*
ClientModel clientModel(&optionsModel);
WalletModel walletModel(pwalletMain, &optionsModel);
@ -261,18 +272,18 @@ int main(int argc, char *argv[]) @@ -261,18 +272,18 @@ int main(int argc, char *argv[])
{
window.show();
}
*/
// Now that initialization/startup is done, process any command-line
// bitcoin: URIs
QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString)));
QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
//QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString)));
//QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
app.exec();
window.hide();
window.setClientModel(0);
window.removeAllWallets();
guiref = 0;
//window.hide();
//window.setClientModel(0);
//window.removeAllWallets();
//guiref = 0;
}
// Shutdown the core and its threads, but don't exit Bitcoin-Qt here
threadGroup.interrupt_all();

169
twister-qt.pro

@ -133,16 +133,7 @@ QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wform @@ -133,16 +133,7 @@ QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wform
# Input
DEPENDPATH += src src/json src/qt
HEADERS += src/qt/bitcoingui.h \
src/qt/transactiontablemodel.h \
src/qt/addresstablemodel.h \
src/qt/optionsdialog.h \
src/qt/sendcoinsdialog.h \
src/qt/addressbookpage.h \
src/qt/signverifymessagedialog.h \
src/qt/aboutdialog.h \
src/qt/editaddressdialog.h \
src/qt/bitcoinaddressvalidator.h \
HEADERS += \
src/alert.h \
src/addrman.h \
src/base58.h \
@ -175,38 +166,13 @@ HEADERS += src/qt/bitcoingui.h \ @@ -175,38 +166,13 @@ HEADERS += src/qt/bitcoingui.h \
src/json/json_spirit_reader.h \
src/json/json_spirit_error_position.h \
src/json/json_spirit.h \
src/qt/clientmodel.h \
src/qt/guiutil.h \
src/qt/transactionrecord.h \
src/qt/guiconstants.h \
src/qt/optionsmodel.h \
src/qt/monitoreddatamapper.h \
src/qt/transactiondesc.h \
src/qt/transactiondescdialog.h \
src/qt/bitcoinamountfield.h \
src/wallet.h \
src/keystore.h \
src/qt/transactionfilterproxy.h \
src/qt/transactionview.h \
src/qt/walletmodel.h \
src/qt/walletview.h \
src/qt/walletstack.h \
src/qt/walletframe.h \
src/bitcoinrpc.h \
src/qt/overviewpage.h \
src/qt/csvmodelwriter.h \
src/crypter.h \
src/qt/sendcoinsentry.h \
src/qt/qvalidatedlineedit.h \
src/qt/bitcoinunits.h \
src/qt/qvaluecombobox.h \
src/qt/askpassphrasedialog.h \
src/protocol.h \
src/qt/notificator.h \
src/qt/paymentserver.h \
src/allocators.h \
src/ui_interface.h \
src/qt/rpcconsole.h \
src/version.h \
src/netbase.h \
src/clientversion.h \
@ -214,19 +180,45 @@ HEADERS += src/qt/bitcoingui.h \ @@ -214,19 +180,45 @@ HEADERS += src/qt/bitcoingui.h \
src/leveldb.h \
src/threadsafety.h \
src/limitedmap.h \
src/qt/splashscreen.h
# src/qt/bitcoingui.h
# src/qt/transactiontablemodel.h \
# src/qt/addresstablemodel.h \
# src/qt/optionsdialog.h \
# src/qt/sendcoinsdialog.h \
# src/qt/addressbookpage.h \
# src/qt/signverifymessagedialog.h \
# src/qt/aboutdialog.h \
# src/qt/editaddressdialog.h \
# src/qt/bitcoinaddressvalidator.h \
# src/qt/clientmodel.h \
# src/qt/guiutil.h \
# src/qt/transactionrecord.h \
# src/qt/guiconstants.h \
# src/qt/optionsmodel.h \
# src/qt/monitoreddatamapper.h \
# src/qt/transactiondesc.h \
# src/qt/transactiondescdialog.h \
# src/qt/bitcoinamountfield.h \
# src/qt/transactionfilterproxy.h \
# src/qt/transactionview.h \
# src/qt/walletmodel.h \
# src/qt/walletview.h \
# src/qt/walletstack.h \
# src/qt/walletframe.h \
# src/qt/overviewpage.h \
# src/qt/csvmodelwriter.h \
# src/qt/sendcoinsentry.h \
# src/qt/qvalidatedlineedit.h \
# src/qt/bitcoinunits.h \
# src/qt/qvaluecombobox.h \
# src/qt/askpassphrasedialog.h \
# src/qt/notificator.h \
# src/qt/paymentserver.h \
# src/qt/rpcconsole.h \
# src/qt/splashscreen.h
SOURCES += src/qt/bitcoin.cpp \
src/qt/bitcoingui.cpp \
src/qt/transactiontablemodel.cpp \
src/qt/addresstablemodel.cpp \
src/qt/optionsdialog.cpp \
src/qt/sendcoinsdialog.cpp \
src/qt/addressbookpage.cpp \
src/qt/signverifymessagedialog.cpp \
src/qt/aboutdialog.cpp \
src/qt/editaddressdialog.cpp \
src/qt/bitcoinaddressvalidator.cpp \
src/alert.cpp \
src/chainparams.cpp \
src/version.cpp \
@ -245,23 +237,8 @@ SOURCES += src/qt/bitcoin.cpp \ @@ -245,23 +237,8 @@ SOURCES += src/qt/bitcoin.cpp \
src/addrman.cpp \
src/db.cpp \
src/walletdb.cpp \
src/qt/clientmodel.cpp \
src/qt/guiutil.cpp \
src/qt/transactionrecord.cpp \
src/qt/optionsmodel.cpp \
src/qt/monitoreddatamapper.cpp \
src/qt/transactiondesc.cpp \
src/qt/transactiondescdialog.cpp \
src/qt/bitcoinstrings.cpp \
src/qt/bitcoinamountfield.cpp \
src/wallet.cpp \
src/keystore.cpp \
src/qt/transactionfilterproxy.cpp \
src/qt/transactionview.cpp \
src/qt/walletmodel.cpp \
src/qt/walletview.cpp \
src/qt/walletstack.cpp \
src/qt/walletframe.cpp \
src/bitcoinrpc.cpp \
src/rpcdump.cpp \
src/rpcnet.cpp \
@ -269,36 +246,62 @@ SOURCES += src/qt/bitcoin.cpp \ @@ -269,36 +246,62 @@ SOURCES += src/qt/bitcoin.cpp \
src/rpcwallet.cpp \
src/rpcblockchain.cpp \
src/rpcrawtransaction.cpp \
src/qt/overviewpage.cpp \
src/qt/csvmodelwriter.cpp \
src/crypter.cpp \
src/qt/sendcoinsentry.cpp \
src/qt/qvalidatedlineedit.cpp \
src/qt/bitcoinunits.cpp \
src/qt/qvaluecombobox.cpp \
src/qt/askpassphrasedialog.cpp \
src/protocol.cpp \
src/qt/notificator.cpp \
src/qt/paymentserver.cpp \
src/qt/rpcconsole.cpp \
src/noui.cpp \
src/leveldb.cpp \
src/txdb.cpp \
src/qt/splashscreen.cpp
# src/qt/guiutil.cpp \
# src/qt/bitcoingui.cpp \
# src/qt/transactiontablemodel.cpp \
# src/qt/addresstablemodel.cpp \
# src/qt/optionsdialog.cpp \
# src/qt/sendcoinsdialog.cpp \
# src/qt/addressbookpage.cpp \
# src/qt/signverifymessagedialog.cpp \
# src/qt/aboutdialog.cpp \
# src/qt/editaddressdialog.cpp \
# src/qt/bitcoinaddressvalidator.cpp \
# src/qt/clientmodel.cpp \
# src/qt/transactionrecord.cpp \
# src/qt/optionsmodel.cpp \
# src/qt/monitoreddatamapper.cpp \
# src/qt/transactiondesc.cpp \
# src/qt/transactiondescdialog.cpp \
# src/qt/bitcoinstrings.cpp \
# src/qt/bitcoinamountfield.cpp \
# src/qt/transactionfilterproxy.cpp \
# src/qt/transactionview.cpp \
# src/qt/walletmodel.cpp \
# src/qt/walletview.cpp \
# src/qt/walletstack.cpp \
# src/qt/walletframe.cpp \
# src/qt/overviewpage.cpp \
# src/qt/csvmodelwriter.cpp \
# src/qt/sendcoinsentry.cpp \
# src/qt/qvalidatedlineedit.cpp \
# src/qt/bitcoinunits.cpp \
# src/qt/qvaluecombobox.cpp \
# src/qt/askpassphrasedialog.cpp \
# src/qt/notificator.cpp \
# src/qt/paymentserver.cpp \
# src/qt/rpcconsole.cpp \
# src/qt/splashscreen.cpp
RESOURCES += src/qt/bitcoin.qrc
FORMS += src/qt/forms/sendcoinsdialog.ui \
src/qt/forms/addressbookpage.ui \
src/qt/forms/signverifymessagedialog.ui \
src/qt/forms/aboutdialog.ui \
src/qt/forms/editaddressdialog.ui \
src/qt/forms/transactiondescdialog.ui \
src/qt/forms/overviewpage.ui \
src/qt/forms/sendcoinsentry.ui \
src/qt/forms/askpassphrasedialog.ui \
src/qt/forms/rpcconsole.ui \
src/qt/forms/optionsdialog.ui
#FORMS += src/qt/forms/sendcoinsdialog.ui \
# src/qt/forms/addressbookpage.ui \
# src/qt/forms/signverifymessagedialog.ui \
# src/qt/forms/aboutdialog.ui \
# src/qt/forms/editaddressdialog.ui \
# src/qt/forms/transactiondescdialog.ui \
# src/qt/forms/overviewpage.ui \
# src/qt/forms/sendcoinsentry.ui \
# src/qt/forms/askpassphrasedialog.ui \
# src/qt/forms/rpcconsole.ui \
# src/qt/forms/optionsdialog.ui
contains(USE_QRCODE, 1) {
HEADERS += src/qt/qrcodedialog.h

Loading…
Cancel
Save