in python 3.7.2 i am trying to test bitcoin testnet code. i am trying to convert odd length testnet private key to byte format but no matter what i try i cannot do it there is always some error mainly because all the functions i tried cannot Handel odd length address. any suggestions guys? so far i have tried

import codecs 
odd_len_str = "93AZYqkwkPsKAjHg7FqjXVMukwRrXkzGXYFNUsov2zFhDdfH8DT" #length=51
decode_hex = codecs.getdecoder("hex_codec") 
decode_hex(odd_len_str)[0]

import binascii
binascii.hexlify(odd_len_str) #doesn't work

bytes.fromhex(odd_len_str) #doesn't work

error msg from the first method is:

_codec.py", line 19, in hex_decode
    return (binascii.a2b_hex(input), len(input))
binascii.Error: Odd-length string

2 Answers

0
Bish Chh On Best Solutions

sorry folks. hear i was trying to convert bit coin address directly to bytes type assuming they are in hexadecimal form but they are not so first have to convert them to hexadecimal notation using base58 then convert them to bytes

0
Community On

What is odd_len_str? You're not showing us what it is.