db

package
v0.0.0-...-7df67f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 21 Imported by: 0

README

SQLite db implementation

The Datastore interface allows for a pluggable wallet database. This package contains a working Datastore implementation using SQLite. This is not the default database.

Documentation

Index

Constants

View Source
const STORAGE = "storage"

Variables

View Source
var (
	ErrBadPw = errors.New("bad password")
	// Argon2 params
	SALT    = []byte("2977958431d29f2d") // TODO: a good random for dev
	TIME    = uint32(1)
	MEM     = uint32(64 * 1024)
	THREADS = uint8(runtime.NumCPU())
	THRDMAX = uint8(255)
	KEYLEN  = uint32(32)
)

Functions

func PrivKeyToWif

func PrivKeyToWif() error

Types

type CfgDB

type CfgDB struct {
	// contains filtered or unexported fields
}

func (*CfgDB) GetCreationDate

func (s *CfgDB) GetCreationDate() (time.Time, error)

func (*CfgDB) PutCreationDate

func (s *CfgDB) PutCreationDate(creationDate time.Time) error

type EncDB

type EncDB struct {
	// contains filtered or unexported fields
}

func (*EncDB) GetDecrypted

func (e *EncDB) GetDecrypted(pw string) ([]byte, error)

func (*EncDB) PutEncrypted

func (e *EncDB) PutEncrypted(b []byte, pw string) error

type KeysDB

type KeysDB struct {
	// contains filtered or unexported fields
}

func (*KeysDB) GetAll

func (k *KeysDB) GetAll() ([]wallet.KeyPath, error)

func (*KeysDB) GetDbg

func (k *KeysDB) GetDbg() string

TODO: Implement dbg keys from bbolt keys For now the `sqlite3` tool gives us this

func (*KeysDB) GetLastKeyIndex

func (k *KeysDB) GetLastKeyIndex(purpose wallet.KeyPurpose) (int, bool, error)

func (*KeysDB) GetLookaheadWindows

func (k *KeysDB) GetLookaheadWindows() map[wallet.KeyPurpose]int

func (*KeysDB) GetPathForKey

func (k *KeysDB) GetPathForKey(scriptAddress []byte) (wallet.KeyPath, error)

func (*KeysDB) GetUnused

func (k *KeysDB) GetUnused(purpose wallet.KeyPurpose) ([]int, error)

func (*KeysDB) MarkKeyAsUsed

func (k *KeysDB) MarkKeyAsUsed(scriptAddress []byte) error

func (*KeysDB) Put

func (k *KeysDB) Put(scriptAddress []byte, keyPath wallet.KeyPath) error

type SQLiteDatastore

type SQLiteDatastore struct {
	// contains filtered or unexported fields
}

This database is an SqLite3 implementation of Datastore. A different database could be plugged in .. bbolt maybe

func Create

func Create(repoPath string) (*SQLiteDatastore, error)

func (*SQLiteDatastore) Cfg

func (db *SQLiteDatastore) Cfg() wallet.Cfg

func (*SQLiteDatastore) Enc

func (db *SQLiteDatastore) Enc() wallet.Enc

func (*SQLiteDatastore) Keys

func (db *SQLiteDatastore) Keys() wallet.Keys

func (*SQLiteDatastore) Stxos

func (db *SQLiteDatastore) Stxos() wallet.Stxos

func (*SQLiteDatastore) Subscriptions

func (db *SQLiteDatastore) Subscriptions() wallet.Subscriptions

func (*SQLiteDatastore) Txns

func (db *SQLiteDatastore) Txns() wallet.Txns

func (*SQLiteDatastore) Utxos

func (db *SQLiteDatastore) Utxos() wallet.Utxos

type StxoDB

type StxoDB struct {
	// contains filtered or unexported fields
}

func (*StxoDB) Delete

func (s *StxoDB) Delete(stxo wallet.Stxo) error

func (*StxoDB) GetAll

func (s *StxoDB) GetAll() ([]wallet.Stxo, error)

func (*StxoDB) Put

func (s *StxoDB) Put(stxo wallet.Stxo) error

type SubscriptionsDB

type SubscriptionsDB struct {
	// contains filtered or unexported fields
}

func (*SubscriptionsDB) Delete

func (s *SubscriptionsDB) Delete(scriptPubKey string) error

func (*SubscriptionsDB) Get

func (s *SubscriptionsDB) Get(scriptPubKey string) (*wallet.Subscription, error)

func (*SubscriptionsDB) GetAll

func (s *SubscriptionsDB) GetAll() ([]*wallet.Subscription, error)

func (*SubscriptionsDB) GetElectrumScripthash

func (s *SubscriptionsDB) GetElectrumScripthash(electrumScripthash string) (*wallet.Subscription, error)

func (*SubscriptionsDB) Put

func (s *SubscriptionsDB) Put(subscription *wallet.Subscription) error

type TxnsDB

type TxnsDB struct {
	// contains filtered or unexported fields
}

func (*TxnsDB) Delete

func (t *TxnsDB) Delete(txid string) error

func (*TxnsDB) Get

func (t *TxnsDB) Get(txid string) (wallet.Txn, error)

func (*TxnsDB) GetAll

func (t *TxnsDB) GetAll(includeWatchOnly bool) ([]wallet.Txn, error)

func (*TxnsDB) Put

func (t *TxnsDB) Put(txn []byte, txid string, value int64, height int64, timestamp time.Time, watchOnly bool) error

func (*TxnsDB) UpdateHeight

func (t *TxnsDB) UpdateHeight(txid string, height int, timestamp time.Time) error

type UtxoDB

type UtxoDB struct {
	// contains filtered or unexported fields
}

func (*UtxoDB) Delete

func (u *UtxoDB) Delete(utxo wallet.Utxo) error

func (*UtxoDB) Freeze

func (u *UtxoDB) Freeze(utxo wallet.Utxo) error

func (*UtxoDB) GetAll

func (u *UtxoDB) GetAll() ([]wallet.Utxo, error)

func (*UtxoDB) Put

func (u *UtxoDB) Put(utxo wallet.Utxo) error

func (*UtxoDB) SetWatchOnly

func (u *UtxoDB) SetWatchOnly(utxo wallet.Utxo) error

func (*UtxoDB) UnFreeze

func (u *UtxoDB) UnFreeze(utxo wallet.Utxo) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL