Documentation
¶
Index ¶
- Constants
- Variables
- func DeriveSeed(owner domain.Owner, identityKey ed25519.PrivateKey, network string) (string, error)
- func IsAddress(address string) bool
- type Account
- type Client
- func (c *Client) Address(ctx context.Context, seed string) (string, error)
- func (c *Client) Balance(ctx context.Context, address string) (Account, error)
- func (c *Client) Close()
- func (c *Client) Decimals() uint8
- func (c *Client) Export(ctx context.Context, seed string) (address, privateKey string, err error)
- func (c *Client) History(ctx context.Context, address, asset string, limit int) ([]Transfer, error)
- func (c *Client) IsAvailable(ctx context.Context) bool
- func (c *Client) IsPaid(ctx context.Context, txId string, s Sponsorship) (Receipt, error)
- func (c *Client) MaxFeePercent() uint64
- func (c *Client) Network() string
- func (c *Client) Pay(ctx context.Context, seed string, s Sponsorship) (Payment, error)
- func (c *Client) Payment(ctx context.Context, s Sponsorship, since time.Time) (PaymentState, error)
- func (c *Client) Quote(ctx context.Context, seed string, s Sponsorship) (Quote, error)
- func (c *Client) Splitter() string
- func (c *Client) Splitters() []string
- func (c *Client) Stake(ctx context.Context, seed, amount string) (string, error)
- func (c *Client) Token() string
- func (c *Client) Transfer(ctx context.Context, seed, asset, to, amount string) (string, error)
- func (c *Client) Unstake(ctx context.Context, seed, amount string) (string, error)
- func (c *Client) Withdraw(ctx context.Context, seed string) (string, error)
- type Config
- type Payment
- type PaymentState
- type Quote
- type QuoteStep
- type Receipt
- type Sponsorship
- type Transfer
- type Unstaking
Constants ¶
const ( PayTimeout = 4 * time.Minute NativeCoin = "TRX" )
Variables ¶
Functions ¶
func DeriveSeed ¶
Types ¶
type Account ¶
type Account struct {
TokenBalance string
TRX string
Staked string
Unstaking []Unstaking
Activated bool
CreatedAt int64
}
func (Account) IsLockedEnough ¶ added in v0.8.83
func (Account) IsStakeEnough ¶ added in v0.8.83
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) MaxFeePercent ¶
func (*Client) Pay ¶
Pay settles sponsored content and nothing else. It sends the money through one of the project's splitter contracts, which adds the fee on top of the amount, routes that fee to a project wallet and emits the Paid event that verification later reads to prove this transaction paid for this order.
Paying a person rather than a sponsorship is Transfer: it moves the whole amount to the recipient, takes no fee and leaves no receipt to check. Do not reach for Pay to send someone money.
func (*Client) Payment ¶ added in v0.8.83
func (c *Client) Payment(ctx context.Context, s Sponsorship, since time.Time) (PaymentState, error)
Payment asks the splitter whether the buyer's order is paid and which of the buyer's transactions from since onwards paid it, so a payment whose answer was lost is found rather than sent again.
func (*Client) Quote ¶
Quote asks what Pay would cost the wallet of seed for s, without signing anything: the token amounts exactly and the TRX the network would burn.
func (*Client) Splitters ¶ added in v0.8.83
Splitters are every splitter this node accepts payments to: the one it pays through first, then the retired ones.
type Config ¶
type Config struct {
BinaryPath string
Network string
Endpoint string
Token string
TokenContract string
Decimals uint8
RPS float64
Splitter string
// Retired are splitters this node no longer pays through but still accepts
// payments to, so a buyer on an older node is not left with a payment no
// author will confirm.
Retired []string
MaxFeePercent uint64
}
func DefaultConfig ¶
type PaymentState ¶ added in v0.8.83
PaymentState is what the splitter records of an order: whether it is paid, and which transaction paid it once the indexer lists it.
type Quote ¶
type Quote struct {
Token string `json:"token"`
FeePercent uint64 `json:"fee_percent"`
Fee string `json:"fee"`
Total string `json:"total"`
Balance string `json:"balance"`
TRX string `json:"trx"`
EnergyPrice int64 `json:"energy_price"`
BandwidthPrice int64 `json:"bandwidth_price"`
NetworkFee string `json:"network_fee"`
Steps []QuoteStep `json:"steps"`
}
type Receipt ¶ added in v0.8.83
Receipt is what verification says of a payment: whether it is confirmed, and when the block that holds it was produced.