Documentation ¶
Index ¶
- Variables
- func Sender(signer Signer, tx *Transaction) (common.Address, error)
- func ToBlockNumArg(number *big.Int) string
- func ToFilterArg(q *FilterQuery) (interface{}, error)
- type EIP155Signer
- type FilterQuery
- type FrontierSigner
- type HomesteadSigner
- type RPCBlock
- type RPCLog
- type RPCTransaction
- type RPCTxAndReceipt
- type RPCTxReceipt
- type Signer
- type StorageSize
- type Transaction
- func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction
- func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, ...) *Transaction
- func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
- func (tx *Transaction) ChainID() *big.Int
- func (tx *Transaction) CheckNonce() bool
- func (tx *Transaction) Cost() *big.Int
- func (tx *Transaction) Data() []byte
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) Gas() uint64
- func (tx *Transaction) GasPrice() *big.Int
- func (tx *Transaction) Hash() common.Hash
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) PrintPretty()
- func (tx *Transaction) PrintRaw()
- func (tx *Transaction) Protected() bool
- func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int)
- func (tx *Transaction) RawStr() string
- func (tx *Transaction) Size() StorageSize
- func (tx *Transaction) To() *common.Address
- func (tx *Transaction) UnmarshalJSON(input []byte) error
- func (tx *Transaction) Value() *big.Int
- func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidChainID = errors.New("invalid chain id for signer") ErrInvalidSig = errors.New("invalid transaction v, r, s values") )
sign tx errors
Functions ¶
func Sender ¶
func Sender(signer Signer, tx *Transaction) (common.Address, error)
Sender returns the address derived from the signature (V, R, S) using secp256k1 elliptic curve and an error if it failed deriving or upon an incorrect signature.
Sender may cache the address, allowing it to be used regardless of signing method. The cache is invalidated if the cached signer does not match the signer used in the current call.
func ToFilterArg ¶
func ToFilterArg(q *FilterQuery) (interface{}, error)
ToFilterArg query to filter arg
Types ¶
type EIP155Signer ¶
type EIP155Signer struct {
// contains filtered or unexported fields
}
EIP155Signer implements Signer using the EIP155 rules.
func NewEIP155Signer ¶
func NewEIP155Signer(chainID *big.Int) EIP155Signer
NewEIP155Signer new EIP155Signer
func (EIP155Signer) Hash ¶
func (s EIP155Signer) Hash(tx *Transaction) common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (EIP155Signer) Sender ¶
func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error)
Sender get sender
func (EIP155Signer) SignatureValues ¶
func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (rsvR, rsvS, rsvV *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type FilterQuery ¶
type FilterQuery struct { BlockHash *common.Hash FromBlock *big.Int ToBlock *big.Int Addresses []common.Address Topics [][]common.Hash }
FilterQuery struct
type FrontierSigner ¶
type FrontierSigner struct{}
FrontierSigner frontier signer
func (FrontierSigner) Hash ¶
func (fs FrontierSigner) Hash(tx *Transaction) common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (FrontierSigner) Sender ¶
func (fs FrontierSigner) Sender(tx *Transaction) (common.Address, error)
Sender get sender
func (FrontierSigner) SignatureValues ¶
func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type HomesteadSigner ¶
type HomesteadSigner struct{ FrontierSigner }
HomesteadSigner implements TransactionInterface using the homestead rules.
func (HomesteadSigner) Sender ¶
func (hs HomesteadSigner) Sender(tx *Transaction) (common.Address, error)
Sender get sender
func (HomesteadSigner) SignatureValues ¶
func (hs HomesteadSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type RPCBlock ¶
type RPCBlock struct { Hash *common.Hash `json:"hash"` ParentHash *common.Hash `json:"parentHash"` UncleHash *common.Hash `json:"sha3Uncles"` Coinbase *common.Address `json:"miner"` Root *common.Hash `json:"stateRoot"` TxHash *common.Hash `json:"transactionsRoot"` ReceiptHash *common.Hash `json:"receiptsRoot"` Bloom *hexutil.Bytes `json:"logsBloom"` Difficulty *hexutil.Big `json:"difficulty"` Number *hexutil.Big `json:"number"` GasLimit *hexutil.Uint64 `json:"gasLimit"` GasUsed *hexutil.Uint64 `json:"gasUsed"` Time *hexutil.Big `json:"timestamp"` Extra *hexutil.Bytes `json:"extraData"` MixDigest *common.Hash `json:"mixHash"` Nonce *hexutil.Bytes `json:"nonce"` Size interface{} `json:"size"` TotalDifficulty *hexutil.Big `json:"totalDifficulty"` Transactions []*common.Hash `json:"transactions"` Uncles []*common.Hash `json:"uncles"` }
RPCBlock struct
type RPCLog ¶
type RPCLog struct { Address *common.Address `json:"address"` Topics []common.Hash `json:"topics"` Data *hexutil.Bytes `json:"data"` BlockNumber *hexutil.Uint64 `json:"blockNumber"` TxHash *common.Hash `json:"transactionHash"` TxIndex *hexutil.Uint `json:"transactionIndex"` BlockHash *common.Hash `json:"blockHash"` Index *hexutil.Uint `json:"logIndex"` Removed *bool `json:"removed"` }
RPCLog struct
type RPCTransaction ¶
type RPCTransaction struct { Hash *common.Hash `json:"hash"` TransactionIndex *hexutil.Uint `json:"transactionIndex"` BlockNumber *hexutil.Big `json:"blockNumber,omitempty"` BlockHash *common.Hash `json:"blockHash,omitempty"` From *common.Address `json:"from,omitempty"` AccountNonce *hexutil.Uint64 `json:"nonce"` Price *hexutil.Big `json:"gasPrice"` GasLimit *hexutil.Uint64 `json:"gas"` Recipient *common.Address `json:"to"` Amount *hexutil.Big `json:"value"` Payload *hexutil.Bytes `json:"input"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` }
RPCTransaction struct
type RPCTxAndReceipt ¶
type RPCTxAndReceipt struct { FsnTxInput interface{} `json:"fsnTxInput,omitempty"` Tx *RPCTransaction `json:"tx"` Receipt *RPCTxReceipt `json:"receipt"` ReceiptFound *bool `json:"receiptFound"` }
RPCTxAndReceipt struct
type RPCTxReceipt ¶
type RPCTxReceipt struct { TxHash *common.Hash `json:"transactionHash"` TxIndex *hexutil.Uint `json:"transactionIndex"` BlockNumber *hexutil.Big `json:"blockNumber"` BlockHash *common.Hash `json:"blockHash"` PostState *hexutil.Bytes `json:"root"` Status *hexutil.Uint64 `json:"status"` From *common.Address `json:"from"` Recipient *common.Address `json:"to"` GasUsed *hexutil.Uint64 `json:"gasUsed"` CumulativeGasUsed *hexutil.Uint64 `json:"cumulativeGasUsed"` ContractAddress *common.Address `json:"contractAddress,omitempty"` Bloom *hexutil.Bytes `json:"logsBloom"` FsnLogTopic *string `json:"fsnLogTopic,omitempty"` FsnLogData interface{} `json:"fsnLogData,omitempty"` Logs []*RPCLog `json:"logs"` }
RPCTxReceipt struct
type Signer ¶
type Signer interface { // Sender returns the sender address of the transaction. Sender(tx *Transaction) (common.Address, error) // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) // Hash returns the hash to be signed. Hash(tx *Transaction) common.Hash // Equal returns true if the given signer is the same as the receiver. Equal(Signer) bool }
Signer encapsulates transaction signature handling. Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction struct
func NewContractCreation ¶
func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction
NewContractCreation new contract creation
func NewTransaction ¶
func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction
NewTransaction new tx
func SignTx ¶
func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
SignTx signs the transaction using the given signer and private key
func (*Transaction) ChainID ¶
func (tx *Transaction) ChainID() *big.Int
ChainID returns which chain id this transaction was signed for (if at all)
func (*Transaction) Cost ¶
func (tx *Transaction) Cost() *big.Int
Cost returns amount + gasprice * gaslimit.
func (*Transaction) DecodeRLP ¶
func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*Transaction) EncodeRLP ¶
func (tx *Transaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() common.Hash
Hash hashes the RLP encoding of tx. It uniquely identifies the transaction.
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON encodes the web3 RPC transaction format.
func (*Transaction) PrintPretty ¶
func (tx *Transaction) PrintPretty()
PrintPretty print pretty (json)
func (*Transaction) PrintRaw ¶
func (tx *Transaction) PrintRaw()
PrintRaw print raw encoded (hex string)
func (*Transaction) Protected ¶
func (tx *Transaction) Protected() bool
Protected returns whether the transaction is protected from replay protection.
func (*Transaction) RawSignatureValues ¶
func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int)
RawSignatureValues returns the V, R, S signature values of the transaction. The return values should not be modified by the caller.
func (*Transaction) RawStr ¶
func (tx *Transaction) RawStr() string
RawStr return raw encoded (hex string)
func (*Transaction) Size ¶
func (tx *Transaction) Size() StorageSize
Size returns the true RLP encoded storage size of the transaction, either by encoding and returning it, or returning a previsouly cached value.
func (*Transaction) To ¶
func (tx *Transaction) To() *common.Address
To returns the recipient address of the transaction. It returns nil if the transaction is a contract creation.
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(input []byte) error
UnmarshalJSON decodes the web3 RPC transaction format.
func (*Transaction) WithSignature ¶
func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)
WithSignature returns a new transaction with the given signature. This signature needs to be in the [R || S || V] format where V is 0 or 1.