bitbox02

package
v4.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: Apache-2.0 Imports: 24 Imported by: 6

Documentation

Overview

Package bitbox02 contains the API to the physical device.

Index

Constants

View Source
const (
	// EventChannelHashChanged is fired when the return values of ChannelHash() change.
	EventChannelHashChanged device.Event = "channelHashChanged"

	// EventStatusChanged is fired when the status changes. Check the status using Status().
	EventStatusChanged device.Event = "statusChanged"
)
View Source
const (

	// ErrInvalidInput is returned when the request sends and invalid or unexpected input
	ErrInvalidInput = 101

	// ErrMemory is returned when an an error occurs during memory handling in the commander
	ErrMemory = 102

	// ErrTouchButton TODO: currently not returned anywhere
	ErrTouchButton = 103

	// ErrSetPW is returned by SetPassword() if the two user passwords did not match.
	ErrSetPW = 104

	// ErrUserAbort is returned when the user aborts an action on the device.
	ErrUserAbort = 108
)
View Source
const ProductName = "bitbox02"

ProductName is the name of the BitBox02 product.

Variables

This section is empty.

Functions

This section is empty.

Types

type Communication

type Communication interface {
	SendFrame(string) error
	ReadFrame() ([]byte, error)
	Close()
}

Communication contains functions needed to communicate with the device.

type Device

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

Device provides the API to communicate with the BitBox02.

func NewDevice

func NewDevice(
	deviceID string,
	bootloader bool,
	version *semver.SemVer,
	communication Communication,
) *Device

NewDevice creates a new instance of Device.

func (*Device) BTCPub

func (device *Device) BTCPub(
	coin messages.BTCCoin,
	keypath []uint32,
	outputType messages.BTCPubRequest_OutputType,
	scriptType messages.BTCScriptType,
	display bool) (string, error)

BTCPub queries the device for a btc, ltc, tbtc, tltc xpub or address.

func (*Device) BTCSign

func (device *Device) BTCSign(
	btcProposedTx *btc.ProposedTransaction) ([]*btcec.Signature, error)

BTCSign signs a bitcoin or bitcoin-like transaction.

func (*Device) ChannelHash

func (device *Device) ChannelHash() (string, bool)

ChannelHash returns the hashed handshake channel binding

func (*Device) ChannelHashVerify

func (device *Device) ChannelHashVerify(ok bool)

ChannelHashVerify verifies the ChannelHash

func (*Device) Close

func (device *Device) Close()

Close implements device.Device.

func (*Device) CreateBackup

func (device *Device) CreateBackup() error

CreateBackup is called after SetPassword() to create the backup.

func (*Device) DeviceInfo

func (device *Device) DeviceInfo() (*DeviceInfo, error)

DeviceInfo retrieves the current device info from the bitbox

func (*Device) Identifier

func (device *Device) Identifier() string

Identifier implements device.Device.

func (*Device) Init

func (device *Device) Init(testing bool)

Init implements device.Device.

func (*Device) InsertRemoveSDCard

func (device *Device) InsertRemoveSDCard(action messages.InsertRemoveSDCardRequest_SDCardAction) error

InsertRemoveSDCard sends a command to the device to insert of remove the sd card based on the workflow state

func (*Device) KeystoreForConfiguration

func (device *Device) KeystoreForConfiguration(configuration *signing.Configuration, cosignerIndex int) keystoreInterface.Keystore

KeystoreForConfiguration implements device.Device.

func (*Device) ProductName

func (device *Device) ProductName() string

ProductName implements device.Device.

func (*Device) Random

func (device *Device) Random() ([]byte, error)

Random requests a random number from the device using protobuf messages

func (*Device) SetDeviceName

func (device *Device) SetDeviceName(deviceName string) error

SetDeviceName sends a request to the device using protobuf to set the device name

func (*Device) SetOnEvent

func (device *Device) SetOnEvent(onEvent func(devicepkg.Event, interface{}))

SetOnEvent implements device.Device.

func (*Device) SetPassword

func (device *Device) SetPassword() error

SetPassword invokes the set password workflow on the device. Should be called only if deviceInfo.Initialized is false.

func (*Device) Status

func (device *Device) Status() Status

Status returns the device state. See the Status* constants.

type DeviceInfo

type DeviceInfo struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Initialized bool   `json:"initialized"`
}

DeviceInfo is the data returned from the device info api call.

type Error

type Error struct {
	Code    int32
	Message string
}

Error wraps an error from bitbox02.

func NewError

func NewError(code int32, message string) *Error

NewError creates a error with the given message and code.

func (*Error) Error

func (err *Error) Error() string

Error implements the error interface.

type Status

type Status string

Status represents the device status.

const (
	// StatusUnpaired is the first status. After the pairing screen has been confirmed, we move to
	// StatusUninitialized or StatusInitialized depending on the device status.
	StatusUnpaired Status = "unpaired"

	// StatusPairingFailed is when the pairing code was rejected on the app or on the device.
	StatusPairingFailed Status = "pairingFailed"

	// StatusUninitialized is the uninitialized device. Use SetPassword() to proceed to
	// StatusSeeded.
	StatusUninitialized Status = "uninitialized"

	// StatusSeeded is after SetPassword(), before CreateBack() during initialization of the
	// device. Use CreateBackup() to move to StatusUnlocked.
	StatusSeeded Status = "seeded"

	// StatusInitialized means the device is seeded and the backup was created. Use Unlock() to move
	// to StatusUnlocked.
	StatusInitialized Status = "initialized"

	// StatusUnlocked means device authentication was successful, and the keystore is ready to use.
	StatusUnlocked Status = "unlocked"
)

Directories

Path Synopsis
Package messages is a generated protocol buffer package.
Package messages is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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