Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInsufficientFunds is returned when we must // request funds. ErrInsufficientFunds = errors.New("insufficient funds") )
Functions ¶
This section is empty.
Types ¶
type Constructor ¶
type Constructor struct {
// contains filtered or unexported fields
}
Constructor is responsible for managing the entire flow of creating test transactions on the Construction API. This runs from creating keypairs to requesting funds be loaded on addresses to creating transactions that satisfy minimum balance constraints.
func New ¶
func New( config *configuration.Configuration, parser *parser.Parser, helper Helper, handler Handler, ) (*Constructor, error)
New returns a new *Constructor.
func (*Constructor) CreateTransactions ¶
func (c *Constructor) CreateTransactions( ctx context.Context, clearBroadcasts bool, ) error
CreateTransactions loops on the create transaction loop until the caller cancels the context.
type Handler ¶
type Handler interface {
AddressCreated(context.Context, string) error
TransactionCreated(context.Context, string, *types.TransactionIdentifier) error
}
Handler is an interface called by the constructor whenever an address is created or a transaction is created.
type Helper ¶
type Helper interface {
// Derive returns a new address for a provided publicKey.
Derive(
context.Context,
*types.NetworkIdentifier,
*types.PublicKey,
map[string]interface{},
) (string, map[string]interface{}, error)
// Preprocess calls the /construction/preprocess endpoint
// on an offline node.
Preprocess(
context.Context,
*types.NetworkIdentifier,
[]*types.Operation,
map[string]interface{},
) (map[string]interface{}, error)
// Metadata calls the /construction/metadata endpoint
// using the online node.
Metadata(
context.Context,
*types.NetworkIdentifier,
map[string]interface{},
) (map[string]interface{}, error)
// Payloads calls the /construction/payloads endpoint
// using the offline node.
Payloads(
context.Context,
*types.NetworkIdentifier,
[]*types.Operation,
map[string]interface{},
) (string, []*types.SigningPayload, error)
// Parse calls the /construction/parse endpoint
// using the offline node.
Parse(
context.Context,
*types.NetworkIdentifier,
bool,
string,
) ([]*types.Operation, []string, map[string]interface{}, error)
// Combine calls the /construction/combine endpoint
// using the offline node.
Combine(
context.Context,
*types.NetworkIdentifier,
string,
[]*types.Signature,
) (string, error)
// Broadcast enqueues a particular intent for broadcast.
Broadcast(
context.Context,
string,
[]*types.Operation,
*types.TransactionIdentifier,
string,
) error
// Hash calls the /construction/hash endpoint
// using the offline node.
Hash(
context.Context,
*types.NetworkIdentifier,
string,
) (*types.TransactionIdentifier, error)
// Sign returns signatures for the provided
// payloads.
Sign(
context.Context,
[]*types.SigningPayload,
) ([]*types.Signature, error)
// StoreKey is called to persist an
// address + KeyPair.
StoreKey(
context.Context,
string,
*keys.KeyPair,
) error
// AccountBalance returns the balance
// for a provided address.
AccountBalance(
context.Context,
*types.AccountIdentifier,
*types.Currency,
) (*big.Int, error)
// CoinBalance returns the balance of the largest
// Coin owned by an address.
CoinBalance(
context.Context,
*types.AccountIdentifier,
*types.Currency,
) (*big.Int, *types.CoinIdentifier, error)
// LockedAddresses is a slice of all addresses currently sending or receiving
// funds.
LockedAddresses(context.Context) ([]string, error)
// AllBroadcasts returns a slice of all in-progress broadcasts.
AllBroadcasts(ctx context.Context) ([]*storage.Broadcast, error)
// ClearBroadcasts deletes all pending broadcasts.
ClearBroadcasts(ctx context.Context) ([]*storage.Broadcast, error)
// AllAddresses returns a slice of all known addresses.
AllAddresses(ctx context.Context) ([]string, error)
// RandomAmount returns some integer between min and max.
RandomAmount(*big.Int, *big.Int) *big.Int
}
Helper is an interface that provides access to information needed by the constructor while creating transactions.
Click to show internal directories.
Click to hide internal directories.