From d8965706d59ff9c06d761cf974208733cda40b1e Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 7 Oct 2022 19:48:49 +0000 Subject: [PATCH] proto/common.py -> proto/btc/common.py --- mmgen/addrlist.py | 2 +- mmgen/altcoin.py | 2 +- mmgen/proto/btc/addrgen.py | 2 +- mmgen/proto/{ => btc}/common.py | 2 +- mmgen/proto/btc/params.py | 2 +- mmgen/proto/zec/addrgen.py | 2 +- mmgen/proto/zec/params.py | 2 +- mmgen/tool/coin.py | 4 ++-- mmgen/tool/util.py | 6 +++--- mmgen/xmrwallet.py | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) rename mmgen/proto/{ => btc}/common.py (95%) diff --git a/mmgen/addrlist.py b/mmgen/addrlist.py index 62ea7fa8..8768a64b 100755 --- a/mmgen/addrlist.py +++ b/mmgen/addrlist.py @@ -272,7 +272,7 @@ class AddrList(MMGenObject): # Address info for a single seed ID return out def gen_wallet_passwd(self,privbytes): - from .proto.common import hash256 + from .proto.btc.common import hash256 return WalletPassword( hash256(privbytes)[:16].hex() ) def check_format(self,addr): diff --git a/mmgen/altcoin.py b/mmgen/altcoin.py index c9a4d8f7..31385ef8 100755 --- a/mmgen/altcoin.py +++ b/mmgen/altcoin.py @@ -556,7 +556,7 @@ class CoinInfo(object): return '1' def phash2addr(ver_num,pk_hash): - from .proto.common import b58chk_encode + from .proto.btc.common import b58chk_encode bl = ver_num.bit_length() ver_bytes = int.to_bytes(ver_num,bl//8 + bool(bl%8),'big') return b58chk_encode(ver_bytes + pk_hash) diff --git a/mmgen/proto/btc/addrgen.py b/mmgen/proto/btc/addrgen.py index d4482856..b443edd3 100755 --- a/mmgen/proto/btc/addrgen.py +++ b/mmgen/proto/btc/addrgen.py @@ -14,7 +14,7 @@ proto.btc.addrgen: Bitcoin address generation classes for the MMGen suite from ...addrgen import addr_generator,check_data from ...addr import CoinAddr -from ..common import hash160 +from .common import hash160 class p2pkh(addr_generator.base): diff --git a/mmgen/proto/common.py b/mmgen/proto/btc/common.py similarity index 95% rename from mmgen/proto/common.py rename to mmgen/proto/btc/common.py index 4f190d7a..67c8221a 100755 --- a/mmgen/proto/common.py +++ b/mmgen/proto/btc/common.py @@ -9,7 +9,7 @@ # https://gitlab.com/mmgen/mmgen """ -proto.common: Functions and constants used by multiple protocols +proto.btc.common: Shared Bitcoin functions and constants """ import hashlib diff --git a/mmgen/proto/btc/params.py b/mmgen/proto/btc/params.py index 688568fb..3efa1ee4 100755 --- a/mmgen/proto/btc/params.py +++ b/mmgen/proto/btc/params.py @@ -13,7 +13,7 @@ Bitcoin protocol """ from ...protocol import CoinProtocol,decoded_wif,decoded_addr,_finfo,_nw -from ..common import * +from .common import b58chk_decode,b58chk_encode,hash160 class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp """ diff --git a/mmgen/proto/zec/addrgen.py b/mmgen/proto/zec/addrgen.py index 57cae3ad..5e91d333 100755 --- a/mmgen/proto/zec/addrgen.py +++ b/mmgen/proto/zec/addrgen.py @@ -14,7 +14,7 @@ proto.zec.addrgen: Zcash-Z address generation class for the MMGen suite from ...addrgen import addr_generator,check_data from ...addr import CoinAddr -from ..common import b58chk_encode +from ..btc.common import b58chk_encode class zcash_z(addr_generator.base): diff --git a/mmgen/proto/zec/params.py b/mmgen/proto/zec/params.py index 695135a3..248d79f4 100755 --- a/mmgen/proto/zec/params.py +++ b/mmgen/proto/zec/params.py @@ -13,7 +13,7 @@ Zcash protocol """ from ..btc.params import mainnet -from ..common import b58chk_decode +from ..btc.common import b58chk_decode from ...protocol import decoded_wif,decoded_addr from ...addr import CoinAddr diff --git a/mmgen/tool/coin.py b/mmgen/tool/coin.py index b1503725..3dd2ad35 100755 --- a/mmgen/tool/coin.py +++ b/mmgen/tool/coin.py @@ -147,7 +147,7 @@ class tool_cmd(tool_cmd_base): def pubhex2redeem_script(self,pubkeyhex:'sstr'): # new "convert a hexadecimal pubkey to a Segwit P2SH-P2WPKH redeem script" assert self.mmtype.name == 'segwit','This command is meaningful only for --type=segwit' - from ..proto.common import hash160 + from ..proto.btc.common import hash160 return self.proto.pubhash2redeem_script( hash160(bytes.fromhex(pubkeyhex)) ).hex() def redeem_script2addr(self,redeem_script_hex:'sstr'): # new @@ -155,7 +155,7 @@ class tool_cmd(tool_cmd_base): assert self.mmtype.name == 'segwit', 'This command is meaningful only for --type=segwit' assert redeem_script_hex[:4] == '0014', f'{redeem_script_hex!r}: invalid redeem script' assert len(redeem_script_hex) == 44, f'{len(redeem_script_hex)//2} bytes: invalid redeem script length' - from ..proto.common import hash160 + from ..proto.btc.common import hash160 return self.proto.pubhash2addr( hash160( bytes.fromhex(redeem_script_hex) ), p2sh = True ) diff --git a/mmgen/tool/util.py b/mmgen/tool/util.py index 05811649..cf472926 100755 --- a/mmgen/tool/util.py +++ b/mmgen/tool/util.py @@ -124,7 +124,7 @@ class tool_cmd(tool_cmd_base): def hash160(self,hexstr:'sstr'): "compute ripemd160(sha256(data)) (convert hex pubkey to hex addr)" - from ..proto.common import hash160 + from ..proto.btc.common import hash160 return hash160( bytes.fromhex(hexstr) ).hex() # TODO: handle stdin @@ -195,12 +195,12 @@ class tool_cmd(tool_cmd_base): def hextob58chk(self,hexstr:'sstr'): "convert a hexadecimal string to base58-check encoding" - from ..proto.common import b58chk_encode + from ..proto.btc.common import b58chk_encode return b58chk_encode( bytes.fromhex(hexstr) ) def b58chktohex(self,b58chk_str:'sstr'): "convert a base58-check encoded string to hexadecimal" - from ..proto.common import b58chk_decode + from ..proto.btc.common import b58chk_decode return b58chk_decode(b58chk_str).hex() def hextob32(self,hexstr:'sstr',pad: 'pad output to this width' = 0): diff --git a/mmgen/xmrwallet.py b/mmgen/xmrwallet.py index 0d1cc2ad..c0022898 100755 --- a/mmgen/xmrwallet.py +++ b/mmgen/xmrwallet.py @@ -27,7 +27,7 @@ from .objmethods import Hilite,InitErrors from .obj import CoinTxID from .seed import SeedID from .protocol import init_proto -from .proto.common import b58a +from .proto.btc.common import b58a from .addr import CoinAddr,AddrIdx from .addrlist import KeyAddrList,AddrIdxList from .rpc import json_encoder