MCPcopy
hub / github.com/raiden-network/raiden / to_checksum_address

Function to_checksum_address

raiden/utils/formatting.py:44–62  ·  view source on GitHub ↗

Implementation of EIP-55 checksum address. Adaptation of https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md#specification for python 3.7+. Refined after: https://github.com/ethereum/eips/issues/55#issuecomment-261521584 Note: As of today (eth-utils==1.8.1), this is ~4-5 t

(address: AddressTypes)

Source from the content-addressed store, hash-verified

42
43@lru_cache(maxsize=5000)
44def to_checksum_address(address: AddressTypes) -> ChecksumAddress:
45 """Implementation of EIP-55 checksum address.
46
47 Adaptation of https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md#specification for
48 python 3.7+.
49
50 Refined after: https://github.com/ethereum/eips/issues/55#issuecomment-261521584
51
52 Note: As of today (eth-utils==1.8.1), this is ~4-5 times faster than
53 `eth_utils.to_checksum_address`.
54 """
55 out = ""
56 v = int.from_bytes(keccak(bytes(address.hex(), "ascii")), byteorder="big")
57 for i, char in enumerate(address.hex()):
58 if char in "0123456789":
59 out += char
60 else:
61 out += char.upper() if (v & (2 ** (255 - 4 * i))) else char.lower()
62 return ChecksumAddress(AddressHex(HexStr("0x" + out)))
63
64
65def pex(data: bytes) -> str:

Callers 15

mainFunction · 0.90
get_loginFunction · 0.90
matrix_api_shellFunction · 0.90
constants.pyFile · 0.90
send_pfs_updateFunction · 0.90
waitMethod · 0.90
wait_for_blockFunction · 0.90
wait_for_token_networkFunction · 0.90
on_raiden_eventsMethod · 0.90

Calls 1

from_bytesMethod · 0.80

Tested by 15

test_api_wrapperFunction · 0.72
test_query_eventsFunction · 0.72
test_channel_withdrawFunction · 0.72
transfer_and_assertFunction · 0.72
setup_raidenFunction · 0.72
pfs_infoFunction · 0.72
run_smoketestFunction · 0.72
iou_side_effectFunction · 0.72
happy_path_fixtureFunction · 0.72