mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-22 16:14:50 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42605ce8bc | ||
|
|
124baa4ccb | ||
|
|
2d98de1b3a | ||
|
|
966cca4bd4 | ||
|
|
2cffa7ce31 | ||
|
|
d7d80a74d5 | ||
|
|
6557910ccf | ||
|
|
c2430126d7 | ||
|
|
cb420a1dfc | ||
|
|
0184604aaf | ||
|
|
75199de534 | ||
|
|
c6ab3cf6d9 |
209
build-osx.txt
Normal file
209
build-osx.txt
Normal file
@@ -0,0 +1,209 @@
|
||||
Mac OS X build instructions
|
||||
Laszlo Hanyecz (solar@heliacal.net)
|
||||
|
||||
|
||||
Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian.
|
||||
|
||||
All of the commands should be executed in Terminal.app.. it's in
|
||||
/Applications/Utilities
|
||||
|
||||
You need to install XCode with all the options checked so that the compiler
|
||||
and everything is available in /usr not just /Developer
|
||||
I think it comes on the DVD but you can get the current version from
|
||||
http://developer.apple.com
|
||||
|
||||
|
||||
1. Pick a directory to work inside.. something like ~/bitcoin works. The
|
||||
structure I use looks like this:
|
||||
(~ is your home directory)
|
||||
|
||||
~/bitcoin
|
||||
~/bitcoin/trunk # source code
|
||||
~/bitcoin/deps # dependencies.. like libraries and headers needed to compile
|
||||
~/bitcoin/Bitcoin.app # the application bundle where you can run the app
|
||||
|
||||
Just execute: mkdir ~/bitcoin
|
||||
This will create the top dir for you..
|
||||
|
||||
WARNING: do not use the ~ notation with the configure scripts.. use the full
|
||||
name of the directory, for example /Users/james/bitcoin/deps for a user named
|
||||
'james'. In my examples I am using 'macosuser' so make sure you change that.
|
||||
|
||||
2. Check out the trunk version of the bitcoin code from subversion:
|
||||
|
||||
cd ~/bitcoin
|
||||
svn checkout https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk
|
||||
|
||||
This will make ~/bitcoin/trunk for you with all the files from subversion.
|
||||
|
||||
3. Get and build the dependencies
|
||||
|
||||
|
||||
Boost
|
||||
-----
|
||||
|
||||
Download from http://www.boost.org/users/download/
|
||||
I'm assuming it ended up in ~/Downloads..
|
||||
|
||||
mkdir ~/bitcoin/deps
|
||||
cd ~/bitcoin/deps
|
||||
tar xvjf ~/Downloads/boost_1_42_0.tar.bz2
|
||||
cd boost_1_42_0
|
||||
./bootstrap.sh
|
||||
./bjam architecture=combined address-model=32_64 macosx-version=10.6 macosx-version-min=10.5 link=static runtime-link=static --toolset=darwin --prefix=/Users/macosuser/bitcoin/deps install
|
||||
|
||||
This part takes a while.. use your judgement and fix it if something doesn't
|
||||
build for some reason.
|
||||
|
||||
Change the prefix to whatever your directory is (my username in this example
|
||||
is macosuser). I'm also running on 10.6 so i have macosx-version=10.6 change
|
||||
to 10.5 if you're using leopard.
|
||||
|
||||
This is what my output looked like at the end:
|
||||
...failed updating 2 targets...
|
||||
...skipped 144 targets...
|
||||
...updated 8074 targets...
|
||||
|
||||
|
||||
OpenSSL
|
||||
-------
|
||||
|
||||
Download from http://www.openssl.org/source/
|
||||
|
||||
We would like to build this as a 32 bit/64 bit library so we actually build it
|
||||
2 times and join it together here.. If you downloaded with safari it already
|
||||
uncompressed it so it will just be a tar not a tar.gz
|
||||
|
||||
cd ~/bitcoin/deps
|
||||
tar xvf ~/Downloads/openssl-1.0.0.tar
|
||||
mv openssl-1.0.0 openssl-1.0.0-i386
|
||||
tar xvf ~/Downloads/openssl-1.0.0.tar
|
||||
mv openssl-1.0.0 openssl-1.0.0-x86_64
|
||||
# build i386 (32 bit intel) binary
|
||||
cd openssl-1.0.0-i386
|
||||
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin-i386-cc && make
|
||||
make install # only do this on one of the architectures, to install the headers
|
||||
cd ..
|
||||
# build x86_64 (64 bit intel) binary
|
||||
cd openssl-1.0.0-x86_64
|
||||
./Configure --prefix=/Users/macosuser/bitcoin/deps --openssldir=/Users/macosuser/deps/openssl darwin64-x86_64-cc && make
|
||||
cd ..
|
||||
|
||||
# combine the libs
|
||||
cd ~/bitcoin/deps
|
||||
lipo -arch i386 openssl-1.0.0-i386/libcrypto.a -arch x86_64 openssl-1.0.0-x86_64/libcrypto.a -o lib/libcrypto.a -create
|
||||
lipo -arch i386 openssl-1.0.0-i386/libssl.a -arch x86_64 openssl-1.0.0-x86_64/libssl.a -o lib/libssl.a -create
|
||||
|
||||
Verify your binaries
|
||||
|
||||
file lib/libcrypto.a
|
||||
|
||||
output should look like this:
|
||||
|
||||
ib/libcrypto.a: Mach-O universal binary with 2 architectures
|
||||
lib/libcrypto.a (for architecture i386): current ar archive random library
|
||||
lib/libcrypto.a (for architecture x86_64): current ar archive random library
|
||||
|
||||
|
||||
Berkeley DB
|
||||
-----------
|
||||
|
||||
Download from http://freshmeat.net/projects/berkeleydb/
|
||||
|
||||
cd ~/bitcoin/deps
|
||||
tar xvf ~/Downloads/db-4.8.26.tar
|
||||
cd db-4.8.26/build_unix
|
||||
../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install
|
||||
|
||||
|
||||
wxWidgets
|
||||
---------
|
||||
|
||||
This is the big one..
|
||||
|
||||
Check it out from svn
|
||||
|
||||
cd ~/bitcoin/deps
|
||||
svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk
|
||||
|
||||
This will make a wxWidgets-trunk directory in deps.
|
||||
|
||||
Use this script snippet, change your prefix to whatever your dir is:
|
||||
|
||||
PREFIX=~/bitcoin/deps
|
||||
SRCDIR="$PREFIX/wxWidgets-trunk"
|
||||
BUILDDIR="$SRCDIR/macbuild"
|
||||
|
||||
cd "$PREFIX" &&
|
||||
#svn checkout http://svn.wxwidgets.org/svn/wx/wxWidgets/trunk wxWidgets-trunk &&
|
||||
cd "$SRCDIR" &&
|
||||
|
||||
[ -f include/wx/hashmap.h.orig ] || cp include/wx/hashmap.h include/wx/hashmap.h.orig &&
|
||||
sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashmap.h.orig > include/wx/hashmap.h &&
|
||||
|
||||
[ -f include/wx/hashset.h.orig ] || cp include/wx/hashset.h include/wx/hashset.h.orig &&
|
||||
sed 's/if wxUSE_STL/if 0 \&\& wxUSE_STL/g' < include/wx/hashset.h.orig > include/wx/hashset.h &&
|
||||
|
||||
|
||||
|
||||
rm -vrf "$BUILDDIR" &&
|
||||
mkdir "$BUILDDIR" &&
|
||||
cd "$BUILDDIR" &&
|
||||
|
||||
../configure --prefix="$PREFIX" \
|
||||
--with-osx_cocoa \
|
||||
--disable-shared \
|
||||
--disable-debug_flag \
|
||||
--with-macosx-version-min=10.5 \
|
||||
--enable-stl \
|
||||
--enable-utf8 \
|
||||
--enable-universal_binary \
|
||||
--with-libjpeg=builtin \
|
||||
--with-libpng=builtin \
|
||||
--with-regex=builtin \
|
||||
--with-libtiff=builtin \
|
||||
--with-zlib=builtin \
|
||||
--with-expat=builtin \
|
||||
--with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk &&
|
||||
|
||||
|
||||
find . -name Makefile |
|
||||
while read i; do
|
||||
echo $i;
|
||||
sed 's/-arch i386/-arch i386 -arch x86_64/g' < "$i" > "$i".new &&
|
||||
mv "$i" "$i".old &&
|
||||
mv "$i".new "$i";
|
||||
done
|
||||
|
||||
|
||||
|
||||
make &&
|
||||
make install
|
||||
|
||||
|
||||
|
||||
Now you should be able to build bitcoin
|
||||
|
||||
cd ~/bitcoin/trunk
|
||||
make -f makefile.osx bitcoin
|
||||
|
||||
Before you can run it, you need to create an application bundle for Mac OS.
|
||||
Create the directories in terminal using mkdir and copy the files into place.
|
||||
They are available at http://heliacal.net/~solar/bitcoin/mac-build/
|
||||
You need the Info.plist and the .ins file. The Contents/MacOS/bitcoin file is
|
||||
the output of the build.
|
||||
Your directory structure should look like this:
|
||||
|
||||
Bitcoin.app
|
||||
Bitcoin.app/Contents
|
||||
Bitcoin.app/Contents/Info.plist
|
||||
Bitcoin.app/Contents/MacOS
|
||||
Bitcoin.app/Contents/MacOS/bitcoin
|
||||
Bitcoin.app/Contents/Resources
|
||||
Bitcoin.app/Contents/Resources/BitcoinAppIcon.icns
|
||||
|
||||
To run it you can just click the Bitcoin.app in Finder, or just do open
|
||||
~/bitcoin/Bitcoin.app
|
||||
If you want to run it with arguments you can just run it without backgrounding
|
||||
by specifying the full name in terminal:
|
||||
~/bitcoin/Bitcoin.app/Contents/MacOS/bitcoin -addnode=192.75.207.66
|
||||
@@ -70,7 +70,7 @@ ldconfig
|
||||
Boost
|
||||
-----
|
||||
If you want to build Boost yourself,
|
||||
cd /usr/local/boost_1_42_0
|
||||
cd /usr/local/boost_1_38_0
|
||||
su
|
||||
./bootstrap.sh
|
||||
./bjam install
|
||||
|
||||
2
db.cpp
2
db.cpp
@@ -599,7 +599,6 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
|
||||
ssKey >> strKey;
|
||||
|
||||
// Menu state
|
||||
if (strKey == "fShowGenerated") ssValue >> fShowGenerated;
|
||||
if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;
|
||||
|
||||
// Options
|
||||
@@ -618,7 +617,6 @@ bool CWalletDB::LoadWallet(vector<unsigned char>& vchDefaultKeyRet)
|
||||
}
|
||||
|
||||
printf("nFileVersion = %d\n", nFileVersion);
|
||||
printf("fShowGenerated = %d\n", fShowGenerated);
|
||||
printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
|
||||
printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
|
||||
printf("addrIncoming = %s\n", addrIncoming.ToString().c_str());
|
||||
|
||||
2
db.h
2
db.h
@@ -328,6 +328,8 @@ public:
|
||||
|
||||
bool EraseName(const string& strAddress)
|
||||
{
|
||||
// This should only be used for sending addresses, never for receiving addresses,
|
||||
// receiving addresses must always have an address book entry if they're not change return.
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
mapAddressBook.erase(strAddress);
|
||||
nWalletDBUpdated++;
|
||||
|
||||
11
headers.h
11
headers.h
@@ -19,11 +19,13 @@
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#define __STDC_LIMIT_MACROS // to enable UINT64_MAX from stdint.h
|
||||
#include <wx/wx.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/snglinst.h>
|
||||
#include <wx/taskbar.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include <wx/snglinst.h>
|
||||
#if wxUSE_GUI
|
||||
#include <wx/utils.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/taskbar.h>
|
||||
#endif
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
@@ -100,8 +102,11 @@ using namespace boost;
|
||||
#include "irc.h"
|
||||
#include "main.h"
|
||||
#include "rpc.h"
|
||||
#if wxUSE_GUI
|
||||
#include "uibase.h"
|
||||
#endif
|
||||
#include "ui.h"
|
||||
#include "init.h"
|
||||
|
||||
#include "xpm/addressbook16.xpm"
|
||||
#include "xpm/addressbook20.xpm"
|
||||
|
||||
630
init.cpp
Normal file
630
init.cpp
Normal file
@@ -0,0 +1,630 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "headers.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void ExitTimeout(void* parg)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
Sleep(5000);
|
||||
ExitProcess(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Shutdown(void* parg)
|
||||
{
|
||||
static CCriticalSection cs_Shutdown;
|
||||
static bool fTaken;
|
||||
bool fFirstThread;
|
||||
CRITICAL_BLOCK(cs_Shutdown)
|
||||
{
|
||||
fFirstThread = !fTaken;
|
||||
fTaken = true;
|
||||
}
|
||||
static bool fExit;
|
||||
if (fFirstThread)
|
||||
{
|
||||
fShutdown = true;
|
||||
nTransactionsUpdated++;
|
||||
DBFlush(false);
|
||||
StopNode();
|
||||
DBFlush(true);
|
||||
CreateThread(ExitTimeout, NULL);
|
||||
Sleep(50);
|
||||
printf("Bitcoin exiting\n\n");
|
||||
fExit = true;
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!fExit)
|
||||
Sleep(500);
|
||||
Sleep(100);
|
||||
ExitThread(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Startup folder
|
||||
//
|
||||
|
||||
#ifdef __WXMSW__
|
||||
typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
|
||||
|
||||
string MyGetSpecialFolderPath(int nFolder, bool fCreate)
|
||||
{
|
||||
char pszPath[MAX_PATH+100] = "";
|
||||
|
||||
// SHGetSpecialFolderPath is not usually available on NT 4.0
|
||||
HMODULE hShell32 = LoadLibraryA("shell32.dll");
|
||||
if (hShell32)
|
||||
{
|
||||
PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =
|
||||
(PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");
|
||||
if (pSHGetSpecialFolderPath)
|
||||
(*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);
|
||||
FreeModule(hShell32);
|
||||
}
|
||||
|
||||
// Backup option
|
||||
if (pszPath[0] == '\0')
|
||||
{
|
||||
if (nFolder == CSIDL_STARTUP)
|
||||
{
|
||||
strcpy(pszPath, getenv("USERPROFILE"));
|
||||
strcat(pszPath, "\\Start Menu\\Programs\\Startup");
|
||||
}
|
||||
else if (nFolder == CSIDL_APPDATA)
|
||||
{
|
||||
strcpy(pszPath, getenv("APPDATA"));
|
||||
}
|
||||
}
|
||||
|
||||
return pszPath;
|
||||
}
|
||||
|
||||
string StartupShortcutPath()
|
||||
{
|
||||
return MyGetSpecialFolderPath(CSIDL_STARTUP, true) + "\\Bitcoin.lnk";
|
||||
}
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
{
|
||||
return wxFileExists(StartupShortcutPath());
|
||||
}
|
||||
|
||||
void SetStartOnSystemStartup(bool fAutoStart)
|
||||
{
|
||||
// If the shortcut exists already, remove it for updating
|
||||
remove(StartupShortcutPath().c_str());
|
||||
|
||||
if (fAutoStart)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
|
||||
// Get a pointer to the IShellLink interface.
|
||||
IShellLink* psl = NULL;
|
||||
HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL,
|
||||
CLSCTX_INPROC_SERVER, IID_IShellLink,
|
||||
reinterpret_cast<void**>(&psl));
|
||||
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
// Get the current executable path
|
||||
TCHAR pszExePath[MAX_PATH];
|
||||
GetModuleFileName(NULL, pszExePath, sizeof(pszExePath));
|
||||
|
||||
// Set the path to the shortcut target
|
||||
psl->SetPath(pszExePath);
|
||||
PathRemoveFileSpec(pszExePath);
|
||||
psl->SetWorkingDirectory(pszExePath);
|
||||
psl->SetShowCmd(SW_SHOWMINNOACTIVE);
|
||||
|
||||
// Query IShellLink for the IPersistFile interface for
|
||||
// saving the shortcut in persistent storage.
|
||||
IPersistFile* ppf = NULL;
|
||||
hres = psl->QueryInterface(IID_IPersistFile,
|
||||
reinterpret_cast<void**>(&ppf));
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
WCHAR pwsz[MAX_PATH];
|
||||
// Ensure that the string is ANSI.
|
||||
MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().c_str(), -1, pwsz, MAX_PATH);
|
||||
// Save the link by calling IPersistFile::Save.
|
||||
hres = ppf->Save(pwsz, TRUE);
|
||||
ppf->Release();
|
||||
}
|
||||
psl->Release();
|
||||
}
|
||||
CoUninitialize();
|
||||
}
|
||||
}
|
||||
#else
|
||||
bool GetStartOnSystemStartup() { return false; }
|
||||
void SetStartOnSystemStartup(bool fAutoStart) { }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CMyApp
|
||||
//
|
||||
|
||||
// Define a new application
|
||||
class CMyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
wxLocale m_locale;
|
||||
|
||||
CMyApp(){};
|
||||
~CMyApp(){};
|
||||
bool OnInit();
|
||||
bool OnInit2();
|
||||
int OnExit();
|
||||
|
||||
// Hook Initialize so we can start without GUI
|
||||
virtual bool Initialize(int& argc, wxChar** argv);
|
||||
|
||||
// 2nd-level exception handling: we get all the exceptions occurring in any
|
||||
// event handler here
|
||||
virtual bool OnExceptionInMainLoop();
|
||||
|
||||
// 3rd, and final, level exception handling: whenever an unhandled
|
||||
// exception is caught, this function is called
|
||||
virtual void OnUnhandledException();
|
||||
|
||||
// and now for something different: this function is called in case of a
|
||||
// crash (e.g. dereferencing null pointer, division by 0, ...)
|
||||
virtual void OnFatalException();
|
||||
};
|
||||
|
||||
IMPLEMENT_APP(CMyApp)
|
||||
|
||||
bool CMyApp::Initialize(int& argc, wxChar** argv)
|
||||
{
|
||||
if (argc > 1 && argv[1][0] != '-' && (!fWindows || argv[1][0] != '/') &&
|
||||
wxString(argv[1]) != "start")
|
||||
{
|
||||
fCommandLine = true;
|
||||
}
|
||||
else if (!fGUI)
|
||||
{
|
||||
fDaemon = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// wxApp::Initialize will remove environment-specific parameters,
|
||||
// so it's too early to call ParseParameters yet
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
wxString str = argv[i];
|
||||
#ifdef __WXMSW__
|
||||
if (str.size() >= 1 && str[0] == '/')
|
||||
str[0] = '-';
|
||||
str = str.MakeLower();
|
||||
#endif
|
||||
// haven't decided which argument to use for this yet
|
||||
if (str == "-daemon" || str == "-d" || str == "start")
|
||||
fDaemon = true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WXGTK__
|
||||
if (fDaemon || fCommandLine)
|
||||
{
|
||||
// Call the original Initialize while suppressing error messages
|
||||
// and ignoring failure. If unable to initialize GTK, it fails
|
||||
// near the end so hopefully the last few things don't matter.
|
||||
{
|
||||
wxLogNull logNo;
|
||||
wxApp::Initialize(argc, argv);
|
||||
}
|
||||
|
||||
if (fDaemon)
|
||||
{
|
||||
// Daemonize
|
||||
pid_t pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno);
|
||||
return false;
|
||||
}
|
||||
if (pid > 0)
|
||||
pthread_exit((void*)0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return wxApp::Initialize(argc, argv);
|
||||
}
|
||||
|
||||
bool CMyApp::OnInit()
|
||||
{
|
||||
bool fRet = false;
|
||||
try
|
||||
{
|
||||
fRet = OnInit2();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
PrintException(&e, "OnInit()");
|
||||
} catch (...) {
|
||||
PrintException(NULL, "OnInit()");
|
||||
}
|
||||
if (!fRet)
|
||||
Shutdown(NULL);
|
||||
return fRet;
|
||||
}
|
||||
|
||||
extern int g_isPainting;
|
||||
|
||||
bool CMyApp::OnInit2()
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
// Turn off microsoft heap dump noise
|
||||
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
|
||||
#endif
|
||||
#if _MSC_VER >= 1400
|
||||
// Disable confusing "helpful" text message on abort, ctrl-c
|
||||
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
#endif
|
||||
#if defined(__WXMSW__) && defined(__WXDEBUG__) && wxUSE_GUI
|
||||
// Disable malfunctioning wxWidgets debug assertion
|
||||
g_isPainting = 10000;
|
||||
#endif
|
||||
#if wxUSE_GUI
|
||||
wxImage::AddHandler(new wxPNGHandler);
|
||||
#endif
|
||||
#if defined(__WXMSW__ ) || defined(__WXMAC__)
|
||||
SetAppName("Bitcoin");
|
||||
#else
|
||||
SetAppName("bitcoin");
|
||||
#endif
|
||||
#ifndef __WXMSW__
|
||||
umask(077);
|
||||
#endif
|
||||
#ifdef __WXMSW__
|
||||
#if wxUSE_UNICODE
|
||||
// Hack to set wxConvLibc codepage to UTF-8 on Windows,
|
||||
// may break if wxMBConv_win32 implementation in strconv.cpp changes.
|
||||
class wxMBConv_win32 : public wxMBConv
|
||||
{
|
||||
public:
|
||||
long m_CodePage;
|
||||
size_t m_minMBCharWidth;
|
||||
};
|
||||
if (((wxMBConv_win32*)&wxConvLibc)->m_CodePage == CP_ACP)
|
||||
((wxMBConv_win32*)&wxConvLibc)->m_CodePage = CP_UTF8;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Load locale/<lang>/LC_MESSAGES/bitcoin.mo language file
|
||||
m_locale.Init(wxLANGUAGE_DEFAULT, 0);
|
||||
m_locale.AddCatalogLookupPathPrefix("locale");
|
||||
if (!fWindows)
|
||||
{
|
||||
m_locale.AddCatalogLookupPathPrefix("/usr/share/locale");
|
||||
m_locale.AddCatalogLookupPathPrefix("/usr/local/share/locale");
|
||||
}
|
||||
m_locale.AddCatalog("wxstd"); // wxWidgets standard translations, if any
|
||||
m_locale.AddCatalog("bitcoin");
|
||||
|
||||
//
|
||||
// Parameters
|
||||
//
|
||||
if (fCommandLine)
|
||||
{
|
||||
int ret = CommandLineRPC(argc, argv);
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
ParseParameters(argc, argv);
|
||||
if (mapArgs.count("-?") || mapArgs.count("--help"))
|
||||
{
|
||||
wxString strUsage = string() +
|
||||
_("Usage: bitcoin [options]") + "\t\t\t\t\t\t\n" +
|
||||
_("Options:\n") +
|
||||
" -gen \t\t " + _("Generate coins\n") +
|
||||
" -gen=0 \t\t " + _("Don't generate coins\n") +
|
||||
" -min \t\t " + _("Start minimized\n") +
|
||||
" -datadir=<dir> \t " + _("Specify data directory\n") +
|
||||
" -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +
|
||||
" -addnode=<ip> \t " + _("Add a node to connect to\n") +
|
||||
" -connect=<ip> \t " + _("Connect only to the specified node\n") +
|
||||
" -? \t\t " + _("This help message\n");
|
||||
|
||||
if (fWindows && fGUI)
|
||||
{
|
||||
// Remove spaces, the tabs make the columns line up in the message box
|
||||
for (int i = 0; i < 50; i++)
|
||||
strUsage.Replace(" \t", "\t");
|
||||
wxMessageBox(strUsage, "Bitcoin", wxOK);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove tabs
|
||||
strUsage.Replace("\t", "");
|
||||
fprintf(stderr, "%s", ((string)strUsage).c_str());
|
||||
}
|
||||
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;
|
||||
|
||||
if (!fDebug && !pszSetDataDir[0])
|
||||
ShrinkDebugFile();
|
||||
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
printf("Bitcoin version 0.%d.%d%s beta, OS version %s\n", VERSION/100, VERSION%100, pszSubVer, ((string)wxGetOsDescription()).c_str());
|
||||
printf("System default language is %d %s\n", m_locale.GetSystemLanguage(), ((string)m_locale.GetSysName()).c_str());
|
||||
printf("Language file %s (%s)\n", (string("locale/") + (string)m_locale.GetCanonicalName() + "/LC_MESSAGES/bitcoin.mo").c_str(), ((string)m_locale.GetLocale()).c_str());
|
||||
|
||||
if (mapArgs.count("-loadblockindextest"))
|
||||
{
|
||||
CTxDB txdb("r");
|
||||
txdb.LoadBlockIndex();
|
||||
PrintBlockTree();
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Limit to single instance per user
|
||||
// Required to protect the database files if we're going to keep deleting log.*
|
||||
//
|
||||
#ifdef __WXMSW__
|
||||
// todo: wxSingleInstanceChecker wasn't working on Linux, never deleted its lock file
|
||||
// maybe should go by whether successfully bind port 8333 instead
|
||||
wxString strMutexName = wxString("bitcoin_running.") + getenv("HOMEPATH");
|
||||
for (int i = 0; i < strMutexName.size(); i++)
|
||||
if (!isalnum(strMutexName[i]))
|
||||
strMutexName[i] = '.';
|
||||
wxSingleInstanceChecker* psingleinstancechecker = new wxSingleInstanceChecker(strMutexName);
|
||||
if (psingleinstancechecker->IsAnotherRunning())
|
||||
{
|
||||
printf("Existing instance found\n");
|
||||
unsigned int nStart = GetTime();
|
||||
loop
|
||||
{
|
||||
// TODO: find out how to do this in Linux, or replace with wxWidgets commands
|
||||
// Show the previous instance and exit
|
||||
HWND hwndPrev = FindWindowA("wxWindowClassNR", "Bitcoin");
|
||||
if (hwndPrev)
|
||||
{
|
||||
if (IsIconic(hwndPrev))
|
||||
ShowWindow(hwndPrev, SW_RESTORE);
|
||||
SetForegroundWindow(hwndPrev);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetTime() > nStart + 60)
|
||||
return false;
|
||||
|
||||
// Resume this instance if the other exits
|
||||
delete psingleinstancechecker;
|
||||
Sleep(1000);
|
||||
psingleinstancechecker = new wxSingleInstanceChecker(strMutexName);
|
||||
if (!psingleinstancechecker->IsAnotherRunning())
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// 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))
|
||||
{
|
||||
wxMessageBox(strErrors, "Bitcoin");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Load data files
|
||||
//
|
||||
if (fDaemon)
|
||||
fprintf(stdout, "bitcoin server starting\n");
|
||||
strErrors = "";
|
||||
int64 nStart;
|
||||
|
||||
printf("Loading addresses...\n");
|
||||
nStart = GetTimeMillis();
|
||||
if (!LoadAddresses())
|
||||
strErrors += _("Error loading addr.dat \n");
|
||||
printf(" addresses %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
printf("Loading block index...\n");
|
||||
nStart = GetTimeMillis();
|
||||
if (!LoadBlockIndex())
|
||||
strErrors += _("Error loading blkindex.dat \n");
|
||||
printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
printf("Loading wallet...\n");
|
||||
nStart = GetTimeMillis();
|
||||
bool fFirstRun;
|
||||
if (!LoadWallet(fFirstRun))
|
||||
strErrors += _("Error loading wallet.dat \n");
|
||||
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
printf("Done loading\n");
|
||||
|
||||
//// debug print
|
||||
printf("mapBlockIndex.size() = %d\n", mapBlockIndex.size());
|
||||
printf("nBestHeight = %d\n", nBestHeight);
|
||||
printf("mapKeys.size() = %d\n", mapKeys.size());
|
||||
printf("mapPubKeys.size() = %d\n", mapPubKeys.size());
|
||||
printf("mapWallet.size() = %d\n", mapWallet.size());
|
||||
printf("mapAddressBook.size() = %d\n", mapAddressBook.size());
|
||||
|
||||
if (!strErrors.empty())
|
||||
{
|
||||
wxMessageBox(strErrors, "Bitcoin");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add wallet transactions that aren't already in a block to mapTransactions
|
||||
ReacceptWalletTransactions();
|
||||
|
||||
//
|
||||
// Parameters
|
||||
//
|
||||
if (mapArgs.count("-printblockindex") || mapArgs.count("-printblocktree"))
|
||||
{
|
||||
PrintBlockTree();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mapArgs.count("-printblock"))
|
||||
{
|
||||
string strMatch = mapArgs["-printblock"];
|
||||
int nFound = 0;
|
||||
for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
|
||||
{
|
||||
uint256 hash = (*mi).first;
|
||||
if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)
|
||||
{
|
||||
CBlockIndex* pindex = (*mi).second;
|
||||
CBlock block;
|
||||
block.ReadFromDisk(pindex);
|
||||
block.BuildMerkleTree();
|
||||
block.print();
|
||||
printf("\n");
|
||||
nFound++;
|
||||
}
|
||||
}
|
||||
if (nFound == 0)
|
||||
printf("No blocks matching %s were found\n", strMatch.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mapArgs.count("-gen"))
|
||||
{
|
||||
if (mapArgs["-gen"].empty())
|
||||
fGenerateBitcoins = true;
|
||||
else
|
||||
fGenerateBitcoins = (atoi(mapArgs["-gen"].c_str()) != 0);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-proxy"))
|
||||
{
|
||||
fUseProxy = true;
|
||||
addrProxy = CAddress(mapArgs["-proxy"]);
|
||||
if (!addrProxy.IsValid())
|
||||
{
|
||||
wxMessageBox(_("Invalid -proxy address"), "Bitcoin");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mapArgs.count("-addnode"))
|
||||
{
|
||||
foreach(string strAddr, mapMultiArgs["-addnode"])
|
||||
{
|
||||
CAddress addr(strAddr, NODE_NETWORK);
|
||||
addr.nTime = 0; // so it won't relay unless successfully connected
|
||||
if (addr.IsValid())
|
||||
AddAddress(addr);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Create the main window and start the node
|
||||
//
|
||||
if (!fDaemon)
|
||||
CreateMainWindow();
|
||||
|
||||
if (!CheckDiskSpace())
|
||||
return false;
|
||||
|
||||
RandAddSeedPerfmon();
|
||||
|
||||
if (!CreateThread(StartNode, NULL))
|
||||
wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin");
|
||||
|
||||
if (mapArgs.count("-server") || fDaemon)
|
||||
CreateThread(ThreadRPCServer, NULL);
|
||||
|
||||
if (fFirstRun)
|
||||
SetStartOnSystemStartup(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CMyApp::OnExit()
|
||||
{
|
||||
Shutdown(NULL);
|
||||
return wxApp::OnExit();
|
||||
}
|
||||
|
||||
bool CMyApp::OnExceptionInMainLoop()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
PrintException(&e, "CMyApp::OnExceptionInMainLoop()");
|
||||
wxLogWarning("Exception %s %s", typeid(e).name(), e.what());
|
||||
Sleep(1000);
|
||||
throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
PrintException(NULL, "CMyApp::OnExceptionInMainLoop()");
|
||||
wxLogWarning("Unknown exception");
|
||||
Sleep(1000);
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMyApp::OnUnhandledException()
|
||||
{
|
||||
// this shows how we may let some exception propagate uncaught
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
PrintException(&e, "CMyApp::OnUnhandledException()");
|
||||
wxLogWarning("Exception %s %s", typeid(e).name(), e.what());
|
||||
Sleep(1000);
|
||||
throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
PrintException(NULL, "CMyApp::OnUnhandledException()");
|
||||
wxLogWarning("Unknown exception");
|
||||
Sleep(1000);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void CMyApp::OnFatalException()
|
||||
{
|
||||
wxMessageBox(_("Program has crashed and will terminate. "), "Bitcoin", wxOK | wxICON_ERROR);
|
||||
}
|
||||
7
init.h
Normal file
7
init.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
void Shutdown(void* parg);
|
||||
bool GetStartOnSystemStartup();
|
||||
void SetStartOnSystemStartup(bool fAutoStart);
|
||||
5
irc.cpp
5
irc.cpp
@@ -76,6 +76,8 @@ bool RecvLine(SOCKET hSocket, string& strLine)
|
||||
if (c == '\r')
|
||||
return true;
|
||||
strLine += c;
|
||||
if (strLine.size() >= 9000)
|
||||
return true;
|
||||
}
|
||||
else if (nBytes <= 0)
|
||||
{
|
||||
@@ -109,7 +111,7 @@ bool RecvLineIRC(SOCKET hSocket, string& strLine)
|
||||
return false;
|
||||
vector<string> vWords;
|
||||
ParseString(strLine, ' ', vWords);
|
||||
if (vWords[0] == "PING")
|
||||
if (vWords.size() >= 1 && vWords[0] == "PING")
|
||||
{
|
||||
strLine[1] = 'O';
|
||||
strLine += '\r';
|
||||
@@ -156,6 +158,7 @@ bool Wait(int nSeconds)
|
||||
|
||||
void ThreadIRCSeed(void* parg)
|
||||
{
|
||||
printf("ThreadIRCSeed started\n");
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
int nErrorWait = 10;
|
||||
int nRetryWait = 10;
|
||||
|
||||
209
main.cpp
209
main.cpp
@@ -55,6 +55,8 @@ int64 nTransactionFee = 0;
|
||||
CAddress addrIncoming;
|
||||
int fLimitProcessors = false;
|
||||
int nLimitProcessors = 1;
|
||||
int fMinimizeToTray = true;
|
||||
int fMinimizeOnClose = true;
|
||||
|
||||
|
||||
|
||||
@@ -1315,11 +1317,10 @@ bool CBlock::AcceptBlock()
|
||||
if (nTime <= pindexPrev->GetMedianTimePast())
|
||||
return error("AcceptBlock() : block's timestamp is too early");
|
||||
|
||||
// Check that all transactions are finalized (starting around Mar 2010)
|
||||
if (nBestHeight > 36000)
|
||||
foreach(const CTransaction& tx, vtx)
|
||||
if (!tx.IsFinal(nTime))
|
||||
return error("AcceptBlock() : contains a non-final transaction");
|
||||
// Check that all transactions are finalized
|
||||
foreach(const CTransaction& tx, vtx)
|
||||
if (!tx.IsFinal(nTime))
|
||||
return error("AcceptBlock() : contains a non-final transaction");
|
||||
|
||||
// Check proof of work
|
||||
if (nBits != GetNextWorkRequired(pindexPrev))
|
||||
@@ -1335,17 +1336,12 @@ bool CBlock::AcceptBlock()
|
||||
if (!AddToBlockIndex(nFile, nBlockPos))
|
||||
return error("AcceptBlock() : AddToBlockIndex failed");
|
||||
|
||||
if (hashBestChain == hash && nBestHeight > 28000)
|
||||
RelayInventory(CInv(MSG_BLOCK, hash));
|
||||
|
||||
// // Add atoms to user reviews for coins created
|
||||
// vector<unsigned char> vchPubKey;
|
||||
// if (ExtractPubKey(vtx[0].vout[0].scriptPubKey, false, vchPubKey))
|
||||
// {
|
||||
// unsigned short nAtom = GetRand(USHRT_MAX - 100) + 100;
|
||||
// vector<unsigned short> vAtoms(1, nAtom);
|
||||
// AddAtomsAndPropagate(Hash(vchPubKey.begin(), vchPubKey.end()), vAtoms, true);
|
||||
// }
|
||||
// Relay inventory, but don't relay old inventory during initial block download
|
||||
if (hashBestChain == hash)
|
||||
CRITICAL_BLOCK(cs_vNodes)
|
||||
foreach(CNode* pnode, vNodes)
|
||||
if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 55000))
|
||||
pnode->PushInventory(CInv(MSG_BLOCK, hash));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1554,8 +1550,8 @@ bool LoadBlockIndex(bool fAllowNew)
|
||||
CTransaction txNew;
|
||||
txNew.vin.resize(1);
|
||||
txNew.vout.resize(1);
|
||||
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
|
||||
txNew.vout[0].nValue = 50 * COIN;
|
||||
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
|
||||
txNew.vout[0].nValue = 50 * COIN;
|
||||
CBigNum bnPubKey;
|
||||
bnPubKey.SetHex("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704");
|
||||
txNew.vout[0].scriptPubKey = CScript() << bnPubKey << OP_CHECKSIG;
|
||||
@@ -1718,6 +1714,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
// (4) message start
|
||||
// (12) command
|
||||
// (4) size
|
||||
// (4) checksum
|
||||
// (x) data
|
||||
//
|
||||
|
||||
@@ -1725,12 +1722,13 @@ bool ProcessMessages(CNode* pfrom)
|
||||
{
|
||||
// Scan for message start
|
||||
CDataStream::iterator pstart = search(vRecv.begin(), vRecv.end(), BEGIN(pchMessageStart), END(pchMessageStart));
|
||||
if (vRecv.end() - pstart < sizeof(CMessageHeader))
|
||||
int nHeaderSize = vRecv.GetSerializeSize(CMessageHeader());
|
||||
if (vRecv.end() - pstart < nHeaderSize)
|
||||
{
|
||||
if (vRecv.size() > sizeof(CMessageHeader))
|
||||
if (vRecv.size() > nHeaderSize)
|
||||
{
|
||||
printf("\n\nPROCESSMESSAGE MESSAGESTART NOT FOUND\n\n");
|
||||
vRecv.erase(vRecv.begin(), vRecv.end() - sizeof(CMessageHeader));
|
||||
vRecv.erase(vRecv.begin(), vRecv.end() - nHeaderSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1739,6 +1737,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||
vRecv.erase(vRecv.begin(), pstart);
|
||||
|
||||
// Read header
|
||||
vector<char> vHeaderSave(vRecv.begin(), vRecv.begin() + nHeaderSize);
|
||||
CMessageHeader hdr;
|
||||
vRecv >> hdr;
|
||||
if (!hdr.IsValid())
|
||||
@@ -1754,10 +1753,9 @@ bool ProcessMessages(CNode* pfrom)
|
||||
{
|
||||
// Rewind and wait for rest of message
|
||||
///// need a mechanism to give up waiting for overlong message size error
|
||||
//if (fDebug)
|
||||
// printf("message-break\n");
|
||||
vRecv.insert(vRecv.begin(), BEGIN(hdr), END(hdr));
|
||||
Sleep(100);
|
||||
if (fDebug)
|
||||
printf("message-break\n");
|
||||
vRecv.insert(vRecv.begin(), vHeaderSave.begin(), vHeaderSave.end());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1765,6 +1763,20 @@ bool ProcessMessages(CNode* pfrom)
|
||||
CDataStream vMsg(vRecv.begin(), vRecv.begin() + nMessageSize, vRecv.nType, vRecv.nVersion);
|
||||
vRecv.ignore(nMessageSize);
|
||||
|
||||
// Checksum
|
||||
if (vRecv.GetVersion() >= 209)
|
||||
{
|
||||
uint256 hash = Hash(vMsg.begin(), vMsg.end());
|
||||
unsigned int nChecksum = 0;
|
||||
memcpy(&nChecksum, &hash, sizeof(nChecksum));
|
||||
if (nChecksum != hdr.nChecksum)
|
||||
{
|
||||
printf("ProcessMessage(%s, %d bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
|
||||
strCommand.c_str(), nMessageSize, nChecksum, hdr.nChecksum);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Process message
|
||||
bool fRet = false;
|
||||
try
|
||||
@@ -1841,6 +1853,9 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
vRecv >> addrFrom >> nNonce;
|
||||
if (pfrom->nVersion >= 106 && !vRecv.empty())
|
||||
vRecv >> strSubVer;
|
||||
if (pfrom->nVersion >= 209 && !vRecv.empty())
|
||||
vRecv >> pfrom->nStartingHeight;
|
||||
|
||||
if (pfrom->nVersion == 0)
|
||||
return false;
|
||||
|
||||
@@ -1851,9 +1866,6 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
return true;
|
||||
}
|
||||
|
||||
pfrom->vSend.SetVersion(min(pfrom->nVersion, VERSION));
|
||||
pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
|
||||
|
||||
pfrom->fClient = !(pfrom->nServices & NODE_NETWORK);
|
||||
if (pfrom->fClient)
|
||||
{
|
||||
@@ -1863,6 +1875,13 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
|
||||
AddTimeData(pfrom->addr.ip, nTime);
|
||||
|
||||
// Change version
|
||||
if (pfrom->nVersion >= 209)
|
||||
pfrom->PushMessage("verack");
|
||||
pfrom->vSend.SetVersion(min(pfrom->nVersion, VERSION));
|
||||
if (pfrom->nVersion < 209)
|
||||
pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
|
||||
|
||||
// Ask the first connected node for block updates
|
||||
static bool fAskedForBlocks;
|
||||
if (!fAskedForBlocks && !pfrom->fClient)
|
||||
@@ -1873,7 +1892,7 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
|
||||
pfrom->fSuccessfullyConnected = true;
|
||||
|
||||
printf("version message: version %d\n", pfrom->nVersion);
|
||||
printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
|
||||
}
|
||||
|
||||
|
||||
@@ -1884,6 +1903,12 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "verack")
|
||||
{
|
||||
pfrom->vRecv.SetVersion(min(pfrom->nVersion, VERSION));
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "addr")
|
||||
{
|
||||
vector<CAddress> vAddr;
|
||||
@@ -2098,9 +2123,8 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
vRecv >> *pblock;
|
||||
|
||||
//// debug print
|
||||
// printf("received block:\n");
|
||||
// pblock->print();
|
||||
printf("received block %s\n", pblock->GetHash().ToString().substr(0,16).c_str());
|
||||
// pblock->print();
|
||||
|
||||
CInv inv(MSG_BLOCK, pblock->GetHash());
|
||||
pfrom->AddInventoryKnown(inv);
|
||||
@@ -2252,9 +2276,9 @@ bool SendMessages(CNode* pto)
|
||||
// Delay tx inv messages to protect privacy,
|
||||
// trickle them out to a few nodes at a time.
|
||||
bool fSendTxInv = false;
|
||||
if (GetTimeMillis() - pto->nLastSentTxInv > 1800 + GetRand(200))
|
||||
if (GetTimeMillis() > pto->nNextSendTxInv)
|
||||
{
|
||||
pto->nLastSentTxInv = GetTimeMillis();
|
||||
pto->nNextSendTxInv = GetTimeMillis() + 3000 + GetRand(2000);
|
||||
fSendTxInv = true;
|
||||
}
|
||||
|
||||
@@ -2385,8 +2409,11 @@ void GenerateBitcoins(bool fGenerate)
|
||||
int nAddThreads = nProcessors - vnThreadsRunning[3];
|
||||
printf("Starting %d BitcoinMiner threads\n", nAddThreads);
|
||||
for (int i = 0; i < nAddThreads; i++)
|
||||
{
|
||||
if (!CreateThread(ThreadBitcoinMiner, NULL))
|
||||
printf("Error: CreateThread(ThreadBitcoinMiner) failed\n");
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2645,7 +2672,12 @@ void BitcoinMiner()
|
||||
do
|
||||
{
|
||||
pindexTmp = pindexBest;
|
||||
Sleep(10000);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Sleep(1000);
|
||||
if (fShutdown)
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (pindexTmp != pindexBest);
|
||||
}
|
||||
@@ -2852,10 +2884,13 @@ bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CK
|
||||
if (keyRet.IsNull())
|
||||
keyRet.MakeNewKey();
|
||||
|
||||
// Fill a vout to ourself
|
||||
CScript scriptPubKey;
|
||||
scriptPubKey << keyRet.GetPubKey() << OP_CHECKSIG;
|
||||
wtxNew.vout.push_back(CTxOut(nValueIn - nTotalValue, scriptPubKey));
|
||||
// Fill a vout to ourself, using same address type as the payment
|
||||
CScript scriptChange;
|
||||
if (scriptPubKey.GetBitcoinAddressHash160() != 0)
|
||||
scriptChange.SetBitcoinAddress(keyRet.GetPubKey());
|
||||
else
|
||||
scriptChange << keyRet.GetPubKey() << OP_CHECKSIG;
|
||||
wtxNew.vout.push_back(CTxOut(nValueIn - nTotalValue, scriptChange));
|
||||
}
|
||||
|
||||
// Fill a vout to the payee
|
||||
@@ -2894,42 +2929,50 @@ bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CK
|
||||
}
|
||||
|
||||
// Call after CreateTransaction unless you want to abort
|
||||
bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key)
|
||||
bool CommitTransaction(CWalletTx& wtxNew, const CKey& key)
|
||||
{
|
||||
CRITICAL_BLOCK(cs_main)
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
//// old: eventually should make this transactional, never want to add a
|
||||
//// transaction without marking spent transactions, although the risk of
|
||||
//// interruption during this step is remote.
|
||||
//// update: This matters even less now that fSpent can get corrected
|
||||
//// when transactions are seen in VerifySignature. The remote chance of
|
||||
//// unmarked fSpent will be handled by that. Don't need to make this
|
||||
//// transactional. Pls delete this comment block later.
|
||||
|
||||
// This is only to keep the database open to defeat the auto-flush for the
|
||||
// duration of this scope. This is the only place where this optimization
|
||||
// maybe makes sense; please don't do it anywhere else.
|
||||
CWalletDB walletdb("r");
|
||||
|
||||
// Add the change's private key to wallet
|
||||
if (!key.IsNull() && !AddKey(key))
|
||||
throw runtime_error("CommitTransactionSpent() : AddKey failed\n");
|
||||
|
||||
// Add tx to wallet, because if it has change it's also ours,
|
||||
// otherwise just for transaction history.
|
||||
AddToWallet(wtxNew);
|
||||
|
||||
// Mark old coins as spent
|
||||
set<CWalletTx*> setCoins;
|
||||
foreach(const CTxIn& txin, wtxNew.vin)
|
||||
setCoins.insert(&mapWallet[txin.prevout.hash]);
|
||||
foreach(CWalletTx* pcoin, setCoins)
|
||||
printf("CommitTransaction:\n%s", wtxNew.ToString().c_str());
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
pcoin->fSpent = true;
|
||||
pcoin->WriteToDisk();
|
||||
vWalletUpdated.push_back(pcoin->GetHash());
|
||||
// This is only to keep the database open to defeat the auto-flush for the
|
||||
// duration of this scope. This is the only place where this optimization
|
||||
// maybe makes sense; please don't do it anywhere else.
|
||||
CWalletDB walletdb("r");
|
||||
|
||||
// Add the change's private key to wallet
|
||||
if (!key.IsNull() && !AddKey(key))
|
||||
throw runtime_error("CommitTransaction() : AddKey failed\n");
|
||||
|
||||
// Add tx to wallet, because if it has change it's also ours,
|
||||
// otherwise just for transaction history.
|
||||
AddToWallet(wtxNew);
|
||||
|
||||
// Mark old coins as spent
|
||||
set<CWalletTx*> setCoins;
|
||||
foreach(const CTxIn& txin, wtxNew.vin)
|
||||
setCoins.insert(&mapWallet[txin.prevout.hash]);
|
||||
foreach(CWalletTx* pcoin, setCoins)
|
||||
{
|
||||
pcoin->fSpent = true;
|
||||
pcoin->WriteToDisk();
|
||||
vWalletUpdated.push_back(pcoin->GetHash());
|
||||
}
|
||||
}
|
||||
|
||||
// Track how many getdata requests our transaction gets
|
||||
CRITICAL_BLOCK(cs_mapRequestCount)
|
||||
mapRequestCount[wtxNew.GetHash()] = 0;
|
||||
|
||||
// Broadcast
|
||||
if (!wtxNew.AcceptTransaction())
|
||||
{
|
||||
// This must not fail. The transaction has already been signed and recorded.
|
||||
printf("CommitTransaction() : Error: Transaction not valid");
|
||||
return false;
|
||||
}
|
||||
wtxNew.RelayWalletTransaction();
|
||||
}
|
||||
MainFrameRepaint();
|
||||
return true;
|
||||
@@ -2938,7 +2981,7 @@ bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key)
|
||||
|
||||
|
||||
|
||||
string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew)
|
||||
string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
|
||||
{
|
||||
CRITICAL_BLOCK(cs_main)
|
||||
{
|
||||
@@ -2954,26 +2997,12 @@ string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew)
|
||||
printf("SendMoney() : %s", strError.c_str());
|
||||
return strError;
|
||||
}
|
||||
if (!CommitTransactionSpent(wtxNew, key))
|
||||
{
|
||||
printf("SendMoney() : Error finalizing transaction");
|
||||
return _("Error finalizing transaction");
|
||||
}
|
||||
|
||||
// Track how many getdata requests our transaction gets
|
||||
CRITICAL_BLOCK(cs_mapRequestCount)
|
||||
mapRequestCount[wtxNew.GetHash()] = 0;
|
||||
if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending..."), NULL))
|
||||
return "ABORTED";
|
||||
|
||||
printf("SendMoney: %s\n", wtxNew.GetHash().ToString().substr(0,6).c_str());
|
||||
|
||||
// Broadcast
|
||||
if (!wtxNew.AcceptTransaction())
|
||||
{
|
||||
// This must not fail. The transaction has already been signed and recorded.
|
||||
printf("SendMoney() : Error: Transaction not valid");
|
||||
if (!CommitTransaction(wtxNew, key))
|
||||
return _("Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
|
||||
}
|
||||
wtxNew.RelayWalletTransaction();
|
||||
}
|
||||
MainFrameRepaint();
|
||||
return "";
|
||||
@@ -2981,18 +3010,18 @@ string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew)
|
||||
|
||||
|
||||
|
||||
string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew)
|
||||
string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
|
||||
{
|
||||
// Check amount
|
||||
if (nValue <= 0)
|
||||
return _("Invalid amount");
|
||||
if (nValue + nTransactionFee > GetBalance())
|
||||
return _("You don't have enough money");
|
||||
return _("Insufficient funds");
|
||||
|
||||
// Parse bitcoin address
|
||||
CScript scriptPubKey;
|
||||
if (!scriptPubKey.SetBitcoinAddress(strAddress))
|
||||
return _("Invalid bitcoin address");
|
||||
|
||||
return SendMoney(scriptPubKey, nValue, wtxNew);
|
||||
return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee);
|
||||
}
|
||||
|
||||
13
main.h
13
main.h
@@ -45,6 +45,8 @@ extern int64 nTransactionFee;
|
||||
extern CAddress addrIncoming;
|
||||
extern int fLimitProcessors;
|
||||
extern int nLimitProcessors;
|
||||
extern int fMinimizeToTray;
|
||||
extern int fMinimizeOnClose;
|
||||
|
||||
|
||||
|
||||
@@ -67,9 +69,10 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv);
|
||||
bool SendMessages(CNode* pto);
|
||||
int64 GetBalance();
|
||||
bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CKey& keyRet, int64& nFeeRequiredRet);
|
||||
bool CommitTransactionSpent(const CWalletTx& wtxNew, const CKey& key);
|
||||
string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew);
|
||||
string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew);
|
||||
bool CommitTransaction(CWalletTx& wtxNew, const CKey& key);
|
||||
bool BroadcastTransaction(CWalletTx& wtxNew);
|
||||
string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
|
||||
string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false);
|
||||
void GenerateBitcoins(bool fGenerate);
|
||||
void ThreadBitcoinMiner(void* parg);
|
||||
void BitcoinMiner();
|
||||
@@ -1383,6 +1386,9 @@ public:
|
||||
CPrivKey vchPrivKey;
|
||||
int64 nTimeCreated;
|
||||
int64 nTimeExpires;
|
||||
string strComment;
|
||||
//// todo: add something to note what created it (user, getnewaddress, change)
|
||||
//// maybe should have a map<string, string> property map
|
||||
|
||||
CWalletKey(int64 nTimeExpiresIn=0)
|
||||
{
|
||||
@@ -1397,6 +1403,7 @@ public:
|
||||
READWRITE(vchPrivKey);
|
||||
READWRITE(nTimeCreated);
|
||||
READWRITE(nTimeExpires);
|
||||
READWRITE(strComment);
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -18,69 +18,59 @@ LIBPATHS= \
|
||||
-L"/openssl/out" \
|
||||
-L"/wxwidgets/lib/gcc_lib"
|
||||
|
||||
WXLIBS= \
|
||||
-l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd
|
||||
|
||||
LIBS= \
|
||||
-l libboost_system-mgw34-mt-d -l libboost_filesystem-mgw34-mt-d \
|
||||
-l db_cxx \
|
||||
-l eay32 \
|
||||
-l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd \
|
||||
-l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi
|
||||
|
||||
WXDEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH
|
||||
DEBUGFLAGS=-g -D__WXDEBUG__
|
||||
CFLAGS=-mthreads -O0 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
||||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h
|
||||
|
||||
CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
||||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
|
||||
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h init.h sha.h
|
||||
|
||||
|
||||
all: bitcoin.exe
|
||||
|
||||
|
||||
headers.h.gch: headers.h $(HEADERS)
|
||||
headers.h.gch: headers.h $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/util.o: util.cpp $(HEADERS)
|
||||
obj/%.o: %.cpp $(HEADERS) headers.h.gch
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/script.o: script.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/db.o: db.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/net.o: net.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/main.o: main.cpp $(HEADERS) sha.h
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/ui.o: ui.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/uibase.o: uibase.cpp uibase.h
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/sha.o: sha.cpp sha.h
|
||||
obj/sha.o: sha.cpp sha.h
|
||||
g++ -c $(CFLAGS) -O3 -o $@ $<
|
||||
|
||||
obj/irc.o: irc.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/rpc.o: rpc.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
|
||||
windres $(WXDEFS) $(INCLUDEPATHS) -o $@ -i $<
|
||||
|
||||
OBJS= \
|
||||
obj/util.o \
|
||||
obj/script.o \
|
||||
obj/db.o \
|
||||
obj/net.o \
|
||||
obj/irc.o \
|
||||
obj/main.o \
|
||||
obj/rpc.o \
|
||||
obj/init.o
|
||||
|
||||
bitcoin.exe: $(OBJS) obj/ui.o obj/uibase.o obj/sha.o obj/ui_res.o
|
||||
g++ $(CFLAGS) -mwindows -Wl,--subsystem,windows -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)
|
||||
|
||||
|
||||
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \
|
||||
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/rpc.o \
|
||||
obj/ui_res.o
|
||||
obj/nogui/%.o: %.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -DwxUSE_GUI=0 -o $@ $<
|
||||
|
||||
bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) obj/sha.o obj/ui_res.o
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -l wxbase29ud $(LIBS)
|
||||
|
||||
bitcoin.exe: headers.h.gch $(OBJS)
|
||||
-kill /f bitcoin.exe
|
||||
g++ $(CFLAGS) -mwindows -Wl,--subsystem,windows -o $@ $(LIBPATHS) $(OBJS) $(LIBS)
|
||||
|
||||
clean:
|
||||
-del /Q obj\*
|
||||
-del /Q obj\nogui\*
|
||||
-del /Q headers.h.gch
|
||||
|
||||
65
makefile.osx
Normal file
65
makefile.osx
Normal file
@@ -0,0 +1,65 @@
|
||||
# Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
# Mac OS X makefile for bitcoin
|
||||
# Laszlo Hanyecz (solar@heliacal.net)
|
||||
|
||||
DEPSDIR=/Users/macosuser/bitcoin/deps
|
||||
|
||||
INCLUDEPATHS= \
|
||||
-I"$(DEPSDIR)/include"
|
||||
|
||||
LIBPATHS= \
|
||||
-L"$(DEPSDIR)/lib"
|
||||
|
||||
WXLIBS=$(shell $(DEPSDIR)/bin/wx-config --libs --static)
|
||||
|
||||
LIBS= -dead_strip \
|
||||
$(DEPSDIR)/lib/libdb_cxx-4.8.a \
|
||||
$(DEPSDIR)/lib/libboost_system.a \
|
||||
$(DEPSDIR)/lib/libboost_filesystem.a \
|
||||
$(DEPSDIR)/lib/libcrypto.a
|
||||
|
||||
WXDEFS=$(shell $(DEPSDIR)/bin/wx-config --cxxflags) -DNOPCH -DMSG_NOSIGNAL=0
|
||||
|
||||
DEBUGFLAGS=-g -DwxDEBUG_LEVEL=0
|
||||
# ppc doesn't work because we don't support big-endian
|
||||
CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
||||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
|
||||
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h init.h sha.h
|
||||
|
||||
|
||||
all: bitcoin
|
||||
|
||||
|
||||
obj/%.o: %.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/sha.o: sha.cpp sha.h
|
||||
g++ -c $(CFLAGS) -O3 -o $@ $<
|
||||
|
||||
OBJS= \
|
||||
obj/util.o \
|
||||
obj/script.o \
|
||||
obj/db.o \
|
||||
obj/net.o \
|
||||
obj/irc.o \
|
||||
obj/main.o \
|
||||
obj/rpc.o \
|
||||
obj/init.o
|
||||
|
||||
bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha.o
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)
|
||||
|
||||
|
||||
obj/nogui/%.o: %.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -DwxUSE_GUI=0 -o $@ $<
|
||||
|
||||
bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha.o
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f obj/*.o
|
||||
-rm -f obj/nogui/*.o
|
||||
@@ -13,66 +13,61 @@ LIBPATHS= \
|
||||
-L"/usr/lib" \
|
||||
-L"/usr/local/lib"
|
||||
|
||||
WXLIBS= \
|
||||
-Wl,-Bstatic \
|
||||
-l wx_gtk2ud-2.9 \
|
||||
-Wl,-Bdynamic \
|
||||
-l gtk-x11-2.0 -l SM
|
||||
|
||||
LIBS= \
|
||||
-Wl,-Bstatic \
|
||||
-l boost_system-mt -l boost_filesystem-mt \
|
||||
-l db_cxx \
|
||||
-l wx_gtk2ud-2.9 \
|
||||
-Wl,-Bdynamic \
|
||||
-l crypto \
|
||||
-l gtk-x11-2.0 -l gthread-2.0 -l SM
|
||||
-l gthread-2.0
|
||||
|
||||
WXDEFS=-D__WXGTK__ -DNOPCH
|
||||
DEBUGFLAGS=-g -D__WXDEBUG__
|
||||
CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
||||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h
|
||||
|
||||
CFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
||||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
|
||||
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h init.h sha.h
|
||||
|
||||
|
||||
all: bitcoin
|
||||
|
||||
|
||||
headers.h.gch: headers.h $(HEADERS)
|
||||
headers.h.gch: headers.h $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/util.o: util.cpp $(HEADERS)
|
||||
obj/%.o: %.cpp $(HEADERS) headers.h.gch
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/script.o: script.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/db.o: db.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/net.o: net.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/main.o: main.cpp $(HEADERS) sha.h
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/ui.o: ui.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/uibase.o: uibase.cpp uibase.h
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj/sha.o: sha.cpp sha.h
|
||||
obj/sha.o: sha.cpp sha.h
|
||||
g++ -c $(CFLAGS) -O3 -o $@ $<
|
||||
|
||||
obj/irc.o: irc.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
OBJS= \
|
||||
obj/util.o \
|
||||
obj/script.o \
|
||||
obj/db.o \
|
||||
obj/net.o \
|
||||
obj/irc.o \
|
||||
obj/main.o \
|
||||
obj/rpc.o \
|
||||
obj/init.o
|
||||
|
||||
obj/rpc.o: rpc.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -o $@ $<
|
||||
bitcoin: $(OBJS) obj/ui.o obj/uibase.o obj/sha.o
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)
|
||||
|
||||
|
||||
obj/nogui/%.o: %.cpp $(HEADERS)
|
||||
g++ -c $(CFLAGS) -DwxUSE_GUI=0 -o $@ $<
|
||||
|
||||
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o \
|
||||
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/rpc.o
|
||||
bitcoind: $(OBJS:obj/%=obj/nogui/%) obj/sha.o
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -l wx_baseud-2.9 $(LIBS)
|
||||
|
||||
bitcoin: headers.h.gch $(OBJS)
|
||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)
|
||||
|
||||
clean:
|
||||
-rm obj/*
|
||||
-rm obj/nogui/*
|
||||
-rm headers.h.gch
|
||||
|
||||
81
makefile.vc
81
makefile.vc
@@ -28,56 +28,79 @@ LIBS= \
|
||||
WXDEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH
|
||||
DEBUGFLAGS=/Zi /Od /D__WXDEBUG__
|
||||
CFLAGS=/c /nologo /Ob0 /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
||||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h
|
||||
|
||||
HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
|
||||
script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h init.h sha.h
|
||||
|
||||
|
||||
all: bitcoin.exe
|
||||
|
||||
|
||||
obj\util.obj: util.cpp $(HEADERS)
|
||||
.cpp{obj}.obj:
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
|
||||
obj\script.obj: script.cpp $(HEADERS)
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
obj\util.obj: $(HEADERS)
|
||||
|
||||
obj\db.obj: db.cpp $(HEADERS)
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
obj\script.obj: $(HEADERS)
|
||||
|
||||
obj\net.obj: net.cpp $(HEADERS)
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
obj\db.obj: $(HEADERS)
|
||||
|
||||
obj\main.obj: main.cpp $(HEADERS) sha.h
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
obj\net.obj: $(HEADERS)
|
||||
|
||||
obj\ui.obj: ui.cpp $(HEADERS)
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
obj\irc.obj: $(HEADERS)
|
||||
|
||||
obj\uibase.obj: uibase.cpp uibase.h
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
obj\main.obj: $(HEADERS)
|
||||
|
||||
obj\sha.obj: sha.cpp sha.h
|
||||
obj\rpc.obj: $(HEADERS)
|
||||
|
||||
obj\init.obj: $(HEADERS)
|
||||
|
||||
obj\ui.obj: $(HEADERS)
|
||||
|
||||
obj\uibase.obj: $(HEADERS)
|
||||
|
||||
obj\sha.obj: sha.cpp sha.h
|
||||
cl $(CFLAGS) /O2 /Fo$@ %s
|
||||
|
||||
obj\irc.obj: irc.cpp $(HEADERS)
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
|
||||
obj\rpc.obj: rpc.cpp $(HEADERS)
|
||||
cl $(CFLAGS) /Fo$@ %s
|
||||
|
||||
obj\ui.res: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
|
||||
rc $(INCLUDEPATHS) $(WXDEFS) /Fo$@ %s
|
||||
|
||||
OBJS= \
|
||||
obj\util.obj \
|
||||
obj\script.obj \
|
||||
obj\db.obj \
|
||||
obj\net.obj \
|
||||
obj\irc.obj \
|
||||
obj\main.obj \
|
||||
obj\rpc.obj \
|
||||
obj\init.obj
|
||||
|
||||
|
||||
OBJS=obj\util.obj obj\script.obj obj\db.obj obj\net.obj obj\main.obj \
|
||||
obj\ui.obj obj\uibase.obj obj\sha.obj obj\irc.obj obj\rpc.obj \
|
||||
obj\ui.res
|
||||
|
||||
bitcoin.exe: $(OBJS)
|
||||
-kill /f bitcoin.exe & sleep 1
|
||||
bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\sha.obj obj\ui.res
|
||||
link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(LIBS)
|
||||
|
||||
|
||||
.cpp{obj\nogui}.obj:
|
||||
cl $(CFLAGS) /DwxUSE_GUI=0 /Fo$@ %s
|
||||
|
||||
obj\nogui\util.obj: $(HEADERS)
|
||||
|
||||
obj\nogui\script.obj: $(HEADERS)
|
||||
|
||||
obj\nogui\db.obj: $(HEADERS)
|
||||
|
||||
obj\nogui\net.obj: $(HEADERS)
|
||||
|
||||
obj\nogui\irc.obj: $(HEADERS)
|
||||
|
||||
obj\nogui\main.obj: $(HEADERS)
|
||||
|
||||
obj\nogui\rpc.obj: $(HEADERS)
|
||||
|
||||
obj\nogui\init.obj: $(HEADERS)
|
||||
|
||||
bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\sha.obj obj\ui.res
|
||||
link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)
|
||||
|
||||
|
||||
clean:
|
||||
-del /Q obj\*
|
||||
-del *.ilk
|
||||
|
||||
4
net.cpp
4
net.cpp
@@ -927,9 +927,7 @@ void ThreadOpenConnections2(void* parg)
|
||||
continue;
|
||||
|
||||
// Only try the old stuff if we don't have enough connections
|
||||
if (vNodes.size() >= 2 && nSinceLastSeen > 7 * 24 * 60 * 60)
|
||||
continue;
|
||||
if (vNodes.size() >= 5 && nSinceLastSeen > 24 * 60 * 60)
|
||||
if (vNodes.size() >= 8 && nSinceLastSeen > 24 * 60 * 60)
|
||||
continue;
|
||||
|
||||
// If multiple addresses are ready, prioritize by time since
|
||||
|
||||
65
net.h
65
net.h
@@ -8,6 +8,7 @@ class CInv;
|
||||
class CRequestTracker;
|
||||
class CNode;
|
||||
class CBlockIndex;
|
||||
extern int nBestHeight;
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +46,7 @@ bool StopNode();
|
||||
// (4) message start
|
||||
// (12) command
|
||||
// (4) size
|
||||
// (4) checksum
|
||||
|
||||
// The message start string is designed to be unlikely to occur in normal data.
|
||||
// The characters are rarely used upper ascii, not valid as UTF-8, and produce
|
||||
@@ -58,6 +60,7 @@ public:
|
||||
char pchMessageStart[sizeof(::pchMessageStart)];
|
||||
char pchCommand[COMMAND_SIZE];
|
||||
unsigned int nMessageSize;
|
||||
unsigned int nChecksum;
|
||||
|
||||
CMessageHeader()
|
||||
{
|
||||
@@ -65,6 +68,7 @@ public:
|
||||
memset(pchCommand, 0, sizeof(pchCommand));
|
||||
pchCommand[1] = 1;
|
||||
nMessageSize = -1;
|
||||
nChecksum = 0;
|
||||
}
|
||||
|
||||
CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn)
|
||||
@@ -72,6 +76,7 @@ public:
|
||||
memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
|
||||
strncpy(pchCommand, pszCommand, COMMAND_SIZE);
|
||||
nMessageSize = nMessageSizeIn;
|
||||
nChecksum = 0;
|
||||
}
|
||||
|
||||
IMPLEMENT_SERIALIZE
|
||||
@@ -79,6 +84,8 @@ public:
|
||||
READWRITE(FLATDATA(pchMessageStart));
|
||||
READWRITE(FLATDATA(pchCommand));
|
||||
READWRITE(nMessageSize);
|
||||
if (nVersion >= 209)
|
||||
READWRITE(nChecksum);
|
||||
)
|
||||
|
||||
string GetCommand()
|
||||
@@ -470,6 +477,7 @@ extern CAddress addrProxy;
|
||||
|
||||
|
||||
|
||||
|
||||
class CNode
|
||||
{
|
||||
public:
|
||||
@@ -484,7 +492,8 @@ public:
|
||||
int64 nLastRecv;
|
||||
int64 nLastSendEmpty;
|
||||
int64 nTimeConnected;
|
||||
unsigned int nPushPos;
|
||||
unsigned int nHeaderStart;
|
||||
unsigned int nMessageStart;
|
||||
CAddress addr;
|
||||
int nVersion;
|
||||
bool fClient;
|
||||
@@ -501,6 +510,7 @@ public:
|
||||
uint256 hashContinue;
|
||||
CBlockIndex* pindexLastGetBlocksBegin;
|
||||
uint256 hashLastGetBlocksEnd;
|
||||
int nStartingHeight;
|
||||
|
||||
// flood
|
||||
vector<CAddress> vAddrToSend;
|
||||
@@ -512,7 +522,7 @@ public:
|
||||
vector<CInv> vInventoryToSend;
|
||||
CCriticalSection cs_inventory;
|
||||
multimap<int64, CInv> mapAskFor;
|
||||
int64 nLastSentTxInv;
|
||||
int64 nNextSendTxInv;
|
||||
|
||||
// publish and subscription
|
||||
vector<char> vfSubscribe;
|
||||
@@ -523,12 +533,15 @@ public:
|
||||
nServices = 0;
|
||||
hSocket = hSocketIn;
|
||||
vSend.SetType(SER_NETWORK);
|
||||
vSend.SetVersion(0);
|
||||
vRecv.SetType(SER_NETWORK);
|
||||
vRecv.SetVersion(0);
|
||||
nLastSend = 0;
|
||||
nLastRecv = 0;
|
||||
nLastSendEmpty = GetTime();
|
||||
nTimeConnected = GetTime();
|
||||
nPushPos = -1;
|
||||
nHeaderStart = -1;
|
||||
nMessageStart = -1;
|
||||
addr = addrIn;
|
||||
nVersion = 0;
|
||||
fClient = false; // set by version message
|
||||
@@ -541,7 +554,9 @@ public:
|
||||
hashContinue = 0;
|
||||
pindexLastGetBlocksBegin = 0;
|
||||
hashLastGetBlocksEnd = 0;
|
||||
nStartingHeight = -1;
|
||||
fGetAddr = false;
|
||||
nNextSendTxInv = 0;
|
||||
vfSubscribe.assign(256, false);
|
||||
|
||||
// Push a version message
|
||||
@@ -550,7 +565,8 @@ public:
|
||||
CAddress addrYou = (fUseProxy ? CAddress("0.0.0.0") : addr);
|
||||
CAddress addrMe = (fUseProxy ? CAddress("0.0.0.0") : addrLocalHost);
|
||||
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
|
||||
PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, string(pszSubVer));
|
||||
PushMessage("version", VERSION, nLocalServices, nTime, addrYou, addrMe,
|
||||
nLocalHostNonce, string(pszSubVer), nBestHeight);
|
||||
}
|
||||
|
||||
~CNode()
|
||||
@@ -639,10 +655,11 @@ public:
|
||||
void BeginMessage(const char* pszCommand)
|
||||
{
|
||||
cs_vSend.Enter();
|
||||
if (nPushPos != -1)
|
||||
if (nHeaderStart != -1)
|
||||
AbortMessage();
|
||||
nPushPos = vSend.size();
|
||||
nHeaderStart = vSend.size();
|
||||
vSend << CMessageHeader(pszCommand, 0);
|
||||
nMessageStart = vSend.size();
|
||||
if (fDebug)
|
||||
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
|
||||
printf("sending: %s ", pszCommand);
|
||||
@@ -650,10 +667,11 @@ public:
|
||||
|
||||
void AbortMessage()
|
||||
{
|
||||
if (nPushPos == -1)
|
||||
if (nHeaderStart == -1)
|
||||
return;
|
||||
vSend.resize(nPushPos);
|
||||
nPushPos = -1;
|
||||
vSend.resize(nHeaderStart);
|
||||
nHeaderStart = -1;
|
||||
nMessageStart = -1;
|
||||
cs_vSend.Leave();
|
||||
printf("(aborted)\n");
|
||||
}
|
||||
@@ -667,25 +685,36 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (nPushPos == -1)
|
||||
if (nHeaderStart == -1)
|
||||
return;
|
||||
|
||||
// Patch in the size
|
||||
unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader);
|
||||
memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize));
|
||||
// Set the size
|
||||
unsigned int nSize = vSend.size() - nMessageStart;
|
||||
memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize));
|
||||
|
||||
// Set the checksum
|
||||
if (vSend.GetVersion() >= 209)
|
||||
{
|
||||
uint256 hash = Hash(vSend.begin() + nMessageStart, vSend.end());
|
||||
unsigned int nChecksum = 0;
|
||||
memcpy(&nChecksum, &hash, sizeof(nChecksum));
|
||||
assert(nMessageStart - nHeaderStart >= offsetof(CMessageHeader, nChecksum) + sizeof(nChecksum));
|
||||
memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum));
|
||||
}
|
||||
|
||||
printf("(%d bytes) ", nSize);
|
||||
printf("\n");
|
||||
|
||||
nPushPos = -1;
|
||||
nHeaderStart = -1;
|
||||
nMessageStart = -1;
|
||||
cs_vSend.Leave();
|
||||
}
|
||||
|
||||
void EndMessageAbortIfEmpty()
|
||||
{
|
||||
if (nPushPos == -1)
|
||||
if (nHeaderStart == -1)
|
||||
return;
|
||||
int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader);
|
||||
int nSize = vSend.size() - nMessageStart;
|
||||
if (nSize > 0)
|
||||
EndMessage();
|
||||
else
|
||||
@@ -694,9 +723,9 @@ public:
|
||||
|
||||
const char* GetMessageCommand() const
|
||||
{
|
||||
if (nPushPos == -1)
|
||||
if (nHeaderStart == -1)
|
||||
return "";
|
||||
return &vSend[nPushPos] + offsetof(CMessageHeader, pchCommand);
|
||||
return &vSend[nHeaderStart] + offsetof(CMessageHeader, pchCommand);
|
||||
}
|
||||
|
||||
|
||||
|
||||
426
rpc.cpp
426
rpc.cpp
@@ -26,7 +26,7 @@ void ThreadRPCServer2(void* parg);
|
||||
|
||||
|
||||
///
|
||||
/// Note: I'm not finished designing this interface, it's still subject to change.
|
||||
/// Note: This interface may still be subject to change.
|
||||
///
|
||||
|
||||
|
||||
@@ -66,6 +66,29 @@ Value getblocknumber(const Array& params)
|
||||
}
|
||||
|
||||
|
||||
Value getconnectioncount(const Array& params)
|
||||
{
|
||||
if (params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getconnectioncount (no parameters)\n"
|
||||
"Returns the number of connections to other nodes.");
|
||||
|
||||
return (int)vNodes.size();
|
||||
}
|
||||
|
||||
|
||||
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 = 256 - 32 - 31; // to fit in a uint
|
||||
double dMinimum = (CBigNum().SetCompact(bnProofOfWorkLimit.GetCompact()) >> nShift).getuint();
|
||||
double dCurrently = (CBigNum().SetCompact(pindexBest->nBits) >> nShift).getuint();
|
||||
return dMinimum / dCurrently;
|
||||
}
|
||||
|
||||
Value getdifficulty(const Array& params)
|
||||
{
|
||||
if (params.size() != 0)
|
||||
@@ -73,15 +96,73 @@ Value getdifficulty(const Array& params)
|
||||
"getdifficulty (no parameters)\n"
|
||||
"Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");
|
||||
|
||||
if (pindexBest == NULL)
|
||||
throw runtime_error("block chain not loaded");
|
||||
return GetDifficulty();
|
||||
}
|
||||
|
||||
// Floating point number that is a multiple of the minimum difficulty,
|
||||
// minimum difficulty = 1.0.
|
||||
int nShift = 256 - 32 - 31; // to fit in a uint
|
||||
double dMinimum = (CBigNum().SetCompact(bnProofOfWorkLimit.GetCompact()) >> nShift).getuint();
|
||||
double dCurrently = (CBigNum().SetCompact(pindexBest->nBits) >> nShift).getuint();
|
||||
return dMinimum / dCurrently;
|
||||
|
||||
Value getbalance(const Array& params)
|
||||
{
|
||||
if (params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getbalance (no parameters)\n"
|
||||
"Returns the server's available balance.");
|
||||
|
||||
return ((double)GetBalance() / (double)COIN);
|
||||
}
|
||||
|
||||
|
||||
Value getgenerate(const Array& params)
|
||||
{
|
||||
if (params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getgenerate (no parameters)\n"
|
||||
"Returns true or false.");
|
||||
|
||||
return (bool)fGenerateBitcoins;
|
||||
}
|
||||
|
||||
|
||||
Value setgenerate(const Array& params)
|
||||
{
|
||||
if (params.size() < 1 || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"setgenerate <generate> [genproclimit]\n"
|
||||
"<generate> is true or false to turn generation on or off.\n"
|
||||
"Generation is limited to [genproclimit] processors, -1 is unlimited.");
|
||||
|
||||
bool fGenerate = true;
|
||||
if (params.size() > 0)
|
||||
fGenerate = params[0].get_bool();
|
||||
|
||||
if (params.size() > 1)
|
||||
{
|
||||
int nGenProcLimit = params[1].get_int();
|
||||
fLimitProcessors = (nGenProcLimit != -1);
|
||||
CWalletDB().WriteSetting("fLimitProcessors", fLimitProcessors);
|
||||
if (nGenProcLimit != -1)
|
||||
CWalletDB().WriteSetting("nLimitProcessors", nLimitProcessors = nGenProcLimit);
|
||||
}
|
||||
|
||||
GenerateBitcoins(fGenerate);
|
||||
return Value::null;
|
||||
}
|
||||
|
||||
|
||||
Value getinfo(const Array& params)
|
||||
{
|
||||
if (params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getinfo (no parameters)");
|
||||
|
||||
Object obj;
|
||||
obj.push_back(Pair("balance", (double)GetBalance() / (double)COIN));
|
||||
obj.push_back(Pair("blocks", (int)nBestHeight + 1));
|
||||
obj.push_back(Pair("connections", (int)vNodes.size()));
|
||||
obj.push_back(Pair("proxy", (fUseProxy ? addrProxy.ToStringIPPort() : string())));
|
||||
obj.push_back(Pair("generate", (bool)fGenerateBitcoins));
|
||||
obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));
|
||||
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,12 +183,78 @@ Value getnewaddress(const Array& params)
|
||||
// Generate a new key that is added to wallet
|
||||
string strAddress = PubKeyToAddress(GenerateNewKey());
|
||||
|
||||
if (params.size() > 0)
|
||||
SetAddressBookName(strAddress, strLabel);
|
||||
SetAddressBookName(strAddress, strLabel);
|
||||
return strAddress;
|
||||
}
|
||||
|
||||
|
||||
Value setlabel(const Array& params)
|
||||
{
|
||||
if (params.size() < 1 || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"setlabel <bitcoinaddress> <label>\n"
|
||||
"Sets the label associated with the given address.");
|
||||
|
||||
string strAddress = params[0].get_str();
|
||||
string strLabel;
|
||||
if (params.size() > 1)
|
||||
strLabel = params[1].get_str();
|
||||
|
||||
SetAddressBookName(strAddress, strLabel);
|
||||
return Value::null;
|
||||
}
|
||||
|
||||
|
||||
Value getlabel(const Array& params)
|
||||
{
|
||||
if (params.size() != 1)
|
||||
throw runtime_error(
|
||||
"getlabel <bitcoinaddress>\n"
|
||||
"Returns the label associated with the given address.");
|
||||
|
||||
string strAddress = params[0].get_str();
|
||||
|
||||
string strLabel;
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
map<string, string>::iterator mi = mapAddressBook.find(strAddress);
|
||||
if (mi != mapAddressBook.end() && !(*mi).second.empty())
|
||||
strLabel = (*mi).second;
|
||||
}
|
||||
return strLabel;
|
||||
}
|
||||
|
||||
|
||||
Value getaddressesbylabel(const Array& params)
|
||||
{
|
||||
if (params.size() != 1)
|
||||
throw runtime_error(
|
||||
"getaddressesbylabel <label>\n"
|
||||
"Returns the list of addresses with the given label.");
|
||||
|
||||
string strLabel = params[0].get_str();
|
||||
|
||||
// Find all addresses that have the given label
|
||||
Array ret;
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
foreach(const PAIRTYPE(string, string)& item, mapAddressBook)
|
||||
{
|
||||
const string& strAddress = item.first;
|
||||
const string& strName = item.second;
|
||||
if (strName == strLabel)
|
||||
{
|
||||
// We're only adding valid bitcoin addresses and not ip addresses
|
||||
CScript scriptPubKey;
|
||||
if (scriptPubKey.SetBitcoinAddress(strAddress))
|
||||
ret.push_back(strAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Value sendtoaddress(const Array& params)
|
||||
{
|
||||
if (params.size() < 2 || params.size() > 4)
|
||||
@@ -157,11 +304,11 @@ Value listtransactions(const Array& params)
|
||||
}
|
||||
|
||||
|
||||
Value getamountreceived(const Array& params)
|
||||
Value getreceivedbyaddress(const Array& params)
|
||||
{
|
||||
if (params.size() < 1 || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"getamountreceived <bitcoinaddress> [minconf=1]\n"
|
||||
"getreceivedbyaddress <bitcoinaddress> [minconf=1]\n"
|
||||
"Returns the total amount received by <bitcoinaddress> in transactions with at least [minconf] confirmations.");
|
||||
|
||||
// Bitcoin address
|
||||
@@ -169,6 +316,8 @@ Value getamountreceived(const Array& params)
|
||||
CScript scriptPubKey;
|
||||
if (!scriptPubKey.SetBitcoinAddress(strAddress))
|
||||
throw runtime_error("Invalid bitcoin address");
|
||||
if (!IsMine(scriptPubKey))
|
||||
return (double)0.0;
|
||||
|
||||
// Minimum confirmations
|
||||
int nMinDepth = 1;
|
||||
@@ -196,6 +345,59 @@ Value getamountreceived(const Array& params)
|
||||
}
|
||||
|
||||
|
||||
Value getreceivedbylabel(const Array& params)
|
||||
{
|
||||
if (params.size() < 1 || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"getreceivedbylabel <label> [minconf=1]\n"
|
||||
"Returns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.");
|
||||
|
||||
// Get the set of pub keys that have the label
|
||||
string strLabel = params[0].get_str();
|
||||
set<CScript> setPubKey;
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
foreach(const PAIRTYPE(string, string)& item, mapAddressBook)
|
||||
{
|
||||
const string& strAddress = item.first;
|
||||
const string& strName = item.second;
|
||||
if (strName == strLabel)
|
||||
{
|
||||
// We're only counting our own valid bitcoin addresses and not ip addresses
|
||||
CScript scriptPubKey;
|
||||
if (scriptPubKey.SetBitcoinAddress(strAddress))
|
||||
if (IsMine(scriptPubKey))
|
||||
setPubKey.insert(scriptPubKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Minimum confirmations
|
||||
int nMinDepth = 1;
|
||||
if (params.size() > 1)
|
||||
nMinDepth = params[1].get_int();
|
||||
|
||||
// Tally
|
||||
int64 nAmount = 0;
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
if (wtx.IsCoinBase() || !wtx.IsFinal())
|
||||
continue;
|
||||
|
||||
foreach(const CTxOut& txout, wtx.vout)
|
||||
if (setPubKey.count(txout.scriptPubKey))
|
||||
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
||||
nAmount += txout.nValue;
|
||||
}
|
||||
}
|
||||
|
||||
return (double)nAmount / (double)COIN;
|
||||
}
|
||||
|
||||
|
||||
struct tallyitem
|
||||
{
|
||||
int64 nAmount;
|
||||
@@ -207,23 +409,18 @@ struct tallyitem
|
||||
}
|
||||
};
|
||||
|
||||
Value getallreceived(const Array& params)
|
||||
Value ListReceived(const Array& params, bool fByLabels)
|
||||
{
|
||||
if (params.size() > 1)
|
||||
throw runtime_error(
|
||||
"getallreceived [minconf=1]\n"
|
||||
"[minconf] is the minimum number of confirmations before payments are included.\n"
|
||||
"Returns an array of objects containing:\n"
|
||||
" \"address\" : bitcoin address\n"
|
||||
" \"amount\" : total amount received by the address\n"
|
||||
" \"conf\" : number of confirmations\n"
|
||||
" \"label\" : the label set for this address when it was created by getnewaddress");
|
||||
|
||||
// Minimum confirmations
|
||||
int nMinDepth = 1;
|
||||
if (params.size() > 0)
|
||||
nMinDepth = params[0].get_int();
|
||||
|
||||
// Whether to include empty accounts
|
||||
bool fIncludeEmpty = false;
|
||||
if (params.size() > 1)
|
||||
fIncludeEmpty = params[1].get_bool();
|
||||
|
||||
// Tally
|
||||
map<uint160, tallyitem> mapTally;
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
@@ -235,45 +432,119 @@ Value getallreceived(const Array& params)
|
||||
continue;
|
||||
|
||||
int nDepth = wtx.GetDepthInMainChain();
|
||||
if (nDepth >= nMinDepth)
|
||||
{
|
||||
foreach(const CTxOut& txout, wtx.vout)
|
||||
{
|
||||
uint160 hash160 = txout.scriptPubKey.GetBitcoinAddressHash160();
|
||||
if (hash160 == 0 || !mapPubKeys.count(hash160))
|
||||
continue;
|
||||
if (nDepth < nMinDepth)
|
||||
continue;
|
||||
|
||||
tallyitem& item = mapTally[hash160];
|
||||
item.nAmount += txout.nValue;
|
||||
item.nConf = min(item.nConf, nDepth);
|
||||
}
|
||||
foreach(const CTxOut& txout, wtx.vout)
|
||||
{
|
||||
// Only counting our own bitcoin addresses and not ip addresses
|
||||
uint160 hash160 = txout.scriptPubKey.GetBitcoinAddressHash160();
|
||||
if (hash160 == 0 || !mapPubKeys.count(hash160)) // IsMine
|
||||
continue;
|
||||
|
||||
tallyitem& item = mapTally[hash160];
|
||||
item.nAmount += txout.nValue;
|
||||
item.nConf = min(item.nConf, nDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reply
|
||||
Array ret;
|
||||
map<string, tallyitem> mapLabelTally;
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
for (map<uint160, tallyitem>::iterator it = mapTally.begin(); it != mapTally.end(); ++it)
|
||||
foreach(const PAIRTYPE(string, string)& item, mapAddressBook)
|
||||
{
|
||||
string strAddress = Hash160ToAddress((*it).first);
|
||||
string strLabel;
|
||||
map<string, string>::iterator mi = mapAddressBook.find(strAddress);
|
||||
if (mi != mapAddressBook.end())
|
||||
strLabel = (*mi).second;
|
||||
const string& strAddress = item.first;
|
||||
const string& strLabel = item.second;
|
||||
uint160 hash160;
|
||||
if (!AddressToHash160(strAddress, hash160))
|
||||
continue;
|
||||
map<uint160, tallyitem>::iterator it = mapTally.find(hash160);
|
||||
if (it == mapTally.end() && !fIncludeEmpty)
|
||||
continue;
|
||||
|
||||
int64 nAmount = 0;
|
||||
int nConf = INT_MAX;
|
||||
if (it != mapTally.end())
|
||||
{
|
||||
nAmount = (*it).second.nAmount;
|
||||
nConf = (*it).second.nConf;
|
||||
}
|
||||
|
||||
if (fByLabels)
|
||||
{
|
||||
tallyitem& item = mapLabelTally[strLabel];
|
||||
item.nAmount += nAmount;
|
||||
item.nConf = min(item.nConf, nConf);
|
||||
}
|
||||
else
|
||||
{
|
||||
Object obj;
|
||||
obj.push_back(Pair("address", strAddress));
|
||||
obj.push_back(Pair("label", strLabel));
|
||||
obj.push_back(Pair("amount", (double)nAmount / (double)COIN));
|
||||
obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf)));
|
||||
ret.push_back(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fByLabels)
|
||||
{
|
||||
for (map<string, tallyitem>::iterator it = mapLabelTally.begin(); it != mapLabelTally.end(); ++it)
|
||||
{
|
||||
int64 nAmount = (*it).second.nAmount;
|
||||
int nConf = (*it).second.nConf;
|
||||
Object obj;
|
||||
obj.push_back(Pair("address", strAddress));
|
||||
obj.push_back(Pair("amount", (double)(*it).second.nAmount / (double)COIN));
|
||||
obj.push_back(Pair("conf", (*it).second.nConf));
|
||||
obj.push_back(Pair("label", strLabel));
|
||||
obj.push_back(Pair("label", (*it).first));
|
||||
obj.push_back(Pair("amount", (double)nAmount / (double)COIN));
|
||||
obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf)));
|
||||
ret.push_back(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Value listreceivedbyaddress(const Array& params)
|
||||
{
|
||||
if (params.size() > 2)
|
||||
throw runtime_error(
|
||||
"listreceivedbyaddress [minconf=1] [includeempty=false]\n"
|
||||
"[minconf] is the minimum number of confirmations before payments are included.\n"
|
||||
"[includeempty] whether to include addresses that haven't received any payments.\n"
|
||||
"Returns an array of objects containing:\n"
|
||||
" \"address\" : receiving address\n"
|
||||
" \"label\" : the label of the receiving address\n"
|
||||
" \"amount\" : total amount received by the address\n"
|
||||
" \"confirmations\" : number of confirmations of the most recent transaction included");
|
||||
|
||||
return ListReceived(params, false);
|
||||
}
|
||||
|
||||
Value listreceivedbylabel(const Array& params)
|
||||
{
|
||||
if (params.size() > 2)
|
||||
throw runtime_error(
|
||||
"listreceivedbylabel [minconf=1] [includeempty=false]\n"
|
||||
"[minconf] is the minimum number of confirmations before payments are included.\n"
|
||||
"[includeempty] whether to include labels that haven't received any payments.\n"
|
||||
"Returns an array of objects containing:\n"
|
||||
" \"label\" : the label of the receiving addresses\n"
|
||||
" \"amount\" : total amount received by addresses with this label\n"
|
||||
" \"confirmations\" : number of confirmations of the most recent transaction included");
|
||||
|
||||
return ListReceived(params, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -287,15 +558,27 @@ Value getallreceived(const Array& params)
|
||||
typedef Value(*rpcfn_type)(const Array& params);
|
||||
pair<string, rpcfn_type> pCallTable[] =
|
||||
{
|
||||
make_pair("stop", &stop),
|
||||
make_pair("getblockcount", &getblockcount),
|
||||
make_pair("getblocknumber", &getblocknumber),
|
||||
make_pair("getdifficulty", &getdifficulty),
|
||||
make_pair("getnewaddress", &getnewaddress),
|
||||
make_pair("sendtoaddress", &sendtoaddress),
|
||||
make_pair("listtransactions", &listtransactions),
|
||||
make_pair("getamountreceived", &getamountreceived),
|
||||
make_pair("getallreceived", &getallreceived),
|
||||
make_pair("stop", &stop),
|
||||
make_pair("getblockcount", &getblockcount),
|
||||
make_pair("getblocknumber", &getblocknumber),
|
||||
make_pair("getconnectioncount", &getconnectioncount),
|
||||
make_pair("getdifficulty", &getdifficulty),
|
||||
make_pair("getbalance", &getbalance),
|
||||
make_pair("getgenerate", &getgenerate),
|
||||
make_pair("setgenerate", &setgenerate),
|
||||
make_pair("getinfo", &getinfo),
|
||||
make_pair("getnewaddress", &getnewaddress),
|
||||
make_pair("setlabel", &setlabel),
|
||||
make_pair("getlabel", &getlabel),
|
||||
make_pair("getaddressesbylabel", &getaddressesbylabel),
|
||||
make_pair("sendtoaddress", &sendtoaddress),
|
||||
make_pair("listtransactions", &listtransactions),
|
||||
make_pair("getamountreceived", &getreceivedbyaddress), // deprecated, renamed to getreceivedbyaddress
|
||||
make_pair("getallreceived", &listreceivedbyaddress), // deprecated, renamed to listreceivedbyaddress
|
||||
make_pair("getreceivedbyaddress", &getreceivedbyaddress),
|
||||
make_pair("getreceivedbylabel", &getreceivedbylabel),
|
||||
make_pair("listreceivedbyaddress", &listreceivedbyaddress),
|
||||
make_pair("listreceivedbylabel", &listreceivedbylabel),
|
||||
};
|
||||
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
|
||||
|
||||
@@ -568,14 +851,25 @@ int CommandLineRPC(int argc, char *argv[])
|
||||
Array params;
|
||||
for (int i = 2; i < argc; i++)
|
||||
params.push_back(argv[i]);
|
||||
|
||||
// Special case other types
|
||||
int n = params.size();
|
||||
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);
|
||||
if (strMethod == "listtransactions" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
if (strMethod == "listtransactions" && n > 1) ConvertTo<bool>(params[1]);
|
||||
if (strMethod == "getamountreceived" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||
if (strMethod == "getallreceived" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
|
||||
//
|
||||
// Special case other types
|
||||
//
|
||||
if (strMethod == "setgenerate" && n > 0) ConvertTo<bool>(params[0]);
|
||||
if (strMethod == "setgenerate" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);
|
||||
if (strMethod == "listtransactions" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
if (strMethod == "listtransactions" && n > 1) ConvertTo<bool>(params[1]);
|
||||
if (strMethod == "getamountreceived" && n > 1) ConvertTo<boost::int64_t>(params[1]); // deprecated
|
||||
if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||
if (strMethod == "getreceivedbylabel" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||
if (strMethod == "getallreceived" && n > 0) ConvertTo<boost::int64_t>(params[0]); // deprecated
|
||||
if (strMethod == "getallreceived" && n > 1) ConvertTo<bool>(params[1]);
|
||||
if (strMethod == "listreceivedbyaddress" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
if (strMethod == "listreceivedbyaddress" && n > 1) ConvertTo<bool>(params[1]);
|
||||
if (strMethod == "listreceivedbylabel" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
if (strMethod == "listreceivedbylabel" && n > 1) ConvertTo<bool>(params[1]);
|
||||
|
||||
// Execute
|
||||
Value result = CallRPC(strMethod, params);
|
||||
@@ -584,18 +878,18 @@ int CommandLineRPC(int argc, char *argv[])
|
||||
string strResult = (result.type() == str_type ? result.get_str() : write_string(result, true));
|
||||
if (result.type() != null_type)
|
||||
{
|
||||
if (fWindows)
|
||||
if (fWindows && fGUI)
|
||||
// Windows GUI apps can't print to command line,
|
||||
// so for now settle for a message box yuck
|
||||
wxMessageBox(strResult.c_str(), "Bitcoin", wxOK);
|
||||
// so settle for a message box yuck
|
||||
MyMessageBox(strResult.c_str(), "Bitcoin", wxOK);
|
||||
else
|
||||
fprintf(stdout, "%s\n", strResult.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
if (fWindows)
|
||||
wxMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);
|
||||
if (fWindows && fGUI)
|
||||
MyMessageBox(strprintf("error: %s\n", e.what()).c_str(), "Bitcoin", wxOK);
|
||||
else
|
||||
fprintf(stderr, "error: %s\n", e.what());
|
||||
} catch (...) {
|
||||
|
||||
5
script.h
5
script.h
@@ -580,6 +580,11 @@ public:
|
||||
*this << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
}
|
||||
|
||||
void SetBitcoinAddress(const vector<unsigned char>& vchPubKey)
|
||||
{
|
||||
SetBitcoinAddress(Hash160(vchPubKey));
|
||||
}
|
||||
|
||||
bool SetBitcoinAddress(const string& strAddress)
|
||||
{
|
||||
this->clear();
|
||||
|
||||
14
serialize.h
14
serialize.h
@@ -19,7 +19,7 @@ class CScript;
|
||||
class CDataStream;
|
||||
class CAutoFile;
|
||||
|
||||
static const int VERSION = 202;
|
||||
static const int VERSION = 209;
|
||||
static const char* pszSubVer = ".0";
|
||||
|
||||
|
||||
@@ -809,6 +809,18 @@ public:
|
||||
vch.insert(it, first, last);
|
||||
}
|
||||
|
||||
void insert(iterator it, vector<char>::const_iterator first, vector<char>::const_iterator last)
|
||||
{
|
||||
if (it == vch.begin() + nReadPos && last - first <= nReadPos)
|
||||
{
|
||||
// special case for inserting at the front when there's room
|
||||
nReadPos -= (last - first);
|
||||
memcpy(&vch[nReadPos], &first[0], last - first);
|
||||
}
|
||||
else
|
||||
vch.insert(it, first, last);
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1300
|
||||
void insert(iterator it, const char* first, const char* last)
|
||||
{
|
||||
|
||||
136
ui.h
136
ui.h
@@ -2,36 +2,79 @@
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
|
||||
|
||||
DECLARE_EVENT_TYPE(wxEVT_UITHREADCALL, -1)
|
||||
|
||||
extern map<string, string> mapArgs;
|
||||
#if wxUSE_GUI
|
||||
static const bool fGUI=true;
|
||||
#else
|
||||
static const bool fGUI=false;
|
||||
#endif
|
||||
|
||||
inline int MyMessageBox(const wxString& message, const wxString& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1)
|
||||
{
|
||||
#if wxUSE_GUI
|
||||
if (!fDaemon)
|
||||
return wxMessageBox(message, caption, style, parent, x, y);
|
||||
#endif
|
||||
printf("wxMessageBox %s: %s\n", string(caption).c_str(), string(message).c_str());
|
||||
fprintf(stderr, "%s: %s\n", string(caption).c_str(), string(message).c_str());
|
||||
return wxOK;
|
||||
}
|
||||
#define wxMessageBox MyMessageBox
|
||||
|
||||
// Settings
|
||||
extern int fShowGenerated;
|
||||
extern int fMinimizeToTray;
|
||||
extern int fMinimizeOnClose;
|
||||
|
||||
|
||||
|
||||
void HandleCtrlA(wxKeyEvent& event);
|
||||
string FormatTxStatus(const CWalletTx& wtx);
|
||||
void UIThreadCall(boost::function0<void>);
|
||||
void MainFrameRepaint();
|
||||
void Shutdown(void* parg);
|
||||
int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
|
||||
bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
|
||||
void CalledSetStatusBar(const string& strText, int nField);
|
||||
void MainFrameRepaint();
|
||||
void CreateMainWindow();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if !wxUSE_GUI
|
||||
inline int ThreadSafeMessageBox(const string& message, const string& caption, int style, wxWindow* parent, int x, int y)
|
||||
{
|
||||
return MyMessageBox(message, caption, style, parent, x, y);
|
||||
}
|
||||
|
||||
inline bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void CalledSetStatusBar(const string& strText, int nField)
|
||||
{
|
||||
}
|
||||
|
||||
inline void UIThreadCall(boost::function0<void> fn)
|
||||
{
|
||||
}
|
||||
|
||||
inline void MainFrameRepaint()
|
||||
{
|
||||
}
|
||||
|
||||
inline void CreateMainWindow()
|
||||
{
|
||||
}
|
||||
#else // wxUSE_GUI
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class CMainFrame : public CMainFrameBase
|
||||
{
|
||||
protected:
|
||||
// Event handlers
|
||||
void OnNotebookPageChanged(wxNotebookEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void OnIconize(wxIconizeEvent& event);
|
||||
void OnMouseEvents(wxMouseEvent& event);
|
||||
@@ -40,8 +83,6 @@ protected:
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnPaintListCtrl(wxPaintEvent& event);
|
||||
void OnMenuFileExit(wxCommandEvent& event);
|
||||
void OnMenuViewShowGenerated(wxCommandEvent& event);
|
||||
void OnUpdateUIViewShowGenerated(wxUpdateUIEvent& event);
|
||||
void OnMenuOptionsGenerate(wxCommandEvent& event);
|
||||
void OnUpdateUIOptionsGenerate(wxUpdateUIEvent& event);
|
||||
void OnMenuOptionsChangeYourAddress(wxCommandEvent& event);
|
||||
@@ -51,7 +92,7 @@ protected:
|
||||
void OnButtonAddressBook(wxCommandEvent& event);
|
||||
void OnSetFocusAddress(wxFocusEvent& event);
|
||||
void OnMouseEventsAddress(wxMouseEvent& event);
|
||||
void OnButtonChange(wxCommandEvent& event);
|
||||
void OnButtonNew(wxCommandEvent& event);
|
||||
void OnButtonCopy(wxCommandEvent& event);
|
||||
void OnListColBeginDrag(wxListEvent& event);
|
||||
void OnListItemActivated(wxListEvent& event);
|
||||
@@ -65,6 +106,18 @@ public:
|
||||
~CMainFrame();
|
||||
|
||||
// Custom
|
||||
enum
|
||||
{
|
||||
ALL = 0,
|
||||
SENTRECEIVED = 1,
|
||||
SENT = 2,
|
||||
RECEIVED = 3,
|
||||
};
|
||||
int nPage;
|
||||
wxListCtrl* m_listCtrl;
|
||||
bool fShowGenerated;
|
||||
bool fShowSent;
|
||||
bool fShowReceived;
|
||||
bool fRefreshListCtrl;
|
||||
bool fRefreshListCtrlRunning;
|
||||
bool fOnSetFocusAddress;
|
||||
@@ -205,53 +258,39 @@ void SendingDialogOnReply3(void* parg, CDataStream& vRecv);
|
||||
|
||||
|
||||
|
||||
class CYourAddressDialog : public CYourAddressDialogBase
|
||||
{
|
||||
protected:
|
||||
// Event handlers
|
||||
void OnListEndLabelEdit(wxListEvent& event);
|
||||
void OnListItemSelected(wxListEvent& event);
|
||||
void OnListItemActivated(wxListEvent& event);
|
||||
void OnButtonRename(wxCommandEvent& event);
|
||||
void OnButtonNew(wxCommandEvent& event);
|
||||
void OnButtonCopy(wxCommandEvent& event);
|
||||
void OnButtonOK(wxCommandEvent& event);
|
||||
void OnButtonCancel(wxCommandEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
||||
public:
|
||||
/** Constructor */
|
||||
CYourAddressDialog(wxWindow* parent);
|
||||
CYourAddressDialog(wxWindow* parent, const string& strInitSelected);
|
||||
|
||||
// Custom
|
||||
wxString GetAddress();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CAddressBookDialog : public CAddressBookDialogBase
|
||||
{
|
||||
protected:
|
||||
// Event handlers
|
||||
void OnNotebookPageChanged(wxNotebookEvent& event);
|
||||
void OnListEndLabelEdit(wxListEvent& event);
|
||||
void OnListItemSelected(wxListEvent& event);
|
||||
void OnListItemActivated(wxListEvent& event);
|
||||
void OnButtonEdit(wxCommandEvent& event);
|
||||
void OnButtonDelete(wxCommandEvent& event);
|
||||
void OnButtonNew(wxCommandEvent& event);
|
||||
void OnButtonCopy(wxCommandEvent& event);
|
||||
void OnButtonEdit(wxCommandEvent& event);
|
||||
void OnButtonNew(wxCommandEvent& event);
|
||||
void OnButtonOK(wxCommandEvent& event);
|
||||
void OnButtonCancel(wxCommandEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
||||
public:
|
||||
/** Constructor */
|
||||
CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, bool fSendingIn);
|
||||
CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn);
|
||||
|
||||
// Custom
|
||||
bool fSending;
|
||||
enum
|
||||
{
|
||||
SENDING = 0,
|
||||
RECEIVING = 1,
|
||||
};
|
||||
int nPage;
|
||||
wxListCtrl* m_listCtrl;
|
||||
bool fDuringSend;
|
||||
wxString GetAddress();
|
||||
wxString GetSelectedAddress();
|
||||
wxString GetSelectedSendingAddress();
|
||||
wxString GetSelectedReceivingAddress();
|
||||
bool CheckIfMine(const string& strAddress, const string& strTitle);
|
||||
};
|
||||
|
||||
@@ -282,18 +321,25 @@ public:
|
||||
const string& strMessage2="",
|
||||
const string& strValue2="") : CGetTextFromUserDialogBase(parent, wxID_ANY, strCaption)
|
||||
{
|
||||
int x = GetSize().GetWidth();
|
||||
int y = GetSize().GetHeight();
|
||||
m_staticTextMessage1->SetLabel(strMessage1);
|
||||
m_textCtrl1->SetValue(strValue1);
|
||||
y += wxString(strMessage1).Freq('\n') * 14;
|
||||
if (!strMessage2.empty())
|
||||
{
|
||||
m_staticTextMessage2->Show(true);
|
||||
m_staticTextMessage2->SetLabel(strMessage2);
|
||||
m_textCtrl2->Show(true);
|
||||
m_textCtrl2->SetValue(strValue2);
|
||||
SetSize(wxDefaultCoord, 180);
|
||||
y += 46 + wxString(strMessage2).Freq('\n') * 14;
|
||||
}
|
||||
if (!fWindows)
|
||||
SetSize(1.14 * GetSize().GetWidth(), 1.14 * GetSize().GetHeight());
|
||||
{
|
||||
x *= 1.14;
|
||||
y *= 1.14;
|
||||
}
|
||||
SetSize(x, y);
|
||||
}
|
||||
|
||||
// Custom
|
||||
@@ -329,3 +375,5 @@ public:
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
198
uibase.cpp
198
uibase.cpp
@@ -24,36 +24,29 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
|
||||
|
||||
m_menuFile = new wxMenu();
|
||||
wxMenuItem* m_menuFileExit;
|
||||
m_menuFileExit = new wxMenuItem( m_menuFile, wxID_ANY, wxString( _("E&xit") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuFileExit = new wxMenuItem( m_menuFile, wxID_EXIT, wxString( _("E&xit") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuFile->Append( m_menuFileExit );
|
||||
|
||||
m_menubar->Append( m_menuFile, _("&File") );
|
||||
|
||||
m_menuView = new wxMenu();
|
||||
wxMenuItem* m_menuViewShowGenerated;
|
||||
m_menuViewShowGenerated = new wxMenuItem( m_menuView, wxID_VIEWSHOWGENERATED, wxString( _("&Show Generated Coins") ) , wxEmptyString, wxITEM_CHECK );
|
||||
m_menuView->Append( m_menuViewShowGenerated );
|
||||
|
||||
m_menubar->Append( m_menuView, _("&View") );
|
||||
|
||||
m_menuOptions = new wxMenu();
|
||||
wxMenuItem* m_menuOptionsGenerateBitcoins;
|
||||
m_menuOptionsGenerateBitcoins = new wxMenuItem( m_menuOptions, wxID_OPTIONSGENERATEBITCOINS, wxString( _("&Generate Coins") ) , wxEmptyString, wxITEM_CHECK );
|
||||
m_menuOptions->Append( m_menuOptionsGenerateBitcoins );
|
||||
|
||||
wxMenuItem* m_menuOptionsChangeYourAddress;
|
||||
m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Change Your Address...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuOptionsChangeYourAddress = new wxMenuItem( m_menuOptions, wxID_ANY, wxString( _("&Your Receiving Addresses...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuOptions->Append( m_menuOptionsChangeYourAddress );
|
||||
|
||||
wxMenuItem* m_menuOptionsOptions;
|
||||
m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_MENUOPTIONSOPTIONS, wxString( _("&Options...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuOptionsOptions = new wxMenuItem( m_menuOptions, wxID_PREFERENCES, wxString( _("&Options...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuOptions->Append( m_menuOptionsOptions );
|
||||
|
||||
m_menubar->Append( m_menuOptions, _("&Options") );
|
||||
m_menubar->Append( m_menuOptions, _("&Settings") );
|
||||
|
||||
m_menuHelp = new wxMenu();
|
||||
wxMenuItem* m_menuHelpAbout;
|
||||
m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ANY, wxString( _("&About...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ABOUT, wxString( _("&About...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuHelp->Append( m_menuHelpAbout );
|
||||
|
||||
m_menubar->Append( m_menuHelp, _("&Help") );
|
||||
@@ -65,8 +58,8 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
|
||||
m_toolBar->SetToolSeparation( 1 );
|
||||
m_toolBar->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
|
||||
|
||||
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->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();
|
||||
|
||||
m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
|
||||
@@ -86,14 +79,10 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
|
||||
bSizer85->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||
|
||||
m_textCtrlAddress = new wxTextCtrl( this, wxID_TEXTCTRLADDRESS, wxEmptyString, wxDefaultPosition, wxSize( 340,-1 ), wxTE_READONLY );
|
||||
m_textCtrlAddress->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
|
||||
|
||||
bSizer85->Add( m_textCtrlAddress, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_buttonNew = new wxButton( this, wxID_BUTTONCHANGE, _("&New..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_buttonNew->Hide();
|
||||
|
||||
bSizer85->Add( m_buttonNew, 0, wxRIGHT, 5 );
|
||||
m_buttonNew = new wxButton( this, wxID_BUTTONNEW, _(" &New... "), wxDefaultPosition, wxSize( -1,-1 ), wxBU_EXACTFIT );
|
||||
bSizer85->Add( m_buttonNew, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, _(" &Copy to Clipboard "), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
|
||||
bSizer85->Add( m_buttonCopy, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
@@ -139,8 +128,53 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
|
||||
|
||||
bSizer2->Add( bSizer3, 0, wxEXPAND, 5 );
|
||||
|
||||
m_listCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING|wxVSCROLL );
|
||||
bSizer2->Add( m_listCtrl, 1, wxEXPAND, 5 );
|
||||
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_panel9 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer11;
|
||||
bSizer11 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_listCtrlAll = new wxListCtrl( m_panel9, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );
|
||||
bSizer11->Add( m_listCtrlAll, 1, wxEXPAND, 5 );
|
||||
|
||||
m_panel9->SetSizer( bSizer11 );
|
||||
m_panel9->Layout();
|
||||
bSizer11->Fit( m_panel9 );
|
||||
m_notebook->AddPage( m_panel9, _("All Transactions"), true );
|
||||
m_panel91 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer111;
|
||||
bSizer111 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_listCtrlSentReceived = new wxListCtrl( m_panel91, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );
|
||||
bSizer111->Add( m_listCtrlSentReceived, 1, wxEXPAND, 5 );
|
||||
|
||||
m_panel91->SetSizer( bSizer111 );
|
||||
m_panel91->Layout();
|
||||
bSizer111->Fit( m_panel91 );
|
||||
m_notebook->AddPage( m_panel91, _("Sent/Received"), false );
|
||||
m_panel92 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer112;
|
||||
bSizer112 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_listCtrlSent = new wxListCtrl( m_panel92, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );
|
||||
bSizer112->Add( m_listCtrlSent, 1, wxEXPAND, 5 );
|
||||
|
||||
m_panel92->SetSizer( bSizer112 );
|
||||
m_panel92->Layout();
|
||||
bSizer112->Fit( m_panel92 );
|
||||
m_notebook->AddPage( m_panel92, _("Sent"), false );
|
||||
m_panel93 = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer113;
|
||||
bSizer113 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_listCtrlReceived = new wxListCtrl( m_panel93, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_DESCENDING );
|
||||
bSizer113->Add( m_listCtrlReceived, 1, wxEXPAND, 5 );
|
||||
|
||||
m_panel93->SetSizer( bSizer113 );
|
||||
m_panel93->Layout();
|
||||
bSizer113->Fit( m_panel93 );
|
||||
m_notebook->AddPage( m_panel93, _("Received"), false );
|
||||
|
||||
bSizer2->Add( m_notebook, 1, wxEXPAND, 5 );
|
||||
|
||||
this->SetSizer( bSizer2 );
|
||||
this->Layout();
|
||||
@@ -164,8 +198,6 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
|
||||
this->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );
|
||||
this->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) );
|
||||
this->Connect( m_menuFileExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) );
|
||||
this->Connect( m_menuViewShowGenerated->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuViewShowGenerated ) );
|
||||
this->Connect( m_menuViewShowGenerated->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIViewShowGenerated ) );
|
||||
this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) );
|
||||
this->Connect( m_menuOptionsGenerateBitcoins->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) );
|
||||
this->Connect( m_menuOptionsChangeYourAddress->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) );
|
||||
@@ -188,11 +220,21 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
|
||||
m_textCtrlAddress->Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );
|
||||
m_textCtrlAddress->Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );
|
||||
m_textCtrlAddress->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );
|
||||
m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );
|
||||
m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonNew ), NULL, this );
|
||||
m_buttonCopy->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );
|
||||
m_listCtrl->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrl->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( CMainFrameBase::OnNotebookPageChanged ), NULL, this );
|
||||
m_listCtrlAll->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlAll->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlAll->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_listCtrlSentReceived->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlSentReceived->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlSentReceived->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_listCtrlSent->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlSent->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlSent->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_listCtrlReceived->Connect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlReceived->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlReceived->Connect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
}
|
||||
|
||||
CMainFrameBase::~CMainFrameBase()
|
||||
@@ -216,8 +258,6 @@ CMainFrameBase::~CMainFrameBase()
|
||||
this->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEvents ) );
|
||||
this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaint ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuFileExit ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuViewShowGenerated ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIViewShowGenerated ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsGenerate ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( CMainFrameBase::OnUpdateUIOptionsGenerate ) );
|
||||
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( CMainFrameBase::OnMenuOptionsChangeYourAddress ) );
|
||||
@@ -240,11 +280,21 @@ CMainFrameBase::~CMainFrameBase()
|
||||
m_textCtrlAddress->Disconnect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );
|
||||
m_textCtrlAddress->Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CMainFrameBase::OnMouseEventsAddress ), NULL, this );
|
||||
m_textCtrlAddress->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( CMainFrameBase::OnSetFocusAddress ), NULL, this );
|
||||
m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonChange ), NULL, this );
|
||||
m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonNew ), NULL, this );
|
||||
m_buttonCopy->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CMainFrameBase::OnButtonCopy ), NULL, this );
|
||||
m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrl->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( CMainFrameBase::OnNotebookPageChanged ), NULL, this );
|
||||
m_listCtrlAll->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlAll->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlAll->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_listCtrlSentReceived->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlSentReceived->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlSentReceived->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_listCtrlSent->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlSent->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlSent->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
m_listCtrlReceived->Disconnect( wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, wxListEventHandler( CMainFrameBase::OnListColBeginDrag ), NULL, this );
|
||||
m_listCtrlReceived->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CMainFrameBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlReceived->Disconnect( wxEVT_PAINT, wxPaintEventHandler( CMainFrameBase::OnPaintListCtrl ), NULL, this );
|
||||
}
|
||||
|
||||
CTxDetailsDialogBase::CTxDetailsDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||
@@ -844,20 +894,53 @@ CAddressBookDialogBase::CAddressBookDialogBase( wxWindow* parent, wxWindowID id,
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
wxBoxSizer* bSizer58;
|
||||
bSizer58 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_panelSending = new wxPanel( m_notebook, wxID_PANELSENDING, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer68;
|
||||
bSizer68 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
||||
bSizer68->Add( 0, 5, 0, wxEXPAND, 5 );
|
||||
bSizer68->Add( 0, 0, 0, wxEXPAND, 5 );
|
||||
|
||||
m_staticText55 = new wxStaticText( this, wxID_ANY, _("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText55 = new wxStaticText( m_panelSending, wxID_ANY, _("Bitcoin Address"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText55->Wrap( -1 );
|
||||
m_staticText55->Hide();
|
||||
|
||||
bSizer68->Add( m_staticText55, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_listCtrl = new wxListCtrl( this, wxID_LISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );
|
||||
bSizer68->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
|
||||
m_listCtrlSending = new wxListCtrl( m_panelSending, wxID_LISTCTRLSENDING, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );
|
||||
bSizer68->Add( m_listCtrlSending, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_panelSending->SetSizer( bSizer68 );
|
||||
m_panelSending->Layout();
|
||||
bSizer68->Fit( m_panelSending );
|
||||
m_notebook->AddPage( m_panelSending, _("Sending"), false );
|
||||
m_panelReceiving = new wxPanel( m_notebook, wxID_PANELRECEIVING, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer681;
|
||||
bSizer681 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
||||
bSizer681->Add( 0, 0, 0, wxEXPAND, 5 );
|
||||
|
||||
m_staticText45 = new wxStaticText( m_panelReceiving, wxID_ANY, _("These are your Bitcoin addresses for receiving payments. You can give a different one to each sender to keep track of who is paying you. The highlighted address will be displayed in the main window."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText45->Wrap( 570 );
|
||||
bSizer681->Add( m_staticText45, 0, wxTOP|wxRIGHT|wxLEFT, 6 );
|
||||
|
||||
|
||||
bSizer681->Add( 0, 2, 0, wxEXPAND, 5 );
|
||||
|
||||
m_listCtrlReceiving = new wxListCtrl( m_panelReceiving, wxID_LISTCTRLRECEIVING, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxLC_SORT_ASCENDING );
|
||||
bSizer681->Add( m_listCtrlReceiving, 1, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_panelReceiving->SetSizer( bSizer681 );
|
||||
m_panelReceiving->Layout();
|
||||
bSizer681->Fit( m_panelReceiving );
|
||||
m_notebook->AddPage( m_panelReceiving, _("Receiving"), true );
|
||||
|
||||
bSizer58->Add( m_notebook, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxBoxSizer* bSizer69;
|
||||
bSizer69 = new wxBoxSizer( wxHORIZONTAL );
|
||||
@@ -865,34 +948,42 @@ CAddressBookDialogBase::CAddressBookDialogBase( wxWindow* parent, wxWindowID id,
|
||||
|
||||
bSizer69->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer69->Add( m_buttonDelete, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonCopy = new wxButton( this, wxID_BUTTONCOPY, _(" &Copy to Clipboard "), wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
||||
bSizer69->Add( m_buttonCopy, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonEdit = new wxButton( this, wxID_BUTTONEDIT, _("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer69->Add( m_buttonEdit, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonNew = new wxButton( this, wxID_BUTTONNEW, _(" &New Address... "), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer69->Add( m_buttonNew, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonDelete = new wxButton( this, wxID_BUTTONDELETE, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizer69->Add( m_buttonDelete, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonOK = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
||||
bSizer69->Add( m_buttonOK, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
||||
bSizer69->Add( m_buttonCancel, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
|
||||
|
||||
bSizer68->Add( bSizer69, 0, wxEXPAND, 5 );
|
||||
bSizer58->Add( bSizer69, 0, wxEXPAND, 5 );
|
||||
|
||||
this->SetSizer( bSizer68 );
|
||||
this->SetSizer( bSizer58 );
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CAddressBookDialogBase::OnClose ) );
|
||||
m_listCtrl->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );
|
||||
m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );
|
||||
m_notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( CAddressBookDialogBase::OnNotebookPageChanged ), NULL, this );
|
||||
m_listCtrlSending->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );
|
||||
m_listCtrlSending->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlSending->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );
|
||||
m_listCtrlReceiving->Connect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );
|
||||
m_listCtrlReceiving->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlReceiving->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );
|
||||
m_buttonDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );
|
||||
m_buttonCopy->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCopy ), NULL, this );
|
||||
m_buttonEdit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonEdit ), NULL, this );
|
||||
m_buttonNew->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonNew ), NULL, this );
|
||||
m_buttonDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );
|
||||
m_buttonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonOK ), NULL, this );
|
||||
m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCancel ), NULL, this );
|
||||
}
|
||||
@@ -901,12 +992,17 @@ CAddressBookDialogBase::~CAddressBookDialogBase()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( CAddressBookDialogBase::OnClose ) );
|
||||
m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );
|
||||
m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );
|
||||
m_notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( CAddressBookDialogBase::OnNotebookPageChanged ), NULL, this );
|
||||
m_listCtrlSending->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );
|
||||
m_listCtrlSending->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlSending->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );
|
||||
m_listCtrlReceiving->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( CAddressBookDialogBase::OnListEndLabelEdit ), NULL, this );
|
||||
m_listCtrlReceiving->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( CAddressBookDialogBase::OnListItemActivated ), NULL, this );
|
||||
m_listCtrlReceiving->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( CAddressBookDialogBase::OnListItemSelected ), NULL, this );
|
||||
m_buttonDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );
|
||||
m_buttonCopy->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCopy ), NULL, this );
|
||||
m_buttonEdit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonEdit ), NULL, this );
|
||||
m_buttonNew->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonNew ), NULL, this );
|
||||
m_buttonDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonDelete ), NULL, this );
|
||||
m_buttonOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonOK ), NULL, this );
|
||||
m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CAddressBookDialogBase::OnButtonCancel ), NULL, this );
|
||||
}
|
||||
|
||||
84
uibase.h
84
uibase.h
@@ -28,6 +28,7 @@
|
||||
#include <wx/panel.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/dialog.h>
|
||||
@@ -40,28 +41,29 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define wxID_MAINFRAME 1000
|
||||
#define wxID_VIEWSHOWGENERATED 1001
|
||||
#define wxID_OPTIONSGENERATEBITCOINS 1002
|
||||
#define wxID_MENUOPTIONSOPTIONS 1003
|
||||
#define wxID_BUTTONSEND 1004
|
||||
#define wxID_BUTTONRECEIVE 1005
|
||||
#define wxID_TEXTCTRLADDRESS 1006
|
||||
#define wxID_BUTTONCHANGE 1007
|
||||
#define wxID_BUTTONCOPY 1008
|
||||
#define wxID_TRANSACTIONFEE 1009
|
||||
#define wxID_PROXYIP 1010
|
||||
#define wxID_PROXYPORT 1011
|
||||
#define wxID_TEXTCTRLPAYTO 1012
|
||||
#define wxID_BUTTONPASTE 1013
|
||||
#define wxID_BUTTONADDRESSBOOK 1014
|
||||
#define wxID_TEXTCTRLAMOUNT 1015
|
||||
#define wxID_CHOICETRANSFERTYPE 1016
|
||||
#define wxID_LISTCTRL 1017
|
||||
#define wxID_BUTTONRENAME 1018
|
||||
#define wxID_BUTTONNEW 1019
|
||||
#define wxID_BUTTONEDIT 1020
|
||||
#define wxID_OPTIONSGENERATEBITCOINS 1001
|
||||
#define wxID_BUTTONSEND 1002
|
||||
#define wxID_BUTTONRECEIVE 1003
|
||||
#define wxID_TEXTCTRLADDRESS 1004
|
||||
#define wxID_BUTTONNEW 1005
|
||||
#define wxID_BUTTONCOPY 1006
|
||||
#define wxID_TRANSACTIONFEE 1007
|
||||
#define wxID_PROXYIP 1008
|
||||
#define wxID_PROXYPORT 1009
|
||||
#define wxID_TEXTCTRLPAYTO 1010
|
||||
#define wxID_BUTTONPASTE 1011
|
||||
#define wxID_BUTTONADDRESSBOOK 1012
|
||||
#define wxID_TEXTCTRLAMOUNT 1013
|
||||
#define wxID_CHOICETRANSFERTYPE 1014
|
||||
#define wxID_LISTCTRL 1015
|
||||
#define wxID_BUTTONRENAME 1016
|
||||
#define wxID_PANELSENDING 1017
|
||||
#define wxID_LISTCTRLSENDING 1018
|
||||
#define wxID_PANELRECEIVING 1019
|
||||
#define wxID_LISTCTRLRECEIVING 1020
|
||||
#define wxID_BUTTONDELETE 1021
|
||||
#define wxID_TEXTCTRL 1022
|
||||
#define wxID_BUTTONEDIT 1022
|
||||
#define wxID_TEXTCTRL 1023
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class CMainFrameBase
|
||||
@@ -73,13 +75,10 @@ class CMainFrameBase : public wxFrame
|
||||
protected:
|
||||
wxMenuBar* m_menubar;
|
||||
wxMenu* m_menuFile;
|
||||
wxMenu* m_menuView;
|
||||
wxMenu* m_menuHelp;
|
||||
wxToolBar* m_toolBar;
|
||||
wxStatusBar* m_statusBar;
|
||||
|
||||
wxStaticText* m_staticText32;
|
||||
wxTextCtrl* m_textCtrlAddress;
|
||||
wxButton* m_buttonNew;
|
||||
wxButton* m_buttonCopy;
|
||||
|
||||
@@ -88,6 +87,11 @@ class CMainFrameBase : public wxFrame
|
||||
wxStaticText* m_staticTextBalance;
|
||||
|
||||
wxChoice* m_choiceFilter;
|
||||
wxNotebook* m_notebook;
|
||||
wxPanel* m_panel9;
|
||||
wxPanel* m_panel91;
|
||||
wxPanel* m_panel92;
|
||||
wxPanel* m_panel93;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }
|
||||
@@ -96,8 +100,6 @@ class CMainFrameBase : public wxFrame
|
||||
virtual void OnMouseEvents( wxMouseEvent& event ){ event.Skip(); }
|
||||
virtual void OnPaint( wxPaintEvent& event ){ event.Skip(); }
|
||||
virtual void OnMenuFileExit( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnMenuViewShowGenerated( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnUpdateUIViewShowGenerated( wxUpdateUIEvent& event ){ event.Skip(); }
|
||||
virtual void OnMenuOptionsGenerate( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnUpdateUIOptionsGenerate( wxUpdateUIEvent& event ){ event.Skip(); }
|
||||
virtual void OnMenuOptionsChangeYourAddress( wxCommandEvent& event ){ event.Skip(); }
|
||||
@@ -108,8 +110,9 @@ class CMainFrameBase : public wxFrame
|
||||
virtual void OnKeyDown( wxKeyEvent& event ){ event.Skip(); }
|
||||
virtual void OnMouseEventsAddress( wxMouseEvent& event ){ event.Skip(); }
|
||||
virtual void OnSetFocusAddress( wxFocusEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonChange( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); }
|
||||
virtual void OnListColBeginDrag( wxListEvent& event ){ event.Skip(); }
|
||||
virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }
|
||||
virtual void OnPaintListCtrl( wxPaintEvent& event ){ event.Skip(); }
|
||||
@@ -117,8 +120,13 @@ class CMainFrameBase : public wxFrame
|
||||
|
||||
public:
|
||||
wxMenu* m_menuOptions;
|
||||
wxListCtrl* m_listCtrl;
|
||||
CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = _("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 712,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
|
||||
wxStatusBar* m_statusBar;
|
||||
wxTextCtrl* m_textCtrlAddress;
|
||||
wxListCtrl* m_listCtrlAll;
|
||||
wxListCtrl* m_listCtrlSentReceived;
|
||||
wxListCtrl* m_listCtrlSent;
|
||||
wxListCtrl* m_listCtrlReceived;
|
||||
CMainFrameBase( wxWindow* parent, wxWindowID id = wxID_MAINFRAME, const wxString& title = _("Bitcoin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 723,484 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
|
||||
~CMainFrameBase();
|
||||
|
||||
};
|
||||
@@ -343,23 +351,33 @@ class CAddressBookDialogBase : public wxDialog
|
||||
private:
|
||||
|
||||
protected:
|
||||
wxNotebook* m_notebook;
|
||||
wxPanel* m_panelSending;
|
||||
|
||||
wxStaticText* m_staticText55;
|
||||
wxListCtrl* m_listCtrl;
|
||||
wxListCtrl* m_listCtrlSending;
|
||||
wxPanel* m_panelReceiving;
|
||||
|
||||
wxStaticText* m_staticText45;
|
||||
|
||||
wxListCtrl* m_listCtrlReceiving;
|
||||
|
||||
wxButton* m_buttonDelete;
|
||||
wxButton* m_buttonCopy;
|
||||
wxButton* m_buttonEdit;
|
||||
wxButton* m_buttonNew;
|
||||
wxButton* m_buttonDelete;
|
||||
wxButton* m_buttonOK;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnClose( wxCloseEvent& event ){ event.Skip(); }
|
||||
virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); }
|
||||
virtual void OnListEndLabelEdit( wxListEvent& event ){ event.Skip(); }
|
||||
virtual void OnListItemActivated( wxListEvent& event ){ event.Skip(); }
|
||||
virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonDelete( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonCopy( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonEdit( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonNew( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonDelete( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonOK( wxCommandEvent& event ){ event.Skip(); }
|
||||
virtual void OnButtonCancel( wxCommandEvent& event ){ event.Skip(); }
|
||||
|
||||
@@ -397,7 +415,7 @@ class CGetTextFromUserDialogBase : public wxDialog
|
||||
|
||||
|
||||
public:
|
||||
CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 403,138 ), long style = wxDEFAULT_DIALOG_STYLE );
|
||||
CGetTextFromUserDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 440,138 ), long style = wxDEFAULT_DIALOG_STYLE );
|
||||
~CGetTextFromUserDialogBase();
|
||||
|
||||
};
|
||||
|
||||
1221
uiproject.fbp
1221
uiproject.fbp
File diff suppressed because it is too large
Load Diff
65
util.cpp
65
util.cpp
@@ -13,6 +13,7 @@ bool fPrintToDebugger = false;
|
||||
char pszSetDataDir[MAX_PATH] = "";
|
||||
bool fShutdown = false;
|
||||
bool fDaemon = false;
|
||||
bool fCommandLine = false;
|
||||
|
||||
|
||||
|
||||
@@ -249,11 +250,6 @@ string strprintf(const char* format, ...)
|
||||
if (p == NULL)
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
// msvc optimisation
|
||||
if (p == buffer)
|
||||
return string(p, p+ret);
|
||||
#endif
|
||||
string str(p, p+ret);
|
||||
if (p != buffer)
|
||||
delete p;
|
||||
@@ -281,15 +277,21 @@ bool error(const char* format, ...)
|
||||
|
||||
void ParseString(const string& str, char c, vector<string>& v)
|
||||
{
|
||||
unsigned int i1 = 0;
|
||||
unsigned int i2;
|
||||
do
|
||||
if (str.empty())
|
||||
return;
|
||||
string::size_type i1 = 0;
|
||||
string::size_type i2;
|
||||
loop
|
||||
{
|
||||
i2 = str.find(c, i1);
|
||||
if (i2 == str.npos)
|
||||
{
|
||||
v.push_back(str.substr(i1));
|
||||
return;
|
||||
}
|
||||
v.push_back(str.substr(i1, i2-i1));
|
||||
i1 = i2+1;
|
||||
}
|
||||
while (i2 != str.npos);
|
||||
}
|
||||
|
||||
|
||||
@@ -307,6 +309,12 @@ string FormatMoney(int64 n, bool fPlus)
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
bool ParseMoney(const string& str, int64& nRet)
|
||||
{
|
||||
return ParseMoney(str.c_str(), nRet);
|
||||
}
|
||||
|
||||
bool ParseMoney(const char* pszIn, int64& nRet)
|
||||
{
|
||||
string strWhole;
|
||||
@@ -431,6 +439,40 @@ void ParseParameters(int argc, char* argv[])
|
||||
}
|
||||
|
||||
|
||||
const char* wxGetTranslation(const char* pszEnglish)
|
||||
{
|
||||
// Wrapper of wxGetTranslation returning the same const char* type as was passed in
|
||||
static CCriticalSection cs;
|
||||
CRITICAL_BLOCK(cs)
|
||||
{
|
||||
// Look in cache
|
||||
static map<string, char*> mapCache;
|
||||
map<string, char*>::iterator mi = mapCache.find(pszEnglish);
|
||||
if (mi != mapCache.end())
|
||||
return (*mi).second;
|
||||
|
||||
// wxWidgets translation
|
||||
wxString strTranslated = wxGetTranslation(wxString(pszEnglish, wxConvUTF8));
|
||||
|
||||
// We don't cache unknown strings because caller might be passing in a
|
||||
// dynamic string and we would keep allocating memory for each variation.
|
||||
if (strcmp(pszEnglish, strTranslated.utf8_str()) == 0)
|
||||
return pszEnglish;
|
||||
|
||||
// Add to cache, memory doesn't need to be freed. We only cache because
|
||||
// we must pass back a pointer to permanently allocated memory.
|
||||
char* pszCached = new char[strlen(strTranslated.utf8_str())+1];
|
||||
strcpy(pszCached, strTranslated.utf8_str());
|
||||
mapCache[pszEnglish] = pszCached;
|
||||
return pszCached;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -467,8 +509,9 @@ void PrintException(std::exception* pex, const char* pszThread)
|
||||
char pszMessage[1000];
|
||||
FormatException(pszMessage, pex, pszThread);
|
||||
printf("\n\n************************\n%s\n", pszMessage);
|
||||
if (wxTheApp)
|
||||
wxMessageBox(pszMessage, "Error", wxOK | wxICON_ERROR);
|
||||
fprintf(stderr, "\n\n************************\n%s\n", pszMessage);
|
||||
if (wxTheApp && !fDaemon && fGUI)
|
||||
MyMessageBox(pszMessage, "Error", wxOK | wxICON_ERROR);
|
||||
throw;
|
||||
//DebugBreak();
|
||||
}
|
||||
|
||||
11
util.h
11
util.h
@@ -121,6 +121,7 @@ extern bool fPrintToDebugger;
|
||||
extern char pszSetDataDir[MAX_PATH];
|
||||
extern bool fShutdown;
|
||||
extern bool fDaemon;
|
||||
extern bool fCommandLine;
|
||||
|
||||
void RandAddSeed();
|
||||
void RandAddSeedPerfmon();
|
||||
@@ -132,10 +133,12 @@ void PrintException(std::exception* pex, const char* pszThread);
|
||||
void LogException(std::exception* pex, const char* pszThread);
|
||||
void ParseString(const string& str, char c, vector<string>& v);
|
||||
string FormatMoney(int64 n, bool fPlus=false);
|
||||
bool ParseMoney(const string& str, int64& nRet);
|
||||
bool ParseMoney(const char* pszIn, int64& nRet);
|
||||
vector<unsigned char> ParseHex(const char* psz);
|
||||
vector<unsigned char> ParseHex(const std::string& str);
|
||||
void ParseParameters(int argc, char* argv[]);
|
||||
const char* wxGetTranslation(const char* psz);
|
||||
int GetFilesize(FILE* file);
|
||||
void GetDataDir(char* pszDirRet);
|
||||
string GetDataDir();
|
||||
@@ -340,11 +343,9 @@ void skipspaces(T& it)
|
||||
++it;
|
||||
}
|
||||
|
||||
inline const char* wxGetTranslation(const char* psz)
|
||||
{
|
||||
// Return translated UTF-8 const char*
|
||||
return wxGetTranslation(wxString(psz, wxConvUTF8)).utf8_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user