ledger_go

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

README

ledger-go

CircleCI Build status Build Status

This project is work in progress. Some aspects are subject to change.

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 ledger.go

Running

./ledger

Make sure that the app is launched in the Ledger before starting this command and Ledger is connected to the USB port. This command line tool will try to send a simple json transaction and will return a signature when user agrees to sign.

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func DeserializePacket

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

func ListDevices

func ListDevices()

func SerializePacket

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

func UnwrapResponseAPDU

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

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

func WrapCommandAPDU

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

WrapCommandAPDU turns the command into a sequence of 64 byte packets

Types

type Device

type Device interface {
	// Close closes the device and associated resources.
	Close()

	// Write writes an output report to device. The first byte must be the
	// report number to write, zero if the device does not use numbered reports.
	Write([]byte) error

	// ReadCh returns a channel that will be sent input reports from the device.
	// If the device uses numbered reports, the first byte will be the report
	// number.
	ReadCh() <-chan []byte

	// ReadError returns the read error, if any after the channel returned from
	// ReadCh has been closed.
	ReadError() error
}

A Device provides access to a HID device.

type Ledger

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

func FindLedger

func FindLedger() (*Ledger, error)

func NewLedger

func NewLedger(dev Device) *Ledger

func (*Ledger) Exchange

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

Jump to

Keyboard shortcuts

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