interface: validate field order in "mempool.get_fee_histogram" response

This commit is contained in:
SomberNight 2020-10-26 02:07:30 +01:00
parent 25d4a40d6e
commit 5481fd8af6
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -993,9 +993,13 @@ class Interface(Logger):
res = await self.session.send_request('mempool.get_fee_histogram')
# check response
assert_list_or_tuple(res)
prev_fee = float('inf')
for fee, s in res:
assert_non_negative_int_or_float(fee)
assert_non_negative_integer(s)
if fee >= prev_fee: # check monotonicity
raise RequestCorrupted(f'fees must be in decreasing order')
prev_fee = fee
return res
async def get_server_banner(self) -> str: