aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bitcoinrpc.cpp9
-rw-r--r--src/bitcoinrpc.h2
-rw-r--r--src/clientversion.h6
-rw-r--r--src/init.cpp5
-rw-r--r--src/key.cpp4
-rw-r--r--src/main.cpp23
-rw-r--r--src/qt/locale/bitcoin_ar.ts2
-rw-r--r--src/rpcmining.cpp9
-rw-r--r--src/rpcwallet.cpp14
-rw-r--r--src/test/checkblock_tests.cpp2
-rw-r--r--src/test/rpc_tests.cpp35
-rw-r--r--src/util.h2
12 files changed, 68 insertions, 45 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index a9b73fd5a6..2c4744a579 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -30,6 +30,10 @@ using namespace boost;
using namespace boost::asio;
using namespace json_spirit;
+// Key used by getwork/getblocktemplate miners.
+// Allocated in StartRPCThreads, free'd in StopRPCThreads
+CReserveKey* pMiningKey = NULL;
+
static std::string strRPCUserColonPass;
// These are created by StartRPCThreads, destroyed in StopRPCThreads
@@ -722,6 +726,9 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol,
void StartRPCThreads()
{
+ // getwork/getblocktemplate mining rewards paid here:
+ pMiningKey = new CReserveKey(pwalletMain);
+
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
if ((mapArgs["-rpcpassword"] == "") ||
(mapArgs["-rpcuser"] == mapArgs["-rpcpassword"]))
@@ -841,6 +848,8 @@ void StartRPCThreads()
void StopRPCThreads()
{
+ delete pMiningKey; pMiningKey = NULL;
+
if (rpc_io_service == NULL) return;
rpc_io_service->stop();
diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h
index 315fd92383..cf5b137988 100644
--- a/src/bitcoinrpc.h
+++ b/src/bitcoinrpc.h
@@ -11,6 +11,7 @@
#include <map>
class CBlockIndex;
+class CReserveKey;
#include "json/json_spirit_reader_template.h"
#include "json/json_spirit_writer_template.h"
@@ -122,6 +123,7 @@ public:
};
extern const CRPCTable tableRPC;
+extern CReserveKey* pMiningKey;
extern int64 nWalletUnlockTime;
extern int64 AmountFromValue(const json_spirit::Value& value);
diff --git a/src/clientversion.h b/src/clientversion.h
index aabab4c726..30c0c4072b 100644
--- a/src/clientversion.h
+++ b/src/clientversion.h
@@ -8,11 +8,11 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 8
-#define CLIENT_VERSION_REVISION 2
-#define CLIENT_VERSION_BUILD 1
+#define CLIENT_VERSION_REVISION 99
+#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build
-#define CLIENT_VERSION_IS_RELEASE true
+#define CLIENT_VERSION_IS_RELEASE false
// Copyright year (2009-this)
// Todo: update this when changing our copyright comments in the source
diff --git a/src/init.cpp b/src/init.cpp
index 6dafcc4af0..2175f73d70 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -101,7 +101,8 @@ void Shutdown()
StopNode();
{
LOCK(cs_main);
- pwalletMain->SetBestChain(CBlockLocator(pindexBest));
+ if (pwalletMain)
+ pwalletMain->SetBestChain(CBlockLocator(pindexBest));
if (pblocktree)
pblocktree->Flush();
if (pcoinsTip)
@@ -532,7 +533,7 @@ bool AppInit2(boost::thread_group& threadGroup)
// Make sure enough file descriptors are available
int nBind = std::max((int)mapArgs.count("-bind"), 1);
nMaxConnections = GetArg("-maxconnections", 125);
- nMaxConnections = std::max(std::min(nMaxConnections, FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS), 0);
+ nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS);
if (nFD < MIN_CORE_FILEDESCRIPTORS)
return InitError(_("Not enough file descriptors available."));
diff --git a/src/key.cpp b/src/key.cpp
index 20114e6bb2..75114c6afe 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -328,7 +328,10 @@ bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
}
if (nRecId == -1)
+ {
+ ECDSA_SIG_free(sig);
throw key_error("CKey::SignCompact() : unable to construct recoverable key");
+ }
vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0);
BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);
@@ -367,6 +370,7 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector<unsigned char>& v
ECDSA_SIG_free(sig);
return true;
}
+ ECDSA_SIG_free(sig);
return false;
}
diff --git a/src/main.cpp b/src/main.cpp
index b7efac53b1..a03921e9b5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2073,25 +2073,6 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
return state.DoS(100, error("CheckBlock() : size limits failed"));
- // Special short-term limits to avoid 10,000 BDB lock limit:
- if (GetBlockTime() >= 1363867200 && // start enforcing 21 March 2013, noon GMT
- GetBlockTime() < 1368576000) // stop enforcing 15 May 2013 00:00:00
- {
- // Rule is: #unique txids referenced <= 4,500
- // ... to prevent 10,000 BDB lock exhaustion on old clients
- set<uint256> setTxIn;
- for (size_t i = 0; i < vtx.size(); i++)
- {
- setTxIn.insert(vtx[i].GetHash());
- if (i == 0) continue; // skip coinbase txin
- BOOST_FOREACH(const CTxIn& txin, vtx[i].vin)
- setTxIn.insert(txin.prevout.hash);
- }
- size_t nTxids = setTxIn.size();
- if (nTxids > 4500)
- return error("CheckBlock() : 15 May maxlocks violation");
- }
-
// Check proof of work matches claimed amount
if (fCheckPOW && !CheckProofOfWork(GetHash(), nBits))
return state.DoS(50, error("CheckBlock() : proof of work failed"));
@@ -4188,10 +4169,6 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey)
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
- // Special compatibility rule before 15 May: limit size to 500,000 bytes:
- if (GetAdjustedTime() < 1368576000)
- nBlockMaxSize = std::min(nBlockMaxSize, (unsigned int)(MAX_BLOCK_SIZE_GEN));
-
// How much of the block should be dedicated to high-priority transactions,
// included regardless of the fees they pay
unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000);
diff --git a/src/qt/locale/bitcoin_ar.ts b/src/qt/locale/bitcoin_ar.ts
index 028080d545..741a25a4da 100644
--- a/src/qt/locale/bitcoin_ar.ts
+++ b/src/qt/locale/bitcoin_ar.ts
@@ -38,7 +38,7 @@ This product includes software developed by the OpenSSL Project for use in the O
<message>
<location filename="../forms/addressbookpage.ui" line="+14"/>
<source>Address Book</source>
- <translation>كتاب العنوانين</translation>
+ <translation>دفتر العناوين</translation>
</message>
<message>
<location line="+19"/>
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index fddda8b5f4..b8b7459634 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -104,7 +104,6 @@ Value getwork(const Array& params, bool fHelp)
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
static vector<CBlockTemplate*> vNewBlockTemplate;
- static CReserveKey reservekey(pwalletMain);
if (params.size() == 0)
{
@@ -134,7 +133,7 @@ Value getwork(const Array& params, bool fHelp)
nStart = GetTime();
// Create new block
- pblocktemplate = CreateNewBlock(reservekey);
+ pblocktemplate = CreateNewBlock(*pMiningKey);
if (!pblocktemplate)
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
vNewBlockTemplate.push_back(pblocktemplate);
@@ -192,7 +191,7 @@ Value getwork(const Array& params, bool fHelp)
pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second;
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
- return CheckWork(pblock, *pwalletMain, reservekey);
+ return CheckWork(pblock, *pwalletMain, *pMiningKey);
}
}
@@ -243,8 +242,6 @@ Value getblocktemplate(const Array& params, bool fHelp)
if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Bitcoin is downloading blocks...");
- static CReserveKey reservekey(pwalletMain);
-
// Update block
static unsigned int nTransactionsUpdatedLast;
static CBlockIndex* pindexPrev;
@@ -267,7 +264,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
delete pblocktemplate;
pblocktemplate = NULL;
}
- pblocktemplate = CreateNewBlock(reservekey);
+ pblocktemplate = CreateNewBlock(*pMiningKey);
if (!pblocktemplate)
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 5fd400c6bb..e156469d11 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -811,6 +811,7 @@ struct tallyitem
{
int64 nAmount;
int nConf;
+ vector<uint256> txids;
tallyitem()
{
nAmount = 0;
@@ -852,6 +853,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
tallyitem& item = mapTally[address];
item.nAmount += txout.nValue;
item.nConf = min(item.nConf, nDepth);
+ item.txids.push_back(wtx.GetHash());
}
}
@@ -887,6 +889,15 @@ Value ListReceived(const Array& params, bool fByAccounts)
obj.push_back(Pair("account", strAccount));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
+ Array transactions;
+ if (it != mapTally.end())
+ {
+ BOOST_FOREACH(const uint256& item, (*it).second.txids)
+ {
+ transactions.push_back(item.GetHex());
+ }
+ }
+ obj.push_back(Pair("txids", transactions));
ret.push_back(obj);
}
}
@@ -919,7 +930,8 @@ Value listreceivedbyaddress(const Array& params, bool fHelp)
" \"address\" : receiving address\n"
" \"account\" : the account of the receiving address\n"
" \"amount\" : total amount received by the address\n"
- " \"confirmations\" : number of confirmations of the most recent transaction included");
+ " \"confirmations\" : number of confirmations of the most recent transaction included\n"
+ " \"txids\" : list of transactions with outputs to the address\n");
return ListReceived(params, false);
}
diff --git a/src/test/checkblock_tests.cpp b/src/test/checkblock_tests.cpp
index 3cfb6dbfa4..d626f9a6f4 100644
--- a/src/test/checkblock_tests.cpp
+++ b/src/test/checkblock_tests.cpp
@@ -52,8 +52,6 @@ BOOST_AUTO_TEST_CASE(May15)
if (read_block("Mar12Fork.dat", forkingBlock))
{
CValidationState state;
- forkingBlock.nTime = tMay15-1; // Invalidates PoW
- BOOST_CHECK(!forkingBlock.CheckBlock(state, false, false));
// After May 15'th, big blocks are OK:
forkingBlock.nTime = tMay15; // Invalidates PoW
diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp
index f8fe443b87..35eabed0e2 100644
--- a/src/test/rpc_tests.cpp
+++ b/src/test/rpc_tests.cpp
@@ -79,23 +79,44 @@ static Value CallRPC(string args)
}
}
-BOOST_AUTO_TEST_CASE(rpc_rawparams)
+BOOST_AUTO_TEST_CASE(rpc_wallet)
{
- // Test raw transaction API argument handling
+ // Test RPC calls for various wallet statistics
Value r;
- BOOST_CHECK_THROW(CallRPC("getrawtransaction"), runtime_error);
- BOOST_CHECK_THROW(CallRPC("getrawtransaction not_hex"), runtime_error);
- BOOST_CHECK_THROW(CallRPC("getrawtransaction a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed not_int"), runtime_error);
-
BOOST_CHECK_NO_THROW(CallRPC("listunspent"));
BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error);
BOOST_CHECK_THROW(CallRPC("listunspent 0 string"), runtime_error);
BOOST_CHECK_THROW(CallRPC("listunspent 0 1 not_array"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("listunspent 0 1 [] extra"), runtime_error);
BOOST_CHECK_NO_THROW(r=CallRPC("listunspent 0 1 []"));
- BOOST_CHECK_THROW(r=CallRPC("listunspent 0 1 [] extra"), runtime_error);
BOOST_CHECK(r.get_array().empty());
+ BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress"));
+ BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress 0"));
+ BOOST_CHECK_THROW(CallRPC("listreceivedbyaddress not_int"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("listreceivedbyaddress 0 not_bool"), runtime_error);
+ BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaddress 0 true"));
+ BOOST_CHECK_THROW(CallRPC("listreceivedbyaddress 0 true extra"), runtime_error);
+
+ BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaccount"));
+ BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaccount 0"));
+ BOOST_CHECK_THROW(CallRPC("listreceivedbyaccount not_int"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("listreceivedbyaccount 0 not_bool"), runtime_error);
+ BOOST_CHECK_NO_THROW(CallRPC("listreceivedbyaccount 0 true"));
+ BOOST_CHECK_THROW(CallRPC("listreceivedbyaccount 0 true extra"), runtime_error);
+}
+
+
+BOOST_AUTO_TEST_CASE(rpc_rawparams)
+{
+ // Test raw transaction API argument handling
+ Value r;
+
+ BOOST_CHECK_THROW(CallRPC("getrawtransaction"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("getrawtransaction not_hex"), runtime_error);
+ BOOST_CHECK_THROW(CallRPC("getrawtransaction a3b807410df0b60fcb9736768df5823938b2f838694939ba45f3c0a1bff150ed not_int"), runtime_error);
+
BOOST_CHECK_THROW(CallRPC("createrawtransaction"), runtime_error);
BOOST_CHECK_THROW(CallRPC("createrawtransaction null null"), runtime_error);
BOOST_CHECK_THROW(CallRPC("createrawtransaction not_array"), runtime_error);
diff --git a/src/util.h b/src/util.h
index 3d25364505..51a694483a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -7,6 +7,8 @@
#include "uint256.h"
+#include <stdarg.h>
+
#ifndef WIN32
#include <sys/types.h>
#include <sys/time.h>