ethereum/keystore2priv.py: getting geth private key

https://ethereum.stackexchange.com/questions/12830/how-to-get-private-key-from-account-address-and-password

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2022-09-14 13:28:06 +02:00
parent dc13f22088
commit 81a4ecac81
No known key found for this signature in database
GPG Key ID: 09AA5403E54D9931
1 changed files with 13 additions and 0 deletions

13
ethereum/keystore2priv.py Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
import sys
import binascii
from web3.auto import w3
keystore_password = sys.argv[1]
keystore_file_path = sys.argv[2]
with open(keystore_file_path) as keyfile:
encrypted_key = keyfile.read()
private_key = w3.eth.account.decrypt(encrypted_key, keystore_password)
print(binascii.b2a_hex(private_key).decode('utf-8'))