mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
Merge 10282 via timebomb_knots
This commit is contained in:
commit
4d81fce30e
@ -130,6 +130,13 @@ static bool ParseArgs(ArgsManager& args, int argc, char* argv[])
|
||||
return InitError(Untranslated(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.", argv[i])));
|
||||
}
|
||||
}
|
||||
|
||||
g_software_expiry = args.GetIntArg("-softwareexpiry", DEFAULT_SOFTWARE_EXPIRY);
|
||||
if (IsThisSoftwareExpired(GetTime())) {
|
||||
tfm::format(std::cerr, "This software is expired, and may be out of consensus. You must choose to upgrade or override this expiration.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -105,3 +105,13 @@ std::string LicenseInfo()
|
||||
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
|
||||
"\n";
|
||||
}
|
||||
|
||||
int64_t g_software_expiry{DEFAULT_SOFTWARE_EXPIRY};
|
||||
|
||||
bool IsThisSoftwareExpired(int64_t nTime)
|
||||
{
|
||||
if (g_software_expiry <= 0) {
|
||||
return false;
|
||||
}
|
||||
return (nTime > g_software_expiry);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#if !defined(WINDRES_PREPROC)
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -46,6 +47,13 @@ std::string CopyrightHolders(const std::string& strPrefix);
|
||||
/** Returns licensing information (for -version) */
|
||||
std::string LicenseInfo();
|
||||
|
||||
static const int64_t SECONDS_PER_YEAR = 31558060;
|
||||
static const int POSIX_EPOCH_YEAR = 1970;
|
||||
static const int64_t DEFAULT_SOFTWARE_EXPIRY = ((COPYRIGHT_YEAR - POSIX_EPOCH_YEAR) * SECONDS_PER_YEAR) + (SECONDS_PER_YEAR * 2);
|
||||
extern int64_t g_software_expiry;
|
||||
|
||||
bool IsThisSoftwareExpired(int64_t nTime);
|
||||
|
||||
#endif // WINDRES_PREPROC
|
||||
|
||||
#endif // BITCOIN_CLIENTVERSION_H
|
||||
|
@ -480,6 +480,7 @@ void SetupServerArgs(ArgsManager& argsman)
|
||||
argsman.AddArg("-reindex", "If enabled, wipe chain state and block index, and rebuild them from blk*.dat files on disk. Also wipe and rebuild other optional indexes that are active. If an assumeutxo snapshot was loaded, its chainstate will be wiped as well. The snapshot can then be reloaded via RPC. Setting this to auto automatically reindexes the block database if it is corrupted.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
argsman.AddArg("-reindex-chainstate", "If enabled, wipe chain state, and rebuild it from blk*.dat files on disk. If an assumeutxo snapshot was loaded, its chainstate will be wiped as well. The snapshot can then be reloaded via RPC.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
argsman.AddArg("-settings=<file>", strprintf("Specify path to dynamic settings data file. Can be disabled with -nosettings. File is written at runtime and not meant to be edited by users (use %s instead for custom settings). Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME, BITCOIN_SETTINGS_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
argsman.AddArg("-softwareexpiry", strprintf("Stop working after this POSIX timestamp (default: %s)", DEFAULT_SOFTWARE_EXPIRY), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS);
|
||||
#if HAVE_SYSTEM
|
||||
argsman.AddArg("-startupnotify=<cmd>", "Execute command on startup.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
argsman.AddArg("-shutdownnotify=<cmd>", "Execute command immediately before beginning shutdown. The need for shutdown may be urgent, so be careful not to delay it long (if the command doesn't require interaction with the server, consider having it fork into the background).", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <qt/bitcoin.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <clientversion.h>
|
||||
#include <common/args.h>
|
||||
#include <common/init.h>
|
||||
#include <common/system.h>
|
||||
@ -652,6 +653,12 @@ int GuiMain(int argc, char* argv[])
|
||||
// Re-initialize translations after changing application name (language in network-specific settings can be different)
|
||||
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
|
||||
|
||||
g_software_expiry = gArgs.GetIntArg("-softwareexpiry", DEFAULT_SOFTWARE_EXPIRY);
|
||||
if (IsThisSoftwareExpired(GetTime())) {
|
||||
QMessageBox::critical(nullptr, QObject::tr("Software expired"), QObject::tr("This software is expired, and may be out of consensus. You must choose to upgrade or override this expiration."));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
/// 8. URI IPC sending
|
||||
// - Do this early as we don't want to bother initializing if we are just calling IPC
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <node/context.h>
|
||||
#include <node/mempool_args.h>
|
||||
@ -113,7 +114,7 @@ void MockTime(FuzzedDataProvider& fuzzed_data_provider, const Chainstate& chains
|
||||
{
|
||||
const auto time = ConsumeTime(fuzzed_data_provider,
|
||||
chainstate.m_chain.Tip()->GetMedianTimePast() + 1,
|
||||
std::numeric_limits<decltype(chainstate.m_chain.Tip()->nTime)>::max());
|
||||
DEFAULT_SOFTWARE_EXPIRY - 1);
|
||||
SetMockTime(time);
|
||||
}
|
||||
|
||||
|
@ -3845,6 +3845,10 @@ static bool CheckBlockHeader(const CBlockHeader& block, BlockValidationState& st
|
||||
if (fCheckPOW && !CheckProofOfWork(block.GetHash(), block.nBits, consensusParams))
|
||||
return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "high-hash", "proof of work failed");
|
||||
|
||||
if (IsThisSoftwareExpired(block.nTime)) {
|
||||
return state.Invalid(BlockValidationResult::BLOCK_TIME_FUTURE, "node-expired", "node software has expired");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,10 @@ class TestNode():
|
||||
"--error-exitcode=1", "--quiet"] + self.args
|
||||
|
||||
if self.version is None:
|
||||
self.args.append("-walletimplicitsegwit")
|
||||
self.args += [
|
||||
"-softwareexpiry=0",
|
||||
"-walletimplicitsegwit",
|
||||
]
|
||||
|
||||
if self.version_is_at_least(190000):
|
||||
self.args.append("-logthreadnames")
|
||||
|
Loading…
Reference in New Issue
Block a user