Cleanup ledger godocs and reduce complexity
This commit is contained in:
parent
de061fa8e1
commit
1a6c4785e9
|
@ -6,9 +6,9 @@ import (
|
|||
ledger "github.com/zondax/ledger-goclient"
|
||||
)
|
||||
|
||||
// If ledger support (build tag) has been enabled, set the discoverLedger
|
||||
// function which is responsible for loading the Ledger device at runtime or
|
||||
// returning an error.
|
||||
// If ledger support (build tag) has been enabled, which implies a CGO dependency,
|
||||
// set the discoverLedger function which is responsible for loading the Ledger
|
||||
// device at runtime or returning an error.
|
||||
func init() {
|
||||
discoverLedger = func() (LedgerSECP256K1, error) {
|
||||
device, err := ledger.FindLedger()
|
||||
|
|
|
@ -49,20 +49,16 @@ type (
|
|||
// CONTRACT: The ledger device, ledgerDevice, must be loaded and set prior to
|
||||
// any creation of a PrivKeyLedgerSecp256k1.
|
||||
func NewPrivKeyLedgerSecp256k1(path DerivationPath) (tmcrypto.PrivKey, error) {
|
||||
var ledgerDevice LedgerSECP256K1
|
||||
if discoverLedger == nil {
|
||||
return nil, errors.New("no Ledger discovery function defined")
|
||||
}
|
||||
|
||||
if discoverLedger != nil {
|
||||
device, err := discoverLedger()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to create PrivKeyLedgerSecp256k1")
|
||||
}
|
||||
|
||||
ledgerDevice = device
|
||||
} else {
|
||||
return nil, errors.New("no Ledger discovery function defined")
|
||||
}
|
||||
|
||||
pkl := &PrivKeyLedgerSecp256k1{Path: path, ledger: ledgerDevice}
|
||||
pkl := &PrivKeyLedgerSecp256k1{Path: path, ledger: device}
|
||||
|
||||
pubKey, err := pkl.getPubKey()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue