diff options
| author | Wladimir J. van der Laan <[email protected]> | 2018-10-26 13:21:11 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2018-10-26 13:21:17 +0200 |
| commit | 9d4541508b981eb7f05c0b9f1d94a698e4aab1d2 (patch) | |
| tree | fe9fb095fe963524c04f5ab4c726566171ee3de8 /src | |
| parent | Merge #14416: Fix OSX dmg issue (10.12 to 10.14) (diff) | |
| parent | rpc: Always throw in getblockstats if -txindex is required (diff) | |
| download | discoin-9d4541508b981eb7f05c0b9f1d94a698e4aab1d2.tar.xz discoin-9d4541508b981eb7f05c0b9f1d94a698e4aab1d2.zip | |
Merge #14518: rpc: Always throw in getblockstats if -txindex is required
3be209d103297aaf2fe4711e237a65046488ea19 rpc: Always throw in getblockstats if -txindex is required (João Barbosa)
Pull request description:
Previously blocks with only the coinbase transaction didn't cause
the RPC error even if the requested stats required -txindex and
it wasn't enabled.
Fixes #14499.
Tree-SHA512: d3a6402889e3ce7199632e79eba66d7d471ff7de5c564d35312e2340cc6d84ef544a8172548fbc2eedf5e637b56dc57bbf7a9815ab798c7f226755f897fd8f3e
Diffstat (limited to 'src')
| -rw-r--r-- | src/rpc/blockchain.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index ff71b1925..e940134fb 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1798,6 +1798,10 @@ static UniValue getblockstats(const JSONRPCRequest& request) const bool do_calculate_weight = do_all || SetHasKeys(stats, "total_weight", "avgfeerate", "swtotal_weight", "avgfeerate", "feerate_percentiles", "minfeerate", "maxfeerate"); const bool do_calculate_sw = do_all || SetHasKeys(stats, "swtxs", "swtotal_size", "swtotal_weight"); + if (loop_inputs && !g_txindex) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "One or more of the selected stats requires -txindex enabled"); + } + CAmount maxfee = 0; CAmount maxfeerate = 0; CAmount minfee = MAX_MONEY; @@ -1861,10 +1865,6 @@ static UniValue getblockstats(const JSONRPCRequest& request) } if (loop_inputs) { - - if (!g_txindex) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "One or more of the selected stats requires -txindex enabled"); - } CAmount tx_total_in = 0; for (const CTxIn& in : tx->vin) { CTransactionRef tx_in; |