Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) ConsensusBlocksHeightGet(height types.BlockHeight) (cbg api.ConsensusBlocksGet, err error)
- func (c *Client) ConsensusBlocksIDGet(id types.BlockID) (cbg api.ConsensusBlocksGet, err error)
- func (c *Client) ConsensusGet() (cg api.ConsensusGET, err error)
- func (c *Client) ConsensusSetSubscribe(subscriber modules.ConsensusSetSubscriber, ccid modules.ConsensusChangeID, ...) (<-chan error, func())
- func (c *Client) ConsensusSubscribeSingle(subscriber modules.ConsensusSetSubscriber, ccid modules.ConsensusChangeID, ...) (modules.ConsensusChangeID, error)
- func (c *Client) DaemonAlertsGet() (dag api.DaemonAlertsGet, err error)
- func (c *Client) DaemonStopGet() (err error)
- func (c *Client) DaemonVersionGet() (dvg api.DaemonVersionGet, err error)
- func (c *Client) GatewayAppendBlocklistPost(addresses []string) (err error)
- func (c *Client) GatewayBandwidthGet() (gbg api.GatewayBandwidthGET, err error)
- func (c *Client) GatewayBlocklistGet() (gbg api.GatewayBlocklistGET, err error)
- func (c *Client) GatewayConnectPost(address modules.NetAddress) (err error)
- func (c *Client) GatewayDisconnectPost(address modules.NetAddress) (err error)
- func (c *Client) GatewayGet() (gwg api.GatewayGET, err error)
- func (c *Client) GatewayRateLimitPost(downloadSpeed, uploadSpeed int64) (err error)
- func (c *Client) GatewayRemoveBlocklistPost(addresses []string) (err error)
- func (c *Client) GatewaySetBlocklistPost(addresses []string) (err error)
- func (c *Client) HostDbActiveGet() (hdag api.HostdbActiveGET, err error)
- func (c *Client) HostDbAllGet() (hdag api.HostdbAllGET, err error)
- func (c *Client) HostDbFilterModeGet() (hdfmg api.HostdbFilterModeGET, err error)
- func (c *Client) HostDbFilterModePost(fm modules.FilterMode, hosts []types.SiaPublicKey, netAddresses []string) (err error)
- func (c *Client) HostDbGet() (hdg api.HostdbGet, err error)
- func (c *Client) HostDbHostsGet(pk types.SiaPublicKey) (hhg api.HostdbHostsGET, err error)
- func (c *Client) NewRequest(method, resource string, body io.Reader) (*http.Request, error)
- func (c *Client) PortalCreditsGet() (credits modules.CreditData, err error)
- func (c *Client) PortalCreditsPost(credits modules.CreditData) (err error)
- func (c *Client) SatelliteBalanceGet(key string) (ub modules.UserBalance, err error)
- func (c *Client) SatelliteContractsGet(key string) (rc api.RenterContracts, err error)
- func (c *Client) SatelliteRenterGet(key string) (r modules.Renter, err error)
- func (c *Client) SatelliteRentersGet() (rg api.RentersGET, err error)
- func (c *Client) TransactionPoolFeeGet() (tfg api.TpoolFeeGET, err error)
- func (c *Client) TransactionPoolRawPost(txn types.Transaction, parents []types.Transaction) (err error)
- func (c *Client) TransactionPoolTransactionsGet() (tptg api.TpoolTxnsGET, err error)
- func (c *Client) WalletAddressGet() (wag api.WalletAddressGET, err error)
- func (c *Client) WalletAddressesGet() (wag api.WalletAddressesGET, err error)
- func (c *Client) WalletChangePasswordPost(currentPassword, newPassword string) (err error)
- func (c *Client) WalletChangePasswordWithSeedPost(seed modules.Seed, newPassword string) (err error)
- func (c *Client) WalletGet() (wg api.WalletGET, err error)
- func (c *Client) WalletInitPost(password string, force bool) (wip api.WalletInitPOST, err error)
- func (c *Client) WalletInitSeedPost(seed, password string, force bool) (err error)
- func (c *Client) WalletLastAddressesGet(count uint64) (wag api.WalletAddressesGET, err error)
- func (c *Client) WalletLockPost() (err error)
- func (c *Client) WalletSeedPost(seed, password string) (err error)
- func (c *Client) WalletSeedsGet() (wsg api.WalletSeedsGET, err error)
- func (c *Client) WalletSiacoinsMultiPost(outputs []types.SiacoinOutput) (wsp api.WalletSiacoinsPOST, err error)
- func (c *Client) WalletSiacoinsPost(amount types.Currency, destination types.UnlockHash, feeIncluded bool) (wsp api.WalletSiacoinsPOST, err error)
- func (c *Client) WalletSignPost(txn types.Transaction, toSign []crypto.Hash) (wspr api.WalletSignPOSTResp, err error)
- func (c *Client) WalletSweepPost(seed string) (wsp api.WalletSweepPOST, err error)
- func (c *Client) WalletTransactionGet(id types.TransactionID) (wtg api.WalletTransactionGETid, err error)
- func (c *Client) WalletTransactionsGet(startHeight types.BlockHeight, endHeight types.BlockHeight) (wtg api.WalletTransactionsGET, err error)
- func (c *Client) WalletUnlockConditionsGet(addr types.UnlockHash) (wucg api.WalletUnlockConditionsGET, err error)
- func (c *Client) WalletUnlockPost(password string) (err error)
- func (c *Client) WalletUnspentGet() (wug api.WalletUnspentGET, err error)
- func (c *Client) WalletVerifyPasswordGet(password string) (wvpg api.WalletVerifyPasswordGET, err error)
- func (c *Client) WalletVerifyPasswordSeedGet(seed modules.Seed) (wvpg api.WalletVerifyPasswordGET, err error)
- func (c *Client) WalletWatchAddPost(addrs []types.UnlockHash, unused bool) error
- func (c *Client) WalletWatchGet() (wwg api.WalletWatchGET, err error)
- func (c *Client) WalletWatchRemovePost(addrs []types.UnlockHash, unused bool) error
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPeerExists indicates that two peers are already connected. The string // of this error needs to be updated if the string of errPeerExists in the // gateway package is changed. ErrPeerExists = errors.New("already connected to this peer") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Options
}
A Client makes requests to the satd HTTP API.
func New ¶
New creates a new Client using the provided address. The password will be set using SATD_API_PASSWORD environment variable and the user agent will be set to "Sat-Agent". Both can be changed manually by the caller after the client is returned.
func (*Client) ConsensusBlocksHeightGet ¶
func (c *Client) ConsensusBlocksHeightGet(height types.BlockHeight) (cbg api.ConsensusBlocksGet, err error)
ConsensusBlocksHeightGet requests the /consensus/blocks api resource.
func (*Client) ConsensusBlocksIDGet ¶
ConsensusBlocksIDGet requests the /consensus/blocks api resource.
func (*Client) ConsensusGet ¶
func (c *Client) ConsensusGet() (cg api.ConsensusGET, err error)
ConsensusGet requests the /consensus api resource.
func (*Client) ConsensusSetSubscribe ¶
func (c *Client) ConsensusSetSubscribe(subscriber modules.ConsensusSetSubscriber, ccid modules.ConsensusChangeID, cancel <-chan struct{}) (<-chan error, func())
ConsensusSetSubscribe polls the /consensus/subscribe endpoint, streaming consensus changes to the subscriber indefinitely. First, it will stream changes until the subscriber is fully caught up. It will send any error encountered down the returned channel, or nil. Consequently, the caller should always wait for the first error before proceeding with initialization. Subsequent errors may be handled asynchronously. It also returns a function that can be called to unsubscribe from further changes.
func (*Client) ConsensusSubscribeSingle ¶
func (c *Client) ConsensusSubscribeSingle(subscriber modules.ConsensusSetSubscriber, ccid modules.ConsensusChangeID, cancel <-chan struct{}) (modules.ConsensusChangeID, error)
ConsensusSubscribeSingle streams consensus changes from the /consensus/subscribe endpoint to the provided subscriber. Multiple calls may be required before the subscriber is fully caught up. It returns the latest change ID; if no changes were sent, this will be the same as the input ID.
func (*Client) DaemonAlertsGet ¶
func (c *Client) DaemonAlertsGet() (dag api.DaemonAlertsGet, err error)
DaemonAlertsGet requests the /daemon/alerts resource.
func (*Client) DaemonStopGet ¶
DaemonStopGet stops the daemon using the /daemon/stop endpoint.
func (*Client) DaemonVersionGet ¶
func (c *Client) DaemonVersionGet() (dvg api.DaemonVersionGet, err error)
DaemonVersionGet requests the /daemon/version resource.
func (*Client) GatewayAppendBlocklistPost ¶
GatewayAppendBlocklistPost uses the /gateway/blocklist endpoint to append addresses to the Gateway's blocklist.
func (*Client) GatewayBandwidthGet ¶
func (c *Client) GatewayBandwidthGet() (gbg api.GatewayBandwidthGET, err error)
GatewayBandwidthGet requests the /gateway/bandwidth api resource.
func (*Client) GatewayBlocklistGet ¶
func (c *Client) GatewayBlocklistGet() (gbg api.GatewayBlocklistGET, err error)
GatewayBlocklistGet uses the /gateway/blocklist endpoint to request the Gateway's blocklist.
func (*Client) GatewayConnectPost ¶
func (c *Client) GatewayConnectPost(address modules.NetAddress) (err error)
GatewayConnectPost uses the /gateway/connect/:address endpoint to connect to the gateway at address.
func (*Client) GatewayDisconnectPost ¶
func (c *Client) GatewayDisconnectPost(address modules.NetAddress) (err error)
GatewayDisconnectPost uses the /gateway/disconnect/:address endpoint to disconnect the gateway from a peer.
func (*Client) GatewayGet ¶
func (c *Client) GatewayGet() (gwg api.GatewayGET, err error)
GatewayGet requests the /gateway api resource.
func (*Client) GatewayRateLimitPost ¶
GatewayRateLimitPost uses the /gateway endpoint to change the gateway's bandwidth rate limit. downloadSpeed and uploadSpeed are interpreted as bytes/second.
func (*Client) GatewayRemoveBlocklistPost ¶
GatewayRemoveBlocklistPost uses the /gateway/blocklist endpoint to remove addresses from the Gateway's blocklist.
func (*Client) GatewaySetBlocklistPost ¶
GatewaySetBlocklistPost uses the /gateway/blocklist endpoint to set the Gateway's blocklist.
func (*Client) HostDbActiveGet ¶
func (c *Client) HostDbActiveGet() (hdag api.HostdbActiveGET, err error)
HostDbActiveGet requests the /hostdb/active endpoint's resources.
func (*Client) HostDbAllGet ¶
func (c *Client) HostDbAllGet() (hdag api.HostdbAllGET, err error)
HostDbAllGet requests the /hostdb/all endpoint's resources.
func (*Client) HostDbFilterModeGet ¶
func (c *Client) HostDbFilterModeGet() (hdfmg api.HostdbFilterModeGET, err error)
HostDbFilterModeGet requests the /hostdb/filtermode GET endpoint.
func (*Client) HostDbFilterModePost ¶
func (c *Client) HostDbFilterModePost(fm modules.FilterMode, hosts []types.SiaPublicKey, netAddresses []string) (err error)
HostDbFilterModePost requests the /hostdb/filtermode POST endpoint.
func (*Client) HostDbHostsGet ¶
func (c *Client) HostDbHostsGet(pk types.SiaPublicKey) (hhg api.HostdbHostsGET, err error)
HostDbHostsGet request the /hostdb/hosts/:pubkey endpoint's resources.
func (*Client) NewRequest ¶
NewRequest constructs a request to the satd HTTP API, setting the correct User-Agent and Basic Auth. The resource path must begin with /.
func (*Client) PortalCreditsGet ¶
func (c *Client) PortalCreditsGet() (credits modules.CreditData, err error)
PortalCreditsGet requests the /portal/credits resource.
func (*Client) PortalCreditsPost ¶
func (c *Client) PortalCreditsPost(credits modules.CreditData) (err error)
PortalCreditsPost requests the /portal/credits resource.
func (*Client) SatelliteBalanceGet ¶
func (c *Client) SatelliteBalanceGet(key string) (ub modules.UserBalance, err error)
SatelliteBalanceGet requests the /satellite/balance resource.
func (*Client) SatelliteContractsGet ¶
func (c *Client) SatelliteContractsGet(key string) (rc api.RenterContracts, err error)
SatelliteContractsGet requests the /satellite/contracts resource.
func (*Client) SatelliteRenterGet ¶
SatelliteRenterGet requests the /satellite/renter resource.
func (*Client) SatelliteRentersGet ¶
func (c *Client) SatelliteRentersGet() (rg api.RentersGET, err error)
SatelliteRentersGet requests the /satellite/renters resource.
func (*Client) TransactionPoolFeeGet ¶
func (c *Client) TransactionPoolFeeGet() (tfg api.TpoolFeeGET, err error)
TransactionPoolFeeGet uses the /tpool/fee endpoint to get a fee estimation.
func (*Client) TransactionPoolRawPost ¶
func (c *Client) TransactionPoolRawPost(txn types.Transaction, parents []types.Transaction) (err error)
TransactionPoolRawPost uses the /tpool/raw endpoint to send a raw transaction to the transaction pool.
func (*Client) TransactionPoolTransactionsGet ¶
func (c *Client) TransactionPoolTransactionsGet() (tptg api.TpoolTxnsGET, err error)
TransactionPoolTransactionsGet uses the /tpool/transactions endpoint to get the transactions of the tpool.
func (*Client) WalletAddressGet ¶
func (c *Client) WalletAddressGet() (wag api.WalletAddressGET, err error)
WalletAddressGet requests a new address from the /wallet/address endpoint.
func (*Client) WalletAddressesGet ¶
func (c *Client) WalletAddressesGet() (wag api.WalletAddressesGET, err error)
WalletAddressesGet requests the wallets known addresses from the /wallet/addresses endpoint.
func (*Client) WalletChangePasswordPost ¶
WalletChangePasswordPost uses the /wallet/changepassword endpoint to change the wallet's password.
func (*Client) WalletChangePasswordWithSeedPost ¶
func (c *Client) WalletChangePasswordWithSeedPost(seed modules.Seed, newPassword string) (err error)
WalletChangePasswordWithSeedPost uses the /wallet/changepassword endpoint to change the password used to encrypt the wallet.
func (*Client) WalletInitPost ¶
WalletInitPost uses the /wallet/init endpoint to initialize and encrypt a wallet.
func (*Client) WalletInitSeedPost ¶
WalletInitSeedPost uses the /wallet/init/seed endpoint to initialize and encrypt a wallet using a given seed.
func (*Client) WalletLastAddressesGet ¶
func (c *Client) WalletLastAddressesGet(count uint64) (wag api.WalletAddressesGET, err error)
WalletLastAddressesGet returns the count last addresses generated by the wallet in reverse order. That means the last generated address will be the first one in the slice.
func (*Client) WalletLockPost ¶
WalletLockPost uses the /wallet/lock endpoint to lock the wallet.
func (*Client) WalletSeedPost ¶
WalletSeedPost uses the /wallet/seed endpoint to add a seed to the wallet's list of seeds.
func (*Client) WalletSeedsGet ¶
func (c *Client) WalletSeedsGet() (wsg api.WalletSeedsGET, err error)
WalletSeedsGet uses the /wallet/seeds endpoint to return the wallet's current seeds.
func (*Client) WalletSiacoinsMultiPost ¶
func (c *Client) WalletSiacoinsMultiPost(outputs []types.SiacoinOutput) (wsp api.WalletSiacoinsPOST, err error)
WalletSiacoinsMultiPost uses the /wallet/siacoin api endpoint to send money to multiple addresses at once.
func (*Client) WalletSiacoinsPost ¶
func (c *Client) WalletSiacoinsPost(amount types.Currency, destination types.UnlockHash, feeIncluded bool) (wsp api.WalletSiacoinsPOST, err error)
WalletSiacoinsPost uses the /wallet/siacoins api endpoint to send money to a single address.
func (*Client) WalletSignPost ¶
func (c *Client) WalletSignPost(txn types.Transaction, toSign []crypto.Hash) (wspr api.WalletSignPOSTResp, err error)
WalletSignPost uses the /wallet/sign api endpoint to sign a transaction.
func (*Client) WalletSweepPost ¶
func (c *Client) WalletSweepPost(seed string) (wsp api.WalletSweepPOST, err error)
WalletSweepPost uses the /wallet/sweep/seed endpoint to sweep a seed into the current wallet.
func (*Client) WalletTransactionGet ¶
func (c *Client) WalletTransactionGet(id types.TransactionID) (wtg api.WalletTransactionGETid, err error)
WalletTransactionGet requests the /wallet/transaction/:id api resource for a certain TransactionID.
func (*Client) WalletTransactionsGet ¶
func (c *Client) WalletTransactionsGet(startHeight types.BlockHeight, endHeight types.BlockHeight) (wtg api.WalletTransactionsGET, err error)
WalletTransactionsGet requests the/wallet/transactions api resource for a certain startheight and endheight.
func (*Client) WalletUnlockConditionsGet ¶
func (c *Client) WalletUnlockConditionsGet(addr types.UnlockHash) (wucg api.WalletUnlockConditionsGET, err error)
WalletUnlockConditionsGet requests the /wallet/unlockconditions endpoint and returns the UnlockConditions of addr.
func (*Client) WalletUnlockPost ¶
WalletUnlockPost uses the /wallet/unlock endpoint to unlock the wallet with a given encryption key. Per default this key is the seed.
func (*Client) WalletUnspentGet ¶
func (c *Client) WalletUnspentGet() (wug api.WalletUnspentGET, err error)
WalletUnspentGet requests the /wallet/unspent endpoint and returns all of the unspent outputs related to the wallet.
func (*Client) WalletVerifyPasswordGet ¶
func (c *Client) WalletVerifyPasswordGet(password string) (wvpg api.WalletVerifyPasswordGET, err error)
WalletVerifyPasswordGet uses the /wallet/verifypassword endpoint to check the wallet's password.
func (*Client) WalletVerifyPasswordSeedGet ¶
func (c *Client) WalletVerifyPasswordSeedGet(seed modules.Seed) (wvpg api.WalletVerifyPasswordGET, err error)
WalletVerifyPasswordSeedGet takes a seed and generates a seed string to submit to the /wallet/verifypassword endpoint.
func (*Client) WalletWatchAddPost ¶
func (c *Client) WalletWatchAddPost(addrs []types.UnlockHash, unused bool) error
WalletWatchAddPost uses the /wallet/watch endpoint to add a set of addresses to the watch set. The unused flag should be set to true if the addresses have never appeared in the blockchain.
func (*Client) WalletWatchGet ¶
func (c *Client) WalletWatchGet() (wwg api.WalletWatchGET, err error)
WalletWatchGet requests the /wallet/watch endpoint and returns the set of currently watched addresses.
func (*Client) WalletWatchRemovePost ¶
func (c *Client) WalletWatchRemovePost(addrs []types.UnlockHash, unused bool) error
WalletWatchRemovePost uses the /wallet/watch endpoint to remove a set of addresses from the watch set. The unused flag should be set to true if the addresses have never appeared in the blockchain.
type Options ¶
type Options struct { // Address is the API address of the satd server. Address string // Password must match the password of the satd server. Password string // UserAgent must match the User-Agent required by the satd server. If not // set, it defaults to "Sat-Agent". UserAgent string // CheckRedirect is an optional handler to be called if the request // receives a redirect status code. // For more see https://golang.org/pkg/net/http/#Client CheckRedirect func(req *http.Request, via []*http.Request) error }
Options defines the options that are available when creating a client.
func DefaultOptions ¶
DefaultOptions returns the default options for a client. This includes setting the default satd user agent to "Sat-Agent" and setting the password using SATD_API_PASSWORD environment variable.