From aecc03e2a2c0f92fbf8c24df5feafed12b5f87f5 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 23 Apr 2022 14:36:10 +0000 Subject: [PATCH] mmgen-tool: add `eth_checksummed_addr` command --- mmgen/main_tool.py | 1 + mmgen/tool/util.py | 5 +++++ test/tooltest2.py | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/mmgen/main_tool.py b/mmgen/main_tool.py index 92fba360..c342071c 100755 --- a/mmgen/main_tool.py +++ b/mmgen/main_tool.py @@ -82,6 +82,7 @@ mods = { 'b6dtohex', 'bytespec', 'bytestob58', + 'eth_checksummed_addr', 'hash160', 'hash256', 'hexdump', diff --git a/mmgen/tool/util.py b/mmgen/tool/util.py index 96ffbbc2..469b8969 100755 --- a/mmgen/tool/util.py +++ b/mmgen/tool/util.py @@ -173,3 +173,8 @@ class tool_cmd(tool_cmd_base): from ..baseconv import baseconv from ..util import remove_whitespace return baseconv('b6d').tohex( remove_whitespace(b6d_num), pad ) + + def eth_checksummed_addr(self,addr:'sstr'): + "create a checksummed Ethereum address" + from ..protocol import init_proto + return init_proto('eth').checksummed_addr(addr) diff --git a/test/tooltest2.py b/test/tooltest2.py index 8cbfe9f0..e94cd72b 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -316,6 +316,12 @@ tests = { ( ['nbytes=16'], {'boolfunc':is_b58_str}, ['-r0'] ), ( ['nbytes=12','pad=0'], is_b58_str, ['-r0'] ), ], + 'eth_checksummed_addr': [ + ( ['00a329c0648769a73afac7f9381e08fb43dbea72'], '00a329c0648769A73afAc7F9381E08FB43dBEA72' ), + ( ['deadbeef'*5], 'DeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF' ), + ( ['ffffffff'*5], 'FFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF' ), + ( ['0'*39 + '1'], '0'*39 + '1' ), + ], }, 'Wallet': { 'gen_key': [