diff options
-rw-r--r-- | contrib/gitian-descriptors/deps-win32.yml | 24 | ||||
-rw-r--r-- | contrib/gitian-descriptors/gitian-win32.yml | 4 | ||||
-rw-r--r-- | contrib/gitian-descriptors/qt-win32.yml | 4 | ||||
-rw-r--r-- | doc/release-process.md | 21 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/bitcoind-res.rc (renamed from src/bitcoin-res.rc) | 0 | ||||
-rw-r--r-- | src/bitcoinrpc.cpp | 153 | ||||
-rw-r--r-- | src/bitcoinrpc.h | 2 | ||||
-rw-r--r-- | src/init.cpp | 30 | ||||
-rw-r--r-- | src/netbase.h | 2 | ||||
-rw-r--r-- | src/qt/forms/sendcoinsentry.ui | 32 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.cpp | 85 | ||||
-rw-r--r-- | src/qt/sendcoinsentry.cpp | 7 | ||||
-rw-r--r-- | src/qt/sendcoinsentry.h | 3 | ||||
-rw-r--r-- | src/rpcmining.cpp | 67 | ||||
-rw-r--r-- | src/rpcrawtransaction.cpp | 3 | ||||
-rw-r--r-- | src/rpcwallet.cpp | 22 |
17 files changed, 280 insertions, 181 deletions
diff --git a/contrib/gitian-descriptors/deps-win32.yml b/contrib/gitian-descriptors/deps-win32.yml index 5129462102..7ad00fcb01 100644 --- a/contrib/gitian-descriptors/deps-win32.yml +++ b/contrib/gitian-descriptors/deps-win32.yml @@ -10,7 +10,6 @@ packages: - "git-core" - "zip" - "faketime" -- "wine" - "psmisc" reference_datetime: "2011-01-30 00:00:00" remotes: [] @@ -47,10 +46,23 @@ script: | # tar xzf miniupnpc-1.6.tar.gz cd miniupnpc-1.6 - sed 's/dllwrap -k --driver-name gcc/$(DLLWRAP) -k --driver-name $(CC)/' -i Makefile.mingw - sed 's|wingenminiupnpcstrings $< $@|./wingenminiupnpcstrings $< $@|' -i Makefile.mingw + echo " + --- miniupnpc-1.6/Makefile.mingw.orig 2013-09-29 18:52:51.014087958 -1000 + +++ miniupnpc-1.6/Makefile.mingw 2013-09-29 19:09:29.663318691 -1000 + @@ -67,8 +67,8 @@ + + wingenminiupnpcstrings.o: wingenminiupnpcstrings.c + + -miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings + - wingenminiupnpcstrings \$< \$@ + +miniupnpcstrings.h: miniupnpcstrings.h.in + + sed -e 's|OS/version|MSWindows/5.1.2600|' -e 's|MINIUPNPC_VERSION_STRING \"version\"|MINIUPNPC_VERSION_STRING \"VERSIONHERE\"|' \$< > \$@ + + minixml.o: minixml.c minixml.h miniupnpcstrings.h + + " | sed "s/VERSIONHERE/$(cat VERSION)/" | patch -p1 mkdir -p dll - make -f Makefile.mingw DLLWRAP=$HOST-dllwrap CC=$HOST-gcc AR=$HOST-ar libminiupnpc.a + make -f Makefile.mingw CC=$HOST-gcc AR=$HOST-ar libminiupnpc.a install -d $INSTALLPREFIX/include/miniupnpc install *.h $INSTALLPREFIX/include/miniupnpc install libminiupnpc.a $INSTALLPREFIX/lib @@ -78,6 +90,4 @@ script: | cd .. # cd $INSTALLPREFIX - zip -r $OUTDIR/bitcoin-deps-win32-gitian-r8.zip include lib - # Kill wine processes as gitian won't figure out we are done otherwise - killall wineserver services.exe explorer.exe winedevice.exe + zip -r $OUTDIR/bitcoin-deps-win32-gitian-r9.zip include lib diff --git a/contrib/gitian-descriptors/gitian-win32.yml b/contrib/gitian-descriptors/gitian-win32.yml index 0d0bd9a74d..a8a823cac0 100644 --- a/contrib/gitian-descriptors/gitian-win32.yml +++ b/contrib/gitian-descriptors/gitian-win32.yml @@ -24,7 +24,7 @@ remotes: files: - "qt-win32-4.8.3-gitian-r4.zip" - "boost-win32-1.54.0-gitian-r6.zip" -- "bitcoin-deps-win32-gitian-r8.zip" +- "bitcoin-deps-win32-gitian-r9.zip" - "protobuf-win32-2.5.0-gitian-r3.zip" script: | # @@ -35,7 +35,7 @@ script: | cd $STAGING unzip ../build/qt-win32-4.8.3-gitian-r4.zip unzip ../build/boost-win32-1.54.0-gitian-r6.zip - unzip ../build/bitcoin-deps-win32-gitian-r8.zip + unzip ../build/bitcoin-deps-win32-gitian-r9.zip unzip ../build/protobuf-win32-2.5.0-gitian-r3.zip cd $HOME/build/ # diff --git a/contrib/gitian-descriptors/qt-win32.yml b/contrib/gitian-descriptors/qt-win32.yml index 9f07968efa..1fc6f861e0 100644 --- a/contrib/gitian-descriptors/qt-win32.yml +++ b/contrib/gitian-descriptors/qt-win32.yml @@ -15,7 +15,7 @@ reference_datetime: "2011-01-30 00:00:00" remotes: [] files: - "qt-everywhere-opensource-src-4.8.3.tar.gz" -- "bitcoin-deps-win32-gitian-r8.zip" +- "bitcoin-deps-win32-gitian-r9.zip" script: | # HOST=i686-w64-mingw32 @@ -25,7 +25,7 @@ script: | mkdir -p $INSTDIR/host/bin # # Need mingw-compiled openssl from bitcoin-deps: - unzip bitcoin-deps-win32-gitian-r8.zip + unzip bitcoin-deps-win32-gitian-r9.zip DEPSDIR=`pwd` # tar xzf qt-everywhere-opensource-src-4.8.3.tar.gz diff --git a/doc/release-process.md b/doc/release-process.md index 85d2e0df61..9e0b860a8c 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -31,29 +31,32 @@ Release Process export SIGNER=(your gitian key, ie bluematt, sipa, etc) export VERSION=(new version, e.g. 0.8.0) + pushd ./bitcoin + git checkout v${VERSION} + popd pushd ./gitian-builder Fetch and build inputs: (first time, or when dependency versions change) mkdir -p inputs; cd inputs/ wget 'http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.6.tar.gz' -O miniupnpc-1.6.tar.gz - wget 'http://www.openssl.org/source/openssl-1.0.1c.tar.gz' + wget 'https://www.openssl.org/source/openssl-1.0.1c.tar.gz' wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz' - wget 'http://zlib.net/zlib-1.2.6.tar.gz' - wget 'ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.9.tar.gz' - wget 'http://fukuchi.org/works/qrencode/qrencode-3.2.0.tar.bz2' - wget 'http://downloads.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.tar.bz2' + wget 'ftp://ftp.simplesystems.org/pub/libpng/png/src/history/zlib/zlib-1.2.6.tar.gz' + wget 'ftp://ftp.simplesystems.org/pub/libpng/png/src/history/libpng15/libpng-1.5.9.tar.gz' + wget 'https://fukuchi.org/works/qrencode/qrencode-3.2.0.tar.bz2' + wget 'https://downloads.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.tar.bz2' wget 'https://svn.boost.org/trac/boost/raw-attachment/ticket/7262/boost-mingw.patch' -O \ boost-mingw-gas-cross-compile-2013-03-03.patch - wget 'http://releases.qt-project.org/qt4/source/qt-everywhere-opensource-src-4.8.3.tar.gz' - wget 'http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2' + wget 'https://download.qt-project.org/archive/qt/4.8/4.8.3/qt-everywhere-opensource-src-4.8.3.tar.gz' + wget 'https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2' cd .. ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/boost-win32.yml mv build/out/boost-win32-*.zip inputs/ - ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/qt-win32.yml - mv build/out/qt-win32-*.zip inputs/ ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/deps-win32.yml mv build/out/bitcoin-deps-*.zip inputs/ + ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/qt-win32.yml + mv build/out/qt-win32-*.zip inputs/ ./bin/gbuild ../bitcoin/contrib/gitian-descriptors/protobuf-win32.yml mv build/out/protobuf-win32-*.zip inputs/ diff --git a/src/Makefile.am b/src/Makefile.am index 2d5b46c9c8..c0687ae2e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,7 +49,7 @@ bitcoind_SOURCES = bitcoind.cpp # if TARGET_WINDOWS -bitcoind_SOURCES += bitcoin-res.rc +bitcoind_SOURCES += bitcoind-res.rc endif AM_CPPFLAGS += $(BDB_CPPFLAGS) diff --git a/src/bitcoin-res.rc b/src/bitcoind-res.rc index 202b7ab352..202b7ab352 100644 --- a/src/bitcoin-res.rc +++ b/src/bitcoind-res.rc diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index ce8ff71a26..ef50ccd07f 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -160,6 +160,9 @@ string CRPCTable::help(string strCommand) const continue; if (strCommand != "" && strMethod != strCommand) continue; + if (pcmd->reqWallet && !pwalletMain) + continue; + try { Array params; @@ -218,76 +221,77 @@ Value stop(const Array& params, bool fHelp) static const CRPCCommand vRPCCommands[] = -{ // name actor (function) okSafeMode threadSafe - // ------------------------ ----------------------- ---------- ---------- - { "help", &help, true, true }, - { "stop", &stop, true, true }, - { "getblockcount", &getblockcount, true, false }, - { "getbestblockhash", &getbestblockhash, true, false }, - { "getconnectioncount", &getconnectioncount, true, false }, - { "getpeerinfo", &getpeerinfo, true, false }, - { "addnode", &addnode, true, true }, - { "getaddednodeinfo", &getaddednodeinfo, true, true }, - { "getdifficulty", &getdifficulty, true, false }, - { "getgenerate", &getgenerate, true, false }, - { "setgenerate", &setgenerate, true, false }, - { "gethashespersec", &gethashespersec, true, false }, - { "getinfo", &getinfo, true, false }, - { "getmininginfo", &getmininginfo, true, false }, - { "getnewaddress", &getnewaddress, true, false }, - { "getaccountaddress", &getaccountaddress, true, false }, - { "getrawchangeaddress", &getrawchangeaddress, true, false }, - { "setaccount", &setaccount, true, false }, - { "getaccount", &getaccount, false, false }, - { "getaddressesbyaccount", &getaddressesbyaccount, true, false }, - { "sendtoaddress", &sendtoaddress, false, false }, - { "getreceivedbyaddress", &getreceivedbyaddress, false, false }, - { "getreceivedbyaccount", &getreceivedbyaccount, false, false }, - { "listreceivedbyaddress", &listreceivedbyaddress, false, false }, - { "listreceivedbyaccount", &listreceivedbyaccount, false, false }, - { "backupwallet", &backupwallet, true, false }, - { "keypoolrefill", &keypoolrefill, true, false }, - { "walletpassphrase", &walletpassphrase, true, false }, - { "walletpassphrasechange", &walletpassphrasechange, false, false }, - { "walletlock", &walletlock, true, false }, - { "encryptwallet", &encryptwallet, false, false }, - { "validateaddress", &validateaddress, true, false }, - { "getbalance", &getbalance, false, false }, - { "move", &movecmd, false, false }, - { "sendfrom", &sendfrom, false, false }, - { "sendmany", &sendmany, false, false }, - { "addmultisigaddress", &addmultisigaddress, false, false }, - { "createmultisig", &createmultisig, true, true }, - { "getrawmempool", &getrawmempool, true, false }, - { "getblock", &getblock, false, false }, - { "getblockhash", &getblockhash, false, false }, - { "gettransaction", &gettransaction, false, false }, - { "listtransactions", &listtransactions, false, false }, - { "listaddressgroupings", &listaddressgroupings, false, false }, - { "signmessage", &signmessage, false, false }, - { "verifymessage", &verifymessage, false, false }, - { "getwork", &getwork, true, false }, - { "listaccounts", &listaccounts, false, false }, - { "settxfee", &settxfee, false, false }, - { "getblocktemplate", &getblocktemplate, true, false }, - { "submitblock", &submitblock, false, false }, - { "listsinceblock", &listsinceblock, false, false }, - { "dumpprivkey", &dumpprivkey, true, false }, - { "dumpwallet", &dumpwallet, true, false }, - { "importprivkey", &importprivkey, false, false }, - { "importwallet", &importwallet, false, false }, - { "listunspent", &listunspent, false, false }, - { "getrawtransaction", &getrawtransaction, false, false }, - { "createrawtransaction", &createrawtransaction, false, false }, - { "decoderawtransaction", &decoderawtransaction, false, false }, - { "decodescript", &decodescript, false, false }, - { "signrawtransaction", &signrawtransaction, false, false }, - { "sendrawtransaction", &sendrawtransaction, false, false }, - { "gettxoutsetinfo", &gettxoutsetinfo, true, false }, - { "gettxout", &gettxout, true, false }, - { "lockunspent", &lockunspent, false, false }, - { "listlockunspent", &listlockunspent, false, false }, - { "verifychain", &verifychain, true, false }, +{ // name actor (function) okSafeMode threadSafe reqWallet + // ------------------------ ----------------------- ---------- ---------- --------- + { "help", &help, true, true, false }, + { "stop", &stop, true, true, false }, + { "getblockcount", &getblockcount, true, false, false }, + { "getbestblockhash", &getbestblockhash, true, false, false }, + { "getconnectioncount", &getconnectioncount, true, false, false }, + { "getpeerinfo", &getpeerinfo, true, false, false }, + { "addnode", &addnode, true, true, false }, + { "getaddednodeinfo", &getaddednodeinfo, true, true, false }, + { "getdifficulty", &getdifficulty, true, false, false }, + { "getnetworkhashps", &getnetworkhashps, true, false, false }, + { "getgenerate", &getgenerate, true, false, false }, + { "setgenerate", &setgenerate, true, false, true }, + { "gethashespersec", &gethashespersec, true, false, false }, + { "getinfo", &getinfo, true, false, false }, + { "getmininginfo", &getmininginfo, true, false, false }, + { "getnewaddress", &getnewaddress, true, false, true }, + { "getaccountaddress", &getaccountaddress, true, false, true }, + { "getrawchangeaddress", &getrawchangeaddress, true, false, true }, + { "setaccount", &setaccount, true, false, true }, + { "getaccount", &getaccount, false, false, true }, + { "getaddressesbyaccount", &getaddressesbyaccount, true, false, true }, + { "sendtoaddress", &sendtoaddress, false, false, true }, + { "getreceivedbyaddress", &getreceivedbyaddress, false, false, true }, + { "getreceivedbyaccount", &getreceivedbyaccount, false, false, true }, + { "listreceivedbyaddress", &listreceivedbyaddress, false, false, true }, + { "listreceivedbyaccount", &listreceivedbyaccount, false, false, true }, + { "backupwallet", &backupwallet, true, false, true }, + { "keypoolrefill", &keypoolrefill, true, false, true }, + { "walletpassphrase", &walletpassphrase, true, false, true }, + { "walletpassphrasechange", &walletpassphrasechange, false, false, true }, + { "walletlock", &walletlock, true, false, true }, + { "encryptwallet", &encryptwallet, false, false, true }, + { "validateaddress", &validateaddress, true, false, false }, + { "getbalance", &getbalance, false, false, true }, + { "move", &movecmd, false, false, true }, + { "sendfrom", &sendfrom, false, false, true }, + { "sendmany", &sendmany, false, false, true }, + { "addmultisigaddress", &addmultisigaddress, false, false, true }, + { "createmultisig", &createmultisig, true, true , false }, + { "getrawmempool", &getrawmempool, true, false, false }, + { "getblock", &getblock, false, false, false }, + { "getblockhash", &getblockhash, false, false, false }, + { "gettransaction", &gettransaction, false, false, true }, + { "listtransactions", &listtransactions, false, false, true }, + { "listaddressgroupings", &listaddressgroupings, false, false, true }, + { "signmessage", &signmessage, false, false, true }, + { "verifymessage", &verifymessage, false, false, false }, + { "getwork", &getwork, true, false, true }, + { "listaccounts", &listaccounts, false, false, true }, + { "settxfee", &settxfee, false, false, true }, + { "getblocktemplate", &getblocktemplate, true, false, false }, + { "submitblock", &submitblock, false, false, false }, + { "listsinceblock", &listsinceblock, false, false, true }, + { "dumpprivkey", &dumpprivkey, true, false, true }, + { "dumpwallet", &dumpwallet, true, false, true }, + { "importprivkey", &importprivkey, false, false, true }, + { "importwallet", &importwallet, false, false, true }, + { "listunspent", &listunspent, false, false, true }, + { "getrawtransaction", &getrawtransaction, false, false, false }, + { "createrawtransaction", &createrawtransaction, false, false, false }, + { "decoderawtransaction", &decoderawtransaction, false, false, false }, + { "decodescript", &decodescript, false, false, false }, + { "signrawtransaction", &signrawtransaction, false, false, false }, + { "sendrawtransaction", &sendrawtransaction, false, false, false }, + { "gettxoutsetinfo", &gettxoutsetinfo, true, false, false }, + { "gettxout", &gettxout, true, false, false }, + { "lockunspent", &lockunspent, false, false, true }, + { "listlockunspent", &listlockunspent, false, false, true }, + { "verifychain", &verifychain, true, false, false }, }; CRPCTable::CRPCTable() @@ -1064,6 +1068,8 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s const CRPCCommand *pcmd = tableRPC[strMethod]; if (!pcmd) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found"); + if (pcmd->reqWallet && !pwalletMain) + throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); // Observe safe mode string strWarning = GetWarnings("rpc"); @@ -1078,7 +1084,10 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s { if (pcmd->threadSafe) result = pcmd->actor(params, false); - else { + else if (!pwalletMain) { + LOCK(cs_main); + result = pcmd->actor(params, false); + } else { LOCK2(cs_main, pwalletMain->cs_wallet); result = pcmd->actor(params, false); } @@ -1188,6 +1197,8 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri if (strMethod == "getaddednodeinfo" && n > 0) ConvertTo<bool>(params[0]); if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]); if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]); + if (strMethod == "getnetworkhashps" && n > 0) ConvertTo<boost::int64_t>(params[0]); + if (strMethod == "getnetworkhashps" && n > 1) ConvertTo<boost::int64_t>(params[1]); if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]); if (strMethod == "settxfee" && n > 0) ConvertTo<double>(params[0]); if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]); diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index ab0a0bc968..ce1c0e68b7 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -104,6 +104,7 @@ public: rpcfn_type actor; bool okSafeMode; bool threadSafe; + bool reqWallet; }; /** @@ -162,6 +163,7 @@ extern json_spirit::Value importwallet(const json_spirit::Array& params, bool fH extern json_spirit::Value getgenerate(const json_spirit::Array& params, bool fHelp); // in rpcmining.cpp extern json_spirit::Value setgenerate(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getnetworkhashps(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value gethashespersec(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getmininginfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getwork(const json_spirit::Array& params, bool fHelp); diff --git a/src/init.cpp b/src/init.cpp index d8d1a55fc9..e75e981a57 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -100,6 +100,7 @@ static CCoinsViewDB *pcoinsdbview; void Shutdown() { + LogPrintf("Shutdown : In progress...\n"); static CCriticalSection cs_Shutdown; TRY_LOCK(cs_Shutdown, lockShutdown); if (!lockShutdown) return; @@ -108,7 +109,8 @@ void Shutdown() nTransactionsUpdated++; StopRPCThreads(); ShutdownRPCMining(); - bitdb.Flush(false); + if (pwalletMain) + bitdb.Flush(false); GenerateBitcoins(false, NULL); StopNode(); { @@ -123,10 +125,13 @@ void Shutdown() delete pcoinsdbview; pcoinsdbview = NULL; delete pblocktree; pblocktree = NULL; } - bitdb.Flush(true); + if (pwalletMain) + bitdb.Flush(true); boost::filesystem::remove(GetPidFile()); UnregisterAllWallets(); - delete pwalletMain; + if (pwalletMain) + delete pwalletMain; + LogPrintf("Shutdown : done\n"); } // @@ -981,9 +986,9 @@ bool AppInit2(boost::thread_group& threadGroup) //// debug print LogPrintf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size()); LogPrintf("nBestHeight = %d\n", nBestHeight); - LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain->setKeyPool.size()); - LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain->mapWallet.size()); - LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain->mapAddressBook.size()); + LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0); + LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0); + LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0); StartNode(threadGroup); @@ -993,17 +998,20 @@ bool AppInit2(boost::thread_group& threadGroup) StartRPCThreads(); // Generate coins in the background - GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain); + if (pwalletMain) + GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain); // ********************************************************* Step 12: finished uiInterface.InitMessage(_("Done loading")); - // Add wallet transactions that aren't already in a block to mapTransactions - pwalletMain->ReacceptWalletTransactions(); + if (pwalletMain) { + // Add wallet transactions that aren't already in a block to mapTransactions + pwalletMain->ReacceptWalletTransactions(); - // Run a thread to flush wallet periodically - threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile))); + // Run a thread to flush wallet periodically + threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile))); + } return !fRequestShutdown; } diff --git a/src/netbase.h b/src/netbase.h index 8d5135e970..e1f80b4ee8 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -54,7 +54,7 @@ class CNetAddr bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32) bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16) bool IsRFC3964() const; // IPv6 6to4 tunnelling (2002::/16) - bool IsRFC4193() const; // IPv6 unique local (FC00::/15) + bool IsRFC4193() const; // IPv6 unique local (FC00::/7) bool IsRFC4380() const; // IPv6 Teredo tunnelling (2001::/32) bool IsRFC4843() const; // IPv6 ORCHID (2001:10::/28) bool IsRFC4862() const; // IPv6 autoconfig (FE80::/64) diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index a2ef9a0a38..2c1cec600c 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -10,19 +10,13 @@ <height>150</height> </rect> </property> - <property name="windowTitle"> - <string>StackedWidget</string> - </property> <property name="autoFillBackground"> <bool>false</bool> </property> <property name="currentIndex"> - <number>1</number> + <number>0</number> </property> <widget class="QFrame" name="SendCoinsInsecure"> - <property name="windowTitle"> - <string>Form</string> - </property> <property name="frameShape"> <enum>QFrame::StyledPanel</enum> </property> @@ -34,7 +28,7 @@ <number>12</number> </property> <item row="5" column="0"> - <widget class="QLabel" name="label"> + <widget class="QLabel" name="amountLabel"> <property name="text"> <string>A&mount:</string> </property> @@ -47,7 +41,7 @@ </widget> </item> <item row="3" column="0"> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="payToLabel"> <property name="text"> <string>Pay &To:</string> </property> @@ -63,7 +57,7 @@ <widget class="BitcoinAmountField" name="payAmount"/> </item> <item row="4" column="0"> - <widget class="QLabel" name="label_4"> + <widget class="QLabel" name="labellLabel"> <property name="text"> <string>&Label:</string> </property> @@ -592,9 +586,6 @@ </disabled> </palette> </property> - <property name="windowTitle"> - <string>SecureSend</string> - </property> <property name="autoFillBackground"> <bool>true</bool> </property> @@ -609,7 +600,7 @@ <number>12</number> </property> <item row="4" column="0"> - <widget class="QLabel" name="label_s4"> + <widget class="QLabel" name="memoLabel_s"> <property name="text"> <string>Memo:</string> </property> @@ -622,7 +613,7 @@ </widget> </item> <item row="5" column="0"> - <widget class="QLabel" name="label_s1"> + <widget class="QLabel" name="amountLabel_s"> <property name="text"> <string>A&mount:</string> </property> @@ -635,7 +626,7 @@ </widget> </item> <item row="3" column="0"> - <widget class="QLabel" name="label_s2"> + <widget class="QLabel" name="payToLabel_s"> <property name="text"> <string>Pay &To:</string> </property> @@ -667,14 +658,17 @@ </property> <item> <widget class="QLabel" name="payTo_s"> + <property name="textFormat"> + <enum>Qt::PlainText</enum> + </property> </widget> </item> </layout> </item> <item row="4" column="2"> - <widget class="QLabel" name="memo_s"> - <property name="text"> - <string>message from merchant</string> + <widget class="QLabel" name="memoTextLabel_s"> + <property name="textFormat"> + <enum>Qt::PlainText</enum> </property> </widget> </item> diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 809eff9c27..00cea463ef 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -94,27 +94,33 @@ void SendCoinsDialog::on_sendButton_clicked() QStringList formatted; foreach(const SendCoinsRecipient &rcp, recipients) { - QString amount = BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount); + // generate bold amount string + QString amount = "<b>" + BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount); + amount.append("</b>"); + // generate monospace address string + QString address = "<span style='font-family: monospace;'>" + rcp.address; + address.append("</span>"); + + QString recipientElement; + if (rcp.authenticatedMerchant.isEmpty()) { - QString recipientElement = QString("<b>%1</b> ").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount)); - recipientElement.append(tr("to")); - - if(rcp.label.length() > 0) + if(rcp.label.length() > 0) // label with address { - recipientElement.append(QString(" %1 <span style='font-size:8px;'>%2</span><br />").arg(GUIUtil::HtmlEscape(rcp.label), rcp.address)); // add address with label + recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label)); + recipientElement.append(QString(" (%1)").arg(address)); } - else + else // just address { - recipientElement.append(QString(" %1<br />").arg(rcp.address)); // add address WITHOUT label + recipientElement = tr("%1 to %2").arg(amount, address); } - formatted.append(recipientElement); } - else + else // just merchant { - QString merchant = GUIUtil::HtmlEscape(rcp.authenticatedMerchant); - formatted.append(tr("<b>%1</b> to %2").arg(amount, merchant)); + recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)); } + + formatted.append(recipientElement); } fNewRecipientAllowed = false; @@ -132,42 +138,38 @@ void SendCoinsDialog::on_sendButton_clicked() WalletModelTransaction currentTransaction(recipients); WalletModel::SendCoinsReturn prepareStatus = model->prepareTransaction(currentTransaction); + QString strSendCoins = tr("Send Coins"); switch(prepareStatus.status) { case WalletModel::InvalidAddress: - QMessageBox::warning(this, tr("Send Coins"), - tr("The recipient address is not valid, please recheck."), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, strSendCoins, + tr("The recipient address is not valid, please recheck.")); break; case WalletModel::InvalidAmount: - QMessageBox::warning(this, tr("Send Coins"), - tr("The amount to pay must be larger than 0."), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, strSendCoins, + tr("The amount to pay must be larger than 0.")); break; case WalletModel::AmountExceedsBalance: - QMessageBox::warning(this, tr("Send Coins"), - tr("The amount exceeds your balance."), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, strSendCoins, + tr("The amount exceeds your balance.")); break; case WalletModel::AmountWithFeeExceedsBalance: - QMessageBox::warning(this, tr("Send Coins"), + QMessageBox::warning(this, strSendCoins, tr("The total exceeds your balance when the %1 transaction fee is included."). - arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee())), - QMessageBox::Ok, QMessageBox::Ok); + arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()))); break; case WalletModel::DuplicateAddress: - QMessageBox::warning(this, tr("Send Coins"), - tr("Duplicate address found, can only send to each address once per send operation."), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, strSendCoins, + tr("Duplicate address found, can only send to each address once per send operation.")); break; case WalletModel::TransactionCreationFailed: - QMessageBox::warning(this, tr("Send Coins"), - tr("Error: Transaction creation failed!"), - QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, strSendCoins, + tr("Error: Transaction creation failed!")); break; - case WalletModel::Aborted: // User aborted, nothing to do - case WalletModel::OK: case WalletModel::TransactionCommitFailed: + case WalletModel::OK: + case WalletModel::Aborted: // User aborted, nothing to do + default: break; } @@ -197,7 +199,7 @@ void SendCoinsDialog::on_sendButton_clicked() QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), questionString.arg(formatted.join("<br />")), - QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); if(retval != QMessageBox::Yes) @@ -211,15 +213,13 @@ void SendCoinsDialog::on_sendButton_clicked() switch(sendstatus.status) { case WalletModel::TransactionCommitFailed: - QMessageBox::warning(this, tr("Send Coins"), - tr("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."), - QMessageBox::Ok, QMessageBox::Ok); - break; - case WalletModel::Aborted: // User aborted, nothing to do + QMessageBox::warning(this, strSendCoins, + tr("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.")); break; case WalletModel::OK: accept(); break; + case WalletModel::Aborted: // User aborted, nothing to do default: break; } @@ -351,13 +351,14 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) { + QString strSendCoins = tr("Send Coins"); if (!rv.authenticatedMerchant.isEmpty()) { // Expired payment request? const payments::PaymentDetails& details = rv.paymentRequest.getDetails(); if (details.has_expires() && (int64)details.expires() < GetTime()) { - QMessageBox::warning(this, tr("Send Coins"), - tr("Payment request expired")); + QMessageBox::warning(this, strSendCoins, + tr("Payment request expired")); return false; } } @@ -365,8 +366,8 @@ bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) CBitcoinAddress address(rv.address.toStdString()); if (!address.IsValid()) { QString strAddress(address.ToString().c_str()); - QMessageBox::warning(this, tr("Send Coins"), - tr("Invalid payment address %1").arg(strAddress)); + QMessageBox::warning(this, strSendCoins, + tr("Invalid payment address %1").arg(strAddress)); return false; } } diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 75610f199e..ee84f7bc11 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -106,8 +106,8 @@ bool SendCoinsEntry::validate() if (!recipient.authenticatedMerchant.isEmpty()) return retval; - if(!ui->payTo->hasAcceptableInput() || - (model && !model->validateAddress(ui->payTo->text()))) + if (!ui->payTo->hasAcceptableInput() || + (model && !model->validateAddress(ui->payTo->text()))) { ui->payTo->setValid(false); retval = false; @@ -163,8 +163,7 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value) const payments::PaymentDetails& details = value.paymentRequest.getDetails(); ui->payTo_s->setText(value.authenticatedMerchant); - ui->memo_s->setTextFormat(Qt::PlainText); - ui->memo_s->setText(QString::fromStdString(details.memo())); + ui->memoTextLabel_s->setText(QString::fromStdString(details.memo())); ui->payAmount_s->setValue(value.amount); setCurrentWidget(ui->SendCoinsSecure); } diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index 9c7bfe9521..49e622daf1 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -33,7 +33,8 @@ public: void setValue(const SendCoinsRecipient &value); void setAddress(const QString &address); - /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases + * (issue https://bugreports.qt-project.org/browse/QTBUG-10907). */ QWidget *setupTabChain(QWidget *prev); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index c7f516caa7..b013b4b200 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -18,15 +18,74 @@ static CReserveKey* pMiningKey = NULL; void InitRPCMining() { + if (!pwalletMain) + return; + // getwork/getblocktemplate mining rewards paid here: pMiningKey = new CReserveKey(pwalletMain); } void ShutdownRPCMining() { + if (!pMiningKey) + return; + delete pMiningKey; pMiningKey = NULL; } +// Return average network hashes per second based on the last 'lookup' blocks, +// or from the last difficulty change if 'lookup' is nonpositive. +// If 'height' is nonnegative, compute the estimate at the time when a given block was found. +Value GetNetworkHashPS(int lookup, int height) { + CBlockIndex *pb = pindexBest; + + if (height >= 0 && height < nBestHeight) + pb = FindBlockByHeight(height); + + if (pb == NULL || !pb->nHeight) + return 0; + + // If lookup is -1, then use blocks since last difficulty change. + if (lookup <= 0) + lookup = pb->nHeight % 2016 + 1; + + // If lookup is larger than chain, then set it to chain length. + if (lookup > pb->nHeight) + lookup = pb->nHeight; + + CBlockIndex *pb0 = pb; + int64 minTime = pb0->GetBlockTime(); + int64 maxTime = minTime; + for (int i = 0; i < lookup; i++) { + pb0 = pb0->pprev; + int64 time = pb0->GetBlockTime(); + minTime = std::min(time, minTime); + maxTime = std::max(time, maxTime); + } + + // In case there's a situation where minTime == maxTime, we don't want a divide by zero exception. + if (minTime == maxTime) + return 0; + + uint256 workDiff = pb->nChainWork - pb0->nChainWork; + int64 timeDiff = maxTime - minTime; + + return (boost::int64_t)(workDiff.getdouble() / timeDiff); +} + +Value getnetworkhashps(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "getnetworkhashps [blocks] [height]\n" + "Returns the estimated network hashes per second based on the last 120 blocks.\n" + "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n" + "Pass in [height] to estimate the network speed at the time when a certain block was found."); + + return GetNetworkHashPS(params.size() > 0 ? params[0].get_int() : 120, params.size() > 1 ? params[1].get_int() : -1); +} + + Value getgenerate(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -34,6 +93,9 @@ Value getgenerate(const Array& params, bool fHelp) "getgenerate\n" "Returns true or false."); + if (!pMiningKey) + return false; + return GetBoolArg("-gen", false); } @@ -59,6 +121,7 @@ Value setgenerate(const Array& params, bool fHelp) } mapArgs["-gen"] = (fGenerate ? "1" : "0"); + assert(pwalletMain != NULL); GenerateBitcoins(fGenerate, pwalletMain); return Value::null; } @@ -90,9 +153,10 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("errors", GetWarnings("statusbar"))); - obj.push_back(Pair("generate", GetBoolArg("-gen", false))); + obj.push_back(Pair("generate", getgenerate(params, false))); obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1))); obj.push_back(Pair("hashespersec", gethashespersec(params, false))); + obj.push_back(Pair("networkhashps", getnetworkhashps(params, false))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("testnet", TestNet())); return obj; @@ -207,6 +271,7 @@ Value getwork(const Array& params, bool fHelp) pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); + assert(pwalletMain != NULL); return CheckWork(pblock, *pwalletMain, *pMiningKey); } } diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index ce9d60e667..fcc5359dd6 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -171,6 +171,7 @@ Value listunspent(const Array& params, bool fHelp) Array results; vector<COutput> vecOutputs; + assert(pwalletMain != NULL); pwalletMain->AvailableCoins(vecOutputs, false); BOOST_FOREACH(const COutput& out, vecOutputs) { @@ -458,7 +459,7 @@ Value signrawtransaction(const Array& params, bool fHelp) } } - const CKeyStore& keystore = (fGivenKeys ? tempKeystore : *pwalletMain); + const CKeyStore& keystore = ((fGivenKeys || !pwalletMain) ? tempKeystore : *pwalletMain); int nHashType = SIGHASH_ALL; if (params.size() > 3 && params[3].type() != null_type) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 46338bdf26..cafb6db9b1 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -21,7 +21,7 @@ static CCriticalSection cs_nWalletUnlockTime; std::string HelpRequiringPassphrase() { - return pwalletMain->IsCrypted() + return pwalletMain && pwalletMain->IsCrypted() ? "\nrequires wallet passphrase to be set with walletpassphrase first" : ""; } @@ -72,18 +72,22 @@ Value getinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("version", (int)CLIENT_VERSION)); obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION)); - obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); - obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + if (pwalletMain) { + obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); + obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); + } obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset())); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string()))); obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("testnet", TestNet())); - obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime())); - obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + if (pwalletMain) { + obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime())); + obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + } obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); - if (pwalletMain->IsCrypted()) + if (pwalletMain && pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime)); obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; @@ -738,7 +742,7 @@ static CScript _createmultisig(const Array& params) // Case 1: Bitcoin address and we have full public key: CBitcoinAddress address(ks); - if (address.IsValid()) + if (pwalletMain && address.IsValid()) { CKeyID keyID; if (!address.GetKeyID(keyID)) @@ -1475,13 +1479,13 @@ Value validateaddress(const Array& params, bool fHelp) CTxDestination dest = address.Get(); string currentAddress = address.ToString(); ret.push_back(Pair("address", currentAddress)); - bool fMine = IsMine(*pwalletMain, dest); + bool fMine = pwalletMain ? IsMine(*pwalletMain, dest) : false; ret.push_back(Pair("ismine", fMine)); if (fMine) { Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest); ret.insert(ret.end(), detail.begin(), detail.end()); } - if (pwalletMain->mapAddressBook.count(dest)) + if (pwalletMain && pwalletMain->mapAddressBook.count(dest)) ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name)); } return ret; |