stellar

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NetworkProduction uses stellar production network
	NetworkProduction = "production"
	// NetworkTest uses stellar test network
	NetworkTest = "testnet"
	// NetworkDebug doesn't do validation, and always address validation is skipped
	// Only supported by the AddressValidator
	NetworkDebug = "debug"
)

Variables

View Source
var (
	// ErrInsufficientBalance is an error that is used when there is insufficient balance
	ErrInsufficientBalance = errors.New("insufficient balance")
	// ErrAssetCodeNotSupported indicated the given asset code is not supported by this wallet
	ErrAssetCodeNotSupported = errors.New("asset code not supported")
)

Functions

This section is empty.

Types

type AddressValidator

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

AddressValidator validates stellar address

func NewAddressValidator

func NewAddressValidator(network, assetCode string) (*AddressValidator, error)

NewAddressValidator creates an address validator instance

func (*AddressValidator) Valid

func (a *AddressValidator) Valid(address string) error

Valid validates a stellar address, and only return nil if address is valid

type Asset

type Asset string

Asset on the stellar network, both code and issuer in the form <CODE>:<ISSUER>

const (
	TFTMainnet Asset = "TFT:GBOVQKJYHXRR3DX6NOX2RRYFRCUMSADGDESTDNBDS6CDVLGVESRTAC47"
	TFTTestnet Asset = "TFT:GA47YZA3PKFUZMPLQ3B5F2E3CJIB57TGGU7SPCQT2WAEYKN766PWIMB3"

	TFTAMainnet Asset = "TFTA:GBUT4GP5GJ6B3XW5PXENHQA7TXJI5GOPW3NF4W3ZIW6OOO4ISY6WNLN2"
	TFTATestnet Asset = "TFTA:GB55A4RR4G2MIORJTQA4L6FENZU7K4W7ATGY6YOT2CW47M5SZYGYKSCT"

	FreeTFTMainnet Asset = "FreeTFT:GCBGS5TFE2BPPUVY55ZPEMWWGR6CLQ7T6P46SOFGHXEBJ34MSP6HVEUT"
	FreeTFTTestnet Asset = "FreeTFT:GBLDUINEFYTF7XEE7YNWA3JQS4K2VD37YU7I2YAE7R5AHZDKQXSS2J6R"
)

Supported assets for the wallet. Assets are different based on testnet/mainnet

func (Asset) Code

func (a Asset) Code() string

Code of the asset

func (Asset) Issuer

func (a Asset) Issuer() string

Issuer of the asset

func (Asset) String

func (a Asset) String() string

String implements Stringer interface

type PayoutInfo

type PayoutInfo struct {
	Address string
	Amount  xdr.Int64
}

PayoutInfo holds information about which address needs to receive how many funds for payment commands which take multiple receivers

type Signers

type Signers []string

Signers is a flag type for setting the signers on the escrow accounts

func (*Signers) Set

func (i *Signers) Set(value string) error

Set a value on the signers flag

func (*Signers) String

func (i *Signers) String() string

type Wallet

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

Wallet is the foundation wallet Payments will be funded and fees will be taken with this wallet

func New

func New(seed, network string, signers []string) (*Wallet, error)

New stellar wallet from an optional seed. If no seed is given (i.e. empty string), the wallet will panic on all actions which need to be signed, or otherwise require a key to be loaded.

func (*Wallet) AssetFromCode

func (w *Wallet) AssetFromCode(code string) (Asset, error)

AssetFromCode loads the full asset from a code, provided the wallet supports the asset code

func (*Wallet) CreateAccount

func (w *Wallet) CreateAccount() (string, string, error)

CreateAccount and activate it, so that it is ready to be used The encrypted seed of the wallet is returned, together with the public address

func (*Wallet) GetAccountDetails

func (w *Wallet) GetAccountDetails(address string) (account hProtocol.Account, err error)

GetAccountDetails gets account details based an a Stellar address

func (*Wallet) GetBalance

func (w *Wallet) GetBalance(address string, memo string, asset Asset) (xdr.Int64, []string, error)

GetBalance gets balance for an address and a given reservation id. It also returns a list of addresses which funded the given address.

func (*Wallet) GetHorizonClient

func (w *Wallet) GetHorizonClient() (*horizonclient.Client, error)

GetHorizonClient gets the horizon client based on the wallet's network

func (*Wallet) GetNetworkPassPhrase

func (w *Wallet) GetNetworkPassPhrase() string

GetNetworkPassPhrase gets the Stellar network passphrase based on the wallet's network

func (*Wallet) PayoutFarmers

func (w *Wallet) PayoutFarmers(encryptedSeed string, destinations []PayoutInfo, memo string, asset Asset) error

PayoutFarmers pays a group of farmers, from an escrow account. The escrow account must be provided as the encrypted string of the seed.

func (*Wallet) PrecisionDigits

func (w *Wallet) PrecisionDigits() int

PrecisionDigits of the underlying currencies on chain

func (*Wallet) PublicAddress

func (w *Wallet) PublicAddress() string

PublicAddress of this wallet

func (*Wallet) Refund

func (w *Wallet) Refund(encryptedSeed string, memo string, asset Asset) error

Refund an escrow address for a reservation. This will transfer all funds for this reservation that are currently on the address (if any), to (some of) the addresses which these funds came from.

Jump to

Keyboard shortcuts

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