Browse Source

proto.parse_wif() -> proto.decode_wif()

The MMGen Project 2 years ago
parent
commit
9ba4331340
3 changed files with 8 additions and 8 deletions
  1. 2 2
      mmgen/key.py
  2. 3 3
      mmgen/proto/btc.py
  3. 3 3
      mmgen/protocol.py

+ 2 - 2
mmgen/key.py

@@ -35,7 +35,7 @@ class WifKey(str,Hilite,InitErrors):
 			return wif
 			return wif
 		try:
 		try:
 			assert wif.isascii() and wif.isalnum(), 'not an ASCII alphanumeric string'
 			assert wif.isascii() and wif.isalnum(), 'not an ASCII alphanumeric string'
-			proto.parse_wif(wif) # raises exception on error
+			proto.decode_wif(wif) # raises exception on error
 			return str.__new__(cls,wif)
 			return str.__new__(cls,wif)
 		except Exception as e:
 		except Exception as e:
 			return cls.init_fail(e,wif)
 			return cls.init_fail(e,wif)
@@ -76,7 +76,7 @@ class PrivKey(bytes,Hilite,InitErrors,MMGenObject):
 			try:
 			try:
 				assert s == None,"'wif' and key hex args are mutually exclusive"
 				assert s == None,"'wif' and key hex args are mutually exclusive"
 				assert wif.isascii() and wif.isalnum(), 'not an ASCII alphanumeric string'
 				assert wif.isascii() and wif.isalnum(), 'not an ASCII alphanumeric string'
-				k = proto.parse_wif(wif) # raises exception on error
+				k = proto.decode_wif(wif) # raises exception on error
 				me = bytes.__new__(cls,k.sec)
 				me = bytes.__new__(cls,k.sec)
 				me.compressed = k.compressed
 				me.compressed = k.compressed
 				me.pubkey_type = k.pubkey_type
 				me.pubkey_type = k.pubkey_type

+ 3 - 3
mmgen/proto/btc.py

@@ -12,7 +12,7 @@
 Bitcoin protocol
 Bitcoin protocol
 """
 """
 
 
-from ..protocol import CoinProtocol,parsed_wif,decoded_addr,_finfo,_nw
+from ..protocol import CoinProtocol,decoded_wif,decoded_addr,_finfo,_nw
 from .common import *
 from .common import *
 
 
 class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
 class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
@@ -58,7 +58,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
 			+ privbytes
 			+ privbytes
 			+ (b'',b'\x01')[bool(compressed)])
 			+ (b'',b'\x01')[bool(compressed)])
 
 
-	def parse_wif(self,wif):
+	def decode_wif(self,wif):
 		key = b58chk_decode(wif)
 		key = b58chk_decode(wif)
 
 
 		for k,v in self.wif_ver_num.items():
 		for k,v in self.wif_ver_num.items():
@@ -78,7 +78,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
 		else:
 		else:
 			raise ValueError(f'{len(key)}: invalid key length')
 			raise ValueError(f'{len(key)}: invalid key length')
 
 
-		return parsed_wif(
+		return decoded_wif(
 			sec         = key[:self.privkey_len],
 			sec         = key[:self.privkey_len],
 			pubkey_type = pubkey_type,
 			pubkey_type = pubkey_type,
 			compressed  = compressed )
 			compressed  = compressed )

+ 3 - 3
mmgen/protocol.py

@@ -25,7 +25,7 @@ from collections import namedtuple
 from .devtools import *
 from .devtools import *
 from .globalvars import g
 from .globalvars import g
 
 
-parsed_wif = namedtuple('parsed_wif',['sec','pubkey_type','compressed'])
+decoded_wif = namedtuple('decoded_wif',['sec','pubkey_type','compressed'])
 decoded_addr = namedtuple('decoded_addr',['bytes','ver_bytes','fmt'])
 decoded_addr = namedtuple('decoded_addr',['bytes','ver_bytes','fmt'])
 parsed_addr = namedtuple('parsed_addr',['ver_bytes','data'])
 parsed_addr = namedtuple('parsed_addr',['ver_bytes','data'])
 
 
@@ -194,8 +194,8 @@ class CoinProtocol(MMGenObject):
 			assert compressed == False, f'{self.name} protocol does not support compressed pubkeys!'
 			assert compressed == False, f'{self.name} protocol does not support compressed pubkeys!'
 			return privbytes.hex()
 			return privbytes.hex()
 
 
-		def parse_wif(self,wif):
-			return parsed_wif(
+		def decode_wif(self,wif):
+			return decoded_wif(
 				sec         = bytes.fromhex(wif),
 				sec         = bytes.fromhex(wif),
 				pubkey_type = self.pubkey_type,
 				pubkey_type = self.pubkey_type,
 				compressed  = False )
 				compressed  = False )