diff --git a/mmgen/addr.py b/mmgen/addr.py index 88b49034..bc0101dc 100755 --- a/mmgen/addr.py +++ b/mmgen/addr.py @@ -144,7 +144,7 @@ class CoinAddr(str,Hilite,InitErrors,MMGenObject): try: assert addr.isascii() and addr.isalnum(), 'not an ASCII alphanumeric string' me = str.__new__(cls,addr) - ap = proto.parse_addr(addr) + ap = proto.decode_addr(addr) assert ap, f'coin address {addr!r} could not be parsed' me.addr_fmt = ap.fmt me.hex = ap.bytes.hex() diff --git a/mmgen/base_proto/bitcoin/tx/base.py b/mmgen/base_proto/bitcoin/tx/base.py index 5e18e5ad..345eb540 100755 --- a/mmgen/base_proto/bitcoin/tx/base.py +++ b/mmgen/base_proto/bitcoin/tx/base.py @@ -22,7 +22,7 @@ from ....util import msg,dmsg,make_chksum_6,die def addr2scriptPubKey(proto,addr): def decode_addr(proto,addr): - ap = proto.parse_addr(addr) + ap = proto.decode_addr(addr) assert ap, f'coin address {addr!r} could not be parsed' return ap.bytes.hex() diff --git a/mmgen/msg.py b/mmgen/msg.py index 30cc7415..34b00b6a 100755 --- a/mmgen/msg.py +++ b/mmgen/msg.py @@ -229,7 +229,7 @@ class coin_msg: 'sig': sig, } if self.msg_cls.include_pubhash: - data.update({ 'pubhash': self.proto.parse_addr(e.addr_p2pkh or e.addr).bytes.hex() }) + data.update({ 'pubhash': self.proto.decode_addr(e.addr_p2pkh or e.addr).bytes.hex() }) if e.addr_p2pkh: data.update({'addr_p2pkh': e.addr_p2pkh}) diff --git a/mmgen/proto/btc.py b/mmgen/proto/btc.py index 5d99a961..1ccdc8bf 100755 --- a/mmgen/proto/btc.py +++ b/mmgen/proto/btc.py @@ -12,7 +12,7 @@ Bitcoin protocol """ -from ..protocol import CoinProtocol,parsed_wif,parsed_addr,_finfo,_nw +from ..protocol import CoinProtocol,parsed_wif,decoded_addr,_finfo,_nw from .common import * class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp @@ -83,7 +83,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp pubkey_type = pubkey_type, compressed = compressed ) - def parse_addr(self,addr): + def decode_addr(self,addr): if 'B' in self.mmtypes and addr[:len(self.bech32_hrp)] == self.bech32_hrp: import mmgen.contrib.bech32 as bech32 @@ -94,9 +94,9 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp msg(f'{ret[0]}: Invalid witness version number') return False - return parsed_addr( bytes(ret[1]), 'bech32' ) if ret[1] else False + return decoded_addr( bytes(ret[1]), 'bech32' ) if ret[1] else False - return self.parse_addr_bytes(b58chk_decode(addr)) + return self.decode_addr_bytes(b58chk_decode(addr)) def pubhash2addr(self,pubhash,p2sh): assert len(pubhash) == 20, f'{len(pubhash)}: invalid length for pubkey hash' diff --git a/mmgen/proto/eth.py b/mmgen/proto/eth.py index c5b8e565..4cc1c777 100755 --- a/mmgen/proto/eth.py +++ b/mmgen/proto/eth.py @@ -13,7 +13,7 @@ Ethereum protocol """ from ..globalvars import g -from ..protocol import CoinProtocol,_nw,parsed_addr +from ..protocol import CoinProtocol,_nw,decoded_addr from ..util import is_hex_str_lc,Msg class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1): @@ -53,9 +53,9 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1): def dcoin(self): return self.tokensym or self.coin - def parse_addr(self,addr): + def decode_addr(self,addr): if is_hex_str_lc(addr) and len(addr) == self.addr_len * 2: - return parsed_addr( bytes.fromhex(addr), 'ethereum' ) + return decoded_addr( bytes.fromhex(addr), 'ethereum' ) if g.debug: Msg(f'Invalid address: {addr}') return False diff --git a/mmgen/proto/xmr.py b/mmgen/proto/xmr.py index c30bc9d8..916395e0 100755 --- a/mmgen/proto/xmr.py +++ b/mmgen/proto/xmr.py @@ -40,7 +40,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Base): self.privkey_len, 'big' )[::-1] - def parse_addr(self,addr): + def decode_addr(self,addr): from ..baseconv import baseconv @@ -57,7 +57,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Base): assert ret[-4:] == chk, f'{ret[-4:].hex()}: incorrect checksum. Correct value: {chk.hex()}' - return self.parse_addr_bytes(ret) + return self.decode_addr_bytes(ret) def pubhash2addr(self,*args,**kwargs): raise NotImplementedError('Monero addresses do not support pubhash2addr()') diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 3d24a70a..7194eef4 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -26,7 +26,7 @@ from .devtools import * from .globalvars import g parsed_wif = namedtuple('parsed_wif',['sec','pubkey_type','compressed']) -parsed_addr = namedtuple('parsed_addr',['bytes','fmt']) +decoded_addr = namedtuple('decoded_addr',['bytes','fmt']) _finfo = namedtuple('fork_info',['height','hash','name','replayable']) _nw = namedtuple('coin_networks',['mainnet','testnet','regtest']) @@ -140,13 +140,13 @@ class CoinProtocol(MMGenObject): def get_addr_len(self,addr_fmt): return self.addr_len - def parse_addr_bytes(self,addr_bytes): + def decode_addr_bytes(self,addr_bytes): for ver_hex,addr_fmt in self.addr_ver_bytes.items(): ver_bytes = bytes.fromhex(ver_hex) vlen = len(ver_bytes) if addr_bytes[:vlen] == ver_bytes: if len(addr_bytes[vlen:]) == self.get_addr_len(addr_fmt): - return parsed_addr( addr_bytes[vlen:], addr_fmt ) + return decoded_addr( addr_bytes[vlen:], addr_fmt ) return False diff --git a/mmgen/tool/coin.py b/mmgen/tool/coin.py index 42a30378..12727e63 100755 --- a/mmgen/tool/coin.py +++ b/mmgen/tool/coin.py @@ -171,7 +171,7 @@ class tool_cmd(tool_cmd_base): def addr2pubhash(self,addr:'sstr'): "convert coin address to public key hash" - ap = self.proto.parse_addr(addr) + ap = self.proto.decode_addr(addr) assert ap, f'coin address {addr!r} could not be parsed' if ap.fmt not in MMGenAddrType.pkh_fmts: from ..util import die