params.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 ...obj import Hostname
  15. from ...addr import CoinAddr
  16. from ...contrib import bech32
  17. from ..btc.params import mainnet as btc_mainnet
  18. class mainnet(CoinProtocol.Secp256k1):
  19. mod_clsname = 'THORChain'
  20. network_names = _nw('mainnet', 'stagenet', 'testnet')
  21. chain_id = 'thorchain-1'
  22. mmtypes = ('X',)
  23. preferred_mmtypes = ('X',)
  24. dfl_mmtype = 'X'
  25. coin_amt = 'UniAmt'
  26. max_tx_fee = 0.1
  27. caps = ()
  28. mmcaps = ('tw', 'rpc', 'rpc_init')
  29. base_proto = 'THORChain'
  30. base_proto_coin = 'RUNE'
  31. base_coin = 'RUNE'
  32. bech32_hrp = 'thor'
  33. sign_mode = 'standalone'
  34. rpc_type = 'remote'
  35. avg_bdi = 6 # TODO
  36. has_usr_fee = False
  37. is_vm = True
  38. address_reuse_ok = False
  39. wif_ver_num = btc_mainnet.wif_ver_num
  40. coin_cfg_opts = btc_mainnet.coin_cfg_opts
  41. encode_wif = btc_mainnet.encode_wif
  42. decode_wif = btc_mainnet.decode_wif
  43. rpc_remote_params = {'server_domain': Hostname('ninerealms.com')}
  44. rpc_remote_rest_params = {'host': Hostname('thornode.ninerealms.com')}
  45. rpc_remote_rpc_params = {'host': Hostname('rpc.ninerealms.com')}
  46. rpc_swap_params = {'host': Hostname('thornode.ninerealms.com')}
  47. def decode_addr(self, addr):
  48. hrp, data = bech32.bech32_decode(addr)
  49. assert hrp == self.bech32_hrp, f'{hrp!r}: invalid bech32 hrp (should be {self.bech32_hrp!r})'
  50. return decoded_addr(
  51. bytes(bech32.convertbits(data, 5, 8)),
  52. None,
  53. 'bech32') if data else False
  54. def encode_addr_bech32x(self, pubhash):
  55. return CoinAddr(
  56. self,
  57. bech32.bech32_encode(
  58. hrp = self.bech32_hrp,
  59. data = bech32.convertbits(list(pubhash), 8, 5)))
  60. class testnet(mainnet): # testnet is stagenet
  61. bech32_hrp = 'sthor'
  62. rpc_remote_rest_params = {'host': Hostname('stagenet-thornode.ninerealms.com')}
  63. rpc_remote_rpc_params = {'host': Hostname('stagenet-rpc.ninerealms.com')}
  64. rpc_swap_params = {'host': Hostname('stagenet-thornode.ninerealms.com')}
  65. class regtest(testnet): # regtest is deprecated testnet
  66. bech32_hrp = 'tthor'
  67. rpc_remote_params = {
  68. 'server_domain': Hostname('localhost')}
  69. rpc_remote_rest_params = {
  70. 'network_proto': 'http',
  71. 'host': Hostname('localhost:18800'),
  72. 'verify': False}
  73. rpc_remote_rpc_params = rpc_remote_rest_params
  74. rpc_swap_params = rpc_remote_rest_params | {'host': Hostname('localhost:18900')}