Electroneum
message_transporter.h
Go to the documentation of this file.
1 // Copyright (c) 2018, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #pragma once
36 #include "net/http_client.h"
37 #include "common/util.h"
38 #include "wipeable_string.h"
40 #include <vector>
41 
42 namespace mms
43 {
44 
46 {
51  crypto::chacha_iv iv;
62 
80 };
81 typedef epee::misc_utils::struct_init<transport_message_t> transport_message;
82 
84 {
85 public:
87  void set_options(const std::string &bitmessage_address, const epee::wipeable_string &bitmessage_login);
88  bool send_message(const transport_message &message);
89  bool receive_messages(const std::vector<std::string> &destination_transport_addresses,
90  std::vector<transport_message> &messages);
91  bool delete_message(const std::string &transport_id);
92  void stop() { m_run.store(false, std::memory_order_relaxed); }
93  std::string derive_transport_address(const std::string &seed);
94  std::string derive_and_receive_transport_address(const std::string &seed);
95  bool delete_transport_address(const std::string &transport_address);
96 
97 private:
99  std::string m_bitmessage_url;
100  epee::wipeable_string m_bitmessage_login;
101  std::atomic<bool> m_run;
102 
103  bool post_request(const std::string &request, std::string &answer);
104  static std::string get_str_between_tags(const std::string &s, const std::string &start_delim, const std::string &stop_delim);
105 
106  static void start_xml_rpc_cmd(std::string &xml, const std::string &method_name);
107  static void add_xml_rpc_string_param(std::string &xml, const std::string &param);
108  static void add_xml_rpc_base64_param(std::string &xml, const std::string &param);
109  static void add_xml_rpc_integer_param(std::string &xml, const int32_t &param);
110  static void end_xml_rpc_cmd(std::string &xml);
111 
112 };
113 
114 }
std::string destination_transport_address
cryptonote::account_public_address source_etn_address
::std::string string
Definition: gtest-port.h:1097
#define KV_SERIALIZE(varialble)
crypto::public_key encryption_public_key
unsigned int uint32_t
Definition: stdint.h:126
unsigned __int64 uint64_t
Definition: stdint.h:136
#define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble)
cryptonote::account_public_address destination_etn_address
POD_CLASS public_key
Definition: crypto.h:76
POD_CLASS signature
Definition: crypto.h:108
POD_CLASS hash
Definition: hash.h:50
#define END_KV_SERIALIZE_MAP()
signed int int32_t
Definition: stdint.h:123
#define BEGIN_KV_SERIALIZE_MAP()