github.com/status-im/status-go@v1.1.0/eth-node/types/rpc.go (about) 1 package types 2 3 import ( 4 "context" 5 ) 6 7 // NewMessage represents a new whisper message that is posted through the RPC. 8 type NewMessage struct { 9 SymKeyID string `json:"symKeyID"` 10 PublicKey []byte `json:"pubKey"` 11 SigID string `json:"sig"` 12 TTL uint32 `json:"ttl"` 13 PubsubTopic string `json:"pubsubTopic"` 14 Topic TopicType `json:"topic"` 15 Payload []byte `json:"payload"` 16 Padding []byte `json:"padding"` 17 PowTime uint32 `json:"powTime"` 18 PowTarget float64 `json:"powTarget"` 19 TargetPeer string `json:"targetPeer"` 20 Ephemeral bool `json:"ephemeral"` 21 Priority *int `json:"priority"` 22 } 23 24 // Message is the RPC representation of a whisper message. 25 type Message struct { 26 Sig []byte `json:"sig,omitempty"` 27 TTL uint32 `json:"ttl"` 28 Timestamp uint32 `json:"timestamp"` 29 PubsubTopic string `json:"pubsubTopic"` 30 Topic TopicType `json:"topic"` 31 Payload []byte `json:"payload"` 32 Padding []byte `json:"padding"` 33 PoW float64 `json:"pow"` 34 Hash []byte `json:"hash"` 35 Dst []byte `json:"recipientPublicKey,omitempty"` 36 P2P bool `json:"bool,omitempty"` 37 ThirdPartyID string `json:"thirdPartyId,omitempty"` 38 } 39 40 // Criteria holds various filter options for inbound messages. 41 type Criteria struct { 42 SymKeyID string `json:"symKeyID"` 43 PrivateKeyID string `json:"privateKeyID"` 44 Sig []byte `json:"sig"` 45 MinPow float64 `json:"minPow"` 46 PubsubTopic string `json:"pubsubTopic"` 47 Topics []TopicType `json:"topics"` 48 AllowP2P bool `json:"allowP2P"` 49 } 50 51 // PublicWhisperAPI provides the whisper RPC service that can be 52 // use publicly without security implications. 53 type PublicWhisperAPI interface { 54 // AddPrivateKey imports the given private key. 55 AddPrivateKey(ctx context.Context, privateKey HexBytes) (string, error) 56 // GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID. 57 GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error) 58 // DeleteKeyPair removes the key with the given key if it exists. 59 DeleteKeyPair(ctx context.Context, key string) (bool, error) 60 61 // Post posts a message on the Whisper network. 62 // returns the hash of the message in case of success. 63 Post(ctx context.Context, req NewMessage) ([]byte, error) 64 65 // NewMessageFilter creates a new filter that can be used to poll for 66 // (new) messages that satisfy the given criteria. 67 NewMessageFilter(req Criteria) (string, error) 68 // GetFilterMessages returns the messages that match the filter criteria and 69 // are received between the last poll and now. 70 GetFilterMessages(id string) ([]*Message, error) 71 // BloomFilter returns the current bloomfilter of the node 72 BloomFilter() []byte 73 } 74 75 // PublicWakuAPI provides the waku RPC service that can be 76 // use publicly without security implications. 77 type PublicWakuAPI interface { 78 // AddPrivateKey imports the given private key. 79 AddPrivateKey(ctx context.Context, privateKey HexBytes) (string, error) 80 // GenerateSymKeyFromPassword derives a key from the given password, stores it, and returns its ID. 81 GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error) 82 // DeleteKeyPair removes the key with the given key if it exists. 83 DeleteKeyPair(ctx context.Context, key string) (bool, error) 84 85 // Post posts a message on the Whisper network. 86 // returns the hash of the message in case of success. 87 Post(ctx context.Context, req NewMessage) ([]byte, error) 88 89 // NewMessageFilter creates a new filter that can be used to poll for 90 // (new) messages that satisfy the given criteria. 91 NewMessageFilter(req Criteria) (string, error) 92 // GetFilterMessages returns the messages that match the filter criteria and 93 // are received between the last poll and now. 94 GetFilterMessages(id string) ([]*Message, error) 95 96 BloomFilter() []byte 97 }