ethereum

package
v0.0.0-...-3805acb Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Size of an ECDSA ethereum signature
	SIGNATURE_SIZE_BYTES = 65
)

Variables

This section is empty.

Functions

func DecodeTxFromBytes

func DecodeTxFromBytes(b *bytes.Reader) (tx types.TxData, err error)

DecodeTxFromBytes from a string of bytes. If the stream of bytes is larger than the transaction then the remaining bytes are discarded and only the first bytes are used to decode the transaction. The function returns the transactions and the number of bytes read.

func EncodeTxForSigning

func EncodeTxForSigning(tx *types.Transaction) (encodedTx []byte)

Encode the transaction so that the hash of the encoded bytes produces exactly the transaction hash.

func GetFrom

func GetFrom(tx *ethtypes.Transaction) types.EthAddress

Returns the sender of a transaction

func GetSigner

func GetSigner(tx *types.Transaction) types.Signer

Get the signer of a transaction

func GetTxHash

func GetTxHash(tx *types.Transaction) common.Hash

Returns the transaction hash of the transaction

func RecoverPublicKey

func RecoverPublicKey(msgHash [32]byte, sig Signature) (pubKey [64]byte, encodedSig [65]byte, err error)

RecoverPublicKey returns the public key from the signature and the msg hash the signature should be "cleaned" before calling this function.

func TryCast

func TryCast[T any](into *T, from any, explainer string) error

TryCast will attempt to set t with the underlying value of `from` will return an error if the type does not match. The explainer string is used to generate the error if any.

Types

type Signature

type Signature struct {
	R string `json:"r"`
	S string `json:"s"`
	V string `json:"v"`
}

The value of a signature

func GetJsonSignature

func GetJsonSignature(tx *ethtypes.Transaction) Signature

Returns the signature in json and the sender of the transaction Signature in JSONable format and from as an hex string

Jump to

Keyboard shortcuts

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