Browse Source

mmgen-tool: add `eth_checksummed_addr` command

The MMGen Project 2 years ago
parent
commit
aecc03e2a2
3 changed files with 12 additions and 0 deletions
  1. 1 0
      mmgen/main_tool.py
  2. 5 0
      mmgen/tool/util.py
  3. 6 0
      test/tooltest2.py

+ 1 - 0
mmgen/main_tool.py

@@ -82,6 +82,7 @@ mods = {
 		'b6dtohex',
 		'bytespec',
 		'bytestob58',
+		'eth_checksummed_addr',
 		'hash160',
 		'hash256',
 		'hexdump',

+ 5 - 0
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)

+ 6 - 0
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': [