# Path: bitcoinlib/main.py
# def script_type_default(witness_type=None, multisig=False, locking_script=False):
# def get_encoding_from_witness(witness_type=None):
# def deprecated(func):
#     def new_func(*args, **kwargs):
# 
# Path: bitcoinlib/db.py
# def compile_largebinary_mysql(type_, compiler, **kwargs):
#     def __init__(self, db_uri=None, password=None):
#     def drop_db(self, yes_i_am_sure=False):
#     def _import_config_data(ses):
# def add_column(engine, table_name, column):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
# def db_update_version_id(db, version):
# def db_update(db, version_db, code_version=BITCOINLIB_VERSION):
# class Db:
# class DbConfig(Base):
# class DbWallet(Base):
# class DbKeyMultisigChildren(Base):
# class DbKey(Base):
# class DbNetwork(Base):
# class DbTransaction(Base):
# class DbTransactionInput(Base):
# class DbTransactionOutput(Base):


import os
import sys
import argparse
from copy import deepcopy
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from shutil import move
from bitcoinlib.main import DEFAULT_DATABASE, BCL_DATABASE_DIR, BITCOINLIB_VERSION
from bitcoinlib.db import Base, DbWallet, DbKey, DbKeyMultisigChildren, DbConfig
        # Remove unused fields
        db_field_names = [field[0] for field in DbWallet.__table__.columns.items()]
        fields_copy = deepcopy(fields)
        for f in fields_copy:
            if f not in db_field_names:
                del(fields[f])

        session.add(DbWallet(**fields))
    session.commit()

    keys = session_backup.execute("SELECT * FROM keys")
    for key in keys:
        fields = dict(key)

        # Update for 'key' field
        if 'key' in fields:
            if fields['is_private']:
                fields['private'] = fields['key']
            else:
                fields['public'] = fields['key']
            del(fields['key'])

        # Remove unused fields
        db_field_names = [field[0] for field in DbKey.__table__.columns.items()]
        fields_copy = deepcopy(fields)
        for f in fields_copy:
            if f not in db_field_names:
                del(fields[f])

        fields['used'] = False  # To force rescan of all keys

# Path: bitcoinlib/main.py
# def script_type_default(witness_type=None, multisig=False, locking_script=False):
# def get_encoding_from_witness(witness_type=None):
# def deprecated(func):
#     def new_func(*args, **kwargs):
# 
# Path: bitcoinlib/db.py
# def compile_largebinary_mysql(type_, compiler, **kwargs):
#     def __init__(self, db_uri=None, password=None):
#     def drop_db(self, yes_i_am_sure=False):
#     def _import_config_data(ses):
# def add_column(engine, table_name, column):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
# def db_update_version_id(db, version):
# def db_update(db, version_db, code_version=BITCOINLIB_VERSION):
# class Db:
# class DbConfig(Base):
# class DbWallet(Base):
# class DbKeyMultisigChildren(Base):
# class DbKey(Base):
# class DbNetwork(Base):
# class DbTransaction(Base):
# class DbTransactionInput(Base):
# class DbTransactionOutput(Base):


# Path: updatedb.py
import os
import sys
import argparse
from copy import deepcopy
from datetime import datetime
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from shutil import move
from bitcoinlib.main import DEFAULT_DATABASE, BCL_DATABASE_DIR, BITCOINLIB_VERSION
from bitcoinlib.db import Base, DbWallet, DbKey, DbKeyMultisigChildren, DbConfig

        # Remove unused fields
        db_field_names = [field[0] for field in DbWallet.__table__.columns.items()]
        fields_copy = deepcopy(fields)
        for f in fields_copy:
            if f not in db_field_names:
                del(fields[f])

        session.add(DbWallet(**fields))
    session.commit()

    keys = session_backup.execute("SELECT * FROM keys")
    for key in keys:
        fields = dict(key)

        # Update for 'key' field
        if 'key' in fields:
            if fields['is_private']:
                fields['private'] = fields['key']
            else:
                fields['public'] = fields['key']
            del(fields['key'])

        # Remove unused fields
        db_field_names = [field[0] for field in DbKey.__table__.columns.items()]
        fields_copy = deepcopy(fields)
        for f in fields_copy:
            if f not in db_field_names:
                del(fields[f])

        fields['used'] = False  # To force rescan of all keys

        session.add(DbKey(**fields))