Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
kernel_notifications.cpp
Go to the documentation of this file.
1// Copyright (c) 2023 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
6
7#if defined(HAVE_CONFIG_H)
8#include <config/bitcoin-config.h>
9#endif
10
11#include <common/args.h>
12#include <common/system.h>
13#include <node/ui_interface.h>
14#include <util/strencodings.h>
15#include <util/string.h>
16#include <util/translation.h>
17
18#include <cstdint>
19#include <string>
20#include <thread>
21
22static void AlertNotify(const std::string &strMessage) {
23 uiInterface.NotifyAlertChanged();
24#if defined(HAVE_SYSTEM)
25 std::string strCmd = gArgs.GetArg("-alertnotify", "");
26 if (strCmd.empty()) {
27 return;
28 }
29
30 // Alert text should be plain ascii coming from a trusted source, but to be
31 // safe we first strip anything not in safeChars, then add single quotes
32 // around the whole string before passing it to the shell:
33 std::string singleQuote("'");
37
38 std::thread t(runCommand, strCmd);
39 // thread runs free
40 t.detach();
41#endif
42}
43
44namespace node {
45
47 CBlockIndex &index) {
48 uiInterface.NotifyBlockTip(state, &index);
49}
50
53 uiInterface.NotifyHeaderTip(state, height, timestamp, presync);
54}
55
61
62void KernelNotifications::warning(const std::string &warning) {
64}
65
66} // namespace node
ArgsManager gArgs
Definition args.cpp:38
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition args.cpp:494
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition blockindex.h:25
void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override
void progress(const bilingual_str &title, int progress_percent, bool resume_possible) override
void warning(const std::string &warning) override
void blockTip(SynchronizationState state, CBlockIndex &index) override
static void AlertNotify(const std::string &strMessage)
Definition init.h:28
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
void ReplaceAll(std::string &in_out, const std::string &search, const std::string &substitute)
Definition string.cpp:10
Bilingual messages:
Definition translation.h:17
std::string translated
Definition translation.h:19
CClientUIInterface uiInterface
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition validation.h:113