params.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2025 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. proto.rune.params: THORChain protocol
  12. """
  13. from ...protocol import CoinProtocol, decoded_addr, _nw
  14. from ...addr import CoinAddr
  15. from ...contrib import bech32
  16. from ..btc.params import mainnet as btc_mainnet
  17. class mainnet(CoinProtocol.Secp256k1):
  18. mod_clsname = 'THORChain'
  19. network_names = _nw('mainnet', 'stagenet', 'testnet')
  20. mmtypes = ('X',)
  21. preferred_mmtypes = ('X',)
  22. dfl_mmtype = 'X'
  23. coin_amt = 'UniAmt'
  24. max_tx_fee = 1 # TODO
  25. caps = ()
  26. mmcaps = ()
  27. base_proto = 'THORChain'
  28. base_proto_coin = 'RUNE'
  29. base_coin = 'RUNE'
  30. bech32_hrp = 'thor'
  31. sign_mode = 'standalone'
  32. avg_bdi = 6 # TODO
  33. address_reuse_ok = False
  34. wif_ver_num = btc_mainnet.wif_ver_num
  35. coin_cfg_opts = btc_mainnet.coin_cfg_opts
  36. encode_wif = btc_mainnet.encode_wif
  37. decode_wif = btc_mainnet.decode_wif
  38. def decode_addr(self, addr):
  39. hrp, data = bech32.bech32_decode(addr)
  40. assert hrp == self.bech32_hrp, f'{hrp!r}: invalid bech32 hrp (should be {self.bech32_hrp!r})'
  41. return decoded_addr(
  42. bytes(bech32.convertbits(data, 5, 8)),
  43. None,
  44. 'bech32') if data else False
  45. def encode_addr_bech32x(self, pubhash):
  46. return CoinAddr(
  47. self,
  48. bech32.bech32_encode(
  49. hrp = self.bech32_hrp,
  50. data = bech32.convertbits(list(pubhash), 8, 5)))
  51. class stagenet(mainnet):
  52. bech32_hrp = 'sthor'
  53. class testnet(stagenet): # testnet is deprecated
  54. bech32_hrp = 'tthor'