backend

package
v4.14.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 39 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAccountAlreadyExists = errors.New("already exists")

ErrAccountAlreadyExists is returned if an account is being added which already exists.

View Source
var (
	// Version of the backend as displayed to the user.
	Version = semver.NewSemVer(4, 14, 1)
)

Functions

This section is empty.

Types

type AccountEvent

type AccountEvent struct {
	Type string `json:"type"`
	Code string `json:"code"`
	Data string `json:"data"`
}

AccountEvent models an event triggered by an account.

type Backend

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

Backend ties everything together and is the main starting point to use the BitBox wallet library.

func NewBackend

func NewBackend(arguments *arguments.Arguments, environment Environment) (*Backend, error)

NewBackend creates a new backend with the given arguments.

func (*Backend) Accounts

func (backend *Backend) Accounts() []accounts.Interface

Accounts returns the current accounts of the backend.

func (*Backend) AccountsStatus

func (backend *Backend) AccountsStatus() string

AccountsStatus returns whether the accounts have been initialized.

func (*Backend) BitBoxBaseDeregister

func (backend *Backend) BitBoxBaseDeregister(bitboxBaseID string)

BitBoxBaseDeregister deregisters the device with the given ID from this backend.

func (*Backend) BitBoxBasesDetected

func (backend *Backend) BitBoxBasesDetected() map[string]string

BitBoxBasesDetected returns a map of IPs and Hostnames of detected Bases.

func (*Backend) BitBoxBasesRegistered

func (backend *Backend) BitBoxBasesRegistered() map[string]bitboxbase.Interface

BitBoxBasesRegistered returns a map of bitboxBaseIDs and registered bitbox bases.

func (*Backend) CheckElectrumServer

func (backend *Backend) CheckElectrumServer(server string, pemCert string) error

CheckElectrumServer checks if a tls connection can be established with the electrum server, and whether the server is an electrum server.

func (*Backend) CheckForUpdate

func (backend *Backend) CheckForUpdate() (*UpdateFile, error)

CheckForUpdate checks whether a newer version of this application has been released. It returns the retrieved update file if a newer version has been released and nil otherwise.

func (*Backend) CheckForUpdateIgnoringErrors

func (backend *Backend) CheckForUpdateIgnoringErrors() *UpdateFile

CheckForUpdateIgnoringErrors suppresses any errors that are triggered, for example, when offline.

func (*Backend) Coin

func (backend *Backend) Coin(code string) (coin.Coin, error)

Coin returns the coin with the given code or an error if no such coin exists.

func (*Backend) Config

func (backend *Backend) Config() *config.Config

Config returns the app config.

func (*Backend) CreateAndAddAccount

func (backend *Backend) CreateAndAddAccount(
	coin coin.Coin,
	code string,
	name string,
	getSigningConfiguration func() (*signing.Configuration, error),
	persist bool,
) error

CreateAndAddAccount creates an account with the given parameters and adds it to the backend. If persist is true, the configuration is fetched and saved in the accounts configuration.

func (*Backend) DefaultAppConfig

func (backend *Backend) DefaultAppConfig() config.AppConfig

DefaultAppConfig returns the default app config.y

func (*Backend) Deregister

func (backend *Backend) Deregister(deviceID string)

Deregister deregisters the device with the given ID from this backend.

func (*Backend) DeregisterKeystore

func (backend *Backend) DeregisterKeystore()

DeregisterKeystore removes the registered keystore.

func (*Backend) DevicesRegistered

func (backend *Backend) DevicesRegistered() map[string]device.Interface

DevicesRegistered returns a map of device IDs to device of registered devices.

func (*Backend) DownloadCert

func (backend *Backend) DownloadCert(server string) (string, error)

DownloadCert downloads the first element of the remote certificate chain.

func (*Backend) EmitBitBoxBaseDetected

func (backend *Backend) EmitBitBoxBaseDetected()

EmitBitBoxBaseDetected saves the IP and Hostname of detected BitBox Bases at this backend

func (*Backend) Events

func (backend *Backend) Events() <-chan interface{}

Events returns the push notifications channel.

func (*Backend) Keystores

func (backend *Backend) Keystores() *keystore.Keystores

Keystores returns the keystores registered at this backend.

func (*Backend) NotifyUser

func (backend *Backend) NotifyUser(text string)

NotifyUser creates a desktop notification.

func (*Backend) OnAccountInit

func (backend *Backend) OnAccountInit(f func(accounts.Interface))

OnAccountInit installs a callback to be called when an account is initialized.

func (*Backend) OnAccountUninit

func (backend *Backend) OnAccountUninit(f func(accounts.Interface))

OnAccountUninit installs a callback to be called when an account is stopped.

func (*Backend) OnBitBoxBaseInit

func (backend *Backend) OnBitBoxBaseInit(f func(bitboxbase.Interface))

OnBitBoxBaseInit installs a callback to be called when a bitboxbase is initialized.

func (*Backend) OnBitBoxBaseUninit

