data.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. # Licensed under the GNU General Public License, Version 3:
  6. # https://www.gnu.org/licenses
  7. # Public project repositories:
  8. # https://github.com/mmgen/mmgen-wallet
  9. # https://gitlab.com/mmgen/mmgen-wallet
  10. """
  11. test.tooltest2_d.data: Test vectors for the ‘mmgen-tool’ utility
  12. """
  13. import sys
  14. from decimal import Decimal
  15. from mmgen.key import is_wif
  16. from mmgen.addr import is_coin_addr
  17. from mmgen.util import is_hex_str
  18. from mmgen.bip39 import is_bip39_mnemonic
  19. from mmgen.baseconv import is_mmgen_mnemonic, is_b58_str
  20. from mmgen.xmrseed import is_xmrseed
  21. from ..modtest_d.ut_baseconv import unit_test as ut_baseconv
  22. from ..modtest_d.ut_bip39 import unit_tests as ut_bip39
  23. from ..modtest_d.ut_xmrseed import unit_tests as ut_xmrseed
  24. from ..include.common import cfg, sample_text
  25. proto = cfg._proto
  26. def is_str(s):
  27. return isinstance(s, str)
  28. def is_wif_loc(s):
  29. return is_wif(proto, s)
  30. def is_coin_addr_loc(s):
  31. return is_coin_addr(proto, s)
  32. def md5_hash(s):
  33. from hashlib import md5
  34. return md5(s.encode()).hexdigest()
  35. def md5_hash_strip(s):
  36. import re
  37. s = re.sub('\x1b' + r'\[[;0-9]+?m', '', s) # strip ANSI color sequences
  38. s = s.replace(NL, '\n') # fix DOS newlines
  39. return md5_hash(s.strip())
  40. NL = ('\n', '\r\n')[sys.platform=='win32']
  41. sample_text_hexdump = (
  42. '000000: 5468 6520 5469 6d65 7320 3033 2f4a 616e{n}' +
  43. '000010: 2f32 3030 3920 4368 616e 6365 6c6c 6f72{n}' +
  44. '000020: 206f 6e20 6272 696e 6b20 6f66 2073 6563{n}' +
  45. '000030: 6f6e 6420 6261 696c 6f75 7420 666f 7220{n}' +
  46. '000040: 6261 6e6b 73').format(n=NL)
  47. kafile_opts = ['-p1', '-Ptest/ref/keyaddrfile_password']
  48. btc_wif1 = '5HwzecKMWD82ppJK3qMKpC7ohXXAwcyAN5VgdJ9PLFaAzpBG4sX'
  49. btc_wif2 = 'KwojSzt1VvW343mQfWQi3J537siAt5ktL2qbuCg1ZyKR8BLQ6UJm'
  50. privhex1 = '0000000000000000000000000000000000000000000000000000000000000001'
  51. privhex2 = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
  52. privhex3 = '0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
  53. privhex4 = '00000000000000000000000000000000000000000000000000000000000000ff'
  54. privhex5 = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0f'
  55. privhex6 = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
  56. privhex7 = '118089d66b4a5853765e94923abdd5de4616c6e5118089d66b4a5853765e9492'
  57. btc_addr1 = '1C5VPtgq9xQ6AcTgMAR3J6GDrs72HC4pS1'
  58. btc_addr2 = '1Kz9fVSUMshzPejpzW9D95kScgA3rY6QxF'
  59. btc_addr3 = '3AhjTiWHhVJAi1s5CfKMcLzYps12x3gZhg'
  60. btc_addr4 = 'bc1q6pqnfwwakuuejpm9w52ds342f9d5u36v0qnz7c'
  61. btc_addr5 = '12bYUGXS8SRArZneQDN9YEEYAtEa59Rykm'
  62. btc_addr6 = 'bc1qxptlvmwaymaxa7pxkr2u5pn7c0508stcncv7ms'
  63. btc_addr7 = '3Eevao3DRVXnYym3tdrJDqS3Wc39PQzahn'
  64. eth_addr1 = '7e5f4552091a69125d5dfcb7b8c2659029395bdf'
  65. eth_addr2 = 'b92702b3eefb3c2049aeb845b0335b283e11e9c6'
  66. eth_addr3 = 'ad30adc7451c1dace34c5d1f328f8a74a4947534'
  67. eth_addr4 = '5044a80bd3eff58302e638018534bbda8896c48a'
  68. eth_addr5 = '8b10f977e27611516f186980d8161b25f8adca5e'
  69. eth_addr6 = 'c96aaa54e2d44c299564da76e1cd3184a2386b8d'
  70. xmr_addr1 = '42nsXK8WbVGTNayQ6Kjw5UdgqbQY5KCCufdxdCgF7NgTfjC69Mna7DJSYyie77hZTQ8H92G2HwgFhgEUYnDzrnLnQdF28r3'
  71. xmr_addr2 = '49voQEbjouUQSDikRWKUt1PGbS47TBde4hiGyftN46CvTDd8LXCaimjHRGtofCJwY5Ed5QhYwc12P15AH5w7SxUAMCz1nr1'
  72. xmr_addr3 = '45Ee1yJSjXBKuf8aaihf6KgSRGtMBN6NNDtkd9fLJzHiK4ar4NyNxDk6afc7MTRoruAsg6J6792tCJazHqs1sjbv7LuEsLx'
  73. xmr_addr4 = '43aZyywWW4MYt2Az32XioQYirxyT8xeRBP84EBNA7Cra5SqQNmca6iD9pM487pcR9JAEiKrnw2QwvA5uWiFNokEzLJ5coZ9'
  74. xmr_addr5 = '4AeR1owefiJGbrAdSKCbVL73ME4FGv2cpczjV2peqqkxagm5D4gBqAHJta6NpbtxyuRe3ywaTj6QCHD59savvPW69wfW9my'
  75. xmr_addr6 = '41i7saPWA53EoHenmJVRt34dubPxsXwoWMnw8AdMyx4mTD1svf7qYzcVjxxRfteLNdYrAxWUMmiPegFW9EfoNgXx7vDMExv'
  76. zec_addr1 = 'zceQDpyNwek7dKqF5ZuFGj7YrNVxh7X1aPkrVxDLVxWSiZAFDEuy5C7XNV8VhyZ3ghTPQ61xjCGiyLT3wqpiN1Yi6mdmaCq'
  77. zec_addr2 = 'zcY1hqJ3P5ifjnWk1BcXpjrLG5XeJZUSPCiiVTF9LXrejxBzAsFWcNyr6PudwQHm8DnQpD8HEaM3dh8sB6cf91ciAa53YQ1'
  78. zec_addr4 = 'zcck12KgVY34LJwVEDLN8sXhL787zmjKqPsP1uBYRHs75bL9sQu4P7wcc5ZJTjKsL376zaSpsYqGxK94JbiYcNoH8DkeGbN'
  79. zec_addr5 = 'zcJ9hEezG1Jeye5dciqiMDh6SXtYbUsircGmpVyhHWyzyxDVRRDs5Q8M7hG3c7nDcvd5Pw4u4wV9RAQmq5RCBZq5wVyMQV8'
  80. zec_addr6 = 'zchFELwBxqsAubsLQ8yZgPCDDGukjXJssgCbiTPwFNmFwn9haLnDatzfhLdZzJT4PcU4o2yr92B52UFirUzEdF6ZYM2gBkM'
  81. redeem_script1 = '0014d04134b9ddb7399907657514d846aa495b4e474c'
  82. btc_pubhex1 = '024281a85c9ce87279e028410b851410d65136304cfbbbeaaa8e2e3931cf4e9727'
  83. btc_pubhex2 = '044281a85c9ce87279e028410b851410d65136304cfbbbeaaa8e2e3931cf4e972757f3254c322eeaa3cb6bf97cc5ecf8d4387b0df2c0b1e6ee18fe3a6977a7d57a'
  84. eth_pubhex1 = '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8' # Bitcoin-style '04'-prefixed pubkey
  85. eth_pubhex2 = '9166c289b9f905e55f9e3df9f69d7f356b4a22095f894f4715714aa4b56606aff181eb966be4acb5cff9e16b66d809be94e214f06c93fd091099af98499255e7' # raw pubkey
  86. xmr_pubhex1 = '1ed49357e217e79dab3c5503822f2bdb561e302e24476ee6ff33242c7551d4e78944790c0cfa9998c2f196061be89b2b8387f9d397db20ea8e049899cdc947d1'
  87. zec_pubhex1 = 'e6a4edbff547f21bcc2a825b6cf70f06e266a452d2da9d6dc5c1da3d99d7e996f488704dcdfe8d92cafe47772b3f692a98d59de1e99e00ff815f64ae59910f0c'
  88. tests = {
  89. 'Mnemonic': {
  90. 'hex2mn': (
  91. [([a[0]], b) for a, b in ut_baseconv.vectors['mmgen']] +
  92. [([a, 'fmt=bip39'], b) for a, b in ut_bip39.vectors] +
  93. [([a, 'fmt=xmrseed'], b) for a, b in ut_xmrseed.vectors]
  94. ),
  95. 'mn2hex': (
  96. [([b, 'fmt=mmgen'], a[0]) for a, b in ut_baseconv.vectors['mmgen']] +
  97. [([b, 'fmt=bip39'], a) for a, b in ut_bip39.vectors] +
  98. [([b, 'fmt=xmrseed'], a) for a, b in ut_xmrseed.vectors]
  99. ),
  100. 'mn_rand128': [
  101. ([], is_mmgen_mnemonic, ['-r0']),
  102. (['fmt=mmgen'], is_mmgen_mnemonic, ['-r0']),
  103. (['fmt=bip39'], is_bip39_mnemonic, ['-r0']),
  104. ],
  105. 'mn_rand192': [
  106. (['fmt=mmgen'], is_mmgen_mnemonic, ['-r0']),
  107. (['fmt=bip39'], is_bip39_mnemonic, ['-r0']),
  108. ],
  109. 'mn_rand256': [
  110. (['fmt=mmgen'], is_mmgen_mnemonic, ['-r0']),
  111. (['fmt=bip39'], is_bip39_mnemonic, ['-r0']),
  112. (['fmt=xmrseed'], is_xmrseed, ['-r0']),
  113. ],
  114. 'mn_stats': [
  115. ([], is_str),
  116. (['fmt=mmgen'], is_str),
  117. (['fmt=bip39'], is_str),
  118. (['fmt=xmrseed'], is_str),
  119. ],
  120. 'mn_printlist': [
  121. ([], is_str),
  122. (['fmt=mmgen'], is_str),
  123. (['fmt=bip39'], is_str),
  124. (['fmt=xmrseed', 'enum=true'], is_str),
  125. ],
  126. },
  127. 'Util': {
  128. 'hextob32': [
  129. (['deadbeef'], 'DPK3PXP'),
  130. (['deadbeefdeadbeef'], 'N5LN657PK3PXP'),
  131. (['ffffffffffffffff'], 'P777777777777'),
  132. (['0000000000000000'], 'A'),
  133. (['0000000000000000', 'pad=10'], 'AAAAAAAAAA'),
  134. (['ff', 'pad=10'], 'AAAAAAAAH7'),
  135. ],
  136. 'b32tohex': [
  137. (['DPK3PXP'], 'deadbeef'),
  138. (['N5LN657PK3PXP'], 'deadbeefdeadbeef'),
  139. (['P777777777777'], 'ffffffffffffffff'),
  140. (['A', 'pad=16'], '0000000000000000'),
  141. (['AAAAAAAAAA', 'pad=16'], '0000000000000000'),
  142. (['AAAAAAAAH7', 'pad=2'], 'ff'),
  143. ],
  144. 'hextob6d': [
  145. (['deadbeef'], '25255 24636 426'),
  146. (['deadbeefdeadbeef'], '43263 51255 35545 36422 42642'),
  147. (['ffffffffffffffff'], '46316 33121 21321 15553 55534'),
  148. (['0000000000000000'], '1'),
  149. (['0000000000000000', 'pad=10'], '11111 11111'),
  150. (['ff', 'pad=10'], '11111 12214'),
  151. (
  152. ['ff'*16],
  153. '34164 46464 12666 61652 46515 46546 53354 43666 45555 21414'
  154. ), (
  155. ['ff'*24],
  156. '24611 14114 33323 36422 24655 66552 32465 25661 21541 62342 '
  157. '61351 63525 45161 35543 13654'
  158. ), (
  159. ['ff'*32],
  160. '21325 21653 31261 31341 45131 42346 54146 36252 11413 12253 '
  161. '24246 31114 16424 56513 41632 24121 46151 43214 22425 65134'
  162. ),
  163. ],
  164. 'b6dtohex': [
  165. (['25255 24636 426'], 'deadbeef'),
  166. (['43263 51255 35545 36422 42642'], 'deadbeefdeadbeef'),
  167. (['46316 33121 21321 15553 55534'], 'ffffffffffffffff'),
  168. (['1', 'pad=16'], '0000000000000000'),
  169. (['11111 11111', 'pad=16'], '0000000000000000'),
  170. (['11111 12214', 'pad=2'], 'ff'),
  171. (['22222 22222'], 'b88733'),
  172. (['66666 66666'], '039aa3ff'),
  173. (['6'*50], {
  174. 'len': 34,
  175. 'value':'0260154fc36cbf42778f23ffffffffffff' # 130 bits
  176. }),
  177. (['6'*75], {
  178. 'len': 50,
  179. 'value':'03a92ef1c3432e71a7679561bb6817d7ffffffffffffffffff' # 194 bits
  180. }),
  181. (['6'*100], {
  182. 'len': 66,
  183. 'value':'05a4653ca673768565b41f775d6947d55cf3813d0fffffffffffffffffffffffff' # 259 bits
  184. }),
  185. ],
  186. 'hextob58chk': [
  187. (['deadbeef'], 'eFGDJPketnz'),
  188. (['deadbeefdeadbeef'], '5CizhNNRPYpBjrbYX'),
  189. (['ffffffffffffffff'], '5qCHTcgbQwprzjWrb'),
  190. (['0000000000000000'], '111111114FCKVB'),
  191. (['00'], '1Wh4bh'),
  192. (['000000000000000000000000000000000000000000'], '1111111111111111111114oLvT2'),
  193. ],
  194. 'b58chktohex': [
  195. (['eFGDJPketnz'], 'deadbeef'),
  196. (['5CizhNNRPYpBjrbYX'], 'deadbeefdeadbeef'),
  197. (['5qCHTcgbQwprzjWrb'], 'ffffffffffffffff'),
  198. (['111111114FCKVB'], '0000000000000000'),
  199. (['3QJmnh'], ''),
  200. (['1111111111111111111114oLvT2'], '000000000000000000000000000000000000000000'),
  201. ],
  202. 'bytestob58': [
  203. ([b'\xde\xad\xbe\xef'], '6h8cQN'),
  204. ([b'\xde\xad\xbe\xef\xde\xad\xbe\xef'], 'eFGDJURJykA'),
  205. ([b'\xff\xff\xff\xff\xff\xff\xff\xff'], 'jpXCZedGfVQ'),
  206. ([b'\x00\x00\x00\x00\x00\x00\x00\x00'], '1'),
  207. ([b'\x00\x00\x00\x00\x00\x00\x00\x00', 'pad=10'], '1111111111'),
  208. ([b'\xff', 'pad=10'], '111111115Q'),
  209. ],
  210. 'b58tobytes': [
  211. (['6h8cQN'], b'\xde\xad\xbe\xef'),
  212. (['eFGDJURJykA'], b'\xde\xad\xbe\xef\xde\xad\xbe\xef'),
  213. (['jpXCZedGfVQ'], b'\xff\xff\xff\xff\xff\xff\xff\xff'),
  214. (['1', 'pad=8'], b'\x00\x00\x00\x00\x00\x00\x00\x00'),
  215. (['1111111111', 'pad=8'], b'\x00\x00\x00\x00\x00\x00\x00\x00'),
  216. (['111111115Q', 'pad=1'], b'\xff'),
  217. ],
  218. 'hextob58': [
  219. (['deadbeef'], '6h8cQN'),
  220. (['deadbeefdeadbeef'], 'eFGDJURJykA'),
  221. (['ffffffffffffffff'], 'jpXCZedGfVQ'),
  222. (['0000000000000000'], '1'),
  223. (['0000000000000000', 'pad=10'], '1111111111'),
  224. (['ff', 'pad=10'], '111111115Q'),
  225. ],
  226. 'b58tohex': [
  227. (['6h8cQN'], 'deadbeef'),
  228. (['eFGDJURJykA'], 'deadbeefdeadbeef'),
  229. (['jpXCZedGfVQ'], 'ffffffffffffffff'),
  230. (['1', 'pad=16'], '0000000000000000'),
  231. (['1111111111', 'pad=16'], '0000000000000000'),
  232. (['111111115Q', 'pad=2'], 'ff'),
  233. ],
  234. 'bytespec': [
  235. (['1G'], str(1024*1024*1024)),
  236. (['1GB'], str(1000*1000*1000)),
  237. (['1234GB'], str(1234*1000*1000*1000)),
  238. (['1234G'], str(1234*1024*1024*1024)),
  239. (['1234TB'], str(1234*1000*1000*1000*1000)),
  240. (['1234T'], str(1234*1024*1024*1024*1024)),
  241. (['1234PB'], str(1234*1000*1000*1000*1000*1000)),
  242. (['1234P'], str(1234*1024*1024*1024*1024*1024)),
  243. (['1234EB'], str(1234*1000*1000*1000*1000*1000*1000)),
  244. (['1234E'], str(1234*1024*1024*1024*1024*1024*1024)),
  245. (['1.234MB'], str(1234*1000)),
  246. (['1.234567M'], str(int(Decimal('1.234567')*1024*1024))),
  247. (['1234'], str(1234)),
  248. ],
  249. 'to_bytespec': [
  250. ([str(1024*1024*1024), 'G'], '1.00G'),
  251. ([str(1024*1024*1024), 'G', 'fmt=0.0'], '1G'),
  252. ([str(1024*1024*1024), 'G', 'fmt=08.5'], '01.00000G'),
  253. ([str(1234*1000*1000*1000), 'GB'], '1234.00GB'),
  254. ([str(1234*1000*1000*1000), 'GB', 'strip=True'], '1234.0GB'),
  255. ([str(1234*1000*1000*1000), 'GB', 'add_space=True'], '1234.00 GB'),
  256. ([str(1234*1024*1024*1024), 'G'], '1234.00G',),
  257. ([str(1000*1000*1000*1000*1000), 'PB'], '1.00PB'),
  258. ([str(1024*1024*1024*1024*1024), 'P'], '1.00P'),
  259. ([str(1024*1024*1024*1024*1024*1024), 'E'], '1.00E'),
  260. ([str(int(Decimal('1.234567')*1024*1024)), 'M', 'fmt=0.6'], '1.234567M'),
  261. (['1234', 'c', 'fmt=0.0', 'print_sym=false'], '1234'),
  262. ],
  263. 'hash160': [ # TODO: check that hextob58chk(hash160) = pubhex2addr
  264. (['deadbeef'], 'f04df4c4b30d2b7ac6e1ed2445aeb12a9cb4d2ec'),
  265. (['000000000000000000000000000000000000000000'], '2db95e704e2d9b0474acf76182f3f985b7064a8a'),
  266. ([''], 'b472a266d0bd89c13706a4132ccfb16f7c3b9fcb'),
  267. (['ffffffffffffffff'], 'f86221f5a1fca059a865c0b7d374dfa9d5f3aeb4'),
  268. ],
  269. 'hash256': [
  270. (['deadbeef'], 'e107944e77a688feae4c2d4db5951923812dd0f72026a11168104ee1b248f8a9'),
  271. (
  272. ['000000000000000000000000000000000000000000'],
  273. 'fd5181fcd097a334ab340569e5edcd09f702fef7994abab01f4b66e86b32ebbe'
  274. ),
  275. ([''], '5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456'),
  276. (['ffffffffffffffff'], '57b2d2c3455e0f76c61c5237ff04fc9fc0f3fe691e587ea9c951949e1a5e0fed'),
  277. ],
  278. 'hexdump': [
  279. ([sample_text.encode()], sample_text_hexdump),
  280. ],
  281. 'unhexdump': [
  282. ([sample_text_hexdump.encode()], sample_text.encode()),
  283. ],
  284. 'hexlify': [
  285. ([b'foobar'], '666f6f626172'),
  286. ],
  287. 'unhexlify': [
  288. (['666f6f626172'], 'foobar'),
  289. ],
  290. 'hexreverse': [
  291. (['deadbeefcafe'], 'fecaefbeadde'),
  292. ],
  293. 'id6': [
  294. ([sample_text.encode()], 'a6d72b'),
  295. ],
  296. 'id8': [
  297. ([sample_text.encode()], '687C09C2'),
  298. ],
  299. 'str2id6': [
  300. (['74ev zjeq Zw2g DspF RKpE 7H'], '70413d'), # checked
  301. ],
  302. 'randhex': [
  303. ([], {'boolfunc':is_hex_str, 'len':64}, ['-r0']),
  304. (['nbytes=16'], {'boolfunc':is_hex_str, 'len':32}, ['-r0']),
  305. (['nbytes=6'], {'boolfunc':is_hex_str, 'len':12}, ['-r0']),
  306. ],
  307. 'randb58': [
  308. ([], {'boolfunc':is_b58_str}, ['-r0']),
  309. (['nbytes=16'], {'boolfunc':is_b58_str}, ['-r0']),
  310. (['nbytes=12', 'pad=0'], is_b58_str, ['-r0']),
  311. ],
  312. },
  313. 'Wallet': {
  314. 'gen_key': [
  315. (
  316. ['98831F3A:11', 'wallet=test/ref/98831F3A.mmwords'],
  317. '5JKLcdYbhP6QQ4BXc9HtjfqJ79FFRXP2SZTKUyEuyXJo9QSFUkv'
  318. ), (
  319. ['98831F3A:C:11', 'wallet=test/ref/98831F3A.mmwords'],
  320. 'L2LwXv94XTU2HjCbJPXCFuaHjrjucGipWPWUi1hkM5EykgektyqR'
  321. ), (
  322. ['98831F3A:B:11', 'wallet=test/ref/98831F3A.mmwords'],
  323. 'L2K4Y9MWb5oUfKKZtwdgCm6FLZdUiWJDHjh9BYxpEvtfcXt4iM5g'
  324. ), (
  325. ['98831F3A:S:11', 'wallet=test/ref/98831F3A.mmwords'],
  326. 'KwmkkfC9GghnJhnKoRXRn5KwGCgXrCmDw6Uv83NzE4kJS5axCR9A'
  327. ),
  328. ],
  329. 'gen_addr': [
  330. (['98831F3A:11', 'wallet=test/ref/98831F3A.mmwords'], btc_addr5),
  331. (['98831F3A:L:11', 'wallet=test/ref/98831F3A.mmwords'], btc_addr5),
  332. (
  333. ['98831F3A:C:11', 'wallet=test/ref/98831F3A.mmwords'],
  334. '1MPsZ7BY9qikqfPxqmrovE8gLDX2rYArZk'
  335. ),
  336. (['98831F3A:B:11', 'wallet=test/ref/98831F3A.mmwords'], btc_addr6),
  337. (['98831F3A:S:11', 'wallet=test/ref/98831F3A.mmwords'], btc_addr7),
  338. ],
  339. 'get_subseed': [
  340. (['3s', 'wallet=test/ref/98831F3A.mmwords'], '4018EB17'),
  341. (['200', 'wallet=test/ref/98831F3A.mmwords'], '2B05AE73'),
  342. ],
  343. 'get_subseed_by_seed_id': [
  344. (['4018EB17', 'wallet=test/ref/98831F3A.mmwords'], '3S'),
  345. (['2B05AE73', 'wallet=test/ref/98831F3A.mmwords'], None),
  346. (['2B05AE73', 'wallet=test/ref/98831F3A.mmwords', 'last_idx=200'], '200L'),
  347. ],
  348. 'list_subseeds': [
  349. (
  350. ['1-5', 'wallet=test/ref/98831F3A.mmwords'],
  351. (md5_hash_strip, '996c047e8543d5dde6f82efc3214a6a1')
  352. ),
  353. ],
  354. 'list_shares': [
  355. (
  356. ['3', 'wallet=test/ref/98831F3A.bip39'],
  357. (md5_hash_strip, '84e8bdaebf9c816a8a3bd2ebec5a2e12')
  358. ), (
  359. ['3', 'id_str=default', 'wallet=test/ref/98831F3A.mmwords'],
  360. (md5_hash_strip, '84e8bdaebf9c816a8a3bd2ebec5a2e12')
  361. ), (
  362. ['3', 'id_str=foo', 'wallet=test/ref/98831F3A.bip39'],
  363. (md5_hash_strip, 'd2ac20823c4ea26f15234b5ca8df5d6f')
  364. ), (
  365. ['3', 'id_str=foo', 'master_share=0', 'wallet=test/ref/98831F3A.mmwords'],
  366. (md5_hash_strip, 'd2ac20823c4ea26f15234b5ca8df5d6f')
  367. ), (
  368. ['3', 'id_str=foo', 'master_share=5', 'wallet=test/ref/98831F3A.mmwords'],
  369. (md5_hash_strip, 'c4feedce40bb5959011ee4a996710832')
  370. ), (
  371. ['3', 'id_str=βαρ', 'master_share=5', 'wallet=test/ref/98831F3A.mmwords'],
  372. (md5_hash_strip, 'f7d254798fe2e34b94b5f4ff312998db')
  373. ), (
  374. ['4', 'id_str=βαρ', 'master_share=5', 'wallet=test/ref/98831F3A.bip39'],
  375. (md5_hash_strip, 'd3e479f55792181372a9f32a569c04e5')
  376. ),
  377. ],
  378. },
  379. 'Coin': {
  380. 'addr2pubhash': {
  381. 'btc_mainnet': [
  382. ([ btc_addr5], '118089d66b4a5853765e94923abdd5de4616c6e5'),
  383. ([ btc_addr6], '3057f66ddd26fa6ef826b0d5ca067ec3e8f3c178'),
  384. ],
  385. },
  386. 'eth_checksummed_addr': {
  387. 'eth_mainnet': [
  388. (['00a329c0648769a73afac7f9381e08fb43dbea72'], '00a329c0648769A73afAc7F9381E08FB43dBEA72'),
  389. (['deadbeef'*5], 'DeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF'),
  390. (['ffffffff'*5], 'FFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF'),
  391. (['0'*39 + '1'], '0'*39 + '1'),
  392. ],
  393. },
  394. 'pubhash2addr': {
  395. 'btc_mainnet': [
  396. (['118089d66b4a5853765e94923abdd5de4616c6e5'], btc_addr5, None, 'legacy'),
  397. (['8e34586186551f6320fa3eb2d238a9c61ab8264b'], '37ZBgCBjjz9WSEzp1Zjv8sqdgmNie3Kd5s',
  398. ['--type=segwit'], 'segwit'),
  399. (['3057f66ddd26fa6ef826b0d5ca067ec3e8f3c178'], btc_addr6, ['--type=bech32'], 'bech32'),
  400. ],
  401. },
  402. 'addr2scriptpubkey': {
  403. 'btc_mainnet': [
  404. ([ btc_addr5], '76a914118089d66b4a5853765e94923abdd5de4616c6e588ac'),
  405. ([ btc_addr7], 'a9148e34586186551f6320fa3eb2d238a9c61ab8264b87'),
  406. ([ btc_addr6], '00143057f66ddd26fa6ef826b0d5ca067ec3e8f3c178'),
  407. ],
  408. },
  409. 'scriptpubkey2addr': {
  410. 'btc_mainnet': [
  411. (['76a914118089d66b4a5853765e94923abdd5de4616c6e588ac'], btc_addr5),
  412. (['a9148e34586186551f6320fa3eb2d238a9c61ab8264b87'], btc_addr7),
  413. (['00143057f66ddd26fa6ef826b0d5ca067ec3e8f3c178'], btc_addr6),
  414. ],
  415. },
  416. 'hex2wif': {
  417. 'btc_mainnet': [
  418. ([privhex7], btc_wif1, None, 'legacy'),
  419. ([privhex7], btc_wif2, ['--type=compressed'], 'compressed'),
  420. ([privhex7], btc_wif2, ['--type=segwit'], 'segwit'),
  421. ([privhex7], btc_wif2, ['--type=bech32'], 'bech32'),
  422. ],
  423. },
  424. 'privhex2addr': {
  425. 'btc_mainnet': [
  426. ([privhex7], btc_addr1, None, 'legacy'),
  427. ([privhex7], btc_addr2, ['--type=compressed'], 'compressed'),
  428. ([privhex7], btc_addr3, ['--type=segwit'], 'segwit'),
  429. ([privhex7], btc_addr4, ['--type=bech32'], 'bech32'),
  430. ],
  431. 'eth_mainnet': [
  432. ([privhex1], eth_addr1),
  433. ([privhex2], eth_addr2),
  434. ([privhex3], eth_addr3),
  435. ([privhex4], eth_addr4),
  436. ([privhex5], eth_addr5),
  437. ([privhex6], eth_addr6),
  438. ],
  439. 'xmr_mainnet': [
  440. ([privhex1], xmr_addr1),
  441. ([privhex2], xmr_addr2),
  442. ([privhex3], xmr_addr3),
  443. ([privhex4], xmr_addr4),
  444. ([privhex5], xmr_addr5),
  445. ([privhex6], xmr_addr6),
  446. ],
  447. 'zec_mainnet': [
  448. ([privhex1], zec_addr1, ['--type=zcash_z'], 'zcash_z'),
  449. ([privhex2], zec_addr2, ['--type=zcash_z'], 'zcash_z'),
  450. ([privhex3], zec_addr2, ['--type=zcash_z'], 'zcash_z'),
  451. ([privhex4], zec_addr4, ['--type=zcash_z'], 'zcash_z'),
  452. ([privhex5], zec_addr5, ['--type=zcash_z'], 'zcash_z'),
  453. ([privhex6], zec_addr6, ['--type=zcash_z'], 'zcash_z'),
  454. ],
  455. },
  456. 'privhex2pubhex': {
  457. 'btc_mainnet': [
  458. ([privhex7], btc_pubhex2, None, 'legacy'),
  459. ([privhex7], btc_pubhex1, ['--type=compressed'], 'compressed'),
  460. ([privhex7], btc_pubhex1, ['--type=segwit'], 'segwit'),
  461. ([privhex7], btc_pubhex1, ['--type=bech32'], 'bech32'),
  462. ],
  463. 'eth_mainnet': [
  464. ([privhex1], eth_pubhex1),
  465. ],
  466. 'xmr_mainnet': [
  467. ([privhex1], xmr_pubhex1),
  468. ],
  469. 'zec_mainnet': [
  470. ([privhex1], zec_pubhex1, ['--type=zcash_z'], 'zcash_z'),
  471. ],
  472. },
  473. 'pubhex2addr': {
  474. 'btc_mainnet': [
  475. ([btc_pubhex2], btc_addr1, None, 'legacy'),
  476. ([btc_pubhex1], btc_addr2, ['--type=compressed'], 'compressed'),
  477. ([btc_pubhex1], btc_addr3, ['--type=segwit'], 'segwit'),
  478. ([btc_pubhex1], btc_addr4, ['--type=bech32'], 'bech32'),
  479. ],
  480. 'eth_mainnet': [
  481. ([eth_pubhex1], eth_addr1),
  482. ([eth_pubhex2], eth_addr2),
  483. ],
  484. 'xmr_mainnet': [
  485. ([xmr_pubhex1], xmr_addr1),
  486. ],
  487. 'zec_mainnet': [
  488. ([zec_pubhex1], zec_addr1, ['--type=zcash_z'], 'zcash_z'),
  489. ],
  490. },
  491. 'pubhex2redeem_script': {
  492. 'btc_mainnet': [
  493. ([btc_pubhex1], redeem_script1, ['--type=segwit'], 'segwit'),
  494. ],
  495. },
  496. 'redeem_script2addr': {
  497. 'btc_mainnet': [
  498. ([redeem_script1], btc_addr3, ['--type=segwit'], 'segwit'),
  499. ],
  500. },
  501. 'randpair': {
  502. 'btc_mainnet': [([], [is_wif_loc, is_coin_addr_loc], ['-r0'])],
  503. 'btc_testnet': [([], [is_wif_loc, is_coin_addr_loc], ['-r0'])],
  504. },
  505. 'randwif': {
  506. 'btc_mainnet': [([], is_wif_loc, ['-r0'])],
  507. 'btc_testnet': [([], is_wif_loc, ['-r0'])],
  508. },
  509. 'wif2addr': {
  510. 'btc_mainnet': [
  511. ([btc_wif1], btc_addr1, ['--type=legacy'], 'legacy'),
  512. ([btc_wif2], btc_addr2, ['--type=compressed'], 'compressed'),
  513. ([btc_wif2], btc_addr3, ['--type=segwit'], 'segwit'),
  514. ([btc_wif2], btc_addr4, ['--type=bech32'], 'bech32'),
  515. ],
  516. 'eth_mainnet': [
  517. ([privhex1], eth_addr1),
  518. (['000000000000000000000000000000014551231950b75fc4402da1732fc9bebe'], eth_addr2),
  519. ([privhex3], eth_addr3),
  520. ([privhex4], eth_addr4),
  521. (['000000000000000000000000000000014551231950b75fc4402da1732fc9bdce'], eth_addr5),
  522. ([privhex6], eth_addr6),
  523. ],
  524. 'xmr_mainnet': [
  525. ([privhex1], xmr_addr1),
  526. (['1c95988d7431ecd670cf7d73f45befc6feffffffffffffffffffffffffffff0f'], xmr_addr2),
  527. (['2c94988d7431ecd670cf7d73f45befc6feffffffffffffffffffffffffffff0f'], xmr_addr3),
  528. (['1d95988d7431ecd670cf7d73f45befc6feffffffffffffffffffffffffffff0e'], xmr_addr4),
  529. ([privhex5], xmr_addr5),
  530. (['e8164dda6d42bd1e261a3406b2038dcbddadbeefdeadbeefdeadbeefdeadbe0f'], xmr_addr6),
  531. ],
  532. 'zec_mainnet': [
  533. (
  534. ['SKxny894fJe2rmZjeuoE6GVfNkWoXfPp8337VrLLNWG56FjqVUYR'],
  535. zec_addr1, ['--type=zcash_z'], 'zcash_z'
  536. ), (
  537. ['SKxv1peuQvMT4TvqPLqKy1px3oqLm98Evi948VU8N8VKcf7C2umc'],
  538. zec_addr2, ['--type=zcash_z'], 'zcash_z'
  539. ), (
  540. ['SKxny894fJe2rmZjeuoE6GVfNkWoXfPp8337VrLLNWG56kQw4qjm'],
  541. zec_addr4, ['--type=zcash_z'], 'zcash_z'
  542. ), (
  543. ['SKxv1peuQvMT4TvqPLqKy1px3oqLm98Evi948VU8N8VKcBwrLwiu'],
  544. zec_addr5, ['--type=zcash_z'], 'zcash_z'
  545. ), (
  546. ['SKxuS56e99jpCeD9mMQ5o63zoGPakNdM9HCvt4Vt2cypvRjCdvGJ'],
  547. zec_addr6, ['--type=zcash_z'], 'zcash_z'
  548. ),
  549. ],
  550. },
  551. 'wif2hex': {
  552. 'btc_mainnet': [
  553. ([btc_wif1], privhex7, None, 'legacy'),
  554. ([btc_wif2], privhex7, ['--type=compressed'], 'compressed'),
  555. ([btc_wif2], privhex7, ['--type=segwit'], 'segwit'),
  556. ([btc_wif2], privhex7, ['--type=bech32'], 'bech32'),
  557. ],
  558. },
  559. 'wif2redeem_script': {
  560. 'btc_mainnet': [
  561. ([btc_wif2], redeem_script1, ['--type=segwit'], 'segwit'),
  562. ],
  563. },
  564. 'wif2segwit_pair': {
  565. 'btc_mainnet': [
  566. ([btc_wif2], (redeem_script1, btc_addr3), ['--type=segwit'], 'segwit'),
  567. ],
  568. },
  569. },
  570. # TODO: compressed address files are missing
  571. # 'addrfile_compressed_chk':
  572. # 'btc': ('A33C 4FDE F515 F5BC', '6C48 AA57 2056 C8C8'),
  573. # 'ltc': ('3FC0 8F03 C2D6 BD19', '4C0A 49B6 2DD1 1BE0'),
  574. 'File': {
  575. 'addrfile_chksum': {
  576. 'btc_mainnet': [
  577. (
  578. ['test/ref/98831F3A[1,31-33,500-501,1010-1011].addrs'],
  579. '6FEF 6FB9 7B13 5D91'
  580. ), (
  581. ['test/ref/98831F3A-S[1,31-33,500-501,1010-1011].addrs'],
  582. '06C1 9C87 F25C 4EE6'
  583. ), (
  584. ['test/ref/98831F3A-B[1,31-33,500-501,1010-1011].addrs'],
  585. '9D2A D4B6 5117 F02E'
  586. ),
  587. ],
  588. 'btc_testnet': [
  589. (
  590. ['test/ref/98831F3A[1,31-33,500-501,1010-1011].testnet.addrs'],
  591. '424E 4326 CFFE 5F51'
  592. ), (
  593. ['test/ref/98831F3A-S[1,31-33,500-501,1010-1011].testnet.addrs'],
  594. '072C 8B07 2730 CB7A'
  595. ), (
  596. ['test/ref/98831F3A-B[1,31-33,500-501,1010-1011].testnet.addrs'],
  597. '0527 9C39 6C1B E39A'
  598. ),
  599. ],
  600. 'ltc_mainnet': [
  601. (
  602. ['test/ref/litecoin/98831F3A-LTC[1,31-33,500-501,1010-1011].addrs'],
  603. 'AD52 C3FE 8924 AAF0'
  604. ), (
  605. ['test/ref/litecoin/98831F3A-LTC-S[1,31-33,500-501,1010-1011].addrs'],
  606. '63DF E42A 0827 21C3'
  607. ), (
  608. ['test/ref/litecoin/98831F3A-LTC-B[1,31-33,500-501,1010-1011].addrs'],
  609. 'FF1C 7939 5967 AB82'
  610. ),
  611. ],
  612. 'ltc_testnet': [
  613. (
  614. ['test/ref/litecoin/98831F3A-LTC[1,31-33,500-501,1010-1011].testnet.addrs'],
  615. '4EBE 2E85 E969 1B30'
  616. ), (
  617. ['test/ref/litecoin/98831F3A-LTC-S[1,31-33,500-501,1010-1011].testnet.addrs'],
  618. '5DD1 D186 DBE1 59F2'
  619. ), (
  620. ['test/ref/litecoin/98831F3A-LTC-B[1,31-33,500-501,1010-1011].testnet.addrs'],
  621. 'ED3D 8AA4 BED4 0B40'
  622. ),
  623. ],
  624. 'zec_mainnet': [
  625. (['test/ref/zcash/98831F3A-ZEC-C[1,31-33,500-501,1010-1011].addrs'], '903E 7225 DD86 6E01'),
  626. (
  627. ['test/ref/zcash/98831F3A-ZEC-Z[1,31-33,500-501,1010-1011].addrs'],
  628. '9C7A 72DC 3D4A B3AF', ['--type=zcash_z'], 'zcash_z'
  629. ),
  630. ],
  631. 'xmr_mainnet': [
  632. (['test/ref/monero/98831F3A-XMR-M[1,31-33,500-501,1010-1011].addrs'], '4369 0253 AC2C 0E38'),],
  633. 'dash_mainnet': [
  634. (['test/ref/dash/98831F3A-DASH-C[1,31-33,500-501,1010-1011].addrs'], 'FBC1 6B6A 0988 4403'),],
  635. 'eth_mainnet': [
  636. (['test/ref/ethereum/98831F3A-ETH[1,31-33,500-501,1010-1011].addrs'],'E554 076E 7AF6 66A3'),],
  637. 'etc_mainnet': [
  638. (
  639. ['test/ref/ethereum_classic/98831F3A-ETC[1,31-33,500-501,1010-1011].addrs'],
  640. 'E97A D796 B495 E8BC'
  641. ),
  642. ],
  643. },
  644. 'viewkeyaddrfile_chksum': {
  645. 'xmr_mainnet': [
  646. (['test/ref/monero/98831F3A-XMR-M[1-3].vkeys'], '40C9 0E61 B743 229C'),
  647. ],
  648. },
  649. 'keyaddrfile_chksum': {
  650. 'btc_mainnet': [
  651. (
  652. ['test/ref/98831F3A[1,31-33,500-501,1010-1011].akeys.mmenc'],
  653. '9F2D D781 1812 8BAD', kafile_opts
  654. ),
  655. ],
  656. 'btc_testnet': [
  657. (
  658. ['test/ref/98831F3A[1,31-33,500-501,1010-1011].testnet.akeys.mmenc'],
  659. '88CC 5120 9A91 22C2', kafile_opts
  660. ),
  661. ],
  662. 'ltc_mainnet': [
  663. (
  664. ['test/ref/litecoin/98831F3A-LTC[1,31-33,500-501,1010-1011].akeys.mmenc'],
  665. 'B804 978A 8796 3ED4', kafile_opts
  666. ),
  667. ],
  668. 'ltc_testnet': [
  669. (
  670. ['test/ref/litecoin/98831F3A-LTC[1,31-33,500-501,1010-1011].testnet.akeys.mmenc'],
  671. '98B5 AC35 F334 0398', kafile_opts
  672. ),
  673. ],
  674. 'zec_mainnet': [
  675. (
  676. ['test/ref/zcash/98831F3A-ZEC-C[1,31-33,500-501,1010-1011].akeys.mmenc'],
  677. 'F05A 5A5C 0C8E 2617', kafile_opts
  678. ), (
  679. ['test/ref/zcash/98831F3A-ZEC-Z[1,31-33,500-501,1010-1011].akeys.mmenc'],
  680. '6B87 9B2D 0D8D 8D1E', kafile_opts + ['--type=zcash_z'], 'zcash_z'
  681. ),
  682. ],
  683. 'xmr_mainnet': [
  684. (
  685. ['test/ref/monero/98831F3A-XMR-M[1,31-33,500-501,1010-1011].akeys.mmenc'],
  686. 'E0D7 9612 3D67 404A', kafile_opts
  687. ),
  688. ],
  689. 'dash_mainnet': [
  690. (
  691. ['test/ref/dash/98831F3A-DASH-C[1,31-33,500-501,1010-1011].akeys.mmenc'],
  692. 'E83D 2C63 FEA2 4142', kafile_opts
  693. ),
  694. ],
  695. 'eth_mainnet': [
  696. (
  697. ['test/ref/ethereum/98831F3A-ETH[1,31-33,500-501,1010-1011].akeys.mmenc'],
  698. 'E400 70D9 0AE3 C7C2', kafile_opts
  699. ),
  700. ],
  701. 'etc_mainnet': [
  702. (
  703. ['test/ref/ethereum_classic/98831F3A-ETC[1,31-33,500-501,1010-1011].akeys.mmenc'],
  704. 'EF49 967D BD6C FE45', kafile_opts
  705. ),
  706. ],
  707. },
  708. 'passwdfile_chksum': {
  709. 'btc_mainnet': [
  710. (
  711. ['test/ref/98831F3A-фубар@crypto.org-b58-20[1,4,1100].pws'],
  712. 'DDD9 44B0 CA28 183F', kafile_opts
  713. ),
  714. ],
  715. },
  716. 'txview': {
  717. 'btc_mainnet': [(['test/ref/0B8D5A[15.31789,14,tl=1320969600].rawtx'], None),],
  718. 'btc_testnet': [(['test/ref/0C7115[15.86255,14,tl=1320969600].testnet.rawtx'], None),],
  719. 'bch_mainnet': [(['test/ref/460D4D-BCH[10.19764,tl=1320969600].rawtx'], None),],
  720. 'bch_testnet': [(['test/ref/359FD5-BCH[6.68868,tl=1320969600].testnet.rawtx'], None),],
  721. 'ltc_mainnet': [(['test/ref/litecoin/AF3CDF-LTC[620.76194,1453,tl=1320969600].rawtx'], None),],
  722. 'ltc_testnet': [(['test/ref/litecoin/A5A1E0-LTC[1454.64322,1453,tl=1320969600].testnet.rawtx'],
  723. None),],
  724. 'eth_mainnet': [(['test/ref/ethereum/88FEFD-ETH[23.45495,40000].rawtx'], None),],
  725. 'eth_testnet': [([
  726. 'test/ref/ethereum/B472BD-ETH[23.45495,40000].testnet.rawtx',
  727. 'test/ref/ethereum/B472BD-ETH[23.45495,40000].testnet.sigtx'
  728. ], None),],
  729. 'mm1_mainnet': [(['test/ref/ethereum/5881D2-MM1[1.23456,50000].rawtx'], None),],
  730. 'mm1_testnet': [(['test/ref/ethereum/6BDB25-MM1[1.23456,50000].testnet.rawtx'], None),],
  731. 'etc_mainnet': [(['test/ref/ethereum_classic/ED3848-ETC[1.2345,40000].rawtx'], None),],
  732. },
  733. },
  734. }