ledger_go

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

ledger-go

CircleCI Build status Build Status

This project provides a library to connect to ledger devices.

It handles USB (HID) communication and APDU encapsulation.

Linux, OSX and Windows are supported.

Get source

Apart from cloning, be sure you install dep dependency management tool https://github.com/golang/dep

Setup

Update dependencies using the following:

dep ensure 

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 DeserializePacket

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

func ErrorMessage

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 NewLedger

func NewLedger(dev *hid.Device) *Ledger

func (*Ledger) Close

func (ledger *Ledger) Close() error

func (*Ledger) Exchange

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

func (*Ledger) Read

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

func (*Ledger) Write

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