mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge pull request #3621 from PastaPastaPasta/backports-0.17-pr17
Backports 0.17 pr17
This commit is contained in:
commit
a37ad95ae8
@ -280,6 +280,5 @@ clean-docs:
|
||||
rm -rf doc/doxygen
|
||||
|
||||
clean-local: clean-docs
|
||||
rm -rf coverage_percent.txt test_dash.coverage/ total.coverage/ test/tmp/ cache/ $(OSX_APP)
|
||||
rm -rf coverage_percent.txt test_dash.coverage/ total.coverage/ test/tmp/ cache/ $(OSX_APP) src/qt/moc_*
|
||||
rm -rf test/functional/__pycache__ test/functional/test_framework/__pycache__ test/cache
|
||||
|
||||
|
20
configure.ac
20
configure.ac
@ -555,20 +555,34 @@ case $host in
|
||||
CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0"
|
||||
OBJCXXFLAGS="$CXXFLAGS"
|
||||
;;
|
||||
*android*)
|
||||
dnl make sure android stays above linux for hosts like *linux-android*
|
||||
LEVELDB_TARGET_FLAGS="-DOS_ANDROID"
|
||||
;;
|
||||
*linux*)
|
||||
TARGET_OS=linux
|
||||
LEVELDB_TARGET_FLAGS="-DOS_LINUX"
|
||||
;;
|
||||
*kfreebsd*)
|
||||
LEVELDB_TARGET_FLAGS="-DOS_KFREEBSD"
|
||||
;;
|
||||
*freebsd*)
|
||||
LEVELDB_TARGET_FLAGS="-DOS_FREEBSD"
|
||||
;;
|
||||
*openbsd*)
|
||||
LEVELDB_TARGET_FLAGS="-DOS_OPENBSD"
|
||||
;;
|
||||
*dragonfly*)
|
||||
LEVELDB_TARGET_FLAGS="-DOS_DRAGONFLYBSD"
|
||||
;;
|
||||
*solaris*)
|
||||
LEVELDB_TARGET_FLAGS="-DOS_SOLARIS"
|
||||
;;
|
||||
*hpux*)
|
||||
LEVELDB_TARGET_FLAGS="-DOS_HPUX"
|
||||
;;
|
||||
*)
|
||||
OTHER_OS=`echo ${host_os} | awk '{print toupper($0)}'`
|
||||
AC_MSG_WARN([Guessing LevelDB OS as OS_${OTHER_OS}, please check whether this is correct, if not add an entry to configure.ac.])
|
||||
LEVELDB_TARGET_FLAGS="-DOS_${OTHER_OS}"
|
||||
AC_MSG_ERROR(Cannot build leveldb for $host. Please file a bug report.)
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -48,7 +48,6 @@ EXPECTED_BOOST_INCLUDES=(
|
||||
boost/algorithm/string.hpp
|
||||
boost/algorithm/string/case_conv.hpp
|
||||
boost/algorithm/string/classification.hpp
|
||||
boost/algorithm/string/join.hpp
|
||||
boost/algorithm/string/replace.hpp
|
||||
boost/algorithm/string/split.hpp
|
||||
boost/bind.hpp
|
||||
|
@ -97,7 +97,7 @@ def check_ELF_RELRO(executable):
|
||||
raise IOError('Error opening file')
|
||||
for line in stdout.splitlines():
|
||||
tokens = line.split()
|
||||
if len(tokens)>1 and tokens[1] == '(BIND_NOW)' or (len(tokens)>2 and tokens[1] == '(FLAGS)' and 'BIND_NOW' in tokens[2]):
|
||||
if len(tokens)>1 and tokens[1] == '(BIND_NOW)' or (len(tokens)>2 and tokens[1] == '(FLAGS)' and 'BIND_NOW' in tokens[2:]):
|
||||
have_bindnow = True
|
||||
return have_gnu_relro and have_bindnow
|
||||
|
||||
|
@ -30,7 +30,7 @@ import signal
|
||||
import struct
|
||||
import sys
|
||||
|
||||
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 5):
|
||||
if (sys.version_info.major, sys.version_info.minor) < (3, 5):
|
||||
print("This example only works with Python 3.5 and greater")
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -34,7 +34,7 @@ import signal
|
||||
import struct
|
||||
import sys
|
||||
|
||||
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 4):
|
||||
if (sys.version_info.major, sys.version_info.minor) < (3, 4):
|
||||
print("This example only works with Python 3.4 and greater")
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -5,6 +5,7 @@ qt_packages = qrencode protobuf zlib
|
||||
|
||||
qt_x86_64_linux_packages:=qt expat dbus libxcb xcb_proto libXau xproto freetype fontconfig libX11 xextproto libXext xtrans
|
||||
qt_i686_linux_packages:=$(qt_x86_64_linux_packages)
|
||||
qt_arm_linux_packages:=$(qt_x86_64_linux_packages)
|
||||
|
||||
qt_darwin_packages=qt
|
||||
qt_mingw32_packages=qt
|
||||
|
@ -101,7 +101,7 @@ $(package)_config_opts_linux += -system-freetype
|
||||
$(package)_config_opts_linux += -no-sm
|
||||
$(package)_config_opts_linux += -fontconfig
|
||||
$(package)_config_opts_linux += -no-opengl
|
||||
$(package)_config_opts_arm_linux = -platform linux-g++ -xplatform $(host)
|
||||
$(package)_config_opts_arm_linux += -platform linux-g++ -xplatform bitcoin-linux-g++
|
||||
$(package)_config_opts_i686_linux = -xplatform linux-g++-32
|
||||
$(package)_config_opts_mingw32 = -no-opengl -xplatform win32-g++ -device-option CROSS_COMPILE="$(host)-"
|
||||
$(package)_build_env = QT_RCC_TEST=1
|
||||
@ -140,6 +140,8 @@ define $(package)_preprocess_cmds
|
||||
cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\
|
||||
cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
|
||||
cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \
|
||||
cp -r qtbase/mkspecs/linux-arm-gnueabi-g++ qtbase/mkspecs/bitcoin-linux-g++ && \
|
||||
sed -i.old "s/arm-linux-gnueabi-/$(host)-/g" qtbase/mkspecs/bitcoin-linux-g++/qmake.conf && \
|
||||
patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \
|
||||
patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \
|
||||
patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \
|
||||
|
@ -246,6 +246,7 @@ BITCOIN_CORE_H = \
|
||||
undo.h \
|
||||
unordered_lru_cache.h \
|
||||
util.h \
|
||||
utilmemory.h \
|
||||
utilmoneystr.h \
|
||||
utiltime.h \
|
||||
validation.h \
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <tinyformat.h>
|
||||
#include <util.h>
|
||||
#include <utilmemory.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -222,7 +222,7 @@ static bool InitRPCAuthentication()
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.\n");
|
||||
LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.\n");
|
||||
strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
|
||||
}
|
||||
if (gArgs.GetArg("-rpcauth","") != "")
|
||||
|
@ -644,7 +644,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-rpccookiefile=<loc>", _("Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir)"));
|
||||
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
|
||||
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
||||
strUsage += HelpMessageOpt("-rpcauth=<userpw>", _("Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times"));
|
||||
strUsage += HelpMessageOpt("-rpcauth=<userpw>", _("Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcauth. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times"));
|
||||
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()));
|
||||
strUsage += HelpMessageOpt("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times"));
|
||||
strUsage += HelpMessageOpt("-rpcthreads=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
|
||||
|
@ -105,7 +105,7 @@ static bool ExtractPubKey(const CScript &dest, CPubKey& pubKeyOut)
|
||||
CScript::const_iterator pc = dest.begin();
|
||||
opcodetype opcode;
|
||||
std::vector<unsigned char> vch;
|
||||
if (!dest.GetOp(pc, opcode, vch) || vch.size() < 33 || vch.size() > 65)
|
||||
if (!dest.GetOp(pc, opcode, vch) || !CPubKey::ValidSize(vch))
|
||||
return false;
|
||||
pubKeyOut = CPubKey(vch);
|
||||
if (!pubKeyOut.IsFullyValid())
|
||||
|
@ -642,7 +642,7 @@ private:
|
||||
* This takes the place of a feeler connection */
|
||||
std::atomic_bool m_try_another_outbound_peer;
|
||||
|
||||
std::atomic<int64_t> m_next_send_inv_to_incoming;
|
||||
std::atomic<int64_t> m_next_send_inv_to_incoming{0};
|
||||
|
||||
friend struct CConnmanTest;
|
||||
};
|
||||
|
@ -70,6 +70,11 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
bool static ValidSize(const std::vector<unsigned char> &vch) {
|
||||
return vch.size() > 0 && GetLen(vch[0]) == vch.size();
|
||||
}
|
||||
|
||||
//! Construct an invalid public key.
|
||||
CPubKey()
|
||||
{
|
||||
|
@ -61,17 +61,17 @@ static inline void popstack(std::vector<valtype>& stack)
|
||||
}
|
||||
|
||||
bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) {
|
||||
if (vchPubKey.size() < 33) {
|
||||
if (vchPubKey.size() < CPubKey::COMPRESSED_PUBLIC_KEY_SIZE) {
|
||||
// Non-canonical public key: too short
|
||||
return false;
|
||||
}
|
||||
if (vchPubKey[0] == 0x04) {
|
||||
if (vchPubKey.size() != 65) {
|
||||
if (vchPubKey.size() != CPubKey::PUBLIC_KEY_SIZE) {
|
||||
// Non-canonical public key: invalid length for uncompressed key
|
||||
return false;
|
||||
}
|
||||
} else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) {
|
||||
if (vchPubKey.size() != 33) {
|
||||
if (vchPubKey.size() != CPubKey::COMPRESSED_PUBLIC_KEY_SIZE) {
|
||||
// Non-canonical public key: invalid length for compressed key
|
||||
return false;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
|
||||
// Template matching opcodes:
|
||||
if (opcode2 == OP_PUBKEYS)
|
||||
{
|
||||
while (vch1.size() >= 33 && vch1.size() <= 65)
|
||||
while (CPubKey::ValidSize(vch1))
|
||||
{
|
||||
vSolutionsRet.push_back(vch1);
|
||||
if (!script1.GetOp(pc1, opcode1, vch1))
|
||||
@ -121,7 +121,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
|
||||
|
||||
if (opcode2 == OP_PUBKEY)
|
||||
{
|
||||
if (vch1.size() < 33 || vch1.size() > 65)
|
||||
if (!CPubKey::ValidSize(vch1))
|
||||
break;
|
||||
vSolutionsRet.push_back(vch1);
|
||||
}
|
||||
|
@ -1069,21 +1069,6 @@ BOOST_AUTO_TEST_CASE(test_ParseFixedPoint)
|
||||
BOOST_CHECK(!ParseFixedPoint("1.", 8, &amount));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(version_info_helper)
|
||||
{
|
||||
BOOST_CHECK(StringVersionToInt("1.1.1") == 0x010101);
|
||||
BOOST_CHECK(IntVersionToString(0x010101) == "1.1.1");
|
||||
|
||||
BOOST_CHECK_THROW(StringVersionToInt("1.1.hgdghfgf"), std::bad_cast);
|
||||
BOOST_CHECK_THROW(StringVersionToInt("1.1"), std::bad_cast);
|
||||
BOOST_CHECK_THROW(StringVersionToInt("1.1.1f"), std::bad_cast);
|
||||
BOOST_CHECK_THROW(StringVersionToInt("1.1.1000"), std::bad_cast);
|
||||
BOOST_CHECK_THROW(StringVersionToInt("10"), std::bad_cast);
|
||||
BOOST_CHECK_THROW(StringVersionToInt("1.1.1.1"), std::bad_cast);
|
||||
BOOST_CHECK_THROW(IntVersionToString(0x01010101), std::bad_cast);
|
||||
BOOST_CHECK_THROW(IntVersionToString(0), std::bad_cast);
|
||||
}
|
||||
|
||||
static void TestOtherThread(fs::path dirname, std::string lockname, bool *result)
|
||||
{
|
||||
*result = LockDirectory(dirname, lockname);
|
||||
|
52
src/util.cpp
52
src/util.cpp
@ -74,9 +74,6 @@
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/interprocess/sync/file_lock.hpp>
|
||||
#include <boost/program_options/detail/config_file.hpp>
|
||||
#include <boost/program_options/parsers.hpp>
|
||||
@ -1040,55 +1037,6 @@ std::string CopyrightHolders(const std::string& strPrefix, unsigned int nStartYe
|
||||
return strCopyrightHolders;
|
||||
}
|
||||
|
||||
uint32_t StringVersionToInt(const std::string& strVersion)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
boost::split(tokens, strVersion, boost::is_any_of("."));
|
||||
if(tokens.size() != 3)
|
||||
throw std::bad_cast();
|
||||
uint32_t nVersion = 0;
|
||||
for(unsigned idx = 0; idx < 3; idx++)
|
||||
{
|
||||
if(tokens[idx].length() == 0)
|
||||
throw std::bad_cast();
|
||||
uint32_t value = boost::lexical_cast<uint32_t>(tokens[idx]);
|
||||
if(value > 255)
|
||||
throw std::bad_cast();
|
||||
nVersion <<= 8;
|
||||
nVersion |= value;
|
||||
}
|
||||
return nVersion;
|
||||
}
|
||||
|
||||
std::string IntVersionToString(uint32_t nVersion)
|
||||
{
|
||||
if((nVersion >> 24) > 0) // MSB is always 0
|
||||
throw std::bad_cast();
|
||||
if(nVersion == 0)
|
||||
throw std::bad_cast();
|
||||
std::array<std::string, 3> tokens;
|
||||
for(unsigned idx = 0; idx < 3; idx++)
|
||||
{
|
||||
unsigned shift = (2 - idx) * 8;
|
||||
uint32_t byteValue = (nVersion >> shift) & 0xff;
|
||||
tokens[idx] = boost::lexical_cast<std::string>(byteValue);
|
||||
}
|
||||
return boost::join(tokens, ".");
|
||||
}
|
||||
|
||||
std::string SafeIntVersionToString(uint32_t nVersion)
|
||||
{
|
||||
try
|
||||
{
|
||||
return IntVersionToString(nVersion);
|
||||
}
|
||||
catch(const std::bad_cast&)
|
||||
{
|
||||
return "invalid_version";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Obtain the application startup time (used for uptime calculation)
|
||||
int64_t GetStartupTime()
|
||||
{
|
||||
|
39
src/util.h
39
src/util.h
@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2018 The Bitcoin Core developers
|
||||
// Copyright (c) 2014-2019 The Dash Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
@ -21,12 +21,12 @@
|
||||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <utiltime.h>
|
||||
#include <utilmemory.h>
|
||||
#include <amount.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@ -317,39 +317,4 @@ template <typename Callable> void TraceThread(const std::string name, Callable
|
||||
|
||||
std::string CopyrightHolders(const std::string& strPrefix, unsigned int nStartYear, unsigned int nEndYear);
|
||||
|
||||
/**
|
||||
* @brief Converts version strings to 4-byte unsigned integer
|
||||
* @param strVersion version in "x.x.x" format (decimal digits only)
|
||||
* @return 4-byte unsigned integer, most significant byte is always 0
|
||||
* Throws std::bad_cast if format doesn\t match.
|
||||
*/
|
||||
uint32_t StringVersionToInt(const std::string& strVersion);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Converts version as 4-byte unsigned integer to string
|
||||
* @param nVersion 4-byte unsigned integer, most significant byte is always 0
|
||||
* @return version string in "x.x.x" format (last 3 bytes as version parts)
|
||||
* Throws std::bad_cast if format doesn\t match.
|
||||
*/
|
||||
std::string IntVersionToString(uint32_t nVersion);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Copy of the IntVersionToString, that returns "Invalid version" string
|
||||
* instead of throwing std::bad_cast
|
||||
* @param nVersion 4-byte unsigned integer, most significant byte is always 0
|
||||
* @return version string in "x.x.x" format (last 3 bytes as version parts)
|
||||
* or "Invalid version" if can't cast the given value
|
||||
*/
|
||||
std::string SafeIntVersionToString(uint32_t nVersion);
|
||||
|
||||
|
||||
//! Substitute for C++14 std::make_unique.
|
||||
template <typename T, typename... Args>
|
||||
std::unique_ptr<T> MakeUnique(Args&&... args)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
#endif // BITCOIN_UTIL_H
|
||||
|
19
src/utilmemory.h
Normal file
19
src/utilmemory.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2018 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_UTILMEMORY_H
|
||||
#define BITCOIN_UTILMEMORY_H
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
//! Substitute for C++14 std::make_unique.
|
||||
template <typename T, typename... Args>
|
||||
std::unique_ptr<T> MakeUnique(Args&&... args)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
#endif
|
@ -55,7 +55,6 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#if defined(NDEBUG)
|
||||
@ -2514,6 +2513,13 @@ static void DoWarning(const std::string& strWarning)
|
||||
}
|
||||
}
|
||||
|
||||
/** Private helper function that concatenates warning messages. */
|
||||
static void AppendWarning(std::string& res, const std::string& warn)
|
||||
{
|
||||
if (!res.empty()) res += ", ";
|
||||
res += warn;
|
||||
}
|
||||
|
||||
/** Check warning conditions and do some notifications on new chain tip set. */
|
||||
void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainParams) {
|
||||
// New best block
|
||||
@ -2525,7 +2531,7 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
||||
g_best_block_cv.notify_all();
|
||||
}
|
||||
|
||||
std::vector<std::string> warningMessages;
|
||||
std::string warningMessages;
|
||||
if (!IsInitialBlockDownload())
|
||||
{
|
||||
int nUpgraded = 0;
|
||||
@ -2538,7 +2544,7 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
||||
if (state == ThresholdState::ACTIVE) {
|
||||
DoWarning(strWarning);
|
||||
} else {
|
||||
warningMessages.push_back(strWarning);
|
||||
AppendWarning(warningMessages, strWarning);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2551,7 +2557,7 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
||||
pindex = pindex->pprev;
|
||||
}
|
||||
if (nUpgraded > 0)
|
||||
warningMessages.push_back(strprintf(_("%d of last 100 blocks have unexpected version"), nUpgraded));
|
||||
AppendWarning(warningMessages, strprintf(_("%d of last 100 blocks have unexpected version"), nUpgraded));
|
||||
if (nUpgraded > 100/2)
|
||||
{
|
||||
std::string strWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
|
||||
@ -2566,7 +2572,7 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
||||
GuessVerificationProgress(chainParams.TxData(), pindexNew), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
||||
strMessage += strprintf(" evodb_cache=%.1fMiB", evoDb->GetMemoryUsage() * (1.0 / (1<<20)));
|
||||
if (!warningMessages.empty())
|
||||
strMessage += strprintf(" warning='%s'", boost::algorithm::join(warningMessages, ", "));
|
||||
strMessage += strprintf(" warning='%s'", warningMessages);
|
||||
LogPrintf("%s\n", strMessage);
|
||||
}
|
||||
|
||||
@ -3974,6 +3980,15 @@ static void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfte
|
||||
int count=0;
|
||||
|
||||
if (nCurrentUsage + nBuffer >= nPruneTarget) {
|
||||
// On a prune event, the chainstate DB is flushed.
|
||||
// To avoid excessive prune events negating the benefit of high dbcache
|
||||
// values, we should not prune too rapidly.
|
||||
// So when pruning in IBD, increase the buffer a bit to avoid a re-prune too soon.
|
||||
if (IsInitialBlockDownload()) {
|
||||
// Since this is only relevant during IBD, we use a fixed 10%
|
||||
nBuffer += nPruneTarget / 10;
|
||||
}
|
||||
|
||||
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
|
||||
nBytesToPrune = vinfoBlockFile[fileNumber].nSize + vinfoBlockFile[fileNumber].nUndoSize;
|
||||
|
||||
|
@ -230,9 +230,9 @@ UniValue importaddress(const JSONRPCRequest& request)
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
|
||||
throw std::runtime_error(
|
||||
"importaddress \"address\" ( \"label\" rescan p2sh )\n"
|
||||
"\nAdds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
|
||||
"\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"script\" (string, required) The hex-encoded script (or address)\n"
|
||||
"1. \"address\" (string, required) The Dash address (or hex-encoded script)\n"
|
||||
"2. \"label\" (string, optional, default=\"\") An optional label\n"
|
||||
"3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
|
||||
"4. p2sh (boolean, optional, default=false) Add the P2SH version of the script as well\n"
|
||||
@ -242,12 +242,12 @@ UniValue importaddress(const JSONRPCRequest& request)
|
||||
"\nNote: If you import a non-standard raw script in hex form, outputs sending to it will be treated\n"
|
||||
"as change, and not show up in many RPCs.\n"
|
||||
"\nExamples:\n"
|
||||
"\nImport a script with rescan\n"
|
||||
+ HelpExampleCli("importaddress", "\"myscript\"") +
|
||||
"\nImport an address with rescan\n"
|
||||
+ HelpExampleCli("importaddress", "\"myaddress\"") +
|
||||
"\nImport using a label without rescan\n"
|
||||
+ HelpExampleCli("importaddress", "\"myscript\" \"testing\" false") +
|
||||
+ HelpExampleCli("importaddress", "\"myaddress\" \"testing\" false") +
|
||||
"\nAs a JSON-RPC call\n"
|
||||
+ HelpExampleRpc("importaddress", "\"myscript\", \"testing\", false")
|
||||
+ HelpExampleRpc("importaddress", "\"myaddress\", \"testing\", false")
|
||||
);
|
||||
|
||||
|
||||
|
@ -5135,7 +5135,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string& name, const fs::path&
|
||||
if (nMaxVersion == 0) // the -upgradewallet without argument case
|
||||
{
|
||||
LogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
|
||||
nMaxVersion = CLIENT_VERSION;
|
||||
nMaxVersion = FEATURE_LATEST;
|
||||
walletInstance->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately
|
||||
}
|
||||
else
|
||||
|
@ -100,7 +100,7 @@ enum WalletFeature
|
||||
FEATURE_HD = 120200, // Hierarchical key derivation after BIP32 (HD Wallet), BIP44 (multi-coin), BIP39 (mnemonic)
|
||||
// which uses on-the-fly private key derivation
|
||||
|
||||
FEATURE_LATEST = 61000
|
||||
FEATURE_LATEST = FEATURE_HD
|
||||
};
|
||||
|
||||
struct CompactTallyItem
|
||||
|
@ -562,7 +562,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
||||
int nMinVersion = 0;
|
||||
if (m_batch.Read((std::string)"minversion", nMinVersion))
|
||||
{
|
||||
if (nMinVersion > CLIENT_VERSION)
|
||||
if (nMinVersion > FEATURE_LATEST)
|
||||
return DBErrors::TOO_NEW;
|
||||
pwallet->LoadMinVersion(nMinVersion);
|
||||
}
|
||||
@ -670,7 +670,7 @@ DBErrors WalletBatch::FindWalletTx(std::vector<uint256>& vTxHash, std::vector<CW
|
||||
int nMinVersion = 0;
|
||||
if (m_batch.Read((std::string)"minversion", nMinVersion))
|
||||
{
|
||||
if (nMinVersion > CLIENT_VERSION)
|
||||
if (nMinVersion > FEATURE_LATEST)
|
||||
return DBErrors::TOO_NEW;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
|
||||
#Old authpair
|
||||
authpair = url.username + ':' + url.password
|
||||
|
||||
#New authpair generated via share/rpcuser tool
|
||||
#New authpair generated via share/rpcauth tool
|
||||
password = "cA773lm788buwYe4g4WT+05pKyNruVKjQ25x3n0DQcM="
|
||||
|
||||
#Second authpair with different username
|
||||
|
@ -523,7 +523,7 @@ class P2PDataStore(P2PInterface):
|
||||
# as we go.
|
||||
prev_block_hash = headers_list[-1].hashPrevBlock
|
||||
if prev_block_hash in self.block_store:
|
||||
prev_block_header = self.block_store[prev_block_hash]
|
||||
prev_block_header = CBlockHeader(self.block_store[prev_block_hash])
|
||||
headers_list.append(prev_block_header)
|
||||
if prev_block_header.sha256 == hash_stop:
|
||||
# if this is the hashstop header, stop here
|
||||
@ -564,7 +564,7 @@ class P2PDataStore(P2PInterface):
|
||||
self.block_store[block.sha256] = block
|
||||
self.last_block_hash = block.sha256
|
||||
|
||||
self.send_message(msg_headers([blocks[-1]]))
|
||||
self.send_message(msg_headers([CBlockHeader(blocks[-1])]))
|
||||
|
||||
if request_block:
|
||||
wait_until(lambda: blocks[-1].sha256 in self.getdata_requests, timeout=timeout, lock=mininode_lock)
|
||||
|
@ -68,22 +68,20 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
|
||||
#Import with no affiliated address
|
||||
assert_raises_rpc_error(-5, "No addresses", self.nodes[1].importprunedfunds, rawtxn1, proof1)
|
||||
|
||||
balance1 = self.nodes[1].getbalance("", 0, False, True)
|
||||
balance1 = self.nodes[1].getbalance()
|
||||
assert_equal(balance1, Decimal(0))
|
||||
|
||||
#Import with affiliated address with no rescan
|
||||
self.nodes[1].importaddress(address2, "add2", False)
|
||||
self.nodes[1].importaddress(address=address2, rescan=False)
|
||||
self.nodes[1].importprunedfunds(rawtxn2, proof2)
|
||||
balance2 = self.nodes[1].getbalance("add2", 0, False, True)
|
||||
assert_equal(balance2, Decimal('0.05'))
|
||||
assert [tx for tx in self.nodes[1].listtransactions(include_watchonly=True) if tx['txid'] == txnid2]
|
||||
|
||||
#Import with private key with no rescan
|
||||
self.nodes[1].importprivkey(privkey=address3_privkey, label="add3", rescan=False)
|
||||
# Import with private key with no rescan
|
||||
self.nodes[1].importprivkey(privkey=address3_privkey, rescan=False)
|
||||
self.nodes[1].importprunedfunds(rawtxn3, proof3)
|
||||
balance3 = self.nodes[1].getbalance("add3", 0, False, False)
|
||||
assert [tx for tx in self.nodes[1].listtransactions() if tx['txid'] == txnid3]
|
||||
balance3 = self.nodes[1].getbalance()
|
||||
assert_equal(balance3, Decimal('0.025'))
|
||||
balance3 = self.nodes[1].getbalance("*", 0, False, True)
|
||||
assert_equal(balance3, Decimal('0.075'))
|
||||
|
||||
#Addresses Test - after import
|
||||
address_info = self.nodes[1].validateaddress(address1)
|
||||
@ -98,17 +96,13 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
|
||||
|
||||
#Remove transactions
|
||||
assert_raises_rpc_error(-8, "Transaction does not exist in wallet.", self.nodes[1].removeprunedfunds, txnid1)
|
||||
|
||||
balance1 = self.nodes[1].getbalance("*", 0, False, True)
|
||||
assert_equal(balance1, Decimal('0.075'))
|
||||
assert not [tx for tx in self.nodes[1].listtransactions(include_watchonly=True) if tx['txid'] == txnid1]
|
||||
|
||||
self.nodes[1].removeprunedfunds(txnid2)
|
||||
balance2 = self.nodes[1].getbalance("*", 0, False, True)
|
||||
assert_equal(balance2, Decimal('0.025'))
|
||||
assert not [tx for tx in self.nodes[1].listtransactions(include_watchonly=True) if tx['txid'] == txnid2]
|
||||
|
||||
self.nodes[1].removeprunedfunds(txnid3)
|
||||
balance3 = self.nodes[1].getbalance("*", 0, False, True)
|
||||
assert_equal(balance3, Decimal('0.0'))
|
||||
assert not [tx for tx in self.nodes[1].listtransactions(include_watchonly=True) if tx['txid'] == txnid3]
|
||||
|
||||
if __name__ == '__main__':
|
||||
ImportPrunedFundsTest().main()
|
||||
|
Loading…
Reference in New Issue
Block a user