6 #if defined(HAVE_CONFIG_H)
35 #include <boost/algorithm/string/predicate.hpp>
36 #include <boost/filesystem.hpp>
37 #include <boost/interprocess/sync/file_lock.hpp>
38 #include <openssl/crypto.h>
41 using namespace boost;
52 #define MIN_CORE_FILEDESCRIPTORS 0
54 #define MIN_CORE_FILEDESCRIPTORS 150
101 fRequestShutdown =
true;
112 LogPrintf(
"Shutdown : In progress...\n");
114 TRY_LOCK(cs_Shutdown, lockShutdown);
115 if (!lockShutdown)
return;
161 fRequestShutdown =
true;
184 std::string strError;
196 string strUsage =
_(
"Options:") +
"\n";
197 strUsage +=
" -? " +
_(
"This help message") +
"\n";
198 strUsage +=
" -alertnotify=<cmd> " +
_(
"Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)") +
"\n";
199 strUsage +=
" -blocknotify=<cmd> " +
_(
"Execute command when the best block changes (%s in cmd is replaced by block hash)") +
"\n";
200 strUsage +=
" -checkblocks=<n> " +
_(
"How many blocks to check at startup (default: 288, 0 = all)") +
"\n";
201 strUsage +=
" -checklevel=<n> " +
_(
"How thorough the block verification of -checkblocks is (0-4, default: 3)") +
"\n";
202 strUsage +=
" -conf=<file> " +
_(
"Specify configuration file (default: bitcoin.conf)") +
"\n";
206 strUsage +=
" -daemon " +
_(
"Run in the background as a daemon and accept commands") +
"\n";
209 strUsage +=
" -datadir=<dir> " +
_(
"Specify data directory") +
"\n";
211 strUsage +=
" -loadblock=<file> " +
_(
"Imports blocks from external blk000??.dat file") +
" " +
_(
"on startup") +
"\n";
215 strUsage +=
" -pid=<file> " +
_(
"Specify pid file (default: bitcoind.pid)") +
"\n";
216 strUsage +=
" -reindex " +
_(
"Rebuild block chain index from current blk000??.dat files") +
" " +
_(
"on startup") +
"\n";
217 strUsage +=
" -txindex " +
_(
"Maintain a full transaction index (default: 1)") +
"\n";
219 strUsage +=
"\n" +
_(
"Connection options:") +
"\n";
220 strUsage +=
" -addnode=<ip> " +
_(
"Add a node to connect to and attempt to keep the connection open") +
"\n";
221 strUsage +=
" -banscore=<n> " +
_(
"Threshold for disconnecting misbehaving peers (default: 100)") +
"\n";
222 strUsage +=
" -bantime=<n> " +
_(
"Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") +
"\n";
223 strUsage +=
" -bind=<addr> " +
_(
"Bind to given address and always listen on it. Use [host]:port notation for IPv6") +
"\n";
224 strUsage +=
" -connect=<ip> " +
_(
"Connect only to the specified node(s)") +
"\n";
225 strUsage +=
" -discover " +
_(
"Discover own IP address (default: 1 when listening and no -externalip)") +
"\n";
226 strUsage +=
" -dns " +
_(
"Allow DNS lookups for -addnode, -seednode and -connect") +
" " +
_(
"(default: 1)") +
"\n";
227 strUsage +=
" -dnsseed " +
_(
"Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect)") +
"\n";
228 strUsage +=
" -forcednsseed " +
_(
"Always query for peer addresses via DNS lookup (default: 0)") +
"\n";
229 strUsage +=
" -externalip=<ip> " +
_(
"Specify your own public address") +
"\n";
230 strUsage +=
" -listen " +
_(
"Accept connections from outside (default: 1 if no -proxy or -connect)") +
"\n";
231 strUsage +=
" -maxconnections=<n> " +
_(
"Maintain at most <n> connections to peers (default: 125)") +
"\n";
232 strUsage +=
" -maxreceivebuffer=<n> " +
_(
"Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") +
"\n";
233 strUsage +=
" -maxsendbuffer=<n> " +
_(
"Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") +
"\n";
234 strUsage +=
" -onion=<ip:port> " +
_(
"Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: -proxy)") +
"\n";
235 strUsage +=
" -onlynet=<net> " +
_(
"Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") +
"\n";
236 strUsage +=
" -port=<port> " +
_(
"Listen for connections on <port> (default: 8333 or testnet: 18333)") +
"\n";
237 strUsage +=
" -proxy=<ip:port> " +
_(
"Connect through SOCKS proxy") +
"\n";
238 strUsage +=
" -seednode=<ip> " +
_(
"Connect to a node to retrieve peer addresses, and disconnect") +
"\n";
239 strUsage +=
" -socks=<n> " +
_(
"Select SOCKS version for -proxy (4 or 5, default: 5)") +
"\n";
240 strUsage +=
" -timeout=<n> " +
_(
"Specify connection timeout in milliseconds (default: 5000)") +
"\n";
243 strUsage +=
" -upnp " +
_(
"Use UPnP to map the listening port (default: 1 when listening)") +
"\n";
245 strUsage +=
" -upnp " +
_(
"Use UPnP to map the listening port (default: 0)") +
"\n";
250 strUsage +=
"\n" +
_(
"Wallet options:") +
"\n";
251 strUsage +=
" -disablewallet " +
_(
"Do not load the wallet and disable wallet RPC calls") +
"\n";
252 strUsage +=
" -keypool=<n> " +
_(
"Set key pool size to <n> (default: 100)") +
"\n";
253 strUsage +=
" -paytxfee=<amt> " +
_(
"Fee per kB to add to transactions you send") +
"\n";
254 strUsage +=
" -rescan " +
_(
"Rescan the block chain for missing wallet transactions") +
" " +
_(
"on startup") +
"\n";
255 strUsage +=
" -salvagewallet " +
_(
"Attempt to recover private keys from a corrupt wallet.dat") +
" " +
_(
"on startup") +
"\n";
256 strUsage +=
" -spendzeroconfchange " +
_(
"Spend unconfirmed change when sending transactions (default: 1)") +
"\n";
257 strUsage +=
" -upgradewallet " +
_(
"Upgrade wallet to latest format") +
" " +
_(
"on startup") +
"\n";
258 strUsage +=
" -wallet=<file> " +
_(
"Specify wallet file (within data directory)") +
" " +
_(
"(default: wallet.dat)") +
"\n";
259 strUsage +=
" -walletnotify=<cmd> " +
_(
"Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") +
"\n";
260 strUsage +=
" -zapwallettxes " +
_(
"Clear list of wallet transactions (diagnostic tool; implies -rescan)") +
"\n";
263 strUsage +=
"\n" +
_(
"Debugging/Testing options:") +
"\n";
266 strUsage +=
" -benchmark " +
_(
"Show benchmark information (default: 0)") +
"\n";
267 strUsage +=
" -checkpoints " +
_(
"Only accept block chain matching built-in checkpoints (default: 1)") +
"\n";
268 strUsage +=
" -dblogsize=<n> " +
_(
"Flush database activity from memory pool to disk log every <n> megabytes (default: 100)") +
"\n";
269 strUsage +=
" -disablesafemode " +
_(
"Disable safemode, override a real safe mode event (default: 0)") +
"\n";
270 strUsage +=
" -testsafemode " +
_(
"Force safe mode (default: 0)") +
"\n";
271 strUsage +=
" -dropmessagestest=<n> " +
_(
"Randomly drop 1 of every <n> network messages") +
"\n";
272 strUsage +=
" -fuzzmessagestest=<n> " +
_(
"Randomly fuzz 1 of every <n> network messages") +
"\n";
273 strUsage +=
" -flushwallet " +
_(
"Run a thread to flush wallet periodically (default: 1)") +
"\n";
275 strUsage +=
" -debug=<category> " +
_(
"Output debugging information (default: 0, supplying <category> is optional)") +
"\n";
276 strUsage +=
" " +
_(
"If <category> is not supplied, output all debugging information.") +
"\n";
277 strUsage +=
" " +
_(
"<category> can be:");
278 strUsage +=
" addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net";
283 strUsage +=
" -gen " +
_(
"Generate coins (default: 0)") +
"\n";
284 strUsage +=
" -genproclimit=<n> " +
_(
"Set the processor limit for when generation is on (-1 = unlimited, default: -1)") +
"\n";
286 strUsage +=
" -help-debug " +
_(
"Show all debugging options (usage: --help -help-debug)") +
"\n";
287 strUsage +=
" -logtimestamps " +
_(
"Prepend debug output with timestamp (default: 1)") +
"\n";
290 strUsage +=
" -limitfreerelay=<n> " +
_(
"Continuously rate-limit free transactions to <n>*1000 bytes per minute (default:15)") +
"\n";
291 strUsage +=
" -maxsigcachesize=<n> " +
_(
"Limit size of signature cache to <n> entries (default: 50000)") +
"\n";
293 strUsage +=
" -mintxfee=<amt> " +
_(
"Fees smaller than this are considered zero fee (for transaction creation) (default:") +
" " +
FormatMoney(
CTransaction::nMinTxFee) +
")" +
"\n";
295 strUsage +=
" -printtoconsole " +
_(
"Send trace/debug info to console instead of debug.log file") +
"\n";
298 strUsage +=
" -printblock=<hash> " +
_(
"Print block on startup, if found in block index") +
"\n";
299 strUsage +=
" -printblocktree " +
_(
"Print block tree on startup (default: 0)") +
"\n";
300 strUsage +=
" -printpriority " +
_(
"Log transaction priority and fee per kB when mining blocks (default: 0)") +
"\n";
301 strUsage +=
" -privdb " +
_(
"Sets the DB_PRIVATE flag in the wallet db environment (default: 1)") +
"\n";
302 strUsage +=
" -regtest " +
_(
"Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") +
"\n";
303 strUsage +=
" " +
_(
"This is intended for regression testing tools and app development.") +
"\n";
304 strUsage +=
" " +
_(
"In this mode -genproclimit controls how many blocks are generated immediately.") +
"\n";
306 strUsage +=
" -shrinkdebugfile " +
_(
"Shrink debug.log file on client startup (default: 1 when no -debug)") +
"\n";
307 strUsage +=
" -testnet " +
_(
"Use the test network") +
"\n";
309 strUsage +=
"\n" +
_(
"Block creation options:") +
"\n";
310 strUsage +=
" -blockminsize=<n> " +
_(
"Set minimum block size in bytes (default: 0)") +
"\n";
314 strUsage +=
"\n" +
_(
"RPC server options:") +
"\n";
315 strUsage +=
" -server " +
_(
"Accept command line and JSON-RPC commands") +
"\n";
316 strUsage +=
" -rpcuser=<user> " +
_(
"Username for JSON-RPC connections") +
"\n";
317 strUsage +=
" -rpcpassword=<pw> " +
_(
"Password for JSON-RPC connections") +
"\n";
318 strUsage +=
" -rpcport=<port> " +
_(
"Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)") +
"\n";
319 strUsage +=
" -rpcallowip=<ip> " +
_(
"Allow JSON-RPC connections from specified IP address") +
"\n";
320 strUsage +=
" -rpcthreads=<n> " +
_(
"Set the number of threads to service RPC calls (default: 4)") +
"\n";
322 strUsage +=
"\n" +
_(
"RPC SSL options: (see the Bitcoin Wiki for SSL setup instructions)") +
"\n";
323 strUsage +=
" -rpcssl " +
_(
"Use OpenSSL (https) for JSON-RPC connections") +
"\n";
324 strUsage +=
" -rpcsslcertificatechainfile=<file.cert> " +
_(
"Server certificate file (default: server.cert)") +
"\n";
325 strUsage +=
" -rpcsslprivatekeyfile=<file.pem> " +
_(
"Server private key (default: server.pem)") +
"\n";
326 strUsage +=
" -rpcsslciphers=<ciphers> " +
_(
"Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH)") +
"\n";
357 LogPrintf(
"Reindexing block file blk%05u.dat...\n", (
unsigned int)nFile);
369 filesystem::path pathBootstrap =
GetDataDir() /
"bootstrap.dat";
370 if (filesystem::exists(pathBootstrap)) {
371 FILE *file = fopen(pathBootstrap.string().c_str(),
"rb");
374 filesystem::path pathBootstrapOld =
GetDataDir() /
"bootstrap.dat.old";
375 LogPrintf(
"Importing bootstrap.dat...\n");
379 LogPrintf(
"Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
384 BOOST_FOREACH(boost::filesystem::path &path, vImportFiles) {
385 FILE *file = fopen(path.string().c_str(),
"rb");
388 LogPrintf(
"Importing blocks file %s...\n", path.string());
391 LogPrintf(
"Warning: Could not open blocks file %s\n", path.string());
403 InitError(
"OpenSSL appears to lack support for elliptic curve cryptography. For more "
404 "information, visit https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries");
421 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
422 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
426 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
432 #ifndef PROCESS_DEP_ENABLE
435 #define PROCESS_DEP_ENABLE 0x00000001
437 typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
438 PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA(
"Kernel32.dll"),
"SetProcessDEPPolicy");
439 if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE);
443 int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
444 if (ret != NO_ERROR || LOBYTE(wsadata.wVersion ) != 2 || HIBYTE(wsadata.wVersion) != 2)
446 return InitError(
strprintf(
"Error: Winsock library failed to start (WSAStartup returned error %d)", ret));
455 sigemptyset(&sa.sa_mask);
457 sigaction(SIGTERM, &sa, NULL);
458 sigaction(SIGINT, &sa, NULL);
461 struct sigaction sa_hup;
463 sigemptyset(&sa_hup.sa_mask);
465 sigaction(SIGHUP, &sa_hup, NULL);
467 #if defined (__SVR4) && defined (__sun)
469 signal(SIGPIPE, SIG_IGN);
479 LogPrintf(
"AppInit2 : parameter interaction: -bind set -> setting -listen=1\n");
485 LogPrintf(
"AppInit2 : parameter interaction: -connect set -> setting -dnsseed=0\n");
487 LogPrintf(
"AppInit2 : parameter interaction: -connect set -> setting -listen=0\n");
493 LogPrintf(
"AppInit2 : parameter interaction: -proxy set -> setting -listen=0\n");
499 LogPrintf(
"AppInit2 : parameter interaction: -listen=0 -> setting -upnp=0\n");
501 LogPrintf(
"AppInit2 : parameter interaction: -listen=0 -> setting -discover=0\n");
504 if (
mapArgs.count(
"-externalip")) {
507 LogPrintf(
"AppInit2 : parameter interaction: -externalip set -> setting -discover=0\n");
513 LogPrintf(
"AppInit2 : parameter interaction: -salvagewallet=1 -> setting -rescan=1\n");
519 LogPrintf(
"AppInit2 : parameter interaction: -zapwallettxes=1 -> setting -rescan=1\n");
523 int nBind = std::max((
int)
mapArgs.count(
"-bind"), 1);
528 return InitError(
_(
"Not enough file descriptors available."));
536 const vector<string>& categories =
mapMultiArgs[
"-debug"];
537 if (
GetBoolArg(
"-nodebug",
false) || find(categories.begin(), categories.end(), string(
"0")) != categories.end())
542 InitWarning(
_(
"Warning: Deprecated argument -debugnet ignored, use -debug=net"));
560 setvbuf(stdout, NULL, _IOLBF, 0);
562 bool fDisableWallet =
GetBoolArg(
"-disablewallet",
false);
567 int nNewTimeout =
GetArg(
"-timeout", 5000);
568 if (nNewTimeout > 0 && nNewTimeout < 600000)
575 const char* pszP2SH =
"/P2SH/";
576 COINBASE_FLAGS << std::vector<unsigned char>(pszP2SH, pszP2SH+strlen(pszP2SH));
584 if (
mapArgs.count(
"-mintxfee"))
592 if (
mapArgs.count(
"-minrelaytxfee"))
602 if (
mapArgs.count(
"-paytxfee"))
607 InitWarning(
_(
"Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
616 return InitError(
_(
"Initialization sanity check failed. Bitcoin Core is shutting down."));
618 std::string strDataDir =
GetDataDir().string();
625 boost::filesystem::path pathLockFile =
GetDataDir() /
".lock";
626 FILE* file = fopen(pathLockFile.string().c_str(),
"a");
627 if (file) fclose(file);
628 static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
629 if (!lock.try_lock())
630 return InitError(
strprintf(
_(
"Cannot obtain a lock on data directory %s. Bitcoin Core is probably already running."), strDataDir));
634 LogPrintf(
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
636 LogPrintf(
"Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
638 LogPrintf(
"Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0));
643 LogPrintf(
"Using data directory %s\n", strDataDir);
644 LogPrintf(
"Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
645 std::ostringstream strErrors;
657 if (!fDisableWallet) {
664 boost::filesystem::path pathDatabase =
GetDataDir() /
"database";
667 boost::filesystem::rename(pathDatabase, pathDatabaseBak);
668 LogPrintf(
"Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string());
669 }
catch(boost::filesystem::filesystem_error &
error) {
676 string msg =
strprintf(
_(
"Error initializing wallet database environment %s!"), strDataDir);
693 string msg =
strprintf(
_(
"Warning: wallet.dat corrupt, data salvaged!"
694 " Original wallet.dat saved as wallet.{timestamp}.bak in %s; if"
695 " your balance or transactions are incorrect you should"
696 " restore from a backup."), strDataDir);
700 return InitError(
_(
"wallet.dat corrupt, salvage failed"));
703 #endif // ENABLE_WALLET
708 int nSocksVersion =
GetArg(
"-socks", 5);
709 if (nSocksVersion != 4 && nSocksVersion != 5)
710 return InitError(
strprintf(
_(
"Unknown -socks proxy version requested: %i"), nSocksVersion));
712 if (
mapArgs.count(
"-onlynet")) {
713 std::set<enum Network> nets;
714 BOOST_FOREACH(std::string snet,
mapMultiArgs[
"-onlynet"]) {
720 for (
int n = 0; n <
NET_MAX; n++) {
722 if (!nets.count(net))
736 if (nSocksVersion > 4) {
747 printf(
"Notice: option -tor has been replaced with -onion and will be removed in a later version.\n");
753 addrOnion = addrProxy;
770 BOOST_FOREACH(std::string strBind,
mapMultiArgs[
"-bind"]) {
778 struct in_addr inaddr_any;
779 inaddr_any.s_addr = INADDR_ANY;
784 return InitError(
_(
"Failed to listen on any port. Use -listen=0 if you want this."));
787 if (
mapArgs.count(
"-externalip")) {
788 BOOST_FOREACH(
string strAddr,
mapMultiArgs[
"-externalip"]) {
796 BOOST_FOREACH(
string strDest,
mapMultiArgs[
"-seednode"])
804 filesystem::path blocksDir =
GetDataDir() /
"blocks";
805 if (!filesystem::exists(blocksDir))
807 filesystem::create_directories(blocksDir);
809 for (
unsigned int i = 1; i < 10000; i++) {
811 if (!filesystem::exists(source))
break;
812 filesystem::path dest = blocksDir /
strprintf(
"blk%05u.dat", i-1);
814 filesystem::create_hard_link(source, dest);
815 LogPrintf(
"Hardlinked %s -> %s\n", source.string(), dest.string());
817 }
catch (filesystem::filesystem_error & e) {
820 LogPrintf(
"Error hardlinking blk%04u.dat : %s\n", i, e.what());
836 size_t nBlockTreeDBCache = nTotalCache / 8;
837 if (nBlockTreeDBCache > (1 << 21) && !
GetBoolArg(
"-txindex",
true))
838 nBlockTreeDBCache = (1 << 21);
839 nTotalCache -= nBlockTreeDBCache;
840 size_t nCoinDBCache = nTotalCache / 2;
841 nTotalCache -= nCoinDBCache;
844 bool fLoaded =
false;
847 std::string strLoadError;
867 strLoadError =
_(
"Error loading block database");
874 return InitError(
_(
"Incorrect or no genesis block found. Wrong datadir for network?"));
878 strLoadError =
_(
"Error initializing block database");
884 strLoadError =
_(
"You need to rebuild the database using -reindex to change -txindex");
890 GetArg(
"-checkblocks", 288))) {
891 strLoadError =
_(
"Corrupted block database detected");
894 }
catch(std::exception &e) {
896 strLoadError =
_(
"Error opening block database");
907 strLoadError +
".\n\n" +
_(
"Do you want to rebuild the block database now?"),
911 fRequestShutdown =
false;
913 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
925 if (fRequestShutdown)
927 LogPrintf(
"Shutdown requested. Exiting.\n");
938 if (
mapArgs.count(
"-printblock"))
940 string strMatch =
mapArgs[
"-printblock"];
945 if (strncmp(hash.
ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)
957 LogPrintf(
"No blocks matching %s were found\n", strMatch);
961 if (!
fTxIndex)
return InitError(
_(
"Master Core: Please use -txindex option at the command line or add txindex=1 to bitcoin.conf file !!!\n"));
967 if (fDisableWallet) {
988 bool fFirstRun =
true;
994 strErrors <<
_(
"Error loading wallet.dat: Wallet corrupted") <<
"\n";
997 string msg(
_(
"Warning: error reading wallet.dat! All keys read correctly, but transaction data"
998 " or address book entries might be missing or incorrect."));
1002 strErrors <<
_(
"Error loading wallet.dat: Wallet requires newer version of Bitcoin") <<
"\n";
1005 strErrors <<
_(
"Wallet needed to be rewritten: restart Bitcoin to complete") <<
"\n";
1010 strErrors <<
_(
"Error loading wallet.dat") <<
"\n";
1015 int nMaxVersion =
GetArg(
"-upgradewallet", 0);
1016 if (nMaxVersion == 0)
1023 LogPrintf(
"Allowing wallet upgrade up to %i\n", nMaxVersion);
1024 if (nMaxVersion < pwalletMain->GetVersion())
1025 strErrors <<
_(
"Cannot downgrade wallet") <<
"\n";
1038 strErrors <<
_(
"Cannot write default address") <<
"\n";
1072 #else // ENABLE_WALLET
1074 #endif // !ENABLE_WALLET
1080 strErrors <<
"Failed to connect best block";
1082 std::vector<boost::filesystem::path> vImportFiles;
1083 if (
mapArgs.count(
"-loadblock"))
1085 BOOST_FOREACH(
string strFile,
mapMultiArgs[
"-loadblock"])
1086 vImportFiles.push_back(strFile);
1088 threadGroup.create_thread(boost::bind(&
ThreadImport, vImportFiles));
1099 LogPrintf(
"Invalid or missing peers.dat; recreating\n");
1102 LogPrintf(
"Loaded %i addresses from peers.dat %dms\n",
1110 if (!strErrors.str().empty())
1118 #ifdef ENABLE_WALLET
1120 LogPrintf(
"mapWallet.size() = %u\n", pwalletMain ? pwalletMain->
mapWallet.size() : 0);
1130 #ifdef ENABLE_WALLET
1140 #ifdef ENABLE_WALLET
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
unsigned int nWalletDBUpdated
CClientUIInterface uiInterface
void SetReachable(enum Network net, bool fFlag)
CNodeSignals & GetNodeSignals()
std::set< int64_t > setKeyPool
Access to the (IP) address database (peers.dat)
void AddOneShot(string strDest)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly)
Open a block file (blk?????.dat)
bool AddLocal(const CService &addr, int nScore)
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
#define TRY_LOCK(cs, name)
int mastercore_shutdown(void)
void GenerateBitcoins(bool fGenerate, CWallet *pwallet, int nThreads)
Run the miner threads.
std::map< CTxDestination, CAddressBookData > mapAddressBook
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE
Default for -blockprioritysize, maximum space for zero/low-fee transactions.
static bool Bind(const CService &addr, unsigned int flags)
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool bSpendZeroConfChange
boost::filesystem::path GetPidFile()
static const int CLIENT_VERSION
void ThreadScriptCheck()
Run an instance of the script checking thread.
void setSanityCheck(bool _fSanityCheck)
std::string strWalletFile
void SetLimited(enum Network net, bool fLimited)
Make a particular network entirely off-limits (no automatic connects to it)
bool VerifyDB(int nCheckLevel, int nCheckDepth)
Verify consistency of the block and coin databases.
void Flush(bool fShutdown)
unsigned short GetListenPort()
static const int64_t nMinDbCache
Don't bring GUI to foreground.
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
bool SetMaxVersion(int nVersion)
std::string HelpMessage(HelpMessageMode hmm)
DBErrors
Error statuses for the wallet database.
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
void RandAddSeedPerfmon()
static int64_t nMinTxFee
Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) ...
string FormatMoney(int64_t n, bool fPlus)
void ReacceptWalletTransactions()
void RenameThread(const char *name)
CChain chainActive
The currently-connected chain of blocks.
bool SetDefaultKey(const CPubKey &vchPubKey)
static const unsigned int DEFAULT_BLOCK_MAX_SIZE
Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will cr...
int mastercore_init(void)
volatile bool fReopenDebugLog
void PrintBlockTree()
Print the loaded block tree.
void SetBestChain(const CBlockLocator &loc)
int RaiseFileDescriptorLimit(int nMinFD)
uint256 BuildMerkleTree() const
CBlockLocator GetLocator(const CBlockIndex *pindex=NULL) const
Return a CBlockLocator that refers to a block in this chain (by default the tip). ...
bool SetMinVersion(enum WalletFeature, CWalletDB *pwalletdbIn=NULL, bool fExplicit=false)
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or NULL if none.
static bool InitWarning(const std::string &str)
int Height() const
Return the maximal height in the chain.
static const unsigned int DEFAULT_MAX_ORPHAN_BLOCKS
Default for -maxorphanblocks, maximum number of orphan blocks kept in memory.
CBlockTreeDB * pblocktree
Global variable that points to the active block tree (protected by cs_main)
enum Network ParseNetwork(std::string net)
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Access to the block database (blocks/index/)
volatile bool fRequestShutdown
void UnloadBlockIndex()
Unload database information.
void RegisterNodeSignals(CNodeSignals &nodeSignals)
Register with a network node to receive its signals.
A combination of a network address (CNetAddr) and a (TCP) port.
static const int nHighTransactionFeeWarning
An encapsulated public key.
bool ActivateBestChain(CValidationState &state)
Find the best known block, and make it the tip of the block chain.
static bool error(const char *format)
bool AppInit2(boost::thread_group &threadGroup)
Initialize bitcoin.
bool LoadBlockIndex()
Load the block tree and coins database from disk.
bool SetNameProxy(CService addrProxy, int nSocksVersion)
static const int64_t nDefaultDbCache
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
void AddTransactionsUpdated(unsigned int n)
void RegisterWallet(CWalletInterface *pwalletIn)
Register a wallet to receive updates from core.
static bool InitError(const std::string &str)
Access to the wallet database (wallet.dat)
void ThreadImport(std::vector< boost::filesystem::path > vImportFiles)
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
std::string strWalletFile
bool ReadBestBlock(CBlockLocator &locator)
CBlockIndex * Genesis() const
Returns the index entry for the genesis block of this chain, or NULL if none.
Capture information about block/transaction validation.
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of script-checking threads allowed.
bool BindListenPort(const CService &addrBind, string &strError)
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos)
int ScanForWalletTransactions(CBlockIndex *pindexStart, bool fUpdate=false)
The block chain is a tree shaped structure starting with the genesis block at the root...
unsigned int nCoinCacheSize
std::string ToString() const
CCoinsView backed by the LevelDB coin database (chainstate/)
CBlockIndex * FindFork(const CBlockLocator &locator) const
Find the last common block between this chain and a locator.
string FormatFullVersion()
static bool Recover(CDBEnv &dbenv, std::string filename, bool fOnlyKeys)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
bool Lookup(const char *pszName, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
bool ParseMoney(const string &str, int64_t &nRet)
static const int64_t nMaxDbCache
void UnregisterAllWallets()
Unregister all wallets from core.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
VerifyResult Verify(std::string strFile, bool(*recoverFunc)(CDBEnv &dbenv, std::string strFile))
bool InitSanityCheck(void)
Sanity checks Ensure that Bitcoin is running in a usable environment with all necessary library suppo...
bool WriteReindexing(bool fReindex)
std::map< uint256, CWalletTx > mapWallet
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
static int64_t nMinRelayTxFee
Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) ...
DBErrors LoadWallet(bool &fFirstRunRet)
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
bool GetKeyFromPool(CPubKey &key)
bool LoadExternalBlockFile(FILE *fileIn, CDiskBlockPos *dbp)
Import blocks from an external file.
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
bool CheckDiskSpace(uint64_t nAdditionalBytes)
Check whether enough disk space is available for an incoming block.
#define MIN_CORE_FILEDESCRIPTORS
bool InitBlockIndex()
Initialize a new block tree database + block data on disk.
map< string, vector< string > > mapMultiArgs
bool Open(const boost::filesystem::path &path)
map< uint256, CBlockIndex * > mapBlockIndex
bool Read(CAddrMan &addr)
void ThreadFlushWalletDB(const std::string &strWalletFile)
bool IsLimited(enum Network net)
const std::string CLIENT_DATE
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
void StartNode(boost::thread_group &threadGroup)
map< string, string > mapArgs
bool SetProxy(enum Network net, CService addrProxy, int nSocksVersion)
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS
Default for -maxorphantx, maximum number of orphan transactions kept in memory.
boost::filesystem::path GetDefaultDataDir()
static CCoinsViewDB * pcoinsdbview
void UnregisterNodeSignals(CNodeSignals &nodeSignals)
Unregister a network node.