bdb

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: 23 Imported by: 1

README

BoltDB db implementation

The Datastore interface allows for a pluggable wallet database. This package contains a workable Datastore implementation using BoltDB. This is the default datastore used by NewDefaultConfig.

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)
)
View Source
var ErrBucketNotFound = errors.New("cannot find bucket")

Functions

func PrivKeyToWif

func PrivKeyToWif() error

Types

type BoltDatastore

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

func Create

func Create(dbPath string, readOnly bool) (*BoltDatastore, error)

func (*BoltDatastore) Cfg

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

func (*BoltDatastore) Close

func (s *BoltDatastore) Close()

func (*BoltDatastore) Enc

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

func (*BoltDatastore) Keys

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

func (*BoltDatastore) Stxos

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

func (*BoltDatastore) Subscriptions

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

func (*BoltDatastore) Txns

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

func (*BoltDatastore) Utxos

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

type CfgDB

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

func (*CfgDB) GetCreationDate

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

func (*CfgDB) PutCreationDate

func (c *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

func (*KeysDB) GetLastKeyIndex

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

GetLastKeyIndex gets the last (highest) key index stored and whether it has been used. If error or no records it will return -1 and 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 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

Delete deletes a utxo from the database.

func (*UtxoDB) Freeze

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

Freeze sets this utxo as frozen. It cannot be used in a transaction.

func (*UtxoDB) Get

func (u *UtxoDB) Get(op *wire.OutPoint) (wallet.Utxo, error)

Get gets the utxo given an outpoint. Not part of the Utxo interface.

func (*UtxoDB) GetAll

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

Get gets all the utxos in the utxo bucket in the database.

func (*UtxoDB) Put

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

Put adds a utxo to the database. If the utxo already exists Put updates the utxo record.

func (*UtxoDB) SetWatchOnly

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

SetWatchOnly sets this utxo as watch only. It cannot be unset.

func (*UtxoDB) UnFreeze

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

UnFreeze resets this utxo as unfrozen. It can again be used in a transaction.

Jump to

Keyboard shortcuts

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