[electrum] move JSON related classes and function from util to json_util
Summary:
This fixes a util.py -> transaction.py -> util.py circular import, which was previously "fixed" in a hacky way by importing transaction.py in MyEncoder
util.py is imported almost everywhere, so it should import as few other modules as possible.
This commit is move-mostly, with two minor fixups flagged by PyCharm:
- rename socket -> sock in the JSONSocketPipe.__init__ args to avoid shadowing the socket module from the outer scope
- simplify chained comparison: if self.max_message_bytes > 0 and len(self.recv_buf) > self.max_message_bytes: -> if 0 < self.max_message_bytes < len(self.recv_buf):
Test Plan: python test_runner.py
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D14240