Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Modernize #6

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f19924d
Add FindLedgerDevices feature
Dec 4, 2019
659e70c
small fix
Dec 4, 2019
c4a59fd
.gitignore: remove `*.mod` in order to track `go.mod`
mkrufky Mar 25, 2019
b882678
add `go.mod` & `go.sum`
mkrufky Mar 25, 2019
d48b51f
remove `Gopkg.lock` & `Gopkg.toml`
mkrufky Mar 25, 2019
85c07f5
fix CI
mkrufky Mar 25, 2019
97e3aed
fixing CI
jleni Dec 6, 2019
9ac3150
including alessio recommendation
jleni Dec 6, 2019
366c283
Merge pull request #9 from mkrufky/go-mod
jleni Dec 6, 2019
9ba0738
update build instructions
jleni Dec 6, 2019
4c9658c
Merge remote-tracking branch 'origin/master' into david-yan/list-ledg…
jleni Dec 6, 2019
42f5038
fixing readme warnings
jleni Dec 6, 2019
0c0b430
improving API + tests
jleni Dec 6, 2019
fd1da71
Merge pull request #13 from ZondaX/david-yan/list-ledger-devices
jleni Dec 6, 2019
f586aa9
adjust exposed module path
jleni Dec 6, 2019
3259ef3
Simplify some logic
claucece Dec 16, 2019
abf8bf8
Merge pull request #14 from claucece/master
jleni Dec 17, 2019
5bb39de
Update README.md
jleni May 20, 2020
7b1a20b
restructuring hid/zemu/mock
jleni May 24, 2020
8c0d39e
Remove extra characters
raynaudoe Jun 1, 2020
bd5b338
Add grpc related code.
raynaudoe Jun 1, 2020
d13f23c
Add response check.
raynaudoe Jun 3, 2020
5a0e8e8
Add commentary
raynaudoe Jun 11, 2020
1dcb160
Merge pull request #15 from Zondax/zemu_gRPC
jleni Jun 12, 2020
9a633ce
Merge pull request #16 from Zondax/dev
jleni Jul 2, 2020
73b5de1
fix initialization issue
jleni Jul 21, 2020
a706abf
fix: use productID to detect ledger type
troian Apr 5, 2021
704180b
Merge pull request #18 from troian/fix-ledger-pid
jleni Apr 7, 2021
7cd72c1
fix device lookup on linux, as usage page is not available.
felipemadero Sep 29, 2022
dbd460b
Merge pull request #20 from felipemadero/fix-device-lookup-on-linux
jleni Oct 5, 2022
5233e2d
Merge branch 'master' of https://github.com/zondax/ledger-go
faddat Oct 11, 2022
3030e36
correct import path
faddat Oct 11, 2022
5584ef4
use go 1.18
faddat Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ version: 2
jobs:
build:
docker:
- image: golang:1.10
working_directory: /go/src/zondax/ledger-goclient
- image: golang:1.14
environment:
GO111MODULE: "on"
working_directory: /ledger-go
steps:
- checkout
- run: go get -v -u github.com/golang/dep/cmd/dep
- run: dep ensure -v
- run: go build ledger.go apduWrapper.go
- run: go test
- run: go test -tags ledger_mock
workflows:
version: 2
build_all:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
Expand Down
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

53 changes: 0 additions & 53 deletions Gopkg.lock

This file was deleted.

18 changes: 0 additions & 18 deletions Gopkg.toml

This file was deleted.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
go test -tags ledger_mock
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
# ledger-go

[![CircleCI](https://circleci.com/gh/ZondaX/ledger-go.svg?style=svg)](https://circleci.com/gh/ZondaX/ledger-go)
[![Build status](https://ci.appveyor.com/api/projects/status/m4wn7kuuuu98b3uh/branch/master?svg=true)](https://ci.appveyor.com/project/zondax/ledger-go/branch/master)
[![Build Status](https://travis-ci.org/ZondaX/ledger-goclient.svg?branch=master)](https://travis-ci.org/ZondaX/ledger-go)
[![CircleCI](https://circleci.com/gh/Zondax/ledger-go.svg?style=shield)](https://circleci.com/gh/ZondaX/ledger-go)

This project provides a library to connect to ledger devices.

It handles USB (HID) communication and APDU encapsulation.
It handles APDU encapsulation, Zemu and USB (HID) communication.

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
```
## Building
```bash
go build
```
37 changes: 37 additions & 0 deletions apduWrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,48 @@ package ledger_go

import (
"encoding/binary"
"fmt"
"github.com/pkg/errors"
)

var codec = binary.BigEndian

func ErrorMessage(errorCode uint16) string {
switch errorCode {
// FIXME: Code and description don't match for 0x6982 and 0x6983 based on
// apdu spec: https://www.eftlab.co.uk/index.php/site-map/knowledge-base/118-apdu-response-list

case 0x6400:
return "[APDU_CODE_EXECUTION_ERROR] No information given (NV-Ram not changed)"
case 0x6700:
return "[APDU_CODE_WRONG_LENGTH] Wrong length"
case 0x6982:
return "[APDU_CODE_EMPTY_BUFFER] Security condition not satisfied"
case 0x6983:
return "[APDU_CODE_OUTPUT_BUFFER_TOO_SMALL] Authentication method blocked"
case 0x6984:
return "[APDU_CODE_DATA_INVALID] Referenced data reversibly blocked (invalidated)"
case 0x6985:
return "[APDU_CODE_CONDITIONS_NOT_SATISFIED] Conditions of use not satisfied"
case 0x6986:
return "[APDU_CODE_COMMAND_NOT_ALLOWED] Command not allowed (no current EF)"
case 0x6A80:
return "[APDU_CODE_BAD_KEY_HANDLE] The parameters in the data field are incorrect"
case 0x6B00:
return "[APDU_CODE_INVALID_P1P2] Wrong parameter(s) P1-P2"
case 0x6D00:
return "[APDU_CODE_INS_NOT_SUPPORTED] Instruction code not supported or invalid"
case 0x6E00:
return "[APDU_CODE_CLA_NOT_SUPPORTED] Class not supported"
case 0x6F00:
return "APDU_CODE_UNKNOWN"
case 0x6F01:
return "APDU_CODE_SIGN_VERIFY_ERROR"
default:
return fmt.Sprintf("Error code: %04x", errorCode)
}
}

func SerializePacket(
channel uint16,
command []byte,
Expand Down
Loading