mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge pull request #3539 from PastaPastaPasta/backports-0.17-pr7
Backports 0.17 pr7
This commit is contained in:
commit
9298a80a2c
@ -84,7 +84,7 @@ AC_PATH_TOOL(STRIP, strip)
|
||||
AC_PATH_TOOL(GCOV, gcov)
|
||||
AC_PATH_PROG(LCOV, lcov)
|
||||
dnl Python 3.x is supported from 3.4 on (see https://github.com/bitcoin/bitcoin/issues/7893)
|
||||
AC_PATH_PROGS([PYTHON], [python3.6 python3.5 python3.4 python3 python2.7 python2 python])
|
||||
AC_PATH_PROGS([PYTHON], [python3.7 python3.6 python3.5 python3.4 python3 python])
|
||||
AC_PATH_PROG(GENHTML, genhtml)
|
||||
AC_PATH_PROG([GIT], [git])
|
||||
AC_PATH_PROG(CCACHE,ccache)
|
||||
@ -704,11 +704,7 @@ if test x$use_hardening != xno; then
|
||||
AX_CHECK_LINK_FLAG([[-Wl,--high-entropy-va]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--high-entropy-va"])
|
||||
AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"])
|
||||
AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"])
|
||||
|
||||
if test x$TARGET_OS != xwindows; then
|
||||
AX_CHECK_COMPILE_FLAG([-fPIE],[PIE_FLAGS="-fPIE"])
|
||||
AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"])
|
||||
fi
|
||||
AX_CHECK_LINK_FLAG([[-fPIE -pie]], [PIE_FLAGS="-fPIE"; HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],, [[$CXXFLAG_WERROR]])
|
||||
|
||||
case $host in
|
||||
*mingw*)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
|
||||
import sys
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
|
||||
try:
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
|
||||
import sys
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
|
||||
try:
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
|
||||
try:
|
||||
|
11
contrib/devtools/lint-python-shebang.sh
Executable file
11
contrib/devtools/lint-python-shebang.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# Shebang must use python3 (not python or python2)
|
||||
EXIT_CODE=0
|
||||
for PYTHON_FILE in $(git ls-files -- "*.py"); do
|
||||
if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
|
||||
$(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
|
||||
echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE} (do not use python or python2)"
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
done
|
||||
exit ${EXIT_CODE}
|
@ -1,11 +1,10 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2015-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.
|
||||
'''
|
||||
Test script for security-check.py
|
||||
'''
|
||||
from __future__ import division,print_function
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
@ -22,7 +21,7 @@ def write_testcode(filename):
|
||||
|
||||
def call_security_check(cc, source, executable, options):
|
||||
subprocess.check_call([cc,source,'-o',executable] + options)
|
||||
p = subprocess.Popen(['./security-check.py',executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
|
||||
p = subprocess.Popen(['./security-check.py',executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
|
||||
(stdout, stderr) = p.communicate()
|
||||
return (p.returncode, stdout.rstrip())
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) 2013 The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
if [ -d "$1" ]; then
|
||||
cd "$1" || exit 1
|
||||
else
|
||||
echo "Usage: $0 <datadir>" >&2
|
||||
echo "Removes obsolete Dash database files" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LEVEL=0
|
||||
if [ -f wallet.dat -a -f addr.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=1; fi
|
||||
if [ -f wallet.dat -a -f peers.dat -a -f blkindex.dat -a -f blk0001.dat ]; then LEVEL=2; fi
|
||||
if [ -f wallet.dat -a -f peers.dat -a -f coins/CURRENT -a -f blktree/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=3; fi
|
||||
if [ -f wallet.dat -a -f peers.dat -a -f chainstate/CURRENT -a -f blocks/index/CURRENT -a -f blocks/blk00000.dat ]; then LEVEL=4; fi
|
||||
|
||||
case $LEVEL in
|
||||
0)
|
||||
echo "Error: no Dash datadir detected."
|
||||
exit 1
|
||||
;;
|
||||
1)
|
||||
echo "Detected old Dash datadir (before 0.7)."
|
||||
echo "Nothing to do."
|
||||
exit 0
|
||||
;;
|
||||
2)
|
||||
echo "Detected Dash 0.7 datadir."
|
||||
;;
|
||||
3)
|
||||
echo "Detected Dash pre-0.8 datadir."
|
||||
;;
|
||||
4)
|
||||
echo "Detected Dash 0.8 datadir."
|
||||
;;
|
||||
esac
|
||||
|
||||
FILES=""
|
||||
DIRS=""
|
||||
|
||||
if [ $LEVEL -ge 3 ]; then FILES=$(echo $FILES blk????.dat blkindex.dat); fi
|
||||
if [ $LEVEL -ge 2 ]; then FILES=$(echo $FILES addr.dat); fi
|
||||
if [ $LEVEL -ge 4 ]; then DIRS=$(echo $DIRS coins blktree); fi
|
||||
|
||||
for FILE in $FILES; do
|
||||
if [ -f $FILE ]; then
|
||||
echo "Deleting: $FILE"
|
||||
rm -f $FILE
|
||||
fi
|
||||
done
|
||||
|
||||
for DIR in $DIRS; do
|
||||
if [ -d $DIR ]; then
|
||||
echo "Deleting: $DIR/"
|
||||
rm -rf $DIR
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Done."
|
@ -1,6 +1,7 @@
|
||||
.NOTPARALLEL :
|
||||
|
||||
SOURCES_PATH ?= $(BASEDIR)/sources
|
||||
WORK_PATH = $(BASEDIR)/work
|
||||
BASE_CACHE ?= $(BASEDIR)/built
|
||||
SDK_PATH ?= $(BASEDIR)/SDKs
|
||||
NO_QT ?=
|
||||
@ -28,9 +29,9 @@ else
|
||||
release_type=release
|
||||
endif
|
||||
|
||||
base_build_dir=$(BASEDIR)/work/build
|
||||
base_staging_dir=$(BASEDIR)/work/staging
|
||||
base_download_dir=$(BASEDIR)/work/download
|
||||
base_build_dir=$(WORK_PATH)/build
|
||||
base_staging_dir=$(WORK_PATH)/staging
|
||||
base_download_dir=$(WORK_PATH)/download
|
||||
canonical_host:=$(shell ./config.sub $(HOST))
|
||||
build:=$(shell ./config.sub $(BUILD))
|
||||
|
||||
@ -182,4 +183,4 @@ download-win:
|
||||
@$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
|
||||
download: download-osx download-linux download-win
|
||||
|
||||
.PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources
|
||||
.PHONY: install cached clean clean-all download-one download-osx download-linux download-win download check-packages check-sources
|
||||
|
@ -13,7 +13,7 @@ Do not submit patches solely to modify the style of existing code.
|
||||
[src/.clang-format](/src/.clang-format). You can use the provided
|
||||
[clang-format-diff script](/contrib/devtools/README.md#clang-format-diffpy)
|
||||
tool to clean up patches automatically before submission.
|
||||
- Braces on new lines for namespaces, classes, functions, methods.
|
||||
- Braces on new lines for classes, functions, methods.
|
||||
- Braces on the same line for everything else.
|
||||
- 4 space indentation (no tabs) for every block except namespaces.
|
||||
- No indentation for `public`/`protected`/`private` or for `namespace`.
|
||||
@ -48,8 +48,7 @@ Block style example:
|
||||
```c++
|
||||
int g_count = 0;
|
||||
|
||||
namespace foo
|
||||
{
|
||||
namespace foo {
|
||||
class Class
|
||||
{
|
||||
std::string m_name;
|
||||
@ -512,11 +511,11 @@ Source code organization
|
||||
|
||||
```c++
|
||||
namespace mynamespace {
|
||||
...
|
||||
...
|
||||
} // namespace mynamespace
|
||||
|
||||
namespace {
|
||||
...
|
||||
...
|
||||
} // namespace
|
||||
```
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
import hashlib
|
||||
import sys
|
||||
import os
|
||||
from random import SystemRandom
|
||||
@ -25,15 +24,9 @@ hexseq = list(map(hex, salt_sequence))
|
||||
salt = "".join([x[2:] for x in hexseq])
|
||||
|
||||
#Create 32 byte b64 password
|
||||
password = base64.urlsafe_b64encode(os.urandom(32))
|
||||
password = base64.urlsafe_b64encode(os.urandom(32)).decode("utf-8")
|
||||
|
||||
digestmod = hashlib.sha256
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
password = password.decode('utf-8')
|
||||
digestmod = 'SHA256'
|
||||
|
||||
m = hmac.new(bytearray(salt, 'utf-8'), bytearray(password, 'utf-8'), digestmod)
|
||||
m = hmac.new(bytearray(salt, 'utf-8'), bytearray(password, 'utf-8'), "SHA256")
|
||||
result = m.hexdigest()
|
||||
|
||||
print("String to be appended to bitcoin.conf:")
|
||||
|
@ -13,7 +13,10 @@ AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
BreakBeforeBinaryOperators: false
|
||||
BreakBeforeBraces: Linux
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AfterFunction: true
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: AfterColon
|
||||
|
@ -215,7 +215,6 @@ BITCOIN_CORE_H = \
|
||||
rpc/client.h \
|
||||
rpc/mining.h \
|
||||
rpc/protocol.h \
|
||||
rpc/safemode.h \
|
||||
rpc/server.h \
|
||||
rpc/register.h \
|
||||
rpc/util.h \
|
||||
@ -344,7 +343,6 @@ libdash_server_a_SOURCES = \
|
||||
rpc/rawtransaction.cpp \
|
||||
rpc/rpcevo.cpp \
|
||||
rpc/rpcquorums.cpp \
|
||||
rpc/safemode.cpp \
|
||||
rpc/server.cpp \
|
||||
rpc/privatesend.cpp \
|
||||
script/sigcache.cpp \
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <policy/policy.h>
|
||||
#include <rpc/server.h>
|
||||
#include <rpc/register.h>
|
||||
#include <rpc/safemode.h>
|
||||
#include <rpc/blockchain.h>
|
||||
#include <script/standard.h>
|
||||
#include <script/sigcache.h>
|
||||
@ -577,9 +576,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
|
||||
strUsage += HelpMessageOpt("-checkmempool=<n>", strprintf("Run checks every <n> transactions (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
|
||||
strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
|
||||
strUsage += HelpMessageOpt("-disablesafemode", strprintf("Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE));
|
||||
strUsage += HelpMessageOpt("-deprecatedrpc=<method>", "Allows deprecated RPC method(s) to be used");
|
||||
strUsage += HelpMessageOpt("-testsafemode", strprintf("Force safe mode (default: %u)", DEFAULT_TESTSAFEMODE));
|
||||
strUsage += HelpMessageOpt("-dropmessagestest=<n>", "Randomly drop 1 of every <n> network messages");
|
||||
strUsage += HelpMessageOpt("-fuzzmessagestest=<n>", "Randomly fuzz 1 of every <n> network messages");
|
||||
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
|
||||
|
@ -436,7 +436,7 @@ std::string EntryDescriptionString()
|
||||
" \"instantlock\" : true|false (boolean) True if this transaction was locked via InstantSend\n";
|
||||
}
|
||||
|
||||
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e)
|
||||
void entryToJSON(UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCKS_REQUIRED(::mempool.cs)
|
||||
{
|
||||
AssertLockHeld(mempool.cs);
|
||||
|
||||
|
@ -51,6 +51,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "listreceivedbyaddress", 1, "addlocked" },
|
||||
{ "listreceivedbyaddress", 2, "include_empty" },
|
||||
{ "listreceivedbyaddress", 3, "include_watchonly" },
|
||||
{ "listreceivedbyaddress", 4, "address_filter" },
|
||||
{ "listreceivedbyaccount", 0, "minconf" },
|
||||
{ "listreceivedbyaccount", 1, "addlocked" },
|
||||
{ "listreceivedbyaccount", 2, "include_empty" },
|
||||
|
@ -8,7 +8,6 @@
|
||||
#endif // ENABLE_WALLET
|
||||
#include <privatesend/privatesend-server.h>
|
||||
#include <rpc/server.h>
|
||||
#include <rpc/safemode.h>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
@ -30,8 +29,6 @@ UniValue privatesend(const JSONRPCRequest& request)
|
||||
" reset - Reset mixing\n"
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
if (fMasternodeMode)
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Client-side mixing is not supported on masternodes");
|
||||
|
||||
|
@ -46,7 +46,6 @@ enum RPCErrorCode
|
||||
|
||||
//! General application defined errors
|
||||
RPC_MISC_ERROR = -1, //!< std::exception thrown in command handling
|
||||
RPC_FORBIDDEN_BY_SAFE_MODE = -2, //!< Server is in safe mode, and command is not allowed in safe mode
|
||||
RPC_TYPE_ERROR = -3, //!< Unexpected type was passed as parameter
|
||||
RPC_INVALID_ADDRESS_OR_KEY = -5, //!< Invalid address or key
|
||||
RPC_OUT_OF_MEMORY = -7, //!< Ran out of memory during operation
|
||||
@ -85,6 +84,10 @@ enum RPCErrorCode
|
||||
RPC_WALLET_ALREADY_UNLOCKED = -17, //!< Wallet is already unlocked
|
||||
RPC_WALLET_NOT_FOUND = -18, //!< Invalid wallet specified
|
||||
RPC_WALLET_NOT_SPECIFIED = -19, //!< No wallet specified (error when there are multiple wallets loaded)
|
||||
|
||||
|
||||
//! Unused reserved codes, kept around for backwards compatibility. Do not reuse.
|
||||
RPC_FORBIDDEN_BY_SAFE_MODE = -2, //!< Server is in safe mode, and command is not allowed in safe mode
|
||||
};
|
||||
|
||||
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <net.h>
|
||||
#include <policy/policy.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <rpc/safemode.h>
|
||||
#include <rpc/server.h>
|
||||
#include <script/script.h>
|
||||
#include <script/script_error.h>
|
||||
@ -793,8 +792,6 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("signrawtransaction", "\"myhex\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true);
|
||||
@ -1008,8 +1005,6 @@ UniValue sendrawtransaction(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("sendrawtransaction", "\"signedhex\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
std::promise<void> promise;
|
||||
|
||||
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL});
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <core_io.h>
|
||||
#include <init.h>
|
||||
#include <messagesigner.h>
|
||||
#include <rpc/safemode.h>
|
||||
#include <rpc/server.h>
|
||||
#include <txmempool.h>
|
||||
#include <utilmoneystr.h>
|
||||
@ -429,8 +428,6 @@ UniValue protx_register(const JSONRPCRequest& request)
|
||||
protx_register_prepare_help();
|
||||
}
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
@ -579,8 +576,6 @@ UniValue protx_register_submit(const JSONRPCRequest& request)
|
||||
protx_register_submit_help(pwallet);
|
||||
}
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
@ -634,8 +629,6 @@ UniValue protx_update_service(const JSONRPCRequest& request)
|
||||
if (request.fHelp || (request.params.size() < 4 || request.params.size() > 6))
|
||||
protx_update_service_help(pwallet);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
@ -732,8 +725,6 @@ UniValue protx_update_registrar(const JSONRPCRequest& request)
|
||||
protx_update_registrar_help(pwallet);
|
||||
}
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
@ -822,8 +813,6 @@ UniValue protx_revoke(const JSONRPCRequest& request)
|
||||
protx_revoke_help(pwallet);
|
||||
}
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
#include <rpc/safemode.h>
|
||||
|
||||
#include <rpc/protocol.h>
|
||||
#include <util.h>
|
||||
#include <warnings.h>
|
||||
|
||||
void ObserveSafeMode()
|
||||
{
|
||||
std::string warning = GetWarnings("rpc");
|
||||
if (warning != "" && !gArgs.GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE)) {
|
||||
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, std::string("Safe mode: ") + warning);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
// Copyright (c) 2017 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_RPC_SAFEMODE_H
|
||||
#define BITCOIN_RPC_SAFEMODE_H
|
||||
|
||||
static const bool DEFAULT_DISABLE_SAFEMODE = true;
|
||||
|
||||
void ObserveSafeMode();
|
||||
|
||||
#endif // BITCOIN_RPC_SAFEMODE_H
|
@ -615,15 +615,6 @@ public:
|
||||
|
||||
return nFound;
|
||||
}
|
||||
int Find(opcodetype op) const
|
||||
{
|
||||
int nFound = 0;
|
||||
opcodetype opcode;
|
||||
for (const_iterator pc = begin(); pc != end() && GetOp(pc, opcode);)
|
||||
if (opcode == op)
|
||||
++nFound;
|
||||
return nFound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs
|
||||
|
@ -453,7 +453,7 @@ private:
|
||||
mutable bool blockSinceLastRollingFeeBump;
|
||||
mutable double rollingMinimumFeeRate; //!< minimum fee to get into the pool, decreases exponentially
|
||||
|
||||
void trackPackageRemoved(const CFeeRate& rate);
|
||||
void trackPackageRemoved(const CFeeRate& rate) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
public:
|
||||
|
||||
@ -532,7 +532,7 @@ private:
|
||||
void UpdateParent(txiter entry, txiter parent, bool add);
|
||||
void UpdateChild(txiter entry, txiter child, bool add);
|
||||
|
||||
std::vector<indexed_transaction_set::const_iterator> GetSortedDepthAndScore() const;
|
||||
std::vector<indexed_transaction_set::const_iterator> GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
public:
|
||||
indirectmap<COutPoint, const CTransaction*> mapNextTx;
|
||||
@ -607,7 +607,7 @@ public:
|
||||
* Set updateDescendants to true when removing a tx that was in a block, so
|
||||
* that any in-mempool descendants have their ancestor state updated.
|
||||
*/
|
||||
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN);
|
||||
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** When adding transactions from a disconnected block back to the mempool,
|
||||
* new mempool entries may have children in the mempool (which is generally
|
||||
|
16
src/util.h
16
src/util.h
@ -201,14 +201,16 @@ template<typename T, typename... Args> static inline void MarkUsed(const T& t, c
|
||||
#define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0)
|
||||
#else
|
||||
#define LogPrintf(...) do { \
|
||||
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
|
||||
try { \
|
||||
_log_msg_ = tfm::format(__VA_ARGS__); \
|
||||
} catch (tinyformat::format_error &e) { \
|
||||
/* Original format string will have newline so don't add one here */ \
|
||||
_log_msg_ = "Error \"" + std::string(e.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
|
||||
if (fPrintToConsole || fPrintToDebugLog) { \
|
||||
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
|
||||
try { \
|
||||
_log_msg_ = tfm::format(__VA_ARGS__); \
|
||||
} catch (tinyformat::format_error &e) { \
|
||||
/* Original format string will have newline so don't add one here */ \
|
||||
_log_msg_ = "Error \"" + std::string(e.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
|
||||
} \
|
||||
LogPrintStr(_log_msg_); \
|
||||
} \
|
||||
LogPrintStr(_log_msg_); \
|
||||
} while(0)
|
||||
|
||||
#define LogPrint(category, ...) do { \
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <base58.h>
|
||||
#include <chain.h>
|
||||
#include <rpc/safemode.h>
|
||||
#include <rpc/server.h>
|
||||
#include <validation.h>
|
||||
#include <script/script.h>
|
||||
@ -180,7 +179,6 @@ UniValue abortrescan(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("abortrescan", "")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) return false;
|
||||
pwallet->AbortRescan();
|
||||
return true;
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <policy/fees.h>
|
||||
#include <privatesend/privatesend-client.h>
|
||||
#include <rpc/mining.h>
|
||||
#include <rpc/safemode.h>
|
||||
#include <rpc/server.h>
|
||||
#include <rpc/util.h>
|
||||
#include <timedata.h>
|
||||
@ -459,8 +458,6 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.1, \"donation\", \"seans outpost\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -553,8 +550,6 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("listaddressgroupings", "")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -713,8 +708,6 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("getreceivedbyaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 6")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -782,8 +775,6 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("getreceivedbyaccount", "\"tabby\", 6")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -853,8 +844,6 @@ UniValue getbalance(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("getbalance", "\"*\", 6")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -907,8 +896,6 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request)
|
||||
"getunconfirmedbalance\n"
|
||||
"Returns the server's total unconfirmed balance\n");
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -947,7 +934,6 @@ UniValue movecmd(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
std::string strFrom = AccountFromValue(request.params[0]);
|
||||
@ -1007,8 +993,6 @@ UniValue sendfrom(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("sendfrom", "\"tabby\", \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.01, 6, false, \"donation\", \"seans outpost\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -1099,8 +1083,6 @@ UniValue sendmany(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("sendmany", "\"tabby\", \"{\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\\\":0.01,\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcG\\\":0.02}\", 6, false, \"testing\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -1311,6 +1293,16 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
|
||||
if(params[3].get_bool())
|
||||
filter = filter | ISMINE_WATCH_ONLY;
|
||||
|
||||
bool has_filtered_address = false;
|
||||
CTxDestination filtered_address = CNoDestination();
|
||||
if (!fByAccounts && params.size() > 4) {
|
||||
if (!IsValidDestinationString(params[4].get_str())) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "address_filter parameter was invalid");
|
||||
}
|
||||
filtered_address = DecodeDestination(params[4].get_str());
|
||||
has_filtered_address = true;
|
||||
}
|
||||
|
||||
// Tally
|
||||
std::map<CTxDestination, tallyitem> mapTally;
|
||||
for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
|
||||
@ -1329,6 +1321,10 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
|
||||
if (!ExtractDestination(txout.scriptPubKey, address))
|
||||
continue;
|
||||
|
||||
if (has_filtered_address && !(filtered_address == address)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
isminefilter mine = IsMine(*pwallet, address);
|
||||
if(!(mine & filter))
|
||||
continue;
|
||||
@ -1345,14 +1341,28 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
|
||||
// Reply
|
||||
UniValue ret(UniValue::VARR);
|
||||
std::map<std::string, tallyitem> mapAccountTally;
|
||||
for (const std::pair<CTxDestination, CAddressBookData>& item : pwallet->mapAddressBook) {
|
||||
const CTxDestination& dest = item.first;
|
||||
const std::string& strAccount = item.second.name;
|
||||
std::map<CTxDestination, tallyitem>::iterator it = mapTally.find(dest);
|
||||
|
||||
// Create mapAddressBook iterator
|
||||
// If we aren't filtering, go from begin() to end()
|
||||
auto start = pwallet->mapAddressBook.begin();
|
||||
auto end = pwallet->mapAddressBook.end();
|
||||
// If we are filtering, find() the applicable entry
|
||||
if (has_filtered_address) {
|
||||
start = pwallet->mapAddressBook.find(filtered_address);
|
||||
if (start != end) {
|
||||
end = std::next(start);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto item_it = start; item_it != end; ++item_it)
|
||||
{
|
||||
const CTxDestination& address = item_it->first;
|
||||
const std::string& strAccount = item_it->second.name;
|
||||
auto it = mapTally.find(address);
|
||||
if (it == mapTally.end() && !fIncludeEmpty)
|
||||
continue;
|
||||
|
||||
isminefilter mine = IsMine(*pwallet, dest);
|
||||
isminefilter mine = IsMine(*pwallet, address);
|
||||
if(!(mine & filter))
|
||||
continue;
|
||||
|
||||
@ -1378,7 +1388,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
if(fIsWatchonly)
|
||||
obj.pushKV("involvesWatchonly", true);
|
||||
obj.pushKV("address", EncodeDestination(dest));
|
||||
obj.pushKV("address", EncodeDestination(address));
|
||||
obj.pushKV("account", strAccount);
|
||||
obj.pushKV("amount", ValueFromAmount(nAmount));
|
||||
obj.pushKV("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
|
||||
@ -1423,16 +1433,16 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
if (request.fHelp || request.params.size() > 4)
|
||||
if (request.fHelp || request.params.size() > 5)
|
||||
throw std::runtime_error(
|
||||
"listreceivedbyaddress ( minconf addlocked include_empty include_watchonly)\n"
|
||||
"listreceivedbyaddress ( minconf addlocked include_empty include_watchonly address_filter )\n"
|
||||
"\nList incoming payments grouped by receiving address.\n"
|
||||
"\nArguments:\n"
|
||||
"1. minconf (numeric, optional, default=1) The minimum number of confirmations before payments are included.\n"
|
||||
"2. addlocked (bool, optional, default=false) Whether to include transactions locked via InstantSend.\n"
|
||||
"3. include_empty (bool, optional, default=false) Whether to include addresses that haven't received any payments.\n"
|
||||
"4. include_watchonly (bool, optional, default=false) Whether to include watch-only addresses (see 'importaddress').\n"
|
||||
|
||||
"5. address_filter (string, optional) If present, only return information on this address.\n"
|
||||
"\nResult:\n"
|
||||
"[\n"
|
||||
" {\n"
|
||||
@ -1456,10 +1466,9 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
|
||||
+ HelpExampleCli("listreceivedbyaddress", "")
|
||||
+ HelpExampleCli("listreceivedbyaddress", "6 false true")
|
||||
+ HelpExampleRpc("listreceivedbyaddress", "6, false, true, true")
|
||||
+ HelpExampleRpc("listreceivedbyaddress", "6, false, true, true, \"XbtdLrTsrPDhGy1wXtwKYoBpuKovE3JeBK\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -1504,8 +1513,6 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("listreceivedbyaccount", "6, false, true, true")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -1699,8 +1706,6 @@ UniValue listtransactions(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("listtransactions", "\"*\", 20, 100")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -1802,8 +1807,6 @@ UniValue listaccounts(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("listaccounts", "6")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -1920,8 +1923,6 @@ UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -2059,8 +2060,6 @@ UniValue gettransaction(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -2127,8 +2126,6 @@ UniValue abandontransaction(const JSONRPCRequest& request)
|
||||
);
|
||||
}
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -2615,7 +2612,6 @@ UniValue listlockunspent(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("listlockunspent", "")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
LOCK2(cs_main, pwallet->cs_wallet);
|
||||
|
||||
std::vector<COutPoint> vOutpts;
|
||||
@ -2761,8 +2757,6 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("getwalletinfo", "")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
pwallet->BlockUntilSyncedToCurrentChain();
|
||||
@ -3042,8 +3036,6 @@ UniValue listunspent(const JSONRPCRequest& request)
|
||||
+ HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
|
||||
int nMinDepth = 1;
|
||||
if (!request.params[0].isNull()) {
|
||||
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
|
||||
@ -3235,7 +3227,6 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
||||
+ HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"")
|
||||
);
|
||||
|
||||
ObserveSafeMode();
|
||||
RPCTypeCheck(request.params, {UniValue::VSTR});
|
||||
|
||||
// Make sure the results are valid at least up to the most recent block
|
||||
@ -3534,7 +3525,7 @@ static const CRPCCommand commands[] =
|
||||
{ "wallet", "listaddressbalances", &listaddressbalances, {"minamount"} },
|
||||
{ "wallet", "listlockunspent", &listlockunspent, {} },
|
||||
{ "wallet", "listreceivedbyaccount", &listreceivedbyaccount, {"minconf","addlocked","include_empty","include_watchonly"} },
|
||||
{ "wallet", "listreceivedbyaddress", &listreceivedbyaddress, {"minconf","addlocked","include_empty","include_watchonly"} },
|
||||
{ "wallet", "listreceivedbyaddress", &listreceivedbyaddress, {"minconf","addlocked","include_empty","include_watchonly","address_filter"} },
|
||||
{ "wallet", "listsinceblock", &listsinceblock, {"blockhash","target_confirmations","include_watchonly","include_removed"} },
|
||||
{ "wallet", "listtransactions", &listtransactions, {"account","count","skip","include_watchonly"} },
|
||||
{ "wallet", "listunspent", &listunspent, {"minconf","maxconf","addresses","include_unsafe","query_options"} },
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <consensus/consensus.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <fs.h>
|
||||
#include <init.h>
|
||||
#include <key.h>
|
||||
#include <keystore.h>
|
||||
#include <validation.h>
|
||||
@ -2060,23 +2061,27 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
|
||||
fAbortRescan = false;
|
||||
ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
|
||||
CBlockIndex* tip = nullptr;
|
||||
double dProgressStart;
|
||||
double dProgressTip;
|
||||
double progress_begin;
|
||||
double progress_end;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
tip = chainActive.Tip();
|
||||
dProgressStart = GuessVerificationProgress(chainParams.TxData(), pindex);
|
||||
dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip);
|
||||
progress_begin = GuessVerificationProgress(chainParams.TxData(), pindex);
|
||||
if (pindexStop == nullptr) {
|
||||
tip = chainActive.Tip();
|
||||
progress_end = GuessVerificationProgress(chainParams.TxData(), tip);
|
||||
} else {
|
||||
progress_end = GuessVerificationProgress(chainParams.TxData(), pindexStop);
|
||||
}
|
||||
}
|
||||
double gvp = dProgressStart;
|
||||
while (pindex && !fAbortRescan)
|
||||
double progress_current = progress_begin;
|
||||
while (pindex && !fAbortRescan && !ShutdownRequested())
|
||||
{
|
||||
if (pindex->nHeight % 100 == 0 && dProgressTip - dProgressStart > 0.0) {
|
||||
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((gvp - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
|
||||
if (pindex->nHeight % 100 == 0 && progress_end - progress_begin > 0.0) {
|
||||
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((progress_current - progress_begin) / (progress_end - progress_begin) * 100))));
|
||||
}
|
||||
if (GetTime() >= nNow + 60) {
|
||||
nNow = GetTime();
|
||||
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, gvp);
|
||||
LogPrintf("Still rescanning. At block %d. Progress=%f\n", pindex->nHeight, progress_current);
|
||||
}
|
||||
|
||||
CBlock block;
|
||||
@ -2100,16 +2105,18 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, CBlock
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindex = chainActive.Next(pindex);
|
||||
gvp = GuessVerificationProgress(chainParams.TxData(), pindex);
|
||||
if (tip != chainActive.Tip()) {
|
||||
progress_current = GuessVerificationProgress(chainParams.TxData(), pindex);
|
||||
if (pindexStop == nullptr && tip != chainActive.Tip()) {
|
||||
tip = chainActive.Tip();
|
||||
// in case the tip has changed, update progress max
|
||||
dProgressTip = GuessVerificationProgress(chainParams.TxData(), tip);
|
||||
progress_end = GuessVerificationProgress(chainParams.TxData(), tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pindex && fAbortRescan) {
|
||||
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, gvp);
|
||||
LogPrintf("Rescan aborted at block %d. Progress=%f\n", pindex->nHeight, progress_current);
|
||||
} else if (pindex && ShutdownRequested()) {
|
||||
LogPrintf("Rescan interrupted by shutdown request at block %d. Progress=%f\n", pindex->nHeight, progress_current);
|
||||
}
|
||||
ShowProgress(_("Rescanning..."), 100); // hide progress dialog in GUI
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ void SetfLargeWorkInvalidChainFound(bool flag)
|
||||
std::string GetWarnings(const std::string& strFor)
|
||||
{
|
||||
std::string strStatusBar;
|
||||
std::string strRPC;
|
||||
std::string strGUI;
|
||||
const std::string uiAlertSeperator = "<hr />";
|
||||
|
||||
@ -52,9 +51,6 @@ std::string GetWarnings(const std::string& strFor)
|
||||
strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
|
||||
}
|
||||
|
||||
if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
|
||||
strStatusBar = strRPC = strGUI = "testsafemode enabled";
|
||||
|
||||
// Misc warnings like out of disk space and clock is wrong
|
||||
if (strMiscWarning != "")
|
||||
{
|
||||
@ -64,12 +60,12 @@ std::string GetWarnings(const std::string& strFor)
|
||||
|
||||
if (fLargeWorkForkFound)
|
||||
{
|
||||
strStatusBar = strRPC = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
|
||||
strStatusBar = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
|
||||
}
|
||||
else if (fLargeWorkInvalidChainFound)
|
||||
{
|
||||
strStatusBar = strRPC = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
|
||||
strStatusBar = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
|
||||
strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
|
||||
}
|
||||
|
||||
@ -77,8 +73,6 @@ std::string GetWarnings(const std::string& strFor)
|
||||
return strGUI;
|
||||
else if (strFor == "statusbar")
|
||||
return strStatusBar;
|
||||
else if (strFor == "rpc")
|
||||
return strRPC;
|
||||
assert(!"GetWarnings(): invalid parameter");
|
||||
return "error";
|
||||
}
|
||||
|
@ -15,13 +15,10 @@ bool GetfLargeWorkForkFound();
|
||||
void SetfLargeWorkInvalidChainFound(bool flag);
|
||||
/** Format a string that describes several potential problems detected by the core.
|
||||
* strFor can have three values:
|
||||
* - "rpc": get critical warnings, which should put the client in safe mode if non-empty
|
||||
* - "statusbar": get all warnings
|
||||
* - "gui": get all warnings, translated (where possible) for GUI
|
||||
* This function only returns the highest priority warning of the set selected by strFor.
|
||||
*/
|
||||
std::string GetWarnings(const std::string& strFor);
|
||||
|
||||
static const bool DEFAULT_TESTSAFEMODE = false;
|
||||
|
||||
#endif // BITCOIN_WARNINGS_H
|
||||
|
@ -125,7 +125,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
# Reboot node 1 to clear its mempool (hopefully make the invalidate faster)
|
||||
# Lower the block max size so we don't keep mining all our big mempool transactions (from disconnected blocks)
|
||||
self.stop_node(1)
|
||||
self.start_node(1, extra_args=["-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"])
|
||||
self.start_node(1, extra_args=["-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5"])
|
||||
|
||||
height = self.nodes[1].getblockcount()
|
||||
self.log.info("Current block height: %d" % height)
|
||||
@ -148,7 +148,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
|
||||
# Reboot node1 to clear those giant tx's from mempool
|
||||
self.stop_node(1)
|
||||
self.start_node(1, extra_args=["-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"])
|
||||
self.start_node(1, extra_args=["-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5"])
|
||||
|
||||
self.log.info("Generating new longer chain of 300 more blocks")
|
||||
self.nodes[1].generate(300)
|
||||
|
@ -49,10 +49,44 @@ class ReceivedByTest(BitcoinTestFramework):
|
||||
assert_array_result(self.nodes[1].listreceivedbyaddress(11), {"address": addr}, {}, True)
|
||||
|
||||
# Empty Tx
|
||||
addr = self.nodes[1].getnewaddress()
|
||||
empty_addr = self.nodes[1].getnewaddress()
|
||||
assert_array_result(self.nodes[1].listreceivedbyaddress(0, False, True),
|
||||
{"address":addr},
|
||||
{"address":addr, "account":"", "amount":0, "confirmations":0, "txids":[]})
|
||||
{"address": empty_addr},
|
||||
{"address": empty_addr, "account": "", "amount": 0, "confirmations": 0, "txids": []})
|
||||
|
||||
#Test Address filtering
|
||||
#Only on addr
|
||||
expected = {"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":10, "txids":[txid,]}
|
||||
res = self.nodes[1].listreceivedbyaddress(minconf=0, addlocked=False, include_empty=True, include_watchonly=True, address_filter=addr)
|
||||
assert_array_result(res, {"address":addr},expected)
|
||||
assert_equal(len(res), 1)
|
||||
#Error on invalid address
|
||||
assert_raises_rpc_error(-4, "address_filter parameter was invalid", self.nodes[1].listreceivedbyaddress, minconf=0, addlocked=True, include_empty=True, include_watchonly=True, address_filter="bamboozling")
|
||||
#Another address receive money
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, True)
|
||||
assert_equal(len(res), 2) #Right now 2 entries
|
||||
other_addr = self.nodes[1].getnewaddress()
|
||||
txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1)
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
#Same test as above should still pass
|
||||
expected = {"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":11, "txids":[txid,]}
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, True, addr)
|
||||
assert_array_result(res, {"address":addr}, expected)
|
||||
assert_equal(len(res), 1)
|
||||
#Same test as above but with other_addr should still pass
|
||||
expected = {"address":other_addr, "account":"", "amount":Decimal("0.1"), "confirmations":1, "txids":[txid2,]}
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, True, other_addr)
|
||||
assert_array_result(res, {"address":other_addr}, expected)
|
||||
assert_equal(len(res), 1)
|
||||
#Should be two entries though without filter
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, True)
|
||||
assert_equal(len(res), 3) #Became 3 entries
|
||||
|
||||
#Not on random addr
|
||||
other_addr = self.nodes[0].getnewaddress() # note on node[0]! just a random addr
|
||||
res = self.nodes[1].listreceivedbyaddress(0, True, True, True, other_addr)
|
||||
assert_equal(len(res), 0)
|
||||
|
||||
self.log.info("getreceivedbyaddress Test")
|
||||
|
||||
|
@ -10,7 +10,6 @@ This file is modified from python-bitcoinlib.
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
ssl = ctypes.cdll.LoadLibrary(ctypes.util.find_library ('ssl') or 'libeay32')
|
||||
|
||||
@ -202,10 +201,5 @@ class CPubKey(bytes):
|
||||
return repr(self)
|
||||
|
||||
def __repr__(self):
|
||||
# Always have represent as b'<secret>' so test cases don't have to
|
||||
# change for py2/3
|
||||
if sys.version > '3':
|
||||
return '%s(%s)' % (self.__class__.__name__, super(CPubKey, self).__repr__())
|
||||
else:
|
||||
return '%s(b%s)' % (self.__class__.__name__, super(CPubKey, self).__repr__())
|
||||
return '%s(%s)' % (self.__class__.__name__, super(CPubKey, self).__repr__())
|
||||
|
||||
|
@ -11,15 +11,6 @@ This file is modified from python-bitcoinlib.
|
||||
from .mininode import CTransaction, CTxOut, sha256, hash256
|
||||
from binascii import hexlify
|
||||
import hashlib
|
||||
|
||||
import sys
|
||||
bchr = chr
|
||||
bord = ord
|
||||
if sys.version > '3':
|
||||
long = int
|
||||
bchr = lambda x: bytes([x])
|
||||
bord = lambda x: x
|
||||
|
||||
import struct
|
||||
|
||||
from .bignum import bn2vch
|
||||
@ -41,9 +32,9 @@ class CScriptOp(int):
|
||||
def encode_op_pushdata(d):
|
||||
"""Encode a PUSHDATA op, returning bytes"""
|
||||
if len(d) < 0x4c:
|
||||
return b'' + bchr(len(d)) + d # OP_PUSHDATA
|
||||
return b'' + bytes([len(d)]) + d # OP_PUSHDATA
|
||||
elif len(d) <= 0xff:
|
||||
return b'\x4c' + bchr(len(d)) + d # OP_PUSHDATA1
|
||||
return b'\x4c' + bytes([len(d)]) + d # OP_PUSHDATA1
|
||||
elif len(d) <= 0xffff:
|
||||
return b'\x4d' + struct.pack(b'<H', len(d)) + d # OP_PUSHDATA2
|
||||
elif len(d) <= 0xffffffff:
|
||||
@ -389,7 +380,7 @@ class CScriptNum():
|
||||
r.append(0x80 if neg else 0)
|
||||
elif neg:
|
||||
r[-1] |= 0x80
|
||||
return bytes(bchr(len(r)) + r)
|
||||
return bytes([len(r)]) + r
|
||||
|
||||
|
||||
class CScript(bytes):
|
||||
@ -406,17 +397,17 @@ class CScript(bytes):
|
||||
def __coerce_instance(cls, other):
|
||||
# Coerce other into bytes
|
||||
if isinstance(other, CScriptOp):
|
||||
other = bchr(other)
|
||||
other = bytes([other])
|
||||
elif isinstance(other, CScriptNum):
|
||||
if (other.value == 0):
|
||||
other = bchr(CScriptOp(OP_0))
|
||||
other = bytes([CScriptOp(OP_0)])
|
||||
else:
|
||||
other = CScriptNum.encode(other)
|
||||
elif isinstance(other, int):
|
||||
if 0 <= other <= 16:
|
||||
other = bytes(bchr(CScriptOp.encode_op_n(other)))
|
||||
other = bytes([CScriptOp.encode_op_n(other)])
|
||||
elif other == -1:
|
||||
other = bytes(bchr(OP_1NEGATE))
|
||||
other = bytes([OP_1NEGATE])
|
||||
else:
|
||||
other = CScriptOp.encode_op_pushdata(bn2vch(other))
|
||||
elif isinstance(other, (bytes, bytearray)):
|
||||
@ -459,7 +450,7 @@ class CScript(bytes):
|
||||
i = 0
|
||||
while i < len(self):
|
||||
sop_idx = i
|
||||
opcode = bord(self[i])
|
||||
opcode = self[i]
|
||||
i += 1
|
||||
|
||||
if opcode > OP_PUSHDATA4:
|
||||
@ -475,21 +466,21 @@ class CScript(bytes):
|
||||
pushdata_type = 'PUSHDATA1'
|
||||
if i >= len(self):
|
||||
raise CScriptInvalidError('PUSHDATA1: missing data length')
|
||||
datasize = bord(self[i])
|
||||
datasize = self[i]
|
||||
i += 1
|
||||
|
||||
elif opcode == OP_PUSHDATA2:
|
||||
pushdata_type = 'PUSHDATA2'
|
||||
if i + 1 >= len(self):
|
||||
raise CScriptInvalidError('PUSHDATA2: missing data length')
|
||||
datasize = bord(self[i]) + (bord(self[i+1]) << 8)
|
||||
datasize = self[i] + (self[i+1] << 8)
|
||||
i += 2
|
||||
|
||||
elif opcode == OP_PUSHDATA4:
|
||||
pushdata_type = 'PUSHDATA4'
|
||||
if i + 3 >= len(self):
|
||||
raise CScriptInvalidError('PUSHDATA4: missing data length')
|
||||
datasize = bord(self[i]) + (bord(self[i+1]) << 8) + (bord(self[i+2]) << 16) + (bord(self[i+3]) << 24)
|
||||
datasize = self[i] + (self[i+1] << 8) + (self[i+2] << 16) + (self[i+3] << 24)
|
||||
i += 4
|
||||
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user