Skip to content

Commit

Permalink
Merge #20150: [0.19] Backports
Browse files Browse the repository at this point in the history
9c71499 rpc: Adjust witness-tx deserialize error message (MarcoFalke)
a7bdf5c rpc: Properly deserialize txs with witness before signing (MarcoFalke)
0b64310 Avoid the use of abs64 in timedata (Pieter Wuille)
5b2de04 Bump vcpkg commit ID to get new msys mirror list (Aaron Clauson)
6957419 build: set minimum required Boost to 1.48.0 (fanquake)
27bb2cc util: Don't reference errno when pthread fails. (MIZUTA Takeshi)
8bd2ab1 docs: Correct description for getblockstats's txs field (Nadav Ivgi)
a8411b3 qt: Fix QFileDialog for static builds (Hennadii Stepanov)

Pull request description:

  Backports the following to the 0.19 branch:
  * #19194 - util: Don't reference errno when pthread fails. - not clean.
  * #19536 - qt, build: Fix QFileDialog for static builds
  * #19777 - docs: Correct description for getblockstats's txs field
  * #19836 - rpc: Properly deserialize txs with witness before signing
  * #20095 - CI: Bump vcpkg commit ID to get new msys mirror list
  * #20141 - Avoid the use of abs64 in timedata
  * #20142 - [0.20] build: set minimum required Boost to 1.48.0

ACKs for top commit:
  jnewbery:
    utACK 9c71499
  dergoegge:
    utACK 9c71499
  MarcoFalke:
    ACK 9c71499

Tree-SHA512: 2151f22bc37a6a2f51a8f36c27376622016b51ff99b570e95354356fce1f1761cf19cb4f8ebfa26d38485a0bff6ff6ee834d2798fb383e2ae2abb175548b8fe6
  • Loading branch information
MarcoFalke committed Dec 2, 2020
2 parents aee9d23 + 9c71499 commit 5baaea4
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Expand Up @@ -11,7 +11,7 @@ environment:
QT_DOWNLOAD_HASH: '9a8c6eb20967873785057fdcd329a657c7f922b0af08c5fde105cc597dd37e21'
QT_LOCAL_PATH: 'C:\Qt5.9.8_x64_static_vs2019'
VCPKG_INSTALL_PATH: 'C:\tools\vcpkg\installed'
VCPKG_COMMIT_ID: 'ed0df8ecc4ed7e755ea03e18aaf285fd9b4b4a74'
VCPKG_COMMIT_ID: '40230b8e3f6368dcb398d649331be878ca1e9007'
install:
# Disable zmq test for now since python zmq library on Windows would cause Access violation sometimes.
# - cmd: pip install zmq
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -1055,7 +1055,7 @@ fi
if test x$use_boost = xyes; then

dnl Minimum required Boost version
define(MINIMUM_REQUIRED_BOOST, 1.47.0)
define(MINIMUM_REQUIRED_BOOST, 1.48.0)

dnl Check for boost libs
AX_BOOST_BASE([MINIMUM_REQUIRED_BOOST])
Expand Down
1 change: 0 additions & 1 deletion depends/packages/qt.mk
Expand Up @@ -76,7 +76,6 @@ $(package)_config_opts += -no-feature-colordialog
$(package)_config_opts += -no-feature-commandlineparser
$(package)_config_opts += -no-feature-concurrent
$(package)_config_opts += -no-feature-dial
$(package)_config_opts += -no-feature-filesystemwatcher
$(package)_config_opts += -no-feature-fontcombobox
$(package)_config_opts += -no-feature-ftp
$(package)_config_opts += -no-feature-image_heuristic_mask
Expand Down
2 changes: 1 addition & 1 deletion doc/dependencies.md
Expand Up @@ -6,7 +6,7 @@ These are the dependencies currently used by Bitcoin Core. You can find instruct
| Dependency | Version used | Minimum required | CVEs | Shared | [Bundled Qt library](https://doc.qt.io/qt-5/configure-options.html#third-party-libraries) |
| --- | --- | --- | --- | --- | --- |
| Berkeley DB | [4.8.30](https://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html) | 4.8.x | No | | |
| Boost | [1.70.0](https://www.boost.org/users/download/) | [1.47.0](https://github.com/bitcoin/bitcoin/pull/8920) | No | | |
| Boost | [1.70.0](https://www.boost.org/users/download/) | [1.48.0](https://github.com/bitcoin/bitcoin/pull/20142) | No | | |
| Clang | | [3.3+](https://releases.llvm.org/download.html) (C++11 support) | | | |
| Expat | [2.2.7](https://libexpat.github.io/) | | No | Yes | |
| fontconfig | [2.12.1](https://www.freedesktop.org/software/fontconfig/release/) | | No | Yes | |
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/blockchain.cpp
Expand Up @@ -1717,7 +1717,7 @@ static UniValue getblockstats(const JSONRPCRequest& request)
" \"90th_percentile_feerate\", (numeric) The 90th percentile feerate\n"
" ],\n"
" \"height\": xxxxx, (numeric) The height of the block\n"
" \"ins\": xxxxx, (numeric) The number of inputs (excluding coinbase)\n"
" \"ins\": xxxxx, (numeric) The number of inputs (including coinbase)\n"
" \"maxfee\": xxxxx, (numeric) Maximum fee in the block\n"
" \"maxfeerate\": xxxxx, (numeric) Maximum feerate (in satoshis per virtual byte)\n"
" \"maxtxsize\": xxxxx, (numeric) Maximum transaction size\n"
Expand Down
16 changes: 8 additions & 8 deletions src/rpc/rawtransaction.cpp
Expand Up @@ -619,8 +619,8 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request)
std::vector<CMutableTransaction> txVariants(txs.size());

for (unsigned int idx = 0; idx < txs.size(); idx++) {
if (!DecodeHexTx(txVariants[idx], txs[idx].get_str(), true)) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d", idx));
if (!DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d. Make sure the tx has at least one input.", idx));
}
}

Expand Down Expand Up @@ -738,8 +738,8 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true);

CMutableTransaction mtx;
if (!DecodeHexTx(mtx, request.params[0].get_str(), true)) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
}

FillableSigningProvider keystore;
Expand Down Expand Up @@ -800,10 +800,10 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
UniValueType(), // NUM or BOOL, checked later
});

// parse hex string from parameter
CMutableTransaction mtx;
if (!DecodeHexTx(mtx, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
}
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));

CFeeRate max_raw_tx_fee_rate = DEFAULT_MAX_RAW_TX_FEE_RATE;
Expand Down Expand Up @@ -875,7 +875,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)

