diff --git a/ci/lint/04_install.sh b/ci/lint/04_install.sh index 431672ba1fb3f..f70ff2d2235e4 100755 --- a/ci/lint/04_install.sh +++ b/ci/lint/04_install.sh @@ -33,10 +33,10 @@ if [ -z "${SKIP_PYTHON_INSTALL}" ]; then python3 --version fi -${CI_RETRY_EXE} pip3 install codespell==2.0.0 -${CI_RETRY_EXE} pip3 install flake8==3.8.3 +${CI_RETRY_EXE} pip3 install codespell==2.1.0 +${CI_RETRY_EXE} pip3 install flake8==4.0.1 ${CI_RETRY_EXE} pip3 install lief==0.13.1 -${CI_RETRY_EXE} pip3 install mypy==0.910 +${CI_RETRY_EXE} pip3 install mypy==0.942 ${CI_RETRY_EXE} pip3 install pyzmq==22.3.0 ${CI_RETRY_EXE} pip3 install vulture==2.3 diff --git a/contrib/containers/ci/ci-slim.Dockerfile b/contrib/containers/ci/ci-slim.Dockerfile index 2bfb3baea2432..7a498bf2b71b4 100644 --- a/contrib/containers/ci/ci-slim.Dockerfile +++ b/contrib/containers/ci/ci-slim.Dockerfile @@ -69,12 +69,12 @@ RUN set -ex; \ # Install Python packages RUN set -ex; \ pip3 install --no-cache-dir \ - codespell==1.17.1 \ - flake8==3.8.3 \ + codespell==2.1.0 \ + flake8==4.0.1 \ jinja2 \ lief==0.13.2 \ multiprocess \ - mypy==0.910 \ + mypy==0.942 \ pyzmq==22.3.0 \ vulture==2.3 @@ -86,7 +86,7 @@ RUN set -ex; \ cd dash_hash && pip3 install -r requirements.txt .; \ cd .. && rm -rf dash_hash -ARG SHELLCHECK_VERSION=v0.7.1 +ARG SHELLCHECK_VERSION=v0.8.0 RUN set -ex; \ curl -fL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" -o /tmp/shellcheck.tar.xz; \ mkdir -p /opt/shellcheck && tar -xf /tmp/shellcheck.tar.xz -C /opt/shellcheck --strip-components=1 && rm /tmp/shellcheck.tar.xz diff --git a/contrib/debian/examples/dash.conf b/contrib/debian/examples/dash.conf index 3bb5690ca4968..22965bc6c0009 100644 --- a/contrib/debian/examples/dash.conf +++ b/contrib/debian/examples/dash.conf @@ -1,185 +1 @@ -## -## dash.conf configuration file. Lines beginning with # are comments. -## - -# Network-related settings: - -# Note that if you use testnet or regtest, particularly with the options -# addnode, connect, port, bind, rpcport, rpcbind or wallet, you will also -# want to read "[Sections]" further down. - -# Run on the test network instead of the real dash network. -#testnet=0 - -# Run a regression test network -#regtest=0 - -# Connect via a SOCKS5 proxy -#proxy=127.0.0.1:9050 - -# Bind to given address and always listen on it. Use [host]:port notation for IPv6 -#bind= - -# Bind to given address and add permission flags to peers connecting to it. Use [host]:port notation for IPv6 -#whitebind=perm@ - -############################################################## -## Quick Primer on addnode vs connect ## -## Let's say for instance you use addnode=4.2.2.4 ## -## addnode will connect you to and tell you about the ## -## nodes connected to 4.2.2.4. In addition it will tell ## -## the other nodes connected to it that you exist so ## -## they can connect to you. ## -## connect will not do the above when you 'connect' to it. ## -## It will *only* connect you to 4.2.2.4 and no one else.## -## ## -## So if you're behind a firewall, or have other problems ## -## finding nodes, add some using 'addnode'. ## -## ## -## If you want to stay private, use 'connect' to only ## -## connect to "trusted" nodes. ## -## ## -## If you run multiple nodes on a LAN, there's no need for ## -## all of them to open lots of connections. Instead ## -## 'connect' them all to one node that is port forwarded ## -## and has lots of connections. ## -## Thanks goes to [Noodle] on Freenode. ## -############################################################## - -# Use as many addnode= settings as you like to connect to specific peers -#addnode=69.164.218.197 -#addnode=10.0.0.2:9999 - -# Alternatively use as many connect= settings as you like to connect ONLY to specific peers -#connect=69.164.218.197 -#connect=10.0.0.1:9999 - -# Listening mode, enabled by default except when 'connect' is being used -#listen=1 - -# Port on which to listen for connections (default: 9999, testnet: 19999, regtest: 19899) -#port= - -# Maximum number of inbound + outbound connections (default: 125). This option -# applies only if inbound connections are enabled; otherwise, the number of connections -# will not be more than 11: 8 full-relay connections, 2 block-relay-only ones, and -# occasionally 1 short-lived feeler or extra outbound block-relay-only connection. -# These limits do not apply to connections added manually with the -addnode -# configuration option or the addnode RPC, which have a separate limit of 8 connections. -#maxconnections= - -# Maximum upload bandwidth target in MiB per day (e.g. 'maxuploadtarget=1024' is 1 GiB per day). -# This limits the upload bandwidth for those with bandwidth limits. 0 = no limit (default: 0). -# -maxuploadtarget does not apply to peers with 'download' permission. -# For more information on reducing bandwidth utilization, see: doc/reduce-traffic.md. -#maxuploadtarget= - -# -# JSON-RPC options (for controlling a running Dash/dashd process) -# - -# server=1 tells Dash-Qt and dashd to accept JSON-RPC commands -#server=0 - -# Bind to given address to listen for JSON-RPC connections. -# Refer to the manpage or dashd -help for further details. -#rpcbind= - -# If no rpcpassword is set, rpc cookie auth is sought. The default `-rpccookiefile` name -# is .cookie and found in the `-datadir` being used for dashd. This option is typically used -# when the server and client are run as the same user. -# -# If not, you must set rpcuser and rpcpassword to secure the JSON-RPC API. -# -# The config option `rpcauth` can be added to server startup argument. It is set at initialization time -# using the output from the script in share/rpcauth/rpcauth.py after providing a username: -# -# ./share/rpcauth/rpcauth.py alice -# String to be appended to dash.conf: -# rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae -# Your password: -# DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E= -# -# On client-side, you add the normal user/password pair to send commands: -#rpcuser=alice -#rpcpassword=DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E= -# -# You can even add multiple entries of these to the server conf file, and client can use any of them: -# rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99 - -# How many seconds Dash Core will wait for a complete RPC HTTP request. -# after the HTTP connection is established. -#rpcclienttimeout=30 - -# By default, only RPC connections from localhost are allowed. -# Specify as many rpcallowip= settings as you like to allow connections from other hosts, -# either as a single IPv4/IPv6 or with a subnet specification. - -# NOTE: opening up the RPC port to hosts outside your local trusted network is NOT RECOMMENDED, -# because the rpcpassword is transmitted over the network unencrypted. - -# server=1 tells Dash-Qt to accept JSON-RPC commands. -# it is also read by dashd to determine if RPC should be enabled -#rpcallowip=10.1.1.34/255.255.255.0 -#rpcallowip=1.2.3.4/24 -#rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96 - -# Listen for RPC connections on this TCP port: -#rpcport=9998 - -# You can use Dash or dashd to send commands to Dash/dashd -# running on another host using this option: -#rpcconnect=127.0.0.1 - -# Wallet options - -# Specify where to find wallet, lockfile and logs. If not present, those files will be -# created as new. -#wallet= - -# Create transactions that have enough fees so they are likely to begin confirmation within n blocks (default: 6). -# This setting is over-ridden by the -paytxfee option. -#txconfirmtarget=n - -# Pay a transaction fee every time you send dash. -#paytxfee=0.000x - -# Miscellaneous options - -# Pre-generate this many public/private key pairs, so wallet backups will be valid for -# both prior transactions and several dozen future transactions. -#keypool=100 - -# Maintain coinstats index used by the gettxoutsetinfo RPC (default: 0). -#coinstatsindex=1 - -# Enable pruning to reduce storage requirements by deleting old blocks. -# This mode is incompatible with -txindex, -coinstatsindex and -rescan. -# 0 = default (no pruning). -# 1 = allows manual pruning via RPC. -# >=945 = target to stay under in MiB. -#prune=945 - -# User interface options - -# Start Dash minimized -#min=1 - -# Minimize to the system tray -#minimizetotray=1 - -# [Sections] -# Most options apply to mainnet, testnet and regtest. -# If you want to confine an option to just one network, you should add it in the -# relevant section below. -# EXCEPTIONS: The options addnode, connect, port, bind, rpcport, rpcbind and wallet -# only apply to mainnet unless they appear in the appropriate section below. - -# Options only for mainnet -[main] - -# Options only for testnet -[test] - -# Options only for regtest -[regtest] +# This is a placeholder file. Please follow the instructions in `contrib/devtools/README.md` to generate a dash.conf file. diff --git a/contrib/devtools/README.md b/contrib/devtools/README.md index 4aadde68ab4bb..31cc1f032c777 100644 --- a/contrib/devtools/README.md +++ b/contrib/devtools/README.md @@ -90,6 +90,21 @@ example: BUILDDIR=$PWD/build contrib/devtools/gen-manpages.py ``` +gen-dash-conf.sh +=================== + +Generates a dash.conf file in `contrib/debian/examples/` by parsing the output from `dashd --help`. This script is run during the +release process to include a dash.conf with the release binaries and can also be run by users to generate a file locally. +When generating a file as part of the release process, make sure to commit the changes after running the script. + +With in-tree builds this tool can be run from any directory within the +repository. To use this tool with out-of-tree builds set `BUILDDIR`. For +example: + +```bash +BUILDDIR=$PWD/build contrib/devtools/gen-dash-conf.sh +``` + github-merge.py =============== diff --git a/contrib/devtools/gen-dash-conf.sh b/contrib/devtools/gen-dash-conf.sh new file mode 100755 index 0000000000000..ebc93daf75a8f --- /dev/null +++ b/contrib/devtools/gen-dash-conf.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# Copyright (c) 2021 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +export LC_ALL=C +TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)} +BUILDDIR=${BUILDDIR:-$TOPDIR} +BINDIR=${BINDIR:-$BUILDDIR/src} +DASHD=${DASHD:-$BINDIR/dashd} +SHARE_EXAMPLES_DIR=${SHARE_EXAMPLES_DIR:-$TOPDIR/contrib/debian/examples/} +EXAMPLE_CONF_FILE=${EXAMPLE_CONF_FILE:-$SHARE_EXAMPLES_DIR/dash.conf} + +[ ! -x "$DASHD" ] && echo "$DASHD not found or not executable." && exit 1 + +DIRTY="" +VERSION_OUTPUT=$($DASHD --version) +if [[ $VERSION_OUTPUT == *"dirty"* ]]; then + DIRTY="${DIRTY}${DASHD}\n" +fi + +if [ -n "$DIRTY" ] +then + echo -e "WARNING: $DASHD was built from a dirty tree.\n" + echo -e "To safely generate a dash.conf file, please commit your changes to $DASHD, rebuild, then run this script again.\n" +fi + +echo 'Generating example dash.conf file in contrib/debian/examples/' + +# create the directory, if it doesn't exist +mkdir -p "${SHARE_EXAMPLES_DIR}" + +# create the header text +cat > "${EXAMPLE_CONF_FILE}" << 'EOF' +## +## dash.conf configuration file. +## Generated by contrib/devtools/gen-dash-conf.sh. +## +## Lines beginning with # are comments. +## All possible configuration options are provided. To use, copy this file +## to your data directory (default or specified by -datadir), uncomment +## options you would like to change, and save the file. +## + + +### Options +EOF + +# parse the output from dashd --help +# adding newlines is a bit funky to ensure portability for BSD +# see here for more details: https://stackoverflow.com/a/24575385 +${DASHD} --help \ + | sed '1,/Print this help message and exit/d' \ + | sed -E 's/^[[:space:]]{2}\-/#/' \ + | sed -E 's/^[[:space:]]{7}/# /' \ + | sed -E '/[=[:space:]]/!s/#.*$/&=1/' \ + | awk '/^#[a-z]/{x=$0;next}{if (NF==0) print x"\n",x="";else print}' \ + | sed 's,\(^[[:upper:]].*\)\:$,\ +### \1,' \ + | sed 's/[[:space:]]*$//' >> "${EXAMPLE_CONF_FILE}" + +# create the footer text +cat >> "${EXAMPLE_CONF_FILE}" << 'EOF' + +# [Sections] +# Most options will apply to all networks. To confine an option to a specific +# network, add it under the relevant section below. +# +# Note: If not specified under a network section, the options addnode, connect, +# port, bind, rpcport, rpcbind, and wallet will only apply to mainnet. + +# Options for mainnet +[main] + +# Options for testnet +[test] + +# Options for regtest +[regtest] +EOF diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index 1bb910b7cc4a3..8f9a0fdcc25b2 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -355,6 +355,10 @@ mkdir -p "$DISTSRC" ;; esac + # copy over the example dash.conf file. if contrib/devtools/gen-dash-conf.sh + # has not been run before buildling, this file will be a stub + cp "${DISTSRC}/contrib/debian/examples/dash.conf" "${DISTNAME}/" + # Finally, deterministically produce {non-,}debug binary tarballs ready # for release case "$HOST" in diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md index 8ebcb68ed24b1..0b5ebb1453c8d 100644 --- a/doc/build-openbsd.md +++ b/doc/build-openbsd.md @@ -11,7 +11,7 @@ Run the following as root to install the base dependencies for building. ```bash pkg_add bash git gmake gmp libevent libtool boost -# Select the newest version of the follow packages: +# Select the newest version of the following packages: pkg_add autoconf automake python git clone https://github.com/dashpay/dash.git diff --git a/doc/dash-conf.md b/doc/dash-conf.md index 13fa0ab708893..3d1c9580948d6 100644 --- a/doc/dash-conf.md +++ b/doc/dash-conf.md @@ -63,4 +63,12 @@ Windows | `%APPDATA%\DashCore\` | `C:\Users\username\AppData\Roaming\DashCore\da Linux | `$HOME/.dashcore/` | `/home/username/.dashcore/dash.conf` macOS | `$HOME/Library/Application Support/DashCore/` | `/Users/username/Library/Application Support/DashCore/dash.conf` -You can find an example dash.conf file in [share/examples/dash.conf](../share/examples/dash.conf). +An example configuration file can be generated by [contrib/devtools/gen-dash-conf.sh](../contrib/devtools/gen-dash-conf.sh). +Run this script after compiling to generate an up-to-date configuration file. +The output is placed under `contrib/debian/examples/dash.conf`. +To use the generated configuration file, copy the example file into your data directory and edit it there, like so: + +``` +# example copy command for linux user +cp contrib/debian/examples/dash.conf ~/.dashcore +``` diff --git a/doc/policy/packages.md b/doc/policy/packages.md index 1e2ddbd82f964..aa720050588ca 100644 --- a/doc/policy/packages.md +++ b/doc/policy/packages.md @@ -60,3 +60,40 @@ test accepts): - *Rationale*: We want to prevent potential censorship vectors. We should not reject entire packages because we already have one of the transactions. Also, if an attacker first broadcasts a competing package, the honest package should still be considered for acceptance. + +### Package Fees and Feerate + +*Package Feerate* is the total modified fees (base fees + any fee delta from +`prioritisetransaction`) divided by the total size of all transactions in the package. +If any transactions in the package are already in the mempool, they are not submitted again +("deduplicated") and are thus excluded from this calculation. + +To meet the two feerate requirements of a mempool, i.e., the pre-configured minimum relay feerate +(`minRelayTxFee`) and the dynamic mempool minimum feerate, the total package feerate is used instead +of the individual feerate. The individual transactions are allowed to be below the feerate +requirements if the package meets the feerate requirements. For example, the parent(s) in the +package can pay no fees but be paid for by the child. + +*Rationale*: This can be thought of as "CPFP within a package," solving the issue of a parent not +meeting minimum fees on its own. This would allow contracting applications to adjust their fees at +broadcast time instead of overshooting or risking becoming stuck or pinned. + +*Rationale*: It would be incorrect to use the fees of transactions that are already in the mempool, as +we do not want a transaction's fees to be double-counted. + +Implementation Note: Transactions within a package are always validated individually first, and +package validation is used for the transactions that failed. Since package feerate is only +calculated using transactions that are not in the mempool, this implementation detail affects the +outcome of package validation. + +*Rationale*: We must not allow a low-feerate child to prevent its parent from being accepted; fees +of children should not negatively impact their parents, since they are not necessary for the parents +to be mined. More generally, if transaction B is not needed in order for transaction A to be mined, +B's fees cannot harm A. In a child-with-parents package, simply validating parents individually +first is sufficient to ensure this. + +*Rationale*: As a principle, we want to avoid accidentally restricting policy in order to be +backward-compatible for users and applications that rely on p2p transaction relay. Concretely, +package validation should not prevent the acceptance of a transaction that would otherwise be +policy-valid on its own. By always accepting a transaction that passes individual validation before +trying package validation, we prevent any unintentional restriction of policy. diff --git a/doc/release-process.md b/doc/release-process.md index 2390badea11f5..8460869291948 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -1,8 +1,9 @@ Release Process ==================== -* [ ] Update translations, see [translation_process.md](https://github.com/dashpay/dash/blob/master/doc/translation_process.md#synchronising-translations). -* [ ] Update manpages (after rebuilding the binaries), see [gen-manpages.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/README.md#gen-manpagespy). +* [ ] Update translations, see [translation_process.md](https://github.com/dashpay/dash/blob/develop/doc/translation_process.md#synchronising-translations). +* [ ] Update manpages (after rebuilding the binaries), see [gen-manpages.py](https://github.com/dashpay/dash/blob/develop/contrib/devtools/README.md#gen-manpagespy). +* [ ] Update dash.conf and commit, see [gen-dash-conf.sh](https://github.com/dashpay/dash/blob/develop/contrib/devtools/README.md#gen-dash-confsh). Before every minor and major release: diff --git a/src/Makefile.am b/src/Makefile.am index 9ad66b87a276d..cacc53d622ec7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -345,6 +345,7 @@ BITCOIN_CORE_H = \ scheduler.h \ script/descriptor.h \ script/keyorigin.h \ + script/miniscript.h \ script/sigcache.h \ script/sign.h \ script/signingprovider.h \ @@ -923,6 +924,7 @@ libbitcoin_common_a_SOURCES = \ saltedhasher.cpp \ scheduler.cpp \ script/descriptor.cpp \ + script/miniscript.cpp \ script/sign.cpp \ script/signingprovider.cpp \ script/standard.cpp \ diff --git a/src/Makefile.test.include b/src/Makefile.test.include index b05116eaee526..d4107750889d6 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -145,6 +145,7 @@ BITCOIN_TESTS =\ test/mempool_tests.cpp \ test/merkle_tests.cpp \ test/merkleblock_tests.cpp \ + test/miniscript_tests.cpp \ test/minisketch_tests.cpp \ test/miner_tests.cpp \ test/multisig_tests.cpp \ @@ -320,6 +321,7 @@ test_fuzz_fuzz_SOURCES = \ test/fuzz/locale.cpp \ test/fuzz/merkleblock.cpp \ test/fuzz/message.cpp \ + test/fuzz/miniscript_decode.cpp \ test/fuzz/minisketch.cpp \ test/fuzz/muhash.cpp \ test/fuzz/multiplication_overflow.cpp \ diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 22c1be063a8b0..46cb1041c23e9 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -4,7 +4,6 @@ #include -#include #include #include #include @@ -12,7 +11,6 @@ #include #include #include -#include #include #include @@ -21,6 +19,7 @@ #include #include #include +#include /** WWW-Authenticate to present with 401 Unauthorized response */ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\""; @@ -288,12 +287,14 @@ static bool InitRPCAuthentication() 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","") != "") - { + if (gArgs.GetArg("-rpcauth", "") != "") { LogPrintf("Using rpcauth authentication.\n"); for (const std::string& rpcauth : gArgs.GetArgs("-rpcauth")) { - std::vector fields = SplitString(rpcauth, ":$"); - if (fields.size() == 3) { + std::vector fields{SplitString(rpcauth, ':')}; + const std::vector salt_hmac{SplitString(fields.back(), '$')}; + if (fields.size() == 2 && salt_hmac.size() == 2) { + fields.pop_back(); + fields.insert(fields.end(), salt_hmac.begin(), salt_hmac.end()); g_rpcauth.push_back(fields); } else { LogPrintf("Invalid -rpcauth argument.\n"); diff --git a/src/init.cpp b/src/init.cpp index e8028aa0a3548..1b2a4072de054 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -520,7 +520,7 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-chainlocknotify=", "Execute command when the best chainlock changes (%s in cmd is replaced by chainlocked block hash)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); #endif argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - argsman.AddArg("-conf=", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-conf=", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-datadir=", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); argsman.AddArg("-dbcache=", strprintf("Maximum database cache size MiB (%d to %d, default: %d). In addition, unused mempool memory is shared for this cache (see -maxmempool).", nMinDbCache, nMaxDbCache, nDefaultDbCache), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); diff --git a/src/masternode/node.h b/src/masternode/node.h index 931233c42f72f..5e4d94bc352a9 100644 --- a/src/masternode/node.h +++ b/src/masternode/node.h @@ -11,6 +11,7 @@ #include #include +class CConnman; class CDeterministicMNManager; struct CActiveMasternodeInfo { diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp index 555cef21a831c..4e751f9de2d2c 100644 --- a/src/node/chainstate.cpp +++ b/src/node/chainstate.cpp @@ -148,9 +148,9 @@ std::optional LoadChainstate(bool fReset, for (CChainState* chainstate : chainman.GetAll()) { chainstate->InitCoinsDB( - /* cache_size_bytes */ nCoinDBCache, - /* in_memory */ coins_db_in_memory, - /* should_wipe */ fReset || fReindexChainState); + /*cache_size_bytes=*/nCoinDBCache, + /*in_memory=*/coins_db_in_memory, + /*should_wipe=*/fReset || fReindexChainState); if (coins_error_cb) { chainstate->CoinsErrorCatcher().AddReadErrCallback(coins_error_cb); diff --git a/src/node/miner.h b/src/node/miner.h index 188416d3ff44b..eea4d69884bd2 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -135,7 +135,7 @@ struct update_for_parent_inclusion void operator() (CTxMemPoolModifiedEntry &e) { - e.nModFeesWithAncestors -= iter->GetFee(); + e.nModFeesWithAncestors -= iter->GetModifiedFee(); e.nSizeWithAncestors -= iter->GetTxSize(); e.nSigOpCountWithAncestors -= iter->GetSigOpCount(); } diff --git a/src/rest.cpp b/src/rest.cpp index e58a650689f6e..5b6222724572a 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -691,7 +691,7 @@ static bool rest_tx(const CoreContext& context, HTTPRequest* req, const std::str const NodeContext* const node = GetNodeContext(context, req); if (!node) return false; uint256 hashBlock = uint256(); - const CTransactionRef tx = GetTransaction(/* block_index */ nullptr, node->mempool.get(), hash, Params().GetConsensus(), hashBlock); + const CTransactionRef tx = GetTransaction(/*block_index=*/nullptr, node->mempool.get(), hash, Params().GetConsensus(), hashBlock); if (!tx) { return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 90ee7464c17ea..60d7ddd101049 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -375,7 +375,7 @@ struct Sections { if (arg.m_type_str.size() != 0 && push_name) { left += "\"" + arg.GetName() + "\": " + arg.m_type_str.at(0); } else { - left += push_name ? arg.ToStringObj(/* oneline */ false) : arg.ToString(/* oneline */ false); + left += push_name ? arg.ToStringObj(/*oneline=*/false) : arg.ToString(/*oneline=*/false); } left += ","; PushSection({left, arg.ToDescriptionString()}); @@ -578,7 +578,7 @@ std::string RPCHelpMan::ToString() const if (was_optional) ret += ") "; was_optional = false; } - ret += arg.ToString(/* oneline */ true); + ret += arg.ToString(/*oneline=*/true); } if (was_optional) ret += " )"; diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 0d7f63a82a644..7d2c42f2fe6ac 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -221,31 +221,6 @@ bool static CheckPubKeyEncoding(const valtype &vchPubKey, unsigned int flags, co return true; } -bool CheckMinimalPush(const valtype& data, opcodetype opcode) { - // Excludes OP_1NEGATE, OP_1-16 since they are by definition minimal - assert(0 <= opcode && opcode <= OP_PUSHDATA4); - if (data.size() == 0) { - // Should have used OP_0. - return opcode == OP_0; - } else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) { - // Should have used OP_1 .. OP_16. - return false; - } else if (data.size() == 1 && data[0] == 0x81) { - // Should have used OP_1NEGATE. - return false; - } else if (data.size() <= 75) { - // Must have used a direct push (opcode indicating number of bytes pushed + those bytes). - return opcode == data.size(); - } else if (data.size() <= 255) { - // Must have used OP_PUSHDATA. - return opcode == OP_PUSHDATA1; - } else if (data.size() <= 65535) { - // Must have used OP_PUSHDATA2. - return opcode == OP_PUSHDATA2; - } - return true; -} - int FindAndDelete(CScript& script, const CScript& b) { int nFound = 0; diff --git a/src/script/interpreter.h b/src/script/interpreter.h index d8809f386c711..f2678e4b748fe 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -214,8 +214,6 @@ class DeferringSignatureChecker : public BaseSignatureChecker bool EvalScript(std::vector >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* error = nullptr); bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* error = nullptr); -bool CheckMinimalPush(const std::vector& data, opcodetype opcode); - int FindAndDelete(CScript& script, const CScript& b); #endif // BITCOIN_SCRIPT_INTERPRETER_H diff --git a/src/script/miniscript.cpp b/src/script/miniscript.cpp new file mode 100644 index 0000000000000..019f02f1594de --- /dev/null +++ b/src/script/miniscript.cpp @@ -0,0 +1,349 @@ +// Copyright (c) 2019 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 +#include +#include