Hello everyone when I start this code on PYCHARM looks like no problem. But when I turned this code from python to exe and exe don't start and it says: import error: cannot import name "privtopub" from 'bitcoin'
import random
import requests
import base58
import hashlib
from bitcoin import privtopub, pubtoaddr
# Some code here
while True:
i += 1
first_character = "89ABCDEF"
first_character.encode('utf-8')
last_15_character = "0123456789ABCDEF"
last_15_character.encode('utf-8')
privateKeyByte = ("000000000000000000000000000000000000000000000000" + "".join(
random.choice(first_character) for _ in range(1)) + "".join(
random.choice(last_15_character) for _ in range(15))).encode('utf-8')
privateKey = str(privateKeyByte)[2:-1]
extendedPrivateKey = ("80" + privateKey)
extendedPrivateKeyByte = bytearray.fromhex(extendedPrivateKey)
firstHash = hashlib.sha256()
firstHash.update(extendedPrivateKeyByte)
secondHash = hashlib.sha256()
firstHashFromHex = bytearray.fromhex(firstHash.hexdigest())
secondHash.update(firstHashFromHex)
checksum = secondHash.hexdigest()[0:8]
finalPrivateKey = extendedPrivateKey + checksum
encodedKey = bytes.fromhex(finalPrivateKey)
wifKey = base58.b58encode(encodedKey)
wifKeyString = str(wifKey)[2:-1]
publicKey = privtopub(privateKey)
btcAddress = pubtoaddr(publicKey)
Last 2 code i mean
publicKey = privtopub(privateKey)
andbtcAddress = pubtoaddr(publicKey) cannot import from bitcoin
? why ?Also i had another problem but i solved it turned my privateKeyByte to byte add this code " .encode('utf-8')." end of the privateKeyByte
When i delete this all code and to get to public adress with this way :
import random
import bitcoin
import requests
while True:
i += 1
liste_ilk_basamak = ("89ABCDEF")
liste_son15_basamak = ("0123456789ABCDEF")
private_key_random = "".join(random.choice(liste_ilk_basamak) for _ in range(1)) + "".join(
random.choice(liste_son15_basamak) for _ in range(15))
decoded_private_key = bitcoin.decode_privkey(private_key_random, 'hex')
valid_private_key = 0 < decoded_private_key < bitcoin.N
wif_encoded_private_key = bitcoin.encode_privkey(decoded_private_key, 'wif')
public_key = bitcoin.fast_multiply(bitcoin.G, decoded_private_key)
adress = bitcoin.pubkey_to_address(public_key)
- İ Have This Error : AttributeError: Module "bitcoin" has no attribute 'decode_privkey'
I am trying to solve this problem 4 days and I am going to be crazy lost my mind :S help me pls :)
$ python3 -m pip show bitcoin Name: bitcoin Version: 1.1.42 Summary: Python Bitcoin Tools Home-page: http://github.com/vbuterin/pybitcointools Author: Vitalik Buterin Author-email: [email protected] License: UNKNOWN Location: /home/valentin/.local/lib/python3.6/site-packages Requires: