Documentation
¶
Overview ¶
Package store is a persistent database for everything that bmclient needs for operation. This includes storing mailboxes and messages, proof of work queue, list of requested pubkeys.
Take note that this store does not encrypt everything. Only messages contents are encrypted. Encryption scheme used is SalsaX20 stream cipher with Poly1305 MAC, based on secretbox in NaCl.
WARNING: If both your database and password were compromised, changing your
password won't accomplish anything. This is because store encrypts the master key using the password you specify when the database is created. A malicious user that knew your password and had a previous copy of the store knows the master key and can decrypt all messages.
WARNING 2: Master key is kept in memory. The package is vulnerable to memory
reading malware.
Index ¶
- Variables
- func DisableLog()
- func UseLogger(logger btclog.Logger)
- type BroadcastAddresses
- type Loader
- type PKRequests
- type Store
- func (s *Store) ChangePassphrase(pass []byte) error
- func (s *Store) Close() error
- func (s *Store) GetCounter(objType wire.ObjectType) (uint64, error)
- func (s *Store) GetUser(name string) (*User, error)
- func (s *Store) NewUser(name string) (*User, error)
- func (s *Store) SetCounter(objType wire.ObjectType, counter uint64) error
- func (s *Store) Users() map[string]*User
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDecryptionFailed is returned when decryption of the master key fails. // This could be due to invalid passphrase or corrupt/tampered data. ErrDecryptionFailed = errors.New("invalid passphrase") // ErrDuplicateMailbox is returned by NewMailbox when a mailbox with the // given name already exists. ErrDuplicateMailbox = errors.New("duplicate mailbox") )
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
Types ¶
type BroadcastAddresses ¶
type BroadcastAddresses struct {
// contains filtered or unexported fields
}
BroadcastAddresses keeps track of the broadcasts that the user is listening to. It provides functionality for adding, removal and running a function for each address.
func (*BroadcastAddresses) Add ¶
func (b *BroadcastAddresses) Add(address string) error
Add adds a new address to the store.
func (*BroadcastAddresses) ForEach ¶
func (b *BroadcastAddresses) ForEach(f func(address bmutil.Address) error) error
ForEach runs the specified function for each broadcast address, breaking early if an error occurs.
func (*BroadcastAddresses) Remove ¶
func (b *BroadcastAddresses) Remove(address string) error
Remove removes an address from the store.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader transforms underlying database into Store.
func (*Loader) Construct ¶
func (l *Loader) Construct(pass []byte) (*Store, *PKRequests, error)
Construct creates a new Store from the given file.
func (*Loader) IsEncrypted ¶
IsEncrypted returns whether the store is encrypted.
type PKRequests ¶
type PKRequests struct {
// contains filtered or unexported fields
}
PKRequests is a store that keeps track of getpubkey requests sent to the Bitmessage network. It stores the requested address along with the time the request was made. All addresses passed are expected to be valid Bitmessage addresses. A separate goroutine routinely queries the bmd RPC server for the public keys corresponding to the addresses in this store and removes them if bmd has received them. Thus, PKRequests serves as a watchlist.
func (*PKRequests) ForEach ¶
func (r *PKRequests) ForEach(f func(address string, reqCount uint32, lastReqTime time.Time) error) error
ForEach runs the specified function for each item in the public key requests store, breaking early if an error occurs.
func (*PKRequests) LastRequestTime ¶
func (r *PKRequests) LastRequestTime(addr string) (time.Time, error)
LastRequestTime returns the time that the last getpubkey request for the given address was sent out to the network. If the address doesn't exist, an ErrNotFound is returned.
func (*PKRequests) New ¶
func (r *PKRequests) New(addr string) (uint32, error)
New adds a new address to the watchlist along with the current timestamp. If the address already exists, it increments the counter value specifying the number of times a getpubkey request was sent for the given address and returns it.
func (*PKRequests) Remove ¶
func (r *PKRequests) Remove(addr string) error
Remove removes an address from the store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists all information about public key requests, pending POW, incoming/outgoing/pending messages to disk.
func (*Store) ChangePassphrase ¶
ChangePassphrase changes the passphrase of the data store. It does not protect against a previous compromise of the data file. Refer to package docs for more details.
func (*Store) GetCounter ¶
func (s *Store) GetCounter(objType wire.ObjectType) (uint64, error)
GetCounter returns the stored counter value associated with the given object type.
func (*Store) SetCounter ¶
func (s *Store) SetCounter(objType wire.ObjectType, counter uint64) error
SetCounter sets the counter value associated with the given object type.