personal key – Python Code – import error : can’t import title “privtopub” from ‘bitcoin’

- Hiya everybody when i begin this code on PYCHARM seems like no
downside. However when i turned this code to from python to exe and exe
dont begin and it says : import error : can’t import title
“privtopub” from ‘bitcoin’
import random
import requests
import base58
import hashlib
from bitcoin import privtopub, pubtoaddr
……
……
……
……
whereas True:
i += 1
first_character = "89ABCDEF"
first_character.encode('utf-8')
last_15_character = "0123456789ABCDEF"
last_15_character.encode('utf-8')
privateKeyByte = ("000000000000000000000000000000000000000000000000" + "".be a part of(
random.selection(first_character) for _ in vary(1)) + "".be a part of(
random.selection(last_15_character) for _ in vary(15))).encode('utf-8')
privateKey = str(privateKeyByte)[2:-1]
extendedPrivateKey = ("80" + privateKey)
extendedPrivateKeyByte = bytearray.fromhex(extendedPrivateKey)
firstHash = hashlib.sha256()
firstHash.replace(extendedPrivateKeyByte)
secondHash = hashlib.sha256()
firstHashFromHex = bytearray.fromhex(firstHash.hexdigest())
secondHash.replace(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)
-
Final 2 code i imply
publicKey = privtopub(privateKey) and btcAddress = pubtoaddr(publicKey) can’t import from bitcoin ? why ? -
Additionally i had one other downside however i solved it turned my privateKeyByte
to byte add this code ” .encode(‘utf-8’).” finish of the privateKeyByte -
When i delete this all code and to get to public adress with
this fashion :
import random
import bitcoin
import requests
whereas True:
i += 1
liste_ilk_basamak = ("89ABCDEF")
liste_son15_basamak = ("0123456789ABCDEF")
private_key_random = "".be a part of(random.selection(liste_ilk_basamak) for _ in vary(1)) + "".be a part of(
random.selection(liste_son15_basamak) for _ in vary(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’m attempting to unravel this downside 4 days and i’m going to be loopy misplaced my thoughts :S assist me pls 🙂