Documentation ¶
Overview ¶
Package starlight exposes a payment channel agent on the Stellar network.
Index ¶
- Variables
- func WriteError(req *http.Request, w http.ResponseWriter, err error)
- type Agent
- func (g *Agent) AddAsset(assetCode, issuer string) error
- func (g *Agent) AfterFunc(t time.Time, f func())
- func (g *Agent) Authenticate(name, password string) bool
- func (g *Agent) Close()
- func (g *Agent) CloseWait()
- func (g *Agent) ConfigEdit(c *Config) error
- func (g *Agent) ConfigInit(c *Config, hostURL string) error
- func (g *Agent) Configured() bool
- func (g *Agent) DoCloseAccount(dest string) error
- func (g *Agent) DoCommand(channelID string, c *fsm.Command) error
- func (g *Agent) DoCreateChannel(guestFedAddr string, hostAmount xlm.Amount) (*fsm.Channel, error)
- func (g *Agent) DoWalletPay(dest string, amount uint64, assetCode, issuer string) error
- func (g *Agent) FindAccount(target string) (accountID, starlightURL string, err error)
- func (g *Agent) LoadAccount(accountID string) (worizon.Account, error)
- func (g *Agent) Messages(chanID string, a, b uint64) []*fsm.Message
- func (g *Agent) Now() time.Time
- func (g *Agent) PeerHandler() http.Handler
- func (g *Agent) RemoveAsset(assetCode, issuer string) error
- func (g *Agent) SetDebug(debug bool, name string)
- func (g *Agent) Updates(a, b uint64) []*Update
- func (g *Agent) WaitMsg(ctx context.Context, chanID string, i uint64)
- func (g *Agent) WaitUpdate(ctx context.Context, i uint64)
- type Config
- type TbMsg
- type TbTx
- type Update
Constants ¶
This section is empty.
Variables ¶
var ( ErrAuthFailed = errors.New("authentication failed") ErrUnmarshaling = errors.New("error unmarshaling input") )
Defines the exported errors that are used by the Starlight wallet RPC handler.
Functions ¶
func WriteError ¶
func WriteError(req *http.Request, w http.ResponseWriter, err error)
WriteError formats an error with the correct message and status from the starlight error formatter and writes the result to w.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
An Agent acts on behalf of the user to open, close, maintain, and use payment channels. Its methods are safe to call concurrently. Methods 'Do*' initiate channel operations.
An Agent serializes all its state changes and stores them in a database as Update records. Methods Wait and Updates provide synchronization and access (respectively) for updates.
func StartAgent ¶
StartAgent starts an agent using the bucket "agent" in db for storage and returns it.
func (*Agent) Authenticate ¶
Authenticate authenticates the given user name and password. If they're valid, it also decrypts the secret entropy seed if necessary, allowing private-key operations to proceed.
It returns whether name and password are valid.
func (*Agent) Close ¶
func (g *Agent) Close()
Close releases resources associated with the Agent. It does not wait for its subordinate goroutines to exit.
func (*Agent) CloseWait ¶
func (g *Agent) CloseWait()
CloseWait releases resources associated with the Agent. It waits for its subordinate goroutines to exit.
func (*Agent) ConfigEdit ¶
ConfigEdit edits g's configuration. Only Password and HorizonURL can be changed; attempting to change another field is an error.
func (*Agent) ConfigInit ¶
ConfigInit sets g's configuration, generates a private key for the wallet, and performs any other necessary setup steps, such as obtaining free testnet lumens. It is an error if g has already been configured.
func (*Agent) Configured ¶
Configured returns whether ConfigInit has been called on g.
func (*Agent) DoCloseAccount ¶
DoCloseAccount will merge the agent's wallet account into the specified destination account. If the agent has any channels that are not closed, it will fail. While the agent is shutting down, it will not accept any other commands. If the transaction fails, the agent will alert the user and return to an Active state. Otherwise, the agent transitions to an empty initial state on merge success.
func (*Agent) DoCreateChannel ¶
DoCreateChannel creates a channel between the agent host and the guest specified at guestFedAddr, funding the channel with hostAmount
func (*Agent) DoWalletPay ¶
DoWalletPay implements the wallet-pay command.
func (*Agent) FindAccount ¶
FindAccount looks up the account ID and Starlight URL for the Stellar account named by target.
The target must be a Stellar address in the form of a federation address, e.g.
kr*mywallet.example.com
Or a valid Stellar account ID.
If given a federation account, FindAccount will use the Stellar TOML file and the Stellar federation server protocol to look up the additional info, returning the account ID and Starlight URL.
If given an Account ID, FindAccount will look up the account's home domain, returning the account's federation address and Starlight URL.
func (*Agent) Messages ¶
Messages returns all messages sent by the agent on channel chanID in the half-open interval [a, b). The returned slice will have length less than b-a if a or b is out of range.
func (*Agent) PeerHandler ¶
PeerHandler handles RPCs (such as ProposeChannel, AcceptChannel, Payment, etc.) from remote channel endpoints.
func (*Agent) RemoveAsset ¶
RemoveAsset deletes a trustline for a non-native Asset.
func (*Agent) Updates ¶
Updates returns all updates in the half-open interval [a, b). The returned slice will have length less than b-a if a or b is out of range.
type Config ¶
type Config struct { Username string `json:",omitempty"` Password string `json:",omitempty"` // WARNING: this software is not compatible with Stellar mainnet. HorizonURL string `json:",omitempty"` // OldPassword is required from the client in ConfigEdit // when changing the password. // It's never included in Updates. OldPassword string `json:",omitempty"` MaxRoundDurMins int64 `json:",omitempty"` FinalityDelayMins int64 `json:",omitempty"` ChannelFeerate xlm.Amount `json:",omitempty"` HostFeerate xlm.Amount `json:",omitempty"` // KeepAlive, if set, indicates whether or not the agent will // send 0-value keep-alive payments on its channels KeepAlive *bool `json:",omitempty"` // Public indicates whether the agent is running on a // publicly-accessible URL. If the agent is public, then it is // able to propose and receive incoming channel requests. // Private agents can only propose channels // and see incoming messages on their local network. Public bool }
Config has user-facing, primary options for the Starlight agent
type TbTx ¶
type TbTx struct { ChanID string // Starlight channel ID, or "wallet" for wallet txs E xdr.TransactionEnvelope // contains filtered or unexported fields }
TbTx is a taskbasket transaction-submitting task.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package fsm implements the state transition logic in the Starlight spec.
|
Package fsm implements the state transition logic in the Starlight spec. |
internal
|
|
Package starlighttest contains agent-level integration tests for starlight.
|
Package starlighttest contains agent-level integration tests for starlight. |
Package taskbasket is a persistent task manager.
|
Package taskbasket is a persistent task manager. |