Using the Bitcoin python library to generate Private Key [Noob question]
I have done pip install bitcoin and then wrote the below code:
from bitcoin import *
private_key = random_key()
print(private_key)
Now I am getting this error:
Traceback (most recent call last):
File "/Users/praveen/Documents/code/sandbox/python/bitcoinkey.py", line 1, in <module>
from bitcoinkey import *
File "/Users/praveen/Documents/code/sandbox/python/bitcoinkey.py", line 2, in <module>
private_key = random_key()
NameError: name 'random_key' is not defined
Any idea why 'random_key' is not defined?
Thanks,
Just getting started with tinkering.
Top Answer/Comment:
Try this:
import bitcoin, base58, ecdsa, requests, smtplib, multiprocessing, blockchain
import gc
import sys
gc.collect()
while True:
private_key = random_key()
public_key = privtopub(private_key)
address = pubtoaddr(public_key)
with open("btc.txt", "r") as m:
add = m.read().split()
for ad in add:
continue
if address in add:
print("Found"+ " " +address+ ' ' +private_key)
data = open("data.txt","a")
data.write(print(address+ ' ' +private_key+ ' ' +"\n"))
data.close()
else:
print(address+ ' ' +private_key)
del (address)
del (private_key)
os.execv(sys.executable, ['python'] + [sys.argv[0]])
상단 광고의 [X] 버튼을 누르면 내용이 보입니다