Browse Source

proto: btc.py -> btc/params.py, ... [code]

The MMGen Project 2 years ago
parent
commit
3f182fed64

+ 1 - 1
mmgen/addrfile.py

@@ -209,7 +209,7 @@ class AddrFile(MMGenObject):
 			else:
 				network = 'mainnet'
 
-			from .proto.btc import mainnet
+			from .proto.btc.params import mainnet
 			if lbl in [MMGenAddrType(mainnet,key).name for key in mainnet.mmtypes]:
 				coin,mmtype_key = ( 'BTC', lbl )
 			elif ':' in lbl: # first component is coin, second is mmtype_key

+ 1 - 1
mmgen/altcoin.py

@@ -736,7 +736,7 @@ def init_genonly_altcoins(usr_coin=None,testnet=False):
 def create_altcoin_protos(data):
 
 	from .protocol import CoinProtocol
-	from .proto.btc import mainnet
+	from .proto.btc.params import mainnet
 
 	def make_proto(e,testnet=False):
 

+ 1 - 1
mmgen/help.py

@@ -162,7 +162,7 @@ one address with no amount on the command line.
 """
 
 		def txsign():
-			from .proto.btc import mainnet
+			from .proto.btc.params import mainnet
 			return """
 Transactions may contain both {pnm} or non-{pnm} input addresses.
 

+ 1 - 1
mmgen/keygen.py

@@ -107,7 +107,7 @@ class keygen_backend:
 
 			def __init__(self):
 
-				from .proto.xmr import mainnet
+				from .proto.xmr.params import mainnet
 				self.proto_cls = mainnet
 
 				from .util import get_keccak

+ 0 - 0
mmgen/proto/__init__.py


+ 1 - 1
mmgen/proto/bch/params.py

@@ -12,7 +12,7 @@
 Bitcoin Cash protocol
 """
 
-from .btc import mainnet,_finfo
+from ..btc.params import mainnet,_finfo
 
 class mainnet(mainnet):
 	is_fork_of      = 'Bitcoin'

+ 3 - 3
mmgen/proto/btc/params.py

@@ -12,8 +12,8 @@
 Bitcoin protocol
 """
 
-from ..protocol import CoinProtocol,decoded_wif,decoded_addr,_finfo,_nw
-from .common import *
+from ...protocol import CoinProtocol,decoded_wif,decoded_addr,_finfo,_nw
+from ..common import *
 
 class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
 	"""
@@ -80,7 +80,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
 			ret = bech32.decode(self.bech32_hrp,addr)
 
 			if ret[0] != self.witness_vernum:
-				from ..util import msg
+				from ...util import msg
 				msg(f'{ret[0]}: Invalid witness version number')
 				return False
 

+ 1 - 1
mmgen/proto/etc/params.py

@@ -12,7 +12,7 @@
 Ethereum Classic protocol
 """
 
-from .eth import mainnet
+from ..eth.params import mainnet
 
 class mainnet(mainnet):
 	chain_names = ['classic','ethereum_classic']

+ 3 - 3
mmgen/proto/eth/params.py

@@ -12,9 +12,9 @@
 Ethereum protocol
 """
 
-from ..globalvars import g
-from ..protocol import CoinProtocol,_nw,decoded_addr
-from ..util import is_hex_str_lc,Msg
+from ...globalvars import g
+from ...protocol import CoinProtocol,_nw,decoded_addr
+from ...util import is_hex_str_lc,Msg
 
 class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1):
 

+ 1 - 1
mmgen/proto/ltc/params.py

@@ -12,7 +12,7 @@
 Litecoin protocol
 """
 
-from .btc import mainnet
+from ..btc.params import mainnet
 
 class mainnet(mainnet):
 	block0          = '12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2'

+ 3 - 3
mmgen/proto/xmr/params.py

@@ -14,7 +14,7 @@ Monero protocol
 
 from collections import namedtuple
 
-from ..protocol import CoinProtocol,_nw
+from ...protocol import CoinProtocol,_nw
 
 parsed_addr = namedtuple('parsed_addr',['ver_bytes','data','payment_id'])
 
@@ -39,7 +39,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Base):
 		return (64,72)[addr_fmt == 'monero_integrated']
 
 	def preprocess_key(self,sec,pubkey_type): # reduce key
-		from ..contrib.ed25519 import l
+		from ...contrib.ed25519 import l
 		return int.to_bytes(
 			int.from_bytes( sec[::-1], 'big' ) % l,
 			self.privkey_len,
@@ -47,7 +47,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Base):
 
 	def decode_addr(self,addr):
 
-		from ..baseconv import baseconv
+		from ...baseconv import baseconv
 
 		def b58dec(addr_str):
 			bc = baseconv('b58')

+ 4 - 4
mmgen/proto/zec/params.py

@@ -12,9 +12,9 @@
 Zcash protocol
 """
 
-from .btc import mainnet
-from .common import b58chk_decode
-from ..protocol import decoded_wif,decoded_addr
+from ..btc.params import mainnet
+from ..common import b58chk_decode
+from ...protocol import decoded_wif,decoded_addr
 
 class mainnet(mainnet):
 	base_coin      = 'ZEC'
@@ -28,7 +28,7 @@ class mainnet(mainnet):
 
 	def __init__(self,*args,**kwargs):
 		super().__init__(*args,**kwargs)
-		from ..opts import opt
+		from ...opts import opt
 		self.coin_id = 'ZEC-Z' if opt.type in ('zcash_z','Z') else 'ZEC-T'
 
 	def get_wif_ver_bytes_len(self,key_data):

+ 1 - 1
mmgen/protocol.py

@@ -236,7 +236,7 @@ def init_proto(coin=None,testnet=False,regtest=False,network=None,network_id=Non
 		setattr(
 			CoinProtocol,
 			proto_name,
-			getattr(importlib.import_module(f'mmgen.proto.{coin}'),network)
+			getattr(importlib.import_module(f'mmgen.proto.{coin}.params'),network)
 		)
 
 	return getattr(CoinProtocol,proto_name)(

+ 7 - 0
setup.cfg

@@ -55,6 +55,13 @@ packages =
 	mmgen.contrib
 	mmgen.data
 	mmgen.proto
+	mmgen.proto.bch
+	mmgen.proto.btc
+	mmgen.proto.etc
+	mmgen.proto.eth
+	mmgen.proto.ltc
+	mmgen.proto.xmr
+	mmgen.proto.zec
 	mmgen.share
 	mmgen.tool
 	mmgen.tx

+ 7 - 0
test/overlay/__init__.py

@@ -52,6 +52,13 @@ def overlay_setup(repo_root):
 				'mmgen.base_proto.monero',
 				'mmgen.data',
 				'mmgen.proto',
+				'mmgen.proto.bch',
+				'mmgen.proto.btc',
+				'mmgen.proto.etc',
+				'mmgen.proto.eth',
+				'mmgen.proto.ltc',
+				'mmgen.proto.xmr',
+				'mmgen.proto.zec',
 				'mmgen.share',
 				'mmgen.tool',
 				'mmgen.tx',