Documentation
¶
Overview ¶
Package message provides the types for messages that are sent between swapd instances.
Index ¶
Constants ¶
const ( Unknown byte = iota // occupies the uninitialized value QueryResponseType RelayerQueryResponseType RelayClaimRequestType RelayClaimResponseType SendKeysType NotifyETHLockedType )
Identifiers for our p2p message types. The first byte of a message has the identifier below telling us which type to decode the JSON message as.
Variables ¶
This section is empty.
Functions ¶
func DecodeMessage ¶
DecodeMessage decodes the given bytes into a Message
func TypeToString ¶
TypeToString converts a message type into a string.
Types ¶
type NotifyETHLocked ¶
type NotifyETHLocked struct {
Address ethcommon.Address `json:"address" validate:"required"`
TxHash types.Hash `json:"txHash" validate:"required"`
ContractSwapID types.Hash `json:"contractSwapID" validate:"required"`
ContractSwap *contracts.SwapCreatorSwap `json:"contractSwap" validate:"required"`
}
NotifyETHLocked is sent by XMRTaker to XMRMaker after deploying the swap contract and locking her ether in it
func (*NotifyETHLocked) Encode ¶
func (m *NotifyETHLocked) Encode() ([]byte, error)
Encode implements the Encode() method of the common.Message interface which prepends a message type byte before the message's JSON encoding.
func (*NotifyETHLocked) Type ¶
func (m *NotifyETHLocked) Type() byte
Type implements the Type() method of the common.Message interface
type QueryResponse ¶
QueryResponse ...
func (*QueryResponse) Encode ¶
func (m *QueryResponse) Encode() ([]byte, error)
Encode implements the Encode() method of the common.Message interface which prepends a message type byte before the message's JSON encoding.
func (*QueryResponse) Type ¶
func (m *QueryResponse) Type() byte
Type implements the Type() method of the common.Message interface
type RelayClaimRequest ¶
type RelayClaimRequest struct {
// OfferID is non-nil, if the request is from a maker to the taker of an
// active swap. It is nil, if the request is being sent to a relay node,
// because it advertised in the DHT.
OfferID *types.Hash `json:"offerID"`
RelaySwap *contracts.SwapCreatorRelaySwap `json:"relaySwap" validate:"required"`
Secret []byte `json:"secret" validate:"required,len=32"`
Signature []byte `json:"signature" validate:"required,len=65"`
}
RelayClaimRequest implements common.Message for our p2p relay claim requests.
func (*RelayClaimRequest) Encode ¶
func (m *RelayClaimRequest) Encode() ([]byte, error)
Encode implements the Encode() method of the common.Message interface which prepends a message type byte before the message's JSON encoding.
func (*RelayClaimRequest) String ¶
func (m *RelayClaimRequest) String() string
String converts the RelayClaimRequest to a string usable for debugging purposes
func (*RelayClaimRequest) Type ¶
func (m *RelayClaimRequest) Type() byte
Type implements the Type() method of the common.Message interface
type RelayClaimResponse ¶
type RelayClaimResponse struct {
TxHash ethcommon.Hash `json:"transactionHash" validate:"required"`
}
RelayClaimResponse implements common.Message for our p2p relay claim responses
func (*RelayClaimResponse) Encode ¶
func (m *RelayClaimResponse) Encode() ([]byte, error)
Encode implements the Encode() method of the common.Message interface which prepends a message type byte before the message's JSON encoding.
func (*RelayClaimResponse) String ¶
func (m *RelayClaimResponse) String() string
String converts the RelayClaimRequest to a string usable for debugging purposes
func (*RelayClaimResponse) Type ¶
func (m *RelayClaimResponse) Type() byte
Type implements the Type() method of the common.Message interface
type RelayerQueryResponse ¶ added in v0.2.1
type RelayerQueryResponse struct {
AddressHash []byte `json:"address" validate:"required,len=32"`
}
RelayerQueryResponse is sent from a relayer to the opener of a /relayerquery/0 stream.
func (*RelayerQueryResponse) Encode ¶ added in v0.2.1
func (m *RelayerQueryResponse) Encode() ([]byte, error)
Encode implements the Encode() method of the common.Message interface which prepends a message type byte before the message's JSON encoding.
func (*RelayerQueryResponse) String ¶ added in v0.2.1
func (m *RelayerQueryResponse) String() string
String converts the RelayerQueryResponse to a string usable for debugging purposes
func (*RelayerQueryResponse) Type ¶ added in v0.2.1
func (m *RelayerQueryResponse) Type() byte
Type implements the Type() method of the common.Message interface
type SendKeysMessage ¶
type SendKeysMessage struct {
OfferID types.Hash `json:"offerID"` // Not set by XMR Maker
ProvidedAmount *apd.Decimal `json:"providedAmount" validate:"required"`
PublicSpendKey *mcrypto.PublicKey `json:"publicSpendKey" validate:"required"`
PrivateViewKey *mcrypto.PrivateViewKey `json:"privateViewKey" validate:"required"`
DLEqProof []byte `json:"dleqProof" validate:"required"`
Secp256k1PublicKey *secp256k1.PublicKey `json:"secp256k1PublicKey" validate:"required"`
EthAddress ethcommon.Address `json:"ethAddress"` // not set by XMR Taker
}
SendKeysMessage is sent by both parties to each other to initiate the protocol
func (*SendKeysMessage) Encode ¶
func (m *SendKeysMessage) Encode() ([]byte, error)
Encode implements the Encode() method of the common.Message interface which prepends a message type byte before the message's JSON encoding.
func (*SendKeysMessage) Type ¶
func (m *SendKeysMessage) Type() byte
Type implements the Type() method of the common.Message interface