rpcclient

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: LGPL-3.0 Imports: 18 Imported by: 0

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

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

func NewClient(ctx context.Context, port uint16) *Client

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) Cancel

func (c *Client) Cancel(offerID types.Hash) (types.Status, error)

Cancel calls swap_cancel.

func (*Client) Claim added in v0.2.1

func (c *Client) Claim(offerID types.Hash) (*rpc.ManualTransactionResponse, error)

Claim calls swap_claim

func (*Client) ClearOffers

func (c *Client) ClearOffers(offerIDs []types.Hash) error

ClearOffers calls swap_clearOffers

func (*Client) Discover

func (c *Client) Discover(provides string, searchTime uint64) ([]peer.ID, error)

Discover calls net_discover.

func (*Client) GetContractSwapInfo added in v0.2.1

func (c *Client) GetContractSwapInfo(offerID types.Hash) (*rpc.GetContractSwapInfoResponse, error)

GetContractSwapInfo calls database_getContractSwapInfo.

func (*Client) GetOffers

func (c *Client) GetOffers() (*rpc.GetOffersResponse, error)

GetOffers calls swap_getOffers.

func (*Client) GetOngoingSwap

func (c *Client) GetOngoingSwap(id *types.Hash) (*rpc.GetOngoingResponse, error)

GetOngoingSwap calls swap_getOngoing

func (*Client) GetPastSwap

func (c *Client) GetPastSwap(id *types.Hash) (*rpc.GetPastResponse, error)

GetPastSwap calls swap_getPast

func (*Client) GetStatus

func (c *Client) GetStatus(id types.Hash) (*rpc.GetStatusResponse, error)

GetStatus calls swap_getStatus

func (*Client) GetSwapSecret added in v0.2.1

func (c *Client) GetSwapSecret(offerID types.Hash) (*rpc.GetSwapSecretResponse, error)

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) Query

func (c *Client) Query(who peer.ID) (*rpctypes.QueryPeerResponse, error)

Query calls net_query.

func (*Client) QueryAll

func (c *Client) QueryAll(provides coins.ProvidesCoin, searchTime uint64) ([]*rpctypes.PeerWithOffers, error)

QueryAll calls net_queryAll.

func (*Client) Refund added in v0.2.1

func (c *Client) Refund(offerID types.Hash) (*rpc.ManualTransactionResponse, error)

Refund calls swap_refund

func (*Client) SetSwapTimeout

func (c *Client) SetSwapTimeout(timeoutSeconds uint64) error

SetSwapTimeout calls personal_setSwapTimeout.

func (*Client) Shutdown

func (c *Client) Shutdown() error

Shutdown swapd

func (*Client) SubscribeSwapStatus added in v0.3.0

func (c *Client) SubscribeSwapStatus(id types.Hash) (<-chan types.Status, error)

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) TakeOffer

func (c *Client) TakeOffer(peerID peer.ID, offerID types.Hash, providesAmount *apd.Decimal) error

TakeOffer calls net_takeOffer.

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) TokenInfo

func (c *Client) TokenInfo(tokenAddr ethcommon.Address) (*coins.ERC20TokenInfo, error)

TokenInfo calls personal_tokenInfo

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

func (*Client) Version

func (c *Client) Version() (*rpc.VersionResponse, error)

Version returns version & misc info about swapd and its dependencies

Jump to

Keyboard shortcuts

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