aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/addrdb.cpp4
-rw-r--r--src/addrman.cpp4
-rw-r--r--src/bench/bip324_ecdh.cpp4
-rw-r--r--src/bench/ccoins_caching.cpp3
-rw-r--r--src/bench/checkqueue.cpp3
-rw-r--r--src/bench/descriptors.cpp4
-rw-r--r--src/bench/ellswift.cpp4
-rw-r--r--src/bench/verify_script.cpp3
-rw-r--r--src/bench/wallet_create.cpp9
-rw-r--r--src/bench/wallet_ismine.cpp4
-rw-r--r--src/bench/wallet_loading.cpp4
-rw-r--r--src/bitcoin-chainstate.cpp1
-rw-r--r--src/bitcoin-cli.cpp4
-rw-r--r--src/bitcoin-tx.cpp23
-rw-r--r--src/bitcoin-util.cpp4
-rw-r--r--src/bitcoin-wallet.cpp7
-rw-r--r--src/bitcoind.cpp7
-rw-r--r--src/clientversion.cpp4
-rw-r--r--src/clientversion.h4
-rw-r--r--src/common/run_command.cpp4
-rw-r--r--src/common/settings.cpp4
-rw-r--r--src/common/system.cpp4
-rw-r--r--src/common/system.h4
-rw-r--r--src/crypto/sha256.cpp4
-rw-r--r--src/httpserver.cpp4
-rw-r--r--src/init.cpp24
-rw-r--r--src/init/common.cpp4
-rw-r--r--src/kernel/checks.cpp6
-rw-r--r--src/kernel/context.cpp7
-rw-r--r--src/kernel/context.h5
-rw-r--r--src/key.cpp16
-rw-r--r--src/key.h20
-rw-r--r--src/mapport.cpp4
-rw-r--r--src/net.cpp7
-rw-r--r--src/net.h3
-rw-r--r--src/net_processing.cpp173
-rw-r--r--src/netbase.cpp4
-rw-r--r--src/node/context.cpp2
-rw-r--r--src/node/context.h11
-rw-r--r--src/node/interfaces.cpp9
-rw-r--r--src/node/kernel_notifications.cpp5
-rw-r--r--src/outputtype.cpp2
-rw-r--r--src/policy/packages.cpp5
-rw-r--r--src/policy/policy.cpp2
-rw-r--r--src/qt/bitcoin.cpp4
-rw-r--r--src/qt/bitcoin.h4
-rw-r--r--src/qt/bitcoingui.cpp4
-rw-r--r--src/qt/bitcoingui.h4
-rw-r--r--src/qt/clientmodel.cpp4
-rw-r--r--src/qt/createwalletdialog.cpp4
-rw-r--r--src/qt/forms/debugwindow.ui2
-rw-r--r--src/qt/forms/signverifymessagedialog.ui2
-rw-r--r--src/qt/guiutil.cpp4
-rw-r--r--src/qt/intro.cpp4
-rw-r--r--src/qt/modaloverlay.cpp4
-rw-r--r--src/qt/notificator.cpp4
-rw-r--r--src/qt/notificator.h4
-rw-r--r--src/qt/optionsdialog.cpp10
-rw-r--r--src/qt/optionsmodel.cpp4
-rw-r--r--src/qt/qrimagewidget.cpp4
-rw-r--r--src/qt/receiverequestdialog.cpp4
-rw-r--r--src/qt/rpcconsole.cpp4
-rw-r--r--src/qt/rpcconsole.h4
-rw-r--r--src/qt/sendcoinsdialog.cpp4
-rw-r--r--src/qt/signverifymessagedialog.cpp8
-rw-r--r--src/qt/splashscreen.cpp4
-rw-r--r--src/qt/test/optiontests.cpp4
-rw-r--r--src/qt/test/test_main.cpp4
-rw-r--r--src/qt/utilitydialog.cpp6
-rw-r--r--src/qt/walletmodel.cpp13
-rw-r--r--src/random.cpp4
-rw-r--r--src/randomenv.cpp4
-rw-r--r--src/rest.cpp4
-rw-r--r--src/rpc/blockchain.cpp12
-rw-r--r--src/rpc/external_signer.cpp4
-rw-r--r--src/rpc/mempool.cpp19
-rw-r--r--src/rpc/mining.cpp17
-rw-r--r--src/rpc/net.cpp12
-rw-r--r--src/rpc/node.cpp4
-rw-r--r--src/rpc/output_script.cpp6
-rw-r--r--src/rpc/register.h4
-rw-r--r--src/rpc/server.cpp4
-rw-r--r--src/rpc/util.cpp28
-rw-r--r--src/rpc/util.h2
-rw-r--r--src/script/miniscript.cpp3
-rw-r--r--src/script/miniscript.h24
-rw-r--r--src/test/fuzz/bip324.cpp2
-rw-r--r--src/test/fuzz/descriptor_parse.cpp2
-rw-r--r--src/test/fuzz/key.cpp2
-rw-r--r--src/test/fuzz/key_io.cpp2
-rw-r--r--src/test/fuzz/message.cpp2
-rw-r--r--src/test/fuzz/miniscript.cpp44
-rw-r--r--src/test/fuzz/p2p_transport_serialization.cpp2
-rw-r--r--src/test/fuzz/poolresource.cpp4
-rw-r--r--src/test/fuzz/script_sign.cpp2
-rw-r--r--src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp3
-rw-r--r--src/test/fuzz/tx_pool.cpp2
-rw-r--r--src/test/streams_tests.cpp4
-rw-r--r--src/test/system_tests.cpp4
-rw-r--r--src/test/util/setup_common.cpp6
-rw-r--r--src/test/util/setup_common.h2
-rw-r--r--src/test/util/txmempool.cpp6
-rw-r--r--src/test/util_threadnames_tests.cpp4
-rw-r--r--src/test/validation_chainstate_tests.cpp7
-rw-r--r--src/txorphanage.cpp4
-rw-r--r--src/util/check.cpp4
-rw-r--r--src/util/fs_helpers.cpp4
-rw-r--r--src/util/subprocess.h174
-rw-r--r--src/util/syserror.cpp4
-rw-r--r--src/util/threadnames.cpp4
-rw-r--r--src/util/tokenpipe.cpp4
-rw-r--r--src/util/trace.h4
-rw-r--r--src/validation.cpp4
-rw-r--r--src/validation.h3
-rw-r--r--src/wallet/init.cpp4
-rw-r--r--src/wallet/rpc/addresses.cpp4
-rw-r--r--src/wallet/rpc/backup.cpp21
-rw-r--r--src/wallet/rpc/spend.cpp10
-rw-r--r--src/wallet/rpc/wallet.cpp4
-rw-r--r--src/wallet/sqlite.cpp4
-rw-r--r--src/wallet/test/db_tests.cpp4
-rw-r--r--src/wallet/test/util.h4
-rw-r--r--src/wallet/wallet.cpp4
-rw-r--r--src/wallet/walletdb.cpp4
-rw-r--r--src/wallet/wallettool.cpp4
-rw-r--r--src/warnings.cpp28
-rw-r--r--src/warnings.h10
128 files changed, 426 insertions, 694 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 639aecf3b3..669bf40362 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -945,7 +945,6 @@ libbitcoinkernel_la_SOURCES = \
kernel/disconnected_transactions.cpp \
kernel/mempool_persist.cpp \
kernel/mempool_removal_reason.cpp \
- key.cpp \
logging.cpp \
node/blockstorage.cpp \
node/chainstate.cpp \
diff --git a/src/addrdb.cpp b/src/addrdb.cpp
index 14dc314c36..4d34c24ba9 100644
--- a/src/addrdb.cpp
+++ b/src/addrdb.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addrdb.h>
diff --git a/src/addrman.cpp b/src/addrman.cpp
index ef8ed92bb5..eb9c372550 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addrman.h>
#include <addrman_impl.h>
diff --git a/src/bench/bip324_ecdh.cpp b/src/bench/bip324_ecdh.cpp
index fb10c2957e..88f3932ad8 100644
--- a/src/bench/bip324_ecdh.cpp
+++ b/src/bench/bip324_ecdh.cpp
@@ -14,7 +14,7 @@
static void BIP324_ECDH(benchmark::Bench& bench)
{
- ECC_Start();
+ ECC_Context ecc_context{};
FastRandomContext rng;
std::array<std::byte, 32> key_data;
@@ -44,8 +44,6 @@ static void BIP324_ECDH(benchmark::Bench& bench)
// - Copy 16 bytes from the resulting shared secret into the middle of their ellswift key.
std::copy(ret.begin() + 16, ret.end(), their_ellswift_data.begin() + 24);
});
-
- ECC_Stop();
}
BENCHMARK(BIP324_ECDH, benchmark::PriorityLevel::HIGH);
diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp
index 4a3ec67c2b..05b2f5435c 100644
--- a/src/bench/ccoins_caching.cpp
+++ b/src/bench/ccoins_caching.cpp
@@ -18,7 +18,7 @@
// (https://github.com/bitcoin/bitcoin/issues/7883#issuecomment-224807484)
static void CCoinsCaching(benchmark::Bench& bench)
{
- ECC_Start();
+ ECC_Context ecc_context{};
FillableSigningProvider keystore;
CCoinsView coinsDummy;
@@ -47,7 +47,6 @@ static void CCoinsCaching(benchmark::Bench& bench)
bool success{AreInputsStandard(tx_1, coins)};
assert(success);
});
- ECC_Stop();
}
BENCHMARK(CCoinsCaching, benchmark::PriorityLevel::HIGH);
diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp
index 114dd9d39c..c973fe9f71 100644
--- a/src/bench/checkqueue.cpp
+++ b/src/bench/checkqueue.cpp
@@ -25,7 +25,7 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
// We shouldn't ever be running with the checkqueue on a single core machine.
if (GetNumCores() <= 1) return;
- ECC_Start();
+ ECC_Context ecc_context{};
struct PrevectorJob {
prevector<PREVECTOR_SIZE, uint8_t> p;
@@ -62,6 +62,5 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
// it is done explicitly here for clarity
control.Wait();
});
- ECC_Stop();
}
BENCHMARK(CCheckQueueSpeedPrevectorJob, benchmark::PriorityLevel::HIGH);
diff --git a/src/bench/descriptors.cpp b/src/bench/descriptors.cpp
index fbef1395fb..5d6bcb8ce8 100644
--- a/src/bench/descriptors.cpp
+++ b/src/bench/descriptors.cpp
@@ -12,7 +12,7 @@
static void ExpandDescriptor(benchmark::Bench& bench)
{
- ECC_Start();
+ ECC_Context ecc_context{};
const auto desc_str = "sh(wsh(multi(16,03669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0,0260b2003c386519fc9eadf2b5cf124dd8eea4c4e68d5e154050a9346ea98ce600,0362a74e399c39ed5593852a30147f2959b56bb827dfa3e60e464b02ccf87dc5e8,0261345b53de74a4d721ef877c255429961b7e43714171ac06168d7e08c542a8b8,02da72e8b46901a65d4374fe6315538d8f368557dda3a1dcf9ea903f3afe7314c8,0318c82dd0b53fd3a932d16e0ba9e278fcc937c582d5781be626ff16e201f72286,0297ccef1ef99f9d73dec9ad37476ddb232f1238aff877af19e72ba04493361009,02e502cfd5c3f972fe9a3e2a18827820638f96b6f347e54d63deb839011fd5765d,03e687710f0e3ebe81c1037074da939d409c0025f17eb86adb9427d28f0f7ae0e9,02c04d3a5274952acdbc76987f3184b346a483d43be40874624b29e3692c1df5af,02ed06e0f418b5b43a7ec01d1d7d27290fa15f75771cb69b642a51471c29c84acd,036d46073cbb9ffee90473f3da429abc8de7f8751199da44485682a989a4bebb24,02f5d1ff7c9029a80a4e36b9a5497027ef7f3e73384a4a94fbfe7c4e9164eec8bc,02e41deffd1b7cce11cde209a781adcffdabd1b91c0ba0375857a2bfd9302419f3,02d76625f7956a7fc505ab02556c23ee72d832f1bac391bcd2d3abce5710a13d06,0399eb0a5487515802dc14544cf10b3666623762fbed2ec38a3975716e2c29c232)))";
const std::pair<int64_t, int64_t> range = {0, 1000};
@@ -27,8 +27,6 @@ static void ExpandDescriptor(benchmark::Bench& bench)
assert(success);
}
});
-
- ECC_Stop();
}
BENCHMARK(ExpandDescriptor, benchmark::PriorityLevel::HIGH);
diff --git a/src/bench/ellswift.cpp b/src/bench/ellswift.cpp
index 9441b4863e..4780db8e1c 100644
--- a/src/bench/ellswift.cpp
+++ b/src/bench/ellswift.cpp
@@ -9,7 +9,7 @@
static void EllSwiftCreate(benchmark::Bench& bench)
{
- ECC_Start();
+ ECC_Context ecc_context{};
CKey key = GenerateRandomKey();
uint256 entropy = GetRandHash();
@@ -22,8 +22,6 @@ static void EllSwiftCreate(benchmark::Bench& bench)
/* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
std::copy(ret.begin() + 32, ret.begin() + 64, MakeWritableByteSpan(entropy).begin());
});
-
- ECC_Stop();
}
BENCHMARK(EllSwiftCreate, benchmark::PriorityLevel::HIGH);
diff --git a/src/bench/verify_script.cpp b/src/bench/verify_script.cpp
index ee750bc1f8..f38aa49a23 100644
--- a/src/bench/verify_script.cpp
+++ b/src/bench/verify_script.cpp
@@ -15,7 +15,7 @@
// modified to measure performance of other types of scripts.
static void VerifyScriptBench(benchmark::Bench& bench)
{
- ECC_Start();
+ ECC_Context ecc_context{};
const uint32_t flags{SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH};
const int witnessversion = 0;
@@ -57,7 +57,6 @@ static void VerifyScriptBench(benchmark::Bench& bench)
assert(err == SCRIPT_ERR_OK);
assert(success);
});
- ECC_Stop();
}
static void VerifyNestedIfScript(benchmark::Bench& bench)
diff --git a/src/bench/wallet_create.cpp b/src/bench/wallet_create.cpp
index 32f55f51e1..618d5bc80c 100644
--- a/src/bench/wallet_create.cpp
+++ b/src/bench/wallet_create.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <bench/bench.h>
#include <node/context.h>
@@ -51,9 +49,14 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }
static void WalletCreateEncrypted(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/true); }
+#ifndef _MSC_VER
+// TODO: Being built with MSVC, the fs::remove_all() call in
+// the WalletCreate() fails with the error "The process cannot
+// access the file because it is being used by another process."
#ifdef USE_SQLITE
BENCHMARK(WalletCreatePlain, benchmark::PriorityLevel::LOW);
BENCHMARK(WalletCreateEncrypted, benchmark::PriorityLevel::LOW);
#endif
+#endif
} // namespace wallet
diff --git a/src/bench/wallet_ismine.cpp b/src/bench/wallet_ismine.cpp
index 3f922e18a5..753404b526 100644
--- a/src/bench/wallet_ismine.cpp
+++ b/src/bench/wallet_ismine.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif // HAVE_CONFIG_H
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <bench/bench.h>
#include <interfaces/chain.h>
#include <key.h>
diff --git a/src/bench/wallet_loading.cpp b/src/bench/wallet_loading.cpp
index 6305126c7d..02582deda4 100644
--- a/src/bench/wallet_loading.cpp
+++ b/src/bench/wallet_loading.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <bench/bench.h>
#include <interfaces/chain.h>
diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index 642af06e82..4927634233 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -26,6 +26,7 @@
#include <script/sigcache.h>
#include <util/chaintype.h>
#include <util/fs.h>
+#include <util/signalinterrupt.h>
#include <util/task_runner.h>
#include <validation.h>
#include <validationinterface.h>
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 8901d10ef6..c7ba2204c3 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparamsbase.h>
#include <clientversion.h>
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index 320624c419..cfac50e090 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparamsbase.h>
#include <clientversion.h>
@@ -694,21 +692,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
tx = mergedTx;
}
-class Secp256k1Init
-{
-public:
- Secp256k1Init() {
- ECC_Start();
- }
- ~Secp256k1Init() {
- ECC_Stop();
- }
-};
-
static void MutateTx(CMutableTransaction& tx, const std::string& command,
const std::string& commandVal)
{
- std::unique_ptr<Secp256k1Init> ecc;
+ std::unique_ptr<ECC_Context> ecc;
if (command == "nversion")
MutateTxVersion(tx, commandVal);
@@ -728,10 +715,10 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
else if (command == "outaddr")
MutateTxAddOutAddr(tx, commandVal);
else if (command == "outpubkey") {
- ecc.reset(new Secp256k1Init());
+ ecc.reset(new ECC_Context());
MutateTxAddOutPubKey(tx, commandVal);
} else if (command == "outmultisig") {
- ecc.reset(new Secp256k1Init());
+ ecc.reset(new ECC_Context());
MutateTxAddOutMultiSig(tx, commandVal);
} else if (command == "outscript")
MutateTxAddOutScript(tx, commandVal);
@@ -739,7 +726,7 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
MutateTxAddOutData(tx, commandVal);
else if (command == "sign") {
- ecc.reset(new Secp256k1Init());
+ ecc.reset(new ECC_Context());
MutateTxSign(tx, commandVal);
}
diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp
index 96387e8c71..c8f5bc5026 100644
--- a/src/bitcoin-util.cpp
+++ b/src/bitcoin-util.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <arith_uint256.h>
#include <chain.h>
diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp
index fe90958a5f..e6d20b55c2 100644
--- a/src/bitcoin-wallet.cpp
+++ b/src/bitcoin-wallet.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <chainparamsbase.h>
@@ -130,10 +128,9 @@ MAIN_FUNCTION
return EXIT_FAILURE;
}
- ECC_Start();
+ ECC_Context ecc_context{};
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
return EXIT_FAILURE;
}
- ECC_Stop();
return EXIT_SUCCESS;
}
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 54796c5abb..0b89aa42af 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <clientversion.h>
@@ -16,11 +14,13 @@
#include <init.h>
#include <interfaces/chain.h>
#include <interfaces/init.h>
+#include <kernel/context.h>
#include <node/context.h>
#include <node/interface_ui.h>
#include <noui.h>
#include <util/check.h>
#include <util/exception.h>
+#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/syserror.h>
#include <util/threadnames.h>
@@ -182,6 +182,7 @@ static bool AppInit(NodeContext& node)
}
node.kernel = std::make_unique<kernel::Context>();
+ node.ecc_context = std::make_unique<ECC_Context>();
if (!AppInitSanityChecks(*node.kernel))
{
// InitError will have been called with detailed error, which ends up on console
diff --git a/src/clientversion.cpp b/src/clientversion.cpp
index bf5579ee69..3a5e060a39 100644
--- a/src/clientversion.cpp
+++ b/src/clientversion.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <util/translation.h>
diff --git a/src/clientversion.h b/src/clientversion.h
index 9da0cd0b39..73aaf868e4 100644
--- a/src/clientversion.h
+++ b/src/clientversion.h
@@ -7,9 +7,7 @@
#include <util/macros.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif //HAVE_CONFIG_H
+#include <config/bitcoin-config.h> // IWYU pragma: keep
// Check that required client information is defined
#if !defined(CLIENT_VERSION_MAJOR) || !defined(CLIENT_VERSION_MINOR) || !defined(CLIENT_VERSION_BUILD) || !defined(CLIENT_VERSION_IS_RELEASE) || !defined(COPYRIGHT_YEAR)
diff --git a/src/common/run_command.cpp b/src/common/run_command.cpp
index 347b486095..67608b985f 100644
--- a/src/common/run_command.cpp
+++ b/src/common/run_command.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/run_command.h>
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index db1001111a..c1520dacd2 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -4,9 +4,7 @@
#include <common/settings.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <tinyformat.h>
#include <univalue.h>
diff --git a/src/common/system.cpp b/src/common/system.cpp
index 1fa53a5f34..ddd0feda3b 100644
--- a/src/common/system.cpp
+++ b/src/common/system.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/system.h>
diff --git a/src/common/system.h b/src/common/system.h
index 83280d46ee..d9115d3b33 100644
--- a/src/common/system.h
+++ b/src/common/system.h
@@ -6,9 +6,7 @@
#ifndef BITCOIN_COMMON_SYSTEM_H
#define BITCOIN_COMMON_SYSTEM_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <cstdint>
#include <string>
diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp
index 301f22a248..c883bd2f03 100644
--- a/src/crypto/sha256.cpp
+++ b/src/crypto/sha256.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <crypto/sha256.h>
#include <crypto/common.h>
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 71134d442f..b1d4dc9234 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <httpserver.h>
diff --git a/src/init.cpp b/src/init.cpp
index 4d7638cd6e..ab35a5f392 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <init.h>
@@ -34,6 +32,8 @@
#include <interfaces/chain.h>
#include <interfaces/init.h>
#include <interfaces/node.h>
+#include <kernel/context.h>
+#include <key.h>
#include <logging.h>
#include <mapport.h>
#include <net.h>
@@ -77,6 +77,7 @@
#include <util/fs_helpers.h>
#include <util/moneystr.h>
#include <util/result.h>
+#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/syserror.h>
@@ -373,6 +374,7 @@ void Shutdown(NodeContext& node)
node.chainman.reset();
node.validation_signals.reset();
node.scheduler.reset();
+ node.ecc_context.reset();
node.kernel.reset();
RemovePidFile(*node.args);
@@ -535,9 +537,7 @@ void SetupServerArgs(ArgsManager& argsman)
argsman.AddArg("-peerbloomfilters", strprintf("Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
- // TODO: remove the sentence "Nodes not using ... incoming connections." once the changes from
- // https://github.com/bitcoin/bitcoin/pull/23542 have become widespread.
- argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port>. Nodes not using the default ports (default: %u, testnet: %u, signet: %u, regtest: %u) are unlikely to get incoming connections. Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
+ argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port> (default: %u, testnet: %u, signet: %u, regtest: %u). Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
#if HAVE_SOCKADDR_UN
argsman.AddArg("-proxy=<ip:port|path>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled). May be a local file path prefixed with 'unix:' if the proxy supports it.", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
#else
@@ -634,7 +634,7 @@ void SetupServerArgs(ArgsManager& argsman)
MAX_OP_RETURN_RELAY),
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
argsman.AddArg("-mempoolfullrbf", strprintf("Accept transaction replace-by-fee without requiring replaceability signaling (default: %u)", DEFAULT_MEMPOOL_FULL_RBF), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
- argsman.AddArg("-permitbaremultisig", strprintf("Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
+ argsman.AddArg("-permitbaremultisig", strprintf("Relay transactions creating non-P2SH multisig outputs (default: %u)", DEFAULT_PERMIT_BAREMULTISIG), ArgsManager::ALLOW_ANY,
OptionsCategory::NODE_RELAY);
argsman.AddArg("-minrelaytxfee=<amt>", strprintf("Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
@@ -1086,6 +1086,10 @@ bool AppInitSanityChecks(const kernel::Context& kernel)
return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), PACKAGE_NAME));
}
+ if (!ECC_InitSanityCheck()) {
+ return InitError(strprintf(_("Elliptic curve cryptography sanity check failure. %s is shutting down."), PACKAGE_NAME));
+ }
+
// Probe the data directory lock to give an early error message, if possible
// We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
// and a fork will cause weird behavior to it.
@@ -1297,7 +1301,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
}
- for (const auto &port_option : std::vector<std::pair<std::string, bool>>{
+ for ([[maybe_unused]] const auto& [arg, unix] : std::vector<std::pair<std::string, bool>>{
// arg name UNIX socket support
{"-i2psam", false},
{"-onion", true},
@@ -1309,10 +1313,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
{"-zmqpubhashtx", true},
{"-zmqpubrawblock", true},
{"-zmqpubrawtx", true},
- {"-zmqpubsequence", true}
+ {"-zmqpubsequence", true},
}) {
- const std::string arg{port_option.first};
- const bool unix{port_option.second};
for (const std::string& socket_addr : args.GetArgs(arg)) {
std::string host_out;
uint16_t port_out{0};
diff --git a/src/init/common.cpp b/src/init/common.cpp
index 0800cd93d8..3a6df3e8bd 100644
--- a/src/init/common.cpp
+++ b/src/init/common.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <common/args.h>
diff --git a/src/kernel/checks.cpp b/src/kernel/checks.cpp
index 45a5e25093..e4a13ee4cc 100644
--- a/src/kernel/checks.cpp
+++ b/src/kernel/checks.cpp
@@ -4,8 +4,8 @@
#include <kernel/checks.h>
-#include <key.h>
#include <random.h>
+#include <util/result.h>
#include <util/translation.h>
#include <memory>
@@ -14,10 +14,6 @@ namespace kernel {
util::Result<void> SanityChecks(const Context&)
{
- if (!ECC_InitSanityCheck()) {
- return util::Error{Untranslated("Elliptic curve cryptography sanity check failure. Aborting.")};
- }
-
if (!Random_SanityCheck()) {
return util::Error{Untranslated("OS cryptographic RNG sanity check failure. Aborting.")};
}
diff --git a/src/kernel/context.cpp b/src/kernel/context.cpp
index c60f1638d1..bfb17915fd 100644
--- a/src/kernel/context.cpp
+++ b/src/kernel/context.cpp
@@ -5,9 +5,7 @@
#include <kernel/context.h>
#include <crypto/sha256.h>
-#include <key.h>
#include <logging.h>
-#include <pubkey.h>
#include <random.h>
#include <string>
@@ -19,12 +17,7 @@ Context::Context()
std::string sha256_algo = SHA256AutoDetect();
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
RandomInit();
- ECC_Start();
}
-Context::~Context()
-{
- ECC_Stop();
-}
} // namespace kernel
diff --git a/src/kernel/context.h b/src/kernel/context.h
index ff4df20473..159af12689 100644
--- a/src/kernel/context.h
+++ b/src/kernel/context.h
@@ -5,10 +5,6 @@
#ifndef BITCOIN_KERNEL_CONTEXT_H
#define BITCOIN_KERNEL_CONTEXT_H
-#include <util/signalinterrupt.h>
-
-#include <memory>
-
namespace kernel {
//! Context struct holding the kernel library's logically global state, and
//! passed to external libbitcoin_kernel functions which need access to this
@@ -19,7 +15,6 @@ namespace kernel {
//! should be stored to std::unique_ptr members pointing to opaque types.
struct Context {
Context();
- ~Context();
};
} // namespace kernel
diff --git a/src/key.cpp b/src/key.cpp
index 2bd6396298..e8458f2e3b 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -432,7 +432,8 @@ bool ECC_InitSanityCheck() {
return key.VerifyPubKey(pubkey);
}
-void ECC_Start() {
+/** Initialize the elliptic curve support. May not be called twice without calling ECC_Stop first. */
+static void ECC_Start() {
assert(secp256k1_context_sign == nullptr);
secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
@@ -449,7 +450,8 @@ void ECC_Start() {
secp256k1_context_sign = ctx;
}
-void ECC_Stop() {
+/** Deinitialize the elliptic curve support. No-op if ECC_Start wasn't called first. */
+static void ECC_Stop() {
secp256k1_context *ctx = secp256k1_context_sign;
secp256k1_context_sign = nullptr;
@@ -457,3 +459,13 @@ void ECC_Stop() {
secp256k1_context_destroy(ctx);
}
}
+
+ECC_Context::ECC_Context()
+{
+ ECC_Start();
+}
+
+ECC_Context::~ECC_Context()
+{
+ ECC_Stop();
+}
diff --git a/src/key.h b/src/key.h
index 53acd179ba..36d093b7dc 100644
--- a/src/key.h
+++ b/src/key.h
@@ -236,13 +236,21 @@ struct CExtKey {
void SetSeed(Span<const std::byte> seed);
};
-/** Initialize the elliptic curve support. May not be called twice without calling ECC_Stop first. */
-void ECC_Start();
-
-/** Deinitialize the elliptic curve support. No-op if ECC_Start wasn't called first. */
-void ECC_Stop();
-
/** Check that required EC support is available at runtime. */
bool ECC_InitSanityCheck();
+/**
+ * RAII class initializing and deinitializing global state for elliptic curve support.
+ * Only one instance may be initialized at a time.
+ *
+ * In the future global ECC state could be removed, and this class could contain
+ * state and be passed as an argument to ECC key functions.
+ */
+class ECC_Context
+{
+public:
+ ECC_Context();
+ ~ECC_Context();
+};
+
#endif // BITCOIN_KEY_H
diff --git a/src/mapport.cpp b/src/mapport.cpp
index 08b365db4b..80670230c7 100644
--- a/src/mapport.cpp
+++ b/src/mapport.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <mapport.h>
diff --git a/src/net.cpp b/src/net.cpp
index 1eda98253a..ad1e464667 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <net.h>
@@ -3113,8 +3111,7 @@ void Discover()
{
if (ifa->ifa_addr == nullptr) continue;
if ((ifa->ifa_flags & IFF_UP) == 0) continue;
- if (strcmp(ifa->ifa_name, "lo") == 0) continue;
- if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
+ if ((ifa->ifa_flags & IFF_LOOPBACK) != 0) continue;
if (ifa->ifa_addr->sa_family == AF_INET)
{
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
diff --git a/src/net.h b/src/net.h
index af41988ba0..8075975d62 100644
--- a/src/net.h
+++ b/src/net.h
@@ -137,8 +137,7 @@ struct CSerializedNetMsg {
/**
* Look up IP addresses from all interfaces on the machine and add them to the
* list of local addresses to self-advertise.
- * The loopback interface is skipped and only the first address from each
- * interface is used.
+ * The loopback interface is skipped.
*/
void Discover();
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index bdbf077ab5..5d2949af33 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -118,6 +118,7 @@ static const unsigned int MAX_HEADERS_RESULTS = 2000;
static const int MAX_CMPCTBLOCK_DEPTH = 5;
/** Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for. */
static const int MAX_BLOCKTXN_DEPTH = 10;
+static_assert(MAX_BLOCKTXN_DEPTH <= MIN_BLOCKS_TO_KEEP, "MAX_BLOCKTXN_DEPTH too high");
/** Size of the "block download window": how far ahead of our current height do we fetch?
* Larger windows tolerate larger download speed differences between peer, but increase the potential
* degree of disordering of blocks on disk (which make reindexing and pruning harder). We'll probably
@@ -600,15 +601,6 @@ private:
void ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, const std::list<CTransactionRef>& replaced_transactions)
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
- /** Handle the results of package validation: calls ProcessValidTx and ProcessInvalidTx for
- * individual transactions, and caches rejection for the package as a group.
- * @param[in] senders Must contain the nodeids of the peers that provided each transaction
- * in package, in the same order.
- * */
- void ProcessPackageResult(const Package& package, const PackageMempoolAcceptResult& package_result, const std::vector<NodeId>& senders)
- EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
-
- /** A package to validate */
struct PackageToValidate {
const Package m_txns;
const std::vector<NodeId> m_senders;
@@ -633,6 +625,12 @@ private:
}
};
+ /** Handle the results of package validation: calls ProcessValidTx and ProcessInvalidTx for
+ * individual transactions, and caches rejection for the package as a group.
+ */
+ void ProcessPackageResult(const PackageToValidate& package_to_validate, const PackageMempoolAcceptResult& package_result)
+ EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, g_msgproc_mutex, cs_main);
+
/** Look for a child of this transaction in the orphanage to form a 1-parent-1-child package,
* skipping any combinations that have already been tried. Return the resulting package along with
* the senders of its respective transactions, or std::nullopt if no package is found. */
@@ -2423,38 +2421,48 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
}
}
- LOCK(cs_main);
- const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(inv.hash);
- if (!pindex) {
- return;
- }
- if (!BlockRequestAllowed(pindex)) {
- LogPrint(BCLog::NET, "%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom.GetId());
- return;
- }
- // disconnect node in case we have reached the outbound limit for serving historical blocks
- if (m_connman.OutboundTargetReached(true) &&
- (((m_chainman.m_best_header != nullptr) && (m_chainman.m_best_header->GetBlockTime() - pindex->GetBlockTime() > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk()) &&
- !pfrom.HasPermission(NetPermissionFlags::Download) // nodes with the download permission may exceed target
- ) {
- LogPrint(BCLog::NET, "historical block serving limit reached, disconnect peer=%d\n", pfrom.GetId());
- pfrom.fDisconnect = true;
- return;
- }
- // Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
- if (!pfrom.HasPermission(NetPermissionFlags::NoBan) && (
- (((peer.m_our_services & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((peer.m_our_services & NODE_NETWORK) != NODE_NETWORK) && (m_chainman.ActiveChain().Tip()->nHeight - pindex->nHeight > (int)NODE_NETWORK_LIMITED_MIN_BLOCKS + 2 /* add two blocks buffer extension for possible races */) )
- )) {
- LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold, disconnect peer=%d\n", pfrom.GetId());
- //disconnect node and prevent it from stalling (would otherwise wait for the missing block)
- pfrom.fDisconnect = true;
- return;
- }
- // Pruned nodes may have deleted the block, so check whether
- // it's available before trying to send.
- if (!(pindex->nStatus & BLOCK_HAVE_DATA)) {
- return;
+ const CBlockIndex* pindex{nullptr};
+ const CBlockIndex* tip{nullptr};
+ bool can_direct_fetch{false};
+ FlatFilePos block_pos{};
+ {
+ LOCK(cs_main);
+ pindex = m_chainman.m_blockman.LookupBlockIndex(inv.hash);
+ if (!pindex) {
+ return;
+ }
+ if (!BlockRequestAllowed(pindex)) {
+ LogPrint(BCLog::NET, "%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom.GetId());
+ return;
+ }
+ // disconnect node in case we have reached the outbound limit for serving historical blocks
+ if (m_connman.OutboundTargetReached(true) &&
+ (((m_chainman.m_best_header != nullptr) && (m_chainman.m_best_header->GetBlockTime() - pindex->GetBlockTime() > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk()) &&
+ !pfrom.HasPermission(NetPermissionFlags::Download) // nodes with the download permission may exceed target
+ ) {
+ LogPrint(BCLog::NET, "historical block serving limit reached, disconnect peer=%d\n", pfrom.GetId());
+ pfrom.fDisconnect = true;
+ return;
+ }
+ tip = m_chainman.ActiveChain().Tip();
+ // Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
+ if (!pfrom.HasPermission(NetPermissionFlags::NoBan) && (
+ (((peer.m_our_services & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((peer.m_our_services & NODE_NETWORK) != NODE_NETWORK) && (tip->nHeight - pindex->nHeight > (int)NODE_NETWORK_LIMITED_MIN_BLOCKS + 2 /* add two blocks buffer extension for possible races */) )
+ )) {
+ LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold, disconnect peer=%d\n", pfrom.GetId());
+ //disconnect node and prevent it from stalling (would otherwise wait for the missing block)
+ pfrom.fDisconnect = true;
+ return;
+ }
+ // Pruned nodes may have deleted the block, so check whether
+ // it's available before trying to send.
+ if (!(pindex->nStatus & BLOCK_HAVE_DATA)) {
+ return;
+ }
+ can_direct_fetch = CanDirectFetch();
+ block_pos = pindex->GetBlockPos();
}
+
std::shared_ptr<const CBlock> pblock;
if (a_recent_block && a_recent_block->GetHash() == pindex->GetBlockHash()) {
pblock = a_recent_block;
@@ -2462,16 +2470,28 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
// Fast-path: in this case it is possible to serve the block directly from disk,
// as the network format matches the format on disk
std::vector<uint8_t> block_data;
- if (!m_chainman.m_blockman.ReadRawBlockFromDisk(block_data, pindex->GetBlockPos())) {
- assert(!"cannot load block from disk");
+ if (!m_chainman.m_blockman.ReadRawBlockFromDisk(block_data, block_pos)) {
+ if (WITH_LOCK(m_chainman.GetMutex(), return m_chainman.m_blockman.IsBlockPruned(*pindex))) {
+ LogPrint(BCLog::NET, "Block was pruned before it could be read, disconnect peer=%s\n", pfrom.GetId());
+ } else {
+ LogError("Cannot load block from disk, disconnect peer=%d\n", pfrom.GetId());
+ }
+ pfrom.fDisconnect = true;
+ return;
}
MakeAndPushMessage(pfrom, NetMsgType::BLOCK, Span{block_data});
// Don't set pblock as we've sent the block
} else {
// Send block from disk
std::shared_ptr<CBlock> pblockRead = std::make_shared<CBlock>();
- if (!m_chainman.m_blockman.ReadBlockFromDisk(*pblockRead, *pindex)) {
- assert(!"cannot load block from disk");
+ if (!m_chainman.m_blockman.ReadBlockFromDisk(*pblockRead, block_pos)) {
+ if (WITH_LOCK(m_chainman.GetMutex(), return m_chainman.m_blockman.IsBlockPruned(*pindex))) {
+ LogPrint(BCLog::NET, "Block was pruned before it could be read, disconnect peer=%s\n", pfrom.GetId());
+ } else {
+ LogError("Cannot load block from disk, disconnect peer=%d\n", pfrom.GetId());
+ }
+ pfrom.fDisconnect = true;
+ return;
}
pblock = pblockRead;
}
@@ -2509,7 +2529,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
// they won't have a useful mempool to match against a compact block,
// and we don't feel like constructing the object for them, so
// instead we respond with the full, non-compact block.
- if (CanDirectFetch() && pindex->nHeight >= m_chainman.ActiveChain().Height() - MAX_CMPCTBLOCK_DEPTH) {
+ if (can_direct_fetch && pindex->nHeight >= tip->nHeight - MAX_CMPCTBLOCK_DEPTH) {
if (a_recent_compact_block && a_recent_compact_block->header.GetHash() == pindex->GetBlockHash()) {
MakeAndPushMessage(pfrom, NetMsgType::CMPCTBLOCK, *a_recent_compact_block);
} else {
@@ -2530,7 +2550,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
// and we want it right after the last block so they don't
// wait for other stuff first.
std::vector<CInv> vInv;
- vInv.emplace_back(MSG_BLOCK, m_chainman.ActiveChain().Tip()->GetBlockHash());
+ vInv.emplace_back(MSG_BLOCK, tip->GetBlockHash());
MakeAndPushMessage(pfrom, NetMsgType::INV, vInv);
peer.m_continuation_block.SetNull();
}
@@ -3252,22 +3272,21 @@ void PeerManagerImpl::ProcessValidTx(NodeId nodeid, const CTransactionRef& tx, c
}
}
-void PeerManagerImpl::ProcessPackageResult(const Package& package, const PackageMempoolAcceptResult& package_result, const std::vector<NodeId>& senders)
+void PeerManagerImpl::ProcessPackageResult(const PackageToValidate& package_to_validate, const PackageMempoolAcceptResult& package_result)
{
AssertLockNotHeld(m_peer_mutex);
AssertLockHeld(g_msgproc_mutex);
AssertLockHeld(cs_main);
+ const auto& package = package_to_validate.m_txns;
+ const auto& senders = package_to_validate.m_senders;
+
if (package_result.m_state.IsInvalid()) {
m_recent_rejects_reconsiderable.insert(GetPackageHash(package));
}
// We currently only expect to process 1-parent-1-child packages. Remove if this changes.
if (!Assume(package.size() == 2)) return;
- // No package results to look through for PCKG_POLICY or PCKG_MEMPOOL_ERROR
- if (package_result.m_state.GetResult() == PackageValidationResult::PCKG_POLICY ||
- package_result.m_state.GetResult() == PackageValidationResult::PCKG_MEMPOOL_ERROR) return;
-
// Iterate backwards to erase in-package descendants from the orphanage before they become
// relevant in AddChildrenToWorkSet.
auto package_iter = package.rbegin();
@@ -3276,14 +3295,14 @@ void PeerManagerImpl::ProcessPackageResult(const Package& package, const Package
const auto& tx = *package_iter;
const NodeId nodeid = *senders_iter;
const auto it_result{package_result.m_tx_results.find(tx->GetWitnessHash())};
- if (Assume(it_result != package_result.m_tx_results.end())) {
+
+ // It is not guaranteed that a result exists for every transaction.
+ if (it_result != package_result.m_tx_results.end()) {
const auto& tx_result = it_result->second;
switch (tx_result.m_result_type) {
case MempoolAcceptResult::ResultType::VALID:
{
- Assume(tx_result.m_replaced_transactions.has_value());
- std::list<CTransactionRef> empty_replacement_list;
- ProcessValidTx(nodeid, tx, tx_result.m_replaced_transactions.value_or(empty_replacement_list));
+ ProcessValidTx(nodeid, tx, tx_result.m_replaced_transactions);
break;
}
case MempoolAcceptResult::ResultType::INVALID:
@@ -3378,9 +3397,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
LogPrint(BCLog::TXPACKAGES, " accepted orphan tx %s (wtxid=%s)\n", orphanHash.ToString(), orphan_wtxid.ToString());
- Assume(result.m_replaced_transactions.has_value());
- std::list<CTransactionRef> empty_replacement_list;
- ProcessValidTx(peer.m_id, porphanTx, result.m_replaced_transactions.value_or(empty_replacement_list));
+ ProcessValidTx(peer.m_id, porphanTx, result.m_replaced_transactions);
return true;
} else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) {
LogPrint(BCLog::TXPACKAGES, " invalid orphan tx %s (wtxid=%s) from peer=%d. %s\n",
@@ -4372,6 +4389,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
return;
}
+ FlatFilePos block_pos{};
{
LOCK(cs_main);
@@ -4382,15 +4400,21 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
}
if (pindex->nHeight >= m_chainman.ActiveChain().Height() - MAX_BLOCKTXN_DEPTH) {
- CBlock block;
- const bool ret{m_chainman.m_blockman.ReadBlockFromDisk(block, *pindex)};
- assert(ret);
-
- SendBlockTransactions(pfrom, *peer, block, req);
- return;
+ block_pos = pindex->GetBlockPos();
}
}
+ if (!block_pos.IsNull()) {
+ CBlock block;
+ const bool ret{m_chainman.m_blockman.ReadBlockFromDisk(block, block_pos)};
+ // If height is above MAX_BLOCKTXN_DEPTH then this block cannot get
+ // pruned after we release cs_main above, so this read should never fail.
+ assert(ret);
+
+ SendBlockTransactions(pfrom, *peer, block, req);
+ return;
+ }
+
// If an older block is requested (should never happen in practice,
// but can happen in tests) send a block response instead of a
// blocktxn response. Sending a full block response instead of a
@@ -4553,7 +4577,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
const auto package_result{ProcessNewPackage(m_chainman.ActiveChainstate(), m_mempool, package_to_validate->m_txns, /*test_accept=*/false, /*client_maxfeerate=*/std::nullopt)};
LogDebug(BCLog::TXPACKAGES, "package evaluation for %s: %s\n", package_to_validate->ToString(),
package_result.m_state.IsValid() ? "package accepted" : "package rejected");
- ProcessPackageResult(package_to_validate->m_txns, package_result, package_to_validate->m_senders);
+ ProcessPackageResult(package_to_validate.value(), package_result);
}
}
// If a tx is detected by m_recent_rejects it is ignored. Because we haven't
@@ -4578,9 +4602,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
const TxValidationState& state = result.m_state;
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
- Assume(result.m_replaced_transactions.has_value());
- std::list<CTransactionRef> empty_replacement_list;
- ProcessValidTx(pfrom.GetId(), ptx, result.m_replaced_transactions.value_or(empty_replacement_list));
+ ProcessValidTx(pfrom.GetId(), ptx, result.m_replaced_transactions);
pfrom.m_last_tx_time = GetTime<std::chrono::seconds>();
}
else if (state.GetResult() == TxValidationResult::TX_MISSING_INPUTS)
@@ -4670,7 +4692,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
const auto package_result{ProcessNewPackage(m_chainman.ActiveChainstate(), m_mempool, package_to_validate->m_txns, /*test_accept=*/false, /*client_maxfeerate=*/std::nullopt)};
LogDebug(BCLog::TXPACKAGES, "package evaluation for %s: %s\n", package_to_validate->ToString(),
package_result.m_state.IsValid() ? "package accepted" : "package rejected");
- ProcessPackageResult(package_to_validate->m_txns, package_result, package_to_validate->m_senders);
+ ProcessPackageResult(package_to_validate.value(), package_result);
}
}
@@ -5205,7 +5227,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
std::vector<unsigned char> vData;
vRecv >> vData;
- // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object,
+ // Nodes must NEVER send a data item > MAX_SCRIPT_ELEMENT_SIZE bytes (the max size for a script data object,
// and thus, the maximum size any matched object can have) in a filteradd message
bool bad = false;
if (vData.size() > MAX_SCRIPT_ELEMENT_SIZE) {
@@ -5419,16 +5441,19 @@ void PeerManagerImpl::ConsiderEviction(CNode& pto, Peer& peer, std::chrono::seco
// unless it's invalid, in which case we should find that out and
// disconnect from them elsewhere).
if (state.pindexBestKnownBlock != nullptr && state.pindexBestKnownBlock->nChainWork >= m_chainman.ActiveChain().Tip()->nChainWork) {
+ // The outbound peer has sent us a block with at least as much work as our current tip, so reset the timeout if it was set
if (state.m_chain_sync.m_timeout != 0s) {
state.m_chain_sync.m_timeout = 0s;
state.m_chain_sync.m_work_header = nullptr;
state.m_chain_sync.m_sent_getheaders = false;
}
} else if (state.m_chain_sync.m_timeout == 0s || (state.m_chain_sync.m_work_header != nullptr && state.pindexBestKnownBlock != nullptr && state.pindexBestKnownBlock->nChainWork >= state.m_chain_sync.m_work_header->nChainWork)) {
- // Our best block known by this peer is behind our tip, and we're either noticing
- // that for the first time, OR this peer was able to catch up to some earlier point
- // where we checked against our tip.
- // Either way, set a new timeout based on current tip.
+ // At this point we know that the outbound peer has either never sent us a block/header or they have, but its tip is behind ours
+ // AND
+ // we are noticing this for the first time (m_timeout is 0)
+ // OR we noticed this at some point within the last CHAIN_SYNC_TIMEOUT + HEADERS_RESPONSE_TIME seconds and set a timeout
+ // for them, they caught up to our tip at the time of setting the timer but not to our current one (we've also advanced).
+ // Either way, set a new timeout based on our current tip.
state.m_chain_sync.m_timeout = time_in_seconds + CHAIN_SYNC_TIMEOUT;
state.m_chain_sync.m_work_header = m_chainman.ActiveChain().Tip();
state.m_chain_sync.m_sent_getheaders = false;
diff --git a/src/netbase.cpp b/src/netbase.cpp
index f0fa298378..e231766487 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <netbase.h>
diff --git a/src/node/context.cpp b/src/node/context.cpp
index ca56fa0b86..e32d21b383 100644
--- a/src/node/context.cpp
+++ b/src/node/context.cpp
@@ -8,6 +8,7 @@
#include <banman.h>
#include <interfaces/chain.h>
#include <kernel/context.h>
+#include <key.h>
#include <net.h>
#include <net_processing.h>
#include <netgroup.h>
@@ -16,6 +17,7 @@
#include <scheduler.h>
#include <txmempool.h>
#include <validation.h>
+#include <validationinterface.h>
namespace node {
NodeContext::NodeContext() = default;
diff --git a/src/node/context.h b/src/node/context.h
index 245f230aec..a7d92989dd 100644
--- a/src/node/context.h
+++ b/src/node/context.h
@@ -5,10 +5,7 @@
#ifndef BITCOIN_NODE_CONTEXT_H
#define BITCOIN_NODE_CONTEXT_H
-#include <kernel/context.h>
-
#include <atomic>
-#include <cassert>
#include <cstdlib>
#include <functional>
#include <memory>
@@ -24,6 +21,7 @@ class ValidationSignals;
class CScheduler;
class CTxMemPool;
class ChainstateManager;
+class ECC_Context;
class NetGroupManager;
class PeerManager;
namespace interfaces {
@@ -32,6 +30,12 @@ class ChainClient;
class Init;
class WalletLoader;
} // namespace interfaces
+namespace kernel {
+struct Context;
+}
+namespace util {
+class SignalInterrupt;
+}
namespace node {
class KernelNotifications;
@@ -49,6 +53,7 @@ class KernelNotifications;
struct NodeContext {
//! libbitcoin_kernel context
std::unique_ptr<kernel::Context> kernel;
+ std::unique_ptr<ECC_Context> ecc_context;
//! Init interface for initializing current process and connecting to other processes.
interfaces::Init* init{nullptr};
//! Interrupt object used to track whether node shutdown was requested.
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 4d2d83812e..c886357a34 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -17,6 +17,7 @@
#include <interfaces/node.h>
#include <interfaces/wallet.h>
#include <kernel/chain.h>
+#include <kernel/context.h>
#include <kernel/mempool_entry.h>
#include <logging.h>
#include <mapport.h>
@@ -47,14 +48,13 @@
#include <util/check.h>
#include <util/result.h>
#include <util/signalinterrupt.h>
+#include <util/string.h>
#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
#include <warnings.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <any>
#include <memory>
@@ -91,7 +91,7 @@ public:
explicit NodeImpl(NodeContext& context) { setContext(&context); }
void initLogging() override { InitLogging(args()); }
void initParameterInteraction() override { InitParameterInteraction(args()); }
- bilingual_str getWarnings() override { return GetWarnings(true); }
+ bilingual_str getWarnings() override { return Join(GetWarnings(), Untranslated("<hr />")); }
int getExitStatus() override { return Assert(m_context)->exit_status.load(); }
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
bool baseInitialize() override
@@ -100,6 +100,7 @@ public:
if (!AppInitParameterInteraction(args())) return false;
m_context->kernel = std::make_unique<kernel::Context>();
+ m_context->ecc_context = std::make_unique<ECC_Context>();
if (!AppInitSanityChecks(*m_context->kernel)) return false;
if (!AppInitLockDataDirectory()) return false;
diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp
index 99f909ff75..e326d4a1f2 100644
--- a/src/node/kernel_notifications.cpp
+++ b/src/node/kernel_notifications.cpp
@@ -4,9 +4,7 @@
#include <node/kernel_notifications.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chain.h>
#include <common/args.h>
@@ -16,6 +14,7 @@
#include <node/abort.h>
#include <node/interface_ui.h>
#include <util/check.h>
+#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
diff --git a/src/outputtype.cpp b/src/outputtype.cpp
index 566e5ec55a..c72d9deacb 100644
--- a/src/outputtype.cpp
+++ b/src/outputtype.cpp
@@ -85,7 +85,7 @@ CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore,
{
// Add script to keystore
keystore.AddCScript(script);
- // Note that scripts over 520 bytes are not yet supported.
+ // Note that scripts over MAX_SCRIPT_ELEMENT_SIZE bytes are not yet supported.
switch (type) {
case OutputType::LEGACY:
return ScriptHash(script);
diff --git a/src/policy/packages.cpp b/src/policy/packages.cpp
index 99d2a6d514..693adcdfd0 100644
--- a/src/policy/packages.cpp
+++ b/src/policy/packages.cpp
@@ -156,7 +156,10 @@ uint256 GetPackageHash(const std::vector<CTransactionRef>& transactions)
[](const auto& tx){ return tx->GetWitnessHash(); });
// Sort in ascending order
- std::sort(wtxids_copy.begin(), wtxids_copy.end(), [](const auto& lhs, const auto& rhs) { return lhs.GetHex() < rhs.GetHex(); });
+ std::sort(wtxids_copy.begin(), wtxids_copy.end(), [](const auto& lhs, const auto& rhs) {
+ return std::lexicographical_compare(std::make_reverse_iterator(lhs.end()), std::make_reverse_iterator(lhs.begin()),
+ std::make_reverse_iterator(rhs.end()), std::make_reverse_iterator(rhs.begin()));
+ });
// Get sha256 hash of the wtxids concatenated in this order
HashWriter hashwriter;
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index d08ec4fb7f..d8b4b907e4 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -111,7 +111,7 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
for (const CTxIn& txin : tx.vin)
{
// Biggest 'standard' txin involving only keys is a 15-of-15 P2SH
- // multisig with compressed keys (remember the 520 byte limit on
+ // multisig with compressed keys (remember the MAX_SCRIPT_ELEMENT_SIZE byte limit on
// redeemScript size). That works out to a (15*(33+1))+3=513 byte
// redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig, which
// we round off to 1650(MAX_STANDARD_SCRIPTSIG_SIZE) bytes for
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index b1a8461d02..44a858c16b 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/bitcoin.h>
diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h
index 9622c9d57d..1423a8bbc6 100644
--- a/src/qt/bitcoin.h
+++ b/src/qt/bitcoin.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_BITCOIN_H
#define BITCOIN_QT_BITCOIN_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <interfaces/node.h>
#include <qt/initexecutor.h>
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 5f132b817e..a43009d954 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/bitcoingui.h>
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index ba91eeb1ff..73adbda5a5 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_BITCOINGUI_H
#define BITCOIN_QT_BITCOINGUI_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/bitcoinunits.h>
#include <qt/clientmodel.h>
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 05172cfbd2..2f3bad37e6 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/clientmodel.h>
diff --git a/src/qt/createwalletdialog.cpp b/src/qt/createwalletdialog.cpp
index 6557280d89..3e8d1461e5 100644
--- a/src/qt/createwalletdialog.cpp
+++ b/src/qt/createwalletdialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <interfaces/node.h>
#include <qt/createwalletdialog.h>
diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui
index 60e9bcde33..eeea53864a 100644
--- a/src/qt/forms/debugwindow.ui
+++ b/src/qt/forms/debugwindow.ui
@@ -1113,7 +1113,7 @@
<item row="3" column="0">
<widget class="QLabel" name="peerSessionIdLabel">
<property name="toolTip">
- <string>The BIP324 session ID string in hex, if any.</string>
+ <string>The BIP324 session ID string in hex.</string>
</property>
<property name="text">
<string>Session ID</string>
diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui
index f42d19093b..b72360b586 100644
--- a/src/qt/forms/signverifymessagedialog.ui
+++ b/src/qt/forms/signverifymessagedialog.ui
@@ -30,7 +30,7 @@
<item>
<widget class="QLabel" name="infoLabel_SM">
<property name="text">
- <string>You can sign messages/agreements with your addresses to prove you can receive bitcoins sent to them. Be careful not to sign anything vague or random, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</string>
+ <string>You can sign messages/agreements with your legacy (P2PKH) addresses to prove you can receive bitcoins sent to them. Be careful not to sign anything vague or random, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index e094b686d4..ee841ce626 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/guiutil.h>
diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp
index 5371dbaa30..26b42deb64 100644
--- a/src/qt/intro.cpp
+++ b/src/qt/intro.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <qt/intro.h>
diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp
index 667db06574..7bc6ccdc49 100644
--- a/src/qt/modaloverlay.cpp
+++ b/src/qt/modaloverlay.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/modaloverlay.h>
#include <qt/forms/ui_modaloverlay.h>
diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp
index 551c0ffd13..85bdeee49a 100644
--- a/src/qt/notificator.cpp
+++ b/src/qt/notificator.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/notificator.h>
diff --git a/src/qt/notificator.h b/src/qt/notificator.h
index 1fd8181a22..8808716aa4 100644
--- a/src/qt/notificator.h
+++ b/src/qt/notificator.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_NOTIFICATOR_H
#define BITCOIN_QT_NOTIFICATOR_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <QIcon>
#include <QObject>
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index dd654a7abe..ee53a59bb5 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/optionsdialog.h>
#include <qt/forms/ui_optionsdialog.h>
@@ -20,6 +18,7 @@
#include <node/chainstatemanager_args.h>
#include <netbase.h>
#include <txdb.h>
+#include <util/strencodings.h>
#include <chrono>
@@ -482,7 +481,10 @@ QValidator(parent)
QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) const
{
Q_UNUSED(pos);
- // Validate the proxy
+ uint16_t port{0};
+ std::string hostname;
+ if (!SplitHostPort(input.toStdString(), port, hostname) || port != 0) return QValidator::Invalid;
+
CService serv(LookupNumeric(input.toStdString(), DEFAULT_GUI_PROXY_PORT));
Proxy addrProxy = Proxy(serv, true);
if (addrProxy.IsValid())
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index d0f7c64357..0c21c6748d 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/optionsmodel.h>
diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp
index 00f928b355..f6e712a047 100644
--- a/src/qt/qrimagewidget.cpp
+++ b/src/qt/qrimagewidget.cpp
@@ -15,9 +15,7 @@
#include <QMouseEvent>
#include <QPainter>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h> /* for USE_QRCODE */
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#ifdef USE_QRCODE
#include <qrencode.h>
diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp
index 3453857f98..b4322ddc0f 100644
--- a/src/qt/receiverequestdialog.cpp
+++ b/src/qt/receiverequestdialog.cpp
@@ -14,9 +14,7 @@
#include <QDialog>
#include <QString>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h> /* for USE_QRCODE */
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
ReceiveRequestDialog::ReceiveRequestDialog(QWidget* parent)
: QDialog(parent, GUIUtil::dialog_flags),
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index bafef62945..702ca44395 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/rpcconsole.h>
#include <qt/forms/ui_debugwindow.h>
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 358f68c3c8..d6a5035c33 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_QT_RPCCONSOLE_H
#define BITCOIN_QT_RPCCONSOLE_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/clientmodel.h>
#include <qt/guiutil.h>
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 89bd35eb1b..0d8c0f7a63 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/sendcoinsdialog.h>
#include <qt/forms/ui_sendcoinsdialog.h>
diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp
index 0e725acb33..4392d76328 100644
--- a/src/qt/signverifymessagedialog.cpp
+++ b/src/qt/signverifymessagedialog.cpp
@@ -10,6 +10,7 @@
#include <qt/platformstyle.h>
#include <qt/walletmodel.h>
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <key_io.h>
#include <util/message.h> // For MessageSign(), MessageVerify()
#include <wallet/wallet.h>
@@ -123,7 +124,7 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
if (!pkhash) {
ui->addressIn_SM->setValid(false);
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
- ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again."));
+ ui->statusLabel_SM->setText(tr("The entered address does not refer to a legacy (P2PKH) key. Message signing for SegWit and other non-P2PKH address types is not supported in this version of %1. Please check the address and try again.").arg(PACKAGE_NAME));
return;
}
@@ -221,10 +222,7 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked()
return;
case MessageVerificationResult::ERR_ADDRESS_NO_KEY:
ui->addressIn_VM->setValid(false);
- ui->statusLabel_VM->setText(
- tr("The entered address does not refer to a key.") + QString(" ") +
- tr("Please check the address and try again.")
- );
+ ui->statusLabel_VM->setText(tr("The entered address does not refer to a legacy (P2PKH) key. Message signing for SegWit and other non-P2PKH address types is not supported in this version of %1. Please check the address and try again.").arg(PACKAGE_NAME));
return;
case MessageVerificationResult::ERR_MALFORMED_SIGNATURE:
ui->signatureIn_VM->setValid(false);
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 8872f8be32..ffd6689910 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/splashscreen.h>
diff --git a/src/qt/test/optiontests.cpp b/src/qt/test/optiontests.cpp
index 5f9f2cb449..0f82f65f3e 100644
--- a/src/qt/test/optiontests.cpp
+++ b/src/qt/test/optiontests.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/args.h>
#include <init.h>
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
index c5405cca98..f310d0a02b 100644
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <interfaces/init.h>
#include <interfaces/node.h>
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
index 22fe219def..f261c6409d 100644
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <qt/utilitydialog.h>
@@ -117,7 +115,7 @@ HelpMessageDialog::~HelpMessageDialog()
void HelpMessageDialog::printToConsole()
{
// On other operating systems, the expected action is to print the message to the console.
- tfm::format(std::cout, "%s\n", qPrintable(text));
+ tfm::format(std::cout, "%s", qPrintable(text));
}
void HelpMessageDialog::showOrPrint()
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index fe000bcbb8..87ad98a4cc 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -529,12 +529,6 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
return false;
}
- WalletModel::UnlockContext ctx(requestUnlock());
- if(!ctx.isValid())
- {
- return false;
- }
-
// Short-circuit if we are returning a bumped transaction PSBT to clipboard
if (retval == QMessageBox::Save) {
// "Create Unsigned" clicked
@@ -549,10 +543,15 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
DataStream ssTx{};
ssTx << psbtx;
GUIUtil::setClipboard(EncodeBase64(ssTx.str()).c_str());
- Q_EMIT message(tr("PSBT copied"), tr("Copied to clipboard", "Fee-bump PSBT saved"), CClientUIInterface::MSG_INFORMATION);
+ Q_EMIT message(tr("PSBT copied"), tr("Fee-bump PSBT copied to clipboard"), CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL);
return true;
}
+ WalletModel::UnlockContext ctx(requestUnlock());
+ if (!ctx.isValid()) {
+ return false;
+ }
+
assert(!m_wallet->privateKeysDisabled() || wallet().hasExternalSigner());
// sign bumped transaction
diff --git a/src/random.cpp b/src/random.cpp
index 4fc9099704..239d5bc6fe 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <random.h>
diff --git a/src/randomenv.cpp b/src/randomenv.cpp
index 123b5cc06c..aeec959c28 100644
--- a/src/randomenv.cpp
+++ b/src/randomenv.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <randomenv.h>
diff --git a/src/rest.cpp b/src/rest.cpp
index 89c033b8a3..9fc5d4af04 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <rest.h>
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index eed004806a..c9997ae063 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -47,7 +47,6 @@
#include <validation.h>
#include <validationinterface.h>
#include <versionbits.h>
-#include <warnings.h>
#include <stdint.h>
@@ -1260,7 +1259,14 @@ RPCHelpMan getblockchaininfo()
{RPCResult::Type::NUM, "pruneheight", /*optional=*/true, "height of the last block pruned, plus one (only present if pruning is enabled)"},
{RPCResult::Type::BOOL, "automatic_pruning", /*optional=*/true, "whether automatic pruning is enabled (only present if pruning is enabled)"},
{RPCResult::Type::NUM, "prune_target_size", /*optional=*/true, "the target size used by pruning (only present if automatic pruning is enabled)"},
- {RPCResult::Type::STR, "warnings", "any network and blockchain warnings"},
+ (IsDeprecatedRPCEnabled("warnings") ?
+ RPCResult{RPCResult::Type::STR, "warnings", "any network and blockchain warnings (DEPRECATED)"} :
+ RPCResult{RPCResult::Type::ARR, "warnings", "any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)",
+ {
+ {RPCResult::Type::STR, "", "warning"},
+ }
+ }
+ ),
}},
RPCExamples{
HelpExampleCli("getblockchaininfo", "")
@@ -1298,7 +1304,7 @@ RPCHelpMan getblockchaininfo()
}
}
- obj.pushKV("warnings", GetWarnings(false).original);
+ obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/external_signer.cpp b/src/rpc/external_signer.cpp
index 8d06ae4258..27c7394909 100644
--- a/src/rpc/external_signer.cpp
+++ b/src/rpc/external_signer.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/args.h>
#include <common/system.h>
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index 920bb9ea7f..0672ec34b3 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -813,13 +813,14 @@ static RPCHelpMan submitpackage()
{
return RPCHelpMan{"submitpackage",
"Submit a package of raw transactions (serialized, hex-encoded) to local node.\n"
- "The package must consist of a child with its parents, and none of the parents may depend on one another.\n"
"The package will be validated according to consensus and mempool policy rules. If any transaction passes, it will be accepted to mempool.\n"
"This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.\n"
"Warning: successful submission does not mean the transactions will propagate throughout the network.\n"
,
{
- {"package", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of raw transactions.",
+ {"package", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of raw transactions.\n"
+ "The package must solely consist of a child and its parents. None of the parents may depend on each other.\n"
+ "The package must be topologically sorted, with the child being the last element in the array.",
{
{"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
},
@@ -860,15 +861,15 @@ static RPCHelpMan submitpackage()
},
},
RPCExamples{
- HelpExampleCli("testmempoolaccept", "[rawtx1, rawtx2]") +
- HelpExampleCli("submitpackage", "[rawtx1, rawtx2]")
+ HelpExampleRpc("submitpackage", R"(["rawtx1", "rawtx2"])") +
+ HelpExampleCli("submitpackage", R"('["rawtx1", "rawtx2"]')")
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
const UniValue raw_transactions = request.params[0].get_array();
- if (raw_transactions.size() < 1 || raw_transactions.size() > MAX_PACKAGE_COUNT) {
+ if (raw_transactions.size() < 2 || raw_transactions.size() > MAX_PACKAGE_COUNT) {
throw JSONRPCError(RPC_INVALID_PARAMETER,
- "Array must contain between 1 and " + ToString(MAX_PACKAGE_COUNT) + " transactions.");
+ "Array must contain between 2 and " + ToString(MAX_PACKAGE_COUNT) + " transactions.");
}
// Fee check needs to be run with chainstate and package context
@@ -994,10 +995,8 @@ static RPCHelpMan submitpackage()
fees.pushKV("effective-includes", effective_includes_res);
}
result_inner.pushKV("fees", fees);
- if (it->second.m_replaced_transactions.has_value()) {
- for (const auto& ptx : it->second.m_replaced_transactions.value()) {
- replaced_txids.insert(ptx->GetHash());
- }
+ for (const auto& ptx : it->second.m_replaced_transactions) {
+ replaced_txids.insert(ptx->GetHash());
}
break;
}
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 454c262803..2391392bd7 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chain.h>
#include <chainparams.h>
@@ -33,13 +31,13 @@
#include <script/signingprovider.h>
#include <txmempool.h>
#include <univalue.h>
+#include <util/signalinterrupt.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/time.h>
#include <util/translation.h>
#include <validation.h>
#include <validationinterface.h>
-#include <warnings.h>
#include <memory>
#include <stdint.h>
@@ -426,7 +424,14 @@ static RPCHelpMan getmininginfo()
{RPCResult::Type::NUM, "networkhashps", "The network hashes per second"},
{RPCResult::Type::NUM, "pooledtx", "The size of the mempool"},
{RPCResult::Type::STR, "chain", "current network name (main, test, signet, regtest)"},
- {RPCResult::Type::STR, "warnings", "any network and blockchain warnings"},
+ (IsDeprecatedRPCEnabled("warnings") ?
+ RPCResult{RPCResult::Type::STR, "warnings", "any network and blockchain warnings (DEPRECATED)"} :
+ RPCResult{RPCResult::Type::ARR, "warnings", "any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)",
+ {
+ {RPCResult::Type::STR, "", "warning"},
+ }
+ }
+ ),
}},
RPCExamples{
HelpExampleCli("getmininginfo", "")
@@ -448,7 +453,7 @@ static RPCHelpMan getmininginfo()
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
obj.pushKV("pooledtx", (uint64_t)mempool.size());
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
- obj.pushKV("warnings", GetWarnings(false).original);
+ obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 739ff1a48e..04f9410b32 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -29,7 +29,6 @@
#include <util/time.h>
#include <util/translation.h>
#include <validation.h>
-#include <warnings.h>
#include <optional>
@@ -657,7 +656,14 @@ static RPCHelpMan getnetworkinfo()
{RPCResult::Type::NUM, "score", "relative score"},
}},
}},
- {RPCResult::Type::STR, "warnings", "any network and blockchain warnings"},
+ (IsDeprecatedRPCEnabled("warnings") ?
+ RPCResult{RPCResult::Type::STR, "warnings", "any network and blockchain warnings (DEPRECATED)"} :
+ RPCResult{RPCResult::Type::ARR, "warnings", "any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)",
+ {
+ {RPCResult::Type::STR, "", "warning"},
+ }
+ }
+ ),
}
},
RPCExamples{
@@ -707,7 +713,7 @@ static RPCHelpMan getnetworkinfo()
}
}
obj.pushKV("localaddresses", localAddresses);
- obj.pushKV("warnings", GetWarnings(false).original);
+ obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp
index ffc2ee5ab0..447be2cf64 100644
--- a/src/rpc/node.cpp
+++ b/src/rpc/node.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chainparams.h>
#include <httpserver.h>
diff --git a/src/rpc/output_script.cpp b/src/rpc/output_script.cpp
index f9343f48a8..474d9076be 100644
--- a/src/rpc/output_script.cpp
+++ b/src/rpc/output_script.cpp
@@ -124,11 +124,7 @@ static RPCHelpMan createmultisig()
const UniValue& keys = request.params[1].get_array();
std::vector<CPubKey> pubkeys;
for (unsigned int i = 0; i < keys.size(); ++i) {
- if (IsHex(keys[i].get_str()) && (keys[i].get_str().length() == 66 || keys[i].get_str().length() == 130)) {
- pubkeys.push_back(HexToPubKey(keys[i].get_str()));
- } else {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid public key: %s\n.", keys[i].get_str()));
- }
+ pubkeys.push_back(HexToPubKey(keys[i].get_str()));
}
// Get the output type
diff --git a/src/rpc/register.h b/src/rpc/register.h
index fd23dde75b..65fd29ff08 100644
--- a/src/rpc/register.h
+++ b/src/rpc/register.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_RPC_REGISTER_H
#define BITCOIN_RPC_REGISTER_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
/** These are in one header file to avoid creating tons of single-function
* headers for everything under src/rpc/ */
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index e7d1e3db4e..a800451f4a 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <rpc/server.h>
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index f683878054..9a7c731afe 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <core_io.h>
@@ -18,16 +16,19 @@
#include <script/signingprovider.h>
#include <script/solver.h>
#include <tinyformat.h>
+#include <univalue.h>
#include <util/check.h>
#include <util/result.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
+#include <warnings.h>
#include <algorithm>
#include <iterator>
#include <string_view>
#include <tuple>
+#include <utility>
const std::string UNIX_EPOCH_TIME = "UNIX epoch time";
const std::string EXAMPLE_ADDRESS[2] = {"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl", "bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3"};
@@ -193,11 +194,14 @@ std::string HelpExampleRpcNamed(const std::string& methodname, const RPCArgList&
CPubKey HexToPubKey(const std::string& hex_in)
{
if (!IsHex(hex_in)) {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid public key: " + hex_in);
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey \"" + hex_in + "\" must be a hex string");
+ }
+ if (hex_in.length() != 66 && hex_in.length() != 130) {
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey \"" + hex_in + "\" must have a length of either 33 or 65 bytes");
}
CPubKey vchPubKey(ParseHex(hex_in));
if (!vchPubKey.IsFullyValid()) {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid public key: " + hex_in);
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey \"" + hex_in + "\" must be cryptographically valid.");
}
return vchPubKey;
}
@@ -1357,3 +1361,17 @@ void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj)
if (warnings.empty()) return;
obj.pushKV("warnings", BilingualStringsToUniValue(warnings));
}
+
+UniValue GetNodeWarnings(bool use_deprecated)
+{
+ if (use_deprecated) {
+ const auto all_warnings{GetWarnings()};
+ return all_warnings.empty() ? "" : all_warnings.back().original;
+ }
+
+ UniValue warnings{UniValue::VARR};
+ for (auto&& warning : GetWarnings()) {
+ warnings.push_back(std::move(warning.original));
+ }
+ return warnings;
+}
diff --git a/src/rpc/util.h b/src/rpc/util.h
index 177af90c05..0e4dcc27b5 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -513,4 +513,6 @@ private:
void PushWarnings(const UniValue& warnings, UniValue& obj);
void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj);
+UniValue GetNodeWarnings(bool use_deprecated);
+
#endif // BITCOIN_RPC_UTIL_H
diff --git a/src/script/miniscript.cpp b/src/script/miniscript.cpp
index 344a81bdf0..455bd56283 100644
--- a/src/script/miniscript.cpp
+++ b/src/script/miniscript.cpp
@@ -231,7 +231,8 @@ Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector<Ty
Type acc_tl = "k"_mst;
for (size_t i = 0; i < sub_types.size(); ++i) {
Type t = sub_types[i];
- if (!(t << (i ? "Wdu"_mst : "Bdu"_mst))) return ""_mst; // Require Bdu, Wdu, Wdu, ...
+ static constexpr auto WDU{"Wdu"_mst}, BDU{"Bdu"_mst};
+ if (!(t << (i ? WDU : BDU))) return ""_mst; // Require Bdu, Wdu, Wdu, ...
if (!(t << "e"_mst)) all_e = false;
if (!(t << "m"_mst)) all_m = false;
if (t << "s"_mst) num_s += 1;
diff --git a/src/script/miniscript.h b/src/script/miniscript.h
index f635fa7340..4880f32410 100644
--- a/src/script/miniscript.h
+++ b/src/script/miniscript.h
@@ -123,12 +123,12 @@ class Type {
//! Internal bitmap of properties (see ""_mst operator for details).
uint32_t m_flags;
- //! Internal constructor used by the ""_mst operator.
- explicit constexpr Type(uint32_t flags) : m_flags(flags) {}
+ //! Internal constructor.
+ explicit constexpr Type(uint32_t flags) noexcept : m_flags(flags) {}
public:
- //! The only way to publicly construct a Type is using this literal operator.
- friend constexpr Type operator"" _mst(const char* c, size_t l);
+ //! Construction function used by the ""_mst operator.
+ static consteval Type Make(uint32_t flags) noexcept { return Type(flags); }
//! Compute the type with the union of properties.
constexpr Type operator|(Type x) const { return Type(m_flags | x.m_flags); }
@@ -150,11 +150,11 @@ public:
};
//! Literal operator to construct Type objects.
-inline constexpr Type operator"" _mst(const char* c, size_t l) {
- Type typ{0};
+inline consteval Type operator"" _mst(const char* c, size_t l) {
+ Type typ{Type::Make(0)};
for (const char *p = c; p < c + l; p++) {
- typ = typ | Type(
+ typ = typ | Type::Make(
*p == 'B' ? 1 << 0 : // Base type
*p == 'V' ? 1 << 1 : // Verify type
*p == 'K' ? 1 << 2 : // Key type
@@ -548,7 +548,8 @@ private:
for (const auto& sub : subs) {
subsize += sub->ScriptSize();
}
- Type sub0type = subs.size() > 0 ? subs[0]->GetType() : ""_mst;
+ static constexpr auto NONE_MST{""_mst};
+ Type sub0type = subs.size() > 0 ? subs[0]->GetType() : NONE_MST;
return internal::ComputeScriptLen(fragment, sub0type, subsize, k, subs.size(), keys.size(), m_script_ctx);
}
@@ -712,9 +713,10 @@ private:
for (const auto& sub : subs) sub_types.push_back(sub->GetType());
}
// All other nodes than THRESH can be computed just from the types of the 0-3 subexpressions.
- Type x = subs.size() > 0 ? subs[0]->GetType() : ""_mst;
- Type y = subs.size() > 1 ? subs[1]->GetType() : ""_mst;
- Type z = subs.size() > 2 ? subs[2]->GetType() : ""_mst;
+ static constexpr auto NONE_MST{""_mst};
+ Type x = subs.size() > 0 ? subs[0]->GetType() : NONE_MST;
+ Type y = subs.size() > 1 ? subs[1]->GetType() : NONE_MST;
+ Type z = subs.size() > 2 ? subs[2]->GetType() : NONE_MST;
return SanitizeType(ComputeType(fragment, x, y, z, sub_types, k, data.size(), subs.size(), keys.size(), m_script_ctx));
}
diff --git a/src/test/fuzz/bip324.cpp b/src/test/fuzz/bip324.cpp
index 37c41f3895..8210e75cee 100644
--- a/src/test/fuzz/bip324.cpp
+++ b/src/test/fuzz/bip324.cpp
@@ -17,7 +17,7 @@ namespace {
void Initialize()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
SelectParams(ChainType::MAIN);
}
diff --git a/src/test/fuzz/descriptor_parse.cpp b/src/test/fuzz/descriptor_parse.cpp
index 6ea315d4e2..b9a5560ffb 100644
--- a/src/test/fuzz/descriptor_parse.cpp
+++ b/src/test/fuzz/descriptor_parse.cpp
@@ -55,7 +55,7 @@ static void TestDescriptor(const Descriptor& desc, FlatSigningProvider& sig_prov
void initialize_descriptor_parse()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
SelectParams(ChainType::MAIN);
}
diff --git a/src/test/fuzz/key.cpp b/src/test/fuzz/key.cpp
index 9e1e318e02..d389a29575 100644
--- a/src/test/fuzz/key.cpp
+++ b/src/test/fuzz/key.cpp
@@ -32,7 +32,7 @@
void initialize_key()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
SelectParams(ChainType::REGTEST);
}
diff --git a/src/test/fuzz/key_io.cpp b/src/test/fuzz/key_io.cpp
index 5f98f2b7f1..aefdefe233 100644
--- a/src/test/fuzz/key_io.cpp
+++ b/src/test/fuzz/key_io.cpp
@@ -14,7 +14,7 @@
void initialize_key_io()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
SelectParams(ChainType::MAIN);
}
diff --git a/src/test/fuzz/message.cpp b/src/test/fuzz/message.cpp
index b5c95441f8..75baaa2754 100644
--- a/src/test/fuzz/message.cpp
+++ b/src/test/fuzz/message.cpp
@@ -19,7 +19,7 @@
void initialize_message()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
SelectParams(ChainType::REGTEST);
}
diff --git a/src/test/fuzz/miniscript.cpp b/src/test/fuzz/miniscript.cpp
index 0d0ee59ab3..f10007222c 100644
--- a/src/test/fuzz/miniscript.cpp
+++ b/src/test/fuzz/miniscript.cpp
@@ -391,6 +391,7 @@ std::optional<NodeInfo> ConsumeNodeStable(MsCtx script_ctx, FuzzedDataProvider&
bool allow_K = (type_needed == ""_mst) || (type_needed << "K"_mst);
bool allow_V = (type_needed == ""_mst) || (type_needed << "V"_mst);
bool allow_W = (type_needed == ""_mst) || (type_needed << "W"_mst);
+ static constexpr auto B{"B"_mst}, K{"K"_mst}, V{"V"_mst}, W{"W"_mst};
switch (provider.ConsumeIntegral<uint8_t>()) {
case 0:
@@ -440,22 +441,22 @@ std::optional<NodeInfo> ConsumeNodeStable(MsCtx script_ctx, FuzzedDataProvider&
}
case 11:
if (!(allow_B || allow_K || allow_V)) return {};
- return {{{"B"_mst, type_needed, type_needed}, Fragment::ANDOR}};
+ return {{{B, type_needed, type_needed}, Fragment::ANDOR}};
case 12:
if (!(allow_B || allow_K || allow_V)) return {};
- return {{{"V"_mst, type_needed}, Fragment::AND_V}};
+ return {{{V, type_needed}, Fragment::AND_V}};
case 13:
if (!allow_B) return {};
- return {{{"B"_mst, "W"_mst}, Fragment::AND_B}};
+ return {{{B, W}, Fragment::AND_B}};
case 15:
if (!allow_B) return {};
- return {{{"B"_mst, "W"_mst}, Fragment::OR_B}};
+ return {{{B, W}, Fragment::OR_B}};
case 16:
if (!allow_V) return {};
- return {{{"B"_mst, "V"_mst}, Fragment::OR_C}};
+ return {{{B, V}, Fragment::OR_C}};
case 17:
if (!allow_B) return {};
- return {{{"B"_mst, "B"_mst}, Fragment::OR_D}};
+ return {{{B, B}, Fragment::OR_D}};
case 18:
if (!(allow_B || allow_K || allow_V)) return {};
return {{{type_needed, type_needed}, Fragment::OR_I}};
@@ -472,25 +473,25 @@ std::optional<NodeInfo> ConsumeNodeStable(MsCtx script_ctx, FuzzedDataProvider&
}
case 20:
if (!allow_W) return {};
- return {{{"B"_mst}, Fragment::WRAP_A}};
+ return {{{B}, Fragment::WRAP_A}};
case 21:
if (!allow_W) return {};
- return {{{"B"_mst}, Fragment::WRAP_S}};
+ return {{{B}, Fragment::WRAP_S}};
case 22:
if (!allow_B) return {};
- return {{{"K"_mst}, Fragment::WRAP_C}};
+ return {{{K}, Fragment::WRAP_C}};
case 23:
if (!allow_B) return {};
- return {{{"V"_mst}, Fragment::WRAP_D}};
+ return {{{V}, Fragment::WRAP_D}};
case 24:
if (!allow_V) return {};
- return {{{"B"_mst}, Fragment::WRAP_V}};
+ return {{{B}, Fragment::WRAP_V}};
case 25:
if (!allow_B) return {};
- return {{{"B"_mst}, Fragment::WRAP_J}};
+ return {{{B}, Fragment::WRAP_J}};
case 26:
if (!allow_B) return {};
- return {{{"B"_mst}, Fragment::WRAP_N}};
+ return {{{B}, Fragment::WRAP_N}};
case 27: {
if (!allow_B || !IsTapscript(script_ctx)) return {};
const auto k = provider.ConsumeIntegral<uint16_t>();
@@ -528,20 +529,23 @@ struct SmartInfo
{
/* Construct a set of interesting type requirements to reason with (sections of BKVWzondu). */
std::vector<Type> types;
+ static constexpr auto B_mst{"B"_mst}, K_mst{"K"_mst}, V_mst{"V"_mst}, W_mst{"W"_mst};
+ static constexpr auto d_mst{"d"_mst}, n_mst{"n"_mst}, o_mst{"o"_mst}, u_mst{"u"_mst}, z_mst{"z"_mst};
+ static constexpr auto NONE_mst{""_mst};
for (int base = 0; base < 4; ++base) { /* select from B,K,V,W */
- Type type_base = base == 0 ? "B"_mst : base == 1 ? "K"_mst : base == 2 ? "V"_mst : "W"_mst;
+ Type type_base = base == 0 ? B_mst : base == 1 ? K_mst : base == 2 ? V_mst : W_mst;
for (int zo = 0; zo < 3; ++zo) { /* select from z,o,(none) */
- Type type_zo = zo == 0 ? "z"_mst : zo == 1 ? "o"_mst : ""_mst;
+ Type type_zo = zo == 0 ? z_mst : zo == 1 ? o_mst : NONE_mst;
for (int n = 0; n < 2; ++n) { /* select from (none),n */
if (zo == 0 && n == 1) continue; /* z conflicts with n */
if (base == 3 && n == 1) continue; /* W conflicts with n */
- Type type_n = n == 0 ? ""_mst : "n"_mst;
+ Type type_n = n == 0 ? NONE_mst : n_mst;
for (int d = 0; d < 2; ++d) { /* select from (none),d */
if (base == 2 && d == 1) continue; /* V conflicts with d */
- Type type_d = d == 0 ? ""_mst : "d"_mst;
+ Type type_d = d == 0 ? NONE_mst : d_mst;
for (int u = 0; u < 2; ++u) { /* select from (none),u */
if (base == 2 && u == 1) continue; /* V conflicts with u */
- Type type_u = u == 0 ? ""_mst : "u"_mst;
+ Type type_u = u == 0 ? NONE_mst : u_mst;
Type type = type_base | type_zo | type_n | type_d | type_u;
types.push_back(type);
}
@@ -683,7 +687,7 @@ struct SmartInfo
/* Find which types are useful. The fuzzer logic only cares about constructing
* B,V,K,W nodes, so any type that isn't needed in any recipe (directly or
* indirectly) for the construction of those is uninteresting. */
- std::set<Type> useful_types{"B"_mst, "V"_mst, "K"_mst, "W"_mst};
+ std::set<Type> useful_types{B_mst, V_mst, K_mst, W_mst};
// Find the transitive closure by adding types until the set of types does not change.
while (true) {
size_t set_size = useful_types.size();
@@ -1197,7 +1201,7 @@ void TestNode(const MsCtx script_ctx, const NodeRef& node, FuzzedDataProvider& p
void FuzzInit()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
TEST_DATA.Init();
}
diff --git a/src/test/fuzz/p2p_transport_serialization.cpp b/src/test/fuzz/p2p_transport_serialization.cpp
index 1b7a732260..f6d82c3001 100644
--- a/src/test/fuzz/p2p_transport_serialization.cpp
+++ b/src/test/fuzz/p2p_transport_serialization.cpp
@@ -25,7 +25,7 @@ std::vector<std::string> g_all_messages;
void initialize_p2p_transport_serialization()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
SelectParams(ChainType::REGTEST);
g_all_messages = getAllNetMessageTypes();
std::sort(g_all_messages.begin(), g_all_messages.end());
diff --git a/src/test/fuzz/poolresource.cpp b/src/test/fuzz/poolresource.cpp
index ce64ef6472..f764d9f8db 100644
--- a/src/test/fuzz/poolresource.cpp
+++ b/src/test/fuzz/poolresource.cpp
@@ -63,9 +63,9 @@ public:
{
if (m_total_allocated > 0x1000000) return;
size_t alignment_bits = m_provider.ConsumeIntegralInRange<size_t>(0, 7);
- size_t alignment = 1 << alignment_bits;
+ size_t alignment = size_t{1} << alignment_bits;
size_t size_bits = m_provider.ConsumeIntegralInRange<size_t>(0, 16 - alignment_bits);
- size_t size = m_provider.ConsumeIntegralInRange<size_t>(1U << size_bits, (1U << (size_bits + 1)) - 1U) << alignment_bits;
+ size_t size = m_provider.ConsumeIntegralInRange<size_t>(size_t{1} << size_bits, (size_t{1} << (size_bits + 1)) - 1U) << alignment_bits;
Allocate(size, alignment);
}
diff --git a/src/test/fuzz/script_sign.cpp b/src/test/fuzz/script_sign.cpp
index 9ae150e553..4695bc611b 100644
--- a/src/test/fuzz/script_sign.cpp
+++ b/src/test/fuzz/script_sign.cpp
@@ -26,7 +26,7 @@
void initialize_script_sign()
{
- ECC_Start();
+ static ECC_Context ecc_context{};
SelectParams(ChainType::REGTEST);
}
diff --git a/src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp b/src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp
index 74ef6bfd4e..ae0c8479cb 100644
--- a/src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp
+++ b/src/test/fuzz/secp256k1_ecdsa_signature_parse_der_lax.cpp
@@ -24,8 +24,7 @@ FUZZ_TARGET(secp256k1_ecdsa_signature_parse_der_lax)
secp256k1_ecdsa_signature sig_der_lax;
const bool parsed_der_lax = ecdsa_signature_parse_der_lax(&sig_der_lax, signature_bytes.data(), signature_bytes.size()) == 1;
if (parsed_der_lax) {
- ECC_Start();
+ ECC_Context ecc_context{};
(void)SigHasLowR(&sig_der_lax);
- ECC_Stop();
}
}
diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp
index 0b4019d5eb..9f0aedf29b 100644
--- a/src/test/fuzz/tx_pool.cpp
+++ b/src/test/fuzz/tx_pool.cpp
@@ -139,7 +139,6 @@ void CheckATMPInvariants(const MempoolAcceptResult& res, bool txid_in_mempool, b
Assert(wtxid_in_mempool);
Assert(res.m_state.IsValid());
Assert(!res.m_state.IsInvalid());
- Assert(res.m_replaced_transactions);
Assert(res.m_vsize);
Assert(res.m_base_fees);
Assert(res.m_effective_feerate);
@@ -154,7 +153,6 @@ void CheckATMPInvariants(const MempoolAcceptResult& res, bool txid_in_mempool, b
Assert(res.m_state.IsInvalid());
const bool is_reconsiderable{res.m_state.GetResult() == TxValidationResult::TX_RECONSIDERABLE};
- Assert(!res.m_replaced_transactions);
Assert(!res.m_vsize);
Assert(!res.m_base_fees);
// Fee information is provided if the failure is TX_RECONSIDERABLE.
diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp
index 0903f987f6..e666e11758 100644
--- a/src/test/streams_tests.cpp
+++ b/src/test/streams_tests.cpp
@@ -143,8 +143,8 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader)
BOOST_CHECK_EQUAL(reader.size(), 5U);
BOOST_CHECK(!reader.empty());
- // Read a single byte as a signed char.
- signed char b;
+ // Read a single byte as a int8_t.
+ int8_t b;
reader >> b;
BOOST_CHECK_EQUAL(b, -1);
BOOST_CHECK_EQUAL(reader.size(), 4U);
diff --git a/src/test/system_tests.cpp b/src/test/system_tests.cpp
index 2de147deea..baa759e42c 100644
--- a/src/test/system_tests.cpp
+++ b/src/test/system_tests.cpp
@@ -3,9 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <test/util/setup_common.h>
#include <common/run_command.h>
#include <univalue.h>
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 38350b33cc..3b890c09db 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <test/util/setup_common.h>
@@ -185,6 +183,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto
AppInitParameterInteraction(*m_node.args);
LogInstance().StartLogging();
m_node.kernel = std::make_unique<kernel::Context>();
+ m_node.ecc_context = std::make_unique<ECC_Context>();
SetupEnvironment();
ValidationCacheSizes validation_cache_sizes{};
@@ -202,6 +201,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto
BasicTestingSetup::~BasicTestingSetup()
{
+ m_node.ecc_context.reset();
m_node.kernel.reset();
SetMockTime(0s); // Reset mocktime for following tests
LogInstance().DisconnectTestLogger();
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index 8ccf9b571c..dbd66e3585 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -6,6 +6,7 @@
#define BITCOIN_TEST_UTIL_SETUP_COMMON_H
#include <common/args.h> // IWYU pragma: export
+#include <kernel/context.h>
#include <key.h>
#include <node/caches.h>
#include <node/context.h> // IWYU pragma: export
@@ -15,6 +16,7 @@
#include <util/chaintype.h> // IWYU pragma: export
#include <util/check.h>
#include <util/fs.h>
+#include <util/signalinterrupt.h>
#include <util/string.h>
#include <util/vector.h>
diff --git a/src/test/util/txmempool.cpp b/src/test/util/txmempool.cpp
index 71cf8aca60..870cdd0b32 100644
--- a/src/test/util/txmempool.cpp
+++ b/src/test/util/txmempool.cpp
@@ -68,12 +68,6 @@ std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
return strprintf("tx %s unexpectedly failed: %s", wtxid.ToString(), atmp_result.m_state.ToString());
}
- //m_replaced_transactions should exist iff the result was VALID
- if (atmp_result.m_replaced_transactions.has_value() != valid) {
- return strprintf("tx %s result should %shave m_replaced_transactions",
- wtxid.ToString(), valid ? "" : "not ");
- }
-
// m_vsize and m_base_fees should exist iff the result was VALID or MEMPOOL_ENTRY
const bool mempool_entry{atmp_result.m_result_type == MempoolAcceptResult::ResultType::MEMPOOL_ENTRY};
if (atmp_result.m_base_fees.has_value() != (valid || mempool_entry)) {
diff --git a/src/test/util_threadnames_tests.cpp b/src/test/util_threadnames_tests.cpp
index 45d3a58fd3..df5b1a4461 100644
--- a/src/test/util_threadnames_tests.cpp
+++ b/src/test/util_threadnames_tests.cpp
@@ -11,9 +11,7 @@
#include <thread>
#include <vector>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <boost/test/unit_test.hpp>
diff --git a/src/test/validation_chainstate_tests.cpp b/src/test/validation_chainstate_tests.cpp
index fe2d2ba592..1c02066047 100644
--- a/src/test/validation_chainstate_tests.cpp
+++ b/src/test/validation_chainstate_tests.cpp
@@ -12,6 +12,7 @@
#include <test/util/random.h>
#include <test/util/setup_common.h>
#include <uint256.h>
+#include <util/check.h>
#include <validation.h>
#include <vector>
@@ -102,14 +103,14 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
BOOST_CHECK_EQUAL(chainman.GetAll().size(), 2);
- Chainstate& background_cs{*[&] {
+ Chainstate& background_cs{*Assert([&]() -> Chainstate* {
for (Chainstate* cs : chainman.GetAll()) {
if (cs != &chainman.ActiveChainstate()) {
return cs;
}
}
- assert(false);
- }()};
+ return nullptr;
+ }())};
// Append the first block to the background chain.
BlockValidationState state;
diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp
index 82206e56c3..92055ded72 100644
--- a/src/txorphanage.cpp
+++ b/src/txorphanage.cpp
@@ -278,7 +278,7 @@ std::vector<CTransactionRef> TxOrphanage::GetChildrenFromSamePeer(const CTransac
// Convert to a vector of CTransactionRef
std::vector<CTransactionRef> children_found;
children_found.reserve(iters.size());
- for (const auto child_iter : iters) {
+ for (const auto& child_iter : iters) {
children_found.emplace_back(child_iter->second.tx);
}
return children_found;
@@ -310,7 +310,7 @@ std::vector<std::pair<CTransactionRef, NodeId>> TxOrphanage::GetChildrenFromDiff
// Convert iterators to pair<CTransactionRef, NodeId>
std::vector<std::pair<CTransactionRef, NodeId>> children_found;
children_found.reserve(iters.size());
- for (const auto child_iter : iters) {
+ for (const auto& child_iter : iters) {
children_found.emplace_back(child_iter->second.tx, child_iter->second.fromPeer);
}
return children_found;
diff --git a/src/util/check.cpp b/src/util/check.cpp
index c4d4b0cc28..eb3885832b 100644
--- a/src/util/check.cpp
+++ b/src/util/check.cpp
@@ -4,9 +4,7 @@
#include <util/check.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
#include <tinyformat.h>
diff --git a/src/util/fs_helpers.cpp b/src/util/fs_helpers.cpp
index bce5602462..8952f20f79 100644
--- a/src/util/fs_helpers.cpp
+++ b/src/util/fs_helpers.cpp
@@ -5,9 +5,7 @@
#include <util/fs_helpers.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <logging.h>
#include <sync.h>
diff --git a/src/util/subprocess.h b/src/util/subprocess.h
index 4acfa8ff83..e76ced687c 100644
--- a/src/util/subprocess.h
+++ b/src/util/subprocess.h
@@ -159,12 +159,6 @@ public:
//--------------------------------------------------------------------
namespace util
{
- template <typename R>
- inline bool is_ready(std::shared_future<R> const &f)
- {
- return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
- }
-
inline void quote_argument(const std::wstring &argument, std::wstring &command_line,
bool force)
{
@@ -676,8 +670,8 @@ struct error
* This is basically used to determine the length of the actual
* data stored inside the dynamically resized vector.
*
- * This is what is returned as the output to communicate and check_output
- * functions, so, users must know about this class.
+ * This is what is returned as the output to the communicate
+ * function, so, users must know about this class.
*
* OutBuffer and ErrBuffer are just different typedefs to this class.
*/
@@ -688,22 +682,6 @@ public:
explicit Buffer(size_t cap) { buf.resize(cap); }
void add_cap(size_t cap) { buf.resize(cap); }
-#if 0
- Buffer(const Buffer& other):
- buf(other.buf),
- length(other.length)
- {
- std::cout << "COPY" << std::endl;
- }
-
- Buffer(Buffer&& other):
- buf(std::move(other.buf)),
- length(other.length)
- {
- std::cout << "MOVE" << std::endl;
- }
-#endif
-
public:
std::vector<char> buf;
size_t length = 0;
@@ -724,39 +702,9 @@ class Popen;
*/
namespace detail {
-
-// Metaprogram for searching a type within
-// a variadic parameter pack
-// This is particularly required to do a compile time
-// checking of the arguments provided to 'check_output' function
-// wherein the user is not expected to provide an 'output' option.
-
-template <typename... T> struct param_pack{};
-
-template <typename F, typename T> struct has_type;
-
-template <typename F>
-struct has_type<F, param_pack<>> {
- static constexpr bool value = false;
-};
-
-template <typename F, typename... T>
-struct has_type<F, param_pack<F, T...>> {
- static constexpr bool value = true;
-};
-
-template <typename F, typename H, typename... T>
-struct has_type<F, param_pack<H,T...>> {
- static constexpr bool value =
- std::is_same<F, typename std::decay<H>::type>::value ? true : has_type<F, param_pack<T...>>::value;
-};
-
-//----
-
/*!
* A helper class to Popen class for setting
- * options as provided in the Popen constructor
- * or in check_output arguments.
+ * options as provided in the Popen constructor.
* This design allows us to _not_ have any fixed position
* to any arguments and specify them in a way similar to what
* can be done in python.
@@ -948,24 +896,15 @@ private:
* interface to the client.
*
* API's provided by the class:
- * 1. Popen({"cmd"}, output{..}, error{..}, ....)
+ * Popen({"cmd"}, output{..}, error{..}, ....)
* Command provided as a sequence.
- * 2. Popen("cmd arg1"m output{..}, error{..}, ....)
+ * Popen("cmd arg1", output{..}, error{..}, ....)
* Command provided in a single string.
- * 3. wait() - Wait for the child to exit.
- * 4. retcode() - The return code of the exited child.
- * 5. pid() - PID of the spawned child.
- * 6. poll() - Check the status of the running child.
- * 7. kill(sig_num) - Kill the child. SIGTERM used by default.
- * 8. send(...) - Send input to the input channel of the child.
- * 9. communicate(...) - Get the output/error from the child and close the channels
- * from the parent side.
- *10. input() - Get the input channel/File pointer. Can be used for
- * customizing the way of sending input to child.
- *11. output() - Get the output channel/File pointer. Usually used
- in case of redirection. See piping examples.
- *12. error() - Get the error channel/File pointer. Usually used
- in case of redirection.
+ * wait() - Wait for the child to exit.
+ * retcode() - The return code of the exited child.
+ * send(...) - Send input to the input channel of the child.
+ * communicate(...) - Get the output/error from the child and close the channels
+ * from the parent side.
*/
class Popen
{
@@ -1009,27 +948,10 @@ public:
execute_process();
}
-/*
- ~Popen()
- {
-#ifdef __USING_WINDOWS__
- CloseHandle(this->process_handle_);
-#endif
- }
-*/
-
- int pid() const noexcept { return child_pid_; }
-
int retcode() const noexcept { return retcode_; }
int wait() noexcept(false);
- int poll() noexcept(false);
-
- // Does not fail, Caller is expected to recheck the
- // status with a call to poll()
- void kill(int sig_num = 9);
-
void set_out_buf_cap(size_t cap) { stream_.set_out_buf_cap(cap); }
void set_err_buf_cap(size_t cap) { stream_.set_err_buf_cap(cap); }
@@ -1067,15 +989,6 @@ public:
return communicate(nullptr, 0);
}
- FILE* input() { return stream_.input(); }
- FILE* output() { return stream_.output();}
- FILE* error() { return stream_.error(); }
-
- /// Stream close APIs
- void close_input() { stream_.input_.reset(); }
- void close_output() { stream_.output_.reset(); }
- void close_error() { stream_.error_.reset(); }
-
private:
template <typename F, typename... Args>
void init_args(F&& farg, Args&&... args);
@@ -1099,7 +1012,6 @@ private:
std::vector<std::string> vargs_;
std::vector<char*> cargv_;
- bool child_created_ = false;
// Pid of the child process
int child_pid_ = -1;
@@ -1134,7 +1046,7 @@ inline int Popen::wait() noexcept(false)
return 0;
#else
int ret, status;
- std::tie(ret, status) = util::wait_for_child_exit(pid());
+ std::tie(ret, status) = util::wait_for_child_exit(child_pid_);
if (ret == -1) {
if (errno != ECHILD) throw OSError("waitpid failed", errno);
return 0;
@@ -1147,68 +1059,6 @@ inline int Popen::wait() noexcept(false)
#endif
}
-inline int Popen::poll() noexcept(false)
-{
-#ifdef __USING_WINDOWS__
- int ret = WaitForSingleObject(process_handle_, 0);
- if (ret != WAIT_OBJECT_0) return -1;
-
- DWORD dretcode_;
- if (FALSE == GetExitCodeProcess(process_handle_, &dretcode_))
- throw OSError("GetExitCodeProcess", 0);
-
- retcode_ = (int)dretcode_;
- CloseHandle(process_handle_);
-
- return retcode_;
-#else
- if (!child_created_) return -1; // TODO: ??
-
- int status;
-
- // Returns zero if child is still running
- int ret = waitpid(child_pid_, &status, WNOHANG);
- if (ret == 0) return -1;
-
- if (ret == child_pid_) {
- if (WIFSIGNALED(status)) {
- retcode_ = WTERMSIG(status);
- } else if (WIFEXITED(status)) {
- retcode_ = WEXITSTATUS(status);
- } else {
- retcode_ = 255;
- }
- return retcode_;
- }
-
- if (ret == -1) {
- // From subprocess.py
- // This happens if SIGCHLD is set to be ignored
- // or waiting for child process has otherwise been disabled
- // for our process. This child is dead, we cannot get the
- // status.
- if (errno == ECHILD) retcode_ = 0;
- else throw OSError("waitpid failed", errno);
- } else {
- retcode_ = ret;
- }
-
- return retcode_;
-#endif
-}
-
-inline void Popen::kill(int sig_num)
-{
-#ifdef __USING_WINDOWS__
- if (!TerminateProcess(this->process_handle_, (UINT)sig_num)) {
- throw OSError("TerminateProcess", 0);
- }
-#else
- ::kill(child_pid_, sig_num);
-#endif
-}
-
-
inline void Popen::execute_process() noexcept(false)
{
#ifdef __USING_WINDOWS__
@@ -1311,8 +1161,6 @@ inline void Popen::execute_process() noexcept(false)
throw OSError("fork failed", errno);
}
- child_created_ = true;
-
if (child_pid_ == 0)
{
// Close descriptors belonging to parent
diff --git a/src/util/syserror.cpp b/src/util/syserror.cpp
index bac498a23d..6f3a724483 100644
--- a/src/util/syserror.cpp
+++ b/src/util/syserror.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <tinyformat.h>
#include <util/syserror.h>
diff --git a/src/util/threadnames.cpp b/src/util/threadnames.cpp
index 91883fe4ff..ea597dd05a 100644
--- a/src/util/threadnames.cpp
+++ b/src/util/threadnames.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <string>
#include <thread>
diff --git a/src/util/tokenpipe.cpp b/src/util/tokenpipe.cpp
index 3c27d5e523..16fbb664ea 100644
--- a/src/util/tokenpipe.cpp
+++ b/src/util/tokenpipe.cpp
@@ -3,9 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <util/tokenpipe.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#ifndef WIN32
diff --git a/src/util/trace.h b/src/util/trace.h
index b7c275f19b..d9ed65e3aa 100644
--- a/src/util/trace.h
+++ b/src/util/trace.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_UTIL_TRACE_H
#define BITCOIN_UTIL_TRACE_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#ifdef ENABLE_TRACING
diff --git a/src/validation.cpp b/src/validation.cpp
index f57851b4f7..c2b56555a2 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <validation.h>
diff --git a/src/validation.h b/src/validation.h
index e3b2a2d59b..28b045fe80 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -113,7 +113,6 @@ void PruneBlockFilesManual(Chainstate& active_chainstate, int nManualPruneHeight
*| txid in mempool? | yes | no | no* | yes | yes |
*| wtxid in mempool? | yes | no | no* | yes | no |
*| m_state | yes, IsValid() | yes, IsInvalid() | yes, IsInvalid() | yes, IsValid() | yes, IsValid() |
-*| m_replaced_transactions | yes | no | no | no | no |
*| m_vsize | yes | no | no | yes | no |
*| m_base_fees | yes | no | no | yes | no |
*| m_effective_feerate | yes | yes | no | no | no |
@@ -139,7 +138,7 @@ struct MempoolAcceptResult {
const TxValidationState m_state;
/** Mempool transactions replaced by the tx. */
- const std::optional<std::list<CTransactionRef>> m_replaced_transactions;
+ const std::list<CTransactionRef> m_replaced_transactions;
/** Virtual size as used by the mempool, calculated using serialized size and sigops. */
const std::optional<int64_t> m_vsize;
/** Raw base fees in satoshis. */
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index f151fad740..14e988ec1a 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <common/args.h>
#include <init.h>
diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp
index bed9ec029a..65587f0b18 100644
--- a/src/wallet/rpc/addresses.cpp
+++ b/src/wallet/rpc/addresses.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <core_io.h>
#include <key_io.h>
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
index ae2dfe5795..8d3eea59ee 100644
--- a/src/wallet/rpc/backup.cpp
+++ b/src/wallet/rpc/backup.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <chain.h>
#include <clientversion.h>
@@ -458,12 +456,7 @@ RPCHelpMan importpubkey()
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
}
- if (!IsHex(request.params[0].get_str()))
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey must be a hex string");
- std::vector<unsigned char> data(ParseHex(request.params[0].get_str()));
- CPubKey pubKey(data);
- if (!pubKey.IsFullyValid())
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey is not a valid public key");
+ CPubKey pubKey = HexToPubKey(request.params[0].get_str());
{
LOCK(pwallet->cs_wallet);
@@ -985,15 +978,7 @@ static UniValue ProcessImportLegacy(ImportData& import_data, std::map<CKeyID, CP
import_data.witnessscript = std::make_unique<CScript>(parsed_witnessscript.begin(), parsed_witnessscript.end());
}
for (size_t i = 0; i < pubKeys.size(); ++i) {
- const auto& str = pubKeys[i].get_str();
- if (!IsHex(str)) {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey \"" + str + "\" must be a hex string");
- }
- auto parsed_pubkey = ParseHex(str);
- CPubKey pubkey(parsed_pubkey);
- if (!pubkey.IsFullyValid()) {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey \"" + str + "\" is not a valid public key");
- }
+ CPubKey pubkey = HexToPubKey(pubKeys[i].get_str());
pubkey_map.emplace(pubkey.GetID(), pubkey);
ordered_pubkeys.push_back(pubkey.GetID());
}
diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp
index 6060f017ce..1a364a75ed 100644
--- a/src/wallet/rpc/spend.cpp
+++ b/src/wallet/rpc/spend.cpp
@@ -627,15 +627,7 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
const UniValue solving_data = options["solving_data"].get_obj();
if (solving_data.exists("pubkeys")) {
for (const UniValue& pk_univ : solving_data["pubkeys"].get_array().getValues()) {
- const std::string& pk_str = pk_univ.get_str();
- if (!IsHex(pk_str)) {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' is not hex", pk_str));
- }
- const std::vector<unsigned char> data(ParseHex(pk_str));
- const CPubKey pubkey(data.begin(), data.end());
- if (!pubkey.IsFullyValid()) {
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' is not a valid public key", pk_str));
- }
+ const CPubKey pubkey = HexToPubKey(pk_univ.get_str());
coinControl.m_external_provider.pubkeys.emplace(pubkey.GetID(), pubkey);
// Add witness script for pubkeys
const CScript wit_script = GetScriptForDestination(WitnessV0KeyHash(pubkey));
diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp
index a684d4e191..f1cb595271 100644
--- a/src/wallet/rpc/wallet.cpp
+++ b/src/wallet/rpc/wallet.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <core_io.h>
#include <key_io.h>
diff --git a/src/wallet/sqlite.cpp b/src/wallet/sqlite.cpp
index 34f18bf0b1..5e3a8179a2 100644
--- a/src/wallet/sqlite.cpp
+++ b/src/wallet/sqlite.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <wallet/sqlite.h>
diff --git a/src/wallet/test/db_tests.cpp b/src/wallet/test/db_tests.cpp
index f783424df8..438dfceb7f 100644
--- a/src/wallet/test/db_tests.cpp
+++ b/src/wallet/test/db_tests.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <boost/test/unit_test.hpp>
diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h
index 9f2974ece6..a3e6ede81e 100644
--- a/src/wallet/test/util.h
+++ b/src/wallet/test/util.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_WALLET_TEST_UTIL_H
#define BITCOIN_WALLET_TEST_UTIL_H
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addresstype.h>
#include <wallet/db.h>
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8f4171eb15..45f69f52d1 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -5,9 +5,7 @@
#include <wallet/wallet.h>
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <addresstype.h>
#include <blockfilter.h>
#include <chain.h>
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index b1ce7ee4e7..3ba43cdb73 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -3,9 +3,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <wallet/walletdb.h>
diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp
index cda344ab19..7a1930fd31 100644
--- a/src/wallet/wallettool.cpp
+++ b/src/wallet/wallettool.cpp
@@ -2,9 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <wallet/wallettool.h>
diff --git a/src/warnings.cpp b/src/warnings.cpp
index d55eecc48d..38c0554cf2 100644
--- a/src/warnings.cpp
+++ b/src/warnings.cpp
@@ -3,15 +3,12 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#if defined(HAVE_CONFIG_H)
-#include <config/bitcoin-config.h>
-#endif
+#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <warnings.h>
#include <common/system.h>
#include <sync.h>
-#include <util/string.h>
#include <util/translation.h>
#include <optional>
@@ -39,37 +36,30 @@ void SetMedianTimeOffsetWarning(std::optional<bilingual_str> warning)
LOCK(g_warnings_mutex);
g_timeoffset_warning = warning;
}
-bilingual_str GetWarnings(bool verbose)
+
+std::vector<bilingual_str> GetWarnings()
{
- bilingual_str warnings_concise;
- std::vector<bilingual_str> warnings_verbose;
+ std::vector<bilingual_str> warnings;
LOCK(g_warnings_mutex);
// Pre-release build warning
if (!CLIENT_VERSION_IS_RELEASE) {
- warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
- warnings_verbose.emplace_back(warnings_concise);
+ warnings.emplace_back(_("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"));
}
// Misc warnings like out of disk space and clock is wrong
if (!g_misc_warnings.empty()) {
- warnings_concise = g_misc_warnings;
- warnings_verbose.emplace_back(warnings_concise);
+ warnings.emplace_back(g_misc_warnings);
}
if (fLargeWorkInvalidChainFound) {
- warnings_concise = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
- warnings_verbose.emplace_back(warnings_concise);
+ warnings.emplace_back(_("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade."));
}
if (g_timeoffset_warning) {
- warnings_verbose.emplace_back(g_timeoffset_warning.value());
- }
-
- if (verbose) {
- return Join(warnings_verbose, Untranslated("<hr />"));
+ warnings.emplace_back(g_timeoffset_warning.value());
}
- return warnings_concise;
+ return warnings;
}
diff --git a/src/warnings.h b/src/warnings.h
index 866bce6246..79dc2ffabf 100644
--- a/src/warnings.h
+++ b/src/warnings.h
@@ -8,6 +8,7 @@
#include <optional>
#include <string>
+#include <vector>
struct bilingual_str;
@@ -15,12 +16,7 @@ void SetMiscWarning(const bilingual_str& warning);
void SetfLargeWorkInvalidChainFound(bool flag);
/** Pass std::nullopt to disable the warning */
void SetMedianTimeOffsetWarning(std::optional<bilingual_str> warning);
-/** Format a string that describes several potential problems detected by the core.
- * @param[in] verbose bool
- * - if true, get all warnings separated by <hr />
- * - if false, get the most important warning
- * @returns the warning string
- */
-bilingual_str GetWarnings(bool verbose);
+/** Return potential problems detected by the node. */
+std::vector<bilingual_str> GetWarnings();
#endif // BITCOIN_WARNINGS_H