diff --git a/db.cpp b/db.cpp index 123559263..61d602533 100644 --- a/db.cpp +++ b/db.cpp @@ -139,7 +139,7 @@ void DBFlush(bool fShutdown) { // Flush log data to the actual data file // on all files that are not in use - printf("DBFlush(%s)\n", fShutdown ? "true" : "false"); + printf("DBFlush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started"); if (!fDbEnvInit) return; CRITICAL_BLOCK(cs_db) diff --git a/main.cpp b/main.cpp index e4f1deb84..fe213c099 100644 --- a/main.cpp +++ b/main.cpp @@ -42,8 +42,6 @@ map > mapPubKeys; CCriticalSection cs_mapKeys; CKey keyUser; -int nDropMessagesTest = 0; - // Settings int fGenerateBitcoins = false; int64 nTransactionFee = 0; @@ -1721,9 +1719,9 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) static map > mapReuseKey; RandAddSeedPerfmon(); printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size()); - if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0) + if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { - printf("dropmessages DROPPING RECV MESSAGE\n"); + printf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } @@ -2315,6 +2313,8 @@ void BitcoinMiner() Sleep(1000); if (fShutdown) return; + if (!fGenerateBitcoins) + return; } unsigned int nTransactionsUpdatedLast = nTransactionsUpdated; diff --git a/main.h b/main.h index 16b8c6a3d..853fdfa5b 100644 --- a/main.h +++ b/main.h @@ -34,7 +34,6 @@ extern int nBestHeight; extern uint256 hashBestChain; extern CBlockIndex* pindexBest; extern unsigned int nTransactionsUpdated; -extern int nDropMessagesTest; // Settings extern int fGenerateBitcoins; diff --git a/net.cpp b/net.cpp index 44a75a177..b4df35cb5 100644 --- a/net.cpp +++ b/net.cpp @@ -511,11 +511,6 @@ void ThreadSocketHandler(void* parg) PrintException(NULL, "ThreadSocketHandler()"); } - foreach(CNode* pnode, vNodes) - closesocket(pnode->hSocket); - if (closesocket(hListenSocket) == SOCKET_ERROR) - printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); - printf("ThreadSocketHandler exiting\n"); } @@ -989,15 +984,13 @@ void ThreadMessageHandler2(void* parg) - -bool StartNode(string& strError) +bool BindListenPort(string& strError) { - if (pnodeLocalHost == NULL) - pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices)); strError = ""; + int nOne = 1; #ifdef __WXMSW__ - // Sockets startup + // Initialize Windows Sockets WSADATA wsadata; int ret = WSAStartup(MAKEWORD(2,2), &wsadata); if (ret != NO_ERROR) @@ -1008,33 +1001,6 @@ bool StartNode(string& strError) } #endif - // Get local host ip - char pszHostName[255]; - if (gethostname(pszHostName, sizeof(pszHostName)) == SOCKET_ERROR) - { - strError = strprintf("Error: Unable to get IP address of this computer (gethostname returned error %d)", WSAGetLastError()); - printf("%s\n", strError.c_str()); - return false; - } - struct hostent* phostent = gethostbyname(pszHostName); - if (!phostent) - { - strError = strprintf("Error: Unable to get IP address of this computer (gethostbyname returned error %d)", WSAGetLastError()); - printf("%s\n", strError.c_str()); - return false; - } - - // Take the first IP that isn't loopback 127.x.x.x - for (int i = 0; phostent->h_addr_list[i] != NULL; i++) - printf("host ip %d: %s\n", i, CAddress(*(unsigned int*)phostent->h_addr_list[i]).ToStringIP().c_str()); - for (int i = 0; phostent->h_addr_list[i] != NULL; i++) - { - addrLocalHost = CAddress(*(unsigned int*)phostent->h_addr_list[i], DEFAULT_PORT, nLocalServices); - if (addrLocalHost.IsValid() && addrLocalHost.GetByte(3) != 127) - break; - } - printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str()); - // Create socket for listening for incoming connections hListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (hListenSocket == INVALID_SOCKET) @@ -1043,15 +1009,21 @@ bool StartNode(string& strError) printf("%s\n", strError.c_str()); return false; } + #if defined(__BSD__) || defined(__WXOSX__) - int set = 1; - setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); + // Different way of disabling SIGPIPE on BSD + setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); +#endif + +#ifndef __WXMSW__ + // Allow binding if the port is still in TIME_WAIT state after + // the program was closed and restarted. Not an issue on windows. + setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); #endif - // Set to nonblocking, incoming connections will also inherit this #ifdef __WXMSW__ - u_long nOne = 1; - if (ioctlsocket(hListenSocket, FIONBIO, &nOne) == SOCKET_ERROR) + // Set to nonblocking, incoming connections will also inherit this + if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR) #else if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR) #endif @@ -1072,7 +1044,7 @@ bool StartNode(string& strError) { int nErr = WSAGetLastError(); if (nErr == WSAEADDRINUSE) - strError = strprintf("Error: Unable to bind to port %d on this computer. The program is probably already running.", ntohs(sockaddr.sin_port)); + strError = strprintf("Unable to bind to port %d on this computer. Bitcoin may be running already.", ntohs(sockaddr.sin_port)); else strError = strprintf("Error: Unable to bind to port %d on this computer (bind returned error %d)", ntohs(sockaddr.sin_port), nErr); printf("%s\n", strError.c_str()); @@ -1088,6 +1060,42 @@ bool StartNode(string& strError) return false; } + return true; +} + +bool StartNode(string& strError) +{ + strError = ""; + if (pnodeLocalHost == NULL) + pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", nLocalServices)); + + // Get local host ip + char pszHostName[255]; + if (gethostname(pszHostName, sizeof(pszHostName)) == SOCKET_ERROR) + { + strError = strprintf("Error: Unable to get IP address of this computer (gethostname returned error %d)", WSAGetLastError()); + printf("%s\n", strError.c_str()); + return false; + } + struct hostent* phostent = gethostbyname(pszHostName); + if (!phostent) + { + strError = strprintf("Error: Unable to get IP address of this computer (gethostbyname returned error %d)", WSAGetLastError()); + printf("%s\n", strError.c_str()); + return false; + } + + // Take the first IP that isn't loopback 127.x.x.x + for (int i = 0; phostent->h_addr_list[i] != NULL; i++) + printf("host ip %d: %s\n", i, CAddress(*(unsigned int*)phostent->h_addr_list[i]).ToStringIP().c_str()); + for (int i = 0; phostent->h_addr_list[i] != NULL; i++) + { + addrLocalHost = CAddress(*(unsigned int*)phostent->h_addr_list[i], DEFAULT_PORT, nLocalServices); + if (addrLocalHost.IsValid() && addrLocalHost.GetByte(3) != 127) + break; + } + printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str()); + // Get our external IP address for incoming connections if (fUseProxy) { @@ -1158,9 +1166,5 @@ bool StopNode() Sleep(20); Sleep(50); - // Sockets shutdown -#ifdef __WXMSW__ - WSACleanup(); -#endif return true; } diff --git a/net.h b/net.h index 024e7336e..7b83d462f 100644 --- a/net.h +++ b/net.h @@ -28,6 +28,7 @@ CNode* FindNode(unsigned int ip); CNode* ConnectNode(CAddress addrConnect, int64 nTimeout=0); void AbandonRequests(void (*fn)(void*, CDataStream&), void* param1); bool AnySubscribed(unsigned int nChannel); +bool BindListenPort(string& strError=REF(string())); bool StartNode(string& strError=REF(string())); bool StopNode(); @@ -456,6 +457,8 @@ extern CNode* pnodeLocalHost; extern uint64 nLocalHostNonce; extern bool fShutdown; extern array vnThreadsRunning; +extern SOCKET hListenSocket; + extern vector vNodes; extern CCriticalSection cs_vNodes; extern map, CAddress> mapAddresses; @@ -647,8 +650,7 @@ public: void EndMessage() { - extern int nDropMessagesTest; - if (nDropMessagesTest > 0 && GetRand(nDropMessagesTest) == 0) + if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { printf("dropmessages DROPPING SEND MESSAGE\n"); AbortMessage(); diff --git a/ui.cpp b/ui.cpp index d33023134..bfb0ad293 100644 --- a/ui.cpp +++ b/ui.cpp @@ -181,17 +181,30 @@ void AddToMyProducts(CProduct product) ""); } -void StringMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y) +void CalledMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y, int* pnRet, bool* pfDone) { - wxMessageBox(message, caption, style, parent, x, y); + *pnRet = wxMessageBox(message, caption, style, parent, x, y); + *pfDone = true; } int ThreadSafeMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y) { #ifdef __WXMSW__ - wxMessageBox(message, caption, style, parent, x, y); + return wxMessageBox(message, caption, style, parent, x, y); #else - UIThreadCall(bind(StringMessageBox, message, caption, style, parent, x, y)); + if (wxThread::IsMain()) + { + return wxMessageBox(message, caption, style, parent, x, y); + } + else + { + int nRet = 0; + bool fDone = false; + UIThreadCall(bind(CalledMessageBox, message, caption, style, parent, x, y, &nRet, &fDone)); + while (!fDone) + Sleep(100); + return nRet; + } #endif } @@ -303,6 +316,18 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent) fOnSetFocusAddress = false; fRefresh = false; m_choiceFilter->SetSelection(0); +#ifndef __WXMSW__ + wxFont fontTmp = m_staticTextBalance->GetFont(); + fontTmp.SetPointSize(10); + fontTmp.SetFamily(wxFONTFAMILY_TELETYPE); + m_staticTextBalance->SetFont(fontTmp); + m_staticTextBalance->SetSize(140, 17); + // ampersand underlines aren't working on gtk + m_toolBar->ClearTools(); + m_toolBar->AddTool(wxID_BUTTONSEND, "Send Coins", wxBitmap(send20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString); + m_toolBar->AddTool(wxID_BUTTONRECEIVE, "Address Book", wxBitmap(addressbook20_xpm), wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString); + m_toolBar->Realize(); +#endif m_staticTextBalance->SetLabel(FormatMoney(GetBalance()) + " "); m_listCtrl->SetFocus(); SetIcon(wxICON(bitcoin)); @@ -998,7 +1023,7 @@ void CMainFrame::OnPaintListCtrl(wxPaintEvent& event) } -void UIThreadCall(boost::function fn) +void UIThreadCall(boost::function0 fn) { // Call this with a function object created with bind. // bind needs all parameters to match the function's expected types @@ -1009,14 +1034,14 @@ void UIThreadCall(boost::function fn) if (pframeMain) { wxCommandEvent event(wxEVT_UITHREADCALL); - event.SetClientData((void*)new boost::function(fn)); + event.SetClientData((void*)new boost::function0(fn)); pframeMain->GetEventHandler()->AddPendingEvent(event); } } void CMainFrame::OnUIThreadCall(wxCommandEvent& event) { - boost::function* pfn = (boost::function*)event.GetClientData(); + boost::function0* pfn = (boost::function0*)event.GetClientData(); (*pfn)(); delete pfn; } @@ -1630,7 +1655,14 @@ CSendDialog::CSendDialog(wxWindow* parent, const wxString& strAddress) : CSendDi m_choiceTransferType->SetSelection(0); m_bitmapCheckMark->Show(false); fEnabledPrev = true; + m_textCtrlAddress->SetFocus(); //// todo: should add a display of your balance for convenience +#ifndef __WXMSW__ + wxFont fontTmp = m_staticTextInstructions->GetFont(); + fontTmp.SetPointSize(fontTmp.GetPointSize()-1); + m_staticTextInstructions->SetFont(fontTmp); + SetSize(725, wxDefaultCoord); +#endif // Set Icon wxIcon iconSend; @@ -1801,7 +1833,7 @@ CSendingDialog::CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 n fUIDone = false; fWorkDone = false; - SetTitle(strprintf("Sending %s to %s...", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str())); + SetTitle(strprintf("Sending %s to %s", FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str())); m_textCtrlStatus->SetValue(""); _beginthread(SendingDialogStartTransfer, 0, this); @@ -3344,16 +3376,19 @@ IMPLEMENT_APP(CMyApp) bool CMyApp::OnInit() { + bool fRet = false; try { - return OnInit2(); + fRet = OnInit2(); } catch (std::exception& e) { PrintException(&e, "OnInit()"); } catch (...) { PrintException(NULL, "OnInit()"); } - return false; + if (!fRet) + Shutdown(NULL); + return fRet; } bool CMyApp::OnInit2() @@ -3374,6 +3409,9 @@ bool CMyApp::OnInit2() SetAppName("bitcoin"); #endif + // + // Parameters + // ParseParameters(argc, argv); if (mapArgs.count("-?") || mapArgs.count("--help")) { @@ -3389,7 +3427,27 @@ bool CMyApp::OnInit2() " -connect=\t Connect only to the specified node\n" " -?\t\t This help message\n"; wxMessageBox(strUsage, "Bitcoin", wxOK); - exit(0); + return false; + } + + if (mapArgs.count("-datadir")) + strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir)); + + if (mapArgs.count("-debug")) + fDebug = true; + + if (mapArgs.count("-printtodebugger")) + fPrintToDebugger = true; + + printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + printf("Bitcoin version %d, OS version %s\n", VERSION, wxGetOsDescription().mb_str()); + + if (mapArgs.count("-loadblockindextest")) + { + CTxDB txdb("r"); + txdb.LoadBlockIndex(); + PrintBlockTree(); + return false; } // @@ -3434,41 +3492,20 @@ bool CMyApp::OnInit2() } #endif - // - // Parameters - // - if (mapArgs.count("-datadir")) - strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir)); - - if (mapArgs.count("-debug")) - fDebug = true; - - if (mapArgs.count("-printtodebugger")) - fPrintToDebugger = true; - - printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); - printf("Bitcoin version %d, OS version %s\n", VERSION, wxGetOsDescription().mb_str()); - - if (mapArgs.count("-dropmessages")) - { - nDropMessagesTest = atoi(mapArgs["-dropmessages"]); - if (nDropMessagesTest == 0) - nDropMessagesTest = 20; - } - - if (mapArgs.count("-loadblockindextest")) + // Bind to the port early so we can tell if another instance is already running. + // This is a backup to wxSingleInstanceChecker, which doesn't work on Linux. + string strErrors; + if (!BindListenPort(strErrors)) { - CTxDB txdb("r"); - txdb.LoadBlockIndex(); - PrintBlockTree(); - exit(0); + wxMessageBox(strErrors, "Bitcoin"); + return false; } // // Load data files // bool fFirstRun; - string strErrors; + strErrors = ""; int64 nStart; printf("Loading addresses...\n"); @@ -3502,7 +3539,6 @@ bool CMyApp::OnInit2() if (!strErrors.empty()) { wxMessageBox(strErrors, "Bitcoin"); - OnExit(); return false; } @@ -3515,7 +3551,6 @@ bool CMyApp::OnInit2() if (mapArgs.count("-printblockindex") || mapArgs.count("-printblocktree")) { PrintBlockTree(); - OnExit(); return false; } @@ -3539,7 +3574,6 @@ bool CMyApp::OnInit2() } if (nFound == 0) printf("No blocks matching %s were found\n", strMatch.c_str()); - OnExit(); return false; } @@ -3558,7 +3592,6 @@ bool CMyApp::OnInit2() if (!addrProxy.IsValid()) { wxMessageBox("Invalid -proxy address", "Bitcoin"); - OnExit(); return false; } } @@ -3588,10 +3621,7 @@ bool CMyApp::OnInit2() _beginthread(ThreadDelayedRepaint, 0, NULL); if (!CheckDiskSpace()) - { - OnExit(); return false; - } RandAddSeedPerfmon(); diff --git a/ui.h b/ui.h index 1db40997f..a919c3668 100644 --- a/ui.h +++ b/ui.h @@ -24,7 +24,7 @@ extern int fMinimizeOnClose; extern void HandleCtrlA(wxKeyEvent& event); extern string FormatTxStatus(const CWalletTx& wtx); -extern void UIThreadCall(boost::function); +extern void UIThreadCall(boost::function0); extern void MainFrameRepaint(); extern void Shutdown(void* parg); extern int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1); diff --git a/uibase.cpp b/uibase.cpp index 6a280cda6..7bc8081f0 100644 --- a/uibase.cpp +++ b/uibase.cpp @@ -89,7 +89,7 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString& bSizer85->Add( m_textCtrlAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT("&Copy to Clipboard"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT(" &Copy to Clipboard "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); bSizer85->Add( m_buttonCopy, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_button91 = new wxButton( this, wxID_BUTTONCHANGE, wxT("C&hange..."), wxDefaultPosition, wxDefaultSize, 0 ); @@ -116,7 +116,7 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString& m_staticTextBalance = new wxStaticText( m_panel14, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 120,15 ), wxALIGN_RIGHT|wxST_NO_AUTORESIZE ); m_staticTextBalance->Wrap( -1 ); m_staticTextBalance->SetFont( wxFont( 8, 70, 90, 90, false, wxEmptyString ) ); - m_staticTextBalance->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + m_staticTextBalance->SetBackgroundColour( wxColour( 255, 255, 255 ) ); bSizer66->Add( m_staticTextBalance, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); @@ -341,10 +341,10 @@ CTxDetailsDialogBase::CTxDetailsDialogBase( wxWindow* parent, wxWindowID id, con bSizer64->Add( bSizer66, 1, wxEXPAND, 5 ); wxBoxSizer* bSizer65; - bSizer65 = new wxBoxSizer( wxVERTICAL ); + bSizer65 = new wxBoxSizer( wxHORIZONTAL ); m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer65->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer65->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer64->Add( bSizer65, 0, wxALIGN_RIGHT, 5 ); @@ -521,13 +521,13 @@ COptionsDialogBase::COptionsDialogBase( wxWindow* parent, wxWindowID id, const w bSizer58 = new wxBoxSizer( wxHORIZONTAL ); m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer58->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer58->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer58->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer58->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonApply = new wxButton( this, wxID_APPLY, wxT("&Apply"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer58->Add( m_buttonApply, 0, wxALL, 5 ); + bSizer58->Add( m_buttonApply, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer55->Add( bSizer58, 0, wxALIGN_RIGHT, 5 ); @@ -619,7 +619,7 @@ CAboutDialogBase::CAboutDialogBase( wxWindow* parent, wxWindowID id, const wxStr bSizer61->Add( 0, 0, 1, wxEXPAND, 5 ); m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer61->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer61->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer60->Add( bSizer61, 0, wxALIGN_RIGHT|wxEXPAND, 5 ); @@ -655,9 +655,9 @@ CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxStrin fgSizer1->Add( 0, 0, 0, wxEXPAND, 5 ); - m_staticText14 = new wxStaticText( this, wxID_ANY, wxT("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 ); - m_staticText14->Wrap( -1 ); - fgSizer1->Add( m_staticText14, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + m_staticTextInstructions = new wxStaticText( this, wxID_ANY, wxT("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 ); + m_staticTextInstructions->Wrap( -1 ); + fgSizer1->Add( m_staticTextInstructions, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bSizer47; bSizer47 = new wxBoxSizer( wxHORIZONTAL ); @@ -681,11 +681,16 @@ CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxStrin m_textCtrlAddress = new wxTextCtrl( this, wxID_TEXTCTRLPAYTO, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizer19->Add( m_textCtrlAddress, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + wxBoxSizer* bSizer66; + bSizer66 = new wxBoxSizer( wxHORIZONTAL ); + m_buttonPaste = new wxButton( this, wxID_BUTTONPASTE, wxT("&Paste"), wxDefaultPosition, wxSize( -1,-1 ), wxBU_EXACTFIT ); - bSizer19->Add( m_buttonPaste, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + bSizer66->Add( m_buttonPaste, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND, 5 ); m_buttonAddress = new wxButton( this, wxID_BUTTONADDRESSBOOK, wxT(" Address &Book..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer19->Add( m_buttonAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + bSizer66->Add( m_buttonAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND, 5 ); + + bSizer19->Add( bSizer66, 0, wxALIGN_CENTER_VERTICAL, 5 ); fgSizer1->Add( bSizer19, 1, wxEXPAND|wxRIGHT, 5 ); @@ -764,10 +769,10 @@ CSendDialogBase::CSendDialogBase( wxWindow* parent, wxWindowID id, const wxStrin m_buttonSend = new wxButton( this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); m_buttonSend->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) ); - bSizer23->Add( m_buttonSend, 0, wxALL, 5 ); + bSizer23->Add( m_buttonSend, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer23->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer23->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer21->Add( bSizer23, 0, wxEXPAND, 5 ); @@ -827,10 +832,10 @@ CSendingDialogBase::CSendingDialogBase( wxWindow* parent, wxWindowID id, const w m_buttonOK = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonOK->Enable( false ); - bSizer69->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer69->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer68->Add( bSizer69, 0, wxEXPAND, 5 ); @@ -877,21 +882,21 @@ CYourAddressDialogBase::CYourAddressDialogBase( wxWindow* parent, wxWindowID id, bSizer69->Add( 0, 0, 1, wxEXPAND, 5 ); m_buttonRename = new wxButton( this, wxID_BUTTONRENAME, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer69->Add( m_buttonRename, 0, wxALL, 5 ); + bSizer69->Add( m_buttonRename, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT("&New Address..."), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer69->Add( m_buttonNew, 0, wxALL, 5 ); + m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT(" &New Address... "), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT("&Copy to Clipboard"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer69->Add( m_buttonCopy, 0, wxALL, 5 ); + m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, wxT(" &Copy to Clipboard "), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + bSizer69->Add( m_buttonCopy, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer69->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); m_buttonCancel->Hide(); - bSizer69->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer68->Add( bSizer69, 0, wxEXPAND, 5 ); @@ -950,19 +955,19 @@ CAddressBookDialogBase::CAddressBookDialogBase( wxWindow* parent, wxWindowID id, bSizer69->Add( 0, 0, 1, wxEXPAND, 5 ); m_buttonEdit = new wxButton( this, wxID_BUTTONEDIT, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer69->Add( m_buttonEdit, 0, wxALL, 5 ); + bSizer69->Add( m_buttonEdit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT("&New Address..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer69->Add( m_buttonNew, 0, wxALL, 5 ); + m_buttonNew = new wxButton( this, wxID_BUTTONNEW, wxT(" &New Address... "), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer69->Add( m_buttonDelete, 0, wxALL, 5 ); + bSizer69->Add( m_buttonDelete, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer69->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer69->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer68->Add( bSizer69, 0, wxEXPAND, 5 ); @@ -1360,13 +1365,13 @@ CEditProductDialogBase::CEditProductDialogBase( wxWindow* parent, wxWindowID id, bSizer26 = new wxBoxSizer( wxHORIZONTAL ); m_buttonOK = new wxButton( this, wxID_BUTTONSEND, wxT("&Send"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer26->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer26->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonPreview = new wxButton( this, wxID_BUTTONPREVIEW, wxT("&Preview"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer26->Add( m_buttonPreview, 0, wxALL, 5 ); + bSizer26->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer26->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer26->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 ); @@ -1551,10 +1556,10 @@ CViewProductDialogBase::CViewProductDialogBase( wxWindow* parent, wxWindowID id, bSizer25 = new wxBoxSizer( wxHORIZONTAL ); m_buttonSubmitForm = new wxButton( m_scrolledWindow, wxID_BUTTONSAMPLE, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer25->Add( m_buttonSubmitForm, 0, wxALL, 5 ); + bSizer25->Add( m_buttonSubmitForm, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancelForm = new wxButton( m_scrolledWindow, wxID_CANCEL2, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer25->Add( m_buttonCancelForm, 0, wxALL, 5 ); + bSizer25->Add( m_buttonCancelForm, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer21->Add( bSizer25, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); @@ -1571,13 +1576,13 @@ CViewProductDialogBase::CViewProductDialogBase( wxWindow* parent, wxWindowID id, m_buttonBack = new wxButton( this, wxID_BUTTONBACK, wxT("< &Back "), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonBack->Enable( false ); - bSizer26->Add( m_buttonBack, 0, wxALL, 5 ); + bSizer26->Add( m_buttonBack, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonNext = new wxButton( this, wxID_BUTTONNEXT, wxT(" &Next >"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer26->Add( m_buttonNext, 0, wxALL, 5 ); + bSizer26->Add( m_buttonNext, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer26->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer26->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 ); @@ -1622,7 +1627,7 @@ CViewOrderDialogBase::CViewOrderDialogBase( wxWindow* parent, wxWindowID id, con bSizer26 = new wxBoxSizer( wxHORIZONTAL ); m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer26->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer26->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer20->Add( bSizer26, 0, wxALIGN_RIGHT, 5 ); @@ -1678,10 +1683,10 @@ CEditReviewDialogBase::CEditReviewDialogBase( wxWindow* parent, wxWindowID id, c bSizer113 = new wxBoxSizer( wxHORIZONTAL ); m_buttonSubmit = new wxButton( this, wxID_SUBMIT, wxT("&Submit"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer113->Add( m_buttonSubmit, 0, wxALL, 5 ); + bSizer113->Add( m_buttonSubmit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer113->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer113->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer112->Add( bSizer113, 0, wxALIGN_RIGHT, 5 ); @@ -1745,10 +1750,10 @@ CGetTextFromUserDialogBase::CGetTextFromUserDialogBase( wxWindow* parent, wxWind bSizer80->Add( 0, 0, 1, wxEXPAND, 5 ); m_buttonOK = new wxButton( this, wxID_OK, wxT("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer80->Add( m_buttonOK, 0, wxALL, 5 ); + bSizer80->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_buttonCancel = new wxButton( this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer80->Add( m_buttonCancel, 0, wxALL, 5 ); + bSizer80->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer79->Add( bSizer80, 0, wxEXPAND, 5 ); diff --git a/uibase.h b/uibase.h index 6332b931c..2cb99e9a5 100644 --- a/uibase.h +++ b/uibase.h @@ -277,7 +277,7 @@ class CSendDialogBase : public wxDialog protected: - wxStaticText* m_staticText14; + wxStaticText* m_staticTextInstructions; wxStaticBitmap* m_bitmapCheckMark; wxStaticText* m_staticText36; diff --git a/uiproject.fbp b/uiproject.fbp index 7c5bb24f9..3aa1c86bc 100644 --- a/uiproject.fbp +++ b/uiproject.fbp @@ -225,7 +225,7 @@ - + 20,20 @@ -489,7 +489,7 @@ 0 wxID_BUTTONCOPY - &Copy to Clipboard + &Copy to Clipboard m_buttonCopy @@ -708,7 +708,7 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 - wxSYS_COLOUR_WINDOW + 255,255,255 1 @@ -1627,11 +1627,11 @@ bSizer65 - wxVERTICAL + wxHORIZONTAL none 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -3014,7 +3014,7 @@ none 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -3066,7 +3066,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -3118,7 +3118,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -3476,7 +3476,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -3638,7 +3638,7 @@ Enter the recipient's IP address (e.g. 123.45.6.7) for online transfer with comments and confirmation, or Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJED9L) if recipient is not online. - m_staticText14 + m_staticTextInstructions protected @@ -3861,106 +3861,117 @@ 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT + wxALIGN_CENTER_VERTICAL 0 - - - - 0 - 1 - - - 0 - wxID_BUTTONPASTE - &Paste - - - m_buttonPaste - protected - - -1,-1 - wxBU_EXACTFIT - - - - - - OnButtonPaste - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT - 0 - - - - 0 - 1 - - - 0 - wxID_BUTTONADDRESSBOOK - Address &Book... - + - m_buttonAddress - protected - - - - - - - - - OnButtonAddressBook - - - - - - - - - - - - - - - - - - - - - - - + bSizer66 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND + 0 + + + + 0 + 1 + + + 0 + wxID_BUTTONPASTE + &Paste + + + m_buttonPaste + protected + + -1,-1 + wxBU_EXACTFIT + + + + + + OnButtonPaste + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxEXPAND + 0 + + + + 0 + 1 + + + 0 + wxID_BUTTONADDRESSBOOK + Address &Book... + + + m_buttonAddress + protected + + + + + + + + + OnButtonAddressBook + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4472,7 +4483,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -4524,7 +4535,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -4762,7 +4773,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -4814,7 +4825,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5076,7 +5087,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5128,7 +5139,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5139,7 +5150,7 @@ 0 wxID_BUTTONNEW - &New Address... + &New Address... -1,-1 m_buttonNew @@ -5180,7 +5191,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5191,7 +5202,7 @@ 0 wxID_BUTTONCOPY - &Copy to Clipboard + &Copy to Clipboard -1,-1 m_buttonCopy @@ -5232,7 +5243,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5284,7 +5295,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5546,7 +5557,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5598,7 +5609,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5609,7 +5620,7 @@ 0 wxID_BUTTONNEW - &New Address... + &New Address... -1,-1 m_buttonNew @@ -5650,7 +5661,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5702,7 +5713,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -5754,7 +5765,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10212,7 +10223,7 @@ none 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10264,7 +10275,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10316,7 +10327,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10665,7 +10676,7 @@ none 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10717,7 +10728,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10785,7 +10796,7 @@ none 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10837,7 +10848,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -10889,7 +10900,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -11074,7 +11085,7 @@ none 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -11475,7 +11486,7 @@ none 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -11527,7 +11538,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -11902,7 +11913,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 @@ -11954,7 +11965,7 @@ 5 - wxALL + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND 0 diff --git a/util.cpp b/util.cpp index 5efb579bf..4a5b983d2 100644 --- a/util.cpp +++ b/util.cpp @@ -53,6 +53,17 @@ public: for (int i = 0; i < CRYPTO_num_locks(); i++) delete ppmutexOpenSSL[i]; OPENSSL_free(ppmutexOpenSSL); + + // Close sockets + foreach(CNode* pnode, vNodes) + closesocket(pnode->hSocket); + if (closesocket(hListenSocket) == SOCKET_ERROR) + printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError()); + +#ifdef __WXMSW__ + // Shutdown Windows Sockets + WSACleanup(); +#endif } } instance_of_cinit;