account

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: GPL-3.0 Imports: 4 Imported by: 6

Documentation

Overview

Package account defines the Account API. All chains that use an account-based model should implement this API. The Account API is used to send and confirm transactions between addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// AccountBalance returns the current balance of the given account.
	AccountBalance(context.Context, address.Address) (pack.U256, error)

	// AccountNonce is the current nonce of this account, which must be used to
	// build a new transaction.
	AccountNonce(context.Context, address.Address) (pack.U256, error)

	// Tx returns the transaction uniquely identified by the given transaction
	// hash. It also returns the number of confirmations for the transaction. If
	// the transaction cannot be found before the context is done, or the
	// transaction is invalid, then an error should be returned.
	Tx(context.Context, pack.Bytes) (Tx, pack.U64, error)

	// SubmitTx to the underlying chain. If the transaction cannot be found
	// before the context is done, or the transaction is invalid, then an error
	// should be returned.
	SubmitTx(context.Context, Tx) error
}

The Client interface defines the functionality required to interact with a chain over RPC.

type Tx

type Tx interface {
	// Hash that uniquely identifies the transaction. Hashes are usually the
	// result of an irreversible hashing function applied to some serialized
	// representation of the transaction.
	Hash() pack.Bytes

	// From returns the address from which value is being sent.
	From() address.Address

	// To returns the address to which value is being sent.
	To() address.Address

	// Value being sent from one address to another.
	Value() pack.U256

	// Nonce used to order the transaction with respect to all other
	// transactions signed and submitted by the sender of this transaction.
	Nonce() pack.U256

	// Payload returns arbitrary data that is associated with the transaction.
	// This payload is often used to send notes between external accounts, or
	// call functions on a contract.
	Payload() contract.CallData

	// Sighashes that must be signed before the transaction can be submitted by
	// the client.
	Sighashes() ([]pack.Bytes32, error)

	// Sign the transaction by injecting signatures for the required sighashes.
	// The serialized public key used to sign the sighashes should also be
	// specified whenever it is available.
	Sign([]pack.Bytes65, pack.Bytes) error

	// Serialize the transaction into bytes. This is the format in which the
	// transaction will be submitted by the client.
	Serialize() (pack.Bytes, error)
}

The Tx interfaces defines the functionality that must be exposed by account-based transactions.

type TxBuilder

type TxBuilder interface {
	BuildTx(ctx context.Context, from, to address.Address, value, nonce, gasLimit, gasPrice, gasCap pack.U256, payload pack.Bytes) (Tx, error)
}

The TxBuilder interface defines the functionality required to build account-based transactions. Most chain implementations require additional information, and this should be accepted during the construction of the chain-specific transaction builder.

Jump to

Keyboard shortcuts

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