Browse Source

proto/common.py -> proto/btc/common.py

The MMGen Project 2 years ago
parent
commit
d8965706d5

+ 1 - 1
mmgen/addrlist.py

@@ -272,7 +272,7 @@ class AddrList(MMGenObject): # Address info for a single seed ID
 		return out
 		return out
 
 
 	def gen_wallet_passwd(self,privbytes):
 	def gen_wallet_passwd(self,privbytes):
-		from .proto.common import hash256
+		from .proto.btc.common import hash256
 		return WalletPassword( hash256(privbytes)[:16].hex() )
 		return WalletPassword( hash256(privbytes)[:16].hex() )
 
 
 	def check_format(self,addr):
 	def check_format(self,addr):

+ 1 - 1
mmgen/altcoin.py

@@ -556,7 +556,7 @@ class CoinInfo(object):
 			return '1'
 			return '1'
 
 
 		def phash2addr(ver_num,pk_hash):
 		def phash2addr(ver_num,pk_hash):
-			from .proto.common import b58chk_encode
+			from .proto.btc.common import b58chk_encode
 			bl = ver_num.bit_length()
 			bl = ver_num.bit_length()
 			ver_bytes = int.to_bytes(ver_num,bl//8 + bool(bl%8),'big')
 			ver_bytes = int.to_bytes(ver_num,bl//8 + bool(bl%8),'big')
 			return b58chk_encode(ver_bytes + pk_hash)
 			return b58chk_encode(ver_bytes + pk_hash)

+ 1 - 1
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 ...addrgen import addr_generator,check_data
 from ...addr import CoinAddr
 from ...addr import CoinAddr
-from ..common import hash160
+from .common import hash160
 
 
 class p2pkh(addr_generator.base):
 class p2pkh(addr_generator.base):
 
 

+ 1 - 1
mmgen/proto/common.py → mmgen/proto/btc/common.py

@@ -9,7 +9,7 @@
 #   https://gitlab.com/mmgen/mmgen
 #   https://gitlab.com/mmgen/mmgen
 
 
 """
 """
-proto.common: Functions and constants used by multiple protocols
+proto.btc.common: Shared Bitcoin functions and constants
 """
 """
 
 
 import hashlib
 import hashlib

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

@@ -13,7 +13,7 @@ Bitcoin protocol
 """
 """
 
 
 from ...protocol import CoinProtocol,decoded_wif,decoded_addr,_finfo,_nw
 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
 class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
 	"""
 	"""

+ 1 - 1
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 ...addrgen import addr_generator,check_data
 from ...addr import CoinAddr
 from ...addr import CoinAddr
-from ..common import b58chk_encode
+from ..btc.common import b58chk_encode
 
 
 class zcash_z(addr_generator.base):
 class zcash_z(addr_generator.base):
 
 

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

@@ -13,7 +13,7 @@ Zcash protocol
 """
 """
 
 
 from ..btc.params import mainnet
 from ..btc.params import mainnet
-from ..common import b58chk_decode
+from ..btc.common import b58chk_decode
 from ...protocol import decoded_wif,decoded_addr
 from ...protocol import decoded_wif,decoded_addr
 from ...addr import CoinAddr
 from ...addr import CoinAddr
 
 

+ 2 - 2
mmgen/tool/coin.py

@@ -147,7 +147,7 @@ class tool_cmd(tool_cmd_base):
 	def pubhex2redeem_script(self,pubkeyhex:'sstr'): # new
 	def pubhex2redeem_script(self,pubkeyhex:'sstr'): # new
 		"convert a hexadecimal pubkey to a Segwit P2SH-P2WPKH redeem script"
 		"convert a hexadecimal pubkey to a Segwit P2SH-P2WPKH redeem script"
 		assert self.mmtype.name == 'segwit','This command is meaningful only for --type=segwit'
 		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()
 		return self.proto.pubhash2redeem_script( hash160(bytes.fromhex(pubkeyhex)) ).hex()
 
 
 	def redeem_script2addr(self,redeem_script_hex:'sstr'): # new
 	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 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 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'
 		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(
 		return self.proto.pubhash2addr(
 			hash160( bytes.fromhex(redeem_script_hex) ),
 			hash160( bytes.fromhex(redeem_script_hex) ),
 			p2sh = True )
 			p2sh = True )

+ 3 - 3
mmgen/tool/util.py

@@ -124,7 +124,7 @@ class tool_cmd(tool_cmd_base):
 
 
 	def hash160(self,hexstr:'sstr'):
 	def hash160(self,hexstr:'sstr'):
 		"compute ripemd160(sha256(data)) (convert hex pubkey to hex addr)"
 		"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()
 		return hash160( bytes.fromhex(hexstr) ).hex()
 
 
 	# TODO: handle stdin
 	# TODO: handle stdin
@@ -195,12 +195,12 @@ class tool_cmd(tool_cmd_base):
 
 
 	def hextob58chk(self,hexstr:'sstr'):
 	def hextob58chk(self,hexstr:'sstr'):
 		"convert a hexadecimal string to base58-check encoding"
 		"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) )
 		return b58chk_encode( bytes.fromhex(hexstr) )
 
 
 	def b58chktohex(self,b58chk_str:'sstr'):
 	def b58chktohex(self,b58chk_str:'sstr'):
 		"convert a base58-check encoded string to hexadecimal"
 		"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()
 		return b58chk_decode(b58chk_str).hex()
 
 
 	def hextob32(self,hexstr:'sstr',pad: 'pad output to this width' = 0):
 	def hextob32(self,hexstr:'sstr',pad: 'pad output to this width' = 0):

+ 1 - 1
mmgen/xmrwallet.py

@@ -27,7 +27,7 @@ from .objmethods import Hilite,InitErrors
 from .obj import CoinTxID
 from .obj import CoinTxID
 from .seed import SeedID
 from .seed import SeedID
 from .protocol import init_proto
 from .protocol import init_proto
-from .proto.common import b58a
+from .proto.btc.common import b58a
 from .addr import CoinAddr,AddrIdx
 from .addr import CoinAddr,AddrIdx
 from .addrlist import KeyAddrList,AddrIdxList
 from .addrlist import KeyAddrList,AddrIdxList
 from .rpc import json_encoder
 from .rpc import json_encoder