protocol

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MPL-2.0 Imports: 42 Imported by: 2

README

status-go/protocol

This is the Status Protocol implementation in Go.

TBD

Documentation

Index

Constants

View Source
const (
	OutgoingStatusSending = "sending"
	OutgoingStatusSent    = "sent"
)
View Source
const PubKeyStringLength = 132

Variables

View Source
var (
	ErrChatIDEmpty    = errors.New("chat ID is empty")
	ErrNotImplemented = errors.New("not implemented")
)
View Source
var (
	// ErrMsgAlreadyExist returned if msg already exist.
	ErrMsgAlreadyExist = errors.New("message with given ID already exist")
)

Functions

func GenerateAlias

func GenerateAlias(id string) (string, error)

GenerateAlias name returns the generated name given a public key hex encoded prefixed with 0x

func Identicon

func Identicon(id string) (string, error)

Identicon returns an identicon based on the input string

func ValidateReceivedAcceptRequestAddressForTransaction added in v1.1.1

func ValidateReceivedAcceptRequestAddressForTransaction(message *protobuf.AcceptRequestAddressForTransaction) error

func ValidateReceivedChatMessage added in v1.0.2

func ValidateReceivedChatMessage(message *protobuf.ChatMessage) error

func ValidateReceivedDeclineRequestAddressForTransaction added in v1.1.1

func ValidateReceivedDeclineRequestAddressForTransaction(message *protobuf.DeclineRequestAddressForTransaction) error

func ValidateReceivedDeclineRequestTransaction added in v1.1.1

func ValidateReceivedDeclineRequestTransaction(message *protobuf.DeclineRequestTransaction) error

func ValidateReceivedPairInstallation added in v1.1.1

func ValidateReceivedPairInstallation(message *protobuf.PairInstallation) error

func ValidateReceivedRequestAddressForTransaction added in v1.1.1

func ValidateReceivedRequestAddressForTransaction(message *protobuf.RequestAddressForTransaction) error

func ValidateReceivedRequestTransaction added in v1.1.1

func ValidateReceivedRequestTransaction(message *protobuf.RequestTransaction) error

func ValidateReceivedSendTransaction added in v1.1.1

func ValidateReceivedSendTransaction(message *protobuf.SendTransaction) error

func WithDatasync

func WithDatasync() func(c *config) error

Types

type Chat

type Chat struct {
	// ID is the id of the chat, for public chats it is the name e.g. status, for one-to-one
	// is the hex encoded public key and for group chats is a random uuid appended with
	// the hex encoded pk of the creator of the chat
	ID    string `json:"id"`
	Name  string `json:"name"`
	Color string `json:"color"`
	// Active indicates whether the chat has been soft deleted
	Active bool `json:"active"`

	ChatType ChatType `json:"chatType"`

	// Timestamp indicates the last time this chat has received/sent a message
	Timestamp int64 `json:"timestamp"`
	// LastClockValue indicates the last clock value to be used when sending messages
	LastClockValue uint64 `json:"lastClockValue"`
	// DeletedAtClockValue indicates the clock value at time of deletion, messages
	// with lower clock value of this should be discarded
	DeletedAtClockValue uint64 `json:"deletedAtClockValue"`

	// Denormalized fields
	UnviewedMessagesCount uint   `json:"unviewedMessagesCount"`
	LastMessage           []byte `json:"lastMessage"`

	// Group chat fields
	// Members are the members who have been invited to the group chat
	Members []ChatMember `json:"members"`
	// MembershipUpdates is all the membership events in the chat
	MembershipUpdates []v1protocol.MembershipUpdateEvent `json:"membershipUpdateEvents"`
}

func CreateOneToOneChat

func CreateOneToOneChat(name string, publicKey *ecdsa.PublicKey) Chat

func CreatePublicChat

func CreatePublicChat(name string) Chat

func OneToOneFromPublicKey added in v1.1.1

func OneToOneFromPublicKey(pk *ecdsa.PublicKey) *Chat

func (*Chat) MarshalJSON added in v1.0.0

