How did you find your private key? Did you find it in an old email? or Was it handwritten?
if it's handwriting You might write it down wrong at some point.
The private key that starts with '5' and has total 51 Char is
Uncompressed WIF private key pattern.
This type of key always has a checksum in the last position to check that all characters of the key are correct. When you try to import the key and got 'Invalid private key', It may be caused by having some characters wrong.
If you write it down no more than 3 character wrong. you can recover it with this python script below.
import base58
import itertools
Damage_key = '5Kax3UAwGmHHuj6fQD1LDmKR6J3SwYyFWyHgxKAZ2cKRzVCRETY' #change this key to your private key
Pos_3_change = list(itertools.combinations(range(1,51),3))
Base58_3_change = list(itertools.product('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz', repeat=3))
def key_recovery():
for a in Pos_3_change:
for b in Base58_3_change:
private_key = list(Damage_key)
private_key[a[0]] = b[0]
private_key[a[1]] = b[1]
private_key[a[2]] = b[2]
try:
base58.b58decode_check(''.join(private_key))
print(''.join(private_key))
except:
pass
print('complete...')
key_recovery()
You can adjust the code above to suit your case. Hope this help. if you have any question, there's an email and telegram contact in my profile, feel free to ask.
Thanks. I shall give it a try.