ot_btc_testnet.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. """
  6. test.objtest_py_d.ot_btc_testnet: BTC testnet test vectors for MMGen data objects
  7. """
  8. from mmgen.key import PrivKey,WifKey
  9. from mmgen.addr import CoinAddr
  10. from mmgen.protocol import init_proto
  11. from .ot_common import r16,r32
  12. from ..include.common import cfg
  13. proto = init_proto( cfg, 'btc', network='testnet', need_amt=True )
  14. tests = {
  15. 'CoinAddr': {
  16. 'bad': (
  17. {'addr':1, 'proto':proto},
  18. {'addr':'x', 'proto':proto},
  19. {'addr':'я', 'proto':proto},
  20. ),
  21. 'good': (
  22. {'addr':'n2FgXPKwuFkCXF946EnoxWJDWF2VwQ6q8J', 'proto':proto},
  23. {'addr':'2MspvWFjBbkv2wzQGqhxJUYPCk3Y2jMaxLN','proto':proto},
  24. ),
  25. },
  26. 'WifKey': {
  27. 'bad': (
  28. {'proto':proto, 'wif':1},
  29. {'proto':proto, 'wif':[]},
  30. {'proto':proto, 'wif':'\0'},
  31. {'proto':proto, 'wif':'\1'},
  32. {'proto':proto, 'wif':'я'},
  33. {'proto':proto, 'wif':'g'},
  34. {'proto':proto, 'wif':'gg'},
  35. {'proto':proto, 'wif':'FF'},
  36. {'proto':proto, 'wif':'f00'},
  37. {'proto':proto, 'wif':r16.hex()},
  38. {'proto':proto, 'wif':'2MspvWFjBbkv2wzQGqhxJUYPCk3Y2jMaxLN'},
  39. ),
  40. 'good': (
  41. {'proto':proto, 'wif':'93HsQEpH75ibaUJYi3QwwiQxnkW4dUuYFPXZxcbcKds7XrqHkY6', 'ret_idx':1},
  42. {'proto':proto, 'wif':'cMsqcmDYZP1LdKgqRh9L4ZRU9br28yvdmTPwW2YQwVSN9aQiMAoR', 'ret_idx':1},
  43. )
  44. },
  45. 'PrivKey': {
  46. 'bad': (
  47. {'proto':proto, 'wif':1},
  48. {'proto':proto, 'wif':'1'},
  49. {'proto':proto, 'wif':'5KXEpVzjWreTcQoG5hX357s1969MUKNLuSfcszF6yu84kpsNZKb'},
  50. {'proto':proto, 's':r32,'wif':'5KXEpVzjWreTcQoG5hX357s1969MUKNLuSfcszF6yu84kpsNZKb'},
  51. {'proto':proto, 'pubkey_type':'std'},
  52. {'proto':proto, 's':r32},
  53. {'proto':proto, 's':r32,'compressed':'yes'},
  54. {'proto':proto, 's':r32,'compressed':'yes','pubkey_type':'std'},
  55. {'proto':proto, 's':r32,'compressed':True,'pubkey_type':'nonstd'},
  56. {'proto':proto, 's':r32+b'x','compressed':True,'pubkey_type':'std'}
  57. ),
  58. 'good': (
  59. {'proto':proto, 'wif':'93HsQEpH75ibaUJYi3QwwiQxnkW4dUuYFPXZxcbcKds7XrqHkY6',
  60. 'ret':bytes.fromhex('e0aef965b905a2fedf907151df8e0a6bac832aa697801c51f58bd2ecb4fd381c')},
  61. {'proto':proto, 'wif':'cMsqcmDYZP1LdKgqRh9L4ZRU9br28yvdmTPwW2YQwVSN9aQiMAoR',
  62. 'ret':bytes.fromhex('08d0ed83b64b68d56fa064be48e2385060ed205be2b1e63cd56d218038c3a05f')},
  63. {'proto':proto, 's':r32,'compressed':False,'pubkey_type':'std','ret':r32},
  64. {'proto':proto, 's':r32,'compressed':True,'pubkey_type':'std','ret':r32}
  65. ),
  66. },
  67. }