Documentation ¶
Overview ¶
Package rpcclient provides client libraries for interacting with a local swapd instance using the JSON-RPC remote procedure call protocol and websockets.
Package rpcclient provides client libraries for interacting with a local swapd instance using the JSON-RPC remote procedure call protocol.
Index ¶
- type Client
- func (c *Client) Addresses() (*rpctypes.AddressesResponse, error)
- func (c *Client) Balances(request *rpctypes.BalancesRequest) (*rpctypes.BalancesResponse, error)
- func (c *Client) Cancel(offerID types.Hash) (types.Status, error)
- func (c *Client) Claim(offerID types.Hash) (*rpc.ManualTransactionResponse, error)
- func (c *Client) ClearOffers(offerIDs []types.Hash) error
- func (c *Client) Discover(provides string, searchTime uint64) ([]peer.ID, error)
- func (c *Client) GetContractSwapInfo(offerID types.Hash) (*rpc.GetContractSwapInfoResponse, error)
- func (c *Client) GetOffers() (*rpc.GetOffersResponse, error)
- func (c *Client) GetOngoingSwap(id *types.Hash) (*rpc.GetOngoingResponse, error)
- func (c *Client) GetPastSwap(id *types.Hash) (*rpc.GetPastResponse, error)
- func (c *Client) GetStatus(id types.Hash) (*rpc.GetStatusResponse, error)
- func (c *Client) GetSwapSecret(offerID types.Hash) (*rpc.GetSwapSecretResponse, error)
- func (c *Client) GetSwapTimeout() (*rpc.GetSwapTimeoutResponse, error)
- func (c *Client) MakeOffer(min, max *apd.Decimal, exchangeRate *coins.ExchangeRate, ...) (*rpctypes.MakeOfferResponse, error)
- func (c *Client) MakeOfferAndSubscribe(min *apd.Decimal, max *apd.Decimal, exchangeRate *coins.ExchangeRate, ...) (*rpctypes.MakeOfferResponse, <-chan types.Status, error)
- func (c *Client) Pairs(searchTime uint64) (*rpctypes.PairsResponse, error)
- func (c *Client) Peers() (*rpctypes.PeersResponse, error)
- func (c *Client) Query(who peer.ID) (*rpctypes.QueryPeerResponse, error)
- func (c *Client) QueryAll(provides coins.ProvidesCoin, searchTime uint64) ([]*rpctypes.PeerWithOffers, error)
- func (c *Client) Refund(offerID types.Hash) (*rpc.ManualTransactionResponse, error)
- func (c *Client) SetSwapTimeout(timeoutSeconds uint64) error
- func (c *Client) Shutdown() error
- func (c *Client) SubscribeSwapStatus(id types.Hash) (<-chan types.Status, error)
- func (c *Client) SuggestedExchangeRate() (*rpc.SuggestedExchangeRateResponse, error)
- func (c *Client) SweepETH(request *rpc.SweepETHRequest) (*rpc.SweepETHResponse, error)
- func (c *Client) SweepXMR(request *rpc.SweepXMRRequest) (*rpc.SweepXMRResponse, error)
- func (c *Client) TakeOffer(peerID peer.ID, offerID types.Hash, providesAmount *apd.Decimal) error
- func (c *Client) TakeOfferAndSubscribe(peerID peer.ID, offerID types.Hash, providesAmount *apd.Decimal) (ch <-chan types.Status, err error)
- func (c *Client) TokenInfo(tokenAddr ethcommon.Address) (*coins.ERC20TokenInfo, error)
- func (c *Client) TransferETH(request *rpc.TransferETHRequest) (*rpc.TransferETHResponse, error)
- func (c *Client) TransferXMR(request *rpc.TransferXMRRequest) (*rpc.TransferXMRResponse, error)
- func (c *Client) Version() (*rpc.VersionResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client primarily exists to be a JSON-RPC client to swapd instances, but it can be used to POST JSON-RPC requests to any JSON-RPC server. Its current use case assumes swapd is running on the local host of a single use system. TLS and authentication are not currently supported.
func NewClient ¶
NewClient creates a new JSON-RPC client for the specified endpoint. The passed context is used for the full lifetime of the client.
func (*Client) Addresses ¶
func (c *Client) Addresses() (*rpctypes.AddressesResponse, error)
Addresses calls net_addresses.
func (*Client) Balances ¶
func (c *Client) Balances(request *rpctypes.BalancesRequest) (*rpctypes.BalancesResponse, error)
Balances calls personal_balances.
func (*Client) ClearOffers ¶
ClearOffers calls swap_clearOffers
func (*Client) GetContractSwapInfo ¶ added in v0.2.1
GetContractSwapInfo calls database_getContractSwapInfo.
func (*Client) GetOffers ¶
func (c *Client) GetOffers() (*rpc.GetOffersResponse, error)
GetOffers calls swap_getOffers.
func (*Client) GetOngoingSwap ¶
GetOngoingSwap calls swap_getOngoing
func (*Client) GetPastSwap ¶
GetPastSwap calls swap_getPast
func (*Client) GetSwapSecret ¶ added in v0.2.1
GetSwapSecret calls database_getSwapSecret.
func (*Client) GetSwapTimeout ¶
func (c *Client) GetSwapTimeout() (*rpc.GetSwapTimeoutResponse, error)
GetSwapTimeout calls personal_getSwapTimeout.
func (*Client) MakeOffer ¶
func (c *Client) MakeOffer( min, max *apd.Decimal, exchangeRate *coins.ExchangeRate, ethAsset types.EthAsset, useRelayer bool, ) (*rpctypes.MakeOfferResponse, error)
MakeOffer calls net_makeOffer.
func (*Client) MakeOfferAndSubscribe ¶ added in v0.3.0
func (c *Client) MakeOfferAndSubscribe( min *apd.Decimal, max *apd.Decimal, exchangeRate *coins.ExchangeRate, ethAsset types.EthAsset, useRelayer bool, ) (*rpctypes.MakeOfferResponse, <-chan types.Status, error)
MakeOfferAndSubscribe calls the server-side net_makeOfferAndSubscribe method to make an offer and get status updates over websockets.
func (*Client) Pairs ¶ added in v0.4.2
func (c *Client) Pairs(searchTime uint64) (*rpctypes.PairsResponse, error)
Pairs calls net_pairs to get pairs from all offers.
func (*Client) Peers ¶
func (c *Client) Peers() (*rpctypes.PeersResponse, error)
Peers calls net_peers to get the connected peers of a swapd instance.
func (*Client) QueryAll ¶
func (c *Client) QueryAll(provides coins.ProvidesCoin, searchTime uint64) ([]*rpctypes.PeerWithOffers, error)
QueryAll calls net_queryAll.
func (*Client) SetSwapTimeout ¶
SetSwapTimeout calls personal_setSwapTimeout.
func (*Client) SubscribeSwapStatus ¶ added in v0.3.0
SubscribeSwapStatus returns a channel that is written to each time the swap's status updates. If there is no swap with the given ID, it returns an error.
func (*Client) SuggestedExchangeRate ¶
func (c *Client) SuggestedExchangeRate() (*rpc.SuggestedExchangeRateResponse, error)
SuggestedExchangeRate calls swap_suggestedExchangeRate
func (*Client) SweepETH ¶ added in v0.3.0
func (c *Client) SweepETH(request *rpc.SweepETHRequest) (*rpc.SweepETHResponse, error)
SweepETH calls personal_sweepETH
func (*Client) SweepXMR ¶ added in v0.2.1
func (c *Client) SweepXMR(request *rpc.SweepXMRRequest) (*rpc.SweepXMRResponse, error)
SweepXMR calls personal_sweepXMR
func (*Client) TakeOfferAndSubscribe ¶ added in v0.3.0
func (c *Client) TakeOfferAndSubscribe( peerID peer.ID, offerID types.Hash, providesAmount *apd.Decimal, ) (ch <-chan types.Status, err error)
TakeOfferAndSubscribe calls the server-side net_takeOfferAndSubscribe method to take and offer and get status updates over websockets.
func (*Client) TransferETH ¶ added in v0.2.1
func (c *Client) TransferETH(request *rpc.TransferETHRequest) (*rpc.TransferETHResponse, error)
TransferETH calls personal_transferETH
func (*Client) TransferXMR ¶ added in v0.2.1
func (c *Client) TransferXMR(request *rpc.TransferXMRRequest) (*rpc.TransferXMRResponse, error)
TransferXMR calls personal_transferXMR