Happy New Year 2020 to all,
anything new under the sun regarding the project, maybe some gpu pollard.
or
Program beginner.
I want to change pubkey to multiple bitcoin addresses at once.
I know sites that I do one by one, but I can't find them
Trying to modify a program
An error occurs.
Can someone help me?
sample
02be50064bec5707a6440c462497250888497b9ef313d16f68c653e73a8c90fef6
034ae4ae34ef74bf8d20012148b96b873207e9ff96a10b274fd464702f7990b55a
028cc91c75715770cdc967721cf6ac6b51464fde790cfda1bb0c02c1cb69e170ec
0374b3e4282cce5018ad6c470d25c6004bd7e629bbc10c644d4229266d3b9313ac
.........
There are many public key addresses.
#!/usr/bin/env python
#https://en.bitcoin.it/wiki/Protocol_documentation#Addresses
import hashlib
import base58
# ECDSA bitcoin Public Key
#pubkey = a
pubkey=['0369ce0e757d759689c9141bc4ee08ed37bb8493b268bd9e9c41eecd81fc9e0e51']
# See 'compressed form' at
https://en.bitcoin.it/wiki/Protocol_documentation#Signaturescompress_pubkey = False
def hash160(hex_str):
sha = hashlib.sha256()
rip = hashlib.new('ripemd160')
sha.update(hex_str)
rip.update( sha.digest() )
print ( "key_hash = \t" + rip.hexdigest() )
return rip.hexdigest() # .hexdigest() is hex ASCII
if (compress_pubkey):
if (ord(bytearray.fromhex(pubkey[-2:])) % 2 == 0):
pubkey_compressed = '02'
else:
pubkey_compressed = '03'
pubkey_compressed += pubkey[2:66]
hex_str = bytearray.fromhex(pubkey_compressed)
else:
hex_str = bytearray.fromhex(pubkey)
# Obtain key:
key_hash = '00' + hash160(hex_str)
# Obtain signature:
sha = hashlib.sha256()
sha.update( bytearray.fromhex(key_hash) )
checksum = sha.digest()
sha = hashlib.sha256()
sha.update(checksum)
checksum = sha.hexdigest()[0:8]
#print ( "checksum = \t" + sha.hexdigest() )
#print ( "key_hash + checksum = \t" + key_hash + ' ' + checksum )
print ( "bitcoin address = \t" + (base58.b58encode( bytes(bytearray.fromhex(key_hash + checksum)) )).decode('utf-8'))