func (backend *Backend) OnBitBoxBaseUninit(f func(string))

OnBitBoxBaseUninit installs a callback to be called when a bitboxbase is uninitialized.

func (*Backend) OnDeviceInit

func (backend *Backend) OnDeviceInit(f func(device.Interface))

OnDeviceInit installs a callback to be called when a device is initialized.

func (*Backend) OnDeviceUninit

func (backend *Backend) OnDeviceUninit(f func(string))

OnDeviceUninit installs a callback to be called when a device is uninitialized.

func (*Backend) RatesUpdater

func (backend *Backend) RatesUpdater() *rates.RateUpdater

RatesUpdater returns the backend's ratesUpdater instance

func (*Backend) Register

func (backend *Backend) Register(theDevice device.Interface) error

Register registers the given device at this backend.

func (*Backend) RegisterKeystore

func (backend *Backend) RegisterKeystore(keystore keystore.Keystore)

RegisterKeystore registers the given keystore at this backend.

func (*Backend) RegisterTestKeystore

func (backend *Backend) RegisterTestKeystore(pin string)

RegisterTestKeystore adds a keystore derived deterministically from a PIN, for convenience in devmode.

func (*Backend) ReinitializeAccounts

func (backend *Backend) ReinitializeAccounts()

ReinitializeAccounts uninits and then reinits all accounts. This is useful to reload the accounts if the configuration changed (e.g. which accounts are active). This is a stopgap measure until accounts can be added and removed individually.

func (*Backend) Start

func (backend *Backend) Start() <-chan interface{}

Start starts the background services. It returns a channel of events to handle by the library client.

func (*Backend) SystemOpen

func (backend *Backend) SystemOpen(url string) error

SystemOpen opens a web url in the default browser, or a file url in the default application. It whitelists url patterns and blocks all invalid ones. Returns an error if the url was blocked or the url could not be opened.

func (*Backend) Testing

func (backend *Backend) Testing() bool

Testing returns whether this backend is for testing only.

func (*Backend) TryMakeNewBase

func (backend *Backend) TryMakeNewBase(ip string) (bool, error)

TryMakeNewBase calls TryMakeNewBase() in the manager with the given ip

func (*Backend) UserLanguage

func (backend *Backend) UserLanguage() language.Tag

UserLanguage returns the language the UI should be presented in to the user.

type Environment

type Environment interface {
	// NotifyUser notifies the user, via desktop notifcation, mobile notification area, ...
	NotifyUser(string)
	// DeviceInfos returns a list of available recognized devices (BitBox01, BitBox02, ...).
	DeviceInfos() []usb.DeviceInfo
	// SystemOpen opens a web url in the default browser, or a file url in the default application.
	SystemOpen(string) error
}

Environment represents functionality where the implementation depends on the environment the app runs in, e.g. Qt5/Mobile/webdev.

type Notifier

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

Notifier implements accounts.Notifier, storing the data of all accounts in a bbolt db.

func NewNotifier

func NewNotifier(dbFilename string) (*Notifier, error)

NewNotifier returns a new Notifier.

func (*Notifier) ForAccount

func (notifier *Notifier) ForAccount(accountCode string) accounts.Notifier

ForAccount returns a Notifier for a specific account.

type UpdateFile

type UpdateFile struct {
	// CurrentVersion stores the current version and is not loaded from the server.
	CurrentVersion *semver.SemVer `json:"current"`

	// NewVersion stores the new version and may not be nil.
	NewVersion *semver.SemVer `json:"version"`

	// Description gives additional information on the release.
	Description string `json:"description"`
}

UpdateFile is retrieved from the server.

Directories

Path Synopsis
mdns
Package mdns manages and/or registers new bitbox bases.
Package mdns manages and/or registers new bitbox bases.
rpcclient
Package rpcclient contains the API to the physical device.
Package rpcclient contains the API to the physical device.
Package bridgecommon provides common util functions to bridge the backend to a native environment.
Package bridgecommon provides common util functions to bridge the backend to a native environment.
coins
btc
btc/electrum/client
Package client implements an Electrum JSON RPC client.
Package client implements an Electrum JSON RPC client.
btc/maketx
Package maketx provides transaction creation code for wallets.
Package maketx provides transaction creation code for wallets.
eth
ltc
devices
bitbox
Package bitbox contains the API to the physical device.
Package bitbox contains the API to the physical device.
bitbox02
Package bitbox02 implements the Device and Keystore interfaces to integrate the bitbox02 into the app.
Package bitbox02 implements the Device and Keystore interfaces to integrate the bitbox02 into the app.
bitbox02/api
Package api contains the API to the physical device.
Package api contains the API to the physical device.
bitbox02bootloader
Package bitbox02bootloader contains the API to the physical device.
Package bitbox02bootloader contains the API to the physical device.
bitbox02common
Package bitbox02common contains common functionality to bitbox02 and bitbox02bootloader.
Package bitbox02common contains common functionality to bitbox02 and bitbox02bootloader.
usb

Jump to

Keyboard shortcuts

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