diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoinrpc.cpp | 120 | ||||
-rw-r--r-- | src/init.cpp | 70 | ||||
-rw-r--r-- | src/irc.cpp | 17 | ||||
-rw-r--r-- | src/main.h | 1 | ||||
-rw-r--r-- | src/makefile.osx | 5 | ||||
-rw-r--r-- | src/net.cpp | 61 | ||||
-rw-r--r-- | src/qt/forms/sendcoinsentry.ui | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_da.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_de.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_en.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_es.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_es_CL.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_hu.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_it.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_nb.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_nl.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_pt_BR.ts | 4 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_ru.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_uk.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_zh_CN.ts | 2 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_zh_TW.ts | 2 | ||||
-rw-r--r-- | src/script.cpp | 2 | ||||
-rw-r--r-- | src/test/multisig_tests.cpp | 5 | ||||
-rw-r--r-- | src/util.cpp | 17 | ||||
-rw-r--r-- | src/util.h | 25 |
25 files changed, 234 insertions, 121 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index c1e8ef7690..09be73af3d 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -72,6 +72,37 @@ void PrintConsole(const std::string &format, ...) fprintf(stdout, "%s", buffer); } +double GetDifficulty(const CBlockIndex* blockindex = NULL) +{ + // Floating point number that is a multiple of the minimum difficulty, + // minimum difficulty = 1.0. + if (blockindex == NULL) + { + if (pindexBest == NULL) + return 1.0; + else + blockindex = pindexBest; + } + + int nShift = (blockindex->nBits >> 24) & 0xff; + + double dDiff = + (double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff); + + while (nShift < 29) + { + dDiff *= 256.0; + nShift++; + } + while (nShift > 29) + { + dDiff /= 256.0; + nShift--; + } + + return dDiff; +} + int64 AmountFromValue(const Value& value) { @@ -112,6 +143,28 @@ string AccountFromValue(const Value& value) return strAccount; } +Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex) +{ + Object result; + result.push_back(Pair("hash", block.GetHash().GetHex())); + result.push_back(Pair("blockcount", blockindex->nHeight)); + result.push_back(Pair("version", block.nVersion)); + result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); + result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime())); + result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce)); + result.push_back(Pair("difficulty", GetDifficulty(blockindex))); + Array txhashes; + BOOST_FOREACH (const CTransaction&tx, block.vtx) + txhashes.push_back(tx.GetHash().GetHex()); + result.push_back(Pair("tx", txhashes)); + + if (blockindex->pprev) + result.push_back(Pair("hashprevious", blockindex->pprev->GetBlockHash().GetHex())); + if (blockindex->pnext) + result.push_back(Pair("hashnext", blockindex->pnext->GetBlockHash().GetHex())); + return result; +} + /// @@ -217,32 +270,6 @@ Value getconnectioncount(const Array& params, bool fHelp) } -double GetDifficulty() -{ - // Floating point number that is a multiple of the minimum difficulty, - // minimum difficulty = 1.0. - - if (pindexBest == NULL) - return 1.0; - int nShift = (pindexBest->nBits >> 24) & 0xff; - - double dDiff = - (double)0x0000ffff / (double)(pindexBest->nBits & 0x00ffffff); - - while (nShift < 29) - { - dDiff *= 256.0; - nShift++; - } - while (nShift > 29) - { - dDiff /= 256.0; - nShift--; - } - - return dDiff; -} - Value getdifficulty(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -1892,6 +1919,44 @@ Value getmemorypool(const Array& params, bool fHelp) } } +Value getblockhash(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getblockhash <index>\n" + "Returns hash of block in best-block-chain at <index>."); + + int nHeight = params[0].get_int(); + if (nHeight < 0 || nHeight > nBestHeight) + throw runtime_error("Block number out of range."); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hashBestChain]; + while (pblockindex->nHeight > nHeight) + pblockindex = pblockindex->pprev; + return pblockindex->phashBlock->GetHex(); +} + +Value getblock(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getblock <hash>\n" + "Returns details of a block with given block-hash."); + + std::string strHash = params[0].get_str(); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(-5, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + block.ReadFromDisk(pblockindex, true); + + return blockToJSON(block, pblockindex); +} + @@ -1940,6 +2005,8 @@ pair<string, rpcfn_type> pCallTable[] = make_pair("sendfrom", &sendfrom), make_pair("sendmany", &sendmany), make_pair("addmultisigaddress", &addmultisigaddress), + make_pair("getblock", &getblock), + make_pair("getblockhash", &getblockhash), make_pair("gettransaction", &gettransaction), make_pair("listtransactions", &listtransactions), make_pair("signmessage", &signmessage), @@ -2565,6 +2632,7 @@ int CommandLineRPC(int argc, char *argv[]) if (strMethod == "listreceivedbyaccount" && n > 0) ConvertTo<boost::int64_t>(params[0]); if (strMethod == "listreceivedbyaccount" && n > 1) ConvertTo<bool>(params[1]); if (strMethod == "getbalance" && n > 1) ConvertTo<boost::int64_t>(params[1]); + if (strMethod == "getblockhash" && n > 0) ConvertTo<boost::int64_t>(params[0]); if (strMethod == "move" && n > 2) ConvertTo<double>(params[2]); if (strMethod == "move" && n > 3) ConvertTo<boost::int64_t>(params[3]); if (strMethod == "sendfrom" && n > 2) ConvertTo<double>(params[2]); diff --git a/src/init.cpp b/src/init.cpp index 1e389b226b..8cbf21cc4b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -194,6 +194,7 @@ bool AppInit2(int argc, char* argv[]) " -maxconnections=<n>\t " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" + " -addnode=<ip> \t " + _("Add a node to connect to") + "\n" + " -connect=<ip> \t\t " + _("Connect only to the specified node") + "\n" + + " -noirc \t " + _("Don't find peers using internet relay chat") + "\n" + " -nolisten \t " + _("Don't accept connections from outside") + "\n" + " -nodnsseed \t " + _("Don't bootstrap list of peers using DNS") + "\n" + " -banscore=<n> \t " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" + @@ -247,8 +248,8 @@ bool AppInit2(int argc, char* argv[]) return false; } + fTestNet = GetBoolArg("-testnet"); fDebug = GetBoolArg("-debug"); - fAllowDNS = GetBoolArg("-dns"); #ifndef WIN32 fDaemon = GetBoolArg("-daemon"); @@ -267,10 +268,6 @@ bool AppInit2(int argc, char* argv[]) #endif fPrintToConsole = GetBoolArg("-printtoconsole"); fPrintToDebugger = GetBoolArg("-printtodebugger"); - - fTestNet = GetBoolArg("-testnet"); - bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); - fNoListen = GetBoolArg("-nolisten") || fTOR; fLogTimestamps = GetBoolArg("-logtimestamps"); #ifndef QT_GUI @@ -332,17 +329,6 @@ bool AppInit2(int argc, char* argv[]) return false; } - // Bind to the port early so we can tell if another instance is already running. - if (!fNoListen) - { - std::string strError; - if (!BindListenPort(strError)) - { - wxMessageBox(strError, "Bitcoin"); - return false; - } - } - std::ostringstream strErrors; // // Load data files @@ -428,6 +414,10 @@ bool AppInit2(int argc, char* argv[]) // Add wallet transactions that aren't already in a block to mapTransactions pwalletMain->ReacceptWalletTransactions(); + // Note: Bitcoin-QT stores several settings in the wallet, so we want + // to load the wallet BEFORE parsing command-line arguments, so + // the command-line/bitcoin.conf settings override GUI setting. + // // Parameters // @@ -480,6 +470,43 @@ bool AppInit2(int argc, char* argv[]) } } + bool fTor = (fUseProxy && addrProxy.port == htons(9050)); + if (fTor) + { + // Use SoftSetArg here so user can override any of these if they wish. + // Note: the GetBoolArg() calls for all of these must happen later. + SoftSetArg("-nolisten", true); + SoftSetArg("-noirc", true); + SoftSetArg("-nodnsseed", true); + SoftSetArg("-noupnp", true); + SoftSetArg("-upnp", false); + SoftSetArg("-dns", false); + } + + fAllowDNS = GetBoolArg("-dns"); + fNoListen = GetBoolArg("-nolisten"); + + if (fHaveUPnP) + { +#if USE_UPNP + if (GetBoolArg("-noupnp")) + fUseUPnP = false; +#else + if (GetBoolArg("-upnp")) + fUseUPnP = true; +#endif + } + + if (!fNoListen) + { + std::string strError; + if (!BindListenPort(strError)) + { + wxMessageBox(strError, "Bitcoin"); + return false; + } + } + if (mapArgs.count("-addnode")) { BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"]) @@ -502,17 +529,6 @@ 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 - } - // // Start the node // diff --git a/src/irc.cpp b/src/irc.cpp index 5278488dcd..fe96a90a1c 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -264,19 +264,14 @@ void ThreadIRCSeed2(void* parg) int nErrorWait = 10; int nRetryWait = 10; bool fNameInUse = false; - bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); while (!fShutdown) { - //CAddress addrConnect("216.155.130.130:6667"); // chat.freenode.net CAddress addrConnect("92.243.23.21", 6667); // irc.lfnet.org - if (!fTOR) - { - //struct hostent* phostent = gethostbyname("chat.freenode.net"); - CAddress addrIRC("irc.lfnet.org", 6667, true); - if (addrIRC.IsValid()) - addrConnect = addrIRC; - } + + CAddress addrIRC("irc.lfnet.org", 6667, true); + if (addrIRC.IsValid()) + addrConnect = addrIRC; SOCKET hSocket; if (!ConnectSocket(addrConnect, hSocket)) @@ -406,10 +401,6 @@ void ThreadIRCSeed2(void* parg) closesocket(hSocket); hSocket = INVALID_SOCKET; - // IRC usually blocks TOR, so only try once - if (fTOR) - return; - if (GetTime() - nStart > 20 * 60) { nErrorWait /= 3; diff --git a/src/main.h b/src/main.h index d613d284b6..a7c168280f 100644 --- a/src/main.h +++ b/src/main.h @@ -25,7 +25,6 @@ class CAddress; class CInv; class CRequestTracker; class CNode; -class CBlockIndex; static const int CLIENT_VERSION = 59900; static const bool VERSION_IS_BETA = true; diff --git a/src/makefile.osx b/src/makefile.osx index cf5ec38d29..966829e222 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -96,11 +96,6 @@ else endif endif -ifdef USE_QRCODE - DEFS += -DUSE_QRCODE=$(USE_QRCODE) - LIBS += -lqrencode -endif - all: bitcoind # auto-generated dependencies: diff --git a/src/net.cpp b/src/net.cpp index 9b8dbe11e8..6dab7e8c11 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -496,21 +496,25 @@ bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) void AddressCurrentlyConnected(const CAddress& addr) { + CAddress *paddrFound = NULL; + CRITICAL_BLOCK(cs_mapAddresses) { // Only if it's been published already map<vector<unsigned char>, CAddress>::iterator it = mapAddresses.find(addr.GetKey()); if (it != mapAddresses.end()) + paddrFound = &(*it).second; + } + + if (paddrFound) + { + int64 nUpdateInterval = 20 * 60; + if (paddrFound->nTime < GetAdjustedTime() - nUpdateInterval) { - CAddress& addrFound = (*it).second; - int64 nUpdateInterval = 20 * 60; - if (addrFound.nTime < GetAdjustedTime() - nUpdateInterval) - { - // Periodically update most recently seen time - addrFound.nTime = GetAdjustedTime(); - CAddrDB addrdb; - addrdb.WriteAddress(addrFound); - } + // Periodically update most recently seen time + paddrFound->nTime = GetAdjustedTime(); + CAddrDB addrdb; + addrdb.WriteAddress(*paddrFound); } } } @@ -1271,13 +1275,13 @@ void ThreadDNSAddressSeed2(void* parg) if (!fTestNet) { printf("Loading addresses from DNS seeds (could take a while)\n"); - CAddrDB addrDB; - addrDB.TxnBegin(); for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { vector<CAddress> vaddr; if (Lookup(strDNSSeed[seed_idx], vaddr, NODE_NETWORK, -1, true)) { + CAddrDB addrDB; + addrDB.TxnBegin(); BOOST_FOREACH (CAddress& addr, vaddr) { if (addr.GetByte(3) != 127) @@ -1287,10 +1291,9 @@ void ThreadDNSAddressSeed2(void* parg) found++; } } + addrDB.TxnCommit(); // Save addresses (it's ok if this fails) } } - - addrDB.TxnCommit(); // Save addresses (it's ok if this fails) } printf("%d addresses found from DNS seeds\n", found); @@ -1462,28 +1465,32 @@ void ThreadOpenConnections2(void* parg) if (fShutdown) return; + bool fAddSeeds = false; + CRITICAL_BLOCK(cs_mapAddresses) { // Add seed nodes if IRC isn't working bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); - if (mapAddresses.empty() && (GetTime() - nStart > 60 || fTOR) && !fTestNet) + if (mapAddresses.empty() && (GetTime() - nStart > 60 || fUseProxy) && !fTestNet) + fAddSeeds = true; + } + + if (fAddSeeds) + { + for (int i = 0; i < ARRAYLEN(pnSeed); i++) { - for (int i = 0; i < ARRAYLEN(pnSeed); i++) - { - // It'll only connect to one or two seed nodes because once it connects, - // it'll get a pile of addresses with newer timestamps. - // Seed nodes are given a random 'last seen time' of between one and two - // weeks ago. - const int64 nOneWeek = 7*24*60*60; - CAddress addr; - addr.ip = pnSeed[i]; - addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; - AddAddress(addr); - } + // It'll only connect to one or two seed nodes because once it connects, + // it'll get a pile of addresses with newer timestamps. + // Seed nodes are given a random 'last seen time' of between one and two + // weeks ago. + const int64 nOneWeek = 7*24*60*60; + CAddress addr; + addr.ip = pnSeed[i]; + addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; + AddAddress(addr); } } - // // Choose an address to connect to based on most recently seen // diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index 0297d17f15..22a3f8fdc6 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -100,7 +100,7 @@ <item> <widget class="QToolButton" name="addressBookButton"> <property name="toolTip"> - <string>Choose adress from address book</string> + <string>Choose address from address book</string> </property> <property name="text"> <string/> diff --git a/src/qt/locale/bitcoin_da.ts b/src/qt/locale/bitcoin_da.ts index c6ef676ffc..a0399e9f6c 100644 --- a/src/qt/locale/bitcoin_da.ts +++ b/src/qt/locale/bitcoin_da.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Vælg adresse fra adressebog</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_de.ts b/src/qt/locale/bitcoin_de.ts index 3b57d31a2c..022e71c294 100644 --- a/src/qt/locale/bitcoin_de.ts +++ b/src/qt/locale/bitcoin_de.ts @@ -915,7 +915,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Adresse aus dem Adressbuch auswählen</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index 0dfb50835d..ff36675100 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -918,7 +918,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/qt/locale/bitcoin_es.ts b/src/qt/locale/bitcoin_es.ts index bf2c49396d..44af31d88d 100644 --- a/src/qt/locale/bitcoin_es.ts +++ b/src/qt/locale/bitcoin_es.ts @@ -918,7 +918,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Elije dirección de la guia</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_es_CL.ts b/src/qt/locale/bitcoin_es_CL.ts index c355a1e4a6..f7bedb2acf 100644 --- a/src/qt/locale/bitcoin_es_CL.ts +++ b/src/qt/locale/bitcoin_es_CL.ts @@ -918,7 +918,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Elije dirección de la guia</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_hu.ts b/src/qt/locale/bitcoin_hu.ts index 8cee3334b8..32dc15af84 100644 --- a/src/qt/locale/bitcoin_hu.ts +++ b/src/qt/locale/bitcoin_hu.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Válassz egy címet a címjegyzékből</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_it.ts b/src/qt/locale/bitcoin_it.ts index 56beb98e84..f2fa08dfdc 100644 --- a/src/qt/locale/bitcoin_it.ts +++ b/src/qt/locale/bitcoin_it.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; }⏎ </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Scegli l'indirizzo dalla rubrica</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_nb.ts b/src/qt/locale/bitcoin_nb.ts index 95f5e9c59f..404e8f0f90 100644 --- a/src/qt/locale/bitcoin_nb.ts +++ b/src/qt/locale/bitcoin_nb.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Velg adresse fra adresseboken</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_nl.ts b/src/qt/locale/bitcoin_nl.ts index 408e18d6ed..c472c924f7 100644 --- a/src/qt/locale/bitcoin_nl.ts +++ b/src/qt/locale/bitcoin_nl.ts @@ -917,7 +917,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Kies adres uit adresboek</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_pt_BR.ts b/src/qt/locale/bitcoin_pt_BR.ts index 13263de865..55a86a08ae 100644 --- a/src/qt/locale/bitcoin_pt_BR.ts +++ b/src/qt/locale/bitcoin_pt_BR.ts @@ -909,8 +909,8 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> - <translation>Choose adress from address book</translation> + <source>Choose address from address book</source> + <translation>Choose address from address book</translation> </message> <message> <location filename="../forms/sendcoinsentry.ui" line="113"/> diff --git a/src/qt/locale/bitcoin_ru.ts b/src/qt/locale/bitcoin_ru.ts index 60332ac570..cefa092949 100644 --- a/src/qt/locale/bitcoin_ru.ts +++ b/src/qt/locale/bitcoin_ru.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Выбрать адрес из адресной книги</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_uk.ts b/src/qt/locale/bitcoin_uk.ts index 8c087ac6c8..ae64940b93 100644 --- a/src/qt/locale/bitcoin_uk.ts +++ b/src/qt/locale/bitcoin_uk.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>Вибрати адресу з адресної книги</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_zh_CN.ts b/src/qt/locale/bitcoin_zh_CN.ts index 2c5b5ba244..33cefda545 100644 --- a/src/qt/locale/bitcoin_zh_CN.ts +++ b/src/qt/locale/bitcoin_zh_CN.ts @@ -916,7 +916,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>从地址薄选择地址</translation> </message> <message> diff --git a/src/qt/locale/bitcoin_zh_TW.ts b/src/qt/locale/bitcoin_zh_TW.ts index f03ff82bbe..e460978f11 100644 --- a/src/qt/locale/bitcoin_zh_TW.ts +++ b/src/qt/locale/bitcoin_zh_TW.ts @@ -915,7 +915,7 @@ p, li { white-space: pre-wrap; } </message> <message> <location filename="../forms/sendcoinsentry.ui" line="103"/> - <source>Choose adress from address book</source> + <source>Choose address from address book</source> <translation>從位址簿中選一個位址</translation> </message> <message> diff --git a/src/script.cpp b/src/script.cpp index f576e14a8b..34872808b3 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1436,7 +1436,7 @@ bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey) // them) enable spend-out-from-under-you attacks, especially // in shared-wallet situations. vector<valtype> keys(vSolutions.begin()+1, vSolutions.begin()+vSolutions.size()-1); - return HaveKeys(vSolutions, keystore); + return HaveKeys(keys, keystore) == keys.size(); } } return false; diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 742083f3cf..0c2e41aedd 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1) // one key that would satisfy an (a|b) or 2-of-3 keys needed // to spend an escrow transaction. // - CBasicKeyStore keystore, emptykeystore; + CBasicKeyStore keystore, emptykeystore, partialkeystore; CKey key[3]; CBitcoinAddress keyaddr[3]; for (int i = 0; i < 3; i++) @@ -183,6 +183,7 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1) keystore.AddKey(key[i]); keyaddr[i].SetPubKey(key[i].GetPubKey()); } + partialkeystore.AddKey(key[0]); { vector<valtype> solutions; @@ -221,6 +222,7 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1) BOOST_CHECK(!ExtractAddress(s, addr)); BOOST_CHECK(IsMine(keystore, s)); BOOST_CHECK(!IsMine(emptykeystore, s)); + BOOST_CHECK(!IsMine(partialkeystore, s)); } { vector<valtype> solutions; @@ -237,6 +239,7 @@ BOOST_AUTO_TEST_CASE(multisig_Solver1) BOOST_CHECK(nRequired = 1); BOOST_CHECK(IsMine(keystore, s)); BOOST_CHECK(!IsMine(emptykeystore, s)); + BOOST_CHECK(!IsMine(partialkeystore, s)); } { vector<valtype> solutions; diff --git a/src/util.cpp b/src/util.cpp index a45ce33a1c..3805e077a1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -470,6 +470,23 @@ void ParseParameters(int argc, char* argv[]) } } +bool SoftSetArg(const std::string& strArg, const std::string& strValue) +{ + if (mapArgs.count(strArg)) + return false; + mapArgs[strArg] = strValue; + return true; +} + +bool SoftSetArg(const std::string& strArg, bool fValue) +{ + if (fValue) + return SoftSetArg(strArg, std::string("1")); + else + return SoftSetArg(strArg, std::string("0")); +} + + string EncodeBase64(const unsigned char* pch, size_t len) { static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; diff --git a/src/util.h b/src/util.h index bb90869962..48fea023bf 100644 --- a/src/util.h +++ b/src/util.h @@ -439,7 +439,7 @@ inline int64 GetArg(const std::string& strArg, int64 nDefault) return nDefault; } -inline bool GetBoolArg(const std::string& strArg) +inline bool GetBoolArg(const std::string& strArg, bool fDefault=false) { if (mapArgs.count(strArg)) { @@ -447,9 +447,26 @@ inline bool GetBoolArg(const std::string& strArg) return true; return (atoi(mapArgs[strArg]) != 0); } - return false; -} - + return fDefault; +} + +/** + * Set an argument if it doesn't already have a value + * + * @param strArg Argument to set (e.g. "-foo") + * @param strValue Value (e.g. "1") + * @return true if argument gets set, false if it already had a value + */ +bool SoftSetArg(const std::string& strArg, const std::string& strValue); + +/** + * Set a boolean argument if it doesn't already have a value + * + * @param strArg Argument to set (e.g. "-foo") + * @param fValue Value (e.g. false) + * @return true if argument gets set, false if it already had a value + */ +bool SoftSetArg(const std::string& strArg, bool fValue); |