mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
[build]: check std::system for -[alert|block|wallet]notify
Platforms such as iOs do not support launching a process through system().
This commit is contained in:
parent
cc3ad56ff2
commit
f874e14cd3
7 changed files with 19 additions and 1 deletions
|
@ -946,7 +946,7 @@ AC_LINK_IFELSE(
|
|||
)
|
||||
|
||||
# Define to 1 if std::system or ::wsystem (Windows) is available
|
||||
AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [HAVE_WSYSTEM])
|
||||
AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [std::system or ::wsystem])
|
||||
|
||||
LEVELDB_CPPFLAGS=
|
||||
LIBLEVELDB=
|
||||
|
|
|
@ -378,10 +378,14 @@ void SetupServerArgs()
|
|||
"-allowselfsignedrootcertificates", "-choosedatadir", "-lang=<lang>", "-min", "-resetguisettings", "-rootcertificates=<file>", "-splash", "-uiplatform"};
|
||||
|
||||
gArgs.AddArg("-version", "Print version and exit", false, OptionsCategory::OPTIONS);
|
||||
#if defined(HAVE_SYSTEM)
|
||||
gArgs.AddArg("-alertnotify=<cmd>", "Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)", false, OptionsCategory::OPTIONS);
|
||||
#endif
|
||||
gArgs.AddArg("-assumevalid=<hex>", strprintf("If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s)", defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex()), false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-blocksdir=<dir>", "Specify directory to hold blocks subdirectory for *.dat files (default: <datadir>)", false, OptionsCategory::OPTIONS);
|
||||
#if defined(HAVE_SYSTEM)
|
||||
gArgs.AddArg("-blocknotify=<cmd>", "Execute command when the best block changes (%s in cmd is replaced by block hash)", false, OptionsCategory::OPTIONS);
|
||||
#endif
|
||||
gArgs.AddArg("-blockreconstructionextratxn=<n>", strprintf("Extra transactions to keep in memory for compact block reconstructions (default: %u)", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN), false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-blocksonly", strprintf("Whether to reject transactions from network peers. Transactions from the wallet or RPC are not affected. (default: %u)", DEFAULT_BLOCKSONLY), false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), false, OptionsCategory::OPTIONS);
|
||||
|
@ -582,6 +586,7 @@ std::string LicenseInfo()
|
|||
"\n";
|
||||
}
|
||||
|
||||
#if defined(HAVE_SYSTEM)
|
||||
static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex)
|
||||
{
|
||||
if (initialSync || !pBlockIndex)
|
||||
|
@ -594,6 +599,7 @@ static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex
|
|||
t.detach(); // thread runs free
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool fHaveGenesis = false;
|
||||
static Mutex g_genesis_wait_mutex;
|
||||
|
@ -1726,8 +1732,10 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
fHaveGenesis = true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_SYSTEM)
|
||||
if (gArgs.IsArgSet("-blocknotify"))
|
||||
uiInterface.NotifyBlockTip_connect(BlockNotifyCallback);
|
||||
#endif
|
||||
|
||||
std::vector<fs::path> vImportFiles;
|
||||
for (const std::string& strFile : gArgs.GetArgs("-loadblock")) {
|
||||
|
|
|
@ -1122,6 +1122,7 @@ fs::path GetSpecialFolderPath(int nFolder, bool fCreate)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYSTEM)
|
||||
void runCommand(const std::string& strCommand)
|
||||
{
|
||||
if (strCommand.empty()) return;
|
||||
|
@ -1133,6 +1134,7 @@ void runCommand(const std::string& strCommand)
|
|||
if (nErr)
|
||||
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void SetupEnvironment()
|
||||
{
|
||||
|
|
|
@ -90,7 +90,9 @@ fs::path GetConfigFile(const std::string& confPath);
|
|||
#ifdef WIN32
|
||||
fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
||||
#endif
|
||||
#if defined(HAVE_SYSTEM)
|
||||
void runCommand(const std::string& strCommand);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Most paths passed as configuration arguments are treated as relative to
|
||||
|
|
|
@ -1054,6 +1054,7 @@ CBlockIndex *pindexBestForkTip = nullptr, *pindexBestForkBase = nullptr;
|
|||
static void AlertNotify(const std::string& strMessage)
|
||||
{
|
||||
uiInterface.NotifyAlertChanged();
|
||||
#if defined(HAVE_SYSTEM)
|
||||
std::string strCmd = gArgs.GetArg("-alertnotify", "");
|
||||
if (strCmd.empty()) return;
|
||||
|
||||
|
@ -1067,6 +1068,7 @@ static void AlertNotify(const std::string& strMessage)
|
|||
|
||||
std::thread t(runCommand, strCmd);
|
||||
t.detach(); // thread runs free
|
||||
#endif
|
||||
}
|
||||
|
||||
static void CheckForkWarningConditions() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
|
|
|
@ -62,7 +62,9 @@ void WalletInit::AddWalletOptions() const
|
|||
gArgs.AddArg("-wallet=<path>", "Specify wallet database path. Can be specified multiple times to load multiple wallets. Path is interpreted relative to <walletdir> if it is not absolute, and will be created if it does not exist (as a directory containing a wallet.dat file and log files). For backwards compatibility this will also accept names of existing data files in <walletdir>.)", false, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-walletbroadcast", strprintf("Make the wallet broadcast transactions (default: %u)", DEFAULT_WALLETBROADCAST), false, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-walletdir=<dir>", "Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)", false, OptionsCategory::WALLET);
|
||||
#if defined(HAVE_SYSTEM)
|
||||
gArgs.AddArg("-walletnotify=<cmd>", "Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)", false, OptionsCategory::WALLET);
|
||||
#endif
|
||||
gArgs.AddArg("-walletrbf", strprintf("Send transactions with full-RBF opt-in enabled (RPC only, default: %u)", DEFAULT_WALLET_RBF), false, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-zapwallettxes=<mode>", "Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup"
|
||||
" (1 = keep tx meta data e.g. payment request information, 2 = drop tx meta data)", false, OptionsCategory::WALLET);
|
||||
|
|
|
@ -1008,6 +1008,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
|||
// Notify UI of new or updated transaction
|
||||
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
|
||||
|
||||
#if defined(HAVE_SYSTEM)
|
||||
// notify an external script when a wallet transaction comes in or is updated
|
||||
std::string strCmd = gArgs.GetArg("-walletnotify", "");
|
||||
|
||||
|
@ -1017,6 +1018,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
|||
std::thread t(runCommand, strCmd);
|
||||
t.detach(); // thread runs free
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue