diff options
author | Carl Dong <contact@carldong.me> | 2022-05-25 18:02:54 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2022-06-02 12:22:46 -0400 |
commit | d87784ac87364fc977bbf9769c8bdb72dea8cbf9 (patch) | |
tree | 11ea6e0e53dbd79ec701ea2a12f916becb29cb31 /src/init.cpp | |
parent | 265d6393bf9ef52e7ef7de97ca9c031da82a5ad1 (diff) |
kernel: SanityChecks: Return an error struct
This reduces libbitcoinkernel's coupling with ui_interface and
translation.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/init.cpp b/src/init.cpp index 108f5c99d3..d0fd6074b1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1094,7 +1094,21 @@ static bool LockDataDirectory(bool probeOnly) bool AppInitSanityChecks(const kernel::Context& kernel) { // ********************************************************* Step 4: sanity checks - if (!kernel::SanityChecks(kernel)) { + auto maybe_error = kernel::SanityChecks(kernel); + + if (maybe_error.has_value()) { + switch (maybe_error.value()) { + case kernel::SanityCheckError::ERROR_ECC: + InitError(Untranslated("Elliptic curve cryptography sanity check failure. Aborting.")); + break; + case kernel::SanityCheckError::ERROR_RANDOM: + InitError(Untranslated("OS cryptographic RNG sanity check failure. Aborting.")); + break; + case kernel::SanityCheckError::ERROR_CHRONO: + InitError(Untranslated("Clock epoch mismatch. Aborting.")); + break; + } // no default case, so the compiler can warn about missing cases + return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), PACKAGE_NAME)); } |