internal

package
v0.0.0-...-c29e294 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAccountExists error = errors.New(fmt.Sprintf("createAccountAlreadyExist (%s)", createAccountAlreadyExistXDR))
View Source
var ErrAccountFunded error = errors.New("account already funded to starting balance")

Functions

func CheckAccountExists

func CheckAccountExists(minion *Minion, hclient horizonclient.ClientInterface, address string) (bool, string, error)

CheckAccountExists checks if the specified address exists as a Stellar account. And returns the current native balance of the account also. This should also be passed to the minion.

func CheckSequenceRefresh

func CheckSequenceRefresh(minion *Minion, hclient horizonclient.ClientInterface) error

CheckSequenceRefresh establishes the minion's initial sequence number, if needed. This should also be passed to the minion.

func SubmitTransaction

func SubmitTransaction(minion *Minion, hclient horizonclient.ClientInterface, tx string) (*hProtocol.Transaction, error)

SubmitTransaction should be passed to the Minion.

Types

type Account

type Account struct {
	AccountID string
	Sequence  int64
}

Account implements the `txnbuild.Account` interface.

func (Account) GetAccountID

func (a Account) GetAccountID() string

GetAccountID returns the Account ID.

func (Account) GetSequenceNumber

func (a Account) GetSequenceNumber() (int64, error)

func (Account) IncrementSequenceNumber

func (a Account) IncrementSequenceNumber() (int64, error)

IncrementSequenceNumber increments the internal record of the account's sequence number by 1.

func (*Account) RefreshSequenceNumber

func (a *Account) RefreshSequenceNumber(hclient horizonclient.ClientInterface) error

RefreshSequenceNumber gets an Account's correct in-memory sequence number from Horizon.

type Bot

type Bot struct {
	Minions []Minion
	// contains filtered or unexported fields
}

Bot represents the friendbot subsystem and primarily delegates work to its Minions.

func (*Bot) Pay

func (bot *Bot) Pay(destAddress string) (*hProtocol.Transaction, error)

Pay funds the account at `destAddress`.

type FriendbotHandler

type FriendbotHandler struct {
	Friendbot *Bot
}

FriendbotHandler causes an account at `Address` to be created.

func (*FriendbotHandler) Handle

func (handler *FriendbotHandler) Handle(w http.ResponseWriter, r *http.Request)

Handle is a method that implements http.HandlerFunc

type Minion

type Minion struct {
	Account         Account
	Keypair         *keypair.Full
	BotAccount      txnbuild.Account
	BotKeypair      *keypair.Full
	Horizon         horizonclient.ClientInterface
	Network         string
	StartingBalance string
	BaseFee         int64

	// Mockable functions
	SubmitTransaction    func(minion *Minion, hclient horizonclient.ClientInterface, tx string) (*hProtocol.Transaction, error)
	CheckSequenceRefresh func(minion *Minion, hclient horizonclient.ClientInterface) error
	CheckAccountExists   func(minion *Minion, hclient horizonclient.ClientInterface, destAddress string) (bool, string, error)
	// contains filtered or unexported fields
}

Minion contains a Stellar channel account and Go channels to communicate with friendbot.

func (*Minion) Run

func (minion *Minion) Run(destAddress string, resultChan chan SubmitResult)

Run reads a payment destination address and an output channel. It attempts to pay that address and submits the result to the channel.

type SubmitResult

type SubmitResult struct {
	// contains filtered or unexported fields
}

SubmitResult is the result from the asynchronous tx submission.

Jump to

Keyboard shortcuts

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