Wrap boost::replace_all

This commit is contained in:
MacroFake
2022-05-05 08:28:29 +02:00
parent c367736f85
commit fa2deae2a8
8 changed files with 22 additions and 19 deletions

View File

@@ -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