What changed
Bitcoin v0.2.9 → v0.2.10
Release commit message: automatically change displayed address whenever it receives anything, added help and -? for daemon command line rpc commands, only relay addr messages to 5 random nodes to save bandwidth, started setting wtx.fFromMe flag, trickle out tx inventory messages to protect privacy -- version 0.2.10
Previous diff: v0.2.8 → v0.2.9. Next: v0.2.10 → v0.2.11.
- db.cpp modified · +5 −6
- db.h modified · +4 −1
- init.cpp modified · +18 −13
- irc.cpp modified · +0 −1
- main.cpp modified · +82 −37
- main.h modified · +2 −1
- net.cpp modified · +7 −2
- net.h modified · +7 −3
- rpc.cpp modified · +150 −101
- serialize.h modified · +1 −1
- ui.cpp modified · +8 −1
- uibase.cpp modified · +1 −1
- uibase.h modified · +1 −1
- uint256.h modified · +4 −1
- util.h modified · +7 −2
db.cpp (modified)
1--- v0.2.9/db.cpp2+++ v0.2.10/db.cpp3@@ -511,9 +511,9 @@4 // CWalletDB5 //6 7-bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)8-{9- vchDefaultKeyRet.clear();10+bool CWalletDB::LoadWallet()11+{12+ vchDefaultKey.clear();13 int nFileVersion = 0;14 15 // Modify defaults16@@ -587,7 +587,7 @@17 }18 else if (strType == "defaultkey")19 {20- ssValue >> vchDefaultKeyRet;21+ ssValue >> vchDefaultKey;22 }23 else if (strType == "version")24 {25@@ -650,8 +650,7 @@26 bool LoadWallet(bool& fFirstRunRet)27 {28 fFirstRunRet = false;29- vector<unsigned char> vchDefaultKey;30- if (!CWalletDB("cr+").LoadWallet(vchDefaultKey))31+ if (!CWalletDB("cr+").LoadWallet())32 return false;33 fFirstRunRet = vchDefaultKey.empty();34
db.h (modified)
1--- v0.2.9/db.h2+++ v0.2.10/db.h3@@ -14,7 +14,9 @@4 5 extern map<string, string> mapAddressBook;6 extern CCriticalSection cs_mapAddressBook;7+extern vector<unsigned char> vchDefaultKey;8 extern bool fClient;9+10 11 12 extern unsigned int nWalletDBUpdated;13@@ -373,6 +375,7 @@14 15 bool WriteDefaultKey(const vector<unsigned char>& vchPubKey)16 {17+ vchDefaultKey = vchPubKey;18 nWalletDBUpdated++;19 return Write(string("defaultkey"), vchPubKey);20 }21@@ -390,7 +393,7 @@22 return Write(make_pair(string("setting"), strKey), value);23 }24 25- bool LoadWallet(vector<unsigned char>& vchDefaultKeyRet);26+ bool LoadWallet();27 };28 29 bool LoadWallet(bool& fFirstRunRet);
init.cpp (modified)
1--- v0.2.9/init.cpp2+++ v0.2.10/init.cpp3@@ -339,22 +339,27 @@4 if (mapArgs.count("-?") || mapArgs.count("--help"))5 {6 wxString strUsage = string() +7- _("Usage: bitcoin [options]") + "\t\t\t\t\t\t\n" +8- _("Options:\n") +9- " -gen \t\t " + _("Generate coins\n") +10- " -gen=0 \t\t " + _("Don't generate coins\n") +11- " -min \t\t " + _("Start minimized\n") +12- " -datadir=<dir> \t " + _("Specify data directory\n") +13- " -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +14- " -addnode=<ip> \t " + _("Add a node to connect to\n") +15- " -connect=<ip> \t " + _("Connect only to the specified node\n") +16- " -? \t\t " + _("This help message\n");17+ _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +18+ " bitcoin [options] \t" + "\n" +19+ " bitcoin [command] \t" + _("Send command to bitcoin running with -server or -daemon\n") +20+ " bitcoin [command] -? \t" + _("Get help for a command\n") +21+ " bitcoin help \t" + _("List commands\n") +22+ _("Options:\n") +23+ " -gen \t " + _("Generate coins\n") +24+ " -gen=0 \t " + _("Don't generate coins\n") +25+ " -min \t " + _("Start minimized\n") +26+ " -datadir=<dir> \t " + _("Specify data directory\n") +27+ " -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +28+ " -addnode=<ip> \t " + _("Add a node to connect to\n") +29+ " -connect=<ip> \t " + _("Connect only to the specified node\n") +30+ " -server \t " + _("Accept command line and JSON-RPC commands\n") +31+ " -daemon \t " + _("Run in the background as a daemon and accept commands\n") +32+ " -? \t " + _("This help message\n");33+34 35 if (fWindows && fGUI)36 {37- // Remove spaces, the tabs make the columns line up in the message box38- for (int i = 0; i < 50; i++)39- strUsage.Replace(" \t", "\t");40+ // Tabs make the columns line up in the message box41 wxMessageBox(strUsage, "Bitcoin", wxOK);42 }43 else
irc.cpp (modified)
1--- v0.2.9/irc.cpp2+++ v0.2.10/irc.cpp3@@ -159,7 +159,6 @@4 void ThreadIRCSeed(void* parg)5 {6 printf("ThreadIRCSeed started\n");7- SetThreadPriority(THREAD_PRIORITY_NORMAL);8 int nErrorWait = 10;9 int nRetryWait = 10;10 bool fNameInUse = false;
main.cpp (modified)
1--- v0.2.9/main.cpp2+++ v0.2.10/main.cpp3@@ -48,6 +48,8 @@4 5 map<string, string> mapAddressBook;6 CCriticalSection cs_mapAddressBook;7+8+vector<unsigned char> vchDefaultKey;9 10 // Settings11 int fGenerateBitcoins = false;12@@ -141,6 +143,19 @@13 if (fInsertedNew || fUpdated)14 if (!wtx.WriteToDisk())15 return false;16+17+ // If default receiving address gets used, replace it with a new one18+ CScript scriptDefaultKey;19+ scriptDefaultKey.SetBitcoinAddress(vchDefaultKey);20+ foreach(const CTxOut& txout, wtx.vout)21+ {22+ if (txout.scriptPubKey == scriptDefaultKey)23+ {24+ CWalletDB walletdb;25+ walletdb.WriteDefaultKey(GenerateNewKey());26+ walletdb.WriteName(PubKeyToAddress(vchDefaultKey), "");27+ }28+ }29 30 // Notify UI31 vWalletUpdated.push_back(hash);32@@ -1753,8 +1768,6 @@33 {34 // Rewind and wait for rest of message35 ///// need a mechanism to give up waiting for overlong message size error36- if (fDebug)37- printf("message-break\n");38 vRecv.insert(vRecv.begin(), vHeaderSave.begin(), vHeaderSave.end());39 break;40 }41@@ -1922,19 +1935,26 @@42 if (fShutdown)43 return true;44 addr.nTime = GetAdjustedTime() - 2 * 60 * 60;45- if (pfrom->fGetAddr)46+ if (pfrom->fGetAddr || vAddr.size() > 10)47 addr.nTime -= 5 * 24 * 60 * 60;48 AddAddress(addr, false);49 pfrom->AddAddressKnown(addr);50 if (!pfrom->fGetAddr && addr.IsRoutable())51 {52- // Put on lists to send to other nodes53+ // Relay to a limited number of other nodes54 CRITICAL_BLOCK(cs_vNodes)55+ {56+ multimap<int, CNode*> mapMix;57 foreach(CNode* pnode, vNodes)58- pnode->PushAddress(addr);59- }60- }61- pfrom->fGetAddr = false;62+ mapMix.insert(make_pair(GetRand(INT_MAX), pnode));63+ int nRelayNodes = 5;64+ for (multimap<int, CNode*>::iterator mi = mapMix.begin(); mi != mapMix.end() && nRelayNodes-- > 0; ++mi)65+ ((*mi).second)->PushAddress(addr);66+ }67+ }68+ }69+ if (vAddr.size() < 1000)70+ pfrom->fGetAddr = false;71 }72 73 74@@ -2177,6 +2197,7 @@75 uint256 hashReply;76 CWalletTx wtxNew;77 vRecv >> hashReply >> wtxNew;78+ wtxNew.fFromMe = false;79 80 // Broadcast81 if (!wtxNew.AcceptWalletTransaction())82@@ -2242,7 +2263,7 @@83 84 85 86-bool SendMessages(CNode* pto)87+bool SendMessages(CNode* pto, bool fSendTrickle)88 {89 CRITICAL_BLOCK(cs_main)90 {91@@ -2273,15 +2294,6 @@92 }93 }94 95- // Delay tx inv messages to protect privacy,96- // trickle them out to a few nodes at a time.97- bool fSendTxInv = false;98- if (GetTimeMillis() > pto->nNextSendTxInv)99- {100- pto->nNextSendTxInv = GetTimeMillis() + 3000 + GetRand(2000);101- fSendTxInv = true;102- }103-104 // Resend wallet transactions that haven't gotten in a block yet105 ResendWalletTransactions();106 107@@ -2289,24 +2301,27 @@108 //109 // Message: addr110 //111- vector<CAddress> vAddr;112- vAddr.reserve(pto->vAddrToSend.size());113- foreach(const CAddress& addr, pto->vAddrToSend)114- {115- // returns true if wasn't already contained in the set116- if (pto->setAddrKnown.insert(addr).second)117- {118- vAddr.push_back(addr);119- if (vAddr.size() >= 1000)120+ if (fSendTrickle)121+ {122+ vector<CAddress> vAddr;123+ vAddr.reserve(pto->vAddrToSend.size());124+ foreach(const CAddress& addr, pto->vAddrToSend)125+ {126+ // returns true if wasn't already contained in the set127+ if (pto->setAddrKnown.insert(addr).second)128 {129- pto->PushMessage("addr", vAddr);130- vAddr.clear();131+ vAddr.push_back(addr);132+ if (vAddr.size() >= 1000)133+ {134+ pto->PushMessage("addr", vAddr);135+ vAddr.clear();136+ }137 }138 }139- }140- pto->vAddrToSend.clear();141- if (!vAddr.empty())142- pto->PushMessage("addr", vAddr);143+ pto->vAddrToSend.clear();144+ if (!vAddr.empty())145+ pto->PushMessage("addr", vAddr);146+ }147 148 149 //150@@ -2320,11 +2335,40 @@151 vInvWait.reserve(pto->vInventoryToSend.size());152 foreach(const CInv& inv, pto->vInventoryToSend)153 {154- // delay txes155- if (!fSendTxInv && inv.type == MSG_TX)156+ if (pto->setInventoryKnown.count(inv))157+ continue;158+159+ // trickle out tx inv to protect privacy160+ if (inv.type == MSG_TX && !fSendTrickle)161 {162- vInvWait.push_back(inv);163- continue;164+ // 1/4 of tx invs blast to all immediately165+ static uint256 hashSalt;166+ if (hashSalt == 0)167+ RAND_bytes((unsigned char*)&hashSalt, sizeof(hashSalt));168+ uint256 hashRand = (inv.hash ^ hashSalt);169+ hashRand = Hash(BEGIN(hashRand), END(hashRand));170+ bool fTrickleWait = ((hashRand & 3) != 0);171+172+ // always trickle our own transactions173+ if (!fTrickleWait)174+ {175+ TRY_CRITICAL_BLOCK(cs_mapWallet)176+ {177+ map<uint256, CWalletTx>::iterator mi = mapWallet.find(inv.hash);178+ if (mi != mapWallet.end())179+ {180+ CWalletTx& wtx = (*mi).second;181+ if (wtx.fFromMe)182+ fTrickleWait = true;183+ }184+ }185+ }186+187+ if (fTrickleWait)188+ {189+ vInvWait.push_back(inv);190+ continue;191+ }192 }193 194 // returns true if wasn't already contained in the set195@@ -2852,6 +2896,7 @@196 {197 wtxNew.vin.clear();198 wtxNew.vout.clear();199+ wtxNew.fFromMe = true;200 if (nValue < 0)201 return false;202 int64 nValueOut = nValue;
main.h (modified)
1--- v0.2.9/main.h2+++ v0.2.10/main.h3@@ -38,6 +38,7 @@4 extern CCriticalSection cs_mapRequestCount;5 extern map<string, string> mapAddressBook;6 extern CCriticalSection cs_mapAddressBook;7+extern vector<unsigned char> vchDefaultKey;8 9 // Settings10 extern int fGenerateBitcoins;11@@ -66,7 +67,7 @@12 void PrintBlockTree();13 bool ProcessMessages(CNode* pfrom);14 bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv);15-bool SendMessages(CNode* pto);16+bool SendMessages(CNode* pto, bool fSendTrickle);17 int64 GetBalance();18 bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CKey& keyRet, int64& nFeeRequiredRet);19 bool CommitTransaction(CWalletTx& wtxNew, const CKey& key);
net.cpp (modified)
1--- v0.2.9/net.cpp2+++ v0.2.10/net.cpp3@@ -1019,7 +1019,6 @@4 SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);5 while (!fShutdown)6 {7- // Poll the connected nodes for messages8 vector<CNode*> vNodesCopy;9 CRITICAL_BLOCK(cs_vNodes)10 {11@@ -1027,6 +1026,11 @@12 foreach(CNode* pnode, vNodesCopy)13 pnode->AddRef();14 }15+16+ // Poll the connected nodes for messages17+ CNode* pnodeTrickle = NULL;18+ if (!vNodesCopy.empty())19+ pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())];20 foreach(CNode* pnode, vNodesCopy)21 {22 // Receive messages23@@ -1037,10 +1041,11 @@24 25 // Send messages26 TRY_CRITICAL_BLOCK(pnode->cs_vSend)27- SendMessages(pnode);28+ SendMessages(pnode, pnode == pnodeTrickle);29 if (fShutdown)30 return;31 }32+33 CRITICAL_BLOCK(cs_vNodes)34 {35 foreach(CNode* pnode, vNodesCopy)
net.h (modified)
1--- v0.2.9/net.h2+++ v0.2.10/net.h3@@ -12,7 +12,7 @@4 5 6 7-static const unsigned short DEFAULT_PORT = htons(8333);8+#define DEFAULT_PORT htons(8333)9 static const unsigned int PUBLISH_HOPS = 5;10 enum11 {12@@ -522,7 +522,6 @@13 vector<CInv> vInventoryToSend;14 CCriticalSection cs_inventory;15 multimap<int64, CInv> mapAskFor;16- int64 nNextSendTxInv;17 18 // publish and subscription19 vector<char> vfSubscribe;20@@ -536,6 +535,12 @@21 vSend.SetVersion(0);22 vRecv.SetType(SER_NETWORK);23 vRecv.SetVersion(0);24+ // Version 0.2 obsoletes 20 Feb 201225+ if (GetTime() > 1329696000)26+ {27+ vSend.SetVersion(209);28+ vRecv.SetVersion(209);29+ }30 nLastSend = 0;31 nLastRecv = 0;32 nLastSendEmpty = GetTime();33@@ -556,7 +561,6 @@34 hashLastGetBlocksEnd = 0;35 nStartingHeight = -1;36 fGetAddr = false;37- nNextSendTxInv = 0;38 vfSubscribe.assign(256, false);39 40 // Push a version message
rpc.cpp (modified)
1--- v0.2.9/rpc.cpp2+++ v0.2.10/rpc.cpp3@@ -18,6 +18,8 @@4 using namespace json_spirit;5 6 void ThreadRPCServer2(void* parg);7+typedef Value(*rpcfn_type)(const Array& params, bool fHelp);8+extern map<string, rpcfn_type> mapCallTable;9 10 11 12@@ -31,11 +33,40 @@13 14 15 16-Value stop(const Array& params)17-{18- if (params.size() != 0)19- throw runtime_error(20- "stop (no parameters)\n"21+Value help(const Array& params, bool fHelp)22+{23+ if (fHelp || params.size() != 0)24+ throw runtime_error(25+ "help\n"26+ "List commands.");27+28+ string strRet;29+ for (map<string, rpcfn_type>::iterator mi = mapCallTable.begin(); mi != mapCallTable.end(); ++mi)30+ {31+ try32+ {33+ Array params;34+ (*(*mi).second)(params, true);35+ }36+ catch (std::exception& e)37+ {38+ // Help text is returned in an exception39+ string strHelp = string(e.what());40+ if (strHelp.find('\n') != -1)41+ strHelp = strHelp.substr(0, strHelp.find('\n'));42+ strRet += strHelp + "\n";43+ }44+ }45+ strRet = strRet.substr(0,strRet.size()-1);46+ return strRet;47+}48+49+50+Value stop(const Array& params, bool fHelp)51+{52+ if (fHelp || params.size() != 0)53+ throw runtime_error(54+ "stop\n"55 "Stop bitcoin server.");56 57 // Shutdown will take long enough that the response should get back58@@ -44,33 +75,33 @@59 }60 61 62-Value getblockcount(const Array& params)63-{64- if (params.size() != 0)65- throw runtime_error(66- "getblockcount (no parameters)\n"67+Value getblockcount(const Array& params, bool fHelp)68+{69+ if (fHelp || params.size() != 0)70+ throw runtime_error(71+ "getblockcount\n"72 "Returns the number of blocks in the longest block chain.");73 74 return nBestHeight + 1;75 }76 77 78-Value getblocknumber(const Array& params)79-{80- if (params.size() != 0)81- throw runtime_error(82- "getblocknumber (no parameters)\n"83+Value getblocknumber(const Array& params, bool fHelp)84+{85+ if (fHelp || params.size() != 0)86+ throw runtime_error(87+ "getblocknumber\n"88 "Returns the block number of the latest block in the longest block chain.");89 90 return nBestHeight;91 }92 93 94-Value getconnectioncount(const Array& params)95-{96- if (params.size() != 0)97- throw runtime_error(98- "getconnectioncount (no parameters)\n"99+Value getconnectioncount(const Array& params, bool fHelp)100+{101+ if (fHelp || params.size() != 0)102+ throw runtime_error(103+ "getconnectioncount\n"104 "Returns the number of connections to other nodes.");105 106 return (int)vNodes.size();107@@ -89,42 +120,42 @@108 return dMinimum / dCurrently;109 }110 111-Value getdifficulty(const Array& params)112-{113- if (params.size() != 0)114- throw runtime_error(115- "getdifficulty (no parameters)\n"116+Value getdifficulty(const Array& params, bool fHelp)117+{118+ if (fHelp || params.size() != 0)119+ throw runtime_error(120+ "getdifficulty\n"121 "Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");122 123 return GetDifficulty();124 }125 126 127-Value getbalance(const Array& params)128-{129- if (params.size() != 0)130- throw runtime_error(131- "getbalance (no parameters)\n"132+Value getbalance(const Array& params, bool fHelp)133+{134+ if (fHelp || params.size() != 0)135+ throw runtime_error(136+ "getbalance\n"137 "Returns the server's available balance.");138 139 return ((double)GetBalance() / (double)COIN);140 }141 142 143-Value getgenerate(const Array& params)144-{145- if (params.size() != 0)146- throw runtime_error(147- "getgenerate (no parameters)\n"148+Value getgenerate(const Array& params, bool fHelp)149+{150+ if (fHelp || params.size() != 0)151+ throw runtime_error(152+ "getgenerate\n"153 "Returns true or false.");154 155 return (bool)fGenerateBitcoins;156 }157 158 159-Value setgenerate(const Array& params)160-{161- if (params.size() < 1 || params.size() > 2)162+Value setgenerate(const Array& params, bool fHelp)163+{164+ if (fHelp || params.size() < 1 || params.size() > 2)165 throw runtime_error(166 "setgenerate <generate> [genproclimit]\n"167 "<generate> is true or false to turn generation on or off.\n"168@@ -148,11 +179,11 @@169 }170 171 172-Value getinfo(const Array& params)173-{174- if (params.size() != 0)175- throw runtime_error(176- "getinfo (no parameters)");177+Value getinfo(const Array& params, bool fHelp)178+{179+ if (fHelp || params.size() != 0)180+ throw runtime_error(181+ "getinfo");182 183 Object obj;184 obj.push_back(Pair("balance", (double)GetBalance() / (double)COIN));185@@ -166,9 +197,9 @@186 }187 188 189-Value getnewaddress(const Array& params)190-{191- if (params.size() > 1)192+Value getnewaddress(const Array& params, bool fHelp)193+{194+ if (fHelp || params.size() > 1)195 throw runtime_error(196 "getnewaddress [label]\n"197 "Returns a new bitcoin address for receiving payments. "198@@ -188,9 +219,9 @@199 }200 201 202-Value setlabel(const Array& params)203-{204- if (params.size() < 1 || params.size() > 2)205+Value setlabel(const Array& params, bool fHelp)206+{207+ if (fHelp || params.size() < 1 || params.size() > 2)208 throw runtime_error(209 "setlabel <bitcoinaddress> <label>\n"210 "Sets the label associated with the given address.");211@@ -205,9 +236,9 @@212 }213 214 215-Value getlabel(const Array& params)216-{217- if (params.size() != 1)218+Value getlabel(const Array& params, bool fHelp)219+{220+ if (fHelp || params.size() != 1)221 throw runtime_error(222 "getlabel <bitcoinaddress>\n"223 "Returns the label associated with the given address.");224@@ -225,9 +256,9 @@225 }226 227 228-Value getaddressesbylabel(const Array& params)229-{230- if (params.size() != 1)231+Value getaddressesbylabel(const Array& params, bool fHelp)232+{233+ if (fHelp || params.size() != 1)234 throw runtime_error(235 "getaddressesbylabel <label>\n"236 "Returns the list of addresses with the given label.");237@@ -255,9 +286,9 @@238 }239 240 241-Value sendtoaddress(const Array& params)242-{243- if (params.size() < 2 || params.size() > 4)244+Value sendtoaddress(const Array& params, bool fHelp)245+{246+ if (fHelp || params.size() < 2 || params.size() > 4)247 throw runtime_error(248 "sendtoaddress <bitcoinaddress> <amount> [comment] [comment-to]\n"249 "<amount> is a real and is rounded to the nearest 0.01");250@@ -283,9 +314,9 @@251 }252 253 254-Value listtransactions(const Array& params)255-{256- if (params.size() > 2)257+Value listtransactions(const Array& params, bool fHelp)258+{259+ if (fHelp || params.size() > 2)260 throw runtime_error(261 "listtransactions [count=10] [includegenerated=false]\n"262 "Returns up to [count] most recent transactions.");263@@ -304,9 +335,9 @@264 }265 266 267-Value getreceivedbyaddress(const Array& params)268-{269- if (params.size() < 1 || params.size() > 2)270+Value getreceivedbyaddress(const Array& params, bool fHelp)271+{272+ if (fHelp || params.size() < 1 || params.size() > 2)273 throw runtime_error(274 "getreceivedbyaddress <bitcoinaddress> [minconf=1]\n"275 "Returns the total amount received by <bitcoinaddress> in transactions with at least [minconf] confirmations.");276@@ -345,9 +376,9 @@277 }278 279 280-Value getreceivedbylabel(const Array& params)281-{282- if (params.size() < 1 || params.size() > 2)283+Value getreceivedbylabel(const Array& params, bool fHelp)284+{285+ if (fHelp || params.size() < 1 || params.size() > 2)286 throw runtime_error(287 "getreceivedbylabel <label> [minconf=1]\n"288 "Returns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.");289@@ -508,9 +539,9 @@290 return ret;291 }292 293-Value listreceivedbyaddress(const Array& params)294-{295- if (params.size() > 2)296+Value listreceivedbyaddress(const Array& params, bool fHelp)297+{298+ if (fHelp || params.size() > 2)299 throw runtime_error(300 "listreceivedbyaddress [minconf=1] [includeempty=false]\n"301 "[minconf] is the minimum number of confirmations before payments are included.\n"302@@ -524,9 +555,9 @@303 return ListReceived(params, false);304 }305 306-Value listreceivedbylabel(const Array& params)307-{308- if (params.size() > 2)309+Value listreceivedbylabel(const Array& params, bool fHelp)310+{311+ if (fHelp || params.size() > 2)312 throw runtime_error(313 "listreceivedbylabel [minconf=1] [includeempty=false]\n"314 "[minconf] is the minimum number of confirmations before payments are included.\n"315@@ -555,9 +586,9 @@316 // Call Table317 //318 319-typedef Value(*rpcfn_type)(const Array& params);320 pair<string, rpcfn_type> pCallTable[] =321 {322+ make_pair("help", &help),323 make_pair("stop", &stop),324 make_pair("getblockcount", &getblockcount),325 make_pair("getblocknumber", &getblocknumber),326@@ -760,7 +791,7 @@327 map<string, rpcfn_type>::iterator mi = mapCallTable.find(strMethod);328 if (mi == mapCallTable.end())329 throw runtime_error("Method not found.");330- Value result = (*(*mi).second)(params);331+ Value result = (*(*mi).second)(params, false);332 333 // Send reply334 string strReply = JSONRPCReply(result, Value::null, id);335@@ -847,32 +878,50 @@336 if (!mapCallTable.count(strMethod))337 throw runtime_error(strprintf("unknown command: %s", strMethod.c_str()));338 339- // Parameters default to strings340- Array params;341- for (int i = 2; i < argc; i++)342- params.push_back(argv[i]);343- int n = params.size();344-345- //346- // Special case other types347- //348- if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]);349- if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]);350- if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);351- if (strMethod == "listtransactions" && n > 0) ConvertTo<boost::int64_t>(params[0]);352- if (strMethod == "listtransactions" && n > 1) ConvertTo<bool>(params[1]);353- if (strMethod == "getamountreceived" && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated354- if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]);355- if (strMethod == "getreceivedbylabel" && n > 1) ConvertTo<boost::int64_t>(params[1]);356- if (strMethod == "getallreceived" && n > 0) ConvertTo<boost::int64_t>(params[0]); // deprecated357- if (strMethod == "getallreceived" && n > 1) ConvertTo<bool>(params[1]);358- if (strMethod == "listreceivedbyaddress" && n > 0) ConvertTo<boost::int64_t>(params[0]);359- if (strMethod == "listreceivedbyaddress" && n > 1) ConvertTo<bool>(params[1]);360- if (strMethod == "listreceivedbylabel" && n > 0) ConvertTo<boost::int64_t>(params[0]);361- if (strMethod == "listreceivedbylabel" && n > 1) ConvertTo<bool>(params[1]);362-363- // Execute364- Value result = CallRPC(strMethod, params);365+ Value result;366+ if (argc == 3 && strcmp(argv[2], "-?") == 0)367+ {368+ // Call help locally, help text is returned in an exception369+ try370+ {371+ map<string, rpcfn_type>::iterator mi = mapCallTable.find(strMethod);372+ Array params;373+ (*(*mi).second)(params, true);374+ }375+ catch (std::exception& e)376+ {377+ result = e.what();378+ }379+ }380+ else381+ {382+ // Parameters default to strings383+ Array params;384+ for (int i = 2; i < argc; i++)385+ params.push_back(argv[i]);386+ int n = params.size();387+388+ //389+ // Special case non-string parameter types390+ //391+ if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]);392+ if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]);393+ if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);394+ if (strMethod == "listtransactions" && n > 0) ConvertTo<boost::int64_t>(params[0]);395+ if (strMethod == "listtransactions" && n > 1) ConvertTo<bool>(params[1]);396+ if (strMethod == "getamountreceived" && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated397+ if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]);398+ if (strMethod == "getreceivedbylabel" && n > 1) ConvertTo<boost::int64_t>(params[1]);399+ if (strMethod == "getallreceived" && n > 0) ConvertTo<boost::int64_t>(params[0]); // deprecated400+ if (strMethod == "getallreceived" && n > 1) ConvertTo<bool>(params[1]);401+ if (strMethod == "listreceivedbyaddress" && n > 0) ConvertTo<boost::int64_t>(params[0]);402+ if (strMethod == "listreceivedbyaddress" && n > 1) ConvertTo<bool>(params[1]);403+ if (strMethod == "listreceivedbylabel" && n > 0) ConvertTo<boost::int64_t>(params[0]);404+ if (strMethod == "listreceivedbylabel" && n > 1) ConvertTo<bool>(params[1]);405+406+ // Execute407+ result = CallRPC(strMethod, params);408+ }409 410 // Print result411 string strResult = (result.type() == str_type ? result.get_str() : write_string(result, true));
serialize.h (modified)
1--- v0.2.9/serialize.h2+++ v0.2.10/serialize.h3@@ -19,7 +19,7 @@4 class CDataStream;5 class CAutoFile;6 7-static const int VERSION = 209;8+static const int VERSION = 210;9 static const char* pszSubVer = ".0";10 11
ui.cpp (modified)
1--- v0.2.9/ui.cpp2+++ v0.2.10/ui.cpp3@@ -1016,6 +1016,11 @@4 5 if (fDebug && GetTime() - nThreadSocketHandlerHeartbeat > 60)6 m_statusBar->SetStatusText(" ERROR: ThreadSocketHandler has stopped", 0);7+8+ // Update receiving address9+ string strDefaultAddress = PubKeyToAddress(vchDefaultKey);10+ if (m_textCtrlAddress->GetValue() != strDefaultAddress)11+ m_textCtrlAddress->SetValue(strDefaultAddress);12 }13 14 15@@ -2087,7 +2092,9 @@16 }17 18 // Send payment tx to seller, with response going to OnReply3 via event handler19- pnode->PushRequest("submitorder", wtx, SendingDialogOnReply3, this);20+ CWalletTx wtxSend = wtx;21+ wtxSend.fFromMe = false;22+ pnode->PushRequest("submitorder", wtxSend, SendingDialogOnReply3, this);23 24 Status(_("Waiting for confirmation..."));25 MainFrameRepaint();
uibase.cpp (modified)
1--- v0.2.9/uibase.cpp2+++ v0.2.10/uibase.cpp3@@ -616,7 +616,7 @@4 5 fgSizer1->Add( 0, 0, 0, wxEXPAND, 5 );6 7- m_staticTextInstructions = new wxStaticText( this, wxID_ANY, _("Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, \nor Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online."), wxDefaultPosition, wxDefaultSize, 0 );8+ m_staticTextInstructions = new wxStaticText( this, wxID_ANY, _("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) or IP address (e.g. 123.45.6.7)"), wxDefaultPosition, wxDefaultSize, 0 );9 m_staticTextInstructions->Wrap( -1 );10 fgSizer1->Add( m_staticTextInstructions, 0, wxTOP|wxRIGHT|wxLEFT, 5 );11
uibase.h (modified)
1--- v0.2.9/uibase.h2+++ v0.2.10/uibase.h3@@ -275,7 +275,7 @@4 5 6 public:7- CSendDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 675,312 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );8+ CSendDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Send Coins"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 675,298 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );9 ~CSendDialogBase();10 11 };
uint256.h (modified)
1--- v0.2.9/uint256.h2+++ v0.2.10/uint256.h3@@ -388,7 +388,6 @@4 //5 // uint160 and uint256 could be implemented as templates, but to keep6 // compile errors and debugging cleaner, they're copy and pasted.7-// It's safe to search and replace 160 with 256 and vice versa.8 //9 10 11@@ -405,6 +404,8 @@12 13 uint160()14 {15+ for (int i = 0; i < WIDTH; i++)16+ pn[i] = 0;17 }18 19 uint160(const basetype& b)20@@ -517,6 +518,8 @@21 22 uint256()23 {24+ for (int i = 0; i < WIDTH; i++)25+ pn[i] = 0;26 }27 28 uint256(const basetype& b)
util.h (modified)
1--- v0.2.9/util.h2+++ v0.2.10/util.h3@@ -520,8 +520,13 @@4 5 inline void SetThreadPriority(int nPriority)6 {7- // threads are processes on linux, so PRIO_PROCESS affects just the one thread8- setpriority(PRIO_PROCESS, getpid(), nPriority);9+ // It's unclear if it's even possible to change thread priorities on Linux,10+ // but we really and truly need it for the generation threads.11+#ifdef PRIO_THREAD12+ setpriority(PRIO_THREAD, 0, nPriority);13+#else14+ setpriority(PRIO_PROCESS, 0, nPriority);15+#endif16 }17 18 inline bool TerminateThread(pthread_t hthread, unsigned int nExitCode)
