Skip to content
Snippets Groups Projects
Commit 521e1847 authored by Vincent Texier's avatar Vincent Texier
Browse files

[fix] fix pycharm alerts

Use staticmethod decorators on static methods
Reformat code
parent ce88ac46
Branches
Tags
1 merge request!52#51: (E)WIF: add four methods: devine format, allow passing to the f() an hexadecimal string
......@@ -154,11 +154,13 @@ pub: {pubkey}
sec: {signkey}""".format(version=version, pubkey=base58_public_key, signkey=base58_signing_key)
)
@staticmethod
def from_wif_or_ewif_file(path: str, password: str = None) -> SigningKeyType:
"""
Return SigningKey instance from Duniter WIF or EWIF file
:param path: Path to WIF of EWIF file
:param password: Password needed for EWIF file
"""
with open(path, 'r') as fh:
wif_content = fh.read()
......@@ -173,6 +175,7 @@ sec: {signkey}""".format(version=version, pubkey=base58_public_key, signkey=base
wif_hex = match.groups()[0]
return SigningKey.from_wif_or_ewif_hex(wif_hex, password)
@staticmethod
def from_wif_or_ewif_hex(wif_hex: str, password: str = None) -> SigningKeyType:
"""
Return SigningKey instance from Duniter WIF or EWIF in hexadecimal format
......@@ -191,7 +194,7 @@ sec: {signkey}""".format(version=version, pubkey=base58_public_key, signkey=base
else:
raise Exception("Error: Bad format: not WIF nor EWIF")
@staticmethod
def from_wif_file(path: str) -> SigningKeyType:
"""
Return SigningKey instance from Duniter WIF file
......@@ -266,6 +269,7 @@ Version: {version}
Data: {data}""".format(version=version, data=wif_key)
)
@staticmethod
def from_ewif_file(path: str, password: str) -> SigningKeyType:
"""
Return SigningKey instance from Duniter EWIF file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment