Documentation ¶
Index ¶
- type PrivateAccountAPI
- func (api *PrivateAccountAPI) EcRecover(_ context.Context, data, sig hexutil.Bytes) (common.Address, error)
- func (api *PrivateAccountAPI) ImportRawKey(privkey, password string) (common.Address, error)
- func (api *PrivateAccountAPI) ListAccounts() ([]common.Address, error)
- func (api *PrivateAccountAPI) LockAccount(address common.Address) bool
- func (api *PrivateAccountAPI) NewAccount(password string) (common.Address, error)
- func (api *PrivateAccountAPI) SendTransaction(_ context.Context, args rpctypes.SendTxArgs, pwrd string) (common.Hash, error)
- func (api *PrivateAccountAPI) Sign(_ context.Context, data hexutil.Bytes, addr common.Address, pwrd string) (hexutil.Bytes, error)
- func (api *PrivateAccountAPI) UnlockAccount(_ context.Context, addr common.Address, _ string, _ *uint64) (bool, error)
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, clientCtx client.Context, backend backend.Backend) *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, pwrd 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 ¶
func (api *PrivateAccountAPI) Sign(_ context.Context, data hexutil.Bytes, addr common.Address, pwrd string) (hexutil.Bytes, error)
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.