bitcoinlib.db module

class bitcoinlib.db.DbInit(databasefile='/home/docs/.bitcoinlib/database/bitcoinlib.sqlite')[source]

Bases: object

Initialize database and open session

Import data if database did not exist yet

class bitcoinlib.db.DbKey(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Database definitions for keys in Sqlalchemy format

Part of a wallet, and used by transactions

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

account_id
address
address_index
balance
change
compressed
depth
encoding
id
is_private
key_type
multisig_children
multisig_parents
name
network
network_name
parent_id
path
private
public
purpose
transaction_inputs
transaction_outputs
used
wallet
wallet_id
wif
class bitcoinlib.db.DbKeyMultisigChildren(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Use many-to-many relationship for multisig keys. A multisig keys contains 2 or more child keys and a child key can be used in more then one multisig key.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

child_id
key_order
parent_id
class bitcoinlib.db.DbNetwork(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Database definitions for networks in Sqlalchemy format

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

description
name
class bitcoinlib.db.DbTransaction(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Database definitions for transactions in Sqlalchemy format

Refers to 1 or more keys which can be part of a wallet

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

block_hash
block_height
coinbase
confirmations
date
fee
hash
id
input_total
inputs
locktime
network
network_name
output_total
outputs
raw
size
status
version
wallet
wallet_id
witness_type
class bitcoinlib.db.DbTransactionInput(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Transaction Input Table

Relates to Transaction table and Key table

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

double_spend
index_n
key
key_id
output_n
prev_hash
script
script_type
sequence
transaction
transaction_id
value
witness_type
class bitcoinlib.db.DbTransactionOutput(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Transaction Output Table

Relates to Transaction and Key table

When spent is False output is considered an UTXO

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

key
key_id
output_n
script
script_type
spent
transaction
transaction_id
value
class bitcoinlib.db.DbWallet(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base

Database definitions for wallets in Sqlalchemy format

Contains one or more keys.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

children
encoding

Default encoding to use for address generation

id
keys
main_key_id
multisig_n_required

Number of required signature for multisig, only used for multisignature master key

name
network
network_name
owner
parent_id
purpose
scheme
sort_keys

Sort keys in multisig wallet

transactions
witness_type
class bitcoinlib.db.TransactionType[source]

Bases: enum.Enum

Incoming or Outgoing transaction Enumeration

incoming = 1
outgoing = 2