X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Finit.cpp;h=44e4f807351763f760c0c272e68ea7bf78b81e8e;hb=75b1972c9beab9c62a4f1d7c1162aba6dd658d4f;hp=3fe6d1b091c52f014a819bd7b90d50b27b236303;hpb=00d971e1e7c73452277829de86fbd7e37f99808c;p=novacoin.git diff --git a/src/init.cpp b/src/init.cpp index 3fe6d1b..44e4f80 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2011-2012 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "db.h" #include "walletdb.h" #include "bitcoinrpc.h" @@ -9,6 +10,7 @@ #include "init.h" #include "util.h" #include "ui_interface.h" +#include "checkpoints.h" #include #include #include @@ -36,6 +38,17 @@ void ExitTimeout(void* parg) #endif } +void StartShutdown() +{ +#ifdef QT_GUI + // ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards) + QueueShutdown(); +#else + // Without UI, Shutdown() can simply be started in a new thread + CreateThread(Shutdown, NULL); +#endif +} + void Shutdown(void* parg) { static CCriticalSection cs_Shutdown; @@ -62,9 +75,12 @@ void Shutdown(void* parg) delete pwalletMain; CreateThread(ExitTimeout, NULL); Sleep(50); - printf("Bitcoin exiting\n\n"); + printf("PPCoin exiting\n\n"); fExit = true; +#ifndef QT_GUI + // ensure non UI client get's exited here, but let Bitcoin-Qt reach return 0; in bitcoin.cpp exit(0); +#endif } else { @@ -161,15 +177,15 @@ bool AppInit2(int argc, char* argv[]) if (mapArgs.count("-?") || mapArgs.count("--help")) { string strUsage = string() + - _("Bitcoin version") + " " + FormatFullVersion() + "\n\n" + + _("PPCoin version") + " " + FormatFullVersion() + "\n\n" + _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" + - " bitcoind [options] \t " + "\n" + - " bitcoind [options] [params]\t " + _("Send command to -server or bitcoind") + "\n" + - " bitcoind [options] help \t\t " + _("List commands") + "\n" + - " bitcoind [options] help \t\t " + _("Get help for a command") + "\n" + + " ppcoind [options] \t " + "\n" + + " ppcoind [options] [params]\t " + _("Send command to -server or ppcoind") + "\n" + + " ppcoind [options] help \t\t " + _("List commands") + "\n" + + " ppcoind [options] help \t\t " + _("Get help for a command") + "\n" + _("Options:") + "\n" + - " -conf= \t\t " + _("Specify configuration file (default: bitcoin.conf)") + "\n" + - " -pid= \t\t " + _("Specify pid file (default: bitcoind.pid)") + "\n" + + " -conf= \t\t " + _("Specify configuration file (default: ppcoin.conf)") + "\n" + + " -pid= \t\t " + _("Specify pid file (default: ppcoind.pid)") + "\n" + " -gen \t\t " + _("Generate coins") + "\n" + " -gen=0 \t\t " + _("Don't generate coins") + "\n" + " -min \t\t " + _("Start minimized") + "\n" + @@ -180,11 +196,10 @@ bool AppInit2(int argc, char* argv[]) " -timeout= \t " + _("Specify connection timeout (in milliseconds)") + "\n" + " -proxy= \t " + _("Connect through socks4 proxy") + "\n" + " -dns \t " + _("Allow DNS lookups for addnode and connect") + "\n" + - " -port= \t\t " + _("Listen for connections on (default: 8333 or testnet: 18333)") + "\n" + + " -port= \t\t " + _("Listen for connections on (default: 9901 or testnet: 9903)") + "\n" + " -maxconnections=\t " + _("Maintain at most connections to peers (default: 125)") + "\n" + " -addnode= \t " + _("Add a node to connect to and attempt to keep the connection open") + "\n" + " -connect= \t\t " + _("Connect only to the specified node") + "\n" + - " -irc \t " + _("Find peers using internet relay chat (default: 0)") + "\n" + " -listen \t " + _("Accept connections from outside (default: 1)") + "\n" + #ifdef QT_GUI " -lang= \t\t " + _("Set language, for example \"de_DE\" (default: system locale)") + "\n" + @@ -218,7 +233,7 @@ bool AppInit2(int argc, char* argv[]) #endif " -rpcuser= \t " + _("Username for JSON-RPC connections") + "\n" + " -rpcpassword=\t " + _("Password for JSON-RPC connections") + "\n" + - " -rpcport= \t\t " + _("Listen for JSON-RPC connections on (default: 8332)") + "\n" + + " -rpcport= \t\t " + _("Listen for JSON-RPC connections on (default: 9902)") + "\n" + " -rpcallowip= \t\t " + _("Allow JSON-RPC connections from specified IP address") + "\n" + " -rpcconnect= \t " + _("Send commands to node running on (default: 127.0.0.1)") + "\n" + " -blocknotify= " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" + @@ -314,7 +329,7 @@ bool AppInit2(int argc, char* argv[]) if (!fDebug) ShrinkDebugFile(); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str()); + printf("PPCoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str()); printf("Default data directory %s\n", GetDefaultDataDir().string().c_str()); if (GetBoolArg("-loadblockindextest")) @@ -332,7 +347,7 @@ bool AppInit2(int argc, char* argv[]) static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); if (!lock.try_lock()) { - ThreadSafeMessageBox(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), GetDataDir().string().c_str()), _("Bitcoin"), wxOK|wxMODAL); + ThreadSafeMessageBox(strprintf(_("Cannot obtain a lock on data directory %s. PPCoin is probably already running."), GetDataDir().string().c_str()), _("PPCoin"), wxOK|wxMODAL); return false; } @@ -341,7 +356,7 @@ bool AppInit2(int argc, char* argv[]) // Load data files // if (fDaemon) - fprintf(stdout, "bitcoin server starting\n"); + fprintf(stdout, "ppcoin server starting\n"); int64 nStart; InitMessage(_("Loading addresses...")); @@ -378,12 +393,12 @@ bool AppInit2(int argc, char* argv[]) if (nLoadWalletRet == DB_CORRUPT) strErrors << _("Error loading wallet.dat: Wallet corrupted") << "\n"; else if (nLoadWalletRet == DB_TOO_NEW) - strErrors << _("Error loading wallet.dat: Wallet requires newer version of Bitcoin") << "\n"; + strErrors << _("Error loading wallet.dat: Wallet requires newer version of PPCoin") << "\n"; else if (nLoadWalletRet == DB_NEED_REWRITE) { - strErrors << _("Wallet needed to be rewritten: restart Bitcoin to complete") << "\n"; + strErrors << _("Wallet needed to be rewritten: restart PPCoin to complete") << "\n"; printf("%s", strErrors.str().c_str()); - ThreadSafeMessageBox(strErrors.str(), _("Bitcoin"), wxOK | wxICON_ERROR | wxMODAL); + ThreadSafeMessageBox(strErrors.str(), _("PPCoin"), wxOK | wxICON_ERROR | wxMODAL); return false; } else @@ -455,7 +470,7 @@ bool AppInit2(int argc, char* argv[]) if (!strErrors.str().empty()) { - ThreadSafeMessageBox(strErrors.str(), _("Bitcoin"), wxOK | wxICON_ERROR | wxMODAL); + ThreadSafeMessageBox(strErrors.str(), _("PPCoin"), wxOK | wxICON_ERROR | wxMODAL); return false; } @@ -511,7 +526,7 @@ bool AppInit2(int argc, char* argv[]) addrProxy = CService(mapArgs["-proxy"], 9050); if (!addrProxy.IsValid()) { - ThreadSafeMessageBox(_("Invalid -proxy address"), _("Bitcoin"), wxOK | wxMODAL); + ThreadSafeMessageBox(_("Invalid -proxy address"), _("PPCcoin"), wxOK | wxMODAL); return false; } } @@ -542,7 +557,7 @@ bool AppInit2(int argc, char* argv[]) std::string strError; if (!BindListenPort(strError)) { - ThreadSafeMessageBox(strError, _("Bitcoin"), wxOK | wxMODAL); + ThreadSafeMessageBox(strError, _("PPCoin"), wxOK | wxMODAL); return false; } } @@ -560,13 +575,29 @@ bool AppInit2(int argc, char* argv[]) if (mapArgs.count("-paytxfee")) { - if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee)) + if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee) || nTransactionFee < MIN_TX_FEE) { - ThreadSafeMessageBox(_("Invalid amount for -paytxfee="), _("Bitcoin"), wxOK | wxMODAL); + ThreadSafeMessageBox(_("Invalid amount for -paytxfee="), _("PPCoin"), wxOK | wxMODAL); return false; } if (nTransactionFee > 0.25 * COIN) - ThreadSafeMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), _("Bitcoin"), wxOK | wxICON_EXCLAMATION | wxMODAL); + ThreadSafeMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), _("PPCoin"), wxOK | wxICON_EXCLAMATION | wxMODAL); + } + + if (mapArgs.count("-reservebalance")) // ppcoin: reserve balance amount + { + int64 nReserveBalance = 0; + if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) + { + ThreadSafeMessageBox(_("Invalid amount for -reservebalance="), _("PPCoin"), wxOK | wxMODAL); + return false; + } + } + + if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key + { + if (!Checkpoints::SetCheckpointPrivKey(GetArg("-checkpointkey", ""))) + ThreadSafeMessageBox(_("Unable to sign checkpoint, wrong checkpointkey?\n"), _("PPCoin"), wxOK | wxMODAL); } // @@ -578,7 +609,7 @@ bool AppInit2(int argc, char* argv[]) RandAddSeedPerfmon(); if (!CreateThread(StartNode, NULL)) - ThreadSafeMessageBox(_("Error: CreateThread(StartNode) failed"), _("Bitcoin"), wxOK | wxMODAL); + ThreadSafeMessageBox(_("Error: CreateThread(StartNode) failed"), _("PPCoin"), wxOK | wxMODAL); if (fServer) CreateThread(ThreadRPCServer, NULL);