Skip to content

Commit 5f96d7d

Browse files
committed
rpc: gettxoutsetinfo rejects hash_serialized_2 for specific height
1 parent 23fe504 commit 5f96d7d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/rpc/blockchain.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,10 @@ static RPCHelpMan gettxoutsetinfo()
11681168
throw JSONRPCError(RPC_INVALID_PARAMETER, "Querying specific block heights requires coinstatsindex");
11691169
}
11701170

1171+
if (stats.m_hash_type == CoinStatsHashType::HASH_SERIALIZED) {
1172+
throw JSONRPCError(RPC_INVALID_PARAMETER, "hash_serialized_2 hash type cannot be queried for a specific block");
1173+
}
1174+
11711175
pindex = ParseHashOrHeight(request.params[1], chainman);
11721176
}
11731177

test/functional/feature_coinstatsindex.py

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def run_test(self):
5252
self._test_coin_stats_index()
5353
self._test_use_index_option()
5454
self._test_reorg_index()
55+
self._test_index_rejects_hash_serialized()
5556

5657
def block_sanity_check(self, block_info):
5758
block_subsidy = 50
@@ -298,6 +299,15 @@ def _test_reorg_index(self):
298299
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash'))
299300
assert_raises_rpc_error(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash', reorg_block)
300301

302+
def _test_index_rejects_hash_serialized(self):
303+
self.log.info("Test that the rpc raises if the legacy hash is passed with the index")
304+
305+
msg = "hash_serialized_2 hash type cannot be queried for a specific block"
306+
assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_2', hash_or_height=111)
307+
308+
for use_index in {True, False, None}:
309+
assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_2', hash_or_height=111, use_index=use_index)
310+
301311

302312
if __name__ == '__main__':
303313
CoinStatsIndexTest().main()

0 commit comments

Comments
 (0)