personal

package
v0.0.0-...-c763619 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

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(ethAPI *eth.PublicEthereumAPI, log log.Logger) *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) ListAccounts

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

ListAccounts will return a list of addresses for accounts 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 rpctypes.SendTxArgs, _ 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, password 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. It exports the private key corresponding to the given address from the keyring and stores it in the API's local keys.

Jump to

Keyboard shortcuts

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