Documentation ¶
Index ¶
- Variables
- func Decrypt(ciphertext []byte, key []byte) ([]byte, error)
- func Encrypt(plaintext []byte, key []byte) ([]byte, error)
- func GetKey(password string, salt []byte) ([]byte, error)
- type BoltDB
- func (b *BoltDB) Close() error
- func (b *BoltDB) Delete(bucket []byte, key []byte) error
- func (b *BoltDB) DeleteBucket(bucket []byte) error
- func (b *BoltDB) Get(bucket []byte, key []byte) (value []byte, err error)
- func (b *BoltDB) GetBucket(bucket []byte) (buck *Bucket, err error)
- func (b *BoltDB) GetRaw(bucket []byte, key []byte) (value []byte, err error)
- func (b *BoltDB) InitDB(filename string, password string) (err error)
- func (b *BoltDB) Name() string
- func (b *BoltDB) Put(bucket []byte, key []byte, value []byte) error
- func (b *BoltDB) PutRaw(bucket []byte, key []byte, value []byte) error
- type Bucket
- type DB
- type KeyValue
- type MemoryDB
- func (b *MemoryDB) Close() error
- func (b *MemoryDB) Delete(bucket []byte, key []byte) (err error)
- func (b *MemoryDB) DeleteBucket(bucket []byte) error
- func (b *MemoryDB) Get(bucket []byte, key []byte) (value []byte, err error)
- func (b *MemoryDB) GetBucket(bucket []byte) (buck *Bucket, err error)
- func (b *MemoryDB) GetRaw(bucket []byte, key []byte) (value []byte, err error)
- func (b *MemoryDB) InitDB(string, string) (err error)
- func (b *MemoryDB) Name() string
- func (b *MemoryDB) Put(bucket []byte, key []byte, value []byte) error
- func (b *MemoryDB) PutRaw(bucket []byte, key []byte, value []byte) error
- type Version
Constants ¶
This section is empty.
Variables ¶
View Source
var BucketConfig = []byte("Config")
View Source
var ErrDatabaseAlreadyEncrypted = errors.New("database already encrypted")
View Source
var ErrDatabaseNotEncrypted = errors.New("database not encrypted")
View Source
var ErrInvalidPassword = errors.New("invalid password")
View Source
var ErrMalformedEncryptedDatabase = errors.New("malformed encrypted database")
View Source
var ErrNoBucket = errors.New("bucket not defined")
View Source
var ErrNoPassword = errors.New("no password specified for encrypted database")
View Source
var ErrNotFound = errors.New("key not found")
View Source
var ErrNotOpen = errors.New("database not open")
View Source
var WalletVersion = NewVersion(0, 0, 1, 1)
WalletVersion is incremented whenever a bucket format is changed.
Functions ¶
Types ¶
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
func (*BoltDB) DeleteBucket ¶
DeleteBucket will delete all key/value pairs from a bucket
func (*BoltDB) GetRaw ¶ added in v0.6.0
Get will get an entry in the database given a bucket and key
type Bucket ¶
type Bucket struct { KeyValueList []KeyValue //KeyValueList contains the key/value data for the entry // contains filtered or unexported fields }
Bucket is the structure to store the key/value data and a reference map to pull it.
func NewBucket ¶
func NewBucket() *Bucket
NewBucket creates a new instance of the bucket and initializes the map
type DB ¶
type DB interface { Close() error // Returns an error if the close fails Name() string // returns the database filename if applicable InitDB(filepath string, password string) error // Sets up the database, returns error if it fails Get(bucket []byte, key []byte) (value []byte, err error) // Get key from database (may further decrypt data if applicable), returns ErrNotFound if the key is not found Put(bucket []byte, key []byte, value []byte) error // Put the value in the database (may further encrypt data if applicable), throws an error if fails GetRaw(bucket []byte, key []byte) (value []byte, err error) // GetRaw value as-is from database using key, returns ErrNotFound if the key is not found PutRaw(bucket []byte, key []byte, value []byte) error // PutRaw the value in the database as-is, throws an error if fails GetBucket(bucket []byte) (*Bucket, error) // GetBucket retrieves all the data contained within a bucket Delete(bucket []byte, key []byte) error // Delete will remove a key/value pair from the bucket DeleteBucket(bucket []byte) error // DeleteBucket will delete all key/value pairs from a bucket }
DB defines the interface functions to access the database
type MemoryDB ¶
type MemoryDB struct {
// contains filtered or unexported fields
}
MemoryDB holds the main map of buckets for the in-memory database
func (*MemoryDB) DeleteBucket ¶
DeleteBucket will delete all key/value pairs from a bucket
func (*MemoryDB) GetRaw ¶ added in v0.6.0
Get will get an entry in the database given a bucket and key
func (*MemoryDB) InitDB ¶
InitDB initializes the MemoryDB and must be called prior to use of the object
Click to show internal directories.
Click to hide internal directories.