CMutableTransaction mtx;
if (!DecodeHexTx(mtx, request.params[0].get_array()[0].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
}
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
const uint256& tx_hash = tx->GetHash();
Expand Down
14 changes: 5 additions & 9 deletions src/timedata.cpp
Expand Up @@ -37,11 +37,6 @@ int64_t GetAdjustedTime()
return GetTime() + GetTimeOffset();
}

static int64_t abs64(int64_t n)
{
return (n >= 0 ? n : -n);
}

#define BITCOIN_TIMEDATA_MAX_SAMPLES 200

void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
Expand Down Expand Up @@ -81,8 +76,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
int64_t nMedian = vTimeOffsets.median();
std::vector<int64_t> vSorted = vTimeOffsets.sorted();
// Only let other nodes change our time by so much
if (abs64(nMedian) <= std::max<int64_t>(0, gArgs.GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT)))
{
int64_t max_adjustment = std::max<int64_t>(0, gArgs.GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT));
if (nMedian >= -max_adjustment && nMedian <= max_adjustment) {
nTimeOffset = nMedian;
}
else
Expand All @@ -94,9 +89,10 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
{
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
bool fMatch = false;
for (const int64_t nOffset : vSorted)
if (nOffset != 0 && abs64(nOffset) < 5 * 60)
for (const int64_t nOffset : vSorted) {
if (nOffset != 0 && nOffset > -5 * 60 && nOffset < 5 * 60)
fMatch = true;
}

if (!fMatch)
{
Expand Down
7 changes: 4 additions & 3 deletions src/util/system.cpp
Expand Up @@ -1236,9 +1236,10 @@ int ScheduleBatchPriority()
{
#ifdef SCHED_BATCH
const static sched_param param{};
if (int ret = pthread_setschedparam(pthread_self(), SCHED_BATCH, &param)) {
LogPrintf("Failed to pthread_setschedparam: %s\n", strerror(errno));
return ret;
const int rc = pthread_setschedparam(pthread_self(), SCHED_BATCH, &param);
if (rc != 0) {
LogPrintf("Failed to pthread_setschedparam: %s\n", strerror(rc));
return rc;
}
return 0;
#else
Expand Down
5 changes: 3 additions & 2 deletions src/wallet/rpcdump.cpp
Expand Up @@ -353,8 +353,9 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
}.Check(request);

CMutableTransaction tx;
if (!DecodeHexTx(tx, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
if (!DecodeHexTx(tx, request.params[0].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
}
uint256 hashTx = tx.GetHash();
CWalletTx wtx(pwallet, MakeTransactionRef(std::move(tx)));

Expand Down
4 changes: 2 additions & 2 deletions src/wallet/rpcwallet.cpp
Expand Up @@ -3269,8 +3269,8 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR}, true);

CMutableTransaction mtx;
if (!DecodeHexTx(mtx, request.params[0].get_str(), true)) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed. Make sure the tx has at least one input.");
}

// Sign the transaction
Expand Down

0 comments on commit 5baaea4

Please sign in to comment.