Documentation
¶
Index ¶
- Constants
- Variables
- func CheckVersion(current, required VersionInfo) error
- func GetBip32bytes(path []uint32, hardenCount int) ([]byte, error)
- func NewVersionRequiredError(required, found VersionInfo) error
- type LedgerCosmos
- func (ledger *LedgerCosmos) CheckVersion(ver VersionInfo) error
- func (ledger *LedgerCosmos) Close() error
- func (ledger *LedgerCosmos) GetAddressPubKeySECP256K1(bip32Path []uint32, hrp string) ([]byte, string, error)
- func (ledger *LedgerCosmos) GetPublicKeySECP256K1(bip32Path []uint32) ([]byte, error)
- func (ledger *LedgerCosmos) GetVersion() (*VersionInfo, error)
- func (ledger *LedgerCosmos) SignSECP256K1(bip32Path []uint32, transaction []byte, signMode byte) ([]byte, error)
- type VersionInfo
- type VersionRequiredError
Constants ¶
const ( SignModeLegacyAminoJSON byte = 0 SignModeTextual byte = 1 )
Sign mode constants for SignSECP256K1
Variables ¶
var ( ErrInvalidResponse = errors.New("invalid response") ErrInvalidSignMode = errors.New("invalid sign mode: only SIGN_MODE_LEGACY_AMINO (0) and SIGN_MODE_TEXTUAL (1) are allowed") ErrHRPTooLong = errors.New("HRP length exceeds maximum allowed (83 characters)") ErrInvalidHRPCharacter = errors.New("all characters in the HRP must be in the [33, 126] range") ErrCosmosAppNotOpen = errors.New("are you sure the Cosmos app is open?") )
Error variables for common error conditions
var ErrInvalidPathLength = errors.New("BIP32 path must contain exactly 5 elements")
ErrInvalidPathLength is returned when the BIP32 path doesn't have exactly 5 elements
var MinRequiredVersion = VersionInfo{Major: 2, Minor: 1, Patch: 0}
MinRequiredVersion is the minimum version of the Cosmos app required by this library
Functions ¶
func CheckVersion ¶ added in v0.9.8
func CheckVersion(current, required VersionInfo) error
CheckVersion compares the current version with the required version. Returns nil if the current version meets or exceeds the required version.
func GetBip32bytes ¶ added in v0.9.8
GetBip32bytes serializes a BIP32/BIP44 path into bytes for the Ledger device. The path must contain exactly 5 elements. Elements at indices less than hardenCount will be hardened (have 0x80000000 added to them).
func NewVersionRequiredError ¶ added in v0.10.1
func NewVersionRequiredError(required, found VersionInfo) error
NewVersionRequiredError creates a new VersionRequiredError.
Types ¶
type LedgerCosmos ¶ added in v0.9.3
type LedgerCosmos struct {
// contains filtered or unexported fields
}
LedgerCosmos represents a connection to the Cosmos app in a Ledger device
func FindLedgerCosmosUserApp ¶ added in v0.9.3
func FindLedgerCosmosUserApp() (*LedgerCosmos, error)
FindLedgerCosmosUserApp finds and connects to a Cosmos user app running in a Ledger device. It returns an error if no device is found, the app is not open, or the version is not supported.
func (*LedgerCosmos) CheckVersion ¶ added in v0.11.1
func (ledger *LedgerCosmos) CheckVersion(ver VersionInfo) error
CheckVersion verifies that the app version meets the minimum required version.
func (*LedgerCosmos) Close ¶ added in v0.9.8
func (ledger *LedgerCosmos) Close() error
Close closes the connection with the Ledger device.
func (*LedgerCosmos) GetAddressPubKeySECP256K1 ¶ added in v0.10.0
func (ledger *LedgerCosmos) GetAddressPubKeySECP256K1(bip32Path []uint32, hrp string) ([]byte, string, error)
GetAddressPubKeySECP256K1 returns the compressed public key and bech32 address for the given BIP32 derivation path and human-readable prefix (HRP). This command requires user confirmation on the device.
func (*LedgerCosmos) GetPublicKeySECP256K1 ¶ added in v0.9.3
func (ledger *LedgerCosmos) GetPublicKeySECP256K1(bip32Path []uint32) ([]byte, error)
GetPublicKeySECP256K1 retrieves the compressed public key for the given BIP32 derivation path. This command does NOT require user confirmation on the device.
func (*LedgerCosmos) GetVersion ¶ added in v0.9.3
func (ledger *LedgerCosmos) GetVersion() (*VersionInfo, error)
GetVersion returns the current version of the Cosmos app.
func (*LedgerCosmos) SignSECP256K1 ¶ added in v0.9.3
func (ledger *LedgerCosmos) SignSECP256K1(bip32Path []uint32, transaction []byte, signMode byte) ([]byte, error)
SignSECP256K1 signs a transaction using the Cosmos app. The signMode parameter determines the signing mode:
- SignModeLegacyAminoJSON (0): SIGN_MODE_LEGACY_AMINO_JSON
- SignModeTextual (1): SIGN_MODE_TEXTUAL
This command requires user confirmation on the device.
type VersionInfo ¶
VersionInfo contains app version information.
func (VersionInfo) String ¶ added in v0.9.8
func (v VersionInfo) String() string
String returns the version as a string in the format "Major.Minor.Patch".
type VersionRequiredError ¶ added in v0.10.1
type VersionRequiredError struct {
Found VersionInfo
Required VersionInfo
}
VersionRequiredError indicates that the app version does not meet the minimum requirements.
func (*VersionRequiredError) Error ¶ added in v0.10.1
func (e *VersionRequiredError) Error() string
Error implements the error interface for VersionRequiredError.