algo

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultValidRoundRange = 100

DefaultValidRoundRange - max valid round range to have transactions be valid for (and to check for confirmation)

Variables

This section is empty.

Functions

func DecodeAndSignNFDTransactions

func DecodeAndSignNFDTransactions(nfdnTxnResponse string, signer MultipleWalletSigner) (string, []byte, error)

DecodeAndSignNFDTransactions decodes and signs transactions that came from an NFD API for user signing, signing each transaction which needs signed using the given signer

func FormattedAlgoAmount

func FormattedAlgoAmount(microAlgos uint64) string

func GetAlgoClient

func GetAlgoClient(log *slog.Logger, config NetworkConfig, maxConnections int) (*algod.Client, error)

func GetNetAndTokenFromFiles

func GetNetAndTokenFromFiles(netFile, tokenFile string) (string, string, error)

GetNetAndTokenFromFiles reads the address and token from the specified files in the local Algorand data directory.

The function takes two arguments: netFile (string) and tokenFile (string), which represent the paths to the files. It returns the API URL (string), the API token (string), and any error encountered.

Example usage:

apiURL, apiToken, err := GetNetAndTokenFromFiles("algod.net", "algod.token")

The function internally uses os.ReadFile function to read the address and token files. It then trims any leading or trailing whitespace from the read contents and returns the cleaned values. If any error occurs during file reading, the function returns an empty string for both API URL and API token, along with an error indicating the specific file reading failure.

func NewLocalKeyStore

func NewLocalKeyStore(log *slog.Logger) *localKeyStore

func SignGroupTransactions

func SignGroupTransactions(ctx context.Context, txns []types.Transaction, signers []TxnSigner) ([]byte, []string, error)

SignGroupTransactions takes the slice of Transactions and of TxnSigner implementations and signs each according to the matching TxnSigner implementation for each transaction.

func SignGroupTransactionsForFrontend

func SignGroupTransactionsForFrontend(ctx context.Context, log *slog.Logger, txns []types.Transaction, signers []TxnSigner) ([]byte, error)

SignGroupTransactionsForFrontend takes the slice of Transactions and of TxnSigner implementations and signs each according to the matching TxnSigner implementation for each transaction - returning as a json array of base64 encoded strings

func SignWithAccountForATC

func SignWithAccountForATC(keyManager MultipleWalletSigner, publicAddress string) transaction.TransactionSigner

func SuggestedParams

func SuggestedParams(ctx context.Context, logger *slog.Logger, client *algod.Client) types.SuggestedParams

Types

type AccountWithMinBalance

type AccountWithMinBalance struct {
	models.Account
	MinBalance uint64 `json:"min-balance,omitempty"`
}

func GetBareAccount

func GetBareAccount(ctx context.Context, algoClient *algod.Client, account string) (AccountWithMinBalance, error)

GetBareAccount just returns account information without asset data, but also includes the minimum balance that's missing from the SDKs.

type MultipleWalletSigner

type MultipleWalletSigner interface {
	HasAccount(publicAddress string) bool
	SignWithAccount(ctx context.Context, tx types.Transaction, publicAddress string) (string, []byte, error)
}

type NetworkConfig

type NetworkConfig struct {
	NodeDataDir string

	NFDAPIUrl string

	NodeURL     string
	NodeToken   string
	NodeHeaders map[string]string
}

func GetNetworkConfig

func GetNetworkConfig(network string) NetworkConfig

type TxnSigner

type TxnSigner interface {
	// SignTxn signs the specified transaction, returning Transaction ID, signed transaction bytes, and error
	SignTxn(ctx context.Context, tx types.Transaction) (string, []byte, error)
}

func SignByUser

func SignByUser(signers []TxnSigner) []TxnSigner

func SignWithAccount

func SignWithAccount(signers []TxnSigner, keyManager MultipleWalletSigner, publicAddress string) []TxnSigner

func SignWithKey

func SignWithKey(signers []TxnSigner, privateKey ed25519.PrivateKey) []TxnSigner

func SignWithLogicSig

func SignWithLogicSig(signers []TxnSigner, logicSigAccount crypto.LogicSigAccount) []TxnSigner

Jump to

Keyboard shortcuts

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