def load_key(cls, wallet_name, key_type):
if key_type == 'public_key':
ecdsa_key = ecdsa.VerifyingKey
extension = ".pk"
elif key_type =='secret_key':
ecdsa_key = ecdsa.SigningKey
extension = ".sk"
else:
raise ValueError('Third argument key_type needs to be either public_key or secret_key.')
key_path = os.path.join(settings.WALLETS_ABS_PATH, wallet_name + extension)
with open(key_path, 'rb') as temp_file:
hex_key = temp_file.read()
bytes_key = unhexlify(hex_key)
key = ecdsa_key.from_string(bytes_key, settings.bitcoin_curve)
return key
评论列表
文章目录