func (c *Chat) MarshalJSON() ([]byte, error)

func (*Chat) MembersAsPublicKeys

func (c *Chat) MembersAsPublicKeys() ([]*ecdsa.PublicKey, error)

func (*Chat) NextClockAndTimestamp added in v1.1.1

func (c *Chat) NextClockAndTimestamp() (uint64, uint64)

NextClockAndTimestamp returns the next clock value and the current timestamp

func (*Chat) PublicKey

func (c *Chat) PublicKey() (*ecdsa.PublicKey, error)

func (*Chat) UnmarshalJSON added in v1.0.0

func (c *Chat) UnmarshalJSON(data []byte) error

func (*Chat) UpdateFromMessage added in v1.1.1

func (c *Chat) UpdateFromMessage(message *Message) error

type ChatMember

type ChatMember struct {
	// ID is the hex encoded public key of the member
	ID string `json:"id"`
	// Admin indicates if the member is an admin of the group chat
	Admin bool `json:"admin"`
	// Joined indicates if the member has joined the group chat
	Joined bool `json:"joined"`
}

ChatMember represents a member who participates in a group chat

func (ChatMember) PublicKey

func (c ChatMember) PublicKey() (*ecdsa.PublicKey, error)

type ChatMembershipUpdate

type ChatMembershipUpdate struct {
	// Unique identifier for the event
	ID string `json:"id"`
	// Type indicates the kind of event
	Type protobuf.MembershipUpdateEvent_EventType `json:"type"`
	// Name represents the name in the event of changing name events
	Name string `json:"name,omitempty"`
	// Clock value of the event
	ClockValue uint64 `json:"clockValue"`
	// Signature of the event
	Signature string `json:"signature"`
	// Hex encoded public key of the creator of the event
	From string `json:"from"`
	// Target of the event for single-target events
	Member string `json:"member,omitempty"`
	// Target of the event for multi-target events
	Members []string `json:"members,omitempty"`
}

ChatMembershipUpdate represent an event on membership of the chat

type ChatType

type ChatType int
const (
	ChatTypeOneToOne ChatType = iota + 1
	ChatTypePublic
	ChatTypePrivateGroupChat
)

type CommandParameters added in v1.1.1

type CommandParameters struct {
	// ID is the ID of the initial message
	ID string `json:"id"`
	// From is the address we are sending the command from
	From string `json:"from"`
	// Address is the address sent with the command
	Address string `json:"address"`
	// Contract is the contract address for ERC20 tokens
	Contract string `json:"contract"`
	// Value is the value as a string sent
	Value string `json:"value"`
	// TransactionHash is the hash of the transaction
	TransactionHash string `json:"transactionHash"`
	// CommandState is the state of the command
	CommandState CommandState `json:"commandState"`
	// The Signature of the pk-bytes+transaction-hash from the wallet
	// address originating
	Signature []byte `json:"signature"`
}

func (*CommandParameters) IsTokenTransfer added in v1.1.1

func (c *CommandParameters) IsTokenTransfer() bool

type CommandState added in v1.1.1

type CommandState int
const (
	CommandStateRequestAddressForTransaction CommandState = iota + 1
	CommandStateRequestAddressForTransactionDeclined
	CommandStateRequestAddressForTransactionAccepted
	CommandStateRequestTransaction
	CommandStateRequestTransactionDeclined
	CommandStateTransactionPending
	CommandStateTransactionSent
)

type Contact

type Contact struct {
	// ID of the contact. It's a hex-encoded public key (prefixed with 0x).
	ID string `json:"id"`
	// Ethereum address of the contact
	Address string `json:"address"`
	// ENS name of contact
	Name string `json:"name,omitempty"`
	// EnsVerified whether we verified the name of the contact
	ENSVerified bool `json:"ensVerified"`
	// EnsVerifiedAt the time we last verified the name
	ENSVerifiedAt int64 `json:"ensVerifiedAt"`
	// Generated username name of the contact
	Alias string `json:"alias,omitempty"`
	// Identicon generated from public key
	Identicon string `json:"identicon"`
	// Photo is the base64 encoded photo
	Photo string `json:"photoPath,omitempty"`
	// LastUpdated is the last time we received an update from the contact
	// updates should be discarded if last updated is less than the one stored
	LastUpdated uint64 `json:"lastUpdated"`
	// SystemTags contains information about whether we blocked/added/have been
	// added.
	SystemTags []string `json:"systemTags"`

	DeviceInfo    []ContactDeviceInfo `json:"deviceInfo"`
	TributeToTalk string              `json:"tributeToTalk"`
}

