From 076cec7495f9f50b4d1ce0216ea1fdb545986294 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 3 Oct 2022 10:00:00 +0000 Subject: [PATCH] base_proto.bitcoin -> proto.btc, ... [code] --- MANIFEST.in | 2 +- mmgen/daemon.py | 2 +- mmgen/data/release_date | 2 +- mmgen/data/version | 2 +- mmgen/main_regtest.py | 2 +- mmgen/msg.py | 2 +- mmgen/opts.py | 2 +- mmgen/proto/btc/params.py | 3 ++- mmgen/proto/eth/params.py | 3 ++- mmgen/proto/xmr/params.py | 3 ++- mmgen/protocol.py | 2 ++ mmgen/rpc.py | 2 +- mmgen/tool/coin.py | 4 ++-- mmgen/tool/fileutil.py | 2 +- mmgen/tx/__init__.py | 2 +- mmgen/tx/info.py | 2 +- mmgen/util.py | 4 ++-- mmgen/xmrwallet.py | 4 ++-- setup.cfg | 18 +++++++----------- test/objattrtest.py | 2 +- test/overlay/__init__.py | 18 +++++++----------- test/test_py_d/ts_ethdev.py | 6 +++--- test/test_py_d/ts_regtest.py | 2 +- test/test_py_d/ts_xmrwallet.py | 4 ++-- test/unit_tests_d/ut_rpc.py | 4 ++-- test/unit_tests_d/ut_tx_deserialize.py | 2 +- 26 files changed, 49 insertions(+), 52 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 02f2c24c..8465b448 100644 --- a/MANIFEST.in +++ b/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/* diff --git a/mmgen/daemon.py b/mmgen/daemon.py index eb121653..2f56ad36 100755 --- a/mmgen/daemon.py +++ b/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 diff --git a/mmgen/data/release_date b/mmgen/data/release_date index 121322d7..1fe2aceb 100644 --- a/mmgen/data/release_date +++ b/mmgen/data/release_date @@ -1 +1 @@ -September 2022 +October 2022 diff --git a/mmgen/data/version b/mmgen/data/version index b1b9f0ad..f81c04d5 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -13.3.dev0 +13.3.dev1 diff --git a/mmgen/main_regtest.py b/mmgen/main_regtest.py index c7052559..49d1b86f 100755 --- a/mmgen/main_regtest.py +++ b/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]) diff --git a/mmgen/msg.py b/mmgen/msg.py index 34b00b6a..0a471281 100755 --- a/mmgen/msg.py +++ b/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') diff --git a/mmgen/opts.py b/mmgen/opts.py index 0f119d36..17e0fc4e 100755 --- a/mmgen/opts.py +++ b/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: diff --git a/mmgen/proto/btc/params.py b/mmgen/proto/btc/params.py index 70b5630d..688568fb 100755 --- a/mmgen/proto/btc/params.py +++ b/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' diff --git a/mmgen/proto/eth/params.py b/mmgen/proto/eth/params.py index b08f30a5..18d4afe9 100755 --- a/mmgen/proto/eth/params.py +++ b/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 diff --git a/mmgen/proto/xmr/params.py b/mmgen/proto/xmr/params.py index 61bb9b74..dbda29af 100755 --- a/mmgen/proto/xmr/params.py +++ b/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',) diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 2086fbf4..cb9e0eed 100755 --- a/mmgen/protocol.py +++ b/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') diff --git a/mmgen/rpc.py b/mmgen/rpc.py index 2335f7d3..1ffb4108 100755 --- a/mmgen/rpc.py +++ b/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 diff --git a/mmgen/tool/coin.py b/mmgen/tool/coin.py index 12727e63..3a4f16a7 100755 --- a/mmgen/tool/coin.py +++ b/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'): diff --git a/mmgen/tool/fileutil.py b/mmgen/tool/fileutil.py index 1ddc4ac6..d7de8c54 100755 --- a/mmgen/tool/fileutil.py +++ b/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() diff --git a/mmgen/tx/__init__.py b/mmgen/tx/__init__.py index 7cc20688..c7070c0d 100755 --- a/mmgen/tx/__init__.py +++ b/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 diff --git a/mmgen/tx/info.py b/mmgen/tx/info.py index 30fd309c..1a05eec2 100755 --- a/mmgen/tx/info.py +++ b/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) diff --git a/mmgen/util.py b/mmgen/util.py index 96e2efa1..0655a4b5 100755 --- a/mmgen/util.py +++ b/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 ) diff --git a/mmgen/xmrwallet.py b/mmgen/xmrwallet.py index 7fbc3e6c..3a3356f9 100755 --- a/mmgen/xmrwallet.py +++ b/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: { diff --git a/setup.cfg b/setup.cfg index ba35691d..2710d169 100644 --- a/setup.cfg +++ b/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 diff --git a/test/objattrtest.py b/test/objattrtest.py index 9526999d..9f78a248 100755 --- a/test/objattrtest.py +++ b/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': [ diff --git a/test/overlay/__init__.py b/test/overlay/__init__.py index 5895e28a..aea2274d 100644 --- a/test/overlay/__init__.py +++ b/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', diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index b92e107b..54cc7373 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/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( diff --git a/test/test_py_d/ts_regtest.py b/test/test_py_d/ts_regtest.py index 3313e02a..dbf6494c 100755 --- a/test/test_py_d/ts_regtest.py +++ b/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 diff --git a/test/test_py_d/ts_xmrwallet.py b/test/test_py_d/ts_xmrwallet.py index 94c618c9..22ea50c9 100755 --- a/test/test_py_d/ts_xmrwallet.py +++ b/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',[ diff --git a/test/unit_tests_d/ut_rpc.py b/test/unit_tests_d/ut_rpc.py index 8e12322c..091bcab6 100755 --- a/test/unit_tests_d/ut_rpc.py +++ b/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}:')) diff --git a/test/unit_tests_d/ut_tx_deserialize.py b/test/unit_tests_d/ut_tx_deserialize.py index dbe3d2f7..8c732fee 100755 --- a/test/unit_tests_d/ut_tx_deserialize.py +++ b/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