Documentation ¶
Overview ¶
Package ledger contains the internals for package crypto/keys/ledger, primarily existing so that the Discover function can be mocked elsewhere.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiscoverFn ¶
DiscoverFn defines a Ledger discovery function that returns a connected device or an error upon failure. Its allows a method to avoid CGO dependencies when Ledger support is potentially not enabled.
var Discover DiscoverFn = DiscoverDefault
Discover defines a function to be invoked at runtime for discovering a connected Ledger device.
type MockLedger ¶
type MockLedger struct{}
MockLedger is an interface that can be used to create mock [Ledger]. Embed it in another type, and implement the method you want to mock:
type MyMock struct { MockLedger } func (MyMock) SignSECP256K1(d1, d2 []byte, d3 byte) ([]byte, error) { ... }
func (MockLedger) Close ¶
func (MockLedger) Close() error
func (MockLedger) GetAddressPubKeySECP256K1 ¶
func (MockLedger) GetPublicKeySECP256K1 ¶
func (MockLedger) GetPublicKeySECP256K1(data []uint32) ([]byte, error)
func (MockLedger) SignSECP256K1 ¶
type SECP256K1 ¶
type SECP256K1 interface { Close() error // Returns an uncompressed pubkey GetPublicKeySECP256K1([]uint32) ([]byte, error) // Returns a compressed pubkey and bech32 address (requires user confirmation) GetAddressPubKeySECP256K1([]uint32, string) ([]byte, string, error) // Signs a message (requires user confirmation) SignSECP256K1([]uint32, []byte, byte) ([]byte, error) }
SECP256K1 reflects an interface a Ledger API must implement for SECP256K1
func DiscoverDefault ¶
DiscoverDefault is the default function for Discover.
func DiscoverMock ¶
DiscoverMock can be used as a mock DiscoverFn.