Documentation
¶
Index ¶
- Constants
- func AddressFromKey(kr keyring.Keyring, keyName, hrp string) (string, error)
- func Bech32ToEVM(bech32Addr string) (common.Address, error)
- func EVMAddressFromKey(kr keyring.Keyring, keyName string) (string, error)
- func EVMToBech32(addr common.Address, hrp string) (string, error)
- func GetKey(kr keyring.Keyring, keyName string) (*keyring.Record, error)
- func ImportKey(kr keyring.Keyring, keyName, mnemonicFile, hrp string, keyType KeyType) ([]byte, string, error)
- func LoadKeyring(keyName, mnemonicFile string, keyType KeyType) (keyring.Keyring, []byte, string, error)
- func NewDefaultTxConfig() client.TxConfig
- func NewKeyring(p KeyringParams) (keyring.Keyring, error)
- func RecoverSender(signed *ethtypes.Transaction) (common.Address, error)
- func SignEthereumTx(kr keyring.Keyring, keyName string, chainID *big.Int, tx *ethtypes.Transaction) (*ethtypes.Transaction, error)
- func SignTxWithKeyring(ctx context.Context, txCfg client.TxConfig, kr keyring.Keyring, keyName string, ...) error
- func ULume(alume *big.Int) (ulume sdkmath.Int, fractional *big.Int)
- func ULumeDecToWei(ulume sdkmath.LegacyDec) (*big.Int, error)
- func Wei(ulume sdkmath.Int) *big.Int
- func WrapAsMsgEthereumTx(signed *ethtypes.Transaction) (*evmtypes.MsgEthereumTx, error)
- type KeyType
- type KeyringParams
Constants ¶
const (
// EVMBIP44HDPath is the default Ethereum derivation path (coin type 60).
EVMBIP44HDPath = "m/44'/60'/0'/0/0"
)
Variables ¶
This section is empty.
Functions ¶
func AddressFromKey ¶
AddressFromKey derives an account address for the given HRP from the public key stored in the keyring under keyName, without mutating the global bech32 prefix configuration.
func Bech32ToEVM ¶ added in v1.2.0
Bech32ToEVM decodes a bech32 account address and reinterprets those 20 bytes as an EVM address. This is only a byte-level conversion: for legacy Cosmos secp256k1 accounts, the result is not the key's Ethereum address. Callers that care must validate against a keyring entry, on-chain account metadata, or an evmigration record.
func EVMAddressFromKey ¶ added in v1.2.0
EVMAddressFromKey derives the EIP-55 0x-prefixed hex address for the key stored in the keyring under keyName. The key must use the eth_secp256k1 signing algorithm; for cosmos secp256k1 keys an error is returned.
func EVMToBech32 ¶ added in v1.2.0
EVMToBech32 converts a 20-byte EVM address to the bech32 form used by the Cosmos bank/auth modules for the same account.
func ImportKey ¶ added in v1.0.9
func ImportKey(kr keyring.Keyring, keyName, mnemonicFile, hrp string, keyType KeyType) ([]byte, string, error)
ImportKey imports a mnemonic into an existing keyring using the specified key type, returning the pubkey bytes and address for the provided HRP.
If a key with the same name already exists, ImportKey verifies that its algorithm matches the requested keyType and returns an error on mismatch.
func LoadKeyring ¶ added in v1.0.9
func LoadKeyring(keyName, mnemonicFile string, keyType KeyType) (keyring.Keyring, []byte, string, error)
LoadKeyring creates a test keyring in a temporary directory under os.TempDir(), imports the mnemonic using the specified key type, and returns the keyring, pubkey bytes, and Lumera address.
The temporary directory is cleaned up by the OS on reboot. For production use, prefer NewKeyring with an explicit directory and import keys via kr.NewAccount directly.
func NewDefaultTxConfig ¶
NewDefaultTxConfig constructs a client.TxConfig backed by a protobuf codec, registering Lumera action message interfaces as required for signing/encoding.
func NewKeyring ¶
func NewKeyring(p KeyringParams) (keyring.Keyring, error)
NewKeyring creates a new keyring that supports both Cosmos (secp256k1) and EVM (eth_secp256k1) key types. The key type used is determined when importing or creating keys, not at keyring creation time.
func RecoverSender ¶ added in v1.2.0
func RecoverSender(signed *ethtypes.Transaction) (common.Address, error)
RecoverSender returns the EVM address recovered from the signature of a signed go-ethereum tx. Useful for verifying that the keyring key produced the expected sender.
func SignEthereumTx ¶ added in v1.2.0
func SignEthereumTx( kr keyring.Keyring, keyName string, chainID *big.Int, tx *ethtypes.Transaction, ) (*ethtypes.Transaction, error)
SignEthereumTx signs a go-ethereum *types.Transaction with the named keyring entry (which must be an eth_secp256k1 key) using the latest replay-protected signer for chainID. Returns the signed transaction.
func SignTxWithKeyring ¶
func SignTxWithKeyring( ctx context.Context, txCfg client.TxConfig, kr keyring.Keyring, keyName string, builder client.TxBuilder, chainID string, accountNumber uint64, sequence uint64, overwrite bool, ) error
SignTxWithKeyring signs the provided TxBuilder using the given keyring identity. The caller must supply chainID, account number and sequence. Set overwrite=false for the first signature; true for subsequent signers on the same tx.
func ULume ¶ added in v1.2.0
ULume converts an alume amount to ulume, truncating any sub-ulume fractional component. The dropped fractional remainder is returned so callers can surface precision loss.
func ULumeDecToWei ¶ added in v1.2.0
ULumeDecToWei converts a decimal ulume value (such as feemarket BaseFee or MinGasPrice in ulume/gas) into the integer alume/gas representation used by EIP-1559 fee fields. It errors if the conversion would lose precision (i.e. the value has more than 12 decimal places).
func Wei ¶ added in v1.2.0
Wei converts an integer ulume amount to its 18-decimal alume (wei-like) form using the 10^12 conversion factor defined by x/precisebank.
func WrapAsMsgEthereumTx ¶ added in v1.2.0
func WrapAsMsgEthereumTx(signed *ethtypes.Transaction) (*evmtypes.MsgEthereumTx, error)
WrapAsMsgEthereumTx packages a signed go-ethereum tx as a cosmos MsgEthereumTx ready for MsgEthereumTx.BuildTxWithEvmParams and broadcast.
Types ¶
type KeyType ¶ added in v1.0.9
type KeyType int
KeyType represents the cryptographic key algorithm and HD derivation path to use for a chain. Controller and host chains can each be configured with an independent KeyType.
func (KeyType) HDPath ¶ added in v1.0.9
HDPath returns the BIP44 HD derivation path for this key type.
func (KeyType) SigningAlgo ¶ added in v1.0.9
func (kt KeyType) SigningAlgo() keyring.SignatureAlgo
SigningAlgo returns the keyring signing algorithm for this key type.
type KeyringParams ¶
type KeyringParams struct {
// AppName names the keyring namespace. Default: "lumera"
AppName string
// Backend selects the keyring backend ("os" | "file" | "test"). Default: "os"
Backend string
// Dir is the root directory for the keyring (if Backend="file"). Default: $HOME/.lumera
Dir string
// Input is an optional io.Reader for interactive backends (nil for non-interactive)
Input io.Reader
}
KeyringParams holds configuration for initializing a Cosmos keyring.
func DefaultKeyringParams ¶
func DefaultKeyringParams() KeyringParams
DefaultKeyringParams returns sensible defaults:
- AppName: "lumera"
- Backend: "os"
- Dir: $HOME/.lumera