Workaround for bug on wxWidgets 2.9.0 Ubuntu 9.10 64-bit where first character of...
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
Sun, 14 Feb 2010 00:08:27 +0000 (00:08 +0000)
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
Sun, 14 Feb 2010 00:08:27 +0000 (00:08 +0000)
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@62 1a98c847-1fd6-4fd8-948a-caf3550aa51b

bignum.h
main.cpp
net.cpp
rpc.cpp
ui.cpp
uint256.h

index e1ab165..61ba3fa 100644 (file)
--- a/bignum.h
+++ b/bignum.h
@@ -64,12 +64,6 @@ public:
         }\r
     }\r
 \r
-    explicit CBigNum(const std::string& str)\r
-    {\r
-        BN_init(this);\r
-        SetHex(str);\r
-    }\r
-\r
     CBigNum& operator=(const CBigNum& b)\r
     {\r
         if (!BN_copy(this, &b))\r
@@ -407,6 +401,7 @@ public:
 \r
     CBigNum& operator>>=(unsigned int shift)\r
     {\r
+        // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number\r
         if (!BN_rshift(this, this, shift))\r
             throw bignum_error("CBigNum:operator>>= : BN_rshift failed");\r
         return *this;\r
@@ -516,6 +511,7 @@ inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
 inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)\r
 {\r
     CBigNum r;\r
+    // Note: BN_rshift segfaults on 64-bit ubuntu 9.10 if 2^shift is greater than the number\r
     if (!BN_rshift(&r, &a, shift))\r
         throw bignum_error("CBigNum:operator>> : BN_rshift failed");\r
     return r;\r
index 90d239f..0c7aff8 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1570,7 +1570,9 @@ bool LoadBlockIndex(bool fAllowNew)
         txNew.vout.resize(1);\r
         txNew.vin[0].scriptSig     = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));\r
         txNew.vout[0].nValue       = 50 * COIN;\r
-        txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG;\r
+        CBigNum bnPubKey;\r
+        bnPubKey.SetHex("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704");\r
+        txNew.vout[0].scriptPubKey = CScript() << bnPubKey << OP_CHECKSIG;\r
         CBlock block;\r
         block.vtx.push_back(txNew);\r
         block.hashPrevBlock = 0;\r
@@ -3022,12 +3024,9 @@ string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtx
         return "You don't have enough money";\r
 \r
     // Parse bitcoin address\r
-    uint160 hash160;\r
-    if (!AddressToHash160(strAddress, hash160))\r
+    CScript scriptPubKey;\r
+    if (!scriptPubKey.SetBitcoinAddress(strAddress))\r
         return "Invalid bitcoin address";\r
 \r
-    // Send to bitcoin address\r
-    CScript scriptPubKey;\r
-    scriptPubKey.SetBitcoinAddress(hash160);\r
     return SendMoney(scriptPubKey, nValue, wtxNew);\r
 }\r
diff --git a/net.cpp b/net.cpp
index ada78eb..d669b8c 100644 (file)
--- a/net.cpp
+++ b/net.cpp
@@ -1032,7 +1032,7 @@ void ThreadMessageHandler2(void* parg)
 {\r
     printf("ThreadMessageHandler started\n");\r
     SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);\r
-    loop\r
+    while (!fShutdown)\r
     {\r
         // Poll the connected nodes for messages\r
         vector<CNode*> vNodesCopy;\r
diff --git a/rpc.cpp b/rpc.cpp
index 9f28e7e..b176b15 100644 (file)
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -503,7 +503,7 @@ Value CallRPC(const string& strMethod, const Array& params)
     // Connect to localhost\r
     tcp::iostream stream("127.0.0.1", "8332");\r
     if (stream.fail())\r
-        throw runtime_error("unable to connect to server");\r
+        throw runtime_error("couldn't connect to server");\r
 \r
     // Send request\r
     string strRequest = JSONRPCRequest(strMethod, params, 1);\r
diff --git a/ui.cpp b/ui.cpp
index 586200d..aad599c 100644 (file)
--- a/ui.cpp
+++ b/ui.cpp
@@ -328,7 +328,7 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
     m_toolBar->Realize();\r
     // resize to fit ubuntu's huge default font\r
     dResize = 1.20;\r
-    SetSize(dResize * GetSize().GetWidth(), 1.1 * GetSize().GetHeight());\r
+    SetSize((dResize + 0.02) * GetSize().GetWidth(), 1.09 * GetSize().GetHeight());\r
 #endif\r
     m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + "  ");\r
     m_listCtrl->SetFocus();\r
@@ -346,24 +346,6 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent)
     m_listCtrl->InsertColumn(5, "Debit",        wxLIST_FORMAT_RIGHT, dResize * 79);\r
     m_listCtrl->InsertColumn(6, "Credit",       wxLIST_FORMAT_RIGHT, dResize * 79);\r
 \r