Contact has information about a "Contact". A contact is not necessarily one that we added or added us, that's based on SystemTags.

func (Contact) HasBeenAdded

func (c Contact) HasBeenAdded() bool

func (Contact) IsAdded

func (c Contact) IsAdded() bool

func (Contact) IsBlocked

func (c Contact) IsBlocked() bool

func (Contact) PublicKey

func (c Contact) PublicKey() (*ecdsa.PublicKey, error)

type ContactDeviceInfo

type ContactDeviceInfo struct {
	// The installation id of the device
	InstallationID string `json:"id"`
	// Timestamp represents the last time we received this info
	Timestamp int64 `json:"timestamp"`
	// FCMToken is to be used for push notifications
	FCMToken string `json:"fcmToken"`
}

ContactDeviceInfo is a struct containing information about a particular device owned by a contact

type CurrentMessageState added in v1.1.1

type CurrentMessageState struct {
	// Message is the protobuf message received
	Message protobuf.ChatMessage
	// MessageID is the ID of the message
	MessageID string
	// WhisperTimestamp is the whisper timestamp of the message
	WhisperTimestamp uint64
	// Contact is the contact associated with the author of the message
	Contact *Contact
	// PublicKey is the public key of the author of the message
	PublicKey *ecdsa.PublicKey
}

type EthClient added in v1.1.1

type EthClient interface {
	TransactionByHash(context.Context, types.Hash) (coretypes.Message, bool, error)
}

type Message

type Message struct {
	protobuf.ChatMessage

	// ID calculated as keccak256(compressedAuthorPubKey, data) where data is unencrypted payload.
	ID string `json:"id"`
	// WhisperTimestamp is a timestamp of a Whisper envelope.
	WhisperTimestamp uint64 `json:"whisperTimestamp"`
	// From is a public key of the author of the message.
	From string `json:"from"`
	// Random 3 words name
	Alias string `json:"alias"`
	// Identicon of the author
	Identicon string `json:"identicon"`
	// The chat id to be stored locally
	LocalChatID string `json:"localChatId"`

	Seen           bool   `json:"seen"`
	OutgoingStatus string `json:"outgoingStatus,omitempty"`

	QuotedMessage *QuotedMessage `json:"quotedMessage"`

	// CommandParameters is the parameters sent with the message
	CommandParameters *CommandParameters `json:"commandParameters"`

	// Computed fields
	RTL        bool   `json:"rtl"`
	ParsedText []byte `json:"parsedText"`
	LineCount  int    `json:"lineCount"`

	// Replace indicates that this is a replacement of a message
	// that has been updated
	Replace   string           `json:"replace,omitEmpty"`
	SigPubKey *ecdsa.PublicKey `json:"-"`
}

Message represents a message record in the database, more specifically in user_messages table.

func (*Message) MarshalJSON added in v1.0.0

func (m *Message) MarshalJSON() ([]byte, error)

func (*Message) PrepareContent added in v1.0.0

func (m *Message) PrepareContent() error

PrepareContent return the parsed content of the message, the line-count and whether is a right-to-left message

func (*Message) UnmarshalJSON added in v1.0.0

func (m *Message) UnmarshalJSON(data []byte) error

type MessageHandler added in v1.1.1

type MessageHandler struct {
	// contains filtered or unexported fields
}

func (*MessageHandler) HandleAcceptRequestAddressForTransaction added in v1.1.1

func (m *MessageHandler) HandleAcceptRequestAddressForTransaction(messageState *ReceivedMessageState, command protobuf.AcceptRequestAddressForTransaction) error

