update some main files
This commit is contained in:
@@ -3,16 +3,16 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "addrdb.h"
|
||||
#include <addrdb.h>
|
||||
|
||||
#include "addrman.h"
|
||||
#include "chainparams.h"
|
||||
#include "clientversion.h"
|
||||
#include "hash.h"
|
||||
#include "random.h"
|
||||
#include "streams.h"
|
||||
#include "tinyformat.h"
|
||||
#include "util.h"
|
||||
#include <addrman.h>
|
||||
#include <chainparams.h>
|
||||
#include <clientversion.h>
|
||||
#include <hash.h>
|
||||
#include <random.h>
|
||||
#include <streams.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef BITCOIN_ADDRDB_H
|
||||
#define BITCOIN_ADDRDB_H
|
||||
|
||||
#include "serialize.h"
|
||||
#include <serialize.h>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "addrman.h"
|
||||
#include <addrman.h>
|
||||
|
||||
#include "hash.h"
|
||||
#include "serialize.h"
|
||||
#include "streams.h"
|
||||
#include <hash.h>
|
||||
#include <serialize.h>
|
||||
#include <streams.h>
|
||||
|
||||
int CAddrInfo::GetTriedBucket(const uint256& nKey) const
|
||||
{
|
||||
@@ -76,13 +76,13 @@ CAddrInfo* CAddrMan::Find(const CNetAddr& addr, int* pnId)
|
||||
{
|
||||
std::map<CNetAddr, int>::iterator it = mapAddr.find(addr);
|
||||
if (it == mapAddr.end())
|
||||
return NULL;
|
||||
return nullptr;
|
||||
if (pnId)
|
||||
*pnId = (*it).second;
|
||||
std::map<int, CAddrInfo>::iterator it2 = mapInfo.find((*it).second);
|
||||
if (it2 != mapInfo.end())
|
||||
return &(*it2).second;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CAddrInfo* CAddrMan::Create(const CAddress& addr, const CNetAddr& addrSource, int* pnId)
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#ifndef BITCOIN_ADDRMAN_H
|
||||
#define BITCOIN_ADDRMAN_H
|
||||
|
||||
#include "netaddress.h"
|
||||
#include "protocol.h"
|
||||
#include "random.h"
|
||||
#include "sync.h"
|
||||
#include "timedata.h"
|
||||
#include "util.h"
|
||||
#include <netbase.h>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
#include <sync.h>
|
||||
#include <timedata.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "amount.h"
|
||||
#include "math.h"
|
||||
#include <amount.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "tinyformat.h"
|
||||
#include <tinyformat.h>
|
||||
|
||||
const std::string CURRENCY_UNIT = "BLK";
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef BITCOIN_AMOUNT_H
|
||||
#define BITCOIN_AMOUNT_H
|
||||
|
||||
#include "serialize.h"
|
||||
#include <serialize.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
@@ -21,8 +21,7 @@ extern const std::string CURRENCY_UNIT;
|
||||
|
||||
/** No amount larger than this (in satoshi) is valid.
|
||||
*
|
||||
* Note that this constant is *not* the total money supply, which in Bitcoin
|
||||
* currently happens to be less than 21,000,000 BTC for various reasons, but
|
||||
* Note that this constant is *not* the total money supply, but
|
||||
* rather a sanity check. As this sanity check is used by consensus-critical
|
||||
* validation code, the exact value of the MAX_MONEY constant is consensus
|
||||
* critical; in unusual circumstances like a(nother) overflow bug that allowed
|
||||
@@ -52,7 +51,7 @@ public:
|
||||
/**
|
||||
* Return the fee in satoshis for a size of 1000 bytes
|
||||
*/
|
||||
CAmount GetFeePerK() const { return GetFee(1000); }
|
||||
CAmount GetFeePerK() const { return GetFee(10000); }
|
||||
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
|
||||
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
|
||||
friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "arith_uint256.h"
|
||||
#include <arith_uint256.h>
|
||||
|
||||
#include "uint256.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "crypto/common.h"
|
||||
#include <uint256.h>
|
||||
#include <utilstrencodings.h>
|
||||
#include <crypto/common.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -216,8 +216,8 @@ arith_uint256& arith_uint256::SetCompact(uint32_t nCompact, bool* pfNegative, bo
|
||||
*pfNegative = nWord != 0 && (nCompact & 0x00800000) != 0;
|
||||
if (pfOverflow)
|
||||
*pfOverflow = nWord != 0 && ((nSize > 34) ||
|
||||
(nWord > 0xff && nSize > 33) ||
|
||||
(nWord > 0xffff && nSize > 32));
|
||||
(nWord > 0xff && nSize > 33) ||
|
||||
(nWord > 0xffff && nSize > 32));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,20 +15,21 @@
|
||||
|
||||
class uint256;
|
||||
|
||||
class uint_error : public std::runtime_error {
|
||||
class uint_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit uint_error(const std::string& str) : std::runtime_error(str) {}
|
||||
};
|
||||
|
||||
/** Template base class for unsigned big integers. */
|
||||
template<unsigned int BITS>
|
||||
template <unsigned int BITS>
|
||||
class base_uint
|
||||
{
|
||||
protected:
|
||||
enum { WIDTH=BITS/32 };
|
||||
enum { WIDTH = BITS / 32 };
|
||||
uint32_t pn[WIDTH];
|
||||
public:
|
||||
|
||||
public:
|
||||
base_uint()
|
||||
{
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
@@ -135,8 +136,7 @@ public:
|
||||
base_uint& operator+=(const base_uint& b)
|
||||
{
|
||||
uint64_t carry = 0;
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
{
|
||||
for (int i = 0; i < WIDTH; i++) {
|
||||
uint64_t n = carry + pn[i] + b.pn[i];
|
||||
pn[i] = n & 0xffffffff;
|
||||
carry = n >> 32;
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
{
|
||||
// prefix operator
|
||||
int i = 0;
|
||||
while (++pn[i] == 0 && i < WIDTH-1)
|
||||
while (++pn[i] == 0 && i < WIDTH - 1)
|
||||
i++;
|
||||
return *this;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
{
|
||||
// prefix operator
|
||||
int i = 0;
|
||||
while (--pn[i] == (uint32_t)-1 && i < WIDTH-1)
|
||||
while (--pn[i] == (uint32_t)-1 && i < WIDTH - 1)
|
||||
i++;
|
||||
return *this;
|
||||
}
|
||||
@@ -250,7 +250,8 @@ public:
|
||||
};
|
||||
|
||||
/** 256-bit unsigned big integer. */
|
||||
class arith_uint256 : public base_uint<256> {
|
||||
class arith_uint256 : public base_uint<256>
|
||||
{
|
||||
public:
|
||||
arith_uint256() {}
|
||||
arith_uint256(const base_uint<256>& b) : base_uint<256>(b) {}
|
||||
@@ -277,11 +278,11 @@ public:
|
||||
* complexities of the sign bit and using base 256 are probably an
|
||||
* implementation accident.
|
||||
*/
|
||||
arith_uint256& SetCompact(uint32_t nCompact, bool *pfNegative = NULL, bool *pfOverflow = NULL);
|
||||
arith_uint256& SetCompact(uint32_t nCompact, bool* pfNegative = NULL, bool* pfOverflow = NULL);
|
||||
uint32_t GetCompact(bool fNegative = false) const;
|
||||
|
||||
friend uint256 ArithToUint256(const arith_uint256 &);
|
||||
friend arith_uint256 UintToArith256(const uint256 &);
|
||||
friend uint256 ArithToUint256(const arith_uint256&);
|
||||
friend arith_uint256 UintToArith256(const uint256&);
|
||||
};
|
||||
|
||||
uint256 ArithToUint256(const arith_uint256 &);
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "base58.h"
|
||||
#include <base58.h>
|
||||
|
||||
#include "hash.h"
|
||||
#include "script/script.h"
|
||||
#include "uint256.h"
|
||||
#include <hash.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
@@ -36,7 +35,7 @@ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vch)
|
||||
while (*psz && !isspace(*psz)) {
|
||||
// Decode base58 character
|
||||
const char* ch = strchr(pszBase58, *psz);
|
||||
if (ch == NULL)
|
||||
if (ch == nullptr)
|
||||
return false;
|
||||
// Apply "b256 = b256 * 58 + ch".
|
||||
int carry = ch - pszBase58;
|
||||
|
||||
13
src/base58.h
13
src/base58.h
@@ -14,11 +14,12 @@
|
||||
#ifndef BITCOIN_BASE58_H
|
||||
#define BITCOIN_BASE58_H
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "key.h"
|
||||
#include "pubkey.h"
|
||||
#include "script/standard.h"
|
||||
#include "support/allocators/zeroafterfree.h"
|
||||
#include <chainparams.h>
|
||||
#include <key.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/script.h>
|
||||
#include <script/standard.h>
|
||||
#include <support/allocators/zeroafterfree.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -94,7 +95,7 @@ public:
|
||||
bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; }
|
||||
};
|
||||
|
||||
/** base58-encoded Bitcoin addresses.
|
||||
/** base58-encoded Blackcoin addresses.
|
||||
* Public-key-hash-addresses have version 0 (or 111 testnet).
|
||||
* The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key.
|
||||
* Script-hash-addresses have version 5 (or 196 testnet).
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright (c) 2017 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#include "dstencode.h"
|
||||
#include "base58.h"
|
||||
#include "cashaddrenc.h"
|
||||
#include "chainparams.h"
|
||||
#include "config.h"
|
||||
#include "script/standard.h"
|
||||
#include <dstencode.h>
|
||||
#include <base58.h>
|
||||
#include <cashaddrenc.h>
|
||||
#include <chainparams.h>
|
||||
#include <config.h>
|
||||
#include <script/standard.h>
|
||||
|
||||
std::string EncodeDestination(const CTxDestination &dst, const CChainParams ¶ms, const Config &cfg)
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
// key.h and pubkey.h are not used here, but gcc doesn't want to instantiate
|
||||
// CTxDestination if types are unknown
|
||||
#include "key.h"
|
||||
#include "pubkey.h"
|
||||
#include "script/standard.h"
|
||||
#include <key.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/standard.h>
|
||||
#include <string>
|
||||
|
||||
class Config;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "hash.h"
|
||||
#include "crypto/common.h"
|
||||
#include "crypto/hmac_sha512.h"
|
||||
#include "pubkey.h"
|
||||
#include <hash.h>
|
||||
#include <crypto/common.h>
|
||||
#include <crypto/hmac_sha512.h>
|
||||
#include <pubkey.h>
|
||||
|
||||
|
||||
inline uint32_t ROTL32(uint32_t x, int8_t r)
|
||||
|
||||
16
src/hash.h
16
src/hash.h
@@ -6,18 +6,18 @@
|
||||
#ifndef BITCOIN_HASH_H
|
||||
#define BITCOIN_HASH_H
|
||||
|
||||
#include "crypto/ripemd160.h"
|
||||
#include "crypto/sha256.h"
|
||||
#include "prevector.h"
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
#include "version.h"
|
||||
#include <crypto/ripemd160.h>
|
||||
#include <crypto/sha256.h>
|
||||
#include <prevector.h>
|
||||
#include <serialize.h>
|
||||
#include <uint256.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
typedef uint256 ChainCode;
|
||||
|
||||
/** A hasher class for Bitcoin's 256-bit hash (double SHA-256). */
|
||||
/** A hasher class for Blackcoin's 256-bit hash (double SHA-256). */
|
||||
class CHash256 {
|
||||
private:
|
||||
CSHA256 sha;
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160). */
|
||||
/** A hasher class for Blackcoin's 160-bit hash (SHA-256 + RIPEMD-160). */
|
||||
class CHash160 {
|
||||
private:
|
||||
CSHA256 sha;
|
||||
|
||||
@@ -2,24 +2,23 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "httprpc.h"
|
||||
#include <httprpc.h>
|
||||
|
||||
#include "base58.h"
|
||||
#include "chainparams.h"
|
||||
#include "httpserver.h"
|
||||
#include "rpc/protocol.h"
|
||||
#include "rpc/server.h"
|
||||
#include "random.h"
|
||||
#include "sync.h"
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "ui_interface.h"
|
||||
#include "crypto/hmac_sha256.h"
|
||||
#include <base58.h>
|
||||
#include <chainparams.h>
|
||||
#include <httpserver.h>
|
||||
#include <rpc/protocol.h>
|
||||
#include <rpc/server.h>
|
||||
#include <random.h>
|
||||
#include <sync.h>
|
||||
#include <util.h>
|
||||
#include <utilstrencodings.h>
|
||||
#include <ui_interface.h>
|
||||
#include <crypto/hmac_sha256.h>
|
||||
#include <stdio.h>
|
||||
#include "utilstrencodings.h"
|
||||
#include <utilstrencodings.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp> // boost::trim
|
||||
#include <boost/foreach.hpp> //BOOST_FOREACH
|
||||
|
||||
/** WWW-Authenticate to present with 401 Unauthorized response */
|
||||
static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
|
||||
@@ -45,7 +44,7 @@ private:
|
||||
class HTTPRPCTimerInterface : public RPCTimerInterface
|
||||
{
|
||||
public:
|
||||
HTTPRPCTimerInterface(struct event_base* _base) : base(_base)
|
||||
HTTPRPCTimerInterface(struct event_base* base) : base(base)
|
||||
{
|
||||
}
|
||||
const char* Name()
|
||||
@@ -86,7 +85,7 @@ static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const Uni
|
||||
//This function checks username and password against -rpcauth
|
||||
//entries from config file.
|
||||
static bool multiUserAuthorized(std::string strUserPass)
|
||||
{
|
||||
{
|
||||
if (strUserPass.find(":") == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
@@ -95,7 +94,7 @@ static bool multiUserAuthorized(std::string strUserPass)
|
||||
|
||||
if (mapMultiArgs.count("-rpcauth") > 0) {
|
||||
//Search for multi-user login/pass "rpcauth" from config
|
||||
BOOST_FOREACH(std::string strRPCAuth, mapMultiArgs["-rpcauth"])
|
||||
for(std::string strRPCAuth: mapMultiArgs["-rpcauth"])
|
||||
{
|
||||
std::vector<std::string> vFields;
|
||||
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));
|
||||
@@ -113,7 +112,7 @@ static bool multiUserAuthorized(std::string strUserPass)
|
||||
std::string strHash = vFields[2];
|
||||
|
||||
unsigned int KEY_SIZE = 32;
|
||||
unsigned char out[KEY_SIZE];
|
||||
unsigned char *out = new unsigned char[KEY_SIZE];
|
||||
|
||||
CHMAC_SHA256(reinterpret_cast<const unsigned char*>(strSalt.c_str()), strSalt.size()).Write(reinterpret_cast<const unsigned char*>(strPass.c_str()), strPass.size()).Finalize(out);
|
||||
std::vector<unsigned char> hexvec(out, out+KEY_SIZE);
|
||||
@@ -136,7 +135,7 @@ static bool RPCAuthorized(const std::string& strAuth)
|
||||
std::string strUserPass64 = strAuth.substr(6);
|
||||
boost::trim(strUserPass64);
|
||||
std::string strUserPass = DecodeBase64(strUserPass64);
|
||||
|
||||
|
||||
//Check if authorized under single-user field
|
||||
if (TimingResistantEqual(strUserPass, strRPCUserColonPass)) {
|
||||
return true;
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "httpserver.h"
|
||||
#include <httpserver.h>
|
||||
|
||||
#include "chainparamsbase.h"
|
||||
#include "compat.h"
|
||||
#include "util.h"
|
||||
#include "netbase.h"
|
||||
#include "rpc/protocol.h" // For HTTP status codes
|
||||
#include "sync.h"
|
||||
#include "ui_interface.h"
|
||||
#include <chainparamsbase.h>
|
||||
#include <compat.h>
|
||||
#include <util.h>
|
||||
#include <netbase.h>
|
||||
#include <rpc/protocol.h> // For HTTP status codes
|
||||
#include <sync.h>
|
||||
#include <ui_interface.h>
|
||||
|
||||
#include <deque>
|
||||
#include <stdio.h>
|
||||
@@ -36,6 +36,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
/** Maximum size of http request (request line + headers) */
|
||||
static const size_t MAX_HEADERS_SIZE = 8192;
|
||||
|
||||
@@ -43,8 +46,8 @@ static const size_t MAX_HEADERS_SIZE = 8192;
|
||||
class HTTPWorkItem : public HTTPClosure
|
||||
{
|
||||
public:
|
||||
HTTPWorkItem(std::unique_ptr<HTTPRequest> _req, const std::string &_path, const HTTPRequestHandler& _func):
|
||||
req(std::move(_req)), path(_path), func(_func)
|
||||
HTTPWorkItem(std::unique_ptr<HTTPRequest> req, const std::string &path, const HTTPRequestHandler& func):
|
||||
req(std::move(req)), path(path), func(func)
|
||||
{
|
||||
}
|
||||
void operator()()
|
||||
@@ -93,8 +96,8 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
WorkQueue(size_t _maxDepth) : running(true),
|
||||
maxDepth(_maxDepth),
|
||||
WorkQueue(size_t maxDepth) : running(true),
|
||||
maxDepth(maxDepth),
|
||||
numThreads(0)
|
||||
{
|
||||
}
|
||||
@@ -159,8 +162,8 @@ public:
|
||||
struct HTTPPathHandler
|
||||
{
|
||||
HTTPPathHandler() {}
|
||||
HTTPPathHandler(std::string _prefix, bool _exactMatch, HTTPRequestHandler _handler):
|
||||
prefix(_prefix), exactMatch(_exactMatch), handler(_handler)
|
||||
HTTPPathHandler(std::string prefix, bool exactMatch, HTTPRequestHandler handler):
|
||||
prefix(prefix), exactMatch(exactMatch), handler(handler)
|
||||
{
|
||||
}
|
||||
std::string prefix;
|
||||
@@ -188,7 +191,7 @@ static bool ClientAllowed(const CNetAddr& netaddr)
|
||||
{
|
||||
if (!netaddr.IsValid())
|
||||
return false;
|
||||
for(const CSubNet& subnet : rpc_allow_subnets)
|
||||
for(const CSubNet& subnet: rpc_allow_subnets)
|
||||
if (subnet.Match(netaddr))
|
||||
return true;
|
||||
return false;
|
||||
@@ -206,7 +209,7 @@ static bool InitHTTPAllowList()
|
||||
rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhost
|
||||
if (mapMultiArgs.count("-rpcallowip")) {
|
||||
const std::vector<std::string>& vAllow = mapMultiArgs["-rpcallowip"];
|
||||
for (std::string strAllow : vAllow) {
|
||||
for(std::string strAllow: vAllow) {
|
||||
CSubNet subnet;
|
||||
LookupSubNet(strAllow.c_str(), subnet);
|
||||
if (!subnet.IsValid()) {
|
||||
@@ -219,7 +222,7 @@ static bool InitHTTPAllowList()
|
||||
}
|
||||
}
|
||||
std::string strAllowed;
|
||||
for (const CSubNet& subnet : rpc_allow_subnets)
|
||||
for(const CSubNet& subnet: rpc_allow_subnets)
|
||||
strAllowed += subnet.ToString() + " ";
|
||||
LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed);
|
||||
return true;
|
||||
@@ -423,7 +426,7 @@ bool InitHTTPServer()
|
||||
evhttp_set_timeout(http, GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT));
|
||||
evhttp_set_max_headers_size(http, MAX_HEADERS_SIZE);
|
||||
evhttp_set_max_body_size(http, MAX_SIZE);
|
||||
evhttp_set_gencb(http, http_request_cb, NULL);
|
||||
evhttp_set_gencb(http, http_request_cb, nullptr);
|
||||
|
||||
if (!HTTPBindAddresses(http)) {
|
||||
LogPrintf("Unable to bind any endpoint for RPC server\n");
|
||||
@@ -466,11 +469,11 @@ void InterruptHTTPServer()
|
||||
LogPrint("http", "Interrupting HTTP server\n");
|
||||
if (eventHTTP) {
|
||||
// Unlisten sockets
|
||||
for (evhttp_bound_socket *socket : boundSockets) {
|
||||
for(evhttp_bound_socket *socket: boundSockets) {
|
||||
evhttp_del_accept_socket(eventHTTP, socket);
|
||||
}
|
||||
// Reject requests on current connections
|
||||
evhttp_set_gencb(eventHTTP, http_reject_request_cb, NULL);
|
||||
evhttp_set_gencb(eventHTTP, http_reject_request_cb, nullptr);
|
||||
}
|
||||
if (eventBase) {
|
||||
// Force-exit event loop after predefined time
|
||||
@@ -502,8 +505,8 @@ void StopHTTPServer()
|
||||
if (threadResult.valid() && threadResult.wait_for(std::chrono::milliseconds(2000)) == std::future_status::timeout) {
|
||||
LogPrintf("HTTP event loop did not exit within allotted time, sending loopbreak\n");
|
||||
event_base_loopbreak(eventBase);
|
||||
threadHTTP.join();
|
||||
}
|
||||
threadHTTP.join();
|
||||
}
|
||||
if (eventHTTP) {
|
||||
evhttp_free(eventHTTP);
|
||||
@@ -530,8 +533,8 @@ static void httpevent_callback_fn(evutil_socket_t, short, void* data)
|
||||
delete self;
|
||||
}
|
||||
|
||||
HTTPEvent::HTTPEvent(struct event_base* base, bool _deleteWhenTriggered, const std::function<void(void)>& _handler):
|
||||
deleteWhenTriggered(_deleteWhenTriggered), handler(_handler)
|
||||
HTTPEvent::HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void(void)>& handler):
|
||||
deleteWhenTriggered(deleteWhenTriggered), handler(handler)
|
||||
{
|
||||
ev = event_new(base, -1, 0, httpevent_callback_fn, this);
|
||||
assert(ev);
|
||||
@@ -542,12 +545,12 @@ HTTPEvent::~HTTPEvent()
|
||||
}
|
||||
void HTTPEvent::trigger(struct timeval* tv)
|
||||
{
|
||||
if (tv == NULL)
|
||||
if (tv == nullptr)
|
||||
event_active(ev, 0, 0); // immediately trigger event in main thread
|
||||
else
|
||||
evtimer_add(ev, tv); // trigger after timeval passed
|
||||
}
|
||||
HTTPRequest::HTTPRequest(struct evhttp_request* _req) : req(_req),
|
||||
HTTPRequest::HTTPRequest(struct evhttp_request* req) : req(req),
|
||||
replySent(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <functional>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
static const int DEFAULT_HTTP_THREADS=4;
|
||||
static const int DEFAULT_HTTP_WORKQUEUE=16;
|
||||
|
||||
32
src/key.cpp
32
src/key.cpp
@@ -1,19 +1,19 @@
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "key.h"
|
||||
#include <key.h>
|
||||
|
||||
#include "arith_uint256.h"
|
||||
#include "crypto/common.h"
|
||||
#include "crypto/hmac_sha512.h"
|
||||
#include "pubkey.h"
|
||||
#include "random.h"
|
||||
#include <arith_uint256.h>
|
||||
#include <crypto/common.h>
|
||||
#include <crypto/hmac_sha512.h>
|
||||
#include <pubkey.h>
|
||||
#include <random.h>
|
||||
|
||||
#include <secp256k1.h>
|
||||
#include <secp256k1_recovery.h>
|
||||
|
||||
static secp256k1_context* secp256k1_context_sign = NULL;
|
||||
static secp256k1_context* secp256k1_context_sign = nullptr;
|
||||
|
||||
/** These functions are taken from the libsecp256k1 distribution and are very ugly. */
|
||||
static int ec_privkey_import_der(const secp256k1_context* ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen) {
|
||||
@@ -173,7 +173,7 @@ bool CKey::Sign(const uint256 &hash, std::vector<unsigned char>& vchSig, uint32_
|
||||
unsigned char extra_entropy[32] = {0};
|
||||
WriteLE32(extra_entropy, test_case);
|
||||
secp256k1_ecdsa_signature sig;
|
||||
int ret = secp256k1_ecdsa_sign(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, test_case ? extra_entropy : NULL);
|
||||
int ret = secp256k1_ecdsa_sign(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, test_case ? extra_entropy : nullptr);
|
||||
assert(ret);
|
||||
secp256k1_ecdsa_signature_serialize_der(secp256k1_context_sign, (unsigned char*)&vchSig[0], &nSigLen, &sig);
|
||||
vchSig.resize(nSigLen);
|
||||
@@ -200,7 +200,7 @@ bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig)
|
||||
vchSig.resize(65);
|
||||
int rec = -1;
|
||||
secp256k1_ecdsa_recoverable_signature sig;
|
||||
int ret = secp256k1_ecdsa_sign_recoverable(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, NULL);
|
||||
int ret = secp256k1_ecdsa_sign_recoverable(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, nullptr);
|
||||
assert(ret);
|
||||
secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, (unsigned char*)&vchSig[1], &rec, &sig);
|
||||
assert(ret);
|
||||
@@ -243,12 +243,12 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CExtKey::Derive(CExtKey &out, unsigned int nChild) const {
|
||||
bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const {
|
||||
out.nDepth = nDepth + 1;
|
||||
CKeyID id = key.GetPubKey().GetID();
|
||||
memcpy(&out.vchFingerprint[0], &id, 4);
|
||||
out.nChild = nChild;
|
||||
return key.Derive(out.key, out.chaincode, nChild, chaincode);
|
||||
out.nChild = _nChild;
|
||||
return key.Derive(out.key, out.chaincode, _nChild, chaincode);
|
||||
}
|
||||
|
||||
void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) {
|
||||
@@ -301,10 +301,10 @@ bool ECC_InitSanityCheck() {
|
||||
}
|
||||
|
||||
void ECC_Start() {
|
||||
assert(secp256k1_context_sign == NULL);
|
||||
assert(secp256k1_context_sign == nullptr);
|
||||
|
||||
secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
|
||||
assert(ctx != NULL);
|
||||
assert(ctx != nullptr);
|
||||
|
||||
{
|
||||
// Pass in a random blinding seed to the secp256k1 context.
|
||||
@@ -321,7 +321,7 @@ void ECC_Start() {
|
||||
|
||||
void ECC_Stop() {
|
||||
secp256k1_context *ctx = secp256k1_context_sign;
|
||||
secp256k1_context_sign = NULL;
|
||||
secp256k1_context_sign = nullptr;
|
||||
|
||||
if (ctx) {
|
||||
secp256k1_context_destroy(ctx);
|
||||
|
||||
16
src/key.h
16
src/key.h
@@ -1,21 +1,21 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_KEY_H
|
||||
#define BITCOIN_KEY_H
|
||||
|
||||
#include "pubkey.h"
|
||||
#include "serialize.h"
|
||||
#include "support/allocators/secure.h"
|
||||
#include "uint256.h"
|
||||
#include <pubkey.h>
|
||||
#include <serialize.h>
|
||||
#include <support/allocators/secure.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* secp256k1:
|
||||
* const unsigned int PRIVATE_KEY_SIZE = 279;
|
||||
* const unsigned int PUBLIC_KEY_SIZE = 65;
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
//! The actual byte data
|
||||
unsigned char vch[32];
|
||||
|
||||
//! Check whether the 32-byte array pointed to be vch is valid keydata.
|
||||
//! Check whether the 32-byte array pointed to by vch is valid keydata.
|
||||
bool static Check(const unsigned char* vch);
|
||||
|
||||
public:
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
|
||||
/**
|
||||
* Convert the private key to a CPrivKey (serialized OpenSSL private key data).
|
||||
* This is expensive.
|
||||
* This is expensive.
|
||||
*/
|
||||
CPrivKey GetPrivKey() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user