Nice one NotATether.
Based on Your code - Ive created similar for version pre0.13 (OP provided password longer than 16, and min 15 chart was requested by Blockstack cli version 0.0.12.4 - so maybe version pre13)
Blockstack cli version 0.0.12.4 use registrar for encrypted_key = (aes_encrypt(hex_privkey, hex_password)).
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Blockstack-client wallet restore script
by NotATether
Usage: python2 restore-wallet.py /path/to/wallet.json /path/to/destination/wallet.json
Due to legacy blockstack_client dependencies, Python 2 is REQUIRED.
This script does not overwrite the destination file until after the wallet JSON is decoded successfully.
Please move your coins off of blockstack-client, it is abandoned wallet software!
"""
from registrar.wallet import HDWallet
from registrar.crypto.utils import aes_encrypt, aes_decrypt
from binascii import hexlify
import json
import sys
import os.path
if __name__ == "__main__":
result = {}
print "Blockstack legacy wallet restore tool by NotATether"
print "-----"
print ""
if len(sys.argv) != 3:
print "Usage: python2 %s /path/to/wallet.json /path/to/destination/wallet.json" % sys.argv[0]
sys.exit(1)
src = sys.argv[1]
dest = sys.argv[2]
print "Opening wallet file %s..." % src
f_src = open(src)
jwallet = json.load(f_src)
print "Deriving master private key..."
hex_privkey = jwallet["master_private_key"]
password = jwallet["wallet_password"]
hex_password = hexlify(password)
wallet = HDWallet(hex_privkey)
child = wallet.get_child_keypairs(count=2)
data = {}
encrypted_key = aes_encrypt(hex_privkey, hex_password)
data['encrypted_master_private_key'] = encrypted_key
data['payment_addresses'] = [child[0]]
data['owner_addresses'] = [child[1]]
file = open(dest, 'w')
file.write(json.dumps(data))
file.close()
print ""
print "Wallet created. Make sure to backup the following:"
print ""
print "-----"
print "master_private_key:", hex_privkey
print "wallet_password:", password
print "-----"
print ""
print "-----"
print "encrypted_master_private_key:", encrypted_key
print "owner_addresses:", [child[1]]
print "payment_addresses:", [child[0]]
print "-----"
print ""
print ""
print "-----"
print "Backup - part of wallet.json"
print(data)
print ""
print ""
How to use? in Ubuntu Terminal
pip2 install registrar==0.0.3.3
Save code (the long one, first one above) as restoreold.py
Create file
old.json with:
{
"master_private_key": "ef242kfjj24ekf3223jesdkhefsfhk324wuefhw38fhrypofhtr34d342132d34jsd49",
"wallet_password": “kljsef9832nkfssf”
}
Put old.json to the same folder with
restoreold.pyUbuntu terminal - navigate to the folder where two above files are.
Commands (use one)
python2 restoreold.py old.json wallet.json
Will create new file wallet.json in the folder of the code (next to old.json and restoreold.py) and print in terminal all keys, passwords etc.
python2 restoreold.py old.json ~/.blockstack/wallet.json
Will create wallet.json in blockstack folder (and also print every keys in terminal).
Maybe it will help.