Coder Social home page Coder Social logo

Comments (5)

mccwdev avatar mccwdev commented on August 24, 2024

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...

from bitcoinlib.

krupan avatar krupan commented on August 24, 2024

I don't see an import_database.py anywhere in this repo

from bitcoinlib.

krupan avatar krupan commented on August 24, 2024

I think I can figure this out by looking at the source for clw though

from bitcoinlib.

krupan avatar krupan commented on August 24, 2024

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

from bitcoinlib.

mccwdev avatar mccwdev commented on August 24, 2024

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...

from bitcoinlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.