-    //m_listCtrlProductsSent->InsertColumn(0, "Category",      wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlProductsSent->InsertColumn(1, "Title",         wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlProductsSent->InsertColumn(2, "Description",   wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlProductsSent->InsertColumn(3, "Price",         wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlProductsSent->InsertColumn(4, "",              wxLIST_FORMAT_LEFT,  100);\r
-\r
-    //m_listCtrlOrdersSent->InsertColumn(0, "Time",          wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersSent->InsertColumn(1, "Price",         wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersSent->InsertColumn(2, "",              wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersSent->InsertColumn(3, "",              wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersSent->InsertColumn(4, "",              wxLIST_FORMAT_LEFT,  100);\r
-\r
-    //m_listCtrlOrdersReceived->InsertColumn(0, "Time",            wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersReceived->InsertColumn(1, "Price",           wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersReceived->InsertColumn(2, "Payment Status",  wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersReceived->InsertColumn(3, "",                wxLIST_FORMAT_LEFT,  100);\r
-    //m_listCtrlOrdersReceived->InsertColumn(4, "",                wxLIST_FORMAT_LEFT,  100);\r
-\r
     // Init status bar\r
     int pnWidths[3] = { -100, 88, 290 };\r
 #ifndef __WXMSW__\r
@@ -503,33 +485,34 @@ int CMainFrame::GetSortIndex(const string& strSort)
 \r
 void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5, const wxString& str6)\r
 {\r
-    string str0 = strSort;\r
-    long nData = *(long*)&hashKey;\r
+    strSort = " " + strSort;       // leading space to workaround wx2.9.0 ubuntu 9.10 bug\r
+    long nData = *(long*)&hashKey; //  where first char of hidden column is displayed\r
 \r
     // Find item\r
     if (!fNew && nIndex == -1)\r
     {\r
+        string strHash = " " + hashKey.ToString();\r
         while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)\r
-            if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString())\r
+            if (GetItemText(m_listCtrl, nIndex, 1) == strHash)\r
                 break;\r
     }\r
 \r
     // fNew is for blind insert, only use if you're sure it's new\r
     if (fNew || nIndex == -1)\r
     {\r
-        nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0);\r
+        nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), strSort);\r
     }\r
     else\r
     {\r
         // If sort key changed, must delete and reinsert to make it relocate\r
-        if (GetItemText(m_listCtrl, nIndex, 0) != str0)\r
+        if (GetItemText(m_listCtrl, nIndex, 0) != strSort)\r
         {\r
             m_listCtrl->DeleteItem(nIndex);\r
-            nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), str0);\r
+            nIndex = m_listCtrl->InsertItem(GetSortIndex(strSort), strSort);\r
         }\r
     }\r
 \r
-    m_listCtrl->SetItem(nIndex, 1, hashKey.ToString());\r
+    m_listCtrl->SetItem(nIndex, 1, " " + hashKey.ToString());\r
     m_listCtrl->SetItem(nIndex, 2, str2);\r
     m_listCtrl->SetItem(nIndex, 3, str3);\r
     m_listCtrl->SetItem(nIndex, 4, str4);\r
@@ -544,8 +527,9 @@ bool CMainFrame::DeleteLine(uint256 hashKey)
 \r
     // Find item\r
     int nIndex = -1;\r
+    string strHash = " " + hashKey.ToString();\r
     while ((nIndex = m_listCtrl->FindItem(nIndex, nData)) != -1)\r
-        if (GetItemText(m_listCtrl, nIndex, 1) == hashKey.ToString())\r
+        if (GetItemText(m_listCtrl, nIndex, 1) == strHash)\r
             break;\r
 \r
     if (nIndex != -1)\r
@@ -1916,7 +1900,7 @@ CSendingDialog::CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 n
     fUIDone = false;\r
     fWorkDone = false;\r
 #ifndef __WXMSW__\r
-    SetSize(1.2 * GetSize().GetWidth(), 1.05 * GetSize().GetHeight());\r
+    SetSize(1.2 * GetSize().GetWidth(), 1.08 * GetSize().GetHeight());\r
 #endif\r
 \r
     SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str()));\r
index 9a0c770..6976d9d 100644 (file)
--- a/uint256.h
+++ b/uint256.h
@@ -299,19 +299,18 @@ public:
         return string(psz, psz + sizeof(pn)*2);\r
     }\r
 \r
-    void SetHex(const std::string& str)\r
+    void SetHex(const char* psz)\r
     {\r
         for (int i = 0; i < WIDTH; i++)\r
             pn[i] = 0;\r
 \r
-        // skip 0x\r
-        const char* psz = str.c_str();\r
+        // skip leading spaces\r
         while (isspace(*psz))\r
             psz++;\r
+\r
+        // skip 0x\r
         if (psz[0] == '0' && tolower(psz[1]) == 'x')\r
             psz += 2;\r
-        while (isspace(*psz))\r
-            psz++;\r
 \r
         // hex string to uint\r
         static char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };\r
@@ -332,6 +331,11 @@ public:
         }\r
     }\r
 \r
+    void SetHex(const std::string& str)\r
+    {\r
+        SetHex(str.c_str());\r
+    }\r
+\r
     std::string ToString() const\r
     {\r
         return (GetHex());\r