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

[fix] fix mypy alert

The ewif method should be executed only if a password is provided.
parent 521e1847
No related branches found
No related tags found
1 merge request!52#51: (E)WIF: add four methods: devine format, allow passing to the f() an hexadecimal string
Pipeline #4389 passed
......@@ -155,7 +155,7 @@ sec: {signkey}""".format(version=version, pubkey=base58_public_key, signkey=base
)
@staticmethod
def from_wif_or_ewif_file(path: str, password: str = None) -> SigningKeyType:
def from_wif_or_ewif_file(path: str, password: Optional[str] = None) -> SigningKeyType:
"""
Return SigningKey instance from Duniter WIF or EWIF file
......@@ -176,7 +176,7 @@ sec: {signkey}""".format(version=version, pubkey=base58_public_key, signkey=base
return SigningKey.from_wif_or_ewif_hex(wif_hex, password)
@staticmethod
def from_wif_or_ewif_hex(wif_hex: str, password: str = None) -> SigningKeyType:
def from_wif_or_ewif_hex(wif_hex: str, password: Optional[str] = None) -> SigningKeyType:
"""
Return SigningKey instance from Duniter WIF or EWIF in hexadecimal format
......@@ -189,7 +189,7 @@ sec: {signkey}""".format(version=version, pubkey=base58_public_key, signkey=base
if fi == b"\x01":
return SigningKey.from_wif_hex(wif_hex)
elif fi == b"\x02":
elif fi == b"\x02" and password is not None:
return SigningKey.from_ewif_hex(wif_hex, password)
else:
raise Exception("Error: Bad format: not WIF nor EWIF")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment