2

I'm trying to generate a testnet address. However, I tried to write this python program (using help of various online code places), and I created this program. The program is designed to take a 20 byte input and then turn that 20 bytes of data into an address by putting the version byte (6f), the meat of the data (the 20 bytes being added into the code), and the checksum. However, it didn't work.

# *-* encoding: utf-8 *-*

import hashlib, codecs, sys, base58, bytes, base64
def checksum(inPut):
# Double SHA256 to get checksum
    sha256_nbpk = hashlib.sha256(inPut.encode())
    sha256_nbpk_digest = sha256_nbpk.digest()
    sha256_2_nbpk = hashlib.sha256(sha256_nbpk_digest)
    sha256_2_nbpk_digest = sha256_2_nbpk.digest()
    sha256_2_hex = codecs.encode(sha256_2_nbpk_digest, 'hex')
    return (str(sha256_2_hex)[2:-1])[:8]

x = "6f"+"64"*20
x += checksum(x)
print(str(base58.b58encode(str(base64.b16decode(x.upper()))))[2:-1])
1
  • This is a great idea. Did you find a solve? Maybe you'd have to have your own fully isolated 'new' bitcoin system , eg a set of dockers? I'm just guessing since I know little. Commented Mar 29, 2020 at 1:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.