proto.parse_wif() -> proto.decode_wif()
This commit is contained in:
parent
fdf2557d01
commit
9ba4331340
3 changed files with 8 additions and 8 deletions
|
|
@ -35,7 +35,7 @@ class WifKey(str,Hilite,InitErrors):
|
|||
return wif
|
||||
try:
|
||||
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)
|
||||
except Exception as e:
|
||||
return cls.init_fail(e,wif)
|
||||
|
|
@ -76,7 +76,7 @@ class PrivKey(bytes,Hilite,InitErrors,MMGenObject):
|
|||
try:
|
||||
assert s == None,"'wif' and key hex args are mutually exclusive"
|
||||
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.compressed = k.compressed
|
||||
me.pubkey_type = k.pubkey_type
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
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 *
|
||||
|
||||
class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
|
||||
|
|
@ -58,7 +58,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
|
|||
+ privbytes
|
||||
+ (b'',b'\x01')[bool(compressed)])
|
||||
|
||||
def parse_wif(self,wif):
|
||||
def decode_wif(self,wif):
|
||||
key = b58chk_decode(wif)
|
||||
|
||||
for k,v in self.wif_ver_num.items():
|
||||
|
|
@ -78,7 +78,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
|
|||
else:
|
||||
raise ValueError(f'{len(key)}: invalid key length')
|
||||
|
||||
return parsed_wif(
|
||||
return decoded_wif(
|
||||
sec = key[:self.privkey_len],
|
||||
pubkey_type = pubkey_type,
|
||||
compressed = compressed )
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from collections import namedtuple
|
|||
from .devtools import *
|
||||
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'])
|
||||
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!'
|
||||
return privbytes.hex()
|
||||
|
||||
def parse_wif(self,wif):
|
||||
return parsed_wif(
|
||||
def decode_wif(self,wif):
|
||||
return decoded_wif(
|
||||
sec = bytes.fromhex(wif),
|
||||
pubkey_type = self.pubkey_type,
|
||||
compressed = False )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue