ethkey

package
v1.10.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EIP55Address

type EIP55Address string

EIP55Address is a newtype for string which persists an ethereum address in its original string representation which includes a leading 0x, and EIP55 checksum which is represented by the case of digits A-F.

func EIP55AddressFromAddress

func EIP55AddressFromAddress(a common.Address) EIP55Address

EIP55AddressFromAddress forces an address into EIP55Address format It is safe to panic on error since address.Hex() should ALWAYS generate EIP55Address-compatible hex strings

func NewEIP55Address

func NewEIP55Address(s string) (EIP55Address, error)

NewEIP55Address creates an EIP55Address from a string, an error is returned if:

1) There is no leading 0x 2) The length is wrong 3) There are any non hexadecimal characters 4) The checksum fails

func (EIP55Address) Address

func (a EIP55Address) Address() common.Address

Address returns EIP55Address as a go-ethereum Address type

func (EIP55Address) Big

func (a EIP55Address) Big() *big.Int

Big returns a big.Int representation

func (EIP55Address) Bytes

func (a EIP55Address) Bytes() []byte

Bytes returns the raw bytes

func (EIP55Address) Format

func (a EIP55Address) Format(s fmt.State, c rune)

Format implements fmt.Formatter

func (EIP55Address) Hash

func (a EIP55Address) Hash() common.Hash

Hash returns the Hash

func (EIP55Address) Hex

func (a EIP55Address) Hex() string

Hex is idential to String but makes the API similar to common.Address

func (EIP55Address) IsZero added in v1.10.17

func (a EIP55Address) IsZero() bool

IsZeroAddress determines whether the address is 0x0000... or not

func (*EIP55Address) Scan

func (a *EIP55Address) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (EIP55Address) String

func (a EIP55Address) String() string

String implements the stringer interface and is used also by the logger.

func (*EIP55Address) UnmarshalJSON

func (a *EIP55Address) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash from a JSON string

func (*EIP55Address) UnmarshalText

func (a *EIP55Address) UnmarshalText(input []byte) error

UnmarshalText parses a hash from plain text

func (EIP55Address) Value

func (a EIP55Address) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type EIP55AddressCollection

type EIP55AddressCollection []EIP55Address

EIP55AddressCollection is an array of EIP55Addresses.

func (*EIP55AddressCollection) Scan

func (c *EIP55AddressCollection) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (EIP55AddressCollection) Value

Value returns this instance serialized for database storage.

type EncryptedEthKeyExport added in v1.10.17

type EncryptedEthKeyExport struct {
	KeyType string              `json:"keyType"`
	Address EIP55Address        `json:"address"`
	Crypto  keystore.CryptoJSON `json:"crypto"`
}

type Key

type Key struct {
	ID        int32 `gorm:"primary_key"`
	Address   EIP55Address
	JSON      datatypes.JSON `json:"-"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-"`
	// This is the nonce that should be used for the next transaction.
	// Conceptually equivalent to geth's `PendingNonceAt` but more reliable
	// because we have a better view of our own transactions
	// NOTE: Be cautious about using this field, it is provided for convenience
	// only, can go out of date, and should not be relied upon. The source of
	// truth is always the database row for the key.
	NextNonce int64 `json:"-"`
	// IsFunding marks the address as being used for rescuing the  node and the pending transactions
	// Only one key can be IsFunding=true at a time.
	IsFunding bool
}

Key holds the private key metadata for a given address that is used to unlock said key when given a password.

By default, a key is assumed to represent an ethereum account.

func NewKeyFromFile

func NewKeyFromFile(path string) (Key, error)

NewKeyFromFile creates an instance in memory from a key file on disk.

func (Key) Type

func (k Key) Type() string

Type returns type of key

type KeyV2 added in v1.10.17

type KeyV2 struct {
	Address EIP55Address
	// contains filtered or unexported fields
}

func FromEncryptedJSON added in v1.10.17

func FromEncryptedJSON(keyJSON []byte, password string) (KeyV2, error)

func FromPrivateKey added in v1.10.17

func FromPrivateKey(privKey *ecdsa.PrivateKey) (key KeyV2)

func NewV2 added in v1.10.17

func NewV2() (KeyV2, error)

func (KeyV2) Cmp added in v1.10.17

func (key KeyV2) Cmp(key2 KeyV2) int

Cmp uses byte-order address comparison to give a stable comparison between two keys

func (KeyV2) GoString added in v1.10.17

func (key KeyV2) GoString() string

func (KeyV2) ID added in v1.10.17

func (key KeyV2) ID() string

func (KeyV2) Raw added in v1.10.17

func (key KeyV2) Raw() Raw

func (KeyV2) String added in v1.10.17

func (key KeyV2) String() string

func (KeyV2) ToEcdsaPrivKey added in v1.10.17

func (key KeyV2) ToEcdsaPrivKey() *ecdsa.PrivateKey

func (KeyV2) ToEncryptedJSON added in v1.10.17

func (key KeyV2) ToEncryptedJSON(password string, scryptParams utils.ScryptParams) (export []byte, err error)

type Raw added in v1.10.17

type Raw []byte

func (Raw) GoString added in v1.10.17

func (raw Raw) GoString() string

func (Raw) Key added in v1.10.17

func (raw Raw) Key() KeyV2

func (Raw) String added in v1.10.17

func (raw Raw) String() string

type State added in v1.10.17

type State struct {
	ID         int32 `gorm:"primary_key"`
	Address    EIP55Address
	NextNonce  int64
	IsFunding  bool
	EVMChainID utils.Big `gorm:"column:evm_chain_id"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
	// contains filtered or unexported fields
}

func (State) KeyID added in v1.10.17

func (s State) KeyID() string

func (State) LastUsed added in v1.10.17

func (s State) LastUsed() time.Time

lastUsed is an internal field and ought not be persisted to the database or exposed outside of the application

func (State) TableName added in v1.10.17

func (State) TableName() string

func (*State) WasUsed added in v1.10.17

func (s *State) WasUsed()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL