mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
merge bitcoin#15457: Check std::system for -[alert|block|wallet|instantsend]notify
This commit is contained in:
parent
589afdc824
commit
6627bc9688
23
configure.ac
23
configure.ac
@ -1206,6 +1206,29 @@ if test x$use_reduce_exports = xyes; then
|
||||
[AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduce-exports.])])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for std::system])
|
||||
AC_LINK_IFELSE(
|
||||
[ AC_LANG_PROGRAM(
|
||||
[[ #include <cstdlib> ]],
|
||||
[[ int nErr = std::system(""); ]]
|
||||
)],
|
||||
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STD__SYSTEM, 1, Define to 1 if you have the `std::system' function.)],
|
||||
[ AC_MSG_RESULT(no) ]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([for ::_wsystem])
|
||||
AC_LINK_IFELSE(
|
||||
[ AC_LANG_PROGRAM(
|
||||
[[ ]],
|
||||
[[ int nErr = ::_wsystem(""); ]]
|
||||
)],
|
||||
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WSYSTEM, 1, Define to 1 if you have the `::wsystem' function.)],
|
||||
[ AC_MSG_RESULT(no) ]
|
||||
)
|
||||
|
||||
# Define to 1 if std::system or ::wsystem (Windows) is available
|
||||
AC_DEFINE([HAVE_SYSTEM], [HAVE_STD__SYSTEM || HAVE_WSYSTEM], [std::system or ::wsystem])
|
||||
|
||||
dnl SUPPRESSED_CPPFLAGS=SUPPRESS_WARNINGS([$SOME_CPPFLAGS])
|
||||
dnl Replace -I with -isystem in $SOME_CPPFLAGS to suppress warnings from
|
||||
dnl headers from its include directories and return the result.
|
||||
|
@ -489,10 +489,14 @@ void SetupServerArgs(NodeContext& node)
|
||||
// Set all of the args and their help
|
||||
// When adding new options to the categories, please keep and ensure alphabetical ordering.
|
||||
gArgs.AddArg("-?", "Print this help message and exit", ArgsManager::ALLOW_ANY, 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)", ArgsManager::ALLOW_ANY, 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()), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-blocksdir=<dir>", "Specify directory to hold blocks subdirectory for *.dat files (default: <datadir>)", ArgsManager::ALLOW_ANY, 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)", ArgsManager::ALLOW_ANY, 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), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-blocksonly", strprintf("Whether to reject transactions from network peers. Automatic broadcast and rebroadcast of any transactions from inbound peers is disabled, unless '-whitelistforcerelay' is '1', in which case whitelisted peers' transactions will be relayed. RPC transactions are not affected. (default: %u)", DEFAULT_BLOCKSONLY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||
@ -786,6 +790,7 @@ std::string LicenseInfo()
|
||||
"\n";
|
||||
}
|
||||
|
||||
#if defined(HAVE_SYSTEM)
|
||||
static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex)
|
||||
{
|
||||
if (initialSync || !pBlockIndex)
|
||||
@ -798,6 +803,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;
|
||||
@ -2420,8 +2426,10 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||
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")) {
|
||||
|
@ -1088,6 +1088,7 @@ fs::path GetSpecialFolderPath(int nFolder, bool fCreate)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYSTEM)
|
||||
void runCommand(const std::string& strCommand)
|
||||
{
|
||||
if (strCommand.empty()) return;
|
||||
@ -1099,6 +1100,7 @@ void runCommand(const std::string& strCommand)
|
||||
if (nErr)
|
||||
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void RenameThreadPool(ctpl::thread_pool& tp, const char* baseName)
|
||||
{
|
||||
|
@ -101,7 +101,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
|
||||
|
@ -1190,6 +1190,7 @@ static 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;
|
||||
|
||||
@ -1203,6 +1204,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)
|
||||
|
@ -47,7 +47,9 @@ void WalletInit::AddWalletOptions() const
|
||||
gArgs.AddArg("-avoidpartialspends", strprintf("Group outputs by address, selecting all or none, instead of selecting on a per-output basis. Privacy is improved as an address is only used once (unless someone sends to it after spending from it), but may result in slightly higher fees as suboptimal coin selection may result due to the added limitation (default: %u)", DEFAULT_AVOIDPARTIALSPENDS), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-createwalletbackups=<n>", strprintf("Number of automatic wallet backups (default: %u)", nWalletBackups), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-disablewallet", "Do not load the wallet and disable wallet RPC calls", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
#if defined(HAVE_SYSTEM)
|
||||
gArgs.AddArg("-instantsendnotify=<cmd>", "Execute command when a wallet InstantSend transaction is successfully locked (%s in cmd is replaced by TxID)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
#endif
|
||||
gArgs.AddArg("-keypool=<n>", strprintf("Set key pool size to <n> (default: %u)", DEFAULT_KEYPOOL_SIZE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-rescan=<mode>", "Rescan the block chain for missing wallet transactions on startup"
|
||||
" (1 = start from wallet creation time, 2 = start from genesis block)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
@ -57,7 +59,9 @@ void WalletInit::AddWalletOptions() const
|
||||
gArgs.AddArg("-walletbackupsdir=<dir>", "Specify full path to directory for automatic wallet backups (must exist)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-walletbroadcast", strprintf("Make the wallet broadcast transactions (default: %u)", DEFAULT_WALLETBROADCAST), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
gArgs.AddArg("-walletdir=<dir>", "Specify directory to hold wallets (default: <datadir>/wallets if it exists, otherwise <datadir>)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
#if defined(HAVE_SYSTEM)
|
||||
gArgs.AddArg("-walletnotify=<cmd>", "Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||
#endif
|
||||
|
||||
gArgs.AddArg("-discardfee=<amt>", strprintf("The fee rate (in %s/kB) that indicates your tolerance for discarding change by adding it to the fee (default: %s). "
|
||||
"Note: An output is discarded if it is dust at this rate, but we will always discard up to the dust relay fee and a discard fee above that is limited by the fee estimate for the longest target",
|
||||
|
@ -1255,6 +1255,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", "");
|
||||
|
||||
@ -1264,6 +1265,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
||||
std::thread t(runCommand, strCmd);
|
||||
t.detach(); // thread runs free
|
||||
}
|
||||
#endif
|
||||
|
||||
fAnonymizableTallyCached = false;
|
||||
fAnonymizableTallyCachedNonDenom = false;
|
||||
@ -5482,6 +5484,7 @@ void CWallet::NotifyTransactionLock(const CTransactionRef &tx, const std::shared
|
||||
if (mi != mapWallet.end()){
|
||||
NotifyTransactionChanged(this, txHash, CT_UPDATED);
|
||||
NotifyISLockReceived();
|
||||
#if defined(HAVE_SYSTEM)
|
||||
// notify an external script
|
||||
std::string strCmd = gArgs.GetArg("-instantsendnotify", "");
|
||||
if (!strCmd.empty()) {
|
||||
@ -5489,6 +5492,7 @@ void CWallet::NotifyTransactionLock(const CTransactionRef &tx, const std::shared
|
||||
std::thread t(runCommand, strCmd);
|
||||
t.detach(); // thread runs free
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user