personal

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.

The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateAccountAPI

type PrivateAccountAPI struct {
	// contains filtered or unexported fields
}

PrivateAccountAPI is the personal_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewAPI

func NewAPI(
	logger log.Logger,
	backend backend.EVMBackend,
) *PrivateAccountAPI

NewAPI creates an instance of the public Personal Eth API.

func (*PrivateAccountAPI) EcRecover

func (api *PrivateAccountAPI) EcRecover(_ context.Context, data, sig hexutil.Bytes) (common.Address, error)

EcRecover returns the address for the account that was used to create the signature. Note, this function is compatible with eth_sign and personal_sign. As such it recovers the address of: hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) addr = ecrecover(hash, signature)

Note, the signature must conform to the secp256k1 curve R, S and V values, where the V value must be 27 or 28 for legacy reasons.

https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecove

func (*PrivateAccountAPI) ImportRawKey

func (api *PrivateAccountAPI) ImportRawKey(privkey, password string) (common.Address, error)

ImportRawKey armors and encrypts a given raw hex encoded ECDSA key and stores it into the key directory. The name of the key will have the format "personal_<length-keys>", where <length-keys> is the total number of keys stored on the keyring.

NOTE: The key will be both armored and encrypted using the same passphrase.

func (*PrivateAccountAPI) InitializeWallet

func (api *PrivateAccountAPI) InitializeWallet(_ context.Context, url string) (string, error)

InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key.

func (*PrivateAccountAPI) ListAccounts

func (api *PrivateAccountAPI) ListAccounts() ([]common.Address, error)

ListAccounts will return a list of addresses for accounts this node manages.

func (*PrivateAccountAPI) ListWallets

func (api *PrivateAccountAPI) ListWallets() []RawWallet

ListWallets will return a list of wallets this node manages.

func (*PrivateAccountAPI) LockAccount

func (api *PrivateAccountAPI) LockAccount(address common.Address) bool

LockAccount will lock the account associated with the given address when it's unlocked. It removes the key corresponding to the given address from the API's local keys.

func (*PrivateAccountAPI) NewAccount

func (api *PrivateAccountAPI) NewAccount(password string) (common.Address, error)

NewAccount will create a new account and returns the address for the new account.

func (*PrivateAccountAPI) SendTransaction

func (api *PrivateAccountAPI) SendTransaction(_ context.Context, args evmtypes.TransactionArgs, _ string) (common.Hash, error)

SendTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.To. If the given password isn't able to decrypt the key it fails.

func (*PrivateAccountAPI) Sign

Sign calculates an Ethereum ECDSA signature for: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))

Note, the produced signature conforms to the secp256k1 curve R, S and V values, where the V value will be 27 or 28 for legacy reasons.

The key used to calculate the signature is decrypted with the given password.

https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign

func (*PrivateAccountAPI) UnlockAccount

func (api *PrivateAccountAPI) UnlockAccount(_ context.Context, addr common.Address, _ string, _ *uint64) (bool, error)

UnlockAccount will unlock the account associated with the given address with the given password for duration seconds. If duration is nil it will use a default of 300 seconds. It returns an indication if the account was unlocked.

func (*PrivateAccountAPI) Unpair

func (api *PrivateAccountAPI) Unpair(_ context.Context, url, pin string) error

Unpair deletes a pairing between wallet and ethermint.

type RawWallet

type RawWallet struct {
	URL      string             `json:"url"`
	Status   string             `json:"status"`
	Failure  string             `json:"failure,omitempty"`
	Accounts []accounts.Account `json:"accounts,omitempty"`
}

RawWallet is a JSON representation of an accounts.Wallet interface, with its data contents extracted into plain fields.

Jump to

Keyboard shortcuts

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