oat_btc_mainnet.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2023 The MMGen Project <mmgen@tuta.io>
  5. """
  6. test.objattrtest_py_d.oat_btc_mainnet: BTC mainnet test vectors for MMGen data objects
  7. """
  8. from .oat_common import *
  9. from ..include.common import cfg
  10. from mmgen.protocol import init_proto
  11. from mmgen.amt import BTCAmt
  12. proto = init_proto( cfg, 'btc', need_amt=True )
  13. sample_objs.update({
  14. 'PrivKey': PrivKey(proto,seed_bin,compressed=True,pubkey_type='std'),
  15. 'WifKey': WifKey(proto,'5HwzecKMWD82ppJK3qMKpC7ohXXAwcyAN5VgdJ9PLFaAzpBG4sX'),
  16. 'CoinAddr': CoinAddr(proto,'1111111111111111111114oLvT2'),
  17. 'BTCAmt': BTCAmt('0.01'),
  18. 'MMGenID': MMGenID(proto,'F00F00BB:B:1'),
  19. 'TwMMGenID': TwMMGenID(proto,'F00F00BB:S:23'),
  20. })
  21. tests = {
  22. # addr.py
  23. 'AddrListEntry': atd({
  24. 'addr': (0b001, CoinAddr),
  25. 'idx': (0b001, AddrIdx),
  26. 'comment': (0b101, TwComment),
  27. 'sec': (0b001, PrivKey),
  28. # 'viewkey': (0b001, ViewKey), # TODO
  29. # 'wallet_passwd': (0b001, WalletPassword), # TODO
  30. },
  31. (proto,),
  32. {}
  33. ),
  34. 'PasswordListEntry': atd({
  35. 'passwd': (0b001, str),
  36. 'idx': (0b001, AddrIdx),
  37. 'comment':(0b101, TwComment),
  38. 'sec': (0b001, PrivKey),
  39. },
  40. (proto,),
  41. {'passwd':'ΑlphaΩmega', 'idx':1 },
  42. ),
  43. # obj.py
  44. 'PrivKey': atd({
  45. 'compressed': (0b001, bool),
  46. 'wif': (0b001, WifKey),
  47. },
  48. (proto,seed_bin),
  49. {'compressed':True, 'pubkey_type':'std'},
  50. ),
  51. 'MMGenAddrType': atd({
  52. 'name': (0b001, str),
  53. 'pubkey_type': (0b001, str),
  54. 'compressed': (0b001, bool),
  55. 'gen_method': (0b001, str),
  56. 'addr_fmt': (0b001, str),
  57. 'wif_label': (0b001, str),
  58. 'extra_attrs': (0b001, tuple),
  59. 'desc': (0b001, str),
  60. },
  61. (proto,'S'),
  62. {},
  63. ),
  64. # seed.py
  65. 'SeedBase': atd({
  66. 'data': (0b001, bytes),
  67. 'sid': (0b001, SeedID),
  68. },
  69. [cfg,seed_bin],
  70. {},
  71. ),
  72. 'SubSeed': atd({
  73. 'idx': (0b001, int),
  74. 'nonce': (0b001, int),
  75. 'ss_idx': (0b001, SubSeedIdx),
  76. },
  77. [sample_objs['SubSeedList'],1,1,'short'],
  78. {},
  79. ),
  80. 'SeedShareList': atd({
  81. 'count': (0b001, SeedShareCount),
  82. 'id_str': (0b001, SeedSplitIDString),
  83. },
  84. [sample_objs['Seed'],sample_objs['SeedShareCount']],
  85. {},
  86. ),
  87. 'SeedShareLast': atd({
  88. 'idx': (0b001, SeedShareIdx),
  89. },
  90. [sample_objs['SeedShareList']],
  91. {},
  92. ),
  93. 'SeedShareMaster': atd({
  94. 'idx': (0b001, MasterShareIdx),
  95. 'nonce': (0b001, int),
  96. },
  97. [sample_objs['SeedShareList'],7,0],
  98. {},
  99. ),
  100. 'SeedShareMasterJoining': atd({
  101. 'id_str': (0b001, SeedSplitIDString),
  102. 'count': (0b001, SeedShareCount),
  103. },
  104. [cfg,sample_objs['MasterShareIdx'], sample_objs['Seed'], 'foo', 2],
  105. {},
  106. ),
  107. # twuo.py
  108. 'BitcoinTwUnspentOutputs.MMGenTwUnspentOutput': atd({
  109. 'txid': (0b001, CoinTxID),
  110. 'vout': (0b001, int),
  111. 'amt': (0b001, BTCAmt),
  112. 'amt2': (0b001, BTCAmt),
  113. 'comment': (0b101, TwComment),
  114. 'twmmid': (0b001, TwMMGenID),
  115. 'addr': (0b001, CoinAddr),
  116. 'confs': (0b001, int),
  117. 'scriptPubKey': (0b001, HexStr),
  118. 'skip': (0b101, str),
  119. },
  120. (proto,),
  121. {
  122. 'amt':BTCAmt('0.01'),
  123. 'twmmid':'F00F00BB:B:17',
  124. 'addr':'1111111111111111111114oLvT2',
  125. 'confs': 100000,
  126. 'scriptPubKey':'ff',
  127. },
  128. ),
  129. # tx.py
  130. 'Base.Input': atd({
  131. 'vout': (0b001, int),
  132. 'amt': (0b001, BTCAmt),
  133. 'comment': (0b101, TwComment),
  134. 'mmid': (0b001, MMGenID),
  135. 'addr': (0b001, CoinAddr),
  136. 'confs': (0b001, int),
  137. 'txid': (0b001, CoinTxID),
  138. 'have_wif': (0b011, bool),
  139. 'scriptPubKey': (0b001, HexStr),
  140. 'sequence': (0b001, int),
  141. },
  142. (proto,),
  143. { 'amt':BTCAmt('0.01'), 'addr':sample_objs['CoinAddr'] },
  144. ),
  145. 'Base.Output': atd({
  146. 'vout': (0b001, int),
  147. 'amt': (0b001, BTCAmt),
  148. 'comment': (0b101, TwComment),
  149. 'mmid': (0b001, MMGenID),
  150. 'addr': (0b001, CoinAddr),
  151. 'confs': (0b001, int),
  152. 'txid': (0b001, CoinTxID),
  153. 'have_wif': (0b011, bool),
  154. 'is_chg': (0b001, bool),
  155. },
  156. (proto,),
  157. { 'amt':BTCAmt('0.01'), 'addr':sample_objs['CoinAddr'] },
  158. ),
  159. }
  160. tests['MMGenPasswordType'] = atd(tests['MMGenAddrType'].attrs, [proto,'P'], {})