aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2019-07-05 17:21:42 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2019-07-05 17:33:33 +0200
commit8c69fae94410f54bad13be0f34d54370fddbf4b3 (patch)
tree9138baf67dd2b51b3b22deff1504794b467e8af6 /src
parent4f378ac30cf66178564620b4a8ca9cad7f031cc3 (diff)
parentf874e14cd3c84cd412bd3fb42b3ee1706ca6a267 (diff)
Merge #15457: Check std::system for -[alert|block|wallet]notify
f874e14cd3c84cd412bd3fb42b3ee1706ca6a267 [build]: check std::system for -[alert|block|wallet]notify (Sjors Provoost) cc3ad56ff2bc2583fe68c4a9e0b41072a47c0b07 [build] MSVC: set HAVE_SYSTEM for desktop apps (Sjors Provoost) c1c91bb78d7267f01ee3a3c156c218b46a92cd39 [build] detect std::system or ::wsystem (Sjors Provoost) Pull request description: Platforms such as iOs and Universal Windows Platform do not support launching a process through system(). ACKs for top commit: laanwj: code review ACK f874e14cd3c84cd412bd3fb42b3ee1706ca6a267 Tree-SHA512: 16bb4a8fa1896046ccb22a46c8985e1aa45f5b11ecf5539eb2299e9a58f1a5b085c0c12cb6939c7493d93abce7e84fadcbfc73374c887db63da6d00c08aa476d
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp8
-rw-r--r--src/util/system.cpp2
-rw-r--r--src/util/system.h2
-rw-r--r--src/validation.cpp2
-rw-r--r--src/wallet/init.cpp2
-rw-r--r--src/wallet/wallet.cpp2
6 files changed, 18 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 6625080c6e..e2a1b99e37 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -376,10 +376,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);
@@ -579,6 +583,7 @@ std::string LicenseInfo()
"\n";
}
+#if defined(HAVE_SYSTEM)
static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex)
{
if (initialSync || !pBlockIndex)
@@ -591,6 +596,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;
@@ -1708,8 +1714,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")) {
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 87ff6e62ba..0f599b85f1 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -1114,6 +1114,7 @@ fs::path GetSpecialFolderPath(int nFolder, bool fCreate)
}
#endif
+#if defined(HAVE_SYSTEM)
void runCommand(const std::string& strCommand)
{
if (strCommand.empty()) return;
@@ -1125,6 +1126,7 @@ void runCommand(const std::string& strCommand)
if (nErr)
LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
}
+#endif
void SetupEnvironment()
{
diff --git a/src/util/system.h b/src/util/system.h
index 15d7b1b402..fd0583658b 100644
--- a/src/util/system.h
+++ b/src/util/system.h
@@ -89,7 +89,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
diff --git a/src/validation.cpp b/src/validation.cpp
index c6995ed24b..76bbb7920b 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1050,6 +1050,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;
@@ -1063,6 +1064,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)
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 0265433863..0085c3bac9 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -57,7 +57,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);
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 8807acb6b7..70fc06a7e7 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1050,6 +1050,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", "");
@@ -1059,6 +1060,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
std::thread t(runCommand, strCmd);
t.detach(); // thread runs free
}
+#endif
return true;
}