diff options
| author | Russell Yanofsky <[email protected]> | 2017-10-26 07:10:59 -0400 |
|---|---|---|
| committer | Russell Yanofsky <[email protected]> | 2017-10-26 07:10:59 -0400 |
| commit | 659b2061c4329472a45e913c5d45e6ab180600a3 (patch) | |
| tree | 0a9b28f79e2278a063794a128795e9340ff8af25 /src | |
| parent | Merge #11538: qa: Fix race condition failures in replace-by-fee.py, sendheade... (diff) | |
| download | discoin-659b2061c4329472a45e913c5d45e6ab180600a3.tar.xz discoin-659b2061c4329472a45e913c5d45e6ab180600a3.zip | |
Make listsinceblock refuse unknown block hash
Change suggested by Cory Fields <[email protected]> who noticed
listsinceblock would ignore invalid block hashes causing it to return a
completely unfiltered list of transactions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wallet/rpcwallet.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d6989add8..97d6dc700 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1893,19 +1893,20 @@ UniValue listsinceblock(const JSONRPCRequest& request) int target_confirms = 1; isminefilter filter = ISMINE_SPENDABLE; - if (!request.params[0].isNull()) { + if (!request.params[0].isNull() && !request.params[0].get_str().empty()) { uint256 blockId; blockId.SetHex(request.params[0].get_str()); BlockMap::iterator it = mapBlockIndex.find(blockId); - if (it != mapBlockIndex.end()) { - paltindex = pindex = it->second; - if (chainActive[pindex->nHeight] != pindex) { - // the block being asked for is a part of a deactivated chain; - // we don't want to depend on its perceived height in the block - // chain, we want to instead use the last common ancestor - pindex = chainActive.FindFork(pindex); - } + if (it == mapBlockIndex.end()) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + } + paltindex = pindex = it->second; + if (chainActive[pindex->nHeight] != pindex) { + // the block being asked for is a part of a deactivated chain; + // we don't want to depend on its perceived height in the block + // chain, we want to instead use the last common ancestor + pindex = chainActive.FindFork(pindex); } } |