2019-11-23 17:57:05 +00:00
|
|
|
package types
|
2019-10-09 14:22:53 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewMessage represents a new whisper message that is posted through the RPC.
|
|
|
|
type NewMessage struct {
|
2023-05-22 21:38:02 +00:00
|
|
|
SymKeyID string `json:"symKeyID"`
|
|
|
|
PublicKey []byte `json:"pubKey"`
|
|
|
|
SigID string `json:"sig"`
|
|
|
|
TTL uint32 `json:"ttl"`
|
|
|
|
PubsubTopic string `json:"pubsubTopic"`
|
|
|
|
Topic TopicType `json:"topic"`
|
|
|
|
Payload []byte `json:"payload"`
|
|
|
|
Padding []byte `json:"padding"`
|
|
|
|
PowTime uint32 `json:"powTime"`
|
|
|
|
PowTarget float64 `json:"powTarget"`
|
|
|
|
TargetPeer string `json:"targetPeer"`
|
|
|
|
Ephemeral bool `json:"ephemeral"`
|
2024-08-01 18:36:25 +00:00
|
|
|
Priority *int `json:"priority"`
|
2019-10-09 14:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Message is the RPC representation of a whisper message.
|
|
|
|
type Message struct {
|
2022-09-28 12:45:34 +00:00
|
|
|
Sig []byte `json:"sig,omitempty"`
|
|
|
|
TTL uint32 `json:"ttl"`
|
|
|
|
Timestamp uint32 `json:"timestamp"`
|
2023-05-22 21:38:02 +00:00
|
|
|
PubsubTopic string `json:"pubsubTopic"`
|
2022-09-28 12:45:34 +00:00
|
|
|
Topic TopicType `json:"topic"`
|
|
|
|
Payload []byte `json:"payload"`
|
|
|
|
Padding []byte `json:"padding"`
|
|
|
|
PoW float64 `json:"pow"`
|
|
|
|
Hash []byte `json:"hash"`
|
|
|
|
Dst []byte `json:"recipientPublicKey,omitempty"`
|
|
|
|
P2P bool `json:"bool,omitempty"`
|
|
|
|
ThirdPartyID string `json:"thirdPartyId,omitempty"`
|
2019-10-09 14:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Criteria holds various filter options for inbound messages.
|
|
|
|
type Criteria struct {
|
|
|
|
SymKeyID string `json:"symKeyID"`
|
|
|
|
PrivateKeyID string `json:"privateKeyID"`
|
|
|
|
Sig []byte `json:"sig"`
|
|
|
|
MinPow float64 `json:"minPow"`
|
2023-05-22 21:38:02 +00:00
|
|
|
PubsubTopic string `json:"pubsubTopic"`
|
2019-10-09 14:22:53 +00:00
|
|
|
Topics []TopicType `json:"topics"`
|
|
|
|
AllowP2P bool `json:"allowP2P"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// PublicWhisperAPI provides the whisper RPC service that can be
|
|
|
|
// use publicly without security implications.
|
|
|
|
type PublicWhisperAPI interface {
|
|
|
|
// AddPrivateKey imports the given private key.
|
2019-11-23 17:57:05 +00:00
|
|
|
AddPrivateKey(ctx context.Context, privateKey HexBytes) (string, error)
|
2019-10-09 14:22:53 +00:00
|
|
|
// GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID.
|
|
|
|
GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
|
|
|
|
// DeleteKeyPair removes the key with the given key if it exists.
|
|
|
|
DeleteKeyPair(ctx context.Context, key string) (bool, error)
|
|
|
|
|
|
|
|
// Post posts a message on the Whisper network.
|
|
|
|
// returns the hash of the message in case of success.
|
|
|
|
Post(ctx context.Context, req NewMessage) ([]byte, error)
|
|
|
|
|
|
|
|
// NewMessageFilter creates a new filter that can be used to poll for
|
|
|
|
// (new) messages that satisfy the given criteria.
|
|
|
|
NewMessageFilter(req Criteria) (string, error)
|
|
|
|
// GetFilterMessages returns the messages that match the filter criteria and
|
|
|
|
// are received between the last poll and now.
|
|
|
|
GetFilterMessages(id string) ([]*Message, error)
|
2021-08-26 20:25:43 +00:00
|
|
|
// BloomFilter returns the current bloomfilter of the node
|
|
|
|
BloomFilter() []byte
|
2019-10-09 14:22:53 +00:00
|
|
|
}
|
2020-01-13 19:17:30 +00:00
|
|
|
|
|
|
|
// PublicWakuAPI provides the waku RPC service that can be
|
|
|
|
// use publicly without security implications.
|
|
|
|
type PublicWakuAPI interface {
|
|
|
|
// AddPrivateKey imports the given private key.
|
|
|
|
AddPrivateKey(ctx context.Context, privateKey HexBytes) (string, error)
|
|
|
|
// GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID.
|
|
|
|
GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
|
|
|
|
// DeleteKeyPair removes the key with the given key if it exists.
|
|
|
|
DeleteKeyPair(ctx context.Context, key string) (bool, error)
|
|
|
|
|
|
|
|
// Post posts a message on the Whisper network.
|
|
|
|
// returns the hash of the message in case of success.
|
|
|
|
Post(ctx context.Context, req NewMessage) ([]byte, error)
|
|
|
|
|
|
|
|
// NewMessageFilter creates a new filter that can be used to poll for
|
|
|
|
// (new) messages that satisfy the given criteria.
|
|
|
|
NewMessageFilter(req Criteria) (string, error)
|
|
|
|
// GetFilterMessages returns the messages that match the filter criteria and
|
|
|
|
// are received between the last poll and now.
|
|
|
|
GetFilterMessages(id string) ([]*Message, error)
|
2021-08-26 20:25:43 +00:00
|
|
|
|
|
|
|
BloomFilter() []byte
|
2020-01-13 19:17:30 +00:00
|
|
|
}
|