ledger_go

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

ledger-go

CircleCI

This project provides a library to connect to ledger devices.

It handles USB (HID) communication and APDU encapsulation.

Linux, OSX and Windows are supported.

Building

go build

Documentation

Index

Constants

View Source
const (
	VendorLedger         = 0x2c97
	UsagePageLedgerNanoS = 0xffa0
	//ProductNano     = 1
	Channel    = 0x0101
	PacketSize = 64
)

Variables

This section is empty.

Functions

func CountLedgerDevices

func CountLedgerDevices() uint

func DeserializePacket

func DeserializePacket(
	channel uint16,
	buffer []byte,
	sequenceIdx uint16) (result []byte, totalResponseLength uint16, err error)

func ErrorMessage added in v0.5.0

func ErrorMessage(errorCode uint16) string

func ListDevices

func ListDevices()

func SerializePacket

func SerializePacket(
	channel uint16,
	command []byte,
	packetSize int,
	sequenceIdx uint16) (result []byte, offset int, err error)

func UnwrapResponseAPDU

func UnwrapResponseAPDU(channel uint16, pipe <-chan []byte, packetSize int) ([]byte, error)

UnwrapResponseAPDU parses a response of 64 byte packets into the real data

func WrapCommandAPDU

func WrapCommandAPDU(
	channel uint16,
	command []byte,
	packetSize int) (result []byte, err error)

WrapCommandAPDU turns the command into a sequence of 64 byte packets

Types

type Ledger

type Ledger struct {
	Logging bool
	// contains filtered or unexported fields
}

func FindLedger

func FindLedger() (*Ledger, error)

func GetLedger

func GetLedger(requiredIndex uint) (*Ledger, error)

func (*Ledger) Close added in v0.8.0

func (ledger *Ledger) Close() error

func (*Ledger) Exchange

func (ledger *Ledger) Exchange(command []byte) ([]byte, error)

func (*Ledger) Read added in v0.5.0

func (ledger *Ledger) Read() <-chan []byte

func (*Ledger) Write added in v0.5.0

func (ledger *Ledger) Write(buffer []byte) (int, error)

Jump to

Keyboard shortcuts

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