mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-29 03:16:40 +01:00
Compare commits
249 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d787e00a3b | ||
|
|
e6e87891a9 | ||
|
|
930a07c3f5 | ||
|
|
5a3e82f9f5 | ||
|
|
9cbae55a6e | ||
|
|
cf7c1874fe | ||
|
|
47908a8907 | ||
|
|
d2e2cb0d27 | ||
|
|
98ba262a48 | ||
|
|
bd7d9140f9 | ||
|
|
b1a657a00d | ||
|
|
d9711a5798 | ||
|
|
10abe4f26e | ||
|
|
84e7ad922b | ||
|
|
4698dd9a02 | ||
|
|
c90ea2bd6d | ||
|
|
fdec7fe203 | ||
|
|
18cb92ab18 | ||
|
|
86c0af514b | ||
|
|
2aadc8bb5b | ||
|
|
ae42d69d72 | ||
|
|
5284e1b60e | ||
|
|
05563e9ef2 | ||
|
|
458cf9070b | ||
|
|
245e1b4fdb | ||
|
|
87c1947d49 | ||
|
|
8b8d59eefb | ||
|
|
dbe79d3451 | ||
|
|
10152506fe | ||
|
|
aaac71d38f | ||
|
|
415535e47b | ||
|
|
3475caf8f5 | ||
|
|
f1307515b7 | ||
|
|
ab931be45b | ||
|
|
d9574c2f14 | ||
|
|
1d23c74361 | ||
|
|
0654e1c4ef | ||
|
|
ed4e8830d7 | ||
|
|
c9f70b381d | ||
|
|
b4671902f2 | ||
|
|
76e97c4002 | ||
|
|
1aefe491fb | ||
|
|
04a9217dcf | ||
|
|
fa446a563e | ||
|
|
2eb09b66ef | ||
|
|
80be6e69a9 | ||
|
|
009d5fb41f | ||
|
|
f86655fddd | ||
|
|
0ded557af6 | ||
|
|
72b9861635 | ||
|
|
5f88e8887a | ||
|
|
ddb68acebe | ||
|
|
2d96276e24 | ||
|
|
86c2bdfd5d | ||
|
|
cba3a1741a | ||
|
|
5568d82c26 | ||
|
|
1c0bf23ba2 | ||
|
|
8250760617 | ||
|
|
59948a6e1c | ||
|
|
55c43da5d8 | ||
|
|
809ee79592 | ||
|
|
629e37dde1 | ||
|
|
bc530fe89f | ||
|
|
fc73ad644f | ||
|
|
9c17a685bd | ||
|
|
986b5e257e | ||
|
|
97ee01ad89 | ||
|
|
d12e53ea09 | ||
|
|
0a87c91692 | ||
|
|
0575c0a667 | ||
|
|
6f8ba620c2 | ||
|
|
94073ecf7b | ||
|
|
262430f705 | ||
|
|
593f74b9cb | ||
|
|
2d8b65e837 | ||
|
|
11c570cfb4 | ||
|
|
8595d31ee8 | ||
|
|
a0cd439788 | ||
|
|
695aa2d5a2 | ||
|
|
5d4b0c9026 | ||
|
|
de374ba6b1 | ||
|
|
be7eecafd2 | ||
|
|
2ea321d85a | ||
|
|
07c46dac87 | ||
|
|
bcd88403e2 | ||
|
|
d1e4a866ad | ||
|
|
2bda554be4 | ||
|
|
cc8005b4e7 | ||
|
|
687c5ef794 | ||
|
|
7d5d89856d | ||
|
|
1b5e57e935 | ||
|
|
a2ae4a8a0f | ||
|
|
5ccee900a0 | ||
|
|
369010406e | ||
|
|
6ce5af574f | ||
|
|
81b2d877fb | ||
|
|
3764c12b1f | ||
|
|
8d13ca1f11 | ||
|
|
645cc8cf49 | ||
|
|
1c21b7943d | ||
|
|
6aeb45187b | ||
|
|
a43a7dfa58 | ||
|
|
fe37c35018 | ||
|
|
4b36f34d6d | ||
|
|
71cc095cb2 | ||
|
|
43e4a2a289 | ||
|
|
c8ad9b8375 | ||
|
|
41016bfc46 | ||
|
|
2323664a37 | ||
|
|
00728c24e7 | ||
|
|
90e165aa0c | ||
|
|
8555125a1a | ||
|
|
14002c8eba | ||
|
|
a2120986ff | ||
|
|
8c9479c6bb | ||
|
|
6690680538 | ||
|
|
2742fdfda2 | ||
|
|
343328c6b8 | ||
|
|
d3631907d6 | ||
|
|
87cfcfd374 | ||
|
|
522dfe3422 | ||
|
|
c545563d46 | ||
|
|
7a37c906a1 | ||
|
|
43deefa435 | ||
|
|
21ca2d833b | ||
|
|
bb3fd02930 | ||
|
|
c923cdbd5b | ||
|
|
019b456605 | ||
|
|
7d489192fd | ||
|
|
76793dc969 | ||
|
|
6ac7f9f144 | ||
|
|
2d12315c94 | ||
|
|
7f71fd13ae | ||
|
|
819adfff6f | ||
|
|
f5d2bc8a36 | ||
|
|
9db7bf5f52 | ||
|
|
410b618d18 | ||
|
|
c2fa70ddfd | ||
|
|
8a38d5663a | ||
|
|
dd9e71843b | ||
|
|
b34e8c3c36 | ||
|
|
73aa262647 | ||
|
|
e1cb7ce017 | ||
|
|
a75560d828 | ||
|
|
ec82517c89 | ||
|
|
31ffe954b6 | ||
|
|
872d60f6e4 | ||
|
|
2689f4d02b | ||
|
|
3dd20ff2f8 | ||
|
|
9f35575ca3 | ||
|
|
b6dc3b517b | ||
|
|
f0c11b1917 | ||
|
|
40cd036941 | ||
|
|
fe98cf8dc5 | ||
|
|
e96cd730d1 | ||
|
|
4110f33cde | ||
|
|
8e79c64750 | ||
|
|
05708fc63e | ||
|
|
9d2174b6f5 | ||
|
|
8bd66202c3 | ||
|
|
f32339e700 | ||
|
|
c8063ff034 | ||
|
|
cefe611ce5 | ||
|
|
a280b4e661 | ||
|
|
603c7ccea8 | ||
|
|
64f9370691 | ||
|
|
e2bf701454 | ||
|
|
c929529f9f | ||
|
|
6cc56d8e83 | ||
|
|
2adc9062d8 | ||
|
|
6970bd96d1 | ||
|
|
d63b0adabd | ||
|
|
bed3ad104e | ||
|
|
dbe23aadae | ||
|
|
a66d097cbe | ||
|
|
3ca507a6eb | ||
|
|
c58e10565e | ||
|
|
904ff7d07b | ||
|
|
d0ac235c8f | ||
|
|
78c7bb8e26 | ||
|
|
3b318ed095 | ||
|
|
d9dac6772f | ||
|
|
5fe8bc0b4d | ||
|
|
7a47324c78 | ||
|
|
9c1e9f0b6a | ||
|
|
240f3fbe2f | ||
|
|
288424ad63 | ||
|
|
91e615bfec | ||
|
|
9a33582204 | ||
|
|
8a46ed83cc | ||
|
|
5eede9d4d9 | ||
|
|
30158c77e9 | ||
|
|
ee618d7540 | ||
|
|
6ff4388ffa | ||
|
|
794298063d | ||
|
|
bcd2714038 | ||
|
|
f3cd4206b8 | ||
|
|
cc4b78d59f | ||
|
|
297a50a063 | ||
|
|
7271c7ff35 | ||
|
|
19765903dc | ||
|
|
22f721dbf2 | ||
|
|
73278c0a16 | ||
|
|
40d324f102 | ||
|
|
1c5d5e58c6 | ||
|
|
a43c00c569 | ||
|
|
2939cab06d | ||
|
|
9e56521b4b | ||
|
|
80264be428 | ||
|
|
95d839f15c | ||
|
|
9228c53cf5 | ||
|
|
2da02dd774 | ||
|
|
2ed2b9a3e4 | ||
|
|
bd336ba272 | ||
|
|
25b12b8839 | ||
|
|
433fb54b25 | ||
|
|
0bbbee96b7 | ||
|
|
ba0909e96a | ||
|
|
658b5b414a | ||
|
|
70918a6645 | ||
|
|
e4db374421 | ||
|
|
01fe1d2137 | ||
|
|
31e6ea7f5d | ||
|
|
e9c2b5c84d | ||
|
|
158ea66c6c | ||
|
|
1a01afab23 | ||
|
|
85c33b9602 | ||
|
|
93cfb02acb | ||
|
|
fba4088941 | ||
|
|
f7d3cc0e58 | ||
|
|
e66ec79b18 | ||
|
|
99142385da | ||
|
|
e874738d3d | ||
|
|
8938414f0c | ||
|
|
ae3ae3df76 | ||
|
|
7be46ce487 | ||
|
|
fc0e97a70e | ||
|
|
cc0b4c3b62 | ||
|
|
6ccefea62a | ||
|
|
44e1254d1c | ||
|
|
5210998688 | ||
|
|
c199b8499d | ||
|
|
f13dff6977 | ||
|
|
f01a4ca4e2 | ||
|
|
75aa0fbf70 | ||
|
|
d1b70ffa03 | ||
|
|
e00d4805d7 | ||
|
|
edffb50b98 | ||
|
|
4405b78d60 |
16
README.md
Normal file
16
README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
Bitcoin integration/staging tree
|
||||
|
||||
Development process
|
||||
===================
|
||||
|
||||
Developers work in their own trees, then submit pull requests when they think their feature or bug fix is ready.
|
||||
|
||||
If it is a simple/trivial/non-controversial change, then one of the bitcoin development team members simply pulls it.
|
||||
|
||||
If it is a more complicated or potentially controversial change, then the patch submitter will be asked to start a discussion (if they haven't already) on the development forums: http://www.bitcoin.org/smf/index.php?board=6.0
|
||||
The patch will be accepted if there is broad consensus that it is a good thing. Developers should expect to rework and resubmit patches if they don't match the project's coding conventions (see coding.txt) or are controversial.
|
||||
|
||||
The master branch is regularly built and tested (by who? need people willing to be quality assurance testers), and periodically pushed to the subversion repo to become the official, stable, released bitcoin.
|
||||
|
||||
|
||||
Feature branches are created when there are major new features being worked on by several people.
|
||||
100
build-msw.txt
100
build-msw.txt
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
Copyright (c) 2009-2011 Bitcoin Developers
|
||||
Distributed under the MIT/X11 software license, see the accompanying
|
||||
file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
This product includes software developed by the OpenSSL Project for use in
|
||||
@@ -11,23 +11,25 @@ WINDOWS BUILD NOTES
|
||||
|
||||
Compilers Supported
|
||||
-------------------
|
||||
MinGW GCC (recommended)
|
||||
http://tdm-gcc.tdragon.net/ has an easy installer. Go back a few versions
|
||||
for a little older gcc like gcc 4.4.?.
|
||||
MinGW GCC http://tdm-gcc.tdragon.net/
|
||||
TDM-GCC with gcc 4.5.1 was used to build this release.
|
||||
MSYS 1.0.11 was also used (sh needed to compile some dependencies)
|
||||
|
||||
MSVC 8.0 (2005) SP1 has been tested. Note: MSVC 7.0 and up have a habit of
|
||||
linking to runtime DLLs that are not installed on XP by default.
|
||||
|
||||
Candidate releases were built with MSVC 10.0 (2010), but
|
||||
compiling with Visual C++ caused rendering artifacts when
|
||||
bitcoin was run.
|
||||
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
Libraries you need to download separately and build:
|
||||
|
||||
default path download
|
||||
wxWidgets-2.9 \wxwidgets http://www.wxwidgets.org/downloads/
|
||||
OpenSSL \openssl http://www.openssl.org/source/
|
||||
Berkeley DB \db http://www.oracle.com/technology/software/products/berkeley-db/index.html
|
||||
Boost \boost http://www.boost.org/users/download/
|
||||
default path download
|
||||
wxWidgets \wxwidgets-2.9.1-mgw http://www.wxwidgets.org/downloads/
|
||||
OpenSSL \openssl-1.0.0c-mgw http://www.openssl.org/source/
|
||||
Berkeley DB \db-4.7.25.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html
|
||||
Boost \boost-1.43.0-mgw http://www.boost.org/users/download/
|
||||
|
||||
Their licenses:
|
||||
wxWidgets LGPL 2.1 with very liberal exceptions
|
||||
@@ -36,11 +38,10 @@ Berkeley DB New BSD license with additional requirement that linked software
|
||||
Boost MIT-like license
|
||||
|
||||
Versions used in this release:
|
||||
MinGW GCC 3.4.5
|
||||
wxWidgets 2.9.0
|
||||
OpenSSL 0.9.8k
|
||||
wxWidgets 2.9.1
|
||||
OpenSSL 1.0.0c
|
||||
Berkeley DB 4.7.25.NC
|
||||
Boost 1.42.1
|
||||
Boost 1.43.0
|
||||
|
||||
|
||||
Notes
|
||||
@@ -49,61 +50,50 @@ The UI layout is edited with wxFormBuilder. The project file is
|
||||
uiproject.fbp. It generates uibase.cpp and uibase.h, which define base
|
||||
classes that do the rote work of constructing all the UI elements.
|
||||
|
||||
The release is built with GCC and then "strip bitcoin.exe" to strip the debug
|
||||
symbols, which reduces the executable size by about 90%.
|
||||
|
||||
|
||||
wxWidgets
|
||||
---------
|
||||
cd \wxwidgets\build\msw
|
||||
make -f makefile.gcc
|
||||
or
|
||||
nmake -f makefile.vc
|
||||
|
||||
DOS shell:
|
||||
cd \wxWidgets-2.9.1-mgw\build\msw
|
||||
mingw32-make -f makefile.gcc
|
||||
|
||||
OpenSSL
|
||||
-------
|
||||
If you want to exclude unused optional algorithms, a few patches are required.
|
||||
(instructions for OpenSSL v0.9.8k)
|
||||
MSYS shell:
|
||||
un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)
|
||||
change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'
|
||||
|
||||
Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around
|
||||
the openssl/rsa.h include:
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
#include <openssl/rsa.h>
|
||||
#endif
|
||||
cd /c/openssl-1.0.0c-mgw
|
||||
./config
|
||||
make
|
||||
|
||||
Edit ms\mingw32.bat and replace the Configure line's parameters with this
|
||||
no-everything list. You have to put this in the batch file because batch
|
||||
files can't take more than nine command line parameters.
|
||||
perl Configure mingw threads no-rc2 no-rc4 no-rc5 no-idea no-des no-bf no-cast no-aes no-camellia no-seed no-rsa no-dh
|
||||
|
||||
Also REM out the following line in ms\mingw32.bat after the mingw32-make
|
||||
line. The build fails after it's already finished building libeay32, which
|
||||
is all we care about, but the failure aborts the script before it runs
|
||||
dllwrap to generate libeay32.dll.
|
||||
REM if errorlevel 1 goto end
|
||||
|
||||
Build
|
||||
cd \openssl
|
||||
ms\mingw32.bat
|
||||
|
||||
If you're using MSVC, generate the .lib file
|
||||
lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib
|
||||
perl util/mkdef.pl 32 libeay enable-static-engine > libeay32.def
|
||||
dllwrap --dllname libeay32.dll --output-lib libeay32.a --def libeay32.def libcrypto.a -lws2_32 -lgdi32
|
||||
|
||||
after that openssl libeay is in main source dir (openssl-1.0.0c-mgw)
|
||||
|
||||
Berkeley DB
|
||||
-----------
|
||||
Using MinGW and MSYS:
|
||||
cd \db\build_unix
|
||||
MSYS shell:
|
||||
cd /c/db-4.7.25.NC-mgw/build_unix
|
||||
sh ../dist/configure --enable-mingw --enable-cxx
|
||||
make
|
||||
|
||||
|
||||
Boost
|
||||
-----
|
||||
download bjam.exe from
|
||||
http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941
|
||||
cd \boost
|
||||
DOS prompt:
|
||||
downloaded boost jam 3.1.18
|
||||
cd \boost-1.43.0-mgw
|
||||
bjam toolset=gcc --build-type=complete stage
|
||||
or
|
||||
bjam toolset=msvc --build-type=complete stage
|
||||
|
||||
Note:
|
||||
building with boost 1.45.0 failed because of boost ticket 4614, 4258
|
||||
builds fine with boost 1.43.0
|
||||
|
||||
Bitcoin
|
||||
-------
|
||||
DOS prompt:
|
||||
cd \bitcoin
|
||||
mingw32-make bitcoin.exe bitcoind.exe -f makefile.mingw
|
||||
strip bitcoin.exe
|
||||
strip bitcoind.exe
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
Copyright (c) 2010 Laszlo Hanyecz
|
||||
Distributed under the MIT/X11 software license, see the accompanying
|
||||
file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
This product includes software developed by the OpenSSL Project for use in
|
||||
|
||||
@@ -9,6 +9,14 @@ cryptographic software written by Eric Young (eay@cryptsoft.com).
|
||||
UNIX BUILD NOTES
|
||||
================
|
||||
|
||||
To Build
|
||||
--------
|
||||
|
||||
make -f makefile.unix # Bitcoin with wxWidgets GUI
|
||||
or
|
||||
make -f makefile.unix bitcoind # Headless bitcoin
|
||||
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
sudo apt-get install build-essential
|
||||
|
||||
2
cryptopp/obj/.gitignore
vendored
Normal file
2
cryptopp/obj/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
16
db.cpp
16
db.cpp
@@ -592,9 +592,9 @@ bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account)
|
||||
return Write(make_pair(string("acc"), strAccount), account);
|
||||
}
|
||||
|
||||
bool CWalletDB::WriteAccountingEntry(const string& strAccount, const CAccountingEntry& acentry)
|
||||
bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry)
|
||||
{
|
||||
return Write(make_tuple(string("acentry"), strAccount, ++nAccountingEntryNumber), acentry);
|
||||
return Write(make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry);
|
||||
}
|
||||
|
||||
int64 CWalletDB::GetAccountCreditDebit(const string& strAccount)
|
||||
@@ -613,6 +613,8 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
|
||||
{
|
||||
int64 nCreditDebit = 0;
|
||||
|
||||
bool fAllAccounts = (strAccount == "*");
|
||||
|
||||
Dbc* pcursor = GetCursor();
|
||||
if (!pcursor)
|
||||
throw runtime_error("CWalletDB::ListAccountCreditDebit() : cannot create DB cursor");
|
||||
@@ -622,7 +624,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
|
||||
// Read next record
|
||||
CDataStream ssKey;
|
||||
if (fFlags == DB_SET_RANGE)
|
||||
ssKey << make_tuple(string("acentry"), strAccount, uint64(0));
|
||||
ssKey << make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0));
|
||||
CDataStream ssValue;
|
||||
int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
|
||||
fFlags = DB_NEXT;
|
||||
@@ -639,12 +641,11 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
|
||||
ssKey >> strType;
|
||||
if (strType != "acentry")
|
||||
break;
|
||||
string strAccountName;
|
||||
ssKey >> strAccountName;
|
||||
if (strAccountName != strAccount)
|
||||
CAccountingEntry acentry;
|
||||
ssKey >> acentry.strAccount;
|
||||
if (!fAllAccounts && acentry.strAccount != strAccount)
|
||||
break;
|
||||
|
||||
CAccountingEntry acentry;
|
||||
ssValue >> acentry;
|
||||
entries.push_back(acentry);
|
||||
}
|
||||
@@ -652,6 +653,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
|
||||
pcursor->close();
|
||||
}
|
||||
|
||||
|
||||
bool CWalletDB::LoadWallet()
|
||||
{
|
||||
vchDefaultKey.clear();
|
||||
|
||||
2
db.h
2
db.h
@@ -433,7 +433,7 @@ public:
|
||||
|
||||
bool ReadAccount(const string& strAccount, CAccount& account);
|
||||
bool WriteAccount(const string& strAccount, const CAccount& account);
|
||||
bool WriteAccountingEntry(const string& strAccount, const CAccountingEntry& acentry);
|
||||
bool WriteAccountingEntry(const CAccountingEntry& acentry);
|
||||
int64 GetAccountCreditDebit(const string& strAccount);
|
||||
void ListAccountCreditDebit(const string& strAccount, list<CAccountingEntry>& acentries);
|
||||
|
||||
|
||||
38
init.cpp
38
init.cpp
@@ -158,7 +158,9 @@ bool AppInit2(int argc, char* argv[])
|
||||
|
||||
if (mapArgs.count("-?") || mapArgs.count("--help"))
|
||||
{
|
||||
string beta = VERSION_IS_BETA ? _(" beta") : "";
|
||||
string strUsage = string() +
|
||||
_("Bitcoin version") + " " + FormatVersion(VERSION) + pszSubVer + beta + "\n\n" +
|
||||
_("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +
|
||||
" bitcoin [options] \t " + "\n" +
|
||||
" bitcoin [options] <command> [params]\t " + _("Send command to -server or bitcoind\n") +
|
||||
@@ -173,23 +175,26 @@ bool AppInit2(int argc, char* argv[])
|
||||
" -proxy=<ip:port> \t " + _("Connect through socks4 proxy\n") +
|
||||
" -addnode=<ip> \t " + _("Add a node to connect to\n") +
|
||||
" -connect=<ip> \t\t " + _("Connect only to the specified node\n") +
|
||||
" -nolisten \t " + _("Don't accept connections from outside") +
|
||||
" -paytxfee=<amt> \t " + _("Fee per KB to add to transactions you send\n") +
|
||||
" -server \t\t " + _("Accept command line and JSON-RPC commands\n") +
|
||||
" -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +
|
||||
" -testnet \t\t " + _("Use the test network\n") +
|
||||
" -rpcuser=<user> \t " + _("Username for JSON-RPC connections\n") +
|
||||
" -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections\n") +
|
||||
" -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port>\n") +
|
||||
" -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port> (default: 8332)\n") +
|
||||
" -rpcallowip=<ip> \t\t " + _("Allow JSON-RPC connections from specified IP address\n") +
|
||||
" -rpcconnect=<ip> \t " + _("Send commands to node running on <ip>\n");
|
||||
" -rpcconnect=<ip> \t " + _("Send commands to node running on <ip> (default: 127.0.0.1)\n") +
|
||||
" -keypool=<n> \t " + _("Set key pool size to <n> (default: 100)\n") +
|
||||
" -rescan \t " + _("Rescan the block chain for missing wallet transactions\n");
|
||||
|
||||
#ifdef USE_SSL
|
||||
strUsage += string() +
|
||||
_("\nSSL options: (see the Bitcoin Wiki for SSL setup instructions)\n") +
|
||||
" -rpcssl=1 \t " + _("Use OpenSSL (https) for JSON-RPC connections\n") +
|
||||
" -rpcsslcertificatchainfile=<file.cert>\t " + _("Server certificate file (default: server.cert)\n") +
|
||||
" -rpcsslprivatekeyfile=<file.pem> \t " + _("Server private key (default: server.pem)\n") +
|
||||
" -rpcsslciphers=<ciphers> \t " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n");
|
||||
" -rpcssl \t " + _("Use OpenSSL (https) for JSON-RPC connections\n") +
|
||||
" -rpcsslcertificatechainfile=<file.cert>\t " + _("Server certificate file (default: server.cert)\n") +
|
||||
" -rpcsslprivatekeyfile=<file.pem> \t " + _("Server private key (default: server.pem)\n") +
|
||||
" -rpcsslciphers=<ciphers> \t " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n");
|
||||
#endif
|
||||
|
||||
strUsage += string() +
|
||||
@@ -208,9 +213,12 @@ bool AppInit2(int argc, char* argv[])
|
||||
|
||||
fDebug = GetBoolArg("-debug");
|
||||
|
||||
fPrintToConsole = GetBoolArg("-printtoconsole");
|
||||
fPrintToDebugger = GetBoolArg("-printtodebugger");
|
||||
|
||||
fTestNet = GetBoolArg("-testnet");
|
||||
|
||||
fNoListen = GetBoolArg("-nolisten");
|
||||
|
||||
if (fCommandLine)
|
||||
{
|
||||
@@ -221,7 +229,7 @@ bool AppInit2(int argc, char* argv[])
|
||||
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 %s%s beta\n", FormatVersion(VERSION).c_str(), pszSubVer);
|
||||
printf("Bitcoin version %s%s%s\n", FormatVersion(VERSION).c_str(), pszSubVer, VERSION_IS_BETA ? _(" beta") : "");
|
||||
#ifdef GUI
|
||||
printf("OS version %s\n", ((string)wxGetOsDescription()).c_str());
|
||||
printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str());
|
||||
@@ -290,10 +298,13 @@ bool AppInit2(int argc, char* argv[])
|
||||
|
||||
// Bind to the port early so we can tell if another instance is already running.
|
||||
string strErrors;
|
||||
if (!BindListenPort(strErrors))
|
||||
if (!fNoListen)
|
||||
{
|
||||
wxMessageBox(strErrors, "Bitcoin");
|
||||
return false;
|
||||
if (!BindListenPort(strErrors))
|
||||
{
|
||||
wxMessageBox(strErrors, "Bitcoin");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -323,6 +334,13 @@ bool AppInit2(int argc, char* argv[])
|
||||
strErrors += _("Error loading wallet.dat \n");
|
||||
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
if (GetBoolArg("-rescan"))
|
||||
{
|
||||
nStart = GetTimeMillis();
|
||||
ScanForWalletTransactions(pindexGenesisBlock);
|
||||
printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
|
||||
}
|
||||
|
||||
printf("Done loading\n");
|
||||
|
||||
//// debug print
|
||||
|
||||
14
irc.cpp
14
irc.cpp
@@ -5,6 +5,7 @@
|
||||
#include "headers.h"
|
||||
|
||||
int nGotIRCAddresses = 0;
|
||||
bool fGotExternalIP = false;
|
||||
|
||||
void ThreadIRCSeed2(void* parg);
|
||||
|
||||
@@ -223,6 +224,8 @@ bool GetIPFromIRC(SOCKET hSocket, string strMyName, unsigned int& ipRet)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hybrid IRC used by lfnet always returns IP when you userhost yourself,
|
||||
// but in case another IRC is ever used this should work.
|
||||
printf("GetIPFromIRC() got userhost %s\n", strHost.c_str());
|
||||
if (fUseProxy)
|
||||
return false;
|
||||
@@ -254,8 +257,10 @@ void ThreadIRCSeed(void* parg)
|
||||
|
||||
void ThreadIRCSeed2(void* parg)
|
||||
{
|
||||
if (mapArgs.count("-connect"))
|
||||
/* Dont advertise on IRC if we don't allow incoming connections */
|
||||
if (mapArgs.count("-connect") || fNoListen)
|
||||
return;
|
||||
|
||||
if (GetBoolArg("-noirc"))
|
||||
return;
|
||||
printf("ThreadIRCSeed started\n");
|
||||
@@ -327,14 +332,15 @@ void ThreadIRCSeed2(void* parg)
|
||||
}
|
||||
Sleep(500);
|
||||
|
||||
// Get my external IP from IRC server
|
||||
// Get our external IP from the IRC server and re-nick before joining the channel
|
||||
CAddress addrFromIRC;
|
||||
if (GetIPFromIRC(hSocket, strMyName, addrFromIRC.ip))
|
||||
{
|
||||
// Just using it as a backup for now
|
||||
printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToStringIP().c_str());
|
||||
if (addrFromIRC.IsRoutable() && !fUseProxy && !addrLocalHost.IsRoutable())
|
||||
if (!fUseProxy && addrFromIRC.IsRoutable())
|
||||
{
|
||||
// IRC lets you to re-nick
|
||||
fGotExternalIP = true;
|
||||
addrLocalHost.ip = addrFromIRC.ip;
|
||||
strMyName = EncodeAddress(addrLocalHost);
|
||||
Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str());
|
||||
|
||||
1
irc.h
1
irc.h
@@ -6,3 +6,4 @@ bool RecvLine(SOCKET hSocket, string& strLine);
|
||||
void ThreadIRCSeed(void* parg);
|
||||
|
||||
extern int nGotIRCAddresses;
|
||||
extern bool fGotExternalIP;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
Copyright (c) 2009-2010 Bitcoin Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
Binary file not shown.
@@ -321,8 +321,8 @@ msgstr "Beim schließen &Minimieren"
|
||||
|
||||
#: ../../../ui.cpp:1595
|
||||
#, c-format
|
||||
msgid "version %s%s beta"
|
||||
msgstr "Version %s%s Beta"
|
||||
msgid "version %s%s BETA"
|
||||
msgstr "Version %s%s BETA"
|
||||
|
||||
#: ../../../ui.cpp:1681
|
||||
msgid "Will appear as \"From: Unknown\""
|
||||
@@ -698,7 +698,7 @@ msgstr "Version"
|
||||
|
||||
#: ../../../uibase.cpp:563
|
||||
msgid ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"This is experimental software.\n"
|
||||
"\n"
|
||||
@@ -709,7 +709,7 @@ msgid ""
|
||||
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
|
||||
"Eric Young (eay@cryptsoft.com)."
|
||||
msgstr ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"Dies ist experimentelle Software.\n"
|
||||
"\n"
|
||||
|
||||
Binary file not shown.
@@ -350,8 +350,8 @@ msgstr "&Minimizar al cerrar"
|
||||
|
||||
#: ../../../ui.cpp:1610
|
||||
#, c-format
|
||||
msgid "version %s%s beta"
|
||||
msgstr "version %s%s beta"
|
||||
msgid "version %s%s BETA"
|
||||
msgstr "version %s%s BETA"
|
||||
|
||||
#: ../../../ui.cpp:1696
|
||||
msgid "Will appear as \"From: Unknown\""
|
||||
@@ -727,7 +727,7 @@ msgstr "version"
|
||||
|
||||
#: ../../../uibase.cpp:557
|
||||
msgid ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"This is experimental software.\n"
|
||||
"\n"
|
||||
@@ -738,7 +738,7 @@ msgid ""
|
||||
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
|
||||
"Eric Young (eay@cryptsoft.com)."
|
||||
msgstr ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"Este es un software experimental.\n"
|
||||
"\n"
|
||||
|
||||
Binary file not shown.
@@ -351,8 +351,8 @@ msgstr "&Réduire à la fermeture"
|
||||
|
||||
#: ../../../ui.cpp:1610
|
||||
#, c-format
|
||||
msgid "version %s%s beta"
|
||||
msgstr "version %s%s beta"
|
||||
msgid "version %s%s BETA"
|
||||
msgstr "version %s%s BETA"
|
||||
|
||||
#: ../../../ui.cpp:1696
|
||||
msgid "Will appear as \"From: Unknown\""
|
||||
@@ -730,7 +730,7 @@ msgstr "version"
|
||||
|
||||
#: ../../../uibase.cpp:557
|
||||
msgid ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"This is experimental software.\n"
|
||||
"\n"
|
||||
@@ -741,7 +741,7 @@ msgid ""
|
||||
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
|
||||
"Eric Young (eay@cryptsoft.com)."
|
||||
msgstr ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"Ceci est un logiciel expérimental.\n"
|
||||
"\n"
|
||||
|
||||
Binary file not shown.
@@ -319,8 +319,8 @@ msgstr "&Minimizza se chiuso"
|
||||
|
||||
#: ../../../ui.cpp:1595
|
||||
#, c-format
|
||||
msgid "version %s%s beta"
|
||||
msgstr "versione %s%s beta"
|
||||
msgid "version %s%s BETA"
|
||||
msgstr "versione %s%s BETA"
|
||||
|
||||
#: ../../../ui.cpp:1681
|
||||
msgid "Will appear as \"From: Unknown\""
|
||||
@@ -696,7 +696,7 @@ msgstr "versione"
|
||||
|
||||
#: ../../../uibase.cpp:563
|
||||
msgid ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"This is experimental software.\n"
|
||||
"\n"
|
||||
@@ -707,7 +707,7 @@ msgid ""
|
||||
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
|
||||
"Eric Young (eay@cryptsoft.com)."
|
||||
msgstr ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"Questo è un software sperimentale.\n"
|
||||
"\n"
|
||||
|
||||
Binary file not shown.
@@ -320,8 +320,8 @@ msgstr "&Minimalizeer bij sluiten"
|
||||
|
||||
#: ../../../ui.cpp:1595
|
||||
#, c-format
|
||||
msgid "version %s%s beta"
|
||||
msgstr "versie %s%s beta"
|
||||
msgid "version %s%s BETA"
|
||||
msgstr "versie %s%s BETA"
|
||||
|
||||
#: ../../../ui.cpp:1681
|
||||
msgid "Will appear as \"From: Unknown\""
|
||||
@@ -697,7 +697,7 @@ msgstr "versie"
|
||||
|
||||
#: ../../../uibase.cpp:563
|
||||
msgid ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"This is experimental software.\n"
|
||||
"\n"
|
||||
@@ -708,7 +708,7 @@ msgid ""
|
||||
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
|
||||
"Eric Young (eay@cryptsoft.com)."
|
||||
msgstr ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"Dit is experimentele software.\n"
|
||||
"\n"
|
||||
|
||||
Binary file not shown.
@@ -319,8 +319,8 @@ msgstr "&Minimizar ao fechar"
|
||||
|
||||
#: ../../../ui.cpp:1595
|
||||
#, c-format
|
||||
msgid "version %s%s beta"
|
||||
msgstr "versão %s%s beta"
|
||||
msgid "version %s%s BETA"
|
||||
msgstr "versão %s%s BETA"
|
||||
|
||||
#: ../../../ui.cpp:1681
|
||||
msgid "Will appear as \"From: Unknown\""
|
||||
@@ -696,7 +696,7 @@ msgstr "versão"
|
||||
|
||||
#: ../../../uibase.cpp:563
|
||||
msgid ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"This is experimental software.\n"
|
||||
"\n"
|
||||
@@ -707,7 +707,7 @@ msgid ""
|
||||
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
|
||||
"Eric Young (eay@cryptsoft.com)."
|
||||
msgstr ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"Este software é experimental.\n"
|
||||
"\n"
|
||||
|
||||
Binary file not shown.
@@ -383,7 +383,7 @@ msgstr "&Сворачивать при закрытии"
|
||||
|
||||
#: ../../../ui.cpp:1798
|
||||
#, c-format
|
||||
msgid "version %s%s beta"
|
||||
msgid "version %s%s BETA"
|
||||
msgstr "версия %s%s бета"
|
||||
|
||||
#: ../../../ui.cpp:1884
|
||||
@@ -760,7 +760,7 @@ msgstr "версия"
|
||||
|
||||
#: ../../../uibase.cpp:557
|
||||
msgid ""
|
||||
"Copyright (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Copyright (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"This is experimental software.\n"
|
||||
"\n"
|
||||
@@ -771,7 +771,7 @@ msgid ""
|
||||
"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n"
|
||||
"Eric Young (eay@cryptsoft.com)."
|
||||
msgstr ""
|
||||
"Все права защищены (c) 2009-2010 Satoshi Nakamoto.\n"
|
||||
"Все права защищены (c) 2009-2010 Bitcoin Developers\n"
|
||||
"\n"
|
||||
"Это экспериментальное ПО.\n"
|
||||
"\n"
|
||||
|
||||
234
main.cpp
234
main.cpp
@@ -187,6 +187,19 @@ bool AddToWalletIfMine(const CTransaction& tx, const CBlock* pblock)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AddToWalletIfFromMe(const CTransaction& tx, const CBlock* pblock)
|
||||
{
|
||||
if (tx.IsFromMe() || mapWallet.count(tx.GetHash()))
|
||||
{
|
||||
CWalletTx wtx(tx);
|
||||
// Get merkle branch if transaction was found in a block
|
||||
if (pblock)
|
||||
wtx.SetMerkleBranch(pblock);
|
||||
return AddToWallet(wtx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EraseFromWallet(uint256 hash)
|
||||
{
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
@@ -394,6 +407,98 @@ int CWalletTx::GetRequestCount() const
|
||||
return nRequests;
|
||||
}
|
||||
|
||||
void CWalletTx::GetAmounts(int64& nGenerated, list<pair<string, int64> >& listReceived,
|
||||
list<pair<string, int64> >& listSent, int64& nFee, string& strSentAccount) const
|
||||
{
|
||||
nGenerated = nFee = 0;
|
||||
listReceived.clear();
|
||||
listSent.clear();
|
||||
strSentAccount = strFromAccount;
|
||||
|
||||
if (IsCoinBase())
|
||||
{
|
||||
if (GetDepthInMainChain() >= COINBASE_MATURITY)
|
||||
nGenerated = GetCredit();
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute fee:
|
||||
int64 nDebit = GetDebit();
|
||||
if (nDebit > 0) // debit>0 means we signed/sent this transaction
|
||||
{
|
||||
int64 nValueOut = GetValueOut();
|
||||
nFee = nDebit - nValueOut;
|
||||
}
|
||||
|
||||
// Sent/received. Standard client will never generate a send-to-multiple-recipients,
|
||||
// but non-standard clients might (so return a list of address/amount pairs)
|
||||
foreach(const CTxOut& txout, vout)
|
||||
{
|
||||
string address;
|
||||
uint160 hash160;
|
||||
vector<unsigned char> vchPubKey;
|
||||
if (ExtractHash160(txout.scriptPubKey, hash160))
|
||||
address = Hash160ToAddress(hash160);
|
||||
else if (ExtractPubKey(txout.scriptPubKey, false, vchPubKey))
|
||||
address = PubKeyToAddress(vchPubKey);
|
||||
else
|
||||
{
|
||||
printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
|
||||
this->GetHash().ToString().c_str());
|
||||
address = " unknown ";
|
||||
}
|
||||
|
||||
// Don't report 'change' txouts
|
||||
if (nDebit > 0 && txout.IsChange())
|
||||
continue;
|
||||
|
||||
if (nDebit > 0)
|
||||
listSent.push_back(make_pair(address, txout.nValue));
|
||||
|
||||
if (txout.IsMine())
|
||||
listReceived.push_back(make_pair(address, txout.nValue));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived,
|
||||
int64& nSent, int64& nFee) const
|
||||
{
|
||||
nGenerated = nReceived = nSent = nFee = 0;
|
||||
|
||||
int64 allGenerated, allFee;
|
||||
allGenerated = allFee = 0;
|
||||
string strSentAccount;
|
||||
list<pair<string, int64> > listReceived;
|
||||
list<pair<string, int64> > listSent;
|
||||
GetAmounts(allGenerated, listReceived, listSent, allFee, strSentAccount);
|
||||
|
||||
if (strAccount == "")
|
||||
nGenerated = allGenerated;
|
||||
if (strAccount == strSentAccount)
|
||||
{
|
||||
foreach(const PAIRTYPE(string,int64)& s, listSent)
|
||||
nSent += s.second;
|
||||
nFee = allFee;
|
||||
}
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
foreach(const PAIRTYPE(string,int64)& r, listReceived)
|
||||
{
|
||||
if (mapAddressBook.count(r.first))
|
||||
{
|
||||
if (mapAddressBook[r.first] == strAccount)
|
||||
{
|
||||
nReceived += r.second;
|
||||
}
|
||||
}
|
||||
else if (strAccount.empty())
|
||||
{
|
||||
nReceived += r.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -571,10 +676,15 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
|
||||
if ((int64)nLockTime > INT_MAX)
|
||||
return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet");
|
||||
|
||||
// Rather not work on nonstandard transactions
|
||||
if (!IsStandard() || GetSigOpCount() > 2 || ::GetSerializeSize(*this, SER_NETWORK) < 100)
|
||||
// Safety limits
|
||||
unsigned int nSize = ::GetSerializeSize(*this, SER_NETWORK);
|
||||
if (GetSigOpCount() > 2 || nSize < 100)
|
||||
return error("AcceptToMemoryPool() : nonstandard transaction");
|
||||
|
||||
// Rather not work on nonstandard transactions
|
||||
if (!IsStandard())
|
||||
return error("AcceptToMemoryPool() : nonstandard transaction type");
|
||||
|
||||
// Do we already have it?
|
||||
uint256 hash = GetHash();
|
||||
CRITICAL_BLOCK(cs_mapTransactions)
|
||||
@@ -612,14 +722,36 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
|
||||
}
|
||||
}
|
||||
|
||||
// Check against previous transactions
|
||||
map<uint256, CTxIndex> mapUnused;
|
||||
int64 nFees = 0;
|
||||
if (fCheckInputs && !ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false))
|
||||
if (fCheckInputs)
|
||||
{
|
||||
if (pfMissingInputs)
|
||||
*pfMissingInputs = true;
|
||||
return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str());
|
||||
// Check against previous transactions
|
||||
map<uint256, CTxIndex> mapUnused;
|
||||
int64 nFees = 0;
|
||||
if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false))
|
||||
{
|
||||
if (pfMissingInputs)
|
||||
*pfMissingInputs = true;
|
||||
return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str());
|
||||
}
|
||||
|
||||
// Don't accept it if it can't get into a block
|
||||
if (nFees < GetMinFee(1000))
|
||||
return error("AcceptToMemoryPool() : not enough fees");
|
||||
|
||||
// Limit free transactions per 10 minutes
|
||||
if (nFees < CENT && GetBoolArg("-limitfreerelay"))
|
||||
{
|
||||
static int64 nNextReset;
|
||||
static int64 nFreeCount;
|
||||
if (GetTime() > nNextReset)
|
||||
{
|
||||
nNextReset = GetTime() + 10 * 60;
|
||||
nFreeCount = 0;
|
||||
}
|
||||
if (nFreeCount > 150000 && !IsFromMe())
|
||||
return error("AcceptToMemoryPool() : free transaction rejected by rate limiter");
|
||||
nFreeCount += nSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Store transaction in memory
|
||||
@@ -746,11 +878,50 @@ bool CWalletTx::AcceptWalletTransaction(CTxDB& txdb, bool fCheckInputs)
|
||||
return false;
|
||||
}
|
||||
|
||||
int ScanForWalletTransactions(CBlockIndex* pindexStart)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
CBlockIndex* pindex = pindexStart;
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
while (pindex)
|
||||
{
|
||||
CBlock block;
|
||||
block.ReadFromDisk(pindex, true);
|
||||
foreach(CTransaction& tx, block.vtx)
|
||||
{
|
||||
uint256 hash = tx.GetHash();
|
||||
if (mapWallet.count(hash)) continue;
|
||||
AddToWalletIfMine(tx, &block);
|
||||
if (mapWallet.count(hash))
|
||||
{
|
||||
++ret;
|
||||
printf("Added missing RECEIVE %s\n", hash.ToString().c_str());
|
||||
continue;
|
||||
}
|
||||
AddToWalletIfFromMe(tx, &block);
|
||||
if (mapWallet.count(hash))
|
||||
{
|
||||
++ret;
|
||||
printf("Added missing SEND %s\n", hash.ToString().c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pindex = pindex->pnext;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ReacceptWalletTransactions()
|
||||
{
|
||||
CTxDB txdb("r");
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
bool fRepeat = true;
|
||||
while (fRepeat) CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
fRepeat = false;
|
||||
vector<CDiskTxPos> vMissingTx;
|
||||
foreach(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
||||
{
|
||||
CWalletTx& wtx = item.second;
|
||||
@@ -772,12 +943,15 @@ void ReacceptWalletTransactions()
|
||||
{
|
||||
if (!txindex.vSpent[i].IsNull() && wtx.vout[i].IsMine())
|
||||
{
|
||||
printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
|
||||
wtx.fSpent = true;
|
||||
wtx.WriteToDisk();
|
||||
break;
|
||||
vMissingTx.push_back(txindex.vSpent[i]);
|
||||
}
|
||||
}
|
||||
if (wtx.fSpent)
|
||||
{
|
||||
printf("ReacceptWalletTransactions found spent coin %sbc %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str());
|
||||
wtx.WriteToDisk();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -787,6 +961,12 @@ void ReacceptWalletTransactions()
|
||||
wtx.AcceptWalletTransaction(txdb, false);
|
||||
}
|
||||
}
|
||||
if (!vMissingTx.empty())
|
||||
{
|
||||
// TODO: optimize this to scan just part of the block chain?
|
||||
if (ScanForWalletTransactions(pindexGenesisBlock))
|
||||
fRepeat = true; // Found missing transactions: re-do Reaccept.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,7 +1144,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
|
||||
|
||||
bool IsInitialBlockDownload()
|
||||
{
|
||||
if (pindexBest == NULL || (!fTestNet && nBestHeight < 74000))
|
||||
if (pindexBest == NULL || (!fTestNet && nBestHeight < 105000))
|
||||
return true;
|
||||
static int64 nLastUpdate;
|
||||
static CBlockIndex* pindexLastBest;
|
||||
@@ -1258,8 +1438,6 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||
{
|
||||
printf("REORGANIZE\n");
|
||||
@@ -1527,11 +1705,12 @@ bool CBlock::AcceptBlock()
|
||||
|
||||
// Check that the block chain matches the known block chain up to a checkpoint
|
||||
if (!fTestNet)
|
||||
if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||
|
||||
(nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||
|
||||
(nHeight == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) ||
|
||||
(nHeight == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) ||
|
||||
(nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")))
|
||||
if ((nHeight == 11111 && hash != uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")) ||
|
||||
(nHeight == 33333 && hash != uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")) ||
|
||||
(nHeight == 68555 && hash != uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a")) ||
|
||||
(nHeight == 70567 && hash != uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a")) ||
|
||||
(nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) ||
|
||||
(nHeight == 105000 && hash != uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")))
|
||||
return error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight);
|
||||
|
||||
// Write block to history file
|
||||
@@ -1548,7 +1727,7 @@ bool CBlock::AcceptBlock()
|
||||
if (hashBestChain == hash)
|
||||
CRITICAL_BLOCK(cs_vNodes)
|
||||
foreach(CNode* pnode, vNodes)
|
||||
if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 55000))
|
||||
if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 105000))
|
||||
pnode->PushInventory(CInv(MSG_BLOCK, hash));
|
||||
|
||||
return true;
|
||||
@@ -1719,7 +1898,7 @@ bool LoadBlockIndex(bool fAllowNew)
|
||||
{
|
||||
if (fTestNet)
|
||||
{
|
||||
hashGenesisBlock = uint256("0x0000000224b1593e3ff16a0e3b61285bbc393a39f78c8aa48c456142671f7110");
|
||||
hashGenesisBlock = uint256("0x00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008");
|
||||
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 28);
|
||||
pchMessageStart[0] = 0xfa;
|
||||
pchMessageStart[1] = 0xbf;
|
||||
@@ -1769,9 +1948,9 @@ bool LoadBlockIndex(bool fAllowNew)
|
||||
|
||||
if (fTestNet)
|
||||
{
|
||||
block.nTime = 1279232055;
|
||||
block.nTime = 1296688602;
|
||||
block.nBits = 0x1d07fff8;
|
||||
block.nNonce = 81622180;
|
||||
block.nNonce = 384568319;
|
||||
}
|
||||
|
||||
//// debug print
|
||||
@@ -1926,7 +2105,6 @@ string GetWarnings(string strFor)
|
||||
{
|
||||
nPriority = alert.nPriority;
|
||||
strStatusBar = alert.strStatusBar;
|
||||
strRPC = alert.strRPCError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2950,7 +3128,7 @@ void CallCPUID(int in, int& aret, int& cret)
|
||||
"mov %%ecx, %1;" // ecx into c
|
||||
:"=r"(a),"=r"(c) /* output */
|
||||
:"r"(in) /* input */
|
||||
:"%eax","%ecx" /* clobbered register */
|
||||
:"%eax","%ebx","%ecx","%edx" /* clobbered register */
|
||||
);
|
||||
aret = a;
|
||||
cret = c;
|
||||
@@ -3353,7 +3531,7 @@ void BitcoinMiner()
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
bool f4WaySSE2 = Detect128BitSSE2();
|
||||
if (mapArgs.count("-4way"))
|
||||
f4WaySSE2 = GetBoolArg(mapArgs["-4way"]);
|
||||
f4WaySSE2 = GetBoolArg("-4way");
|
||||
|
||||
// Each thread has its own key and counter
|
||||
CReserveKey reservekey;
|
||||
|
||||
49
main.h
49
main.h
@@ -69,6 +69,7 @@ bool AddKey(const CKey& key);
|
||||
vector<unsigned char> GenerateNewKey();
|
||||
bool AddToWallet(const CWalletTx& wtxIn);
|
||||
void WalletUpdateSpent(const COutPoint& prevout);
|
||||
int ScanForWalletTransactions(CBlockIndex* pindexStart);
|
||||
void ReacceptWalletTransactions();
|
||||
bool LoadBlockIndex(bool fAllowNew=true);
|
||||
void PrintBlockTree();
|
||||
@@ -873,36 +874,11 @@ public:
|
||||
return nChangeCached;
|
||||
}
|
||||
|
||||
void GetAccountAmounts(string strAccount, const set<CScript>& setPubKey,
|
||||
int64& nGenerated, int64& nReceived, int64& nSent, int64& nFee) const
|
||||
{
|
||||
nGenerated = nReceived = nSent = nFee = 0;
|
||||
void GetAmounts(int64& nGenerated, list<pair<string /* address */, int64> >& listReceived,
|
||||
list<pair<string /* address */, int64> >& listSent, int64& nFee, string& strSentAccount) const;
|
||||
|
||||
// Generated blocks count to account ""
|
||||
if (IsCoinBase())
|
||||
{
|
||||
if (strAccount == "" && GetBlocksToMaturity() == 0)
|
||||
nGenerated = GetCredit();
|
||||
return;
|
||||
}
|
||||
|
||||
// Received
|
||||
foreach(const CTxOut& txout, vout)
|
||||
if (setPubKey.count(txout.scriptPubKey))
|
||||
nReceived += txout.nValue;
|
||||
|
||||
// Sent
|
||||
if (strFromAccount == strAccount)
|
||||
{
|
||||
int64 nDebit = GetDebit();
|
||||
if (nDebit > 0)
|
||||
{
|
||||
int64 nValueOut = GetValueOut();
|
||||
nFee = nDebit - nValueOut;
|
||||
nSent = nValueOut - GetChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
void GetAccountAmounts(const string& strAccount, int64& nGenerated, int64& nReceived,
|
||||
int64& nSent, int64& nFee) const;
|
||||
|
||||
bool IsFromMe() const
|
||||
{
|
||||
@@ -1695,6 +1671,7 @@ public:
|
||||
class CAccountingEntry
|
||||
{
|
||||
public:
|
||||
string strAccount;
|
||||
int64 nCreditDebit;
|
||||
int64 nTime;
|
||||
string strOtherAccount;
|
||||
@@ -1709,6 +1686,7 @@ public:
|
||||
{
|
||||
nCreditDebit = 0;
|
||||
nTime = 0;
|
||||
strAccount.clear();
|
||||
strOtherAccount.clear();
|
||||
strComment.clear();
|
||||
}
|
||||
@@ -1717,6 +1695,7 @@ public:
|
||||
(
|
||||
if (!(nType & SER_GETHASH))
|
||||
READWRITE(nVersion);
|
||||
// Note: strAccount is serialized as part of the key, not here.
|
||||
READWRITE(nCreditDebit);
|
||||
READWRITE(nTime);
|
||||
READWRITE(strOtherAccount);
|
||||
@@ -1733,6 +1712,8 @@ public:
|
||||
|
||||
|
||||
//
|
||||
// Alerts are for notifying old versions if they become too obsolete and
|
||||
// need to upgrade. The message is displayed in the status bar.
|
||||
// Alert messages are broadcast as a vector of signed data. Unserializing may
|
||||
// not read the entire buffer if the alert is for a newer version, but older
|
||||
// versions can still relay the original data.
|
||||
@@ -1754,7 +1735,7 @@ public:
|
||||
// Actions
|
||||
string strComment;
|
||||
string strStatusBar;
|
||||
string strRPCError;
|
||||
string strReserved;
|
||||
|
||||
IMPLEMENT_SERIALIZE
|
||||
(
|
||||
@@ -1772,7 +1753,7 @@ public:
|
||||
|
||||
READWRITE(strComment);
|
||||
READWRITE(strStatusBar);
|
||||
READWRITE(strRPCError);
|
||||
READWRITE(strReserved);
|
||||
)
|
||||
|
||||
void SetNull()
|
||||
@@ -1790,7 +1771,7 @@ public:
|
||||
|
||||
strComment.clear();
|
||||
strStatusBar.clear();
|
||||
strRPCError.clear();
|
||||
strReserved.clear();
|
||||
}
|
||||
|
||||
string ToString() const
|
||||
@@ -1815,7 +1796,6 @@ public:
|
||||
" nPriority = %d\n"
|
||||
" strComment = \"%s\"\n"
|
||||
" strStatusBar = \"%s\"\n"
|
||||
" strRPCError = \"%s\"\n"
|
||||
")\n",
|
||||
nVersion,
|
||||
nRelayUntil,
|
||||
@@ -1828,8 +1808,7 @@ public:
|
||||
strSetSubVer.c_str(),
|
||||
nPriority,
|
||||
strComment.c_str(),
|
||||
strStatusBar.c_str(),
|
||||
strRPCError.c_str());
|
||||
strStatusBar.c_str());
|
||||
}
|
||||
|
||||
void print() const
|
||||
|
||||
@@ -4,26 +4,26 @@
|
||||
|
||||
|
||||
INCLUDEPATHS= \
|
||||
-I"/boost" \
|
||||
-I"/db/build_unix" \
|
||||
-I"/openssl/include" \
|
||||
-I"/wxwidgets/lib/gcc_lib/mswud" \
|
||||
-I"/wxwidgets/include"
|
||||
-I"C:\boost-1.43.0-mgw" \
|
||||
-I"C:\db-4.7.25.NC-mgw\build_unix" \
|
||||
-I"C:\openssl-1.0.0c-mgw\include" \
|
||||
-I"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib\mswud" \
|
||||
-I"C:\wxWidgets-2.9.1-mgw\include"
|
||||
|
||||
LIBPATHS= \
|
||||
-L"/boost/stage/lib" \
|
||||
-L"/db/build_unix" \
|
||||
-L"/openssl/out" \
|
||||
-L"/wxwidgets/lib/gcc_lib"
|
||||
-L"C:\boost-1.43.0-mgw\stage\lib" \
|
||||
-L"C:\db-4.7.25.NC-mgw\build_unix" \
|
||||
-L"C:\openssl-1.0.0c-mgw" \
|
||||
-L"C:\wxWidgets-2.9.1-mgw\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 libboost_program_options-mgw34-mt-d \
|
||||
-l libboost_thread-mgw34-mt-d \
|
||||
-l boost_system-mgw45-mt-s-1_43 \
|
||||
-l boost_filesystem-mgw45-mt-s-1_43 \
|
||||
-l boost_program_options-mgw45-mt-s-1_43 \
|
||||
-l boost_thread-mgw45-mt-s-1_43 \
|
||||
-l db_cxx \
|
||||
-l eay32 \
|
||||
-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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
# Copyright (c) 2010 Laszlo Hanyecz
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file license.txt or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
31
makefile.vc
31
makefile.vc
@@ -7,29 +7,32 @@ INCLUDEPATHS= \
|
||||
/I"/boost" \
|
||||
/I"/db/build_windows" \
|
||||
/I"/openssl/include" \
|
||||
/I"/wxwidgets/lib/vc_lib/mswud" \
|
||||
/I"/wxwidgets/lib/vc_lib/mswu" \
|
||||
/I"/wxwidgets/include"
|
||||
|
||||
LIBPATHS= \
|
||||
/LIBPATH:"/boost/stage/lib" \
|
||||
/LIBPATH:"/db/build_windows/debug" \
|
||||
/LIBPATH:"/openssl/out" \
|
||||
/LIBPATH:"/wxwidgets/lib/vc_lib"
|
||||
/LIBPATH:"/db/build_windows/Release" \
|
||||
/LIBPATH:"/openssl/lib" \
|
||||
/LIBPATH:"/wxwidgets/lib/vc_lib" \
|
||||
/NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib \
|
||||
/NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib \
|
||||
/NODEFAULTLIB:msvcrtd.lib
|
||||
|
||||
WXLIBS=wxmsw29ud_html.lib wxmsw29ud_core.lib wxmsw29ud_adv.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib
|
||||
WXLIBS=wxmsw29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib
|
||||
|
||||
LIBS= \
|
||||
libboost_system-vc80-mt-gd.lib \
|
||||
libboost_filesystem-vc80-mt-gd.lib \
|
||||
libboost_program_options-vc80-mt-gd.lib \
|
||||
libboost_thread-vc80-mt-gd.lib \
|
||||
libdb47sd.lib \
|
||||
libboost_system-vc100-mt.lib \
|
||||
libboost_filesystem-vc100-mt.lib \
|
||||
libboost_program_options-vc100-mt.lib \
|
||||
libboost_thread-vc100-mt.lib \
|
||||
libdb47s.lib \
|
||||
libeay32.lib \
|
||||
kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib
|
||||
|
||||
DEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH
|
||||
DEBUGFLAGS=/Zi /D__WXDEBUG__
|
||||
CFLAGS=/c /nologo /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
|
||||
DEBUGFLAGS=/Os
|
||||
CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(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 noui.h init.h
|
||||
|
||||
@@ -82,7 +85,7 @@ obj\ui.res: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp r
|
||||
rc $(INCLUDEPATHS) $(DEFS) /Fo$@ %s
|
||||
|
||||
bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\ui.res
|
||||
link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)
|
||||
link /nologo /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)
|
||||
|
||||
|
||||
.cpp{obj\nogui}.obj:
|
||||
@@ -105,7 +108,7 @@ obj\nogui\rpc.obj: $(HEADERS)
|
||||
obj\nogui\init.obj: $(HEADERS)
|
||||
|
||||
bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\ui.res
|
||||
link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)
|
||||
link /nologo /OUT:$@ $(LIBPATHS) $** $(LIBS)
|
||||
|
||||
|
||||
clean:
|
||||
|
||||
194
net.cpp
194
net.cpp
@@ -163,7 +163,7 @@ bool GetMyExternalIP2(const CAddress& addrConnect, const char* pszGet, const cha
|
||||
return error("GetMyExternalIP() : connection closed");
|
||||
}
|
||||
|
||||
|
||||
// We now get our external IP from the IRC server first and only use this as a backup
|
||||
bool GetMyExternalIP(unsigned int& ipRet)
|
||||
{
|
||||
CAddress addrConnect;
|
||||
@@ -176,6 +176,10 @@ bool GetMyExternalIP(unsigned int& ipRet)
|
||||
for (int nLookup = 0; nLookup <= 1; nLookup++)
|
||||
for (int nHost = 1; nHost <= 2; nHost++)
|
||||
{
|
||||
// We should be phasing out our use of sites like these. If we need
|
||||
// replacements, we should ask for volunteers to put this simple
|
||||
// php file on their webserver that prints the client IP:
|
||||
// <?php echo $_SERVER["REMOTE_ADDR"]; ?>
|
||||
if (nHost == 1)
|
||||
{
|
||||
addrConnect = CAddress("91.198.22.70:80"); // checkip.dyndns.org
|
||||
@@ -222,6 +226,36 @@ bool GetMyExternalIP(unsigned int& ipRet)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ThreadGetMyExternalIP(void* parg)
|
||||
{
|
||||
// Wait for IRC to get it first
|
||||
if (!GetBoolArg("-noirc"))
|
||||
{
|
||||
for (int i = 0; i < 2 * 60; i++)
|
||||
{
|
||||
Sleep(1000);
|
||||
if (fGotExternalIP || fShutdown)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback in case IRC fails to get it
|
||||
if (GetMyExternalIP(addrLocalHost.ip))
|
||||
{
|
||||
printf("GetMyExternalIP() returned %s\n", addrLocalHost.ToStringIP().c_str());
|
||||
if (addrLocalHost.IsRoutable())
|
||||
{
|
||||
// If we already connected to a few before we had our IP, go back and addr them.
|
||||
// setAddrKnown automatically filters any duplicate sends.
|
||||
CAddress addr(addrLocalHost);
|
||||
addr.nTime = GetAdjustedTime();
|
||||
CRITICAL_BLOCK(cs_vNodes)
|
||||
foreach(CNode* pnode, vNodes)
|
||||
pnode->PushAddress(addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -609,7 +643,9 @@ void ThreadSocketHandler2(void* parg)
|
||||
FD_ZERO(&fdsetSend);
|
||||
FD_ZERO(&fdsetError);
|
||||
SOCKET hSocketMax = 0;
|
||||
FD_SET(hListenSocket, &fdsetRecv);
|
||||
|
||||
if(hListenSocket != INVALID_SOCKET)
|
||||
FD_SET(hListenSocket, &fdsetRecv);
|
||||
hSocketMax = max(hSocketMax, hListenSocket);
|
||||
CRITICAL_BLOCK(cs_vNodes)
|
||||
{
|
||||
@@ -646,18 +682,24 @@ void ThreadSocketHandler2(void* parg)
|
||||
//
|
||||
// Accept new connections
|
||||
//
|
||||
if (FD_ISSET(hListenSocket, &fdsetRecv))
|
||||
if (hListenSocket != INVALID_SOCKET && FD_ISSET(hListenSocket, &fdsetRecv))
|
||||
{
|
||||
struct sockaddr_in sockaddr;
|
||||
socklen_t len = sizeof(sockaddr);
|
||||
SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);
|
||||
CAddress addr(sockaddr);
|
||||
int nInbound = 0;
|
||||
|
||||
CRITICAL_BLOCK(cs_vNodes)
|
||||
foreach(CNode* pnode, vNodes)
|
||||
if (pnode->fInbound)
|
||||
nInbound++;
|
||||
if (hSocket == INVALID_SOCKET)
|
||||
{
|
||||
if (WSAGetLastError() != WSAEWOULDBLOCK)
|
||||
printf("socket error accept failed: %d\n", WSAGetLastError());
|
||||
}
|
||||
else if (mapArgs.count("-maxconnections") && (int)vNodes.size() >= atoi(mapArgs["-maxconnections"]) - MAX_OUTBOUND_CONNECTIONS)
|
||||
else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
|
||||
{
|
||||
closesocket(hSocket);
|
||||
}
|
||||
@@ -699,32 +741,39 @@ void ThreadSocketHandler2(void* parg)
|
||||
CDataStream& vRecv = pnode->vRecv;
|
||||
unsigned int nPos = vRecv.size();
|
||||
|
||||
// typical socket buffer is 8K-64K
|
||||
char pchBuf[0x10000];
|
||||
int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
|
||||
if (nBytes > 0)
|
||||
{
|
||||
vRecv.resize(nPos + nBytes);
|
||||
memcpy(&vRecv[nPos], pchBuf, nBytes);
|
||||
pnode->nLastRecv = GetTime();
|
||||
}
|
||||
else if (nBytes == 0)
|
||||
{
|
||||
// socket closed gracefully
|
||||
if (nPos > 1000*GetArg("-maxreceivebuffer", 2*1000)) {
|
||||
if (!pnode->fDisconnect)
|
||||
printf("socket closed\n");
|
||||
printf("socket recv flood control disconnect (%d bytes)\n", vRecv.size());
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
else if (nBytes < 0)
|
||||
{
|
||||
// error
|
||||
int nErr = WSAGetLastError();
|
||||
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
|
||||
else {
|
||||
// typical socket buffer is 8K-64K
|
||||
char pchBuf[0x10000];
|
||||
int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
|
||||
if (nBytes > 0)
|
||||
{
|
||||
vRecv.resize(nPos + nBytes);
|
||||
memcpy(&vRecv[nPos], pchBuf, nBytes);
|
||||
pnode->nLastRecv = GetTime();
|
||||
}
|
||||
else if (nBytes == 0)
|
||||
{
|
||||
// socket closed gracefully
|
||||
if (!pnode->fDisconnect)
|
||||
printf("socket recv error %d\n", nErr);
|
||||
printf("socket closed\n");
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
else if (nBytes < 0)
|
||||
{
|
||||
// error
|
||||
int nErr = WSAGetLastError();
|
||||
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
|
||||
{
|
||||
if (!pnode->fDisconnect)
|
||||
printf("socket recv error %d\n", nErr);
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -757,6 +806,11 @@ void ThreadSocketHandler2(void* parg)
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
}
|
||||
if (vSend.size() > 1000*GetArg("-maxsendbuffer", 256)) {
|
||||
if (!pnode->fDisconnect)
|
||||
printf("socket send flood control disconnect (%d bytes)\n", vSend.size());
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -809,42 +863,46 @@ void ThreadSocketHandler2(void* parg)
|
||||
|
||||
unsigned int pnSeed[] =
|
||||
{
|
||||
// 2010/06
|
||||
0x35218252, 0x9c9c9618, 0xda6bacad, 0xb9aca862, 0x97c235c6,
|
||||
0x146f9562, 0xb67b9e4b, 0x87cf4bc0, 0xb83945d0, 0x984333ad,
|
||||
0xbbeec555, 0x6f0eb440, 0xe0005318, 0x7797e460, 0xddc60fcc,
|
||||
0xb3bbd24a, 0x1ac85746, 0x641846a6, 0x85ee1155, 0xbb2e7a4c,
|
||||
0x9cb8514b, 0xfc342648, 0x62958fae, 0xd0a8c87a, 0xa800795b,
|
||||
0xda8c814e, 0x256a0c80, 0x3f23ec63, 0xd565df43, 0x997d9044,
|
||||
0xaa121448, 0xbed8688e, 0x59d09a5e, 0xb2931243, 0x3730ba18,
|
||||
0xdd3462d0, 0x4e4d1448, 0x171df645, 0x84ee1155,
|
||||
0x248ac445, 0x0e634444, 0x0ded1b63, 0x30c01e60,
|
||||
0xa2b9a094, 0x29e4fd43, 0x9ce61b4c, 0xdae09744,
|
||||
|
||||
// 2010/08
|
||||
0x5ae6bf43, 0x460be257, 0x7245c0cf, 0x4e0f028d, 0x26501760, 0x38643255, 0x67094f4f, 0x480449b8,
|
||||
0x16545143, 0x1f082e5a, 0xaa428018, 0xe411e793, 0x14c1f862, 0x2726105b, 0x9b33ea50, 0xeeef86ca,
|
||||
0xe3210d44, 0x0dca8b63, 0x3f9dfb18, 0x860340ad, 0xf33ba17a, 0x9018375c, 0x1de4e353, 0x0fa52dcb,
|
||||
0x89c4555b, 0x109cf37b, 0x28c55b40, 0x04c801ae, 0x275c1e80, 0x6f7f745d, 0x7a2a5653, 0xa28e26d8,
|
||||
0xa4e65db2, 0x99a06580, 0xf253ba44, 0x82cf6ab8, 0x859c2e8e, 0xf71a815d, 0xc18f1454, 0x71c8a943,
|
||||
0x90d24e18, 0x311789b2, 0x74aba645, 0xde0bbfc3, 0xad724fad, 0xbf1ae15e, 0xbaa6fb54, 0x06e4d145,
|
||||
0x51528645, 0x72120cd4, 0xd4cfd145, 0x0a7afed8, 0x9b9a5fad, 0x9e9ff45e, 0x10128355, 0xd44e8646,
|
||||
0x04a07b47, 0x5fc9d547, 0xe0491e45, 0xbac21b41, 0x7aa31bae, 0x10483c5f, 0x94a23055, 0x73d9dc47,
|
||||
0x1a99c247, 0x822fe847, 0x7e57ba48, 0xb19ea843, 0xa60621b2, 0x778cf163, 0x125c6556, 0xf94ba44f,
|
||||
0xa61a0948, 0x6c839e4b, 0x29af5348, 0x68d84845, 0x752b95c3, 0xcf0d4663, 0x08e11e56, 0x75109550,
|
||||
0x5f24b94c, 0x42426d4d, 0xfbbc0a4c, 0x70a9a246, 0xda7837cb, 0xae2a986d, 0xe283c358, 0x0c7ca954,
|
||||
0x8e9bde59, 0x61521760, 0x6884444c, 0xa194e548, 0x9b8809cc, 0x16e96a8f, 0x956ff859, 0xfad5e555,
|
||||
0x0ea70c80, 0x5b4ce26d, 0x7984444c, 0x1080d24a, 0x22a686cf, 0x6bf8c2ad, 0xb0f7485f, 0x06b66e56,
|
||||
0x668373bc, 0x75506279, 0x3868694e, 0x12a5954b, 0x3a8b62d1, 0xb74fcbad, 0xa7dc3360, 0xc070b359,
|
||||
0xa2b87242, 0xc45cab7c, 0x69882050, 0x14a5464b, 0x386acad5, 0x80b85db2, 0x1f78a062, 0xc608c55b,
|
||||
0x4257d543, 0x7636ad80, 0x4432d655, 0xb2114d4b, 0x32639bd9, 0xadd75db2, 0x9be5a362, 0x6831bc5e,
|
||||
0xf7f77046, 0x8f35ba81, 0x09bb4e59, 0xd0fb6b4e, 0xc5daa445, 0x9c611618, 0x355dcc62, 0xf2cf435e,
|
||||
0x31e72c46, 0xdd8a43ad, 0x171f9c5b, 0xb4c2e355, 0xbe8af945, 0x613d3942, 0xe6f9e863, 0x7a3d855f,
|
||||
0xa66adc47, 0x261089b2, 0x5a27105b, 0x6c28105b, 0xdd247946, 0xe6c3a445, 0x43a1ec63, 0x99b4dd5f,
|
||||
0xb6834347, 0x5e9649bc, 0xf9dd545d, 0x6ae4c15b, 0xa5318a47, 0x7984ec47, 0x93a73b63, 0x0c60195f,
|
||||
0xa5c85e4b, 0xa0a36dc2, 0x0739a95e, 0x3d44c15b, 0xfb940f4b, 0xd67c9148, 0x614f9876, 0x0a241c5f,
|
||||
0xad9da74c, 0x4459abc8, 0x12e71b5f, 0x1c534a5d, 0x8ff5fc50, 0x2ca8864b, 0xd894fd80, 0x82ab3160,
|
||||
0x390d804e, 0x2cf310cc, 0x680dad80, 0x691be15e, 0x5a8f4652, 0xaad0784d, 0x0d2431ad,
|
||||
0x1ddb1032, 0x6242ce40, 0x52d6a445, 0x2dd7a445, 0x8a53cd47, 0x73263750, 0xda23c257, 0xecd4ed57,
|
||||
0x0a40ec59, 0x75dce160, 0x7df76791, 0x89370bad, 0xa4f214ad, 0x767700ae, 0x638b0418, 0x868a1018,
|
||||
0xcd9f332e, 0x0129653e, 0xcc92dc3e, 0x96671640, 0x56487e40, 0x5b66f440, 0xb1d01f41, 0xf1dc6041,
|
||||
0xc1d12b42, 0x86ba1243, 0x6be4df43, 0x6d4cef43, 0xd18e0644, 0x1ab0b344, 0x6584a345, 0xe7c1a445,
|
||||
0x58cea445, 0xc5daa445, 0x21dda445, 0x3d3b5346, 0x13e55347, 0x1080d24a, 0x8e611e4b, 0x81518e4b,
|
||||
0x6c839e4b, 0xe2ad0a4c, 0xfbbc0a4c, 0x7f5b6e4c, 0x7244224e, 0x1300554e, 0x20690652, 0x5a48b652,
|
||||
0x75c5c752, 0x4335cc54, 0x340fd154, 0x87c07455, 0x087b2b56, 0x8a133a57, 0xac23c257, 0x70374959,
|
||||
0xfb63d45b, 0xb9a1685c, 0x180d765c, 0x674f645d, 0x04d3495e, 0x1de44b5e, 0x4ee8a362, 0x0ded1b63,
|
||||
0xc1b04b6d, 0x8d921581, 0x97b7ea82, 0x1cf83a8e, 0x91490bad, 0x09dc75ae, 0x9a6d79ae, 0xa26d79ae,
|
||||
0x0fd08fae, 0x0f3e3fb2, 0x4f944fb2, 0xcca448b8, 0x3ecd6ab8, 0xa9d5a5bc, 0x8d0119c1, 0x045997d5,
|
||||
0xca019dd9, 0x0d526c4d, 0xabf1ba44, 0x66b1ab55, 0x1165f462, 0x3ed7cbad, 0xa38fae6e, 0x3bd2cbad,
|
||||
0xd36f0547, 0x20df7840, 0x7a337742, 0x549f8e4b, 0x9062365c, 0xd399f562, 0x2b5274a1, 0x8edfa153,
|
||||
0x3bffb347, 0x7074bf58, 0xb74fcbad, 0x5b5a795b, 0x02fa29ce, 0x5a6738d4, 0xe8a1d23e, 0xef98c445,
|
||||
0x4b0f494c, 0xa2bc1e56, 0x7694ad63, 0xa4a800c3, 0x05fda6cd, 0x9f22175e, 0x364a795b, 0x536285d5,
|
||||
0xac44c9d4, 0x0b06254d, 0x150c2fd4, 0x32a50dcc, 0xfd79ce48, 0xf15cfa53, 0x66c01e60, 0x6bc26661,
|
||||
0xc03b47ae, 0x4dda1b81, 0x3285a4c1, 0x883ca96d, 0x35d60a4c, 0xdae09744, 0x2e314d61, 0x84e247cf,
|
||||
0x6c814552, 0x3a1cc658, 0x98d8f382, 0xe584cb5b, 0x15e86057, 0x7b01504e, 0xd852dd48, 0x56382f56,
|
||||
0x0a5df454, 0xa0d18d18, 0x2e89b148, 0xa79c114c, 0xcbdcd054, 0x5523bc43, 0xa9832640, 0x8a066144,
|
||||
0x3894c3bc, 0xab76bf58, 0x6a018ac1, 0xfebf4f43, 0x2f26c658, 0x31102f4e, 0x85e929d5, 0x2a1c175e,
|
||||
0xfc6c2cd1, 0x27b04b6d, 0xdf024650, 0x161748b8, 0x28be6580, 0x57be6580, 0x1cee677a, 0xaa6bb742,
|
||||
0x9a53964b, 0x0a5a2d4d, 0x2434c658, 0x9a494f57, 0x1ebb0e48, 0xf610b85d, 0x077ecf44, 0x085128bc,
|
||||
0x5ba17a18, 0x27ca1b42, 0xf8a00b56, 0xfcd4c257, 0xcf2fc15e, 0xd897e052, 0x4cada04f, 0x2f35f6d5,
|
||||
0x382ce8c9, 0xe523984b, 0x3f946846, 0x60c8be43, 0x41da6257, 0xde0be142, 0xae8a544b, 0xeff0c254,
|
||||
0x1e0f795b, 0xaeb28890, 0xca16acd9, 0x1e47ddd8, 0x8c8c4829, 0xd27dc747, 0xd53b1663, 0x4096b163,
|
||||
0x9c8dd958, 0xcb12f860, 0x9e79305c, 0x40c1a445, 0x4a90c2bc, 0x2c3a464d, 0x2727f23c, 0x30b04b6d,
|
||||
0x59024cb8, 0xa091e6ad, 0x31b04b6d, 0xc29d46a6, 0x63934fb2, 0xd9224dbe, 0x9f5910d8, 0x7f530a6b,
|
||||
0x752e9c95, 0x65453548, 0xa484be46, 0xce5a1b59, 0x710e0718, 0x46a13d18, 0xdaaf5318, 0xc4a8ff53,
|
||||
0x87abaa52, 0xb764cf51, 0xb2025d4a, 0x6d351e41, 0xc035c33e, 0xa432c162, 0x61ef34ae, 0xd16fddbc,
|
||||
0x0870e8c1, 0x3070e8c1, 0x9c71e8c1, 0xa4992363, 0x85a1f663, 0x4184e559, 0x18d96ed8, 0x17b8dbd5,
|
||||
0x60e7cd18, 0xe5ee104c, 0xab17ac62, 0x1e786e1b, 0x5d23b762, 0xf2388fae, 0x88270360, 0x9e5b3d80,
|
||||
0x7da518b2, 0xb5613b45, 0x1ad41f3e, 0xd550854a, 0x8617e9a9, 0x925b229c, 0xf2e92542, 0x47af0544,
|
||||
0x73b5a843, 0xb9b7a0ad, 0x03a748d0, 0x0a6ff862, 0x6694df62, 0x3bfac948, 0x8e098f4f, 0x746916c3,
|
||||
0x02f38e4f, 0x40bb1243, 0x6a54d162, 0x6008414b, 0xa513794c, 0x514aa343, 0x63781747, 0xdbb6795b,
|
||||
0xed065058, 0x42d24b46, 0x1518794c, 0x9b271681, 0x73e4ffad, 0x0654784f, 0x438dc945, 0x641846a6,
|
||||
0x2d1b0944, 0x94b59148, 0x8d369558, 0xa5a97662, 0x8b705b42, 0xce9204ae, 0x8d584450, 0x2df61555,
|
||||
0xeebff943, 0x2e75fb4d, 0x3ef8fc57, 0x9921135e, 0x8e31042e, 0xb5afad43, 0x89ecedd1, 0x9cfcc047,
|
||||
0x8fcd0f4c, 0xbe49f5ad, 0x146a8d45, 0x98669ab8, 0x98d9175e, 0xd1a8e46d, 0x839a3ab8, 0x40a0016c,
|
||||
0x6d27c257, 0x977fffad, 0x7baa5d5d, 0x1213be43, 0xb167e5a9, 0x640fe8ca, 0xbc9ea655, 0x0f820a4c,
|
||||
0x0f097059, 0x69ac957c, 0x366d8453, 0xb1ba2844, 0x8857f081, 0x70b5be63, 0xc545454b, 0xaf36ded1,
|
||||
0xb5a4b052, 0x21f062d1, 0x72ab89b2, 0x74a45318, 0x8312e6bc, 0xb916965f, 0x8aa7c858, 0xfe7effad,
|
||||
};
|
||||
|
||||
|
||||
@@ -923,8 +981,7 @@ void ThreadOpenConnections2(void* parg)
|
||||
if (!pnode->fInbound)
|
||||
nOutbound++;
|
||||
int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;
|
||||
if (mapArgs.count("-maxconnections"))
|
||||
nMaxOutboundConnections = min(nMaxOutboundConnections, atoi(mapArgs["-maxconnections"]));
|
||||
nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125));
|
||||
if (nOutbound < nMaxOutboundConnections)
|
||||
break;
|
||||
Sleep(2000);
|
||||
@@ -973,7 +1030,7 @@ void ThreadOpenConnections2(void* parg)
|
||||
{
|
||||
foreach(PAIRTYPE(const vector<unsigned char>, CAddress)& item, mapAddresses)
|
||||
{
|
||||
if (setSeed.count(item.second.ip))
|
||||
if (setSeed.count(item.second.ip) && item.second.nTime != 0)
|
||||
{
|
||||
item.second.nTime = 0;
|
||||
CAddrDB().WriteAddress(item.second);
|
||||
@@ -1310,8 +1367,7 @@ void StartNode(void* parg)
|
||||
#endif
|
||||
printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
|
||||
|
||||
// Get our external IP address for incoming connections
|
||||
if (fUseProxy)
|
||||
if (fUseProxy || mapArgs.count("-connect") || fNoListen)
|
||||
{
|
||||
// Proxies can't take incoming connections
|
||||
addrLocalHost.ip = CAddress("0.0.0.0").ip;
|
||||
@@ -1319,15 +1375,7 @@ void StartNode(void* parg)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (addrIncoming.IsValid())
|
||||
addrLocalHost.ip = addrIncoming.ip;
|
||||
|
||||
if (GetMyExternalIP(addrLocalHost.ip))
|
||||
{
|
||||
addrIncoming = addrLocalHost;
|
||||
CWalletDB().WriteSetting("addrIncoming", addrIncoming);
|
||||
printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
|
||||
}
|
||||
CreateThread(ThreadGetMyExternalIP, NULL);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
2
obj/.gitignore
vendored
Normal file
2
obj/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
obj/nogui/.gitignore
vendored
Normal file
2
obj/nogui/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
397
rpc.cpp
397
rpc.cpp
@@ -80,11 +80,18 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
|
||||
{
|
||||
entry.push_back(Pair("confirmations", wtx.GetDepthInMainChain()));
|
||||
entry.push_back(Pair("txid", wtx.GetHash().GetHex()));
|
||||
entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime()));
|
||||
foreach(const PAIRTYPE(string,string)& item, wtx.mapValue)
|
||||
entry.push_back(Pair(item.first, item.second));
|
||||
}
|
||||
|
||||
|
||||
string AccountFromValue(const Value& value)
|
||||
{
|
||||
string strAccount = value.get_str();
|
||||
if (strAccount == "*")
|
||||
throw JSONRPCError(-11, "Invalid account name");
|
||||
return strAccount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -239,6 +246,8 @@ Value setgenerate(const Array& params, bool fHelp)
|
||||
CWalletDB().WriteSetting("fLimitProcessors", fLimitProcessors);
|
||||
if (nGenProcLimit != -1)
|
||||
CWalletDB().WriteSetting("nLimitProcessors", nLimitProcessors = nGenProcLimit);
|
||||
if (nGenProcLimit == 0)
|
||||
fGenerate = false;
|
||||
}
|
||||
|
||||
GenerateBitcoins(fGenerate);
|
||||
@@ -296,7 +305,7 @@ Value getnewaddress(const Array& params, bool fHelp)
|
||||
// Parse the account first so we don't generate a key if there's an error
|
||||
string strAccount;
|
||||
if (params.size() > 0)
|
||||
strAccount = params[0].get_str();
|
||||
strAccount = AccountFromValue(params[0]);
|
||||
|
||||
// Generate a new key that is added to wallet
|
||||
string strAddress = PubKeyToAddress(GetKeyFromKeyPool());
|
||||
@@ -306,15 +315,9 @@ Value getnewaddress(const Array& params, bool fHelp)
|
||||
}
|
||||
|
||||
|
||||
Value getaccountaddress(const Array& params, bool fHelp)
|
||||
string GetAccountAddress(string strAccount, bool bForceNew=false)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"getaccountaddress <account>\n"
|
||||
"Returns the current bitcoin address for receiving payments to this account.");
|
||||
|
||||
// Parse the account first so we don't generate a key if there's an error
|
||||
string strAccount = params[0].get_str();
|
||||
string strAddress;
|
||||
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
@@ -341,7 +344,7 @@ Value getaccountaddress(const Array& params, bool fHelp)
|
||||
}
|
||||
|
||||
// Generate a new key
|
||||
if (account.vchPubKey.empty())
|
||||
if (account.vchPubKey.empty() || bForceNew)
|
||||
{
|
||||
account.vchPubKey = GetKeyFromKeyPool();
|
||||
string strAddress = PubKeyToAddress(account.vchPubKey);
|
||||
@@ -350,10 +353,25 @@ Value getaccountaddress(const Array& params, bool fHelp)
|
||||
}
|
||||
|
||||
walletdb.TxnCommit();
|
||||
return PubKeyToAddress(account.vchPubKey);
|
||||
strAddress = PubKeyToAddress(account.vchPubKey);
|
||||
}
|
||||
return strAddress;
|
||||
}
|
||||
|
||||
Value getaccountaddress(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"getaccountaddress <account>\n"
|
||||
"Returns the current bitcoin address for receiving payments to this account.");
|
||||
|
||||
// Parse the account first so we don't generate a key if there's an error
|
||||
string strAccount = AccountFromValue(params[0]);
|
||||
|
||||
return GetAccountAddress(strAccount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Value setaccount(const Array& params, bool fHelp)
|
||||
{
|
||||
@@ -365,7 +383,18 @@ Value setaccount(const Array& params, bool fHelp)
|
||||
string strAddress = params[0].get_str();
|
||||
string strAccount;
|
||||
if (params.size() > 1)
|
||||
strAccount = params[1].get_str();
|
||||
strAccount = AccountFromValue(params[1]);
|
||||
|
||||
// Detect when changing the account of an address that is the 'unused current key' of another account:
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
if (mapAddressBook.count(strAddress))
|
||||
{
|
||||
string strOldAccount = mapAddressBook[strAddress];
|
||||
if (strAddress == GetAccountAddress(strOldAccount))
|
||||
GetAccountAddress(strOldAccount, true);
|
||||
}
|
||||
}
|
||||
|
||||
SetAddressBookName(strAddress, strAccount);
|
||||
return Value::null;
|
||||
@@ -399,7 +428,7 @@ Value getaddressesbyaccount(const Array& params, bool fHelp)
|
||||
"getaddressesbyaccount <account>\n"
|
||||
"Returns the list of addresses for the given account.");
|
||||
|
||||
string strAccount = params[0].get_str();
|
||||
string strAccount = AccountFromValue(params[0]);
|
||||
|
||||
// Find all addresses that have the given account
|
||||
Array ret;
|
||||
@@ -436,7 +465,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
|
||||
// Wallet comments
|
||||
CWalletTx wtx;
|
||||
if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty())
|
||||
wtx.mapValue["message"] = params[2].get_str();
|
||||
wtx.mapValue["comment"] = params[2].get_str();
|
||||
if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
|
||||
wtx.mapValue["to"] = params[3].get_str();
|
||||
|
||||
@@ -522,7 +551,7 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
|
||||
nMinDepth = params[1].get_int();
|
||||
|
||||
// Get the set of pub keys that have the label
|
||||
string strAccount = params[0].get_str();
|
||||
string strAccount = AccountFromValue(params[0]);
|
||||
set<CScript> setPubKey;
|
||||
GetAccountPubKeys(strAccount, setPubKey);
|
||||
|
||||
@@ -549,9 +578,6 @@ Value getreceivedbyaccount(const Array& params, bool fHelp)
|
||||
|
||||
int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth)
|
||||
{
|
||||
set<CScript> setPubKey;
|
||||
GetAccountPubKeys(strAccount, setPubKey);
|
||||
|
||||
int64 nBalance = 0;
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
@@ -563,7 +589,7 @@ int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinD
|
||||
continue;
|
||||
|
||||
int64 nGenerated, nReceived, nSent, nFee;
|
||||
wtx.GetAccountAmounts(strAccount, setPubKey, nGenerated, nReceived, nSent, nFee);
|
||||
wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee);
|
||||
|
||||
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
||||
nBalance += nReceived;
|
||||
@@ -595,7 +621,37 @@ Value getbalance(const Array& params, bool fHelp)
|
||||
if (params.size() == 0)
|
||||
return ((double)GetBalance() / (double)COIN);
|
||||
|
||||
string strAccount = params[0].get_str();
|
||||
if (params[0].get_str() == "*") {
|
||||
// Calculate total balance a different way from GetBalance()
|
||||
// (GetBalance() sums up all unspent TxOuts)
|
||||
// getbalance and getbalance '*' should always return the same number.
|
||||
int64 nBalance = 0;
|
||||
vector<string> vAccounts;
|
||||
for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
int64 allGenerated, allFee;
|
||||
allGenerated = allFee = 0;
|
||||
string strSentAccount;
|
||||
list<pair<string, int64> > listReceived;
|
||||
list<pair<string, int64> > listSent;
|
||||
wtx.GetAmounts(allGenerated, listReceived, listSent, allFee, strSentAccount);
|
||||
foreach(const PAIRTYPE(string,int64)& r, listReceived)
|
||||
{
|
||||
nBalance += r.second;
|
||||
if (!count(vAccounts.begin(), vAccounts.end(), r.first))
|
||||
vAccounts.push_back(r.first);
|
||||
}
|
||||
foreach(const PAIRTYPE(string,int64)& r, listSent)
|
||||
nBalance -= r.second;
|
||||
nBalance -= allFee;
|
||||
nBalance += allGenerated;
|
||||
}
|
||||
printf("Found %d accounts\n", vAccounts.size());
|
||||
return (double)nBalance / (double)COIN;
|
||||
}
|
||||
|
||||
string strAccount = AccountFromValue(params[0]);
|
||||
int nMinDepth = 1;
|
||||
if (params.size() > 1)
|
||||
nMinDepth = params[1].get_int();
|
||||
@@ -613,8 +669,8 @@ Value movecmd(const Array& params, bool fHelp)
|
||||
"move <fromaccount> <toaccount> <amount> [minconf=1] [comment]\n"
|
||||
"Move from one account in your wallet to another.");
|
||||
|
||||
string strFrom = params[0].get_str();
|
||||
string strTo = params[1].get_str();
|
||||
string strFrom = AccountFromValue(params[0]);
|
||||
string strTo = AccountFromValue(params[1]);
|
||||
int64 nAmount = AmountFromValue(params[2]);
|
||||
int nMinDepth = 1;
|
||||
if (params.size() > 3)
|
||||
@@ -647,19 +703,21 @@ Value movecmd(const Array& params, bool fHelp)
|
||||
|
||||
// Debit
|
||||
CAccountingEntry debit;
|
||||
debit.strAccount = strFrom;
|
||||
debit.nCreditDebit = -nAmount;
|
||||
debit.nTime = nNow;
|
||||
debit.strOtherAccount = strTo;
|
||||
debit.strComment = strComment;
|
||||
walletdb.WriteAccountingEntry(strFrom, debit);
|
||||
walletdb.WriteAccountingEntry(debit);
|
||||
|
||||
// Credit
|
||||
CAccountingEntry credit;
|
||||
credit.strAccount = strTo;
|
||||
credit.nCreditDebit = nAmount;
|
||||
credit.nTime = nNow;
|
||||
credit.strOtherAccount = strFrom;
|
||||
credit.strComment = strComment;
|
||||
walletdb.WriteAccountingEntry(strTo, credit);
|
||||
walletdb.WriteAccountingEntry(credit);
|
||||
|
||||
walletdb.TxnCommit();
|
||||
}
|
||||
@@ -674,7 +732,7 @@ Value sendfrom(const Array& params, bool fHelp)
|
||||
"sendfrom <fromaccount> <tobitcoinaddress> <amount> [minconf=1] [comment] [comment-to]\n"
|
||||
"<amount> is a real and is rounded to the nearest 0.01");
|
||||
|
||||
string strAccount = params[0].get_str();
|
||||
string strAccount = AccountFromValue(params[0]);
|
||||
string strAddress = params[1].get_str();
|
||||
int64 nAmount = AmountFromValue(params[2]);
|
||||
int nMinDepth = 1;
|
||||
@@ -684,7 +742,7 @@ Value sendfrom(const Array& params, bool fHelp)
|
||||
CWalletTx wtx;
|
||||
wtx.strFromAccount = strAccount;
|
||||
if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty())
|
||||
wtx.mapValue["message"] = params[4].get_str();
|
||||
wtx.mapValue["comment"] = params[4].get_str();
|
||||
if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty())
|
||||
wtx.mapValue["to"] = params[5].get_str();
|
||||
|
||||
@@ -849,97 +907,200 @@ Value listreceivedbyaccount(const Array& params, bool fHelp)
|
||||
return ListReceived(params, true);
|
||||
}
|
||||
|
||||
void ListAccountTransactions(CWalletDB& walletdb, const string& strAccount, int nMinDepth, multimap<int64, Object>& ret)
|
||||
void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret)
|
||||
{
|
||||
set<CScript> setPubKey;
|
||||
GetAccountPubKeys(strAccount, setPubKey);
|
||||
int64 nGenerated, nFee;
|
||||
string strSentAccount;
|
||||
list<pair<string, int64> > listReceived;
|
||||
list<pair<string, int64> > listSent;
|
||||
wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount);
|
||||
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
bool fAllAccounts = (strAccount == string("*"));
|
||||
|
||||
// Generated blocks assigned to account ""
|
||||
if (nGenerated != 0 && (fAllAccounts || strAccount == ""))
|
||||
{
|
||||
// Wallet: generate/send/receive transactions
|
||||
for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
if (!wtx.IsFinal())
|
||||
continue;
|
||||
Object entry;
|
||||
entry.push_back(Pair("account", string("")));
|
||||
entry.push_back(Pair("category", "generate"));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(nGenerated)));
|
||||
if (fLong)
|
||||
WalletTxToJSON(wtx, entry);
|
||||
ret.push_back(entry);
|
||||
}
|
||||
|
||||
int64 nGenerated, nReceived, nSent, nFee;
|
||||
wtx.GetAccountAmounts(strAccount, setPubKey, nGenerated, nReceived, nSent, nFee);
|
||||
|
||||
// Generated blocks count to account ""
|
||||
if (nGenerated != 0)
|
||||
{
|
||||
Object entry;
|
||||
entry.push_back(Pair("category", "generate"));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(nGenerated)));
|
||||
WalletTxToJSON(wtx, entry);
|
||||
ret.insert(make_pair(wtx.GetTxTime(), entry));
|
||||
}
|
||||
|
||||
// Sent
|
||||
if (nSent != 0 || nFee != 0)
|
||||
{
|
||||
Object entry;
|
||||
entry.push_back(Pair("category", "send"));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(-nSent)));
|
||||
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
|
||||
WalletTxToJSON(wtx, entry);
|
||||
ret.insert(make_pair(wtx.GetTxTime(), entry));
|
||||
}
|
||||
|
||||
// Received
|
||||
if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
||||
{
|
||||
Object entry;
|
||||
entry.push_back(Pair("category", "receive"));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(nReceived)));
|
||||
WalletTxToJSON(wtx, entry);
|
||||
ret.insert(make_pair(wtx.GetTxTime(), entry));
|
||||
}
|
||||
}
|
||||
|
||||
// Internal accounting entries
|
||||
list<CAccountingEntry> acentries;
|
||||
walletdb.ListAccountCreditDebit(strAccount, acentries);
|
||||
foreach (const CAccountingEntry& acentry, acentries)
|
||||
// Sent
|
||||
if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount))
|
||||
{
|
||||
foreach(const PAIRTYPE(string, int64)& s, listSent)
|
||||
{
|
||||
Object entry;
|
||||
entry.push_back(Pair("category", "move"));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit)));
|
||||
entry.push_back(Pair("otheraccount", acentry.strOtherAccount));
|
||||
ret.insert(make_pair(acentry.nTime, entry));
|
||||
entry.push_back(Pair("account", strSentAccount));
|
||||
entry.push_back(Pair("address", s.first));
|
||||
entry.push_back(Pair("category", "send"));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(-s.second)));
|
||||
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
|
||||
if (fLong)
|
||||
WalletTxToJSON(wtx, entry);
|
||||
ret.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// Received
|
||||
if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth)
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
foreach(const PAIRTYPE(string, int64)& r, listReceived)
|
||||
{
|
||||
string account;
|
||||
if (mapAddressBook.count(r.first))
|
||||
account = mapAddressBook[r.first];
|
||||
if (fAllAccounts || (account == strAccount))
|
||||
{
|
||||
Object entry;
|
||||
entry.push_back(Pair("account", account));
|
||||
entry.push_back(Pair("address", r.first));
|
||||
entry.push_back(Pair("category", "receive"));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(r.second)));
|
||||
if (fLong)
|
||||
WalletTxToJSON(wtx, entry);
|
||||
ret.push_back(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret)
|
||||
{
|
||||
bool fAllAccounts = (strAccount == string("*"));
|
||||
|
||||
if (fAllAccounts || acentry.strAccount == strAccount)
|
||||
{
|
||||
Object entry;
|
||||
entry.push_back(Pair("account", acentry.strAccount));
|
||||
entry.push_back(Pair("category", "move"));
|
||||
entry.push_back(Pair("time", (boost::int64_t)acentry.nTime));
|
||||
entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit)));
|
||||
entry.push_back(Pair("otheraccount", acentry.strOtherAccount));
|
||||
entry.push_back(Pair("comment", acentry.strComment));
|
||||
ret.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
Value listtransactions(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||
if (fHelp || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"listtransactions <account> [count=10]\n"
|
||||
"listtransactions [account] [count=10]\n"
|
||||
"Returns up to [count] most recent transactions for account <account>.");
|
||||
|
||||
string strAccount = params[0].get_str();
|
||||
string strAccount = "*";
|
||||
if (params.size() > 0)
|
||||
strAccount = params[0].get_str();
|
||||
int nCount = 10;
|
||||
if (params.size() > 1)
|
||||
nCount = params[1].get_int();
|
||||
|
||||
Array ret;
|
||||
CWalletDB walletdb;
|
||||
multimap<int64, Object> mapByTime; // keys are transaction time
|
||||
ListAccountTransactions(walletdb, strAccount, 0, mapByTime);
|
||||
|
||||
// Return only last nCount items:
|
||||
int nToErase = mapByTime.size()-nCount;
|
||||
if (nToErase > 0)
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
multimap<int64, Object>::iterator end = mapByTime.begin();
|
||||
std::advance(end, nToErase);
|
||||
mapByTime.erase(mapByTime.begin(), end);
|
||||
// Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap:
|
||||
typedef pair<CWalletTx*, CAccountingEntry*> TxPair;
|
||||
typedef multimap<int64, TxPair > TxItems;
|
||||
TxItems txByTime;
|
||||
|
||||
for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||
{
|
||||
CWalletTx* wtx = &((*it).second);
|
||||
txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, (CAccountingEntry*)0)));
|
||||
}
|
||||
list<CAccountingEntry> acentries;
|
||||
walletdb.ListAccountCreditDebit(strAccount, acentries);
|
||||
foreach(CAccountingEntry& entry, acentries)
|
||||
{
|
||||
txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
|
||||
}
|
||||
|
||||
// Now: iterate backwards until we have nCount items to return:
|
||||
for (TxItems::reverse_iterator it = txByTime.rbegin(); it != txByTime.rend(); ++it)
|
||||
{
|
||||
CWalletTx *const pwtx = (*it).second.first;
|
||||
if (pwtx != 0)
|
||||
ListTransactions(*pwtx, strAccount, 0, true, ret);
|
||||
CAccountingEntry *const pacentry = (*it).second.second;
|
||||
if (pacentry != 0)
|
||||
AcentryToJSON(*pacentry, strAccount, ret);
|
||||
|
||||
if (ret.size() >= nCount) break;
|
||||
}
|
||||
// ret is now newest to oldest
|
||||
}
|
||||
|
||||
// Make sure we return only last nCount items (sends-to-self might give us an extra):
|
||||
if (ret.size() > nCount)
|
||||
{
|
||||
Array::iterator last = ret.begin();
|
||||
std::advance(last, nCount);
|
||||
ret.erase(last, ret.end());
|
||||
}
|
||||
std::reverse(ret.begin(), ret.end()); // oldest to newest
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Value listaccounts(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() > 1)
|
||||
throw runtime_error(
|
||||
"listaccounts [minconf=1]\n"
|
||||
"Returns Object that has account names as keys, account balances as values.");
|
||||
|
||||
int nMinDepth = 1;
|
||||
if (params.size() > 0)
|
||||
nMinDepth = params[0].get_int();
|
||||
|
||||
map<string, int64> mapAccountBalances;
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
CRITICAL_BLOCK(cs_mapAddressBook)
|
||||
{
|
||||
foreach(const PAIRTYPE(string, string)& entry, mapAddressBook)
|
||||
mapAccountBalances[entry.second] = 0;
|
||||
|
||||
for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
|
||||
{
|
||||
const CWalletTx& wtx = (*it).second;
|
||||
int64 nGenerated, nFee;
|
||||
string strSentAccount;
|
||||
list<pair<string, int64> > listReceived;
|
||||
list<pair<string, int64> > listSent;
|
||||
wtx.GetAmounts(nGenerated, listReceived, listSent, nFee, strSentAccount);
|
||||
mapAccountBalances[strSentAccount] -= nFee;
|
||||
foreach(const PAIRTYPE(string, int64)& s, listSent)
|
||||
mapAccountBalances[strSentAccount] -= s.second;
|
||||
if (wtx.GetDepthInMainChain() >= nMinDepth)
|
||||
{
|
||||
mapAccountBalances[""] += nGenerated;
|
||||
foreach(const PAIRTYPE(string, int64)& r, listReceived)
|
||||
if (mapAddressBook.count(r.first))
|
||||
mapAccountBalances[mapAddressBook[r.first]] += r.second;
|
||||
else
|
||||
mapAccountBalances[""] += r.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array ret;
|
||||
foreach(const PAIRTYPE(int64, Object)& item, mapByTime)
|
||||
ret.push_back(item.second);
|
||||
list<CAccountingEntry> acentries;
|
||||
CWalletDB().ListAccountCreditDebit("*", acentries);
|
||||
foreach(const CAccountingEntry& entry, acentries)
|
||||
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
|
||||
|
||||
Object ret;
|
||||
foreach(const PAIRTYPE(string, int64)& accountBalance, mapAccountBalances) {
|
||||
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -957,7 +1118,7 @@ Value gettransaction(const Array& params, bool fHelp)
|
||||
CRITICAL_BLOCK(cs_mapWallet)
|
||||
{
|
||||
if (!mapWallet.count(hash))
|
||||
throw JSONRPCError(-5, "Invalid transaction id");
|
||||
throw JSONRPCError(-5, "Invalid or non-wallet transaction id");
|
||||
const CWalletTx& wtx = mapWallet[hash];
|
||||
|
||||
int64 nCredit = wtx.GetCredit();
|
||||
@@ -968,7 +1129,12 @@ Value gettransaction(const Array& params, bool fHelp)
|
||||
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
|
||||
if (wtx.IsFromMe())
|
||||
entry.push_back(Pair("fee", ValueFromAmount(nFee)));
|
||||
|
||||
WalletTxToJSON(mapWallet[hash], entry);
|
||||
|
||||
Array details;
|
||||
ListTransactions(mapWallet[hash], "*", 0, false, details);
|
||||
entry.push_back(Pair("details", details));
|
||||
}
|
||||
|
||||
return entry;
|
||||
@@ -1175,6 +1341,7 @@ pair<string, rpcfn_type> pCallTable[] =
|
||||
make_pair("gettransaction", &gettransaction),
|
||||
make_pair("listtransactions", &listtransactions),
|
||||
make_pair("getwork", &getwork),
|
||||
make_pair("listaccounts", &listaccounts),
|
||||
};
|
||||
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
|
||||
|
||||
@@ -1247,7 +1414,7 @@ string HTTPReply(int nStatus, const string& strMsg)
|
||||
"Server: bitcoin-json-rpc\r\n"
|
||||
"WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
|
||||
"Content-Type: text/html\r\n"
|
||||
"Content-Length: 311\r\n"
|
||||
"Content-Length: 296\r\n"
|
||||
"\r\n"
|
||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\r\n"
|
||||
"\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd\">\r\n"
|
||||
@@ -1421,6 +1588,17 @@ string JSONRPCReply(const Value& result, const Value& error, const Value& id)
|
||||
return write_string(Value(reply), false) + "\n";
|
||||
}
|
||||
|
||||
void ErrorReply(std::ostream& stream, const Object& objError, const Value& id)
|
||||
{
|
||||
// Send error reply from json-rpc error object
|
||||
int nStatus = 500;
|
||||
int code = find_value(objError, "code").get_int();
|
||||
if (code == -32600) nStatus = 400;
|
||||
else if (code == -32601) nStatus = 404;
|
||||
string strReply = JSONRPCReply(Value::null, objError, id);
|
||||
stream << HTTPReply(nStatus, strReply) << std::flush;
|
||||
}
|
||||
|
||||
bool ClientAllowed(const string& strAddress)
|
||||
{
|
||||
if (strAddress == asio::ip::address_v4::loopback().to_string())
|
||||
@@ -1581,10 +1759,16 @@ void ThreadRPCServer2(void* parg)
|
||||
if (!ClientAllowed(peer.address().to_string()))
|
||||
continue;
|
||||
|
||||
// Receive request
|
||||
map<string, string> mapHeaders;
|
||||
string strRequest;
|
||||
ReadHTTP(stream, mapHeaders, strRequest);
|
||||
|
||||
boost::thread api_caller(ReadHTTP, boost::ref(stream), boost::ref(mapHeaders), boost::ref(strRequest));
|
||||
if (!api_caller.timed_join(boost::posix_time::seconds(GetArg("-rpctimeout", 30))))
|
||||
{ // Timed out:
|
||||
acceptor.cancel();
|
||||
printf("ThreadRPCServer ReadHTTP timeout\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (mapHeaders.count("Authorization") == 0)
|
||||
@@ -1656,26 +1840,16 @@ void ThreadRPCServer2(void* parg)
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
// Send error reply from method
|
||||
string strReply = JSONRPCReply(Value::null, JSONRPCError(-1, e.what()), id);
|
||||
stream << HTTPReply(500, strReply) << std::flush;
|
||||
ErrorReply(stream, JSONRPCError(-1, e.what()), id);
|
||||
}
|
||||
}
|
||||
catch (Object& objError)
|
||||
{
|
||||
// Send error reply from json-rpc error object
|
||||
int nStatus = 500;
|
||||
int code = find_value(objError, "code").get_int();
|
||||
if (code == -32600) nStatus = 400;
|
||||
else if (code == -32601) nStatus = 404;
|
||||
string strReply = JSONRPCReply(Value::null, objError, id);
|
||||
stream << HTTPReply(nStatus, strReply) << std::flush;
|
||||
ErrorReply(stream, objError, id);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
// Send error reply from other json-rpc parsing errors
|
||||
string strReply = JSONRPCReply(Value::null, JSONRPCError(-32700, e.what()), id);
|
||||
stream << HTTPReply(500, strReply) << std::flush;
|
||||
ErrorReply(stream, JSONRPCError(-32700, e.what()), id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1812,6 +1986,7 @@ int CommandLineRPC(int argc, char *argv[])
|
||||
if (strMethod == "sendfrom" && n > 2) ConvertTo<double>(params[2]);
|
||||
if (strMethod == "sendfrom" && n > 3) ConvertTo<boost::int64_t>(params[3]);
|
||||
if (strMethod == "listtransactions" && n > 1) ConvertTo<boost::int64_t>(params[1]);
|
||||
if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);
|
||||
|
||||
// Execute
|
||||
Object reply = CallRPC(strMethod, params);
|
||||
|
||||
@@ -25,8 +25,9 @@ class CDataStream;
|
||||
class CAutoFile;
|
||||
static const unsigned int MAX_SIZE = 0x02000000;
|
||||
|
||||
static const int VERSION = 31800;
|
||||
static const int VERSION = 32001;
|
||||
static const char* pszSubVer = "";
|
||||
static const bool VERSION_IS_BETA = true;
|
||||
|
||||
|
||||
|
||||
@@ -762,6 +763,8 @@ struct secure_allocator : public std::allocator<T>
|
||||
typedef typename base::value_type value_type;
|
||||
secure_allocator() throw() {}
|
||||
secure_allocator(const secure_allocator& a) throw() : base(a) {}
|
||||
template <typename U>
|
||||
secure_allocator(const secure_allocator<U>& a) throw() : base(a) {}
|
||||
~secure_allocator() throw() {}
|
||||
template<typename _Other> struct rebind
|
||||
{ typedef secure_allocator<_Other> other; };
|
||||
|
||||
11
setup.nsi
11
setup.nsi
@@ -1,13 +1,10 @@
|
||||
# Auto-generated by EclipseNSIS Script Wizard
|
||||
# 3.10.2009 19:00:28
|
||||
|
||||
Name Bitcoin
|
||||
|
||||
RequestExecutionLevel highest
|
||||
|
||||
# General Symbol Definitions
|
||||
!define REGKEY "SOFTWARE\$(^Name)"
|
||||
!define VERSION 0.3.18
|
||||
!define VERSION 0.3.20
|
||||
!define COMPANY "Bitcoin project"
|
||||
!define URL http://www.bitcoin.org/
|
||||
|
||||
@@ -42,12 +39,12 @@ Var StartMenuGroup
|
||||
!insertmacro MUI_LANGUAGE English
|
||||
|
||||
# Installer attributes
|
||||
OutFile bitcoin-0.3.18-win32-setup.exe
|
||||
OutFile bitcoin-0.3.20-win32-setup.exe
|
||||
InstallDir $PROGRAMFILES\Bitcoin
|
||||
CRCCheck on
|
||||
XPStyle on
|
||||
ShowInstDetails show
|
||||
VIProductVersion 0.3.18.0
|
||||
VIProductVersion 0.3.20.0
|
||||
VIAddVersionKey ProductName Bitcoin
|
||||
VIAddVersionKey ProductVersion "${VERSION}"
|
||||
VIAddVersionKey CompanyName "${COMPANY}"
|
||||
@@ -64,7 +61,6 @@ Section -Main SEC0000
|
||||
SetOverwrite on
|
||||
File bitcoin.exe
|
||||
File libeay32.dll
|
||||
File mingwm10.dll
|
||||
File license.txt
|
||||
File readme.txt
|
||||
SetOutPath $INSTDIR\daemon
|
||||
@@ -113,7 +109,6 @@ done${UNSECTION_ID}:
|
||||
Section /o -un.Main UNSEC0000
|
||||
Delete /REBOOTOK $INSTDIR\bitcoin.exe
|
||||
Delete /REBOOTOK $INSTDIR\libeay32.dll
|
||||
Delete /REBOOTOK $INSTDIR\mingwm10.dll
|
||||
Delete /REBOOTOK $INSTDIR\license.txt
|
||||
Delete /REBOOTOK $INSTDIR\readme.txt
|
||||
RMDir /r /REBOOTOK $INSTDIR\daemon
|
||||
|
||||
19
ui.cpp
19
ui.cpp
@@ -746,6 +746,12 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
|
||||
strDescription += " - ";
|
||||
strDescription += mapValue["message"];
|
||||
}
|
||||
else if (!mapValue["comment"].empty())
|
||||
{
|
||||
if (!strDescription.empty())
|
||||
strDescription += " - ";
|
||||
strDescription += mapValue["comment"];
|
||||
}
|
||||
|
||||
int64 nValue = txout.nValue;
|
||||
if (nTxFee > 0)
|
||||
@@ -1405,6 +1411,8 @@ CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetails
|
||||
//
|
||||
if (!wtx.mapValue["message"].empty())
|
||||
strHTML += string() + "<br><b>" + _("Message:") + "</b><br>" + HtmlEscape(wtx.mapValue["message"], true) + "<br>";
|
||||
if (!wtx.mapValue["comment"].empty())
|
||||
strHTML += string() + "<br><b>" + _("Comment:") + "</b><br>" + HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
|
||||
|
||||
if (wtx.IsCoinBase())
|
||||
strHTML += string() + "<br>" + _("Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>";
|
||||
@@ -1458,8 +1466,7 @@ CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetails
|
||||
|
||||
void CTxDetailsDialog::OnButtonOK(wxCommandEvent& event)
|
||||
{
|
||||
Close();
|
||||
//Destroy();
|
||||
EndModal(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1728,12 +1735,12 @@ void COptionsDialog::OnKillFocusProxy(wxFocusEvent& event)
|
||||
void COptionsDialog::OnButtonOK(wxCommandEvent& event)
|
||||
{
|
||||
OnButtonApply(event);
|
||||
Close();
|
||||
EndModal(false);
|
||||
}
|
||||
|
||||
void COptionsDialog::OnButtonCancel(wxCommandEvent& event)
|
||||
{
|
||||
Close();
|
||||
EndModal(false);
|
||||
}
|
||||
|
||||
void COptionsDialog::OnButtonApply(wxCommandEvent& event)
|
||||
@@ -1796,7 +1803,7 @@ void COptionsDialog::OnButtonApply(wxCommandEvent& event)
|
||||
|
||||
CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent)
|
||||
{
|
||||
m_staticTextVersion->SetLabel(strprintf(_("version %s%s beta"), FormatVersion(VERSION).c_str(), pszSubVer));
|
||||
m_staticTextVersion->SetLabel(strprintf(_("version %s%s BETA"), FormatVersion(VERSION).c_str(), pszSubVer));
|
||||
|
||||
// Change (c) into UTF-8 or ANSI copyright symbol
|
||||
wxString str = m_staticTextMain->GetLabel();
|
||||
@@ -1820,7 +1827,7 @@ CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent)
|
||||
|
||||
void CAboutDialog::OnButtonOK(wxCommandEvent& event)
|
||||
{
|
||||
Close();
|
||||
EndModal(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ CMainFrameBase::CMainFrameBase( wxWindow* parent, wxWindowID id, const wxString&
|
||||
m_toolBar->Realize();
|
||||
|
||||
m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
|
||||
m_statusBar->SetBackgroundColour( wxColour( 240, 240, 240 ) );
|
||||
|
||||
wxBoxSizer* bSizer2;
|
||||
bSizer2 = new wxBoxSizer( wxVERTICAL );
|
||||
@@ -551,7 +550,7 @@ CAboutDialogBase::CAboutDialogBase( wxWindow* parent, wxWindowID id, const wxStr
|
||||
|
||||
bSizer631->Add( 0, 4, 0, wxEXPAND, 5 );
|
||||
|
||||
m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Satoshi Nakamoto.\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextMain = new wxStaticText( this, wxID_ANY, _("Copyright (c) 2009-2010 Bitcoin Developers\n\nThis is experimental software.\n\nDistributed under the MIT/X11 software license, see the accompanying file \nlicense.txt or http://www.opensource.org/licenses/mit-license.php.\n\nThis product includes software developed by the OpenSSL Project for use in the \nOpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \nEric Young (eay@cryptsoft.com)."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextMain->Wrap( -1 );
|
||||
bSizer631->Add( m_staticTextMain, 0, wxALL, 5 );
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@
|
||||
</object>
|
||||
</object>
|
||||
<object class="wxStatusBar" expanded="1">
|
||||
<property name="bg">240,240,240</property>
|
||||
<property name="bg"></property>
|
||||
<property name="context_help"></property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
@@ -1488,7 +1488,7 @@
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="Dialog" expanded="1">
|
||||
<object class="Dialog" expanded="0">
|
||||
<property name="bg"></property>
|
||||
<property name="center"></property>
|
||||
<property name="context_help"></property>
|
||||
@@ -3140,7 +3140,7 @@
|
||||
<property name="font"></property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Copyright (c) 2009-2010 Satoshi Nakamoto.

This is experimental software.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This product includes software developed by the OpenSSL Project for use in the 
OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by 
Eric Young (eay@cryptsoft.com).</property>
|
||||
<property name="label">Copyright (c) 2009-2010 Bitcoin Developers

This is experimental software.

Distributed under the MIT/X11 software license, see the accompanying file 
license.txt or http://www.opensource.org/licenses/mit-license.php.

This product includes software developed by the OpenSSL Project for use in the 
OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by 
Eric Young (eay@cryptsoft.com).</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">m_staticTextMain</property>
|
||||
|
||||
31
util.cpp
31
util.cpp
@@ -17,7 +17,7 @@ bool fDaemon = false;
|
||||
bool fCommandLine = false;
|
||||
string strMiscWarning;
|
||||
bool fTestNet = false;
|
||||
|
||||
bool fNoListen = false;
|
||||
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
|
||||
GetDataDir(pszFile);
|
||||
strlcat(pszFile, "/debug.log", sizeof(pszFile));
|
||||
fileout = fopen(pszFile, "a");
|
||||
setbuf(fileout, NULL); // unbuffered
|
||||
if (fileout) setbuf(fileout, NULL); // unbuffered
|
||||
}
|
||||
if (fileout)
|
||||
{
|
||||
@@ -810,19 +810,24 @@ void AddTimeData(unsigned int ip, int64 nTime)
|
||||
else
|
||||
{
|
||||
nTimeOffset = 0;
|
||||
// If nobody else has the same time as us, give a warning
|
||||
bool fMatch = false;
|
||||
foreach(int64 nOffset, vTimeOffsets)
|
||||
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
|
||||
fMatch = true;
|
||||
|
||||
static bool fDone;
|
||||
if (!fMatch && !fDone)
|
||||
if (!fDone)
|
||||
{
|
||||
fDone = true;
|
||||
string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly.");
|
||||
strMiscWarning = strMessage;
|
||||
printf("*** %s\n", strMessage.c_str());
|
||||
boost::thread(boost::bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1));
|
||||
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
|
||||
bool fMatch = false;
|
||||
foreach(int64 nOffset, vTimeOffsets)
|
||||
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
|
||||
fMatch = true;
|
||||
|
||||
if (!fMatch)
|
||||
{
|
||||
fDone = true;
|
||||
string strMessage = _("Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly.");
|
||||
strMiscWarning = strMessage;
|
||||
printf("*** %s\n", strMessage.c_str());
|
||||
boost::thread(boost::bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach(int64 n, vTimeOffsets)
|
||||
|
||||
Reference in New Issue
Block a user