mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 00:34:01 +02:00
Make listsinceblock refuse unknown block hash
Change suggested by Cory Fields <cory-nospam-@coryfields.com> who noticed
listsinceblock would ignore invalid block hashes causing it to return a
completely unfiltered list of transactions.
Github-Pull: #11565
Rebased-From: 659b2061c4
Tree-SHA512: 2091a830b730421b49c806cb83a16c7da2ec0a7adac2bac0585324aad12a32bb99a840264c3d346937ea84786fac56e44befb6641511a417977803875efe5a21
This commit is contained in:
committed by
Wladimir J. van der Laan
parent
cf18f42899
commit
7d4546f17d
@@ -1823,19 +1823,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user