Closed krupan closed 8 months ago
Between major versions the database is not automatically updated unfortunately.
What you can do is copy the private keys and recreate the wallets. In tools/import_database.py you can find an example of a very basic automated script to import a bunch of wallets.
Make sure you backup the database before you run any scripts, but you already knew that...
I don't see an import_database.py anywhere in this repo
I think I can figure this out by looking at the source for clw though
Here's a quick and dirty script I wrote to migrate my wallets from an old database to a new one:
#!/usr/bin/env python3
"""Pretty hacky, but it works. Move the database from
~/.bitcoinlib/database/bitcoinlib.sqlite to
database-bitcoinlib.sqlite, then run this script
"""
import subprocess
from bitcoinlib.config.config import DEFAULT_DATABASE
from bitcoinlib.wallets import Wallet, wallets_list
print(f"database: {DEFAULT_DATABASE}")
# learned how to do this from clw
for w in wallets_list(db_uri='database-backup.sqlite'):
if 'parent_id' in w and w['parent_id']:
continue
wlt = Wallet(w['name'], db_uri='database-backup.sqlite')
print(f"[{w['id']}] {w['name']} ({w['network']}) {w['owner']}")
subprocess.run(['clw', '-c', wlt.main_key.wif, w['name']], check=True)
try:
subprocess.run(['clw', '--update-transactions', w['name']], check=True)
except subprocess.CalledProcessError:
pass # we'll just try again later
I'm sorry, I saw the tools/import_database.py was only available in the latest version and not in the current branch. https://github.com/1200wd/bitcoinlib/blob/release-v07/bitcoinlib/tools/import_database.py
But your script seems to do the same...
I have some wallets I created back in 2021 and I recently updated my laptop with the python 3.11 and bitcoinlib 0.6.14 and now when I do this:
I see some wallet info and then a traceback which seems to indicate that my database probably needs a schema upgrade? Is there an easy safe way to do that?