aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/init.cpp3
-rw-r--r--src/torcontrol.cpp4
-rw-r--r--src/util/string.cpp7
-rw-r--r--src/util/string.h4
-rw-r--r--src/util/system.cpp3
-rw-r--r--src/validation.cpp5
-rw-r--r--src/wallet/wallet.cpp14
8 files changed, 22 insertions, 19 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b9958f96be..357e562c69 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -919,6 +919,7 @@ libbitcoinkernel_la_SOURCES = \
util/serfloat.cpp \
util/settings.cpp \
util/strencodings.cpp \
+ util/string.cpp \
util/syscall_sandbox.cpp \
util/syserror.cpp \
util/system.cpp \
diff --git a/src/init.cpp b/src/init.cpp
index 13a4b3f433..713598f411 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -92,7 +92,6 @@
#include <sys/stat.h>
#endif
-#include <boost/algorithm/string/replace.hpp>
#include <boost/signals2/signal.hpp>
#if ENABLE_ZMQ
@@ -1641,7 +1640,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
uiInterface.NotifyBlockTip_connect([block_notify](SynchronizationState sync_state, const CBlockIndex* pBlockIndex) {
if (sync_state != SynchronizationState::POST_INIT || !pBlockIndex) return;
std::string command = block_notify;
- boost::replace_all(command, "%s", pBlockIndex->GetBlockHash().GetHex());
+ ReplaceAll(command, "%s", pBlockIndex->GetBlockHash().GetHex());
std::thread t(runCommand, command);
t.detach(); // thread runs free
});
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index e2a7cb4066..05dbc6057f 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -24,8 +24,6 @@
#include <set>
#include <vector>
-#include <boost/algorithm/string/replace.hpp>
-
#include <event2/buffer.h>
#include <event2/bufferevent.h>
#include <event2/event.h>
@@ -566,7 +564,7 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro
if (!torpassword.empty()) {
if (methods.count("HASHEDPASSWORD")) {
LogPrint(BCLog::TOR, "tor: Using HASHEDPASSWORD authentication\n");
- boost::replace_all(torpassword, "\"", "\\\"");
+ ReplaceAll(torpassword, "\"", "\\\"");
_conn.Command("AUTHENTICATE \"" + torpassword + "\"", std::bind(&TorController::auth_cb, this, std::placeholders::_1, std::placeholders::_2));
} else {
LogPrintf("tor: Password provided with -torpassword, but HASHEDPASSWORD authentication is not available\n");
diff --git a/src/util/string.cpp b/src/util/string.cpp
index 8ea3a1afc6..d05222e8b8 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -3,3 +3,10 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <util/string.h>
+
+#include <boost/algorithm/string/replace.hpp>
+
+void ReplaceAll(std::string& in_out, std::string_view search, std::string_view substitute)
+{
+ boost::replace_all(in_out, search, substitute);
+}
diff --git a/src/util/string.h b/src/util/string.h
index 2e91347b27..df20e34ae9 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -5,11 +5,11 @@
#ifndef BITCOIN_UTIL_STRING_H
#define BITCOIN_UTIL_STRING_H
-#include <attributes.h>
#include <util/spanparsing.h>
#include <algorithm>
#include <array>
+#include <cstdint>
#include <cstring>
#include <locale>
#include <sstream>
@@ -17,6 +17,8 @@
#include <string_view>
#include <vector>
+void ReplaceAll(std::string& in_out, std::string_view search, std::string_view substitute);
+
[[nodiscard]] inline std::vector<std::string> SplitString(std::string_view str, char sep)
{
return spanparsing::Split<std::string>(str, sep);
diff --git a/src/util/system.cpp b/src/util/system.cpp
index facf6855cb..44ebf5cb3e 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -76,7 +76,6 @@
#include <malloc.h>
#endif
-#include <boost/algorithm/string/replace.hpp>
#include <univalue.h>
#include <fstream>
@@ -1253,7 +1252,7 @@ fs::path GetSpecialFolderPath(int nFolder, bool fCreate)
std::string ShellEscape(const std::string& arg)
{
std::string escaped = arg;
- boost::replace_all(escaped, "'", "'\"'\"'");
+ ReplaceAll(escaped, "'", "'\"'\"'");
return "'" + escaped + "'";
}
#endif
diff --git a/src/validation.cpp b/src/validation.cpp
index 5a2bee2418..4614fc1402 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -55,12 +55,11 @@
#include <warnings.h>
#include <algorithm>
+#include <deque>
#include <numeric>
#include <optional>
#include <string>
-#include <boost/algorithm/string/replace.hpp>
-
using node::BLOCKFILE_CHUNK_SIZE;
using node::BlockManager;
using node::BlockMap;
@@ -1577,7 +1576,7 @@ static void AlertNotify(const std::string& strMessage)
std::string singleQuote("'");
std::string safeStatus = SanitizeString(strMessage);
safeStatus = singleQuote+safeStatus+singleQuote;
- boost::replace_all(strCmd, "%s", safeStatus);
+ ReplaceAll(strCmd, "%s", safeStatus);
std::thread t(runCommand, strCmd);
t.detach(); // thread runs free
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 79faf29907..356d0ce5a0 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -44,8 +44,6 @@
#include <assert.h>
#include <optional>
-#include <boost/algorithm/string/replace.hpp>
-
using interfaces::FoundBlock;
namespace wallet {
@@ -1018,14 +1016,14 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const
if (!strCmd.empty())
{
- boost::replace_all(strCmd, "%s", hash.GetHex());
+ ReplaceAll(strCmd, "%s", hash.GetHex());
if (auto* conf = wtx.state<TxStateConfirmed>())
{
- boost::replace_all(strCmd, "%b", conf->confirmed_block_hash.GetHex());
- boost::replace_all(strCmd, "%h", ToString(conf->confirmed_block_height));
+ ReplaceAll(strCmd, "%b", conf->confirmed_block_hash.GetHex());
+ ReplaceAll(strCmd, "%h", ToString(conf->confirmed_block_height));
} else {
- boost::replace_all(strCmd, "%b", "unconfirmed");
- boost::replace_all(strCmd, "%h", "-1");
+ ReplaceAll(strCmd, "%b", "unconfirmed");
+ ReplaceAll(strCmd, "%h", "-1");
}
#ifndef WIN32
// Substituting the wallet name isn't currently supported on windows
@@ -1033,7 +1031,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const
// https://github.com/bitcoin/bitcoin/pull/13339#issuecomment-537384875
// A few ways it could be implemented in the future are described in:
// https://github.com/bitcoin/bitcoin/pull/13339#issuecomment-461288094
- boost::replace_all(strCmd, "%w", ShellEscape(GetName()));
+ ReplaceAll(strCmd, "%w", ShellEscape(GetName()));
#endif
std::thread t(runCommand, strCmd);
t.detach(); // thread runs free