1

I launched a private RPC Blockchain network and connected through another computer to this network. The connection is successful. How can I get a private key(through Python) if the file is on another computer on this private network? I can get private key on my computer through this code: P.S. But I can't use it to get private key from another computer in my private network.

from web3 import Web3
web = "My IP and Port"
web3 = Web3(Web3.HTTPProvider(web))
import binascii
import glob

account_1 = "0xAC89Ec2301A5760985c9953ae4f81E607Fe8Ba8d"
passw = input()
account_2 = "0x2a2034F5a872341e66ba44e8a884e89acA023130"

addr = "".join(glob.glob('C:/ether/keystore/*'+account_1.replace('0x', '')))
with open(addr) as keyfile:
    encrypted_key = keyfile.read()
    private_key1 = web3.eth.account.decrypt(encrypted_key, passw)

private_key = ''.join((str(binascii.b2a_hex(private_key1)).replace("b'",'')).replace("'", ''))

print(private_key)
0

You can't through blockchain. You'd need to transfer the actual keys separately (that is outside of blockchain). In geth, to do that you'd need to copy over contents of keystore in datadir.

  • In geth, to do that you'd need to copy over contents of keystore in datadir. Thanks for the answer, but I did not understand a bit. Suppose I moved them to datadir. And what should I do next? – Kojimba-san Nov 26 '19 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.