trezoreum

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TrezorScheme         string = "trezor"
	VendorIDWithHID      uint16 = 0x534c
	VendorIDWithWebUSB   uint16 = 0x1209
	UsageIDWIthHID       uint16 = 0xff00
	UsageIDWIthWebUSB    uint16 = 0xffff
	EndPointIDWithHID    int    = 0x0
	EndPointIDWithWebUSB int    = 0x0
)

Variables

View Source
var (
	ProductIDsWithHID    []uint16 = []uint16{0x0001}
	ProductIDsWithWebUSB []uint16 = []uint16{0x53c1}
)
View Source
var ErrTrezorPINNeeded = errors.New("trezor: pin needed")

ErrTrezorPINNeeded is returned if opening the trezor requires a PIN code. In this case, the calling application should display a pinpad and send back the encoded passphrase.

View Source
var ErrTrezorPassphraseNeeded = errors.New("trezor: passphrase needed")

ErrTrezorPassphraseNeeded is returned if opening the trezor requires a passphrase

Functions

func PromptPINFromStdin

func PromptPINFromStdin() string

func ReadPassword

func ReadPassword(fd int) ([]byte, error)

Types

type Bridge

type Bridge interface {
	// init the connection to trezor via libusb and return the status
	// of the device as well as indication to next step to unlock the
	// device.
	Init() (info trezor.Features, state TrezorState, err error)

	Unlock() error

	Derive(path accounts.DerivationPath) (common.Address, error)

	Sign(
		path accounts.DerivationPath,
		tx *types.Transaction,
		chainID *big.Int,
	) (common.Address, *types.Transaction, error)
}

type CallMode

type CallMode int
const (
	CallModeRead      CallMode = 0
	CallModeWrite     CallMode = 1
	CallModeReadWrite CallMode = 2
)

type TrezorDriver

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

trezorDriver implements the communication with a Trezor hardware wallet.

func NewTrezorDriver

func NewTrezorDriver() *TrezorDriver

newTrezorDriver creates a new instance of a Trezor USB protocol driver.

func (*TrezorDriver) Exchange

func (self *TrezorDriver) Exchange(req proto.Message, results ...proto.Message) (int, error)

func (*TrezorDriver) SetDevice

func (self *TrezorDriver) SetDevice(device io.ReadWriter)

type TrezorSigner

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

func NewTrezorSigner

func NewTrezorSigner(path string, address string) (*TrezorSigner, error)

func (*TrezorSigner) SignTx

func (self *TrezorSigner) SignTx(
	tx *types.Transaction,
	chainId *big.Int,
) (*types.Transaction, error)

type TrezorState

type TrezorState int
const (
	Ready                TrezorState = iota // Already unlocked and ready to sign data
	WaitingForPin                           // Expecting PIN in order to unlock the trezor
	WaitingForPassphrase                    // Expecting passphrase in order to unlock the trezor
	Unexpected
)

type Trezoreum

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

func NewTrezoreum

func NewTrezoreum() (*Trezoreum, error)

func (*Trezoreum) Derive

func (self *Trezoreum) Derive(path accounts.DerivationPath) (common.Address, error)

func (*Trezoreum) GetDevice

func (self *Trezoreum) GetDevice() ([]usb.DeviceInfo, error)

func (*Trezoreum) Init

func (self *Trezoreum) Init() (trezor.Features, TrezorState, error)

func (*Trezoreum) Sign

func (self *Trezoreum) Sign(
	path accounts.DerivationPath,
	tx *types.Transaction,
	chainId *big.Int,
) (common.Address, *types.Transaction, error)

func (*Trezoreum) SignDynamicFeeTx added in v0.0.30

func (self *Trezoreum) SignDynamicFeeTx(
	path accounts.DerivationPath,
	tx *types.Transaction,
	chainId *big.Int,
) (common.Address, *types.Transaction, error)

func (*Trezoreum) SignLegacyTx added in v0.0.30

func (self *Trezoreum) SignLegacyTx(
	path accounts.DerivationPath,
	tx *types.Transaction,
	chainId *big.Int,
) (common.Address, *types.Transaction, error)

func (*Trezoreum) Unlock

func (self *Trezoreum) Unlock() error

func (*Trezoreum) UnlockByPassphrase

func (self *Trezoreum) UnlockByPassphrase(passphrase string) (TrezorState, error)

func (*Trezoreum) UnlockByPin

func (self *Trezoreum) UnlockByPin(pin string, results ...proto.Message) (int, error)

Directories

Path Synopsis
Package trezor contains the wire protocol.
Package trezor contains the wire protocol.

Jump to

Keyboard shortcuts

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