func (*MessageHandler) HandleChatMessage added in v1.1.1

func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error

func (*MessageHandler) HandleContactUpdate added in v1.1.1

func (m *MessageHandler) HandleContactUpdate(state *ReceivedMessageState, message protobuf.ContactUpdate) error

func (*MessageHandler) HandleDeclineRequestAddressForTransaction added in v1.1.1

func (m *MessageHandler) HandleDeclineRequestAddressForTransaction(messageState *ReceivedMessageState, command protobuf.DeclineRequestAddressForTransaction) error

func (*MessageHandler) HandleDeclineRequestTransaction added in v1.1.1

func (m *MessageHandler) HandleDeclineRequestTransaction(messageState *ReceivedMessageState, command protobuf.DeclineRequestTransaction) error

func (*MessageHandler) HandleMembershipUpdate added in v1.1.1

func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageState, chat *Chat, rawMembershipUpdate protobuf.MembershipUpdateMessage, translations map[protobuf.MembershipUpdateEvent_EventType]string) error

HandleMembershipUpdate updates a Chat instance according to the membership updates. It retrieves chat, if exists, and merges membership updates from the message. Finally, the Chat is updated with the new group events.

func (*MessageHandler) HandlePairInstallation added in v1.1.1

func (m *MessageHandler) HandlePairInstallation(state *ReceivedMessageState, message protobuf.PairInstallation) error

func (*MessageHandler) HandleRequestAddressForTransaction added in v1.1.1

func (m *MessageHandler) HandleRequestAddressForTransaction(messageState *ReceivedMessageState, command protobuf.RequestAddressForTransaction) error

func (*MessageHandler) HandleRequestTransaction added in v1.1.1

func (m *MessageHandler) HandleRequestTransaction(messageState *ReceivedMessageState, command protobuf.RequestTransaction) error

func (*MessageHandler) HandleSendTransaction added in v1.1.1

func (m *MessageHandler) HandleSendTransaction(messageState *ReceivedMessageState, command protobuf.SendTransaction) error

func (*MessageHandler) HandleSyncInstallationContact added in v1.1.1

func (m *MessageHandler) HandleSyncInstallationContact(state *ReceivedMessageState, message protobuf.SyncInstallationContact) error

type Messenger

type Messenger struct {
	// contains filtered or unexported fields
}

Messenger is a entity managing chats and messages. It acts as a bridge between the application and encryption layers. It needs to expose an interface to manage installations because installations are managed by the user. Similarly, it needs to expose an interface to manage mailservers because they can also be managed by the user.

func NewMessenger

func NewMessenger(
	identity *ecdsa.PrivateKey,
	node types.Node,
	installationID string,
	opts ...Option,
) (*Messenger, error)

func (*Messenger) AcceptRequestAddressForTransaction added in v1.1.1

func (m *Messenger) AcceptRequestAddressForTransaction(ctx context.Context, messageID, address string) (*MessengerResponse, error)

func (*Messenger) AcceptRequestTransaction added in v1.1.1

func (m *Messenger) AcceptRequestTransaction(ctx context.Context, transactionHash, messageID string, signature []byte) (*MessengerResponse, error)

func (*Messenger) AddAdminsToGroupChat added in v1.0.2

func (m *Messenger) AddAdminsToGroupChat(ctx context.Context, chatID string, members []string) (*MessengerResponse, error)

func (*Messenger) AddMailserver

func (m *Messenger) AddMailserver(enode string) error

NOT IMPLEMENTED

func (*Messenger) AddMembersToGroupChat added in v1.0.2

func (m *Messenger) AddMembersToGroupChat(ctx context.Context, chatID string, members []string) (*MessengerResponse, error)

func (*Messenger) BlockContact

func (m *Messenger) BlockContact(contact *Contact) ([]*Chat, error)

func (*Messenger) Chats

func (m *Messenger) Chats() []*Chat

func (*Messenger) ConfirmJoiningGroup

func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chatID string) (*MessengerResponse, error)

func (*Messenger) ConfirmMessagesProcessed

func (m *Messenger) ConfirmMessagesProcessed(messageIDs [][]byte) error

DEPRECATED

func (*Messenger) Contacts

func (m *Messenger) Contacts() []*Contact

func (*Messenger) CreateGroupChatWithMembers added in v1.0.2

func (m *Messenger) CreateGroupChatWithMembers(ctx context.Context, name string, members []string) (*MessengerResponse, error)

func (*Messenger) DeclineRequestAddressForTransaction added in v1.1.1

func (m *Messenger) DeclineRequestAddressForTransaction(ctx context.Context, messageID string) (*MessengerResponse, error)

func (*Messenger) DeclineRequestTransaction added in v1.1.1

func (m *Messenger) DeclineRequestTransaction(ctx context.Context, messageID string) (*MessengerResponse, error)

func (*Messenger) DeleteChat

func (m *Messenger) DeleteChat(chatID string) error

func (*Messenger) DeleteMessage

func (m *Messenger) DeleteMessage(id string) error

DEPRECATED: required by status-react.

func (*Messenger) DeleteMessagesByChatID

func (m *Messenger) DeleteMessagesByChatID(id string) error

DEPRECATED: required by status-react.

func (*Messenger) DisableInstallation

func (m *Messenger) DisableInstallation(id string) error

func (*Messenger) EnableInstallation

func (m *Messenger) EnableInstallation(id string) error

func (*Messenger) Init

func (m *Messenger) Init() error

Init analyzes chats and contacts in order to setup filters which are responsible for retrieving messages.

func (*Messenger) Installations

func (m *Messenger) Installations() []*multidevice.Installation

func (*Messenger) Join

func (m *Messenger) Join(chat Chat) error

func (*Messenger) Leave

func (m *Messenger) Leave(chat Chat) error

This is not accurate, it should not leave transport on removal of chat/group only once there is no more: Group chat with that member, one-to-one chat, contact added by us

func (*Messenger) LeaveGroupChat added in v1.0.2

func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string) (*MessengerResponse, error)

func (*Messenger) LoadFilters

func (m *Messenger) LoadFilters(filters []*transport.Filter) ([]*transport.Filter, error)

DEPRECATED

func (*Messenger) Mailservers

func (m *Messenger) Mailservers() ([]string, error)

NOT IMPLEMENTED

func (*Messenger) MarkMessagesSeen

func (m *Messenger) MarkMessagesSeen(chatID string, ids []string) error

DEPRECATED: required by status-react.

func (*Messenger) MessageByChatID

func (m *Messenger) MessageByChatID(chatID, cursor string, limit int) ([]*Message, string, error)

DEPRECATED: required by status-react.

func (*Messenger) MessageByID

func (m *Messenger) MessageByID(id string) (*Message, error)

DEPRECATED: required by status-react.

func (*Messenger) MessagesExist

func (m *Messenger) MessagesExist(ids []string) (map[string]bool, error)

DEPRECATED: required by status-react.

func (*Messenger) ReSendChatMessage added in v1.0.0

func (m *Messenger) ReSendChatMessage(ctx context.Context, messageID string) error

ReSendChatMessage pulls a message from the database and sends it again

func (*Messenger) RemoveFilters

func (m *Messenger) RemoveFilters(filters []*transport.Filter) error

DEPRECATED

func (*Messenger) RemoveMailserver

func (m *Messenger) RemoveMailserver(id string) error

NOT IMPLEMENTED

func (*Messenger) RemoveMemberFromGroupChat added in v1.0.2

func (m *Messenger) RemoveMemberFromGroupChat(ctx context.Context, chatID string, member string) (*MessengerResponse, error)

func (*Messenger) RequestAddressForTransaction added in v1.1.1

func (m *Messenger) RequestAddressForTransaction(ctx context.Context, chatID, from, value, contract string) (*MessengerResponse, error)

func (*Messenger) RequestHistoricMessages

func (m *Messenger) RequestHistoricMessages(
	ctx context.Context,
	peer []byte,
	from, to uint32,
	cursor []byte,
) ([]byte, error)

func (*Messenger) RequestTransaction added in v1.1.1

func (m *Messenger) RequestTransaction(ctx context.Context, chatID, value, contract, address string) (*MessengerResponse, error)

func (*Messenger) RetrieveAll

func (m *Messenger) RetrieveAll() (*MessengerResponse, error)

RetrieveAll retrieves messages from all filters, processes them and returns a MessengerResponse to the client

func (*Messenger) SaveChat

func (m *Messenger) SaveChat(chat *Chat) error

func (*Messenger) SaveContact

func (m *Messenger) SaveContact(contact *Contact) error

func (*Messenger) SaveMessages

func (m *Messenger) SaveMessages(messages []*Message) error

DEPRECATED: required by status-react.

func (*Messenger) SelectMailserver

func (m *Messenger) SelectMailserver(id string) error

NOT IMPLEMENTED

func (*Messenger) SendChatMessage added in v1.0.0

func (m *Messenger) SendChatMessage(ctx context.Context, message *Message) (*MessengerResponse, error)

SendChatMessage takes a minimal message and sends it based on the corresponding chat

func (*Messenger) SendContactUpdate added in v1.1.1

func (m *Messenger) SendContactUpdate(ctx context.Context, chatID, ensName, profileImage string) (*MessengerResponse, error)

SendContactUpdate sends a contact update to a user and adds the user to contacts

func (*Messenger) SendContactUpdates added in v1.1.1

func (m *Messenger) SendContactUpdates(ctx context.Context, ensName, profileImage string) error

Send contact updates to all contacts added by us

func (*Messenger) SendPairInstallation added in v1.1.1

func (m *Messenger) SendPairInstallation(ctx context.Context) (*MessengerResponse, error)

SendPairInstallation sends a pair installation message

func (*Messenger) SendRaw

func (m *Messenger) SendRaw(ctx context.Context, chat Chat, data []byte) ([]byte, error)

SendRaw takes encoded data, encrypts it and sends through the wire. DEPRECATED

func (*Messenger) SendTransaction added in v1.1.1

func (m *Messenger) SendTransaction(ctx context.Context, chatID, transactionHash string, signature []byte) (*MessengerResponse, error)

func (*Messenger) SetInstallationMetadata

func (m *Messenger) SetInstallationMetadata(id string, data *multidevice.InstallationMetadata) error

func (*Messenger) Shutdown

func (m *Messenger) Shutdown() (err error)

Shutdown takes care of ensuring a clean shutdown of Messenger

func (*Messenger) UpdateMessageOutgoingStatus

func (m *Messenger) UpdateMessageOutgoingStatus(id, newOutgoingStatus string) error

DEPRECATED: required by status-react.

func (*Messenger) ValidateTransactions added in v1.1.1

func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.Address) (*MessengerResponse, error)

func (*Messenger) VerifyENSNames

func (m *Messenger) VerifyENSNames(rpcEndpoint, contractAddress string, ensDetails []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, error)

VerifyENSNames verifies that a registered ENS name matches the expected public key

type MessengerResponse added in v1.0.0

type MessengerResponse struct {
	Chats         []*Chat                     `json:"chats,omitEmpty"`
	Messages      []*Message                  `json:"messages,omitEmpty"`
	Contacts      []*Contact                  `json:"contacts,omitEmpty"`
	Installations []*multidevice.Installation `json:"installations,omitEmpty"`
	// Raw unprocessed messages
	RawMessages []*RawResponse `json:"rawMessages,omitEmpty"`
}

func (*MessengerResponse) IsEmpty added in v1.0.0

func (m *MessengerResponse) IsEmpty() bool

type Option

type Option func(*config) error

func WithCustomLogger

func WithCustomLogger(logger *zap.Logger) Option

func WithDatabase

func WithDatabase(db *sql.DB) Option

func WithDatabaseConfig

func WithDatabaseConfig(dbPath, dbKey string) Option

func WithEnvelopesMonitorConfig

func WithEnvelopesMonitorConfig(emc *transport.EnvelopesMonitorConfig) Option

func WithMessagesPersistenceEnabled

func WithMessagesPersistenceEnabled() Option

func WithOnNegotiatedFilters

func WithOnNegotiatedFilters(h func([]*transport.Filter)) Option

func WithSystemMessagesTranslations added in v1.0.2

func WithSystemMessagesTranslations(t map[protobuf.MembershipUpdateEvent_EventType]string) Option

func WithVerifyTransactionClient added in v1.1.1

func WithVerifyTransactionClient(client EthClient) Option

type QuotedMessage

type QuotedMessage struct {
	// From is a public key of the author of the message.
	From string `json:"from"`
	Text string `json:"text"`
}

QuotedMessage contains the original text of the message replied to

type RawMessage added in v1.1.1

type RawMessage struct {
	ID                  string
	LocalChatID         string
	LastSent            uint64
	SendCount           int
	Sent                bool
	ResendAutomatically bool
	MessageType         protobuf.ApplicationMetadataMessage_Type
	Payload             []byte
	Recipients          []*ecdsa.PublicKey
}

RawMessage represent a sent or received message, kept for being able to re-send/propagate

type RawResponse added in v1.0.0

type RawResponse struct {
	Filter   *transport.Filter           `json:"filter"`
	Messages []*v1protocol.StatusMessage `json:"messages"`
}

type ReceivedMessageState added in v1.0.2

type ReceivedMessageState struct {
	// State on the message being processed
	CurrentMessageState *CurrentMessageState
	// AllChats in memory
	AllChats map[string]*Chat
	// List of chats modified
	ModifiedChats map[string]bool
	// All contacts in memory
	AllContacts map[string]*Contact
	// List of contacs modified
	ModifiedContacts map[string]bool
	// All installations in memory
	AllInstallations map[string]*multidevice.Installation
	// List of installations modified
	ModifiedInstallations map[string]bool
	// Map of existing messages
	ExistingMessagesMap map[string]bool
	// Response to the client
	Response *MessengerResponse
}

type TransactionToValidate added in v1.1.1

type TransactionToValidate struct {
	TransactionHash string
	CommandID       string
	MessageID       string
	RetryCount      int
	// First seen indicates the whisper timestamp of the first time we seen this
	FirstSeen uint64
	// Validate indicates whether we should be validating this transaction
	Validate  bool
	Signature []byte
	From      *ecdsa.PublicKey
}

type TransactionValidator added in v1.1.1

type TransactionValidator struct {
	// contains filtered or unexported fields
}

func NewTransactionValidator added in v1.1.1

func NewTransactionValidator(addresses []types.Address, persistence *sqlitePersistence, client EthClient, logger *zap.Logger) *TransactionValidator

func (*TransactionValidator) ValidateTransaction added in v1.1.1

func (t *TransactionValidator) ValidateTransaction(ctx context.Context, parameters *CommandParameters, from *ecdsa.PublicKey) (*VerifyTransactionResponse, error)

func (*TransactionValidator) ValidateTransactions added in v1.1.1

func (t *TransactionValidator) ValidateTransactions(ctx context.Context) ([]*VerifyTransactionResponse, error)

type VerifyTransactionResponse added in v1.1.1

type VerifyTransactionResponse struct {
	Pending bool
	// AccordingToSpec means that the transaction is valid,
	// the user should be notified, but is not the same as
	// what was requested, for example because the value is different
	AccordingToSpec bool
	// Valid means that the transaction is valid
	Valid bool
	// The actual value received
	Value string
	// The contract used in case of tokens
	Contract string
	// The address the transaction was actually sent
	Address string

	Message     *Message
	Transaction *TransactionToValidate
}

Directories

Path Synopsis
identity
internal
Package sqlite is responsible for creation of encrypted sqlite3 database using sqlcipher driver.
Package sqlite is responsible for creation of encrypted sqlite3 database using sqlcipher driver.
transport

Jump to

Keyboard shortcuts

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