diff options
41 files changed, 979 insertions, 636 deletions
diff --git a/build-msw.txt b/build-msw.txt index deba805d52..a28c7ef859 100644 --- a/build-msw.txt +++ b/build-msw.txt @@ -3,7 +3,8 @@ Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This product includes -cryptographic software written by Eric Young (eay@cryptsoft.com). +cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP +software written by Thomas Bernard. WINDOWS BUILD NOTES @@ -25,23 +26,26 @@ Dependencies ------------ Libraries you need to download separately and build: - default path download -wxWidgets \wxwidgets-2.9.1-mgw http://www.wxwidgets.org/downloads/ -OpenSSL \openssl-1.0.0c-mgw http://www.openssl.org/source/ -Berkeley DB \db-4.7.25.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html -Boost \boost-1.43.0-mgw http://www.boost.org/users/download/ + default path download +wxWidgets \wxwidgets-2.9.1-mgw http://www.wxwidgets.org/downloads/ +OpenSSL \openssl-1.0.0c-mgw http://www.openssl.org/source/ +Berkeley DB \db-4.7.25.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html +Boost \boost-1.43.0-mgw http://www.boost.org/users/download/ +miniupnpc \upnpc-exe-win32-20110215 http://miniupnp.tuxfamily.org/files/ Their licenses: wxWidgets LGPL 2.1 with very liberal exceptions OpenSSL Old BSD license with the problematic advertising requirement Berkeley DB New BSD license with additional requirement that linked software must be free open source Boost MIT-like license +miniupnpc New (3-clause) BSD license Versions used in this release: wxWidgets 2.9.1 OpenSSL 1.0.0c Berkeley DB 4.7.25.NC Boost 1.43.0 +miniupnpc 1.5-20110215 Notes @@ -90,6 +94,15 @@ Note: building with boost 1.45.0 failed because of boost ticket 4614, 4258 builds fine with boost 1.43.0 +MiniUPnPc +--------- +Building miniupnpc failed on Windows Server 2003, thus it is expected that a binary copy will be used. +See http://miniupnp.tuxfamily.org/forum/viewtopic.php?t=642 +UPnP support is optional, make with USE_UPNP= to disable it. + +Get upnpc-exe-win32-20110215.zip and unzip it to \upnpc-exe-win32-20110215 +Get miniupnpc-1.5.20110215.tar.gz and copy *.h to \upnpc-exe-win32-20110215\miniupnpc + Bitcoin ------- DOS prompt: diff --git a/build-osx.txt b/build-osx.txt index 2f8b53321f..79279838d3 100644 --- a/build-osx.txt +++ b/build-osx.txt @@ -3,7 +3,8 @@ Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This product includes -cryptographic software written by Eric Young (eay@cryptsoft.com). +cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP +software written by Thomas Bernard. Mac OS X build instructions @@ -58,7 +59,10 @@ cd ~/bitcoin/deps tar xvjf ~/Downloads/boost_1_42_0.tar.bz2 cd boost_1_42_0 ./bootstrap.sh -./bjam architecture=combined address-model=32_64 macosx-version=10.6 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install +./bjam architecture=combined address-model=32_64 macosx-version=10.5 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install + +If you're using Snow Leopard, you will need to specify 10.6 as your Mac OS X +version instead of 10.5. This part takes a while.. use your judgement and fix it if something doesn't build for some reason. @@ -89,12 +93,12 @@ tar xvf ~/Downloads/openssl-1.0.0.tar mv openssl-1.0.0 openssl-1.0.0-x86_64 # build i386 (32 bit intel) binary cd openssl-1.0.0-i386 -./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin-i386-cc && make +./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin-i386-cc && make make install # only do this on one of the architectures, to install the headers cd .. # build x86_64 (64 bit intel) binary cd openssl-1.0.0-x86_64 -./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin64-x86_64-cc && make +./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/bitcoin/deps/openssl darwin64-x86_64-cc && make cd .. # combine the libs @@ -108,11 +112,51 @@ file lib/libcrypto.a output should look like this: -ib/libcrypto.a: Mach-O universal binary with 2 architectures +lib/libcrypto.a: Mach-O universal binary with 2 architectures lib/libcrypto.a (for architecture i386): current ar archive random library lib/libcrypto.a (for architecture x86_64): current ar archive random library +miniupnpc +--------- + +The process for miniupnpc (optional) is similar to that of OpenSSL. + +Download from http://miniupnp.tuxfamily.org/files/. + +cd ~/bitcoin/deps +tar xvf ~/Downloads/miniupnpc-1.5.tar +mv miniupnpc-1.5 miniupnpc-1.5-x86_64 +tar xvf ~/Downloads/miniupnpc-1.5.tar +mv miniupnpc-1.5 miniupnpc-1.5-i386 +# build x86_64 (64 bit intel) binary +cd miniupnpc-1.5-x86_64 +export CFLAGS="-arch x86_64" +export LDFLAGS="-arch x86_64" +export PREFIX="/Users/macuser/bitcoin/deps" +make && make install +# build i386 (32 bit intel) binary +cd miniupnpc-1.5-i386 +export CFLAGS="-arch i386" +export LDFLAGS="-arch i386" +export PREFIX="/Users/macuser/bitcoin/deps" +make + +# combine the libs +cd ~/bitcoin/deps +lipo -arch i386 miniupnpc-1.5-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.5-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create + +Verify your binaries + +file lib/libminiupnpc.a + +output should look like this: + +lib/libminiupnpc.a: Mach-O universal binary with 2 architectures +lib/libminiupnpc.a (for architecture i386): current ar archive random library +lib/libminiupnpc.a (for architecture x86_64): current ar archive random library + + Berkeley DB ----------- diff --git a/build-unix.txt b/build-unix.txt index 27a4570665..922a43bd23 100644 --- a/build-unix.txt +++ b/build-unix.txt @@ -3,7 +3,8 @@ Distributed under the MIT/X11 software license, see the accompanying file license.txt or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/). This product includes -cryptographic software written by Eric Young (eay@cryptsoft.com). +cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP +software written by Thomas Bernard. UNIX BUILD NOTES @@ -36,10 +37,18 @@ You need to download wxWidgets from http://www.wxwidgets.org/downloads/ and build it yourself. See the build instructions and configure parameters below. +Requires miniupnpc for UPnP port mapping. It can be downloaded from +http://miniupnp.tuxfamily.org/files/. UPnP support is compiled in and +turned off by default. Set USE_UPNP to a different value to control this: +USE_UPNP= no UPnP support, miniupnp not required; +USE_UPNP=0 (the default) UPnP support turned off by default at runtime; +USE_UPNP=1 UPnP support turned on by default at runtime. + Licenses of statically linked libraries: wxWidgets LGPL 2.1 with very liberal exceptions Berkeley DB New BSD license with additional requirement that linked software must be free open source Boost MIT-like license +miniupnpc New (3-clause) BSD license Versions used in this release: GCC 4.3.3 @@ -47,6 +56,7 @@ OpenSSL 0.9.8g wxWidgets 2.9.0 Berkeley DB 4.7.25.NC Boost 1.37 +miniupnpc 1.5 Notes @@ -66,13 +76,22 @@ tar -xzvf wxWidgets-2.9.0.tar.gz cd wxWidgets-2.9.0 mkdir buildgtk cd buildgtk -../configure --with-gtk --enable-debug --disable-shared --enable-monolithic +../configure --with-gtk --enable-debug --disable-shared --enable-monolithic --without-libpng --disable-svg make sudo su make install ldconfig +miniupnpc +--------- +tar -xzvf miniupnpc-1.5.tar.gz +cd miniupnpc-1.5 +make +sudo su +make install + + Berkeley DB ----------- You need Berkeley DB 4.7. Don't use 4.8, the database/log0000* files diff --git a/contrib/gitian.yml b/contrib/gitian.yml index 92385e50b2..5d12f72700 100644 --- a/contrib/gitian.yml +++ b/contrib/gitian.yml @@ -18,20 +18,29 @@ remotes: "dir": "bitcoin" files: - "wxWidgets-2.9.1.tar.bz2" +- "miniupnpc-1.5.tar.gz" script: | INSTDIR="$HOME/install" export LIBRARY_PATH="$INSTDIR/lib" + # + tar xzf miniupnpc-1.5.tar.gz + cd miniupnpc-1.5 + INSTALLPREFIX=$INSTDIR make $MAKEOPTS install + cd .. + # tar xjf wxWidgets-2.9.1.tar.bz2 cd wxWidgets-2.9.1 ./configure --prefix=$INSTDIR --enable-monolithic --disable-shared perl -i -p -e "s/__TIME__/\"$REFERENCE_TIME\"/;s/__DATE__/\"$REFERENCE_DATE\"/" include/wx/chartype.h make $MAKEOPTS install - cd ../bitcoin + cd .. + # + cd bitcoin mkdir -p $OUTDIR/src cp -a . $OUTDIR/src rm -rf $OUTDIR/src/.git mv $OUTDIR/src/locale $OUTDIR cp $OUTDIR/src/license.txt $OUTDIR - make -f makefile.unix $MAKEOPTS WXLIBS="-Wl,-Bstatic -l wx_gtk2u-2.9 -Wl,-Bdynamic -l gtk-x11-2.0 -l SM -l Xxf86vm" INCLUDEPATHS="`$INSTDIR/bin/wx-config --cflags`" bitcoin bitcoind + PATH=$INSTDIR/bin:$PATH make -f makefile.unix CXX="g++ -I$INSTDIR/include -L$INSTDIR/lib" $MAKEOPTS bitcoin bitcoind mkdir -p $OUTDIR/bin/$GBUILD_BITS - cp bitcoin bitcoind $OUTDIR/bin/$GBUILD_BITS + install -s bitcoin bitcoind $OUTDIR/bin/$GBUILD_BITS @@ -668,8 +668,8 @@ bool CWalletDB::LoadWallet() #endif //// todo: shouldn't we catch exceptions and try to recover and continue? - CRITICAL_BLOCK(cs_mapKeys) CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_mapKeys) { // Get cursor Dbc* pcursor = GetCursor(); @@ -778,10 +778,10 @@ bool CWalletDB::LoadWallet() string strKey; ssKey >> strKey; - // Menu state - if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins; - // Options +#ifndef GUI + if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins; +#endif if (strKey == "nTransactionFee") ssValue >> nTransactionFee; if (strKey == "addrIncoming") ssValue >> addrIncoming; if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors; @@ -790,7 +790,7 @@ bool CWalletDB::LoadWallet() if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose; if (strKey == "fUseProxy") ssValue >> fUseProxy; if (strKey == "addrProxy") ssValue >> addrProxy; - + if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP; } } pcursor->close(); @@ -807,6 +807,8 @@ bool CWalletDB::LoadWallet() printf("fMinimizeOnClose = %d\n", fMinimizeOnClose); printf("fUseProxy = %d\n", fUseProxy); printf("addrProxy = %s\n", addrProxy.ToString().c_str()); + if (fHaveUPnP) + printf("fUseUPnP = %d\n", fUseUPnP); // Upgrade @@ -13,6 +13,7 @@ class CAddress; class CWalletTx; class CAccount; class CAccountingEntry; +class CBlockLocator; extern map<string, string> mapAddressBook; extern CCriticalSection cs_mapAddressBook; @@ -405,6 +406,17 @@ public: return Write(make_pair(string("key"), vchPubKey), vchPrivKey, false); } + bool WriteBestBlock(const CBlockLocator& locator) + { + nWalletDBUpdated++; + return Write(string("bestblock"), locator); + } + + bool ReadBestBlock(CBlockLocator& locator) + { + return Read(string("bestblock"), locator); + } + bool ReadDefaultKey(vector<unsigned char>& vchPubKey) { vchPubKey.clear(); diff --git a/doc/README b/doc/README new file mode 100644 index 0000000000..3137d0adc7 --- /dev/null +++ b/doc/README @@ -0,0 +1,30 @@ +Bitcoin 0.3.21 BETA + +Copyright (c) 2009-2011 Bitcoin Developers +Distributed under the MIT/X11 software license, see the accompanying +file license.txt or http://www.opensource.org/licenses/mit-license.php. +This product includes software developed by the OpenSSL Project for use in +the OpenSSL Toolkit (http://www.openssl.org/). This product includes +cryptographic software written by Eric Young (eay@cryptsoft.com). + + +Intro +----- +Bitcoin is a free open source peer-to-peer electronic cash system that is +completely decentralized, without the need for a central server or trusted +parties. Users hold the crypto keys to their own money and transact directly +with each other, with the help of a P2P network to check for double-spending. + + +Setup +----- +Unpack the files into a directory and run: + bin/32/bitcoin (GUI, 32-bit) + bin/32/bitcoind (headless, 32-bit) + bin/64/bitcoin (GUI, 64-bit) + bin/64/bitcoind (headless, 64-bit) + +See the documentation at the bitcoin wiki: + https://en.bitcoin.it/wiki/Main_Page + +... for help and more information. diff --git a/doc/README_windows.txt b/doc/README_windows.txt new file mode 100644 index 0000000000..4c2065235b --- /dev/null +++ b/doc/README_windows.txt @@ -0,0 +1,34 @@ +Bitcoin 0.3.21 BETA
+
+Copyright (c) 2009-2011 Bitcoin Developers
+Distributed under the MIT/X11 software license, see the accompanying
+file license.txt or http://www.opensource.org/licenses/mit-license.php.
+This product includes software developed by the OpenSSL Project for use in
+the OpenSSL Toolkit (http://www.openssl.org/). This product includes
+cryptographic software written by Eric Young (eay@cryptsoft.com).
+
+
+Intro
+-----
+Bitcoin is a free open source peer-to-peer electronic cash system that is
+completely decentralized, without the need for a central server or trusted
+parties. Users hold the crypto keys to their own money and transact directly
+with each other, with the help of a P2P network to check for double-spending.
+
+
+Setup
+-----
+Unpack the files into a directory and run bitcoin.exe.
+
+If you have Microsoft Security Essentials, you need to add bitcoin.exe to its
+"Excluded processes" list. Microsoft Security Essentials->Settings tab,
+select Excluded processes, press Add, select bitcoin.exe, OK, Save changes.
+
+The software automatically finds other nodes to connect to. You can
+enable Universal Plug and Play using a menu entry or set your firewall
+to forward port 8333 (TCP) to your computer so you can receive
+incoming connections. Bitcoin work without incoming connections,
+but allowing incoming connections helps the Bitcoin network.
+
+See the bitcoin wiki at: https://en.bitcoin.it/wiki/Main_Page
+for more help and information.
@@ -41,6 +41,7 @@ void Shutdown(void* parg) DBFlush(false); StopNode(); DBFlush(true); + boost::filesystem::remove(GetPidFile()); CreateThread(ExitTimeout, NULL); Sleep(50); printf("Bitcoin exiting\n\n"); @@ -78,7 +79,9 @@ int main(int argc, char* argv[]) fRet = AppInit(argc, argv); if (fRet && fDaemon) - pthread_exit((void*)0); + return 0; + + return 1; } #endif @@ -141,7 +144,7 @@ bool AppInit2(int argc, char* argv[]) { string beta = VERSION_IS_BETA ? _(" beta") : ""; string strUsage = string() + - _("Bitcoin version") + " " + FormatVersion(VERSION) + pszSubVer + beta + "\n\n" + + _("Bitcoin version") + " " + FormatFullVersion() + "\n\n" + _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" + " bitcoin [options] \t " + "\n" + " bitcoin [options] <command> [params]\t " + _("Send command to -server or bitcoind\n") + @@ -149,6 +152,7 @@ bool AppInit2(int argc, char* argv[]) " bitcoin [options] help <command> \t\t " + _("Get help for a command\n") + _("Options:\n") + " -conf=<file> \t\t " + _("Specify configuration file (default: bitcoin.conf)\n") + + " -pid=<file> \t\t " + _("Specify pid file (default: bitcoind.pid)\n") + " -gen \t\t " + _("Generate coins\n") + " -gen=0 \t\t " + _("Don't generate coins\n") + " -min \t\t " + _("Start minimized\n") + @@ -157,9 +161,18 @@ bool AppInit2(int argc, char* argv[]) " -addnode=<ip> \t " + _("Add a node to connect to\n") + " -connect=<ip> \t\t " + _("Connect only to the specified node\n") + " -nolisten \t " + _("Don't accept connections from outside\n") + +#ifdef USE_UPNP +#if USE_UPNP + " -noupnp \t " + _("Don't attempt to use UPnP to map the listening port\n") + +#else + " -upnp \t " + _("Attempt to use UPnP to map the listening port\n") + +#endif +#endif " -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send\n") + #ifdef GUI " -server \t\t " + _("Accept command line and JSON-RPC commands\n") + +#endif +#ifndef __WXMSW__ " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + #endif " -testnet \t\t " + _("Use the test network\n") + @@ -196,17 +209,20 @@ bool AppInit2(int argc, char* argv[]) fDebug = GetBoolArg("-debug"); +#ifndef __WXMSW__ fDaemon = GetBoolArg("-daemon"); +#else + fDaemon = false; +#endif if (fDaemon) fServer = true; else fServer = GetBoolArg("-server"); - /* force fServer and fDaemon when running without GUI */ + /* force fServer when running without GUI */ #ifndef GUI fServer = true; - fDaemon = true; #endif fPrintToConsole = GetBoolArg("-printtoconsole"); @@ -226,7 +242,7 @@ bool AppInit2(int argc, char* argv[]) exit(ret); } -#ifndef GUI +#ifndef __WXMSW__ if (fDaemon) { // Daemonize @@ -237,7 +253,10 @@ bool AppInit2(int argc, char* argv[]) return false; } if (pid > 0) + { + CreatePidFile(GetPidFile(), pid); return true; + } pid_t sid = setsid(); if (sid < 0) @@ -248,7 +267,7 @@ bool AppInit2(int argc, char* argv[]) if (!fDebug && !pszSetDataDir[0]) 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%s\n", FormatVersion(VERSION).c_str(), pszSubVer, VERSION_IS_BETA ? _(" beta") : ""); + printf("Bitcoin version %s\n", FormatFullVersion().c_str()); #ifdef GUI printf("OS version %s\n", ((string)wxGetOsDescription()).c_str()); printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str()); @@ -307,7 +326,7 @@ bool AppInit2(int argc, char* argv[]) // Make sure only a single bitcoin process is using the data directory. string strLockFile = GetDataDir() + "/.lock"; FILE* file = fopen(strLockFile.c_str(), "a"); // empty lock file; created if it doesn't exist. - fclose(file); + if (file) fclose(file); static boost::interprocess::file_lock lock(strLockFile.c_str()); if (!lock.try_lock()) { @@ -353,10 +372,21 @@ bool AppInit2(int argc, char* argv[]) strErrors += _("Error loading wallet.dat \n"); printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart); + CBlockIndex *pindexRescan = pindexBest; if (GetBoolArg("-rescan")) + pindexRescan = pindexGenesisBlock; + else + { + CWalletDB walletdb; + CBlockLocator locator; + if (walletdb.ReadBestBlock(locator)) + pindexRescan = locator.GetBlockIndex(); + } + if (pindexBest != pindexRescan) { + printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight); nStart = GetTimeMillis(); - ScanForWalletTransactions(pindexGenesisBlock); + ScanForWalletTransactions(pindexRescan); printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart); } @@ -449,6 +479,17 @@ bool AppInit2(int argc, char* argv[]) wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin", wxOK | wxICON_EXCLAMATION); } + if (fHaveUPnP) + { +#if USE_UPNP + if (GetBoolArg("-noupnp")) + fUseUPnP = false; +#else + if (GetBoolArg("-upnp")) + fUseUPnP = true; +#endif + } + // // Create the main window and start the node // @@ -472,10 +513,11 @@ bool AppInit2(int argc, char* argv[]) if (fFirstRun) SetStartOnSystemStartup(true); #endif - - if (fDaemon) - while (!fShutdown) - Sleep(5000); + +#ifndef GUI + while (1) + Sleep(5000); +#endif return true; } diff --git a/license.txt b/license.txt index c27d7b053f..ab042014e8 100644 --- a/license.txt +++ b/license.txt @@ -1,4 +1,4 @@ -Copyright (c) 2009-2010 Bitcoin Developers +Copyright (c) 2009-2011 Bitcoin Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/locale/de/LC_MESSAGES/bitcoin.mo b/locale/de/LC_MESSAGES/bitcoin.mo Binary files differindex eb0ca5ddf3..5d5ec90e23 100644 --- a/locale/de/LC_MESSAGES/bitcoin.mo +++ b/locale/de/LC_MESSAGES/bitcoin.mo diff --git a/locale/de/LC_MESSAGES/bitcoin.po b/locale/de/LC_MESSAGES/bitcoin.po index 058a3ce9b6..7504db1fcf 100644 --- a/locale/de/LC_MESSAGES/bitcoin.po +++ b/locale/de/LC_MESSAGES/bitcoin.po @@ -1,9 +1,11 @@ # DataWraith <DataWraith@web.de>, 2010. msgid "" msgstr "" +"Project-Id-Version: \n" "POT-Creation-Date: 2010-05-26 22:02-0000\n" "PO-Revision-Date: 2010-06-03 13:11+0200\n" "Last-Translator: DataWraith\n" +"Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -529,11 +531,6 @@ msgstr "Bitcoin Ö&ffnen" msgid "O&ptions..." msgstr "O&ptionen..." -#: ../../../ui.cpp:2502 -#: ../../../uibase.cpp:34 -msgid "&Generate Coins" -msgstr "Münzen Er&zeugen" - #: ../../../ui.cpp:2505 #: ../../../uibase.cpp:27 msgid "E&xit" @@ -707,7 +704,7 @@ msgid "" "\n" "This product includes software developed by the OpenSSL Project for use in the \n" "OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." msgstr "" "Copyright (c) 2009-2010 Bitcoin Developers\n" "\n" @@ -718,7 +715,8 @@ msgstr "" "\n" "Dieses Produkt enthält Software, die vom OpenSSL-Projekt zur Nutzung im\n" "OpenSSL Toolkit (http://www.openssl.org/) geschrieben wurde sowie\n" -"kryptographische Software von Eric Young (eay@cryptsoft.com)." +"kryptographische Software von Eric Young (eay@cryptsoft.com)\n" +"und UPnP-Software, entwickelt von Thomas Bernard." #: ../../../uibase.cpp:619 msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)" diff --git a/locale/es/LC_MESSAGES/bitcoin.mo b/locale/es/LC_MESSAGES/bitcoin.mo Binary files differindex 0677b6b5ca..234acbd011 100644 --- a/locale/es/LC_MESSAGES/bitcoin.mo +++ b/locale/es/LC_MESSAGES/bitcoin.mo diff --git a/locale/es/LC_MESSAGES/bitcoin.po b/locale/es/LC_MESSAGES/bitcoin.po index d5ad2ee91f..5f4bef8732 100644 --- a/locale/es/LC_MESSAGES/bitcoin.po +++ b/locale/es/LC_MESSAGES/bitcoin.po @@ -556,11 +556,6 @@ msgstr "&Abrir Bitcoin" msgid "O&ptions..." msgstr "O&pciones" -#: ../../../ui.cpp:2521 -#: ../../../uibase.cpp:32 -msgid "&Generate Coins" -msgstr "&Generar monedas" - #: ../../../ui.cpp:2524 #: ../../../uibase.cpp:25 msgid "E&xit" @@ -734,7 +729,7 @@ msgid "" "\n" "This product includes software developed by the OpenSSL Project for use in the \n" "OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." msgstr "" "Copyright (c) 2009-2010 Bitcoin Developers\n" "\n" @@ -745,7 +740,7 @@ msgstr "" "\n" "Este producto incluye software desarrollado por OpenSSL Project para su uso en el\n" "OpenSSL Toolkit (http://www.openssl.org/) y software criptografico escrito por \n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) y UPnP software escrito por Thomas Bernard." #: ../../../uibase.cpp:613 msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)" diff --git a/locale/fr/LC_MESSAGES/bitcoin.mo b/locale/fr/LC_MESSAGES/bitcoin.mo Binary files differindex 6e97eff7d1..f4d669b4c0 100644 --- a/locale/fr/LC_MESSAGES/bitcoin.mo +++ b/locale/fr/LC_MESSAGES/bitcoin.mo diff --git a/locale/fr/LC_MESSAGES/bitcoin.po b/locale/fr/LC_MESSAGES/bitcoin.po index 5bc28575ee..a714e01026 100644 --- a/locale/fr/LC_MESSAGES/bitcoin.po +++ b/locale/fr/LC_MESSAGES/bitcoin.po @@ -559,11 +559,6 @@ msgstr "&Ouvrir Bitcoin" msgid "O&ptions..." msgstr "O&ptions..." -#: ../../../ui.cpp:2521 -#: ../../../uibase.cpp:32 -msgid "&Generate Coins" -msgstr "&Générer des pièces" - #: ../../../ui.cpp:2524 #: ../../../uibase.cpp:25 msgid "E&xit" @@ -739,7 +734,7 @@ msgid "" "\n" "This product includes software developed by the OpenSSL Project for use in the \n" "OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." msgstr "" "Copyright (c) 2009-2010 Bitcoin Developers\n" "\n" @@ -750,7 +745,7 @@ msgstr "" "\n" "Ce produit comprend des composants logiciels développés pour le Projet OpenSSL \n" "OpenSSL Toolkit (http://www.openssl.org/) ainsi que des composants cryptographiques \n" -"écrits par Eric Young (eay@cryptsoft.com)." +"écrits par Eric Young (eay@cryptsoft.com) et des logiciels UPnP écrits par Thomas Bernard.." #: ../../../uibase.cpp:613 msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)" diff --git a/locale/it/LC_MESSAGES/bitcoin.mo b/locale/it/LC_MESSAGES/bitcoin.mo Binary files differindex 706386487f..9347018037 100644 --- a/locale/it/LC_MESSAGES/bitcoin.mo +++ b/locale/it/LC_MESSAGES/bitcoin.mo diff --git a/locale/it/LC_MESSAGES/bitcoin.po b/locale/it/LC_MESSAGES/bitcoin.po index 2b6f45debf..ccb74eac99 100644 --- a/locale/it/LC_MESSAGES/bitcoin.po +++ b/locale/it/LC_MESSAGES/bitcoin.po @@ -527,11 +527,6 @@ msgstr "&Apri Bitcoin" msgid "O&ptions..." msgstr "O&pzioni..." -#: ../../../ui.cpp:2502 -#: ../../../uibase.cpp:34 -msgid "&Generate Coins" -msgstr "&Genera monete" - #: ../../../ui.cpp:2505 #: ../../../uibase.cpp:27 msgid "E&xit" @@ -705,7 +700,7 @@ msgid "" "\n" "This product includes software developed by the OpenSSL Project for use in the \n" "OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." msgstr "" "Copyright (c) 2009-2010 Bitcoin Developers\n" "\n" @@ -714,9 +709,9 @@ msgstr "" "Distribuito sotto la licenza software MIT/X11, guarda il file license.txt\n" "incluso oppure su http://www.opensource.org/licenses/mit-license.php.\n" "\n" -"Questo prodoto include software sviluppato dal progetto OpenSSL per\n" +"Questo prodotto include software sviluppato dal progetto OpenSSL per\n" "l'uso del (http://www.openssl.org/) e il software criptografico scritto\n" -"da Eric Young (eay@cryptsoft.com)." +"da Eric Young (eay@cryptsoft.com) e UPnP software scritto da Thomas Bernard." #: ../../../uibase.cpp:619 msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)" diff --git a/locale/nl/LC_MESSAGES/bitcoin.mo b/locale/nl/LC_MESSAGES/bitcoin.mo Binary files differindex 8b1e6a50f6..11a547e411 100644 --- a/locale/nl/LC_MESSAGES/bitcoin.mo +++ b/locale/nl/LC_MESSAGES/bitcoin.mo diff --git a/locale/nl/LC_MESSAGES/bitcoin.po b/locale/nl/LC_MESSAGES/bitcoin.po index f44b94cc50..399ad8b871 100644 --- a/locale/nl/LC_MESSAGES/bitcoin.po +++ b/locale/nl/LC_MESSAGES/bitcoin.po @@ -528,11 +528,6 @@ msgstr "&Open Bitcoin" msgid "O&ptions..." msgstr "O&pties" -#: ../../../ui.cpp:2502 -#: ../../../uibase.cpp:34 -msgid "&Generate Coins" -msgstr "&Genereer coins" - #: ../../../ui.cpp:2505 #: ../../../uibase.cpp:27 msgid "E&xit" @@ -706,7 +701,7 @@ msgid "" "\n" "This product includes software developed by the OpenSSL Project for use in the \n" "OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." msgstr "" "Copyright (c) 2009-2011 Bitcoin-ontwikkelaars\n" "\n" @@ -717,7 +712,8 @@ msgstr "" "\n" "Dit product bevat software ontwikkeld door het OpenSSL project for gebruik \n" "in de OpenSSL Toolkit (http://www.openssl.org/), en cryptografische \n" -"software geschreven door Eric Young (eay@cryptsoft.com)." +"software geschreven door Eric Young (eay@cryptsoft.com)) en UPnP software geschreven\n" +"door Thomas Bernard." #: ../../../uibase.cpp:619 msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)" diff --git a/locale/pt/LC_MESSAGES/bitcoin.mo b/locale/pt/LC_MESSAGES/bitcoin.mo Binary files differindex 7c662c1540..20e100f578 100644 --- a/locale/pt/LC_MESSAGES/bitcoin.mo +++ b/locale/pt/LC_MESSAGES/bitcoin.mo diff --git a/locale/pt/LC_MESSAGES/bitcoin.po b/locale/pt/LC_MESSAGES/bitcoin.po index f37fef20f1..040fb1da68 100644 --- a/locale/pt/LC_MESSAGES/bitcoin.po +++ b/locale/pt/LC_MESSAGES/bitcoin.po @@ -527,11 +527,6 @@ msgstr "&Abrir Bitcoin" msgid "O&ptions..."
msgstr "O&pções"
-#: ../../../ui.cpp:2502
-#: ../../../uibase.cpp:34
-msgid "&Generate Coins"
-msgstr "&Gerar Moedas"
-
#: ../../../ui.cpp:2505
#: ../../../uibase.cpp:27
msgid "E&xit"
@@ -705,7 +700,7 @@ msgid "" "\n"
"This product includes software developed by the OpenSSL Project for use in the \n"
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
-"Eric Young (eay@cryptsoft.com)."
+"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard."
msgstr ""
"Copyright (c) 2009-2010 Bitcoin Developers\n"
"\n"
@@ -716,7 +711,8 @@ msgstr "" "http://www.opensource.org/licenses/mit-license.php.\n"
"Este producto inclui software desenvolvido pelo projecto OpenSSL, para \n"
"ser utilizado no OpenSSL Toolkit (http://www.openssl.org) e software de \n"
-"criptografia desenvolvido por Eric Young (eay@cryptsoft.com)."
+"criptografia desenvolvido por Eric Young (eay@cryptsoft.com)\n"
+"e UPnP software escrito por Thomas Bernard."
#: ../../../uibase.cpp:619
msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)"
diff --git a/locale/ru/LC_MESSAGES/bitcoin.mo b/locale/ru/LC_MESSAGES/bitcoin.mo Binary files differindex 4af3e0dfa0..b44c10ad47 100644 --- a/locale/ru/LC_MESSAGES/bitcoin.mo +++ b/locale/ru/LC_MESSAGES/bitcoin.mo diff --git a/locale/ru/LC_MESSAGES/bitcoin.po b/locale/ru/LC_MESSAGES/bitcoin.po index 1b893bfc42..545f54db2e 100644 --- a/locale/ru/LC_MESSAGES/bitcoin.po +++ b/locale/ru/LC_MESSAGES/bitcoin.po @@ -587,11 +587,6 @@ msgstr "&Открыть Bitcoin" msgid "O&ptions..." msgstr "О&пции..." -#: ../../../ui.cpp:2713 -#: ../../../uibase.cpp:32 -msgid "&Generate Coins" -msgstr "&Генерировать монеты" - #: ../../../ui.cpp:2716 #: ../../../uibase.cpp:25 msgid "E&xit" @@ -769,7 +764,7 @@ msgid "" "\n" "This product includes software developed by the OpenSSL Project for use in the \n" "OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." msgstr "" "Все права защищены (c) 2009-2010 Bitcoin Developers\n" "\n" @@ -780,7 +775,7 @@ msgstr "" "\n" "Этот продукт включает ПО, разработанное проектом OpenSSL для использования в\n" "OpenSSL Toolkit (http://www.openssl.org/), и криптографическое ПО, написанное\n" -"Eric Young (eay@cryptsoft.com)." +"Eric Young (eay@cryptsoft.com) и UPnP программного обеспечения, написанного Thomas Bernard." #: ../../../uibase.cpp:613 msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)" @@ -65,6 +65,14 @@ int fLimitProcessors = false; int nLimitProcessors = 1; int fMinimizeToTray = true; int fMinimizeOnClose = true; +#ifdef USE_UPNP +#if USE_UPNP +int fUseUPnP = true; +#else +int fUseUPnP = false; +#endif +#endif + @@ -136,11 +144,7 @@ bool AddToWallet(const CWalletTx& wtxIn) wtx.fFromMe = wtxIn.fFromMe; fUpdated = true; } - if (wtxIn.fSpent && wtxIn.fSpent != wtx.fSpent) - { - wtx.fSpent = wtxIn.fSpent; - fUpdated = true; - } + fUpdated |= wtx.UpdateSpent(wtxIn.vfSpent); } //// debug print @@ -174,22 +178,12 @@ bool AddToWallet(const CWalletTx& wtxIn) return true; } -bool AddToWalletIfMine(const CTransaction& tx, const CBlock* pblock) -{ - if (tx.IsMine() || mapWallet.count(tx.GetHash())) - { - CWalletTx wtx(tx); - // Get merkle branch if transaction was found in a block - if (pblock) - wtx.SetMerkleBranch(pblock); - return AddToWallet(wtx); - } - return true; -} - -bool AddToWalletIfFromMe(const CTransaction& tx, const CBlock* pblock) +bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate = false) { - if (tx.IsFromMe() || mapWallet.count(tx.GetHash())) + uint256 hash = tx.GetHash(); + bool fExisted = mapWallet.count(hash); + if (fExisted && !fUpdate) return false; + if (fExisted || tx.IsMine() || tx.IsFromMe()) { CWalletTx wtx(tx); // Get merkle branch if transaction was found in a block @@ -197,7 +191,7 @@ bool AddToWalletIfFromMe(const CTransaction& tx, const CBlock* pblock) wtx.SetMerkleBranch(pblock); return AddToWallet(wtx); } - return true; + return false; } bool EraseFromWallet(uint256 hash) @@ -221,10 +215,10 @@ void WalletUpdateSpent(const COutPoint& prevout) if (mi != mapWallet.end()) { CWalletTx& wtx = (*mi).second; - if (!wtx.fSpent && wtx.vout[prevout.n].IsMine()) + if (!wtx.IsSpent(prevout.n) && wtx.vout[prevout.n].IsMine()) { printf("WalletUpdateSpent found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str()); - wtx.fSpent = true; + wtx.MarkSpent(prevout.n); wtx.WriteToDisk(); vWalletUpdated.push_back(prevout.hash); } @@ -407,18 +401,20 @@ int CWalletTx::GetRequestCount() const return nRequests; } -void CWalletTx::GetAmounts(int64& nGenerated, list<pair<string, int64> >& listReceived, +void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, list<pair<string, int64> >& listReceived, list<pair<string, int64> >& listSent, int64& nFee, string& strSentAccount) const { - nGenerated = nFee = 0; + nGeneratedImmature = nGeneratedMature = nFee = 0; listReceived.clear(); listSent.clear(); strSentAccount = strFromAccount; if (IsCoinBase()) { - if (GetDepthInMainChain() >= COINBASE_MATURITY) - nGenerated = GetCredit(); + if (GetBlocksToMaturity() > 0) + nGeneratedImmature = CTransaction::GetCredit(); + else + nGeneratedMature = GetCredit(); return; } @@ -466,15 +462,15 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, i { nGenerated = nReceived = nSent = nFee = 0; - int64 allGenerated, allFee; - allGenerated = allFee = 0; + int64 allGeneratedImmature, allGeneratedMature, allFee; + allGeneratedImmature = allGeneratedMature = allFee = 0; string strSentAccount; list<pair<string, int64> > listReceived; list<pair<string, int64> > listSent; - GetAmounts(allGenerated, listReceived, listSent, allFee, strSentAccount); + GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount); if (strAccount == "") - nGenerated = allGenerated; + nGenerated = allGeneratedMature; if (strAccount == strSentAccount) { foreach(const PAIRTYPE(string,int64)& s, listSent) @@ -685,8 +681,8 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi if (GetSigOpCount() > nSize / 34 || nSize < 100) return error("AcceptToMemoryPool() : nonstandard transaction"); - // Rather not work on nonstandard transactions - if (!IsStandard()) + // Rather not work on nonstandard transactions (unless -testnet) + if (!fTestNet && !IsStandard()) return error("AcceptToMemoryPool() : nonstandard transaction type"); // Do we already have it? @@ -905,22 +901,8 @@ int ScanForWalletTransactions(CBlockIndex* pindexStart) block.ReadFromDisk(pindex, true); foreach(CTransaction& tx, block.vtx) { - uint256 hash = tx.GetHash(); - if (mapWallet.count(hash)) continue; - AddToWalletIfMine(tx, &block); - if (mapWallet.count(hash)) - { - ++ret; - printf("Added missing RECEIVE %s\n", hash.ToString().c_str()); - continue; - } - AddToWalletIfFromMe(tx, &block); - if (mapWallet.count(hash)) - { - ++ret; - printf("Added missing SEND %s\n", hash.ToString().c_str()); - continue; - } + if (AddToWalletIfInvolvingMe(tx, &block)) + ret++; } pindex = pindex->pnext; } @@ -939,34 +921,36 @@ void ReacceptWalletTransactions() foreach(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) { CWalletTx& wtx = item.second; - if (wtx.fSpent && wtx.IsCoinBase()) + if (wtx.IsCoinBase() && wtx.IsSpent(0)) continue; CTxIndex txindex; + bool fUpdated = false; if (txdb.ReadTxIndex(wtx.GetHash(), txindex)) { // Update fSpent if a tx got spent somewhere else by a copy of wallet.dat - if (!wtx.fSpent) + if (txindex.vSpent.size() != wtx.vout.size()) { - if (txindex.vSpent.size() != wtx.vout.size()) - { - printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size()); + printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %d != wtx.vout.size() %d\n", txindex.vSpent.size(), wtx.vout.size()); + continue; + } + for (int i = 0; i < txindex.vSpent.size(); i++) + { + if (wtx.IsSpent(i)) continue; - } - for (int i = 0; i < txindex.vSpent.size(); i++) - { - if (!txindex.vSpent[i].IsNull() && wtx.vout[i].IsMine()) - { - wtx.fSpent = true; - vMissingTx.push_back(txindex.vSpent[i]); - } - } - if (wtx.fSpent) + if (!txindex.vSpent[i].IsNull() && wtx.vout[i].IsMine()) { - printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str()); - wtx.WriteToDisk(); + wtx.MarkSpent(i); + fUpdated = true; + vMissingTx.push_back(txindex.vSpent[i]); } } + if (fUpdated) + { + printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str()); + wtx.MarkDirty(); + wtx.WriteToDisk(); + } } else { @@ -1174,7 +1158,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits) bool IsInitialBlockDownload() { - if (pindexBest == NULL || (!fTestNet && nBestHeight < 105000)) + if (pindexBest == NULL || (!fTestNet && nBestHeight < 118000)) return true; static int64 nLastUpdate; static CBlockIndex* pindexLastBest; @@ -1463,7 +1447,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) // Watch for transactions paying to me foreach(CTransaction& tx, vtx) - AddToWalletIfMine(tx, this); + AddToWalletIfInvolvingMe(tx, this, true); return true; } @@ -1603,6 +1587,15 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) } } + // Update best block in wallet (so we can detect restored wallets) + if (!IsInitialBlockDownload()) + { + CWalletDB walletdb; + const CBlockLocator locator(pindexNew); + if (!walletdb.WriteBestBlock(locator)) + return error("SetBestChain() : WriteWalletBest failed"); + } + // New best block hashBestChain = hash; pindexBest = pindexNew; @@ -1740,7 +1733,8 @@ bool CBlock::AcceptBlock() (nHeight == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) || (nHeight == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) || (nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) || - (nHeight == 105000 && hash != uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))) + (nHeight == 105000 && hash != uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")) || + (nHeight == 118000 && hash != uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553"))) return error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight); // Write block to history file @@ -1757,7 +1751,7 @@ bool CBlock::AcceptBlock() if (hashBestChain == hash) CRITICAL_BLOCK(cs_vNodes) foreach(CNode* pnode, vNodes) - if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 105000)) + if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 118000)) pnode->PushInventory(CInv(MSG_BLOCK, hash)); return true; @@ -2696,7 +2690,7 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) bool fMissingInputs = false; if (tx.AcceptToMemoryPool(true, &fMissingInputs)) { - AddToWalletIfMine(tx, NULL); + AddToWalletIfInvolvingMe(tx, NULL, true); RelayMessage(inv, vMsg); mapAlreadyAskedFor.erase(inv); vWorkQueue.push_back(inv.hash); @@ -2717,7 +2711,7 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (tx.AcceptToMemoryPool(true)) { printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str()); - AddToWalletIfMine(tx, NULL); + AddToWalletIfInvolvingMe(tx, NULL, true); RelayMessage(inv, vMsg); mapAlreadyAskedFor.erase(inv); vWorkQueue.push_back(inv.hash); @@ -3656,9 +3650,9 @@ int64 GetBalance() for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { CWalletTx* pcoin = &(*it).second; - if (!pcoin->IsFinal() || pcoin->fSpent || !pcoin->IsConfirmed()) + if (!pcoin->IsFinal() || !pcoin->IsConfirmed()) continue; - nTotal += pcoin->GetCredit(); + nTotal += pcoin->GetAvailableCredit(); } } @@ -3667,14 +3661,16 @@ int64 GetBalance() } -bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<CWalletTx*>& setCoinsRet) +bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set<pair<CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) { setCoinsRet.clear(); + nValueRet = 0; // List of values less than target - int64 nLowestLarger = INT64_MAX; - CWalletTx* pcoinLowestLarger = NULL; - vector<pair<int64, CWalletTx*> > vValue; + pair<int64, pair<CWalletTx*,unsigned int> > coinLowestLarger; + coinLowestLarger.first = INT64_MAX; + coinLowestLarger.second.first = NULL; + vector<pair<int64, pair<CWalletTx*,unsigned int> > > vValue; int64 nTotalLower = 0; CRITICAL_BLOCK(cs_mapWallet) @@ -3687,30 +3683,43 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set< foreach(CWalletTx* pcoin, vCoins) { - if (!pcoin->IsFinal() || pcoin->fSpent || !pcoin->IsConfirmed()) + if (!pcoin->IsFinal() || !pcoin->IsConfirmed()) + continue; + + if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) continue; int nDepth = pcoin->GetDepthInMainChain(); if (nDepth < (pcoin->IsFromMe() ? nConfMine : nConfTheirs)) continue; - int64 n = pcoin->GetCredit(); - if (n <= 0) - continue; - if (n == nTargetValue) - { - setCoinsRet.insert(pcoin); - return true; - } - else if (n < nTargetValue + CENT) - { - vValue.push_back(make_pair(n, pcoin)); - nTotalLower += n; - } - else if (n < nLowestLarger) + for (int i = 0; i < pcoin->vout.size(); i++) { - nLowestLarger = n; - pcoinLowestLarger = pcoin; + if (pcoin->IsSpent(i) || !pcoin->vout[i].IsMine()) + continue; + + int64 n = pcoin->vout[i].nValue; + + if (n <= 0) + continue; + + pair<int64,pair<CWalletTx*,unsigned int> > coin = make_pair(n,make_pair(pcoin,i)); + + if (n == nTargetValue) + { + setCoinsRet.insert(coin.second); + nValueRet += coin.first; + return true; + } + else if (n < nTargetValue + CENT) + { + vValue.push_back(coin); + nTotalLower += n; + } + else if (n < coinLowestLarger.first) + { + coinLowestLarger = coin; + } } } } @@ -3718,15 +3727,19 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set< if (nTotalLower == nTargetValue || nTotalLower == nTargetValue + CENT) { for (int i = 0; i < vValue.size(); ++i) + { setCoinsRet.insert(vValue[i].second); + nValueRet += vValue[i].first; + } return true; } - if (nTotalLower < nTargetValue + (pcoinLowestLarger ? CENT : 0)) + if (nTotalLower < nTargetValue + (coinLowestLarger.second.first ? CENT : 0)) { - if (pcoinLowestLarger == NULL) + if (coinLowestLarger.second.first == NULL) return false; - setCoinsRet.insert(pcoinLowestLarger); + setCoinsRet.insert(coinLowestLarger.second); + nValueRet += coinLowestLarger.first; return true; } @@ -3769,13 +3782,18 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set< } // If the next larger is still closer, return it - if (pcoinLowestLarger && nLowestLarger - nTargetValue <= nBest - nTargetValue) - setCoinsRet.insert(pcoinLowestLarger); - else + if (coinLowestLarger.second.first && coinLowestLarger.first - nTargetValue <= nBest - nTargetValue) { + setCoinsRet.insert(coinLowestLarger.second); + nValueRet += coinLowestLarger.first; + } + else { for (int i = 0; i < vValue.size(); i++) if (vfBest[i]) + { setCoinsRet.insert(vValue[i].second); + nValueRet += vValue[i].first; + } //// debug print printf("SelectCoins() best subset: "); @@ -3788,11 +3806,11 @@ bool SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, set< return true; } -bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet) +bool SelectCoins(int64 nTargetValue, set<pair<CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) { - return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet) || - SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet) || - SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet)); + return (SelectCoinsMinConf(nTargetValue, 1, 6, setCoinsRet, nValueRet) || + SelectCoinsMinConf(nTargetValue, 1, 1, setCoinsRet, nValueRet) || + SelectCoinsMinConf(nTargetValue, 0, 1, setCoinsRet, nValueRet)); } @@ -3830,15 +3848,14 @@ bool CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CWalletTx& wtxNew.vout.push_back(CTxOut(s.second, s.first)); // Choose coins to use - set<CWalletTx*> setCoins; - if (!SelectCoins(nTotalValue, setCoins)) - return false; + set<pair<CWalletTx*,unsigned int> > setCoins; int64 nValueIn = 0; - foreach(CWalletTx* pcoin, setCoins) + if (!SelectCoins(nTotalValue, setCoins, nValueIn)) + return false; + foreach(PAIRTYPE(CWalletTx*, unsigned int) pcoin, setCoins) { - int64 nCredit = pcoin->GetCredit(); - nValueIn += nCredit; - dPriority += (double)nCredit * pcoin->GetDepthInMainChain(); + int64 nCredit = pcoin.first->vout[pcoin.second].nValue; + dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain(); } // Fill a vout back to self with any change @@ -3871,18 +3888,14 @@ bool CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CWalletTx& reservekey.ReturnKey(); // Fill vin - foreach(CWalletTx* pcoin, setCoins) - for (int nOut = 0; nOut < pcoin->vout.size(); nOut++) - if (pcoin->vout[nOut].IsMine()) - wtxNew.vin.push_back(CTxIn(pcoin->GetHash(), nOut)); + foreach(const PAIRTYPE(CWalletTx*,unsigned int)& coin, setCoins) + wtxNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second)); // Sign int nIn = 0; - foreach(CWalletTx* pcoin, setCoins) - for (int nOut = 0; nOut < pcoin->vout.size(); nOut++) - if (pcoin->vout[nOut].IsMine()) - if (!SignSignature(*pcoin, wtxNew, nIn++)) - return false; + foreach(const PAIRTYPE(CWalletTx*,unsigned int)& coin, setCoins) + if (!SignSignature(*coin.first, wtxNew, nIn++)) + return false; // Limit size unsigned int nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK); @@ -3941,12 +3954,11 @@ bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) // Mark old coins as spent set<CWalletTx*> setCoins; foreach(const CTxIn& txin, wtxNew.vin) - setCoins.insert(&mapWallet[txin.prevout.hash]); - foreach(CWalletTx* pcoin, setCoins) { - pcoin->fSpent = true; - pcoin->WriteToDisk(); - vWalletUpdated.push_back(pcoin->GetHash()); + CWalletTx &pcoin = mapWallet[txin.prevout.hash]; + pcoin.MarkSpent(txin.prevout.n); + pcoin.WriteToDisk(); + vWalletUpdated.push_back(pcoin.GetHash()); } } @@ -3970,35 +3982,35 @@ bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) +// requires cs_main lock string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee) { - CRITICAL_BLOCK(cs_main) + CReserveKey reservekey; + int64 nFeeRequired; + if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired)) { - CReserveKey reservekey; - int64 nFeeRequired; - if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired)) - { - string strError; - if (nValue + nFeeRequired > GetBalance()) - strError = strprintf(_("Error: This is an oversized transaction that requires a transaction fee of %s "), FormatMoney(nFeeRequired).c_str()); - else - strError = _("Error: Transaction creation failed "); - printf("SendMoney() : %s", strError.c_str()); - return strError; - } + string strError; + if (nValue + nFeeRequired > GetBalance()) + strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds "), FormatMoney(nFeeRequired).c_str()); + else + strError = _("Error: Transaction creation failed "); + printf("SendMoney() : %s", strError.c_str()); + return strError; + } - if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending..."), NULL)) - return "ABORTED"; + if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending..."), NULL)) + return "ABORTED"; + + if (!CommitTransaction(wtxNew, reservekey)) + return _("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); - if (!CommitTransaction(wtxNew, reservekey)) - return _("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); - } MainFrameRepaint(); return ""; } +// requires cs_main lock string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee) { // Check amount @@ -22,6 +22,11 @@ static const int64 CENT = 1000000; static const int64 MAX_MONEY = 21000000 * COIN; inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } static const int COINBASE_MATURITY = 100; +#ifdef USE_UPNP +static const int fHaveUPnP = true; +#else +static const int fHaveUPnP = false; +#endif @@ -55,6 +60,7 @@ extern int fLimitProcessors; extern int nLimitProcessors; extern int fMinimizeToTray; extern int fMinimizeOnClose; +extern int fUseUPnP; @@ -738,6 +744,7 @@ public: fMerkleVerified = false; } + IMPLEMENT_SERIALIZE ( nSerSize += SerReadWrite(s, *(CTransaction*)this, nType, nVersion, ser_action); @@ -774,15 +781,17 @@ public: unsigned int fTimeReceivedIsTxTime; unsigned int nTimeReceived; // time received by this node char fFromMe; - char fSpent; string strFromAccount; + vector<char> vfSpent; // memory only mutable char fDebitCached; mutable char fCreditCached; + mutable char fAvailableCreditCached; mutable char fChangeCached; mutable int64 nDebitCached; mutable int64 nCreditCached; + mutable int64 nAvailableCreditCached; mutable int64 nChangeCached; // memory only UI hints @@ -814,13 +823,15 @@ public: fTimeReceivedIsTxTime = false; nTimeReceived = 0; fFromMe = false; - fSpent = false; strFromAccount.clear(); + vfSpent.clear(); fDebitCached = false; fCreditCached = false; + fAvailableCreditCached = false; fChangeCached = false; nDebitCached = 0; nCreditCached = 0; + nAvailableCreditCached = 0; nChangeCached = 0; nTimeDisplayed = 0; nLinesDisplayed = 0; @@ -832,22 +843,96 @@ public: CWalletTx* pthis = const_cast<CWalletTx*>(this); if (fRead) pthis->Init(); - nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion, ser_action); - READWRITE(vtxPrev); + char fSpent = false; - pthis->mapValue["fromaccount"] = pthis->strFromAccount; - READWRITE(mapValue); - pthis->strFromAccount = pthis->mapValue["fromaccount"]; - pthis->mapValue.erase("fromaccount"); - pthis->mapValue.erase("version"); + if (!fRead) + { + pthis->mapValue["fromaccount"] = pthis->strFromAccount; + string str; + foreach(char f, vfSpent) + { + str += (f ? '1' : '0'); + if (f) + fSpent = true; + } + pthis->mapValue["spent"] = str; + } + + nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion,ser_action); + READWRITE(vtxPrev); + READWRITE(mapValue); READWRITE(vOrderForm); READWRITE(fTimeReceivedIsTxTime); READWRITE(nTimeReceived); READWRITE(fFromMe); READWRITE(fSpent); + + if (fRead) + { + pthis->strFromAccount = pthis->mapValue["fromaccount"]; + + if (mapValue.count("spent")) + foreach(char c, pthis->mapValue["spent"]) + pthis->vfSpent.push_back(c != '0'); + else + pthis->vfSpent.assign(vout.size(), fSpent); + } + + pthis->mapValue.erase("fromaccount"); + pthis->mapValue.erase("version"); + pthis->mapValue.erase("spent"); ) + // marks certain txout's as spent + // returns true if any update took place + bool UpdateSpent(const vector<char>& vfNewSpent) + { + bool fReturn = false; + for (int i=0; i < vfNewSpent.size(); i++) + { + if (i == vfSpent.size()) + break; + + if (vfNewSpent[i] && !vfSpent[i]) + { + vfSpent[i] = true; + fReturn = true; + fAvailableCreditCached = false; + } + } + return fReturn; + } + + void MarkDirty() + { + fCreditCached = false; + fAvailableCreditCached = false; + fDebitCached = false; + fChangeCached = false; + } + + void MarkSpent(unsigned int nOut) + { + if (nOut >= vout.size()) + throw runtime_error("CWalletTx::MarkSpent() : nOut out of range"); + vfSpent.resize(vout.size()); + if (!vfSpent[nOut]) + { + vfSpent[nOut] = true; + fAvailableCreditCached = false; + } + } + + bool IsSpent(unsigned int nOut) const + { + if (nOut >= vout.size()) + throw runtime_error("CWalletTx::IsSpent() : nOut out of range"); + if (nOut >= vfSpent.size()) + return false; + return (!!vfSpent[nOut]); + } + int64 GetDebit() const { if (vin.empty()) @@ -873,6 +958,33 @@ public: return nCreditCached; } + int64 GetAvailableCredit(bool fUseCache=true) const + { + // Must wait until coinbase is safely deep enough in the chain before valuing it + if (IsCoinBase() && GetBlocksToMaturity() > 0) + return 0; + + if (fUseCache && fAvailableCreditCached) + return nAvailableCreditCached; + + int64 nCredit = 0; + for (int i = 0; i < vout.size(); i++) + { + if (!IsSpent(i)) + { + const CTxOut &txout = vout[i]; + nCredit += txout.GetCredit(); + if (!MoneyRange(nCredit)) + throw runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); + } + } + + nAvailableCreditCached = nCredit; + fAvailableCreditCached = true; + return nCredit; + } + + int64 GetChange() const { if (fChangeCached) @@ -882,7 +994,7 @@ public: return nChangeCached; } - void GetAmounts(int64& nGenerated, list<pair<string /* address */, int64> >& listReceived, + void GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, list<pair<string /* address */, int64> >& listReceived, list<pair<string /* address */, int64> >& listSent, int64& nFee, string& strSentAccount) const; void GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived, @@ -916,7 +1028,7 @@ public: if (!ptx->IsFinal()) return false; if (ptx->GetDepthInMainChain() >= 1) - return true; + continue; if (!ptx->IsFromMe()) return false; diff --git a/makefile.mingw b/makefile.mingw index 6b849f93f6..1969ecc971 100644 --- a/makefile.mingw +++ b/makefile.mingw @@ -2,6 +2,7 @@ # Distributed under the MIT/X11 software license, see the accompanying # file license.txt or http://www.opensource.org/licenses/mit-license.php. +USE_UPNP:=0 INCLUDEPATHS= \ -I"C:\boost-1.43.0-mgw" \ @@ -25,8 +26,7 @@ LIBS= \ -l boost_program_options-mgw45-mt-s-1_43 \ -l boost_thread-mgw45-mt-s-1_43 \ -l db_cxx \ - -l eay32 \ - -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi + -l eay32 DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH DEBUGFLAGS=-g -D__WXDEBUG__ @@ -34,6 +34,15 @@ CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(I HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h +ifdef USE_UPNP + INCLUDEPATHS += -I"C:\upnpc-exe-win32-20110215" + LIBPATHS += -L"C:\upnpc-exe-win32-20110215" + LIBS += -l miniupnpc -l iphlpapi + DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) +endif + +LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi + OBJS= \ obj/util.o \ obj/script.o \ diff --git a/makefile.osx b/makefile.osx index 5c1ca6fba7..4836ea3f4f 100644 --- a/makefile.osx +++ b/makefile.osx @@ -16,6 +16,8 @@ LIBPATHS= \ WXLIBS=$(shell $(DEPSDIR)/bin/wx-config --libs --static) +USE_UPNP:=0 + LIBS= -dead_strip \ $(DEPSDIR)/lib/libdb_cxx-4.8.a \ $(DEPSDIR)/lib/libboost_system.a \ @@ -44,6 +46,11 @@ OBJS= \ obj/init.o \ cryptopp/obj/sha.o \ cryptopp/obj/cpu.o + +ifdef USE_UPNP + LIBS += $(DEPSDIR)/lib/libminiupnpc.a + DEFS += -DUSE_UPNP=$(USE_UPNP) +endif all: bitcoin diff --git a/makefile.unix b/makefile.unix index 8beebdde2c..4f2da37894 100644 --- a/makefile.unix +++ b/makefile.unix @@ -8,6 +8,10 @@ WXINCLUDEPATHS=$(shell wx-config --cxxflags) WXLIBS=$(shell wx-config --libs) +USE_UPNP:=0 + +DEFS=-DNOPCH -DFOURWAYSSE2 -DUSE_SSL + # for boost 1.37, add -mt to the boost libraries LIBS= \ -Wl,-Bstatic \ @@ -17,13 +21,21 @@ LIBS= \ -l boost_thread \ -l db_cxx \ -l ssl \ - -l crypto \ + -l crypto + +ifdef USE_UPNP + LIBS += -l miniupnpc + DEFS += -DUSE_UPNP=$(USE_UPNP) +endif + +LIBS+= \ -Wl,-Bdynamic \ -l gthread-2.0 \ -l z \ - -l dl + -l dl \ + -l pthread + -DEFS=-DNOPCH -DUSE_SSL DEBUGFLAGS=-g -D__WXDEBUG__ CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ @@ -4,11 +4,21 @@ #include "headers.h" +#ifdef USE_UPNP +#include <miniupnpc/miniwget.h> +#include <miniupnpc/miniupnpc.h> +#include <miniupnpc/upnpcommands.h> +#include <miniupnpc/upnperrors.h> +#endif + static const int MAX_OUTBOUND_CONNECTIONS = 8; void ThreadMessageHandler2(void* parg); void ThreadSocketHandler2(void* parg); void ThreadOpenConnections2(void* parg); +#ifdef USE_UPNP +void ThreadMapPort2(void* parg); +#endif bool OpenNetworkConnection(const CAddress& addrConnect); @@ -857,8 +867,114 @@ void ThreadSocketHandler2(void* parg) +#ifdef USE_UPNP +void ThreadMapPort(void* parg) +{ + IMPLEMENT_RANDOMIZE_STACK(ThreadMapPort(parg)); + try + { + vnThreadsRunning[5]++; + ThreadMapPort2(parg); + vnThreadsRunning[5]--; + } + catch (std::exception& e) { + vnThreadsRunning[5]--; + PrintException(&e, "ThreadMapPort()"); + } catch (...) { + vnThreadsRunning[5]--; + PrintException(NULL, "ThreadMapPort()"); + } + printf("ThreadMapPort exiting\n"); +} + +void ThreadMapPort2(void* parg) +{ + printf("ThreadMapPort started\n"); + + char port[6]; + sprintf(port, "%d", ntohs(GetDefaultPort())); + + const char * rootdescurl = 0; + const char * multicastif = 0; + const char * minissdpdpath = 0; + struct UPNPDev * devlist = 0; + char lanaddr[64]; + + devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); + + struct UPNPUrls urls; + struct IGDdatas data; + int r; + + r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); + if (r == 1) + { + char intClient[16]; + char intPort[6]; + +#ifndef __WXMSW__ + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port, port, lanaddr, 0, "TCP", 0); +#else + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port, port, lanaddr, 0, "TCP", 0, "0"); +#endif + if(r!=UPNPCOMMAND_SUCCESS) + printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", + port, port, lanaddr, r, strupnperror(r)); + else + printf("UPnP Port Mapping successful.\n"); + loop { + if (fShutdown || !fUseUPnP) + { + r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port, "TCP", 0); + printf("UPNP_DeletePortMapping() returned : %d\n", r); + freeUPNPDevlist(devlist); devlist = 0; + FreeUPNPUrls(&urls); + return; + } + Sleep(2000); + } + } else { + printf("No valid UPnP IGDs found\n"); + freeUPNPDevlist(devlist); devlist = 0; + if (r != 0) + FreeUPNPUrls(&urls); + loop { + if (fShutdown || !fUseUPnP) + return; + Sleep(2000); + } + } +} + +void MapPort(bool fMapPort) +{ + if (fUseUPnP != fMapPort) + { + fUseUPnP = fMapPort; + CWalletDB().WriteSetting("fUseUPnP", fUseUPnP); + } + if (fUseUPnP && vnThreadsRunning[5] < 1) + { + if (!CreateThread(ThreadMapPort, NULL)) + printf("Error: ThreadMapPort(ThreadMapPort) failed\n"); + } +} +#endif + + + + + + + + + + static const char *strDNSSeed[] = { "bitseed.xf2.org", + "bitseed.bitcoin.org.uk", }; void DNSAddressSeed() @@ -1409,6 +1525,10 @@ void StartNode(void* parg) // Start threads // + // Map ports with UPnP + if (fHaveUPnP) + MapPort(fUseUPnP); + // Get addresses from IRC and advertise ours if (!CreateThread(ThreadIRCSeed, NULL)) printf("Error: CreateThread(ThreadIRCSeed) failed\n"); @@ -1434,7 +1554,11 @@ bool StopNode() fShutdown = true; nTransactionsUpdated++; int64 nStart = GetTime(); - while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0) + while (vnThreadsRunning[0] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0 +#ifdef USE_UPNP + || vnThreadsRunning[5] > 0 +#endif + ) { if (GetTime() - nStart > 20) break; @@ -1445,6 +1569,7 @@ bool StopNode() if (vnThreadsRunning[2] > 0) printf("ThreadMessageHandler still running\n"); if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n"); if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n"); + if (fHaveUPnP && vnThreadsRunning[5] > 0) printf("ThreadMapPort still running\n"); while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0) Sleep(20); Sleep(50); @@ -30,6 +30,7 @@ CNode* FindNode(unsigned int ip); CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0); void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1); bool AnySubscribed(unsigned int nChannel); +void MapPort(bool fMapPort); void DNSAddressSeed(); bool BindListenPort(string& strError=REF(string())); void StartNode(void* parg); @@ -315,46 +315,45 @@ Value getnewaddress(const Array& params, bool fHelp) } +// requires cs_main, cs_mapWallet locks string GetAccountAddress(string strAccount, bool bForceNew=false) { string strAddress; - CRITICAL_BLOCK(cs_mapWallet) - { - CWalletDB walletdb; - walletdb.TxnBegin(); - - CAccount account; - walletdb.ReadAccount(strAccount, account); + CWalletDB walletdb; + walletdb.TxnBegin(); - // Check if the current key has been used - if (!account.vchPubKey.empty()) - { - CScript scriptPubKey; - scriptPubKey.SetBitcoinAddress(account.vchPubKey); - for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); - it != mapWallet.end() && !account.vchPubKey.empty(); - ++it) - { - const CWalletTx& wtx = (*it).second; - foreach(const CTxOut& txout, wtx.vout) - if (txout.scriptPubKey == scriptPubKey) - account.vchPubKey.clear(); - } - } + CAccount account; + walletdb.ReadAccount(strAccount, account); - // Generate a new key - if (account.vchPubKey.empty() || bForceNew) + // Check if the current key has been used + if (!account.vchPubKey.empty()) + { + CScript scriptPubKey; + scriptPubKey.SetBitcoinAddress(account.vchPubKey); + for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); + it != mapWallet.end() && !account.vchPubKey.empty(); + ++it) { - account.vchPubKey = GetKeyFromKeyPool(); - string strAddress = PubKeyToAddress(account.vchPubKey); - SetAddressBookName(strAddress, strAccount); - walletdb.WriteAccount(strAccount, account); + const CWalletTx& wtx = (*it).second; + foreach(const CTxOut& txout, wtx.vout) + if (txout.scriptPubKey == scriptPubKey) + account.vchPubKey.clear(); } + } - walletdb.TxnCommit(); - strAddress = PubKeyToAddress(account.vchPubKey); + // Generate a new key + if (account.vchPubKey.empty() || bForceNew) + { + account.vchPubKey = GetKeyFromKeyPool(); + string strAddress = PubKeyToAddress(account.vchPubKey); + SetAddressBookName(strAddress, strAccount); + walletdb.WriteAccount(strAccount, account); } + + walletdb.TxnCommit(); + strAddress = PubKeyToAddress(account.vchPubKey); + return strAddress; } @@ -368,7 +367,15 @@ Value getaccountaddress(const Array& params, bool fHelp) // Parse the account first so we don't generate a key if there's an error string strAccount = AccountFromValue(params[0]); - return GetAccountAddress(strAccount); + Value ret; + + CRITICAL_BLOCK(cs_main) + CRITICAL_BLOCK(cs_mapWallet) + { + ret = GetAccountAddress(strAccount); + } + + return ret; } @@ -392,6 +399,8 @@ Value setaccount(const Array& params, bool fHelp) strAccount = AccountFromValue(params[1]); // Detect when changing the account of an address that is the 'unused current key' of another account: + CRITICAL_BLOCK(cs_main) + CRITICAL_BLOCK(cs_mapWallet) CRITICAL_BLOCK(cs_mapAddressBook) { if (mapAddressBook.count(strAddress)) @@ -475,9 +484,13 @@ Value sendtoaddress(const Array& params, bool fHelp) if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) wtx.mapValue["to"] = params[3].get_str(); - string strError = SendMoneyToBitcoinAddress(strAddress, nAmount, wtx); - if (strError != "") - throw JSONRPCError(-4, strError); + CRITICAL_BLOCK(cs_main) + { + string strError = SendMoneyToBitcoinAddress(strAddress, nAmount, wtx); + if (strError != "") + throw JSONRPCError(-4, strError); + } + return wtx.GetHash().GetHex(); } @@ -627,40 +640,39 @@ Value getbalance(const Array& params, bool fHelp) if (params.size() == 0) return ValueFromAmount(GetBalance()); + int nMinDepth = 1; + if (params.size() > 1) + nMinDepth = params[1].get_int(); + if (params[0].get_str() == "*") { // Calculate total balance a different way from GetBalance() // (GetBalance() sums up all unspent TxOuts) // getbalance and getbalance '*' should always return the same number. int64 nBalance = 0; - vector<string> vAccounts; for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - int64 allGenerated, allFee; - allGenerated = allFee = 0; + if (!wtx.IsFinal()) + continue; + + int64 allGeneratedImmature, allGeneratedMature, allFee; + allGeneratedImmature = allGeneratedMature = allFee = 0; string strSentAccount; list<pair<string, int64> > listReceived; list<pair<string, int64> > listSent; - wtx.GetAmounts(allGenerated, listReceived, listSent, allFee, strSentAccount); - foreach(const PAIRTYPE(string,int64)& r, listReceived) - { - nBalance += r.second; - if (!count(vAccounts.begin(), vAccounts.end(), r.first)) - vAccounts.push_back(r.first); - } + wtx.GetAmounts(allGeneratedImmature, allGeneratedMature, listReceived, listSent, allFee, strSentAccount); + if (wtx.GetDepthInMainChain() >= nMinDepth) + foreach(const PAIRTYPE(string,int64)& r, listReceived) + nBalance += r.second; foreach(const PAIRTYPE(string,int64)& r, listSent) nBalance -= r.second; nBalance -= allFee; - nBalance += allGenerated; + nBalance += allGeneratedMature; } - printf("Found %d accounts\n", vAccounts.size()); return ValueFromAmount(nBalance); } string strAccount = AccountFromValue(params[0]); - int nMinDepth = 1; - if (params.size() > 1) - nMinDepth = params[1].get_int(); int64 nBalance = GetAccountBalance(strAccount, nMinDepth); @@ -752,6 +764,7 @@ Value sendfrom(const Array& params, bool fHelp) if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty()) wtx.mapValue["to"] = params[5].get_str(); + CRITICAL_BLOCK(cs_main) CRITICAL_BLOCK(cs_mapWallet) { // Check funds @@ -808,6 +821,7 @@ Value sendmany(const Array& params, bool fHelp) vecSend.push_back(make_pair(scriptPubKey, nAmount)); } + CRITICAL_BLOCK(cs_main) CRITICAL_BLOCK(cs_mapWallet) { // Check funds @@ -978,21 +992,29 @@ Value listreceivedbyaccount(const Array& params, bool fHelp) void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret) { - int64 nGenerated, nFee; + int64 nGeneratedImmature, nGeneratedMature, nFee; string strSentAccount; list<pair<string, int64> > listReceived; list<pair<string, int64> > listSent; - wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount); + wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount); bool fAllAccounts = (strAccount == string("*")); // Generated blocks assigned to account "" - if (nGenerated != 0 && (fAllAccounts || strAccount == "")) + if ((nGeneratedMature+nGeneratedImmature) != 0 && (fAllAccounts || strAccount == "")) { Object entry; entry.push_back(Pair("account", string(""))); - entry.push_back(Pair("category", "generate")); - entry.push_back(Pair("amount", ValueFromAmount(nGenerated))); + if (nGeneratedImmature) + { + entry.push_back(Pair("category", wtx.GetDepthInMainChain() ? "immature" : "orphan")); + entry.push_back(Pair("amount", ValueFromAmount(nGeneratedImmature))); + } + else + { + entry.push_back(Pair("category", "generate")); + entry.push_back(Pair("amount", ValueFromAmount(nGeneratedMature))); + } if (fLong) WalletTxToJSON(wtx, entry); ret.push_back(entry); @@ -1135,23 +1157,26 @@ Value listaccounts(const Array& params, bool fHelp) CRITICAL_BLOCK(cs_mapWallet) CRITICAL_BLOCK(cs_mapAddressBook) { - foreach(const PAIRTYPE(string, string)& entry, mapAddressBook) - mapAccountBalances[entry.second] = 0; + foreach(const PAIRTYPE(string, string)& entry, mapAddressBook) { + uint160 hash160; + if(AddressToHash160(entry.first, hash160) && mapPubKeys.count(hash160)) // This address belongs to me + mapAccountBalances[entry.second] = 0; + } for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - int64 nGenerated, nFee; + int64 nGeneratedImmature, nGeneratedMature, nFee; string strSentAccount; list<pair<string, int64> > listReceived; list<pair<string, int64> > listSent; - wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount); + wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount); mapAccountBalances[strSentAccount] -= nFee; foreach(const PAIRTYPE(string, int64)& s, listSent) mapAccountBalances[strSentAccount] -= s.second; if (wtx.GetDepthInMainChain() >= nMinDepth) { - mapAccountBalances[""] += nGenerated; + mapAccountBalances[""] += nGeneratedMature; foreach(const PAIRTYPE(string, int64)& r, listReceived) if (mapAddressBook.count(r.first)) mapAccountBalances[mapAddressBook[r.first]] += r.second; @@ -1454,7 +1479,7 @@ string HTTPPost(const string& strMsg, const map<string,string>& mapRequestHeader { ostringstream s; s << "POST / HTTP/1.1\r\n" - << "User-Agent: json-rpc/1.0\r\n" + << "User-Agent: bitcoin-json-rpc/" << FormatFullVersion() << "\r\n" << "Host: 127.0.0.1\r\n" << "Content-Type: application/json\r\n" << "Content-Length: " << strMsg.size() << "\r\n" @@ -1468,11 +1493,14 @@ string HTTPPost(const string& strMsg, const map<string,string>& mapRequestHeader string rfc1123Time() { - char buffer[32]; + char buffer[64]; time_t now; time(&now); struct tm* now_gmt = gmtime(&now); - strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S %Z", now_gmt); + string locale(setlocale(LC_TIME, NULL)); + setlocale(LC_TIME, "C"); // we want posix (aka "C") weekday/month strings + strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S +0000", now_gmt); + setlocale(LC_TIME, locale.c_str()); return string(buffer); } @@ -1481,7 +1509,7 @@ string HTTPReply(int nStatus, const string& strMsg) if (nStatus == 401) return strprintf("HTTP/1.0 401 Authorization Required\r\n" "Date: %s\r\n" - "Server: bitcoin-json-rpc\r\n" + "Server: bitcoin-json-rpc/%s\r\n" "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n" "Content-Type: text/html\r\n" "Content-Length: 296\r\n" @@ -1494,7 +1522,7 @@ string HTTPReply(int nStatus, const string& strMsg) "<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>\r\n" "</HEAD>\r\n" "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n" - "</HTML>\r\n", rfc1123Time().c_str()); + "</HTML>\r\n", rfc1123Time().c_str(), FormatFullVersion().c_str()); string strStatus; if (nStatus == 200) strStatus = "OK"; else if (nStatus == 400) strStatus = "Bad Request"; @@ -1506,13 +1534,14 @@ string HTTPReply(int nStatus, const string& strMsg) "Connection: close\r\n" "Content-Length: %d\r\n" "Content-Type: application/json\r\n" - "Server: bitcoin-json-rpc/1.0\r\n" + "Server: bitcoin-json-rpc/%s\r\n" "\r\n" "%s", nStatus, strStatus.c_str(), rfc1123Time().c_str(), strMsg.size(), + FormatFullVersion().c_str(), strMsg.c_str()); } diff --git a/serialize.h b/serialize.h index 383c987864..ee39c0703d 100644 --- a/serialize.h +++ b/serialize.h @@ -25,7 +25,7 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 32100; +static const int VERSION = 32200; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; @@ -4,7 +4,7 @@ RequestExecutionLevel highest # General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
-!define VERSION 0.3.20
+!define VERSION 0.3.22
!define COMPANY "Bitcoin project"
!define URL http://www.bitcoin.org/
@@ -39,12 +39,12 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English
# Installer attributes
-OutFile bitcoin-0.3.20-win32-setup.exe
+OutFile bitcoin-0.3.22-win32-setup.exe
InstallDir $PROGRAMFILES\Bitcoin
CRCCheck on
XPStyle on
ShowInstDetails show
-VIProductVersion 0.3.20.0
+VIProductVersion 0.3.22.0
VIAddVersionKey ProductName Bitcoin
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
@@ -1094,12 +1094,6 @@ void CMainFrame::OnMenuFileExit(wxCommandEvent& event) Close(true); } -void CMainFrame::OnMenuOptionsGenerate(wxCommandEvent& event) -{ - // Options->Generate Coins - GenerateBitcoins(event.IsChecked()); -} - void CMainFrame::OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event) { event.Check(fGenerateBitcoins); @@ -1655,16 +1649,13 @@ COptionsDialog::COptionsDialog(wxWindow* parent) : COptionsDialogBase(parent) // Init values m_textCtrlTransactionFee->SetValue(FormatMoney(nTransactionFee)); - m_checkBoxLimitProcessors->SetValue(fLimitProcessors); - m_spinCtrlLimitProcessors->Enable(fLimitProcessors); - m_spinCtrlLimitProcessors->SetValue(nLimitProcessors); - int nProcessors = wxThread::GetCPUCount(); - if (nProcessors < 1) - nProcessors = 999; - m_spinCtrlLimitProcessors->SetRange(1, nProcessors); m_checkBoxStartOnSystemStartup->SetValue(fTmpStartOnSystemStartup = GetStartOnSystemStartup()); m_checkBoxMinimizeToTray->SetValue(fMinimizeToTray); m_checkBoxMinimizeOnClose->SetValue(fMinimizeOnClose); + if (fHaveUPnP) + m_checkBoxUseUPnP->SetValue(fUseUPnP); + else + m_checkBoxUseUPnP->Enable(false); m_checkBoxUseProxy->SetValue(fUseProxy); m_textCtrlProxyIP->Enable(fUseProxy); m_textCtrlProxyPort->Enable(fUseProxy); @@ -1698,11 +1689,6 @@ void COptionsDialog::OnKillFocusTransactionFee(wxFocusEvent& event) m_textCtrlTransactionFee->SetValue(FormatMoney(nTmp)); } -void COptionsDialog::OnCheckBoxLimitProcessors(wxCommandEvent& event) -{ - m_spinCtrlLimitProcessors->Enable(event.IsChecked()); -} - void COptionsDialog::OnCheckBoxUseProxy(wxCommandEvent& event) { m_textCtrlProxyIP->Enable(event.IsChecked()); @@ -1751,20 +1737,6 @@ void COptionsDialog::OnButtonApply(wxCommandEvent& event) if (ParseMoney(m_textCtrlTransactionFee->GetValue(), nTransactionFee) && nTransactionFee != nPrevTransactionFee) walletdb.WriteSetting("nTransactionFee", nTransactionFee); - int nPrevMaxProc = (fLimitProcessors ? nLimitProcessors : INT_MAX); - if (fLimitProcessors != m_checkBoxLimitProcessors->GetValue()) - { - fLimitProcessors = m_checkBoxLimitProcessors->GetValue(); - walletdb.WriteSetting("fLimitProcessors", fLimitProcessors); - } - if (nLimitProcessors != m_spinCtrlLimitProcessors->GetValue()) - { - nLimitProcessors = m_spinCtrlLimitProcessors->GetValue(); - walletdb.WriteSetting("nLimitProcessors", nLimitProcessors); - } - if (fGenerateBitcoins && (fLimitProcessors ? nLimitProcessors : INT_MAX) > nPrevMaxProc) - GenerateBitcoins(fGenerateBitcoins); - if (fTmpStartOnSystemStartup != m_checkBoxStartOnSystemStartup->GetValue()) { fTmpStartOnSystemStartup = m_checkBoxStartOnSystemStartup->GetValue(); @@ -1784,6 +1756,13 @@ void COptionsDialog::OnButtonApply(wxCommandEvent& event) walletdb.WriteSetting("fMinimizeOnClose", fMinimizeOnClose); } + if (fHaveUPnP && fUseUPnP != m_checkBoxUseUPnP->GetValue()) + { + fUseUPnP = m_checkBoxUseUPnP->GetValue(); + walletdb.WriteSetting("fUseUPnP", fUseUPnP); + MapPort(fUseUPnP); + } + fUseProxy = m_checkBoxUseProxy->GetValue(); walletdb.WriteSetting("fUseProxy", fUseProxy); @@ -1803,7 +1782,7 @@ void COptionsDialog::OnButtonApply(wxCommandEvent& event) CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent) { - m_staticTextVersion->SetLabel(strprintf(_("version %s%s BETA"), FormatVersion(VERSION).c_str(), pszSubVer)); + m_staticTextVersion->SetLabel(strprintf(_("version %s"), FormatFullVersion().c_str())); // Change (c) into UTF-8 or ANSI copyright symbol wxString str = m_staticTextMain->GetLabel(); @@ -1848,6 +1827,7 @@ CSendDialog::CSendDialog(wxWindow* parent, const wxString& strAddress) : CSendDi m_bitmapCheckMark->Show(false); fEnabledPrev = true; m_textCtrlAddress->SetFocus(); + //// todo: should add a display of your balance for convenience #ifndef __WXMSW__ wxFont fontTmp = m_staticTextInstructions->GetFont(); @@ -1856,7 +1836,7 @@ CSendDialog::CSendDialog(wxWindow* parent, const wxString& strAddress) : CSendDi m_staticTextInstructions->SetFont(fontTmp); SetSize(725, 180); #endif - + // Set Icon wxIcon iconSend; iconSend.CopyFromBitmap(wxBitmap(send16noshadow_xpm)); @@ -1934,20 +1914,24 @@ void CSendDialog::OnButtonSend(wxCommandEvent& event) if (fBitcoinAddress) { - // Send to bitcoin address - CScript scriptPubKey; - scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG; - - string strError = SendMoney(scriptPubKey, nValue, wtx, true); - if (strError == "") - wxMessageBox(_("Payment sent "), _("Sending...")); - else if (strError == "ABORTED") - return; // leave send dialog open - else - { - wxMessageBox(strError + " ", _("Sending...")); - EndModal(false); - } + CRITICAL_BLOCK(cs_main) + { + // Send to bitcoin address + CScript scriptPubKey; + scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG; + + string strError = SendMoney(scriptPubKey, nValue, wtx, true); + if (strError == "") + wxMessageBox(_("Payment sent "), _("Sending...")); + else if (strError == "ABORTED") + return; // leave send dialog open + else + { + wxMessageBox(strError + " ", _("Sending...")); + EndModal(false); + return; + } + } } else { @@ -2233,7 +2217,7 @@ void CSendingDialog::OnReply2(CDataStream& vRecv) if (!CreateTransaction(scriptPubKey, nPrice, wtx, reservekey, nFeeRequired)) { if (nPrice + nFeeRequired > GetBalance()) - Error(strprintf(_("This is an oversized transaction that requires a transaction fee of %s"), FormatMoney(nFeeRequired).c_str())); + Error(strprintf(_("This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds"), FormatMoney(nFeeRequired).c_str())); else Error(_("Transaction creation failed")); return; @@ -2591,6 +2575,7 @@ void CAddressBookDialog::OnClose(wxCloseEvent& event) enum { ID_TASKBAR_RESTORE = 10001, + ID_TASKBAR_SEND, ID_TASKBAR_OPTIONS, ID_TASKBAR_GENERATE, ID_TASKBAR_EXIT, @@ -2599,8 +2584,8 @@ enum BEGIN_EVENT_TABLE(CMyTaskBarIcon, wxTaskBarIcon) EVT_TASKBAR_LEFT_DCLICK(CMyTaskBarIcon::OnLeftButtonDClick) EVT_MENU(ID_TASKBAR_RESTORE, CMyTaskBarIcon::OnMenuRestore) + EVT_MENU(ID_TASKBAR_SEND, CMyTaskBarIcon::OnMenuSend) EVT_MENU(ID_TASKBAR_OPTIONS, CMyTaskBarIcon::OnMenuOptions) - EVT_MENU(ID_TASKBAR_GENERATE, CMyTaskBarIcon::OnMenuGenerate) EVT_UPDATE_UI(ID_TASKBAR_GENERATE, CMyTaskBarIcon::OnUpdateUIGenerate) EVT_MENU(ID_TASKBAR_EXIT, CMyTaskBarIcon::OnMenuExit) END_EVENT_TABLE() @@ -2651,6 +2636,13 @@ void CMyTaskBarIcon::OnMenuRestore(wxCommandEvent& event) Restore(); } +void CMyTaskBarIcon::OnMenuSend(wxCommandEvent& event) +{ + // Taskbar: Send + CSendDialog dialog(pframeMain); + dialog.ShowModal(); +} + void CMyTaskBarIcon::OnMenuOptions(wxCommandEvent& event) { // Since it's modal, get the main window to do it @@ -2667,11 +2659,6 @@ void CMyTaskBarIcon::Restore() pframeMain->Raise(); } -void CMyTaskBarIcon::OnMenuGenerate(wxCommandEvent& event) -{ - GenerateBitcoins(event.IsChecked()); -} - void CMyTaskBarIcon::OnUpdateUIGenerate(wxUpdateUIEvent& event) { event.Check(fGenerateBitcoins); @@ -2692,8 +2679,8 @@ wxMenu* CMyTaskBarIcon::CreatePopupMenu() { wxMenu* pmenu = new wxMenu; pmenu->Append(ID_TASKBAR_RESTORE, _("&Open Bitcoin")); + pmenu->Append(ID_TASKBAR_SEND, _("&Send Bitcoins")); pmenu->Append(ID_TASKBAR_OPTIONS, _("O&ptions...")); - pmenu->AppendCheckItem(ID_TASKBAR_GENERATE, _("&Generate Coins"))->Check(fGenerateBitcoins); #ifndef __WXMAC_OSX__ // Mac has built-in quit menu pmenu->AppendSeparator(); pmenu->Append(ID_TASKBAR_EXIT, _("E&xit")); @@ -2805,6 +2792,10 @@ bool CMyApp::Initialize(int& argc, wxChar** argv) } if (pid > 0) pthread_exit((void*)0); + + pid_t sid = setsid(); + if (sid < 0) + fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); } return true; @@ -2821,9 +2812,6 @@ bool CMyApp::OnInit() extern int g_isPainting; g_isPainting = 10000; #endif -#ifdef GUI - wxImage::AddHandler(new wxPNGHandler); -#endif #if defined(__WXMSW__ ) || defined(__WXMAC_OSX__) SetAppName("Bitcoin"); #else @@ -52,7 +52,6 @@ protected: void OnPaint(wxPaintEvent& event); void OnPaintListCtrl(wxPaintEvent& event); void OnMenuFileExit(wxCommandEvent& event); - void OnMenuOptionsGenerate(wxCommandEvent& event); void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event); void OnMenuOptionsChangeYourAddress(wxCommandEvent& event); void OnMenuOptionsOptions(wxCommandEvent& event); @@ -127,7 +126,6 @@ protected: // Event handlers void OnListBox(wxCommandEvent& event); void OnKillFocusTransactionFee(wxFocusEvent& event); - void OnCheckBoxLimitProcessors(wxCommandEvent& event); void OnCheckBoxUseProxy(wxCommandEvent& event); void OnKillFocusProxy(wxFocusEvent& event); @@ -323,6 +321,7 @@ protected: // Event handlers void OnLeftButtonDClick(wxTaskBarIconEvent& event); void OnMenuRestore(wxCommandEvent& event); + void OnMenuSend(wxCommandEvent& event); void OnMenuOptions(wxCommandEvent& event); void OnUpdateUIGenerate(wxUpdateUIEvent& event); void OnMenuGenerate(wxCommandEvent& event); diff --git a/uibase.cpp b/uibase.cpp index f3ff3bf1ef..1b901a1edb 100644 --- a/uibase.cpp +++ b/uibase.cpp @@ -28,10 +28,6 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString& m_menubar->Append( m_menuFile, _("&File") ); m_menuOptions = new wxMenu(); - wxMenuItem* m_menuOptionsGenerateBitcoins; - m_menuOptionsGenerateBitcoins = new wxMenuItem( m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString( _("&Generate Coins") ) , wxEmptyString, wxITEM_CHECK ); - m_menuOptions->Append( m_menuOptionsGenerateBitcoins ); - wxMenuItem* m_menuOptionsChangeYourAddress; m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Your Receiving Addresses...") ) , wxEmptyString, wxITEM_NORMAL ); m_menuOptions->Append( m_menuOptionsChangeYourAddress ); @@ -190,8 +186,6 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString& this->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) ); this->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) ); this->Connect( m_menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) ); - this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) ); - this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) ); this->Connect( m_menuOptionsChangeYourAddress->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) ); this->Connect( m_menuOptionsOptions->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsOptions ) ); this->Connect( m_menuHelpAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuHelpAbout ) ); @@ -250,8 +244,6 @@ CMainFrameBase::~CMainFrameBase() this->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) ); this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) ); - this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) ); - this->Disconnect( wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsOptions ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuHelpAbout ) ); @@ -350,27 +342,15 @@ COptionsDialogBase::COptionsDialogBase( wxWindow* parent, wxWindowID id, const w bSizer69->Add( 0, 16, 0, wxEXPAND, 5 ); - wxBoxSizer* bSizer71; - bSizer71 = new wxBoxSizer( wxHORIZONTAL ); - - m_checkBoxLimitProcessors = new wxCheckBox( m_panelMain, wxID_ANY, _("&Limit coin generation to"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer71->Add( m_checkBoxLimitProcessors, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - m_spinCtrlLimitProcessors = new wxSpinCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 48,-1 ), wxSP_ARROW_KEYS, 1, 999, 1 ); - bSizer71->Add( m_spinCtrlLimitProcessors, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_staticText35 = new wxStaticText( m_panelMain, wxID_ANY, _("processors"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText35->Wrap( -1 ); - bSizer71->Add( m_staticText35, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - bSizer69->Add( bSizer71, 0, 0, 5 ); - m_checkBoxStartOnSystemStartup = new wxCheckBox( m_panelMain, wxID_ANY, _("&Start Bitcoin on system startup"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer69->Add( m_checkBoxStartOnSystemStartup, 0, wxALL, 5 ); m_checkBoxMinimizeToTray = new wxCheckBox( m_panelMain, wxID_ANY, _("&Minimize to the tray instead of the taskbar"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer69->Add( m_checkBoxMinimizeToTray, 0, wxALL, 5 ); + m_checkBoxUseUPnP = new wxCheckBox( m_panelMain, wxID_ANY, _("Map port using &UPnP"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer69->Add( m_checkBoxUseUPnP, 0, wxALL, 5 ); + m_checkBoxMinimizeOnClose = new wxCheckBox( m_panelMain, wxID_ANY, _("M&inimize to the tray on close"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer69->Add( m_checkBoxMinimizeOnClose, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); @@ -476,7 +456,6 @@ COptionsDialogBase::COptionsDialogBase( wxWindow* parent, wxWindowID id, const w // Connect Events m_listBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this ); - m_checkBoxLimitProcessors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this ); m_checkBoxMinimizeToTray->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this ); m_checkBoxUseProxy->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this ); m_textCtrlProxyIP->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this ); @@ -491,7 +470,6 @@ COptionsDialogBase::~COptionsDialogBase() { // Disconnect Events m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( COptionsDialogBase::OnListBox ), NULL, this ); - m_checkBoxLimitProcessors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxLimitProcessors ), NULL, this ); m_checkBoxMinimizeToTray->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxMinimizeToTray ), NULL, this ); m_checkBoxUseProxy->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( COptionsDialogBase::OnCheckBoxUseProxy ), NULL, this ); m_textCtrlProxyIP->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( COptionsDialogBase::OnKillFocusProxy ), NULL, this ); @@ -544,7 +522,7 @@ CAboutDialogBase::CAboutDialogBase( wxWindow* parent, wxWindowID id, const wxStr bSizer631->Add( 0, 4, 0, wxEXPAND, 5 ); - m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2011 Bitcoin Developers\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2011 Bitcoin Developers\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard."), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextMain->Wrap( -1 ); bSizer631->Add( m_staticTextMain, 0, wxALL, 5 ); @@ -34,36 +34,34 @@ #include <wx/dialog.h> #include <wx/listbox.h> #include <wx/checkbox.h> -#include <wx/spinctrl.h> #include <wx/scrolwin.h> #include <wx/statbmp.h> /////////////////////////////////////////////////////////////////////////// #define wxID_MAINFRAME 1000 -#define wxID_OPTIONSGENERATEBITCOINS 1001 -#define wxID_BUTTONSEND 1002 -#define wxID_BUTTONRECEIVE 1003 -#define wxID_TEXTCTRLADDRESS 1004 -#define wxID_BUTTONNEW 1005 -#define wxID_BUTTONCOPY 1006 -#define wxID_PROXYIP 1007 -#define wxID_PROXYPORT 1008 -#define wxID_TRANSACTIONFEE 1009 -#define wxID_TEXTCTRLPAYTO 1010 -#define wxID_BUTTONPASTE 1011 -#define wxID_BUTTONADDRESSBOOK 1012 -#define wxID_TEXTCTRLAMOUNT 1013 -#define wxID_CHOICETRANSFERTYPE 1014 -#define wxID_LISTCTRL 1015 -#define wxID_BUTTONRENAME 1016 -#define wxID_PANELSENDING 1017 -#define wxID_LISTCTRLSENDING 1018 -#define wxID_PANELRECEIVING 1019 -#define wxID_LISTCTRLRECEIVING 1020 -#define wxID_BUTTONDELETE 1021 -#define wxID_BUTTONEDIT 1022 -#define wxID_TEXTCTRL 1023 +#define wxID_BUTTONSEND 1001 +#define wxID_BUTTONRECEIVE 1002 +#define wxID_TEXTCTRLADDRESS 1003 +#define wxID_BUTTONNEW 1004 +#define wxID_BUTTONCOPY 1005 +#define wxID_PROXYIP 1006 +#define wxID_PROXYPORT 1007 +#define wxID_TRANSACTIONFEE 1008 +#define wxID_TEXTCTRLPAYTO 1009 +#define wxID_BUTTONPASTE 1010 +#define wxID_BUTTONADDRESSBOOK 1011 +#define wxID_TEXTCTRLAMOUNT 1012 +#define wxID_CHOICETRANSFERTYPE 1013 +#define wxID_LISTCTRL 1014 +#define wxID_BUTTONRENAME 1015 +#define wxID_PANELSENDING 1016 +#define wxID_LISTCTRLSENDING 1017 +#define wxID_PANELRECEIVING 1018 +#define wxID_LISTCTRLRECEIVING 1019 +#define wxID_BUTTONDELETE 1020 +#define wxID_BUTTONEDIT 1021 +#define wxID_TEXTCTRL 1022 /////////////////////////////////////////////////////////////////////////////// /// Class CMainFrameBase @@ -99,8 +97,6 @@ class CMainFrameBase : public wxFrame virtual void OnMouseEvents( wxMouseEvent& event ) { event.Skip(); } virtual void OnPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnMenuFileExit( wxCommandEvent& event ) { event.Skip(); } - virtual void OnMenuOptionsGenerate( wxCommandEvent& event ) { event.Skip(); } - virtual void OnUpdateUIOptionsGenerate( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnMenuOptionsChangeYourAddress( wxCommandEvent& event ) { event.Skip(); } virtual void OnMenuOptionsOptions( wxCommandEvent& event ) { event.Skip(); } virtual void OnMenuHelpAbout( wxCommandEvent& event ) { event.Skip(); } @@ -165,11 +161,9 @@ class COptionsDialogBase : public wxDialog wxScrolledWindow* m_scrolledWindow; wxPanel* m_panelMain; - wxCheckBox* m_checkBoxLimitProcessors; - wxSpinCtrl* m_spinCtrlLimitProcessors; - wxStaticText* m_staticText35; wxCheckBox* m_checkBoxStartOnSystemStartup; wxCheckBox* m_checkBoxMinimizeToTray; + wxCheckBox* m_checkBoxUseUPnP; wxCheckBox* m_checkBoxMinimizeOnClose; wxCheckBox* m_checkBoxUseProxy; @@ -191,7 +185,6 @@ class COptionsDialogBase : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnListBox( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCheckBoxLimitProcessors( wxCommandEvent& event ) { event.Skip(); } virtual void OnCheckBoxMinimizeToTray( wxCommandEvent& event ) { event.Skip(); } virtual void OnCheckBoxUseProxy( wxCommandEvent& event ) { event.Skip(); } virtual void OnKillFocusProxy( wxFocusEvent& event ) { event.Skip(); } diff --git a/uiproject.fbp b/uiproject.fbp index f54fdc2ba2..d9d46382d3 100644 --- a/uiproject.fbp +++ b/uiproject.fbp @@ -152,21 +152,6 @@ <property name="checked">0</property>
<property name="enabled">1</property>
<property name="help"></property>
- <property name="id">wxID_OPTIONSGENERATEBITCOINS</property>
- <property name="kind">wxITEM_CHECK</property>
- <property name="label">&Generate Coins</property>
- <property name="name">m_menuOptionsGenerateBitcoins</property>
- <property name="permission">none</property>
- <property name="shortcut"></property>
- <property name="unchecked_bitmap"></property>
- <event name="OnMenuSelection">OnMenuOptionsGenerate</event>
- <event name="OnUpdateUI">OnUpdateUIOptionsGenerate</event>
- </object>
- <object class="wxMenuItem" expanded="1">
- <property name="bitmap"></property>
- <property name="checked">0</property>
- <property name="enabled">1</property>
- <property name="help"></property>
<property name="id">wxID_ANY</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">&Your Receiving Addresses...</property>
@@ -1831,187 +1816,6 @@ </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
- <property name="flag"></property>
- <property name="proportion">0</property>
- <object class="wxBoxSizer" expanded="1">
- <property name="minimum_size"></property>
- <property name="name">bSizer71</property>
- <property name="orient">wxHORIZONTAL</property>
- <property name="permission">none</property>
- <object class="sizeritem" expanded="1">
- <property name="border">5</property>
- <property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
- <property name="proportion">0</property>
- <object class="wxCheckBox" expanded="1">
- <property name="bg"></property>
- <property name="checked">0</property>
- <property name="context_help"></property>
- <property name="enabled">1</property>
- <property name="fg"></property>
- <property name="font"></property>
- <property name="hidden">0</property>
- <property name="id">wxID_ANY</property>
- <property name="label">&Limit coin generation to</property>
- <property name="maximum_size"></property>
- <property name="minimum_size"></property>
- <property name="name">m_checkBoxLimitProcessors</property>
- <property name="permission">protected</property>
- <property name="pos"></property>
- <property name="size"></property>
- <property name="style"></property>
- <property name="subclass"></property>
- <property name="tooltip"></property>
- <property name="validator_data_type"></property>
- <property name="validator_style">wxFILTER_NONE</property>
- <property name="validator_type">wxDefaultValidator</property>
- <property name="validator_variable"></property>
- <property name="window_extra_style"></property>
- <property name="window_name"></property>
- <property name="window_style"></property>
- <event name="OnChar"></event>
- <event name="OnCheckBox">OnCheckBoxLimitProcessors</event>
- <event name="OnEnterWindow"></event>
- <event name="OnEraseBackground"></event>
- <event name="OnKeyDown"></event>
- <event name="OnKeyUp"></event>
- <event name="OnKillFocus"></event>
- <event name="OnLeaveWindow"></event>
- <event name="OnLeftDClick"></event>
- <event name="OnLeftDown"></event>
- <event name="OnLeftUp"></event>
- <event name="OnMiddleDClick"></event>
- <event name="OnMiddleDown"></event>
- <event name="OnMiddleUp"></event>
- <event name="OnMotion"></event>
- <event name="OnMouseEvents"></event>
- <event name="OnMouseWheel"></event>
- <event name="OnPaint"></event>
- <event name="OnRightDClick"></event>
- <event name="OnRightDown"></event>
- <event name="OnRightUp"></event>
- <event name="OnSetFocus"></event>
- <event name="OnSize"></event>
- <event name="OnUpdateUI"></event>
- </object>
- </object>
- <object class="sizeritem" expanded="1">
- <property name="border">5</property>
- <property name="flag">wxALIGN_CENTER_VERTICAL</property>
- <property name="proportion">0</property>
- <object class="wxSpinCtrl" expanded="1">
- <property name="bg"></property>
- <property name="context_help"></property>
- <property name="enabled">1</property>
- <property name="fg"></property>
- <property name="font"></property>
- <property name="hidden">0</property>
- <property name="id">wxID_ANY</property>
- <property name="initial">1</property>
- <property name="max">999</property>
- <property name="maximum_size"></property>
- <property name="min">1</property>
- <property name="minimum_size"></property>
- <property name="name">m_spinCtrlLimitProcessors</property>
- <property name="permission">protected</property>
- <property name="pos"></property>
- <property name="size">48,-1</property>
- <property name="style">wxSP_ARROW_KEYS</property>
- <property name="subclass"></property>
- <property name="tooltip"></property>
- <property name="validator_data_type"></property>
- <property name="validator_style">wxFILTER_NONE</property>
- <property name="validator_type">wxDefaultValidator</property>
- <property name="validator_variable"></property>
- <property name="value"></property>
- <property name="window_extra_style"></property>
- <property name="window_name"></property>
- <property name="window_style"></property>
- <event name="OnChar"></event>
- <event name="OnEnterWindow"></event>
- <event name="OnEraseBackground"></event>
- <event name="OnKeyDown"></event>
- <event name="OnKeyUp"></event>
- <event name="OnKillFocus"></event>
- <event name="OnLeaveWindow"></event>
- <event name="OnLeftDClick"></event>
- <event name="OnLeftDown"></event>
- <event name="OnLeftUp"></event>
- <event name="OnMiddleDClick"></event>
- <event name="OnMiddleDown"></event>
- <event name="OnMiddleUp"></event>
- <event name="OnMotion"></event>
- <event name="OnMouseEvents"></event>
- <event name="OnMouseWheel"></event>
- <event name="OnPaint"></event>
- <event name="OnRightDClick"></event>
- <event name="OnRightDown"></event>
- <event name="OnRightUp"></event>
- <event name="OnSetFocus"></event>
- <event name="OnSize"></event>
- <event name="OnSpinCtrl"></event>
- <event name="OnSpinCtrlText"></event>
- <event name="OnUpdateUI"></event>
- </object>
- </object>
- <object class="sizeritem" expanded="1">
- <property name="border">5</property>
- <property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
- <property name="proportion">0</property>
- <object class="wxStaticText" expanded="1">
- <property name="bg"></property>
- <property name="context_help"></property>
- <property name="enabled">1</property>
- <property name="fg"></property>
- <property name="font"></property>
- <property name="hidden">0</property>
- <property name="id">wxID_ANY</property>
- <property name="label">processors</property>
- <property name="maximum_size"></property>
- <property name="minimum_size"></property>
- <property name="name">m_staticText35</property>
- <property name="permission">protected</property>
- <property name="pos"></property>
- <property name="size"></property>
- <property name="style"></property>
- <property name="subclass"></property>
- <property name="tooltip"></property>
- <property name="validator_data_type"></property>
- <property name="validator_style">wxFILTER_NONE</property>
- <property name="validator_type">wxDefaultValidator</property>
- <property name="validator_variable"></property>
- <property name="window_extra_style"></property>
- <property name="window_name"></property>
- <property name="window_style"></property>
- <property name="wrap">-1</property>
- <event name="OnChar"></event>
- <event name="OnEnterWindow"></event>
- <event name="OnEraseBackground"></event>
- <event name="OnKeyDown"></event>
- <event name="OnKeyUp"></event>
- <event name="OnKillFocus"></event>
- <event name="OnLeaveWindow"></event>
- <event name="OnLeftDClick"></event>
- <event name="OnLeftDown"></event>
- <event name="OnLeftUp"></event>
- <event name="OnMiddleDClick"></event>
- <event name="OnMiddleDown"></event>
- <event name="OnMiddleUp"></event>
- <event name="OnMotion"></event>
- <event name="OnMouseEvents"></event>
- <event name="OnMouseWheel"></event>
- <event name="OnPaint"></event>
- <event name="OnRightDClick"></event>
- <event name="OnRightDown"></event>
- <event name="OnRightUp"></event>
- <event name="OnSetFocus"></event>
- <event name="OnSize"></event>
- <event name="OnUpdateUI"></event>
- </object>
- </object>
- </object>
- </object>
- <object class="sizeritem" expanded="1">
- <property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
@@ -2124,6 +1928,62 @@ </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
+ <property name="flag">wxALL</property>
+ <property name="proportion">0</property>
+ <object class="wxCheckBox" expanded="1">
+ <property name="bg"></property>
+ <property name="checked">0</property>
+ <property name="context_help"></property>
+ <property name="enabled">1</property>
+ <property name="fg"></property>
+ <property name="font"></property>
+ <property name="hidden">0</property>
+ <property name="id">wxID_ANY</property>
+ <property name="label">Map port using &UPnP</property>
+ <property name="maximum_size"></property>
+ <property name="minimum_size"></property>
+ <property name="name">m_checkBoxUseUPnP</property>
+ <property name="permission">protected</property>
+ <property name="pos"></property>
+ <property name="size"></property>
+ <property name="style"></property>
+ <property name="subclass"></property>
+ <property name="tooltip"></property>
+ <property name="validator_data_type"></property>
+ <property name="validator_style">wxFILTER_NONE</property>
+ <property name="validator_type">wxDefaultValidator</property>
+ <property name="validator_variable"></property>
+ <property name="window_extra_style"></property>
+ <property name="window_name"></property>
+ <property name="window_style"></property>
+ <event name="OnChar"></event>
+ <event name="OnCheckBox"></event>
+ <event name="OnEnterWindow"></event>
+ <event name="OnEraseBackground"></event>
+ <event name="OnKeyDown"></event>
+ <event name="OnKeyUp"></event>
+ <event name="OnKillFocus"></event>
+ <event name="OnLeaveWindow"></event>
+ <event name="OnLeftDClick"></event>
+ <event name="OnLeftDown"></event>
+ <event name="OnLeftUp"></event>
+ <event name="OnMiddleDClick"></event>
+ <event name="OnMiddleDown"></event>
+ <event name="OnMiddleUp"></event>
+ <event name="OnMotion"></event>
+ <event name="OnMouseEvents"></event>
+ <event name="OnMouseWheel"></event>
+ <event name="OnPaint"></event>
+ <event name="OnRightDClick"></event>
+ <event name="OnRightDown"></event>
+ <event name="OnRightUp"></event>
+ <event name="OnSetFocus"></event>
+ <event name="OnSize"></event>
+ <event name="OnUpdateUI"></event>
+ </object>
+ </object>
+ <object class="sizeritem" expanded="1">
+ <property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
@@ -3345,7 +3205,7 @@ <property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
- <property name="label">Copyright (c) 2009-2011 Bitcoin Developers

This is experimental software.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This product includes software developed by the OpenSSL Project for use in the 
OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by 
Eric Young (eay@cryptsoft.com).</property>
+ <property name="label">Copyright (c) 2009-2011 Bitcoin Developers

This is experimental software.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This product includes software developed by the OpenSSL Project for use in the 
OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by 
Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard.</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticTextMain</property>
@@ -747,6 +747,25 @@ void ReadConfigFile(map<string, string>& mapSettingsRet, } } +string GetPidFile() +{ + namespace fs = boost::filesystem; + fs::path pathConfig(GetArg("-pid", "bitcoind.pid")); + if (!pathConfig.is_complete()) + pathConfig = fs::path(GetDataDir()) / pathConfig; + return pathConfig.string(); +} + +void CreatePidFile(string pidFile, pid_t pid) +{ + FILE* file; + if (file = fopen(pidFile.c_str(), "w")) + { + fprintf(file, "%d\n", pid); + fclose(file); + } +} + int GetFilesize(FILE* file) { int nSavePos = ftell(file); @@ -855,3 +874,32 @@ void AddTimeData(unsigned int ip, int64 nTime) printf("| nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60); } } + + + + + + + + + +string FormatVersion(int nVersion) +{ + if (nVersion%100 == 0) + return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100); + else + return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100); +} + +string FormatFullVersion() +{ + string s = FormatVersion(VERSION) + pszSubVer; + if (VERSION_IS_BETA) + s += _("-beta"); + return s; +} + + + + + @@ -172,6 +172,8 @@ bool WildcardMatch(const string& str, const string& mask); int GetFilesize(FILE* file); void GetDataDir(char* pszDirRet); string GetConfigFile(); +string GetPidFile(); +void CreatePidFile(string pidFile, pid_t pid); void ReadConfigFile(map<string, string>& mapSettingsRet, map<string, vector<string> >& mapMultiSettingsRet); #ifdef __WXMSW__ string MyGetSpecialFolderPath(int nFolder, bool fCreate); @@ -184,6 +186,7 @@ uint64 GetRand(uint64 nMax); int64 GetTime(); int64 GetAdjustedTime(); void AddTimeData(unsigned int ip, int64 nTime); +string FormatFullVersion(); @@ -431,14 +434,6 @@ inline bool GetBoolArg(const string& strArg) return false; } -inline string FormatVersion(int nVersion) -{ - if (nVersion%100 == 0) - return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100); - else - return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100); -} - |