Documentation ¶
Index ¶
- func AddHexPrefix(hex string) string
- func ConvertPrivateKey(key string) (privateKey *ecdsa.PrivateKey, err error)
- func ConvertToBigEndian(hex string) (string, error)
- func CreateHTTPRPCRequest(url string, method string, args ...string) (*http.Request, error)
- func CreateJSONRequest(method string, paramsStr ...string) ([]byte, error)
- func DecodeBig(input string) (*big.Int, error)
- func DecodeRawTx(rawtx string) (*types.Transaction, error)
- func EncodeBig(input *big.Int) string
- func GetAddressFromPrivKey(privateKey *ecdsa.PrivateKey) (address common.Address, err error)
- func GetFromAddress(tx *types.Transaction) (*common.Address, error)
- func GetSignatureAndSigner(tx *types.Transaction) (signature []byte, signer types.Signer)
- func HexStringToBytes32(dataStr string) ([]byte, error)
- func IsValidHexAddress(iaddress interface{}) bool
- func IsValidHexPrivKey(privKey string) bool
- func IsValidWeiAmount(weiAmount string) bool
- func NewEthereumTx() *types.Transaction
- func PrivToPubKey(privKeyHex string) (string, error)
- func PubKeyToAddress(pubKeyHex string) (string, error)
- func ReadJSONResult(resp *http.Response, result interface{}) error
- func RemoveHexPrefix(hex string) string
- func SignEthereumTx(tx *types.Transaction, signer types.Signer, privKeyHex string) (*types.Transaction, error)
- func VerifyTxSignature(tx *types.Transaction, pubKeyHex string) bool
- type JSONRPCError
- type JSONRPCRequest
- type JSONRPCResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHexPrefix ¶
func ConvertPrivateKey ¶
func ConvertPrivateKey(key string) (privateKey *ecdsa.PrivateKey, err error)
ConvertPrivateKey() converts a private key (hex) string to an ecdsa.PrivateKey
func ConvertToBigEndian ¶
Converts a hex string (without 0x prefix) to a hex string in Big Endian format
func CreateHTTPRPCRequest ¶
CreateHTTPRPCRequest is a helper function to create a new JSON RPC http request with the given method and arguments.
func CreateJSONRequest ¶
CreateJSONRequest creates a JSON RPC request with the given method and params and returns the JSON encoded request as a byte array.
func DecodeRawTx ¶
func DecodeRawTx(rawtx string) (*types.Transaction, error)
DecodeRawTX decodes a raw ethereum RLP encoded transaction and returns a go-ethereum types.Transaction
func GetAddressFromPrivKey ¶
func GetAddressFromPrivKey(privateKey *ecdsa.PrivateKey) (address common.Address, err error)
GetAddressFromPrivKey() returns the ethereum common.Address from a ecdsa.PrivateKey
func GetFromAddress ¶
func GetFromAddress(tx *types.Transaction) (*common.Address, error)
GetFromAddress extracts the signer address from the public key of a signed ethereum transaction
func GetSignatureAndSigner ¶
func GetSignatureAndSigner(tx *types.Transaction) (signature []byte, signer types.Signer)
GetSignatureAndSigner returns the signature and signer from a signed ethereum transaction
func HexStringToBytes32 ¶
HexStringToBytes32 converts a hex string to a byte array of length 32.
If input string is not 64 characters long returns an error.
Used to convert 256 bits keys and addresses to byte array.
func IsValidHexAddress ¶
func IsValidHexAddress(iaddress interface{}) bool
IsValidHexAddress checks if the given address is a valid ethereum hex address.
func IsValidHexPrivKey ¶
IsValidHexPrivKey checks if the given private key is a valid hex ecdsa private key.
func IsValidWeiAmount ¶
IsValidWeiAmount() checks if a string represents a valid wei amount.
func NewEthereumTx ¶
func NewEthereumTx() *types.Transaction
NewEthereumTx() creates a new unsigned ethereum transaction with default parameters.
func PrivToPubKey ¶
PrivToPubKey converts a ECDSA private key to a Ethereum public key.
func PubKeyToAddress ¶
PubKeyToAddress converts a public key to an Ethereum address.
func ReadJSONResult ¶
ReadJSONResult reads the JSON response from the given http response and unmarshals the result into the given result interface.
func RemoveHexPrefix ¶
func SignEthereumTx ¶
func SignEthereumTx(tx *types.Transaction, signer types.Signer, privKeyHex string) (*types.Transaction, error)
SignEthereumTx() signs an ethereum transaction with a private key.
Params: - tx: the unsigned transaction types.Transaction - signer: the signer types.Signer - privKeyHex: the private key hex string of the signer
func VerifyTxSignature ¶
func VerifyTxSignature(tx *types.Transaction, pubKeyHex string) bool
VerifyTxSignature() verifies the signature of a signed ethereum transaction against a public key.
Params: - tx: the signed transaction types.Transaction - pubKeyHex: the public key hex string of the signer
Types ¶
type JSONRPCError ¶
type JSONRPCError struct { JSONRPC string `json:"jsonrpc"` Code int `json:"code"` Message string `json:"message"` // Data string `json:"data"` Data json.RawMessage `json:"data"` ID int `json:"id"` }
http://www.jsonrpc.org/specification#error_object
func NewJSONRPCResponseError ¶
func NewJSONRPCResponseError(id, code int, message string, data json.RawMessage) *JSONRPCError
type JSONRPCRequest ¶
type JSONRPCRequest struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` // Params []interface{} `json:"params"` Params []json.RawMessage `json:"params"` ID int `json:"id"` }
http://www.jsonrpc.org/specification#request_object
func NewJSONRPCRequest ¶
func NewJSONRPCRequest(id int, method string, params []json.RawMessage) *JSONRPCRequest
type JSONRPCResponse ¶
type JSONRPCResponse struct { JSONRPC string `json:"jsonrpc"` Result json.RawMessage `json:"result"` // Error string `json:"error"` Error *JSONRPCError `json:"error"` ID int `json:"id"` }
http://www.jsonrpc.org/specification#response_object
func NewJSONRPCResponse ¶
func NewJSONRPCResponse(id int, result json.RawMessage, err *JSONRPCError) *JSONRPCResponse