W
W
winerr2022-03-06 21:30:39
bitcoin
winerr, 2022-03-06 21:30:39

How to get bitcoin wallet address?

How, for example, from a private key in this format (L3KijrvAsMuLaCaEMaj2LcHwRpp3Koxkab6ipX7s9LfewoEU69g6 or KziExJ8gox5xdQVnS3Toun3SZC2Pgm146yDEvvYAb5fgkDwnnnkG), preferably offline, is there a script or software?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Mamonov, 2022-03-07
@EvgenyMamonov

Try this option

import ecdsa
import hashlib
import base58

# тут ваш ключ
str_private_key = "L3KijrvAsMuLaCaEMaj2LcHwRpp3Koxkab6ipX7s9LfewoEU69g6"

private_key = base58.b58decode_check(str_private_key)
private_key = private_key[1:]

signing_key = ecdsa.SigningKey.from_string(private_key, curve = ecdsa.SECP256k1)
verifying_key = signing_key.get_verifying_key()
public_key = bytes.fromhex("04") + verifying_key.to_string()

sha256_1 = hashlib.sha256(public_key)

ripemd160 = hashlib.new("ripemd160")
ripemd160.update(sha256_1.digest())

hashed_public_key = bytes.fromhex("00") + ripemd160.digest()
checksum_full = hashlib.sha256(hashlib.sha256(hashed_public_key).digest()).digest()
checksum = checksum_full[:4]
bin_addr = hashed_public_key + checksum

result_address = base58.b58encode(bin_addr)
print ("Bitcoin address ", result_address)

In this video https://www.youtube.com/watch?v=tX-XokHf_nI explain all the details.

I
Ivan Tikhonov, 2022-03-07
@polym0rph

Yes, as stated above, we get a public key from a private key, and from it we already have a bitcoin address. Here it is described in detail how to get the address from the public key .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question