mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
rpc: gettxoutsetinfo rejects hash_serialized_2 for specific height
This commit is contained in:
parent
23fe50436b
commit
5f96d7d22d
2 changed files with 14 additions and 0 deletions
|
@ -1168,6 +1168,10 @@ static RPCHelpMan gettxoutsetinfo()
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Querying specific block heights requires coinstatsindex");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Querying specific block heights requires coinstatsindex");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stats.m_hash_type == CoinStatsHashType::HASH_SERIALIZED) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "hash_serialized_2 hash type cannot be queried for a specific block");
|
||||||
|
}
|
||||||
|
|
||||||
pindex = ParseHashOrHeight(request.params[1], chainman);
|
pindex = ParseHashOrHeight(request.params[1], chainman);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||||
self._test_coin_stats_index()
|
self._test_coin_stats_index()
|
||||||
self._test_use_index_option()
|
self._test_use_index_option()
|
||||||
self._test_reorg_index()
|
self._test_reorg_index()
|
||||||
|
self._test_index_rejects_hash_serialized()
|
||||||
|
|
||||||
def block_sanity_check(self, block_info):
|
def block_sanity_check(self, block_info):
|
||||||
block_subsidy = 50
|
block_subsidy = 50
|
||||||
|
@ -298,6 +299,15 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash'))
|
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash'))
|
||||||
assert_raises_rpc_error(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash', reorg_block)
|
assert_raises_rpc_error(-32603, "Unable to read UTXO set", node.gettxoutsetinfo, 'muhash', reorg_block)
|
||||||
|
|
||||||
|
def _test_index_rejects_hash_serialized(self):
|
||||||
|
self.log.info("Test that the rpc raises if the legacy hash is passed with the index")
|
||||||
|
|
||||||
|
msg = "hash_serialized_2 hash type cannot be queried for a specific block"
|
||||||
|
assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_2', hash_or_height=111)
|
||||||
|
|
||||||
|
for use_index in {True, False, None}:
|
||||||
|
assert_raises_rpc_error(-8, msg, self.nodes[1].gettxoutsetinfo, hash_type='hash_serialized_2', hash_or_height=111, use_index=use_index)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
CoinStatsIndexTest().main()
|
CoinStatsIndexTest().main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue