message

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: 10 Imported by: 0

Documentation

Overview

Package message provides the types for messages that are sent between swapd instances.

Index

Constants

View Source
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

func DecodeMessage(b []byte) (common.Message, error)

DecodeMessage decodes the given bytes into a Message

func TypeToString

func TypeToString(t byte) string

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

func (m *NotifyETHLocked) String() string

String ...

func (*NotifyETHLocked) Type

func (m *NotifyETHLocked) Type() byte

Type implements the Type() method of the common.Message interface

type QueryResponse

type QueryResponse struct {
	Offers []*types.Offer `json:"offers" validate:"dive,required"`
}

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

func (m *QueryResponse) String() string

String ...

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

func (m *SendKeysMessage) String() string

String ...

func (*SendKeysMessage) Type

func (m *SendKeysMessage) Type() byte

Type implements the Type() method of the common.Message interface

Jump to

Keyboard shortcuts

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