Documentation ¶
Overview ¶
Package rpctypes provides the serialized types for queries and responses shared by swapd's JSON-RPC server and client-side libraries.
Index ¶
- Constants
- type AddressesResponse
- type BalancesRequest
- type BalancesResponse
- type DiscoverRequest
- type DiscoverResponse
- type ErrCode
- type Error
- type MakeOfferRequest
- type MakeOfferResponse
- type PeerWithOffers
- type PeersResponse
- type QueryAllRequest
- type QueryAllResponse
- type QueryPeerRequest
- type QueryPeerResponse
- type Request
- type Response
- type SignerRequest
- type SignerResponse
- type SignerTxSigned
- type SubscribeSwapStatusRequest
- type SubscribeSwapStatusResponse
- type TakeOfferRequest
- type TokenInfoRequest
- type TokenInfoResponse
Constants ¶
const ( NetDiscover = "net_discover" NetQueryPeer = "net_queryPeer" SubscribeNewPeer = "net_subscribeNewPeer" SubscribeMakeOffer = "net_makeOfferAndSubscribe" SubscribeTakeOffer = "net_takeOfferAndSubscribe" SubscribeSwapStatus = "swap_subscribeStatus" SubscribeSigner = "signer_subscribe" )
JSON RPC method names that we serve on the localhost server
const DefaultJSONRPCVersion = "2.0"
DefaultJSONRPCVersion ...
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressesResponse ¶
type AddressesResponse struct {
Addrs []string `json:"addresses" validate:"dive,required"`
}
AddressesResponse ...
type BalancesRequest ¶
type BalancesRequest struct {
TokenAddrs []ethcommon.Address `json:"tokensAddrs" validate:"dive,required"`
}
BalancesRequest is used to request the combined Monero and Ethereum balances as well as the balances of any tokens included in the request.
type BalancesResponse ¶
type BalancesResponse struct { MoneroAddress *mcrypto.Address `json:"moneroAddress" validate:"required"` PiconeroBalance *coins.PiconeroAmount `json:"piconeroBalance" validate:"required"` PiconeroUnlockedBalance *coins.PiconeroAmount `json:"piconeroUnlockedBalance" validate:"required"` BlocksToUnlock uint64 `json:"blocksToUnlock"` EthAddress ethcommon.Address `json:"ethAddress" validate:"required"` WeiBalance *coins.WeiAmount `json:"weiBalance" validate:"required"` TokenBalances []*coins.ERC20TokenAmount `json:"tokenBalances" validate:"dive,required"` }
BalancesResponse holds the response for the combined Monero, Ethereum and optional token Balances request
type DiscoverRequest ¶
type DiscoverRequest struct { Provides string `json:"provides"` SearchTime uint64 `json:"searchTime"` // in seconds }
DiscoverRequest ...
type DiscoverResponse ¶
DiscoverResponse ...
type Error ¶
type Error struct { Message string `json:"message"` ErrorCode ErrCode `json:"code"` Data map[string]interface{} `json:"data"` }
Error is a struct that holds the error message and the error code for a error
type MakeOfferRequest ¶
type MakeOfferRequest struct { MinAmount *apd.Decimal `json:"minAmount" validate:"required"` MaxAmount *apd.Decimal `json:"maxAmount" validate:"required"` ExchangeRate *coins.ExchangeRate `json:"exchangeRate" validate:"required"` EthAsset types.EthAsset `json:"ethAsset,omitempty"` UseRelayer bool `json:"useRelayer,omitempty"` }
MakeOfferRequest ...
type MakeOfferResponse ¶
type MakeOfferResponse struct { PeerID peer.ID `json:"peerID" validate:"required"` OfferID types.Hash `json:"offerID" validate:"required"` }
MakeOfferResponse ...
type PeerWithOffers ¶
type PeerWithOffers struct { PeerID peer.ID `json:"peerID" validate:"required"` Offers []*types.Offer `json:"offers" validate:"dive,required"` }
PeerWithOffers ...
type PeersResponse ¶
type PeersResponse struct {
Addrs []string `json:"addresses" validate:"dive,required"`
}
PeersResponse ...
type QueryAllResponse ¶
type QueryAllResponse struct {
PeersWithOffers []*PeerWithOffers `json:"peersWithOffers" validate:"dive,required"`
}
QueryAllResponse ...
type QueryPeerRequest ¶
type QueryPeerRequest struct { // Peer ID of peer to query PeerID peer.ID `json:"peerID" validate:"required"` }
QueryPeerRequest ...
type QueryPeerResponse ¶
QueryPeerResponse ...
type Request ¶
type Request struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params json.RawMessage `json:"params"` ID uint64 `json:"id"` }
Request represents a JSON-RPC request
type Response ¶
type Response struct { Version string `json:"jsonrpc"` Result json.RawMessage `json:"result"` Error *Error `json:"error"` ID *json.RawMessage `json:"id"` }
Response is the JSON format of a response
type SignerRequest ¶
type SignerRequest struct { OfferID types.Hash `json:"offerID" validate:"required"` EthAddress ethcommon.Address `json:"ethAddress" validate:"required"` XMRAddress *mcrypto.Address `json:"xmrAddress" validate:"required"` }
SignerRequest initiates the signer_subscribe handler from the front-end
type SignerResponse ¶
type SignerResponse struct { OfferID types.Hash `json:"offerID" validate:"required"` To ethcommon.Address `json:"to" validate:"required"` Data []byte `json:"data" validate:"required"` Value *apd.Decimal `json:"value" validate:"required"` // In ETH (or other ETH asset) not WEI }
SignerResponse sends a tx to be signed to the front-end
type SignerTxSigned ¶
type SignerTxSigned struct { OfferID types.Hash `json:"offerID" validate:"required"` TxHash ethcommon.Hash `json:"txHash" validate:"required"` }
SignerTxSigned is a response from the front-end saying the given tx has been submitted successfully
type SubscribeSwapStatusRequest ¶
SubscribeSwapStatusRequest ...
type SubscribeSwapStatusResponse ¶
SubscribeSwapStatusResponse ...
type TakeOfferRequest ¶
type TakeOfferRequest struct { PeerID peer.ID `json:"peerID" validate:"required"` OfferID types.Hash `json:"offerID" validate:"required"` ProvidesAmount *apd.Decimal `json:"providesAmount" validate:"required"` // eth asset amount }
TakeOfferRequest ...
type TokenInfoRequest ¶
TokenInfoRequest is used to request lookup of the token's metadata.
type TokenInfoResponse ¶
type TokenInfoResponse = coins.ERC20TokenInfo
TokenInfoResponse contains the metadata for the requested token