Wrong testnet address generation [python]

Wrong testnet address generation [python]

I'm trying to generate a testnet address without success.Main net address is working fine. Here is my code. The generated testnet address from this code is :CNFNz61dzQ2NQ9RCnjJFrm2de7nLbbT9xSv which is in wrong format.

import os
import ecdsa
import hashlib
import base58

#private_key = os.urandom(32).encode("hex")
private_key = 
"7c7cd1c5f24b255ae113459dccdba8df3ff2e76ca0932d02f81be27311c64e32"

print "this is my private key: " + private_key

sk = ecdsa.SigningKey.from_string(private_key.decode("hex"), curve = 
ecdsa.SECP256k1)

vk = sk.verifying_key

public_key = ('\04'+ vk.to_string()).encode("hex")

print "this is my public key: " + public_key

ripemd160 = hashlib.new('ripemd160')

ripemd160.update(hashlib.sha256(public_key.decode("hex")).digest())

ripemd160.digest()
#main network id
#middle_man = '\00' + ripemd160.digest()

#testnet id
middle_man = '\6f' + ripemd160.digest()

checksum = 
hashlib.sha256(hashlib.sha256(middle_man).digest()).digest()[:4]

binary_addr = middle_man + checksum

addr = base58.b58encode(binary_addr)

# main address = 19kyG9Q5QXMEZSpte6fpTeo1BWKV5Pa6ch
print "testnet address: " + addr
http://ift.tt/2t4I1jY

Comments

Popular posts from this blog

Bitcoin Core errors with database block

Bitfinex & Market Synergy To Offer Institutional Calibre Cryptocurrency Connectivity