aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/chainparams.cpp35
-rw-r--r--src/kernel/chainparams.h3
-rw-r--r--src/kernel/chainstatemanager_opts.h2
-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/kernel/mempool_persist.cpp6
-rw-r--r--src/kernel/notifications_interface.h5
-rw-r--r--src/kernel/warning.h14
9 files changed, 60 insertions, 23 deletions
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index 26c261eba2..bf3a340cb8 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -29,7 +29,7 @@
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CMutableTransaction txNew;
- txNew.nVersion = 1;
+ txNew.version = 1;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
@@ -140,6 +140,7 @@ public:
vSeeds.emplace_back("seed.bitcoin.sprovoost.nl."); // Sjors Provoost
vSeeds.emplace_back("dnsseed.emzy.de."); // Stephan Oeste
vSeeds.emplace_back("seed.bitcoin.wiz.biz."); // Jason Maurice
+ vSeeds.emplace_back("seed.mainnet.achownodes.xyz."); // Ava Chow, only supports x1, x5, x9, x49, x809, x849, xd, x400, x404, x408, x448, xc08, xc48, x40c
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
@@ -246,6 +247,7 @@ public:
vSeeds.emplace_back("seed.tbtc.petertodd.net.");
vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl.");
vSeeds.emplace_back("testnet-seed.bluematt.me."); // Just a static list of stable node(s), only supports x9
+ vSeeds.emplace_back("seed.testnet.achownodes.xyz."); // Ava Chow, only supports x1, x5, x9, x49, x809, x849, xd, x400, x404, x408, x448, xc08, xc48, x40c
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
@@ -297,6 +299,7 @@ public:
if (!options.challenge) {
bin = ParseHex("512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be430210359ef5021964fe22d6f8e05b2463c9540ce96883fe3b278760f048f5189f2e6c452ae");
vSeeds.emplace_back("seed.signet.bitcoin.sprovoost.nl.");
+ vSeeds.emplace_back("seed.signet.achownodes.xyz."); // Ava Chow, only supports x1, x5, x9, x49, x809, x849, xd, x400, x404, x408, x448, xc08, xc48, x40c
// Hardcoded nodes can be removed once there are more DNS seeds
vSeeds.emplace_back("178.128.221.177");
@@ -542,3 +545,33 @@ std::unique_ptr<const CChainParams> CChainParams::TestNet()
{
return std::make_unique<const CTestNetParams>();
}
+
+std::vector<int> CChainParams::GetAvailableSnapshotHeights() const
+{
+ std::vector<int> heights;
+ heights.reserve(m_assumeutxo_data.size());
+
+ for (const auto& data : m_assumeutxo_data) {
+ heights.emplace_back(data.height);
+ }
+ return heights;
+}
+
+std::optional<ChainType> GetNetworkForMagic(const MessageStartChars& message)
+{
+ const auto mainnet_msg = CChainParams::Main()->MessageStart();
+ const auto testnet_msg = CChainParams::TestNet()->MessageStart();
+ const auto regtest_msg = CChainParams::RegTest({})->MessageStart();
+ const auto signet_msg = CChainParams::SigNet({})->MessageStart();
+
+ if (std::equal(message.begin(), message.end(), mainnet_msg.data())) {
+ return ChainType::MAIN;
+ } else if (std::equal(message.begin(), message.end(), testnet_msg.data())) {
+ return ChainType::TESTNET;
+ } else if (std::equal(message.begin(), message.end(), regtest_msg.data())) {
+ return ChainType::REGTEST;
+ } else if (std::equal(message.begin(), message.end(), signet_msg.data())) {
+ return ChainType::SIGNET;
+ }
+ return std::nullopt;
+}
diff --git a/src/kernel/chainparams.h b/src/kernel/chainparams.h
index 7a5539bc71..05ebd07ec7 100644
--- a/src/kernel/chainparams.h
+++ b/src/kernel/chainparams.h
@@ -93,6 +93,7 @@ public:
const Consensus::Params& GetConsensus() const { return consensus; }
const MessageStartChars& MessageStart() const { return pchMessageStart; }
uint16_t GetDefaultPort() const { return nDefaultPort; }
+ std::vector<int> GetAvailableSnapshotHeights() const;
const CBlock& GenesisBlock() const { return genesis; }
/** Default value for -checkmempool and -checkblockindex argument */
@@ -183,4 +184,6 @@ protected:
ChainTxData chainTxData;
};
+std::optional<ChainType> GetNetworkForMagic(const MessageStartChars& pchMessageStart);
+
#endif // BITCOIN_KERNEL_CHAINPARAMS_H
diff --git a/src/kernel/chainstatemanager_opts.h b/src/kernel/chainstatemanager_opts.h
index de5f78494a..076841c3c9 100644
--- a/src/kernel/chainstatemanager_opts.h
+++ b/src/kernel/chainstatemanager_opts.h
@@ -33,7 +33,7 @@ namespace kernel {
struct ChainstateManagerOpts {
const CChainParams& chainparams;
fs::path datadir;
- std::optional<bool> check_block_index{};
+ std::optional<int32_t> check_block_index{};
bool checkpoints_enabled{DEFAULT_CHECKPOINTS_ENABLED};
//! If set, it will override the minimum work we will assume exists on some valid chain.
std::optional<arith_uint256> minimum_chain_work{};
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/kernel/mempool_persist.cpp b/src/kernel/mempool_persist.cpp
index f06f609379..53028a45ae 100644
--- a/src/kernel/mempool_persist.cpp
+++ b/src/kernel/mempool_persist.cpp
@@ -96,7 +96,7 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
if (amountdelta && opts.apply_fee_delta_priority) {
pool.PrioritiseTransaction(tx->GetHash(), amountdelta);
}
- if (nTime > TicksSinceEpoch<std::chrono::seconds>(now - pool.m_expiry)) {
+ if (nTime > TicksSinceEpoch<std::chrono::seconds>(now - pool.m_opts.expiry)) {
LOCK(cs_main);
const auto& accepted = AcceptToMemoryPool(active_chainstate, tx, nTime, /*bypass_limits=*/false, /*test_accept=*/false);
if (accepted.m_result_type == MempoolAcceptResult::ResultType::VALID) {
@@ -174,11 +174,11 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
}
try {
- const uint64_t version{pool.m_persist_v1_dat ? MEMPOOL_DUMP_VERSION_NO_XOR_KEY : MEMPOOL_DUMP_VERSION};
+ const uint64_t version{pool.m_opts.persist_v1_dat ? MEMPOOL_DUMP_VERSION_NO_XOR_KEY : MEMPOOL_DUMP_VERSION};
file << version;
std::vector<std::byte> xor_key(8);
- if (!pool.m_persist_v1_dat) {
+ if (!pool.m_opts.persist_v1_dat) {
FastRandomContext{}.fillrand(xor_key);
file << xor_key;
}
diff --git a/src/kernel/notifications_interface.h b/src/kernel/notifications_interface.h
index 7283a88e86..8e090dd7db 100644
--- a/src/kernel/notifications_interface.h
+++ b/src/kernel/notifications_interface.h
@@ -16,6 +16,8 @@ namespace kernel {
//! Result type for use with std::variant to indicate that an operation should be interrupted.
struct Interrupted{};
+enum class Warning;
+
//! Simple result type for functions that need to propagate an interrupt status and don't have other return values.
using InterruptResult = std::variant<std::monostate, Interrupted>;
@@ -38,7 +40,8 @@ public:
[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index) { return {}; }
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}
- virtual void warning(const bilingual_str& warning) {}
+ virtual void warningSet(Warning id, const bilingual_str& message) {}
+ virtual void warningUnset(Warning id) {}
//! The flush error notification is sent to notify the user that an error
//! occurred while flushing block data to disk. Kernel code may ignore flush
diff --git a/src/kernel/warning.h b/src/kernel/warning.h
new file mode 100644
index 0000000000..453f36c552
--- /dev/null
+++ b/src/kernel/warning.h
@@ -0,0 +1,14 @@
+// Copyright (c) 2024-present The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_KERNEL_WARNING_H
+#define BITCOIN_KERNEL_WARNING_H
+
+namespace kernel {
+enum class Warning {
+ UNKNOWN_NEW_RULES_ACTIVATED,
+ LARGE_WORK_INVALID_CHAIN,
+};
+} // namespace kernel
+#endif // BITCOIN_KERNEL_WARNING_H