util

package
v0.0.0-...-4467ad0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPLimitedGet

func HTTPLimitedGet(url string, maxSize int64) ([]byte, error)

Performs an HTTP GET request and returns the response body, limited to the specified maximum size. If the response body exceeds the maximum size, an error is returned. If the maximum size is 0 or greater than maxHTTPBodySize, maxHTTPBodySize is used instead.

func RecoverAddressFromSignature

func RecoverAddressFromSignature(msg []byte, sig []byte) (*common.Address, error)

Recovers the address of the signer from a message and signature. Expects a signature in the format returned by eth_sign: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign This is the format currently used to sign messages by the Rocket Pool smartnode stack: https://github.com/rocket-pool/smartnode/blob/9ded8d070bdd81798813e16b53657f600bab781e/shared/services/wallet/wallet.go#L305

Types

type Wallet

type Wallet struct {
	Address *common.Address
	Key     *ecdsa.PrivateKey
}

func NewWallet

func NewWallet() (*Wallet, error)

Generates a new wallet with a random private key.

func (*Wallet) Sign

func (w *Wallet) Sign(msg []byte) ([]byte, error)

Signs a message with the wallet's private key. Return a signature in the format used by eth_sign. See RecoverAddressFromSignature() for more details.

Jump to

Keyboard shortcuts

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