oat_btc_mainnet.py 4.1 KB

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