Add regtest support to bitcoin-chainstate tool

Adds -regtest flag to enable testing with regtest chain parameters.
This commit is contained in:
stringintech
2025-10-27 21:21:07 +03:30
parent 516ae5ede4
commit 5f3d6bdb66

View File

@@ -144,16 +144,18 @@ public:
int main(int argc, char* argv[])
{
// SETUP: Argument parsing and handling
if (argc != 2) {
const bool has_regtest_flag{argc == 3 && std::string(argv[1]) == "-regtest"};
if (argc < 2 || argc > 3 || (argc == 3 && !has_regtest_flag)) {
std::cerr
<< "Usage: " << argv[0] << " DATADIR" << std::endl
<< "Usage: " << argv[0] << " [-regtest] DATADIR" << std::endl
<< "Display DATADIR information, and process hex-encoded blocks on standard input." << std::endl
<< "Uses mainnet parameters by default, regtest with -regtest flag" << std::endl
<< std::endl
<< "IMPORTANT: THIS EXECUTABLE IS EXPERIMENTAL, FOR TESTING ONLY, AND EXPECTED TO" << std::endl
<< " BREAK IN FUTURE VERSIONS. DO NOT USE ON YOUR ACTUAL DATADIR." << std::endl;
return 1;
}
std::filesystem::path abs_datadir{std::filesystem::absolute(argv[1])};
std::filesystem::path abs_datadir{std::filesystem::absolute(argv[argc-1])};
std::filesystem::create_directories(abs_datadir);
btck_LoggingOptions logging_options = {
@@ -169,7 +171,7 @@ int main(int argc, char* argv[])
Logger logger{std::make_unique<KernelLog>()};
ContextOptions options{};
ChainParams params{ChainType::MAINNET};
ChainParams params{has_regtest_flag ? ChainType::REGTEST : ChainType::MAINNET};
options.SetChainParams(params);
options.SetNotifications(std::make_shared<TestKernelNotifications>());