0

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.

2

1 Answer 1

0

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]])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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