Documentation ¶
Index ¶
- Variables
- func ChainId(tx *types.Transaction) *big.Int
- func CopyBytes(b []byte) (copiedBytes []byte)
- func DefaultTestKey() (*ecdsa.PrivateKey, common.Address)
- func EncodeRLP(tx *types.Transaction, w io.Writer) error
- func EncodeToRLP(tx *types.Transaction) ([]byte, error)
- func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, ...) *types.Transaction
- func Protected(tx *types.Transaction) bool
- func Sender(signer Signer, tx *types.Transaction) (common.Address, error)
- func SignTx(tx *types.Transaction, s Signer, prv *ecdsa.PrivateKey) (*types.Transaction, error)
- func TypeConvert(a *common.Address) *types.Address
- func WithSignature(tx *types.Transaction, signer Signer, sig []byte) (*types.Transaction, error)
- type EIP155Signer
- type FrontierSigner
- type HomesteadSigner
- type Signer
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidChainId = errors.New("invalid chain id for signer") ErrInvalidSig = errors.New("invalid transaction v, r, s values") )
Functions ¶
func DefaultTestKey ¶
func DefaultTestKey() (*ecdsa.PrivateKey, common.Address)
-------------------------- FIXME(peerlink): default key for Test
func EncodeRLP ¶
func EncodeRLP(tx *types.Transaction, w io.Writer) error
EncodeRLP implements rlp.Encoder
func EncodeToRLP ¶
func EncodeToRLP(tx *types.Transaction) ([]byte, error)
EncodeToBytes returns the RLP encoding of val.
func NewTransaction ¶
func Protected ¶
func Protected(tx *types.Transaction) bool
func Sender ¶
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 SignTx ¶
func SignTx(tx *types.Transaction, s Signer, prv *ecdsa.PrivateKey) (*types.Transaction, error)
SignTx signs the transaction using the given signer and private key
func WithSignature ¶
func WithSignature(tx *types.Transaction, signer Signer, sig []byte) (*types.Transaction, error)
WithSignature returns a new transaction with the given signature. This signature needs to be formatted as described in the yellow paper (v+27).
Types ¶
type EIP155Signer ¶
type EIP155Signer struct {
// contains filtered or unexported fields
}
EIP155Transaction implements Signer using the EIP155 rules.
func NewEIP155Signer ¶
func NewEIP155Signer(chainId *big.Int) EIP155Signer
func (EIP155Signer) Equal ¶
func (s EIP155Signer) Equal(s2 Signer) bool
func (EIP155Signer) Hash ¶
func (s EIP155Signer) Hash(tx *types.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 *types.Transaction) (common.Address, error)
func (EIP155Signer) SignatureValues ¶
func (s EIP155Signer) SignatureValues(tx *types.Transaction, sig []byte) (R, S, V *big.Int, err 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.
type FrontierSigner ¶
type FrontierSigner struct{}
func (FrontierSigner) Equal ¶
func (s FrontierSigner) Equal(s2 Signer) bool
func (FrontierSigner) Hash ¶
func (fs FrontierSigner) Hash(tx *types.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 *types.Transaction) (common.Address, error)
func (FrontierSigner) SignatureValues ¶
func (fs FrontierSigner) SignatureValues(tx *types.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 }
HomesteadTransaction implements TransactionInterface using the homestead rules.
func (HomesteadSigner) Equal ¶
func (s HomesteadSigner) Equal(s2 Signer) bool
func (HomesteadSigner) Sender ¶
func (hs HomesteadSigner) Sender(tx *types.Transaction) (common.Address, error)
func (HomesteadSigner) SignatureValues ¶
func (hs HomesteadSigner) SignatureValues(tx *types.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 Signer ¶
type Signer interface { // Sender returns the sender address of the transaction. Sender(tx *types.Transaction) (common.Address, error) // SignatureValues returns the raw R, S, V values corresponding to the // given signature. SignatureValues(tx *types.Transaction, sig []byte) (r, s, v *big.Int, err error) // Hash returns the hash to be signed. Hash(tx *types.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.
func MakeSigner ¶
func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer
MakeSigner returns a Signer based on the given chain config and block number.