Browse Source

base_proto.bitcoin -> proto.btc, ... [code]

The MMGen Project 2 years ago
parent
commit
076cec7495

+ 1 - 1
MANIFEST.in

@@ -6,7 +6,7 @@ include doc/*/*/*
 
 include examples/*
 
-include mmgen/base_proto/ethereum/*/LICENSE
+include mmgen/proto/eth/*/LICENSE
 include mmgen/data/*
 
 include scripts/*

+ 1 - 1
mmgen/daemon.py

@@ -302,7 +302,7 @@ class CoinDaemon(Daemon):
 			from .protocol import init_proto
 			proto = init_proto(coin)
 		return getattr(
-			importlib.import_module(f'mmgen.base_proto.{proto.base_proto.lower()}.daemon'),
+			importlib.import_module(f'mmgen.proto.{proto.base_proto_coin.lower()}.daemon'),
 			daemon_id+'_daemon' )
 
 	@classmethod

+ 1 - 1
mmgen/data/release_date

@@ -1 +1 @@
-September 2022
+October 2022

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-13.3.dev0
+13.3.dev1

+ 1 - 1
mmgen/main_regtest.py

@@ -57,7 +57,7 @@ opts_data = {
 
 cmd_args = opts.init(opts_data)
 
-from .base_proto.bitcoin.regtest import MMGenRegtest
+from .proto.btc.regtest import MMGenRegtest
 
 def check_num_args():
 	m = getattr(MMGenRegtest,cmd_args[0])

+ 1 - 1
mmgen/msg.py

@@ -365,7 +365,7 @@ def _get_obj(clsname,coin=None,network='mainnet',infile=None,data=None,*args,**k
 
 	try:
 		msg_cls = getattr(
-			importlib.import_module(f'mmgen.base_proto.{proto.base_proto.lower()}.msg'),
+			importlib.import_module(f'mmgen.proto.{proto.base_proto_coin.lower()}.msg'),
 			'coin_msg' )
 	except:
 		die(1,f'Message signing operations not supported for {proto.base_proto} protocol')

+ 1 - 1
mmgen/opts.py

@@ -605,7 +605,7 @@ def check_usr_opts(usr_opts): # Raises an exception if any check fails
 #			die( 'UserOptError', f'--rbf requested, but {proto.coin} does not support replace-by-fee transactions' )
 
 #	def chk_bob(key,val,desc):
-#		from .base_proto.bitcoin.regtest import MMGenRegtest
+#		from .proto.btc.regtest import MMGenRegtest
 #		try:
 #			os.stat(os.path.join(MMGenRegtest(g.coin).d.datadir,'regtest','debug.log'))
 #		except:

+ 2 - 1
mmgen/proto/btc/params.py

@@ -35,8 +35,9 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
 	]
 	caps            = ('rbf','segwit')
 	mmcaps          = ('key','addr','rpc_init','tx')
-	base_coin       = 'BTC'
 	base_proto      = 'Bitcoin'
+	base_proto_coin = 'BTC'
+	base_coin       = 'BTC'
 	# From BIP173: witness version 'n' is stored as 'OP_n'. OP_0 is encoded as 0x00,
 	# but OP_1 through OP_16 are encoded as 0x51 though 0x60 (81 to 96 in decimal).
 	witness_vernum_hex = '00'

+ 2 - 1
mmgen/proto/eth/params.py

@@ -23,7 +23,6 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1):
 	mmtypes       = ('E',)
 	dfl_mmtype    = 'E'
 	mod_clsname   = 'Ethereum'
-	base_coin     = 'ETH'
 	pubkey_type   = 'std' # required by DummyWIF
 
 	coin_amt      = 'ETHAmt'
@@ -33,6 +32,8 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1):
 	caps          = ('token',)
 	mmcaps        = ('key','addr','rpc_init','tx')
 	base_proto    = 'Ethereum'
+	base_proto_coin = 'ETH'
+	base_coin     = 'ETH'
 	avg_bdi       = 15
 	ignore_daemon_version = False
 

+ 2 - 1
mmgen/proto/xmr/params.py

@@ -22,8 +22,9 @@ parsed_addr = namedtuple('parsed_addr',['ver_bytes','data','payment_id'])
 class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Base):
 
 	network_names  = _nw('mainnet','stagenet',None)
-	base_coin      = 'XMR'
 	base_proto     = 'Monero'
+	base_proto_coin = 'XMR'
+	base_coin      = 'XMR'
 	addr_ver_info  = { '12': 'monero', '2a': 'monero_sub', '13': 'monero_integrated' }
 	pubkey_types   = ('monero',)
 	mmtypes        = ('M',)

+ 2 - 0
mmgen/protocol.py

@@ -49,6 +49,8 @@ class CoinProtocol(MMGenObject):
 
 	class Base(MMGenObject):
 		base_proto = None
+		base_proto_coin  = None
+		base_coin  = None
 		is_fork_of = None
 		networks   = ('mainnet','testnet','regtest')
 

+ 1 - 1
mmgen/rpc.py

@@ -478,7 +478,7 @@ async def rpc_init(
 		die(1,f'rpc_init() not supported for {proto.name} protocol!')
 
 	cls = getattr(
-		importlib.import_module(f'mmgen.base_proto.{proto.base_proto.lower()}.rpc'),
+		importlib.import_module(f'mmgen.proto.{proto.base_proto_coin.lower()}.rpc'),
 			proto.base_proto + 'RPCClient' )
 
 	from .daemon import CoinDaemon

+ 2 - 2
mmgen/tool/coin.py

@@ -180,12 +180,12 @@ class tool_cmd(tool_cmd_base):
 
 	def addr2scriptpubkey(self,addr:'sstr'):
 		"convert coin address to scriptPubKey"
-		from ..base_proto.bitcoin.tx.base import addr2scriptPubKey
+		from ..proto.btc.tx.base import addr2scriptPubKey
 		return addr2scriptPubKey( self.proto, CoinAddr(self.proto,addr) )
 
 	def scriptpubkey2addr(self,hexstr:'sstr'):
 		"convert scriptPubKey to coin address"
-		from ..base_proto.bitcoin.tx.base import scriptPubKey2addr
+		from ..proto.btc.tx.base import scriptPubKey2addr
 		return scriptPubKey2addr( self.proto, hexstr )[0]
 
 	def eth_checksummed_addr(self,addr:'sstr'):

+ 1 - 1
mmgen/tool/fileutil.py

@@ -153,6 +153,6 @@ class tool_cmd(tool_cmd_base):
 		"decrypt the encrypted private key in a Geth keystore wallet, returning the decrypted key"
 		from ..util import line_input
 		from ..opts import opt
-		from ..base_proto.ethereum.misc import extract_key_from_geth_keystore_wallet
+		from ..proto.eth.misc import extract_key_from_geth_keystore_wallet
 		passwd = line_input( 'Enter passphrase: ', echo=opt.echo_passphrase ).strip().encode()
 		return extract_key_from_geth_keystore_wallet( wallet_file, passwd, check_addr ).hex()

+ 1 - 1
mmgen/tx/__init__.py

@@ -17,7 +17,7 @@ from ..objmethods import MMGenObject
 def _base_proto_subclass(clsname,modname,proto):
 	if proto:
 		clsname = ('Token' if proto.tokensym else '') + clsname
-		modname = 'mmgen.base_proto.{}.tx.{}'.format( proto.base_proto.lower(), modname )
+		modname = 'mmgen.proto.{}.tx.{}'.format( proto.base_proto_coin.lower(), modname )
 	else:
 		modname = 'mmgen.tx.base'
 	import importlib

+ 1 - 1
mmgen/tx/info.py

@@ -117,5 +117,5 @@ class TxInfo:
 
 def init_info(tx):
 	return getattr(
-		importlib.import_module(f'mmgen.base_proto.{tx.proto.base_proto.lower()}.tx.info'),
+		importlib.import_module(f'mmgen.proto.{tx.proto.base_proto_coin.lower()}.tx.info'),
 		('Token' if tx.proto.tokensym else '') + 'TxInfo' )(tx)

+ 2 - 2
mmgen/util.py

@@ -660,8 +660,8 @@ def base_proto_subclass(cls,proto,subdir,modname,sub_clsname=None):
 	"""
 	magic module loading and class selection
 	"""
-	modpath = 'mmgen.base_proto.{}.{}{}'.format(
-		proto.base_proto.lower(),
+	modpath = 'mmgen.proto.{}.{}{}'.format(
+		proto.base_proto_coin.lower(),
 		subdir + '.' if subdir else '',
 		modname )
 

+ 2 - 2
mmgen/xmrwallet.py

@@ -31,8 +31,8 @@ from .proto.common import b58a
 from .addr import CoinAddr,AddrIdx
 from .addrlist import KeyAddrList,AddrIdxList
 from .rpc import json_encoder
-from .base_proto.monero.rpc import MoneroRPCClientRaw,MoneroWalletRPCClient
-from .base_proto.monero.daemon import MoneroWalletDaemon
+from .proto.xmr.rpc import MoneroRPCClientRaw,MoneroWalletRPCClient
+from .proto.xmr.daemon import MoneroWalletDaemon
 
 xmrwallet_uarg_info = (
 	lambda e,hp: {

+ 7 - 11
setup.cfg

@@ -41,24 +41,20 @@ install_requires =
 
 packages =
 	mmgen
-	mmgen.base_proto
-	mmgen.base_proto.bitcoin
-	mmgen.base_proto.bitcoin.tx
-	mmgen.base_proto.bitcoin.tw
-	mmgen.base_proto.ethereum
-	mmgen.base_proto.ethereum.pyethereum
-	mmgen.base_proto.ethereum.rlp
-	mmgen.base_proto.ethereum.rlp.sedes
-	mmgen.base_proto.ethereum.tx
-	mmgen.base_proto.ethereum.tw
-	mmgen.base_proto.monero
 	mmgen.contrib
 	mmgen.data
 	mmgen.proto
 	mmgen.proto.bch
 	mmgen.proto.btc
+	mmgen.proto.btc.tx
+	mmgen.proto.btc.tw
 	mmgen.proto.etc
 	mmgen.proto.eth
+	mmgen.proto.eth.pyethereum
+	mmgen.proto.eth.rlp
+	mmgen.proto.eth.rlp.sedes
+	mmgen.proto.eth.tx
+	mmgen.proto.eth.tw
 	mmgen.proto.ltc
 	mmgen.proto.xmr
 	mmgen.proto.zec

+ 1 - 1
test/objattrtest.py

@@ -35,7 +35,7 @@ from mmgen.common import *
 from mmgen.addrlist import *
 from mmgen.passwdlist import *
 from mmgen.tx.base import Base
-from mmgen.base_proto.bitcoin.tw.unspent import BitcoinTwUnspentOutputs
+from mmgen.proto.btc.tw.unspent import BitcoinTwUnspentOutputs
 
 opts_data = {
 	'sets': [

+ 7 - 11
test/overlay/__init__.py

@@ -39,23 +39,19 @@ def overlay_setup(repo_root):
 		for d in (
 				'mmgen',
 				'mmgen.contrib',
-				'mmgen.base_proto',
-				'mmgen.base_proto.bitcoin',
-				'mmgen.base_proto.bitcoin.tx',
-				'mmgen.base_proto.bitcoin.tw',
-				'mmgen.base_proto.ethereum',
-				'mmgen.base_proto.ethereum.pyethereum',
-				'mmgen.base_proto.ethereum.rlp',
-				'mmgen.base_proto.ethereum.rlp.sedes',
-				'mmgen.base_proto.ethereum.tx',
-				'mmgen.base_proto.ethereum.tw',
-				'mmgen.base_proto.monero',
 				'mmgen.data',
 				'mmgen.proto',
 				'mmgen.proto.bch',
 				'mmgen.proto.btc',
+				'mmgen.proto.btc.tx',
+				'mmgen.proto.btc.tw',
 				'mmgen.proto.etc',
 				'mmgen.proto.eth',
+				'mmgen.proto.eth.pyethereum',
+				'mmgen.proto.eth.rlp',
+				'mmgen.proto.eth.rlp.sedes',
+				'mmgen.proto.eth.tx',
+				'mmgen.proto.eth.tw',
 				'mmgen.proto.ltc',
 				'mmgen.proto.xmr',
 				'mmgen.proto.zec',

+ 3 - 3
test/test_py_d/ts_ethdev.py

@@ -452,7 +452,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 
 			wallet_fn = os.path.join( self.keystore_dir, os.listdir(self.keystore_dir)[0] )
 
-			from mmgen.base_proto.ethereum.misc import extract_key_from_geth_keystore_wallet
+			from mmgen.proto.eth.misc import extract_key_from_geth_keystore_wallet
 			key = extract_key_from_geth_keystore_wallet(
 				wallet_fn = wallet_fn,
 				passwd = b'' )
@@ -709,7 +709,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 		def create_signature_mmgen():
 			key = self.keystore_data['key']
 			imsg(f'Key:       {key}')
-			from mmgen.base_proto.ethereum.misc import ec_sign_message_with_privkey
+			from mmgen.proto.eth.misc import ec_sign_message_with_privkey
 			return ec_sign_message_with_privkey(self.message,bytes.fromhex(key),'eth_sign')
 
 		async def create_signature_rpc():
@@ -976,7 +976,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 		usr_mmaddrs = [f'{sid}:E:{i}' for i in (11,21)]
 		usr_addrs = [tool_cmd(cmdname='gen_addr',proto=self.proto).gen_addr(addr,dfl_words_file) for addr in usr_mmaddrs]
 
-		from mmgen.base_proto.ethereum.contract import TokenResolve
+		from mmgen.proto.eth.contract import TokenResolve
 		async def do_transfer(rpc):
 			for i in range(2):
 				tk = await TokenResolve(

+ 1 - 1
test/test_py_d/ts_regtest.py

@@ -524,7 +524,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
 		if not self.deterministic:
 			return 'skip'
 		self.spawn('',msg_only=True)
-		from mmgen.base_proto.bitcoin.regtest import MMGenRegtest
+		from mmgen.proto.btc.regtest import MMGenRegtest
 		rt = MMGenRegtest(self.proto.coin)
 		await rt.stop()
 		from shutil import rmtree

+ 2 - 2
test/test_py_d/ts_xmrwallet.py

@@ -189,8 +189,8 @@ class TestSuiteXMRWallet(TestSuiteBase):
 
 	def init_users(self):
 		from mmgen.daemon import CoinDaemon
-		from mmgen.base_proto.monero.daemon import MoneroWalletDaemon
-		from mmgen.base_proto.monero.rpc import MoneroRPCClient,MoneroRPCClientRaw,MoneroWalletRPCClient
+		from mmgen.proto.xmr.daemon import MoneroWalletDaemon
+		from mmgen.proto.xmr.rpc import MoneroRPCClient,MoneroRPCClientRaw,MoneroWalletRPCClient
 		self.users = {}
 		n = self.tmpdir_nums[0]
 		ud = namedtuple('user_data',[

+ 2 - 2
test/unit_tests_d/ut_rpc.py

@@ -8,8 +8,8 @@ from mmgen.common import *
 from mmgen.protocol import init_proto
 from mmgen.rpc import rpc_init
 from mmgen.daemon import CoinDaemon
-from mmgen.base_proto.monero.rpc import MoneroRPCClient,MoneroRPCClientRaw,MoneroWalletRPCClient
-from mmgen.base_proto.monero.daemon import MoneroWalletDaemon
+from mmgen.proto.xmr.rpc import MoneroRPCClient,MoneroRPCClientRaw,MoneroWalletRPCClient
+from mmgen.proto.xmr.daemon import MoneroWalletDaemon
 
 def cfg_file_auth_test(proto,d):
 	qmsg(cyan(f'\n  Testing authentication with credentials from {d.cfg_file}:'))

+ 1 - 1
test/unit_tests_d/ut_tx_deserialize.py

@@ -9,7 +9,7 @@ from mmgen.common import *
 from ..include.common import *
 from mmgen.protocol import init_proto
 from mmgen.tx import CompletedTX
-from mmgen.base_proto.bitcoin.tx.base import DeserializeTX
+from mmgen.proto.btc.tx.base import DeserializeTX
 from mmgen.rpc import rpc_init
 from mmgen.daemon import CoinDaemon