Merge #17197: [0.19.0] Backports
334e27ed5a
util: Filter out macOS process serial number (Hennadii Stepanov)e1bacb591a
rpc: fix -rpcclienttimeout 0 option (Fabian Jahr)6a45766acb
doc: update bips.md with buried BIP9 deployments (MarcoFalke)dc0fe7ae1f
util: Filter control characters out of log messages (Wladimir J. van der Laan)ba46f39418
init: Change fallback locale to C.UTF-8 (Wladimir J. van der Laan) Pull request description: Backports the following PRs to the `0.19.0` [branch](https://github.com/bitcoin/bitcoin/tree/0.19): * #17184 - util: Filter out macOS process serial number * #17131 - rpc: fix -rpcclienttimeout 0 option * #17111 - doc: update bips.md with buried BIP9 deployments * #17095 - util: Filter control characters out of log messages * #17085 - init: Change fallback locale to C.UTF-8 ACKs for top commit: laanwj: ACK334e27ed5a
Tree-SHA512: 436064c00f98bae8475d0e46ab104df6fc9bdae4927dcdd5cffa4242704256c749352e9cabb23cf806911b1c303ddcb0208a42d540412e98da2513176e5e1023
This commit is contained in:
commit
5b68d1654f
5 changed files with 73 additions and 11 deletions
14
doc/bips.md
14
doc/bips.md
|
@ -18,23 +18,23 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.19.0**):
|
|||
* [`BIP 61`](https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki): The 'reject' protocol message (and the protocol version bump to 70002) was added in **v0.9.0** ([PR #3185](https://github.com/bitcoin/bitcoin/pull/3185)). Starting **v0.17.0**, whether to send reject messages can be configured with the `-enablebip61` option, and support is deprecated as of **v0.18.0**.
|
||||
* [`BIP 65`](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki): The CHECKLOCKTIMEVERIFY softfork was merged in **v0.12.0** ([PR #6351](https://github.com/bitcoin/bitcoin/pull/6351)), and backported to **v0.11.2** and **v0.10.4**. Mempool-only CLTV was added in [PR #6124](https://github.com/bitcoin/bitcoin/pull/6124).
|
||||
* [`BIP 66`](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki): The strict DER rules and associated version 3 blocks have been implemented since **v0.10.0** ([PR #5713](https://github.com/bitcoin/bitcoin/pull/5713)).
|
||||
* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki): Sequence locks have been implemented as of **v0.12.1** ([PR #7184](https://github.com/bitcoin/bitcoin/pull/7184)), and have been activated since *block 419328*.
|
||||
* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki): Sequence locks have been implemented as of **v0.12.1** ([PR #7184](https://github.com/bitcoin/bitcoin/pull/7184)), and have been *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
|
||||
* [`BIP 70`](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki) [`71`](https://github.com/bitcoin/bips/blob/master/bip-0071.mediawiki) [`72`](https://github.com/bitcoin/bips/blob/master/bip-0072.mediawiki): Payment Protocol support has been available in Bitcoin Core GUI since **v0.9.0** ([PR #5216](https://github.com/bitcoin/bitcoin/pull/5216)). Support can be optionally disabled at build time since **v0.18.0** ([PR 14451](https://github.com/bitcoin/bitcoin/pull/14451)), and is disabled by default at build time since **v0.19.0** ([PR #15584](https://github.com/bitcoin/bitcoin/pull/15584)).
|
||||
* [`BIP 90`](https://github.com/bitcoin/bips/blob/master/bip-0090.mediawiki): Trigger mechanism for activation of BIPs 34, 65, and 66 has been simplified to block height checks since **v0.14.0** ([PR #8391](https://github.com/bitcoin/bitcoin/pull/8391)).
|
||||
* [`BIP 111`](https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki): `NODE_BLOOM` service bit added, and enforced for all peer versions as of **v0.13.0** ([PR #6579](https://github.com/bitcoin/bitcoin/pull/6579) and [PR #6641](https://github.com/bitcoin/bitcoin/pull/6641)).
|
||||
* [`BIP 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki): The CHECKSEQUENCEVERIFY opcode has been implemented since **v0.12.1** ([PR #7524](https://github.com/bitcoin/bitcoin/pull/7524)) and has been activated since *block 419328*.
|
||||
* [`BIP 113`](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki): Median time past lock-time calculations have been implemented since **v0.12.1** ([PR #6566](https://github.com/bitcoin/bitcoin/pull/6566)) and have been activated since *block 419328*.
|
||||
* [`BIP 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki): The CHECKSEQUENCEVERIFY opcode has been implemented since **v0.12.1** ([PR #7524](https://github.com/bitcoin/bitcoin/pull/7524)), and has been *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
|
||||
* [`BIP 113`](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki): Median time past lock-time calculations have been implemented since **v0.12.1** ([PR #6566](https://github.com/bitcoin/bitcoin/pull/6566)), and has been *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
|
||||
* [`BIP 125`](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki): Opt-in full replace-by-fee signaling honoured in mempool and mining as of **v0.12.0** ([PR 6871](https://github.com/bitcoin/bitcoin/pull/6871)). Enabled by default in the wallet GUI as of **v0.18.1** ([PR #11605](https://github.com/bitcoin/bitcoin/pull/11605))
|
||||
* [`BIP 130`](https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki): direct headers announcement is negotiated with peer versions `>=70012` as of **v0.12.0** ([PR 6494](https://github.com/bitcoin/bitcoin/pull/6494)).
|
||||
* [`BIP 133`](https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki): feefilter messages are respected and sent for peer versions `>=70013` as of **v0.13.0** ([PR 7542](https://github.com/bitcoin/bitcoin/pull/7542)).
|
||||
* [`BIP 141`](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki): Segregated Witness (Consensus Layer) as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)), and defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
|
||||
* [`BIP 143`](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki): Transaction Signature Verification for Version 0 Witness Program as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)) and defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
|
||||
* [`BIP 141`](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki): Segregated Witness (Consensus Layer) as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)), defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)), and *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
|
||||
* [`BIP 143`](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki): Transaction Signature Verification for Version 0 Witness Program as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)), defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)), and *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
|
||||
* [`BIP 144`](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki): Segregated Witness as of **0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)).
|
||||
* [`BIP 145`](https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki): getblocktemplate updates for Segregated Witness as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)).
|
||||
* [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
|
||||
* [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)), *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
|
||||
* [`BIP 152`](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki): Compact block transfer and related optimizations are used as of **v0.13.0** ([PR 8068](https://github.com/bitcoin/bitcoin/pull/8068)).
|
||||
- [`BIP 158`](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki): Compact Block Filters for Light Clients can be indexed as of **v0.19.0** ([PR #14121](https://github.com/bitcoin/bitcoin/pull/14121)).
|
||||
* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): The NODE_NETWORK_LIMITED service bit is signalled as of **v0.16.0** ([PR 11740](https://github.com/bitcoin/bitcoin/pull/11740)), and such nodes are connected to as of **v0.17.0** ([PR 10387](https://github.com/bitcoin/bitcoin/pull/10387)).
|
||||
* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): The `NODE_NETWORK_LIMITED` service bit is signalled as of **v0.16.0** ([PR 11740](https://github.com/bitcoin/bitcoin/pull/11740)), and such nodes are connected to as of **v0.17.0** ([PR 10387](https://github.com/bitcoin/bitcoin/pull/10387)).
|
||||
* [`BIP 173`](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki): Bech32 addresses for native Segregated Witness outputs are supported as of **v0.16.0** ([PR 11167](https://github.com/bitcoin/bitcoin/pull/11167)).
|
||||
* [`BIP 174`](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki): RPCs to operate on Partially Signed Bitcoin Transactions (PSBT) are present as of **v0.17.0** ([PR 13557](https://github.com/bitcoin/bitcoin/pull/13557)).
|
||||
* [`BIP 176`](https://github.com/bitcoin/bips/blob/master/bip-0176.mediawiki): Bits Denomination [QT only] is supported as of **v0.16.0** ([PR 12035](https://github.com/bitcoin/bitcoin/pull/12035)).
|
||||
|
|
|
@ -314,7 +314,20 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co
|
|||
|
||||
// Synchronously look up hostname
|
||||
raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
|
||||
evhttp_connection_set_timeout(evcon.get(), gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
|
||||
|
||||
// Set connection timeout
|
||||
{
|
||||
const int timeout = gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT);
|
||||
if (timeout > 0) {
|
||||
evhttp_connection_set_timeout(evcon.get(), timeout);
|
||||
} else {
|
||||
// Indefinite request timeouts are not possible in libevent-http, so we
|
||||
// set the timeout to a very long time period instead.
|
||||
|
||||
constexpr int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
|
||||
evhttp_connection_set_timeout(evcon.get(), 5 * YEAR_IN_SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
HTTPReply response;
|
||||
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
|
||||
|
|
|
@ -224,10 +224,32 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str)
|
|||
return strStamped;
|
||||
}
|
||||
|
||||
namespace BCLog {
|
||||
/** Belts and suspenders: make sure outgoing log messages don't contain
|
||||
* potentially suspicious characters, such as terminal control codes.
|
||||
*
|
||||
* This escapes control characters except newline ('\n') in C syntax.
|
||||
* It escapes instead of removes them to still allow for troubleshooting
|
||||
* issues where they accidentally end up in strings.
|
||||
*/
|
||||
std::string LogEscapeMessage(const std::string& str) {
|
||||
std::string ret;
|
||||
for (char ch_in : str) {
|
||||
uint8_t ch = (uint8_t)ch_in;
|
||||
if ((ch >= 32 || ch == '\n') && ch != '\x7f') {
|
||||
ret += ch_in;
|
||||
} else {
|
||||
ret += strprintf("\\x%02x", ch);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
void BCLog::Logger::LogPrintStr(const std::string& str)
|
||||
{
|
||||
std::lock_guard<std::mutex> scoped_lock(m_cs);
|
||||
std::string str_prefixed = str;
|
||||
std::string str_prefixed = LogEscapeMessage(str);
|
||||
|
||||
if (m_log_threadnames && m_started_new_line) {
|
||||
str_prefixed.insert(0, "[" + util::ThreadGetInternalName() + "] ");
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
/* defined in logging.cpp */
|
||||
namespace BCLog {
|
||||
std::string LogEscapeMessage(const std::string& str);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(util_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_criticalsection)
|
||||
|
@ -1572,4 +1577,17 @@ BOOST_AUTO_TEST_CASE(test_Capitalize)
|
|||
BOOST_CHECK_EQUAL(Capitalize("\x00\xfe\xff"), "\x00\xfe\xff");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_LogEscapeMessage)
|
||||
{
|
||||
// ASCII and UTF-8 must pass through unaltered.
|
||||
BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage("Valid log message貓"), "Valid log message貓");
|
||||
// Newlines must pass through unaltered.
|
||||
BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage("Message\n with newlines\n"), "Message\n with newlines\n");
|
||||
// Other control characters are escaped in C syntax.
|
||||
BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage("\x01\x7f Corrupted log message\x0d"), R"(\x01\x7f Corrupted log message\x0d)");
|
||||
// Embedded NULL characters are escaped too.
|
||||
const std::string NUL("O\x00O", 3);
|
||||
BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage(NUL), R"(O\x00O)");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -380,6 +380,15 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
|||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::string key(argv[i]);
|
||||
|
||||
#ifdef MAC_OSX
|
||||
// At the first time when a user gets the "App downloaded from the
|
||||
// internet" warning, and clicks the Open button, macOS passes
|
||||
// a unique process serial number (PSN) as -psn_... command-line
|
||||
// argument, which we filter out.
|
||||
if (key.substr(0, 5) == "-psn_") continue;
|
||||
#endif
|
||||
|
||||
if (key == "-") break; //bitcoin-tx using stdin
|
||||
std::string val;
|
||||
size_t is_index = key.find('=');
|
||||
|
@ -1153,12 +1162,12 @@ void SetupEnvironment()
|
|||
}
|
||||
#endif
|
||||
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale
|
||||
// may be invalid, in which case the "C" locale is used as fallback.
|
||||
// may be invalid, in which case the "C.UTF-8" locale is used as fallback.
|
||||
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||
try {
|
||||
std::locale(""); // Raises a runtime error if current locale is invalid
|
||||
} catch (const std::runtime_error&) {
|
||||
setenv("LC_ALL", "C", 1);
|
||||
setenv("LC_ALL", "C.UTF-8", 1);
|
||||
}
|
||||
#elif defined(WIN32)
|
||||
// Set the default input/output charset is utf-8
|
||||
|
|
Loading…
Reference in a new issue