diff options
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/common.cpp | 30 | ||||
-rw-r--r-- | src/init/common.h | 16 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/init/common.cpp b/src/init/common.cpp new file mode 100644 index 0000000000..cb24708031 --- /dev/null +++ b/src/init/common.cpp @@ -0,0 +1,30 @@ +// Copyright (c) 2021 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include <crypto/sha256.h> +#include <key.h> +#include <logging.h> +#include <pubkey.h> +#include <random.h> + +#include <memory> + +static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle; + +namespace init { +void SetGlobals() +{ + std::string sha256_algo = SHA256AutoDetect(); + LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo); + RandomInit(); + ECC_Start(); + globalVerifyHandle.reset(new ECCVerifyHandle()); +} + +void UnsetGlobals() +{ + globalVerifyHandle.reset(); + ECC_Stop(); +} +} // namespace init diff --git a/src/init/common.h b/src/init/common.h new file mode 100644 index 0000000000..b201232bfc --- /dev/null +++ b/src/init/common.h @@ -0,0 +1,16 @@ +// Copyright (c) 2021 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +//! @file +//! @brief Common init functions shared by bitcoin-node, bitcoin-wallet, etc. + +#ifndef BITCOIN_INIT_COMMON_H +#define BITCOIN_INIT_COMMON_H + +namespace init { +void SetGlobals(); +void UnsetGlobals(); +} // namespace init + +#endif // BITCOIN_INIT_COMMON_H |