aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2010-07-19 01:18:46 +0000
committerGavin Andresen <gavinandresen@gmail.com>2010-07-19 01:18:46 +0000
commite96cd730d188dde8915061ad4f19dc716dd97097 (patch)
treee88552bdefe151b5571ac082917b2c2baf5ae47f
parent4110f33cded01bde5f01a6312248fa6fdd14cc76 (diff)
json-rpc password, minor UI tweaks, removed some outdated txt files
-rw-r--r--bugs.txt2
-rw-r--r--changelog.txt7
-rw-r--r--init.cpp6
-rw-r--r--locale/de/LC_MESSAGES/bitcoin.mobin16092 -> 16083 bytes
-rw-r--r--locale/de/LC_MESSAGES/bitcoin.po2
-rw-r--r--locale/es/LC_MESSAGES/bitcoin.mobin15005 -> 14996 bytes
-rw-r--r--locale/es/LC_MESSAGES/bitcoin.po2
-rw-r--r--locale/fr/LC_MESSAGES/bitcoin.mobin15732 -> 15723 bytes
-rw-r--r--locale/fr/LC_MESSAGES/bitcoin.po2
-rw-r--r--locale/it/LC_MESSAGES/bitcoin.mobin15616 -> 15607 bytes
-rw-r--r--locale/it/LC_MESSAGES/bitcoin.po2
-rw-r--r--locale/nl/LC_MESSAGES/bitcoin.mobin14923 -> 14914 bytes
-rw-r--r--locale/nl/LC_MESSAGES/bitcoin.po2
-rw-r--r--locale/pt/LC_MESSAGES/bitcoin.mobin15663 -> 15654 bytes
-rw-r--r--locale/pt/LC_MESSAGES/bitcoin.po2
-rw-r--r--rpc.cpp81
-rw-r--r--serialize.h2
-rw-r--r--ui.cpp4
-rw-r--r--util.cpp3
19 files changed, 71 insertions, 46 deletions
diff --git a/bugs.txt b/bugs.txt
deleted file mode 100644
index 806c777ba1..0000000000
--- a/bugs.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Known bugs:
-- Window flickers when blocks are added (problem with repainting?) \ No newline at end of file
diff --git a/changelog.txt b/changelog.txt
deleted file mode 100644
index d2380b8a09..0000000000
--- a/changelog.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Changes after 0.1.5:
---------------------
-+ Options dialog layout changed - added the UI options panel
-+ Minimize to tray feature
-+ Startup on system boot feature
-+ Ask before closing
-+ NSIS installer \ No newline at end of file
diff --git a/init.cpp b/init.cpp
index ba57866a4b..dcd2c50936 100644
--- a/init.cpp
+++ b/init.cpp
@@ -389,7 +389,7 @@ bool CMyApp::OnInit2()
" bitcoin [options] \t" + "\n" +
" bitcoin [command] \t" + _("Send command to bitcoin running with -server or -daemon\n") +
" bitcoin [command] -? \t" + _("Get help for a command\n") +
- " bitcoin help \t" + _("List commands\n") +
+ " bitcoin help <pw> \t" + _("List commands\n") +
_("Options:\n") +
" -gen \t " + _("Generate coins\n") +
" -gen=0 \t " + _("Don't generate coins\n") +
@@ -398,7 +398,7 @@ bool CMyApp::OnInit2()
" -proxy=<ip:port>\t " + _("Connect through socks4 proxy\n") +
" -addnode=<ip> \t " + _("Add a node to connect to\n") +
" -connect=<ip> \t " + _("Connect only to the specified node\n") +
- " -server \t " + _("Accept command line and JSON-RPC commands\n") +
+ " -rpcpw=<pw> \t " + _("Accept command line and JSON-RPC commands with the given password\n") +
" -daemon \t " + _("Run in the background as a daemon and accept commands\n") +
" -? \t " + _("This help message\n");
@@ -611,7 +611,7 @@ bool CMyApp::OnInit2()
if (!CreateThread(StartNode, NULL))
wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin");
- if (mapArgs.count("-server") || fDaemon)
+ if (mapArgs.count("-server") || mapArgs.count("-rpcpw") || fDaemon)
CreateThread(ThreadRPCServer, NULL);
if (fFirstRun)
diff --git a/locale/de/LC_MESSAGES/bitcoin.mo b/locale/de/LC_MESSAGES/bitcoin.mo
index d53b22f7b1..2b5ff6f963 100644
--- a/locale/de/LC_MESSAGES/bitcoin.mo
+++ b/locale/de/LC_MESSAGES/bitcoin.mo
Binary files differ
diff --git a/locale/de/LC_MESSAGES/bitcoin.po b/locale/de/LC_MESSAGES/bitcoin.po
index 9d1b6b08cb..b8857929ab 100644
--- a/locale/de/LC_MESSAGES/bitcoin.po
+++ b/locale/de/LC_MESSAGES/bitcoin.po
@@ -216,7 +216,7 @@ msgstr "&Neue Empfangs-Adresse"
#: ../../../ui.cpp:1124
#: ../../../ui.cpp:2352
msgid ""
-"It's good policy to use a new address for each payment you receive.\n"
+"You should use a new address for each payment you receive.\n"
"\n"
"Label"
msgstr ""
diff --git a/locale/es/LC_MESSAGES/bitcoin.mo b/locale/es/LC_MESSAGES/bitcoin.mo
index 96bdece336..8d7cf0ba68 100644
--- a/locale/es/LC_MESSAGES/bitcoin.mo
+++ b/locale/es/LC_MESSAGES/bitcoin.mo
Binary files differ
diff --git a/locale/es/LC_MESSAGES/bitcoin.po b/locale/es/LC_MESSAGES/bitcoin.po
index e0b3170b49..b55a8daa70 100644
--- a/locale/es/LC_MESSAGES/bitcoin.po
+++ b/locale/es/LC_MESSAGES/bitcoin.po
@@ -242,7 +242,7 @@ msgstr "Nueva direccion de recepcion"
#: ../../../ui.cpp:1129
#: ../../../ui.cpp:2369
msgid ""
-"It's good policy to use a new address for each payment you receive.\n"
+"You should use a new address for each payment you receive.\n"
"\n"
"Label"
msgstr ""
diff --git a/locale/fr/LC_MESSAGES/bitcoin.mo b/locale/fr/LC_MESSAGES/bitcoin.mo
index c42e539d4e..25db2af273 100644
--- a/locale/fr/LC_MESSAGES/bitcoin.mo
+++ b/locale/fr/LC_MESSAGES/bitcoin.mo
Binary files differ
diff --git a/locale/fr/LC_MESSAGES/bitcoin.po b/locale/fr/LC_MESSAGES/bitcoin.po
index f8a7e48943..46ee83c200 100644
--- a/locale/fr/LC_MESSAGES/bitcoin.po
+++ b/locale/fr/LC_MESSAGES/bitcoin.po
@@ -242,7 +242,7 @@ msgstr "Nouvelle adresse de reception"
#: ../../../ui.cpp:1129
#: ../../../ui.cpp:2369
msgid ""
-"It's good policy to use a new address for each payment you receive.\n"
+"You should use a new address for each payment you receive.\n"
"\n"
"Label"
msgstr ""
diff --git a/locale/it/LC_MESSAGES/bitcoin.mo b/locale/it/LC_MESSAGES/bitcoin.mo
index dc7b94edfa..4a4f7a3fd1 100644
--- a/locale/it/LC_MESSAGES/bitcoin.mo
+++ b/locale/it/LC_MESSAGES/bitcoin.mo
Binary files differ
diff --git a/locale/it/LC_MESSAGES/bitcoin.po b/locale/it/LC_MESSAGES/bitcoin.po
index 7a267079fc..ef75bf6219 100644
--- a/locale/it/LC_MESSAGES/bitcoin.po
+++ b/locale/it/LC_MESSAGES/bitcoin.po
@@ -216,7 +216,7 @@ msgstr "Nuovo indirizzo ricevente"
#: ../../../ui.cpp:1124
#: ../../../ui.cpp:2352
msgid ""
-"It's good policy to use a new address for each payment you receive.\n"
+"You should use a new address for each payment you receive.\n"
"\n"
"Label"
msgstr ""
diff --git a/locale/nl/LC_MESSAGES/bitcoin.mo b/locale/nl/LC_MESSAGES/bitcoin.mo
index 380eafe929..2b515433b0 100644
--- a/locale/nl/LC_MESSAGES/bitcoin.mo
+++ b/locale/nl/LC_MESSAGES/bitcoin.mo
Binary files differ
diff --git a/locale/nl/LC_MESSAGES/bitcoin.po b/locale/nl/LC_MESSAGES/bitcoin.po
index c97d7d63d2..54ef4d3c67 100644
--- a/locale/nl/LC_MESSAGES/bitcoin.po
+++ b/locale/nl/LC_MESSAGES/bitcoin.po
@@ -216,7 +216,7 @@ msgstr "Nieuw Ontvangings Adres"
#: ../../../ui.cpp:1124
#: ../../../ui.cpp:2352
msgid ""
-"It's good policy to use a new address for each payment you receive.\n"
+"You should use a new address for each payment you receive.\n"
"\n"
"Label"
msgstr ""
diff --git a/locale/pt/LC_MESSAGES/bitcoin.mo b/locale/pt/LC_MESSAGES/bitcoin.mo
index 0b7d49fa45..dceec49df2 100644
--- a/locale/pt/LC_MESSAGES/bitcoin.mo
+++ b/locale/pt/LC_MESSAGES/bitcoin.mo
Binary files differ
diff --git a/locale/pt/LC_MESSAGES/bitcoin.po b/locale/pt/LC_MESSAGES/bitcoin.po
index 827f14a5ac..8280d94a2a 100644
--- a/locale/pt/LC_MESSAGES/bitcoin.po
+++ b/locale/pt/LC_MESSAGES/bitcoin.po
@@ -216,7 +216,7 @@ msgstr "Novo Endereço de Recepção"
#: ../../../ui.cpp:1124
#: ../../../ui.cpp:2352
msgid ""
-"It's good policy to use a new address for each payment you receive.\n"
+"You should use a new address for each payment you receive.\n"
"\n"
"Label"
msgstr ""
diff --git a/rpc.cpp b/rpc.cpp
index ecc3d6a5ff..57738b89aa 100644
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -21,6 +21,8 @@ void ThreadRPCServer2(void* parg);
typedef Value(*rpcfn_type)(const Array& params, bool fHelp);
extern map<string, rpcfn_type> mapCallTable;
+static string strRPCPassword;
+
@@ -37,16 +39,24 @@ Value help(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "help\n"
+ "help <pw>\n"
"List commands.");
string strRet;
+ set<rpcfn_type> setDone;
for (map<string, rpcfn_type>::iterator mi = mapCallTable.begin(); mi != mapCallTable.end(); ++mi)
{
+ string strMethod = (*mi).first;
+ // We already filter duplicates, but these deprecated screw up the sort order
+ if (strMethod == "getamountreceived" ||
+ strMethod == "getallreceived")
+ continue;
try
{
Array params;
- (*(*mi).second)(params, true);
+ rpcfn_type pfn = (*mi).second;
+ if (setDone.insert(pfn).second)
+ (*pfn)(params, true);
}
catch (std::exception& e)
{
@@ -66,7 +76,7 @@ Value stop(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "stop\n"
+ "stop <pw>\n"
"Stop bitcoin server.");
// Shutdown will take long enough that the response should get back
@@ -79,7 +89,7 @@ Value getblockcount(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "getblockcount\n"
+ "getblockcount <pw>\n"
"Returns the number of blocks in the longest block chain.");
return nBestHeight + 1;
@@ -90,7 +100,7 @@ Value getblocknumber(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "getblocknumber\n"
+ "getblocknumber <pw>\n"
"Returns the block number of the latest block in the longest block chain.");
return nBestHeight;
@@ -101,7 +111,7 @@ Value getconnectioncount(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "getconnectioncount\n"
+ "getconnectioncount <pw>\n"
"Returns the number of connections to other nodes.");
return (int)vNodes.size();
@@ -124,7 +134,7 @@ Value getdifficulty(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "getdifficulty\n"
+ "getdifficulty <pw>\n"
"Returns the proof-of-work difficulty as a multiple of the minimum difficulty.");
return GetDifficulty();
@@ -135,7 +145,7 @@ Value getbalance(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "getbalance\n"
+ "getbalance <pw>\n"
"Returns the server's available balance.");
return ((double)GetBalance() / (double)COIN);
@@ -146,7 +156,7 @@ Value getgenerate(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "getgenerate\n"
+ "getgenerate <pw>\n"
"Returns true or false.");
return (bool)fGenerateBitcoins;
@@ -157,7 +167,7 @@ Value setgenerate(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "setgenerate <generate> [genproclimit]\n"
+ "setgenerate <pw> <generate> [genproclimit]\n"
"<generate> is true or false to turn generation on or off.\n"
"Generation is limited to [genproclimit] processors, -1 is unlimited.");
@@ -183,7 +193,7 @@ Value getinfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
throw runtime_error(
- "getinfo");
+ "getinfo <pw>");
Object obj;
obj.push_back(Pair("balance", (double)GetBalance() / (double)COIN));
@@ -201,7 +211,7 @@ Value getnewaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
throw runtime_error(
- "getnewaddress [label]\n"
+ "getnewaddress <pw> [label]\n"
"Returns a new bitcoin address for receiving payments. "
"If [label] is specified (recommended), it is added to the address book "
"so payments received with the address will be labeled.");
@@ -223,7 +233,7 @@ Value setlabel(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "setlabel <bitcoinaddress> <label>\n"
+ "setlabel <pw> <bitcoinaddress> <label>\n"
"Sets the label associated with the given address.");
string strAddress = params[0].get_str();
@@ -240,7 +250,7 @@ Value getlabel(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
- "getlabel <bitcoinaddress>\n"
+ "getlabel <pw> <bitcoinaddress>\n"
"Returns the label associated with the given address.");
string strAddress = params[0].get_str();
@@ -260,7 +270,7 @@ Value getaddressesbylabel(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
- "getaddressesbylabel <label>\n"
+ "getaddressesbylabel <pw> <label>\n"
"Returns the list of addresses with the given label.");
string strLabel = params[0].get_str();
@@ -290,7 +300,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 2 || params.size() > 4)
throw runtime_error(
- "sendtoaddress <bitcoinaddress> <amount> [comment] [comment-to]\n"
+ "sendtoaddress <pw> <bitcoinaddress> <amount> [comment] [comment-to]\n"
"<amount> is a real and is rounded to the nearest 0.01");
string strAddress = params[0].get_str();
@@ -318,7 +328,7 @@ Value listtransactions(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
- "listtransactions [count=10] [includegenerated=false]\n"
+ "listtransactions <pw> [count=10] [includegenerated=false]\n"
"Returns up to [count] most recent transactions.");
int64 nCount = 10;
@@ -339,7 +349,7 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "getreceivedbyaddress <bitcoinaddress> [minconf=1]\n"
+ "getreceivedbyaddress <pw> <bitcoinaddress> [minconf=1]\n"
"Returns the total amount received by <bitcoinaddress> in transactions with at least [minconf] confirmations.");
// Bitcoin address
@@ -380,7 +390,7 @@ Value getreceivedbylabel(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
- "getreceivedbylabel <label> [minconf=1]\n"
+ "getreceivedbylabel <pw> <label> [minconf=1]\n"
"Returns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.");
// Get the set of pub keys that have the label
@@ -543,7 +553,7 @@ Value listreceivedbyaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
- "listreceivedbyaddress [minconf=1] [includeempty=false]\n"
+ "listreceivedbyaddress <pw> [minconf=1] [includeempty=false]\n"
"[minconf] is the minimum number of confirmations before payments are included.\n"
"[includeempty] whether to include addresses that haven't received any payments.\n"
"Returns an array of objects containing:\n"
@@ -559,7 +569,7 @@ Value listreceivedbylabel(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 2)
throw runtime_error(
- "listreceivedbylabel [minconf=1] [includeempty=false]\n"
+ "listreceivedbylabel <pw> [minconf=1] [includeempty=false]\n"
"[minconf] is the minimum number of confirmations before payments are included.\n"
"[includeempty] whether to include labels that haven't received any payments.\n"
"Returns an array of objects containing:\n"
@@ -603,7 +613,6 @@ pair<string, rpcfn_type> pCallTable[] =
make_pair("getlabel", &getlabel),
make_pair("getaddressesbylabel", &getaddressesbylabel),
make_pair("sendtoaddress", &sendtoaddress),
- make_pair("listtransactions", &listtransactions),
make_pair("getamountreceived", &getreceivedbyaddress), // deprecated, renamed to getreceivedbyaddress
make_pair("getallreceived", &listreceivedbyaddress), // deprecated, renamed to listreceivedbyaddress
make_pair("getreceivedbyaddress", &getreceivedbyaddress),
@@ -742,6 +751,17 @@ void ThreadRPCServer2(void* parg)
{
printf("ThreadRPCServer started\n");
+ if (mapArgs.count("-rpcpw"))
+ strRPCPassword = mapArgs["-rpcpw"];
+ if (strRPCPassword == "")
+ {
+#if defined(__WXMSW__) && wxUSE_GUI
+ MyMessageBox("Warning: rpc password is blank, use -rpcpw=<password>\n", "Bitcoin", wxOK | wxICON_EXCLAMATION);
+#else
+ fprintf(stdout, "Warning: rpc password is blank, use -rpcpw=<password>\n");
+#endif
+ }
+
// Bind to loopback 127.0.0.1 so the socket can only be accessed locally
boost::asio::io_service io_service;
tcp::endpoint endpoint(boost::asio::ip::address_v4::loopback(), 8332);
@@ -764,7 +784,6 @@ void ThreadRPCServer2(void* parg)
// Receive request
string strRequest = ReadHTTP(stream);
- printf("ThreadRPCServer request=%s", strRequest.c_str());
// Handle multiple invocations per request
string::iterator begin = strRequest.begin();
@@ -787,11 +806,25 @@ void ThreadRPCServer2(void* parg)
const Array& params = find_value(request, "params").get_array();
id = find_value(request, "id");
+ printf("ThreadRPCServer method=%s\n", strMethod.c_str());
+
+ // Check password
+ if (params.size() < 1 || params[0].type() != str_type)
+ throw runtime_error("First parameter must be the password.");
+ if (params[0].get_str() != strRPCPassword)
+ {
+ if (strRPCPassword.size() < 15)
+ Sleep(50);
+ begin = strRequest.end();
+ printf("ThreadRPCServer incorrect password attempt\n");
+ throw runtime_error("Incorrect password.");
+ }
+
// Execute
map<string, rpcfn_type>::iterator mi = mapCallTable.find(strMethod);
if (mi == mapCallTable.end())
throw runtime_error("Method not found.");
- Value result = (*(*mi).second)(params, false);
+ Value result = (*(*mi).second)(Array(params.begin()+1, params.end()), false);
// Send reply
string strReply = JSONRPCReply(result, Value::null, id);
diff --git a/serialize.h b/serialize.h
index 59ae025728..0ee4da140c 100644
--- a/serialize.h
+++ b/serialize.h
@@ -20,7 +20,7 @@ class CDataStream;
class CAutoFile;
static const int VERSION = 302;
-static const char* pszSubVer = "";
+static const char* pszSubVer = ".2";
diff --git a/ui.cpp b/ui.cpp
index 3da94a201b..c184fc4950 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -1132,7 +1132,7 @@ void CMainFrame::OnButtonNew(wxCommandEvent& event)
// Ask name
CGetTextFromUserDialog dialog(this,
_("New Receiving Address"),
- _("It's good policy to use a new address for each payment you receive.\n\nLabel"),
+ _("You should use a new address for each payment you receive.\n\nLabel"),
"");
if (!dialog.ShowModal())
return;
@@ -2372,7 +2372,7 @@ void CAddressBookDialog::OnButtonNew(wxCommandEvent& event)
// Ask name
CGetTextFromUserDialog dialog(this,
_("New Receiving Address"),
- _("It's good policy to use a new address for each payment you receive.\n\nLabel"),
+ _("You should use a new address for each payment you receive.\n\nLabel"),
"");
if (!dialog.ShowModal())
return;
diff --git a/util.cpp b/util.cpp
index c374dc2d3b..c94ee0aaea 100644
--- a/util.cpp
+++ b/util.cpp
@@ -701,12 +701,13 @@ void AddTimeData(unsigned int ip, int64 nTime)
sort(vTimeOffsets.begin(), vTimeOffsets.end());
int64 nMedian = vTimeOffsets[vTimeOffsets.size()/2];
nTimeOffset = nMedian;
- if ((nMedian > 0 ? nMedian : -nMedian) > 5 * 60)
+ if ((nMedian > 0 ? nMedian : -nMedian) > 36 * 60 * 60)
{
// Only let other nodes change our clock so far before we
// go to the NTP servers
/// todo: Get time from NTP servers, then set a flag
/// to make sure it doesn't get changed again
+ nTimeOffset = 0;
}
foreach(int64 n, vTimeOffsets)
printf("%+"PRI64d" ", n);