request

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadSignature = errors.New("bad signature")

ErrBadSignature is returned when the signature does not verify the payload.

Functions

func Sign

func Sign(privkey *ecdsa.PrivateKey, method string, pubkey string, nonce int64, args ...interface{}) (string, error)

Sign produces a base64-encoded signature from an RPC request. If the pubkey is a wallet address, then the "\x19Ethereum Signed Message:\n" prefix will be applied.

func Verify

func Verify(sig string, method string, pubkey string, nonce int64, args ...interface{}) error

Verify checks a base64-encoded signature of an RPC request. If the pubkey is a wallet address, then the "\x19Ethereum Signed Message:\n" prefix will be applied.

Types

type AddressRequest added in v0.2.3

type AddressRequest struct {
	Method    string
	Address   string // Hex-encoded (e.g. public wallet or contract address)
	Nonce     int64
	ExtraArgs []interface{}
}

AddressRequest represents the components of an RPC request signed by an Ethereum address.

func (AddressRequest) Sign added in v0.2.3

func (r AddressRequest) Sign(privkey *ecdsa.PrivateKey) (string, error)

Sign produces a hex-encoded signature of the request.

func (AddressRequest) SignedArgs added in v0.2.3

func (r AddressRequest) SignedArgs(privkey *ecdsa.PrivateKey) ([]interface{}, error)

SignedArgs returns a slice of arguments with the first element containing the signature for the remaining arguments. This is a convenient form factor for doing signed RPC calls.

func (AddressRequest) Verify added in v0.2.3

func (r AddressRequest) Verify(sig string) error

Verify validates this request against a base64-encoded signature (presumably produced by Request.Sign).

type NodeRequest added in v0.2.3

type NodeRequest struct {
	Method    string
	NodeID    string // Hex-encoded (e.g. public wallet or contract address)
	Nonce     int64
	ExtraArgs []interface{}
}

NodeRequest represents the components of an RPC request signed by an Ethereum address.

func (NodeRequest) Sign added in v0.2.3

func (r NodeRequest) Sign(privkey *ecdsa.PrivateKey) (string, error)

Sign produces a base64-encoded signature of the request.

func (NodeRequest) SignedArgs added in v0.2.3

func (r NodeRequest) SignedArgs(privkey *ecdsa.PrivateKey) ([]interface{}, error)

SignedArgs returns a slice of arguments with the first element containing the signature for the remaining arguments. This is a convenient form factor for doing signed RPC calls.

func (NodeRequest) Verify added in v0.2.3

func (r NodeRequest) Verify(sig string) error

Verify validates this request against a base64-encoded signature (presumably produced by NodeRequest.Sign).

Jump to

Keyboard shortcuts

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