diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h index ef131696..2dbec160 100644 --- a/contrib/epee/include/console_handler.h +++ b/contrib/epee/include/console_handler.h @@ -422,7 +422,6 @@ namespace epee std::string get_usage() { std::stringstream ss; - ss << "Commands: " << ENDL; size_t max_command_len = 0; for(auto& x:m_command_handlers) if(x.first.size() > max_command_len) @@ -430,8 +429,7 @@ namespace epee for(auto& x:m_command_handlers) { - ss.width(max_command_len + 3); - ss << " " << std::left << x.first << " " << x.second.second << ENDL; + ss << " " << std::left << std::setw(max_command_len + 3) << x.first << " " << x.second.second << ENDL; } return ss.str(); } diff --git a/contrib/epee/include/storages/portable_storage.h b/contrib/epee/include/storages/portable_storage.h index b9b7aba9..92fbeece 100644 --- a/contrib/epee/include/storages/portable_storage.h +++ b/contrib/epee/include/storages/portable_storage.h @@ -83,7 +83,7 @@ namespace epee bool load_from_binary(const binarybuffer& target); template bool dump_as_xml(std::string& targetObj, const std::string& root_name = ""); - bool dump_as_json(std::string& targetObj, size_t indent = 0); + bool dump_as_json(std::string& targetObj, size_t indent = 0, end_of_line_t eol = eol_crlf); bool load_from_json(const std::string& source); private: @@ -106,11 +106,11 @@ namespace epee #pragma pack(pop) }; inline - bool portable_storage::dump_as_json(std::string& buff, size_t indent) + bool portable_storage::dump_as_json(std::string& buff, size_t indent /* = 0 */, end_of_line_t eol /* = eol_crlf */) { TRY_ENTRY(); std::stringstream ss; - epee::serialization::dump_as_json(ss, m_root, indent); + epee::serialization::dump_as_json(ss, m_root, indent, eol); buff = ss.str(); return true; CATCH_ENTRY("portable_storage::dump_as_json", false) diff --git a/contrib/epee/include/storages/portable_storage_base.h b/contrib/epee/include/storages/portable_storage_base.h index 3f163753..3620dbcc 100644 --- a/contrib/epee/include/storages/portable_storage_base.h +++ b/contrib/epee/include/storages/portable_storage_base.h @@ -69,6 +69,8 @@ namespace epee { namespace serialization { + enum end_of_line_t { eol_crlf = 0, eol_lf = 1, eol_cr = 2, eol_space = 3 }; + struct section; /************************************************************************/ diff --git a/contrib/epee/include/storages/portable_storage_template_helper.h b/contrib/epee/include/storages/portable_storage_template_helper.h index 4f91e081..d7471a51 100644 --- a/contrib/epee/include/storages/portable_storage_template_helper.h +++ b/contrib/epee/include/storages/portable_storage_template_helper.h @@ -56,16 +56,16 @@ namespace epee } //----------------------------------------------------------------------------------------------------------- template - bool store_t_to_json(const t_struct& str_in, std::string& json_buff, size_t indent = 0) + bool store_t_to_json(const t_struct& str_in, std::string& json_buff, size_t indent = 0, end_of_line_t eol = eol_crlf) { portable_storage ps; str_in.store(ps); - ps.dump_as_json(json_buff, indent); + ps.dump_as_json(json_buff, indent, eol); return true; } //----------------------------------------------------------------------------------------------------------- template - std::string store_t_to_json(const t_struct& str_in, size_t indent = 0) + std::string store_t_to_json(const t_struct& str_in, size_t indent = 0, end_of_line_t eol = eol_crlf) { std::string json_buff; store_t_to_json(str_in, json_buff, indent); diff --git a/contrib/epee/include/storages/portable_storage_to_json.h b/contrib/epee/include/storages/portable_storage_to_json.h index 7c22f30c..9cfd9c0a 100644 --- a/contrib/epee/include/storages/portable_storage_to_json.h +++ b/contrib/epee/include/storages/portable_storage_to_json.h @@ -37,23 +37,23 @@ namespace epee { template - void dump_as_json(t_stream& strm, const array_entry& ae, size_t indent); + void dump_as_json(t_stream& strm, const array_entry& ae, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const storage_entry& se, size_t indent); + void dump_as_json(t_stream& strm, const storage_entry& se, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const std::string& v, size_t indent); + void dump_as_json(t_stream& strm, const std::string& v, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const int8_t& v, size_t indent); + void dump_as_json(t_stream& strm, const int8_t& v, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const uint8_t& v, size_t indent); + void dump_as_json(t_stream& strm, const uint8_t& v, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const bool& v, size_t indent); + void dump_as_json(t_stream& strm, const bool& v, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const double& v, size_t indent); + void dump_as_json(t_stream& strm, const double& v, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const t_type& v, size_t indent); + void dump_as_json(t_stream& strm, const t_type& v, size_t indent, end_of_line_t eol = eol_crlf); template - void dump_as_json(t_stream& strm, const section& sec, size_t indent); + void dump_as_json(t_stream& strm, const section& sec, size_t indent, end_of_line_t eol = eol_crlf); inline std::string make_indent(size_t indent) @@ -66,7 +66,13 @@ namespace epee { t_stream& m_strm; size_t m_indent; - array_entry_store_to_json_visitor(t_stream& strm, size_t indent):m_strm(strm), m_indent(indent){} + end_of_line_t m_eol; + + array_entry_store_to_json_visitor(t_stream& strm, size_t indent, end_of_line_t eol) + : m_strm(strm) + , m_indent(indent) + , m_eol(eol) + {} template void operator()(const array_entry_t& a) @@ -77,7 +83,7 @@ namespace epee auto last_it = --a.m_array.end(); for(auto it = a.m_array.begin(); it != a.m_array.end(); it++) { - dump_as_json(m_strm, *it, m_indent); + dump_as_json(m_strm, *it, m_indent, m_eol); if(it != last_it) m_strm << ","; } @@ -91,50 +97,56 @@ namespace epee { t_stream& m_strm; size_t m_indent; - storage_entry_store_to_json_visitor(t_stream& strm, size_t indent):m_strm(strm), m_indent(indent) + end_of_line_t m_eol; + + storage_entry_store_to_json_visitor(t_stream& strm, size_t indent, end_of_line_t eol) + : m_strm(strm) + , m_indent(indent) + , m_eol(eol) {} + //section, array_entry template void operator()(const visited_type& v) { - dump_as_json(m_strm, v, m_indent); + dump_as_json(m_strm, v, m_indent, m_eol); } }; template - void dump_as_json(t_stream& strm, const array_entry& ae, size_t indent) + void dump_as_json(t_stream& strm, const array_entry& ae, size_t indent, end_of_line_t eol) { - array_entry_store_to_json_visitor aesv(strm, indent); + array_entry_store_to_json_visitor aesv(strm, indent, eol); boost::apply_visitor(aesv, ae); } template - void dump_as_json(t_stream& strm, const storage_entry& se, size_t indent) + void dump_as_json(t_stream& strm, const storage_entry& se, size_t indent, end_of_line_t eol) { - storage_entry_store_to_json_visitor sv(strm, indent); + storage_entry_store_to_json_visitor sv(strm, indent, eol); boost::apply_visitor(sv, se); } template - void dump_as_json(t_stream& strm, const std::string& v, size_t indent) + void dump_as_json(t_stream& strm, const std::string& v, size_t indent, end_of_line_t eol) { strm << "\"" << misc_utils::parse::transform_to_json_escape_sequence(v) << "\""; } template - void dump_as_json(t_stream& strm, const int8_t& v, size_t indent) + void dump_as_json(t_stream& strm, const int8_t& v, size_t indent, end_of_line_t eol) { strm << static_cast(v); } template - void dump_as_json(t_stream& strm, const uint8_t& v, size_t indent) + void dump_as_json(t_stream& strm, const uint8_t& v, size_t indent, end_of_line_t eol) { strm << static_cast(v); } template - void dump_as_json(t_stream& strm, const bool& v, size_t indent) + void dump_as_json(t_stream& strm, const bool& v, size_t indent, end_of_line_t eol) { if(v) strm << "true"; @@ -143,23 +155,34 @@ namespace epee } template - void dump_as_json(t_stream& strm, const double& v, size_t indent) + void dump_as_json(t_stream& strm, const double& v, size_t indent, end_of_line_t eol) { strm.precision(8); strm << std::fixed << v; } template - void dump_as_json(t_stream& strm, const t_type& v, size_t /*indent*/) + void dump_as_json(t_stream& strm, const t_type& v, size_t indent, end_of_line_t eol) { strm << v; } template - void dump_as_json(t_stream& strm, const section& sec, size_t indent) + void dump_as_json(t_stream& strm, const section& sec, size_t indent, end_of_line_t eol) { + auto put_eol = [&]() { + switch (eol) + { + case eol_lf: strm << "\n"; break; + case eol_cr: strm << "\r"; break; + case eol_space: strm << " "; break; + default: strm << "\r\n"; break; + } + }; + size_t local_indent = indent + 1; - strm << "{\r\n"; + strm << "{"; + put_eol(); std::string indent_str = make_indent(local_indent); if(sec.m_entries.size()) { @@ -167,10 +190,10 @@ namespace epee for(auto it = sec.m_entries.begin(); it!= sec.m_entries.end();it++) { strm << indent_str << "\"" << misc_utils::parse::transform_to_json_escape_sequence(it->first) << "\"" << ": "; - dump_as_json(strm, it->second, local_indent); + dump_as_json(strm, it->second, local_indent, eol); if(it_last != it) strm << ","; - strm << "\r\n"; + put_eol(); } } strm << make_indent(indent) << "}"; diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h index f66abfcf..e1cb977f 100644 --- a/contrib/epee/include/string_tools.h +++ b/contrib/epee/include/string_tools.h @@ -648,9 +648,6 @@ POP_WARNINGS return res; } //---------------------------------------------------------------------------- - - - inline std::string cut_off_extension(const std::string& str) { std::string res; @@ -661,7 +658,17 @@ POP_WARNINGS res = str.substr(0, pos); return res; } + //---------------------------------------------------------------------------- + inline std::wstring cut_off_extension(const std::wstring& str) + { + std::wstring res; + std::wstring::size_type pos = str.rfind('.'); + if (std::wstring::npos == pos) + return str; + res = str.substr(0, pos); + return res; + } //---------------------------------------------------------------------------- // replaces all non-ascii characters with mask_character inline std::string mask_non_ascii_chars(const std::string& str, const char mask_character = '?') diff --git a/contrib/zlib/test/infcover.c b/contrib/zlib/test/infcover.c index 2be01646..e45b6cbb 100644 --- a/contrib/zlib/test/infcover.c +++ b/contrib/zlib/test/infcover.c @@ -9,7 +9,7 @@ #include #include #include -#include "zlib.h" +#include "../zlib.h" /* get definition of internal structure so we can mess with it (see pull()), and so we can call inflate_trees() (see cover5()) */ diff --git a/contrib/zlib/test/minigzip.c b/contrib/zlib/test/minigzip.c index e22fb08c..93de87ba 100644 --- a/contrib/zlib/test/minigzip.c +++ b/contrib/zlib/test/minigzip.c @@ -15,7 +15,7 @@ /* @(#) $Id$ */ -#include "zlib.h" +#include "../zlib.h" #include #ifdef STDC diff --git a/src/common/command_line.cpp b/src/common/command_line.cpp index c1b90b7b..920423bb 100644 --- a/src/common/command_line.cpp +++ b/src/common/command_line.cpp @@ -16,8 +16,11 @@ namespace command_line const arg_descriptor arg_config_file = { "config-file", "Specify configuration file", std::string(CURRENCY_NAME_SHORT ".conf") }; const arg_descriptor arg_os_version = { "os-version", "" }; + const arg_descriptor arg_log_dir = { "log-dir", "", "", true}; - const arg_descriptor arg_log_level = { "log-level", "", LOG_LEVEL_0, true}; + const arg_descriptor arg_log_file = { "log-file", "", "" }; + const arg_descriptor arg_log_level = { "log-level", "", LOG_LEVEL_0, true }; + const arg_descriptor arg_console = { "no-console", "Disable daemon console commands" }; const arg_descriptor arg_show_details = { "currency-details", "Display currency details" }; const arg_descriptor arg_show_rpc_autodoc = { "show_rpc_autodoc", "Display rpc auto-generated documentation template" }; diff --git a/src/common/command_line.h b/src/common/command_line.h index 152c923f..4d7105c5 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -179,6 +179,7 @@ namespace command_line extern const arg_descriptor arg_config_file; extern const arg_descriptor arg_os_version; extern const arg_descriptor arg_log_dir; + extern const arg_descriptor arg_log_file; extern const arg_descriptor arg_log_level; extern const arg_descriptor arg_console; extern const arg_descriptor arg_show_details; diff --git a/src/common/pod_array_file_container.h b/src/common/pod_array_file_container.h new file mode 100644 index 00000000..7c168d79 --- /dev/null +++ b/src/common/pod_array_file_container.h @@ -0,0 +1,127 @@ +// Copyright (c) 2012-2013 The Cryptonote developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once +#include +#include +#include + +namespace tools +{ + + template + class pod_array_file_container + { + public: + pod_array_file_container() + {} + + ~pod_array_file_container() + { + close(); + } + + bool open(const std::wstring& filename, bool create_if_not_exist, bool* p_corrupted = nullptr, std::string* p_reason = nullptr) + { + if (!create_if_not_exist && !boost::filesystem::exists(filename)) + { + if (p_reason) + *p_reason = "file doest not exist"; + return false; + } + + m_stream.open(filename, std::ios::binary | std::ios::app | std::ios::in); + if (m_stream.rdstate() != std::ios::goodbit && m_stream.rdstate() != std::ios::eofbit) + { + if (p_reason) + *p_reason = "file could not be opened"; + return false; + } + + if (p_corrupted) + *p_corrupted = false; + + size_t file_size = size_bytes(); + if (file_size % sizeof(pod_t) != 0) + { + // currupted + if (p_corrupted) + *p_corrupted = true; + + size_t corrected_size = file_size - file_size % sizeof(pod_t); + + // truncate to nearest item boundary + close(); + boost::filesystem::resize_file(filename, corrected_size); + m_stream.open(filename, std::ios::binary | std::ios::app | std::ios::in); + if ((m_stream.rdstate() != std::ios::goodbit && m_stream.rdstate() != std::ios::eofbit) || + size_bytes() != corrected_size) + { + if (p_reason) + *p_reason = "truncation failed"; + return false; + } + + if (p_reason) + *p_reason = std::string("file was corrupted, truncated: ") + epee::string_tools::num_to_string_fast(file_size) + " -> " + epee::string_tools::num_to_string_fast(corrected_size); + } + + return true; + } + + void close() + { + m_stream.close(); + } + + bool push_back(const pod_t& item) + { + if (!m_stream.is_open() || (m_stream.rdstate() != std::ios::goodbit && m_stream.rdstate() != std::ios::eofbit)) + return false; + + m_stream.seekp(0, std::ios_base::end); + m_stream.write(reinterpret_cast(&item), sizeof item); + + if (m_stream.rdstate() != std::ios::goodbit && m_stream.rdstate() != std::ios::eofbit) + return false; + + m_stream.flush(); + + return true; + } + + bool get_item(size_t index, pod_t& result) const + { + if (!m_stream.is_open() || (m_stream.rdstate() != std::ios::goodbit && m_stream.rdstate() != std::ios::eofbit)) + return false; + + size_t offset = index * sizeof result; + m_stream.seekg(offset); + if (m_stream.rdstate() != std::ios::goodbit) + return false; + + m_stream.read(reinterpret_cast(&result), sizeof result); + + return m_stream.gcount() == sizeof result; + } + + size_t size_bytes() const + { + if (!m_stream.is_open() || (m_stream.rdstate() != std::ios::goodbit && m_stream.rdstate() != std::ios::eofbit)) + return 0; + + m_stream.seekg(0, std::ios_base::end); + return m_stream.tellg(); + } + + size_t size() const + { + return size_bytes() / sizeof(pod_t); + } + + private: + mutable boost::filesystem::fstream m_stream; + }; + +} // namespace tools diff --git a/src/crypto/chacha8.h b/src/crypto/chacha8.h index 98e14280..cebc6abe 100644 --- a/src/crypto/chacha8.h +++ b/src/crypto/chacha8.h @@ -78,10 +78,7 @@ namespace crypto { buff = decrypted_buff; return true; } -// inline bool chacha_decrypt(std::string& buff, const std::string& pass) -// { -// return chacha_crypt(buff, pass); -// } + template inline bool chacha_crypt(pod_to_encrypt& crypt, const pod_pass& pass) { @@ -91,6 +88,7 @@ namespace crypto { memcpy(&crypt, buff.data(), sizeof(crypt)); return true; } + template inline bool chacha_crypt(std::string& buff, const pod_pass& pass) { @@ -101,6 +99,15 @@ namespace crypto { return true; } + template + inline std::string chacha_crypt(const std::string& input, const pod_pass& pass) + { + std::string result; + result.resize(input.size()); + if (chacha_crypt(input.data(), input.size(), (void*)result.data(), &pass, sizeof pass)) + return result; + return ""; + } } diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index d039eee8..3a3fafd8 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -229,7 +229,7 @@ namespace crypto { } -POD_MAKE_COMPARABLE(crypto, public_key) +POD_MAKE_HASHABLE(crypto, public_key) POD_MAKE_COMPARABLE(crypto, secret_key) POD_MAKE_HASHABLE(crypto, key_image) POD_MAKE_COMPARABLE(crypto, signature) diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index a291feb8..39f6675e 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -122,11 +122,16 @@ namespace currency return get_account_address_as_str(m_keys.m_account_address); } //----------------------------------------------------------------- + void account_base::make_account_watch_only() + { + m_keys.m_spend_secret_key = currency::null_skey; + } + //----------------------------------------------------------------- std::string transform_addr_to_str(const account_public_address& addr) { return get_account_address_as_str(addr); } - + //----------------------------------------------------------------- account_public_address transform_str_to_addr(const std::string& str) { account_public_address ad = AUTO_VAL_INIT(ad); diff --git a/src/currency_core/account.h b/src/currency_core/account.h index 656c497c..f39e1a61 100644 --- a/src/currency_core/account.h +++ b/src/currency_core/account.h @@ -63,6 +63,8 @@ namespace currency bool load(const std::string& file_path); bool store(const std::string& file_path); + void make_account_watch_only(); + template inline void serialize(t_archive &a, const unsigned int /*ver*/) { diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 81d5bac3..f6facfc8 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -51,7 +51,7 @@ namespace currency const static crypto::signature null_sig = AUTO_VAL_INIT(null_sig); const static crypto::key_derivation null_derivation = AUTO_VAL_INIT(null_derivation); - + typedef std::string payment_id_t; /************************************************************************/ @@ -563,7 +563,8 @@ namespace currency KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(keyimage) END_KV_SERIALIZE_MAP() }; -} + +} // namespace currency POD_MAKE_HASHABLE(currency, account_public_address); diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 6766f9c6..aff816c4 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -212,7 +212,7 @@ #define BC_OFFERS_CURRENCY_MARKET_FILENAME "market.bin" -#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+62) +#define WALLET_FILE_SERIALIZATION_VERSION (CURRENCY_FORMATION_VERSION+63) #define CURRENT_MEMPOOL_ARCHIVE_VER (CURRENCY_FORMATION_VERSION+31) diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index cc73db4c..57b9a8d2 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -2443,7 +2443,7 @@ namespace currency return true; } //----------------------------------------------------------------------- - bool is_payment_id_size_ok(const std::string& payment_id) + bool is_payment_id_size_ok(const payment_id_t& payment_id) { return payment_id.size() <= BC_PAYMENT_ID_SERVICE_SIZE_MAX; } @@ -2453,7 +2453,7 @@ namespace currency return tools::base58::encode_addr(CURRENCY_PUBLIC_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr)); } //----------------------------------------------------------------------- - std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const std::string& payment_id) + std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const payment_id_t& payment_id) { return tools::base58::encode_addr(CURRENCY_PUBLIC_INTEG_ADDRESS_BASE58_PREFIX, t_serializable_object_to_blob(addr) + payment_id); } @@ -2464,7 +2464,7 @@ namespace currency return get_account_address_and_payment_id_from_str(addr, integrated_payment_id, str); } //----------------------------------------------------------------------- - bool get_account_address_and_payment_id_from_str(account_public_address& addr, std::string& payment_id, const std::string& str) + bool get_account_address_and_payment_id_from_str(account_public_address& addr, payment_id_t& payment_id, const std::string& str) { static const size_t addr_blob_size = sizeof(account_public_address); blobdata blob; @@ -2516,6 +2516,11 @@ namespace currency return true; } + //--------------------------------------------------------------- + bool parse_payment_id_from_hex_str(const std::string& payment_id_str, payment_id_t& payment_id) + { + return epee::string_tools::parse_hexstr_to_binbuff(payment_id_str, payment_id); + } //------------------------------------------------------------------ bool is_tx_expired(const transaction& tx, uint64_t expiration_ts_median) { diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index f8b27bdb..a43c66ae 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -68,12 +68,26 @@ namespace currency crypto::public_key real_out_tx_key; //real output's transaction's public key size_t real_output_in_tx_index; //index in transaction outputs vector uint64_t amount; //money + uint64_t transfer_index; //money crypto::hash multisig_id; //if txin_multisig: multisig output id size_t ms_sigs_count; //if txin_multisig: must be equal to output's minimum_sigs size_t ms_keys_count; //if txin_multisig: must be equal to size of output's keys container bool separately_signed_tx_complete; //for separately signed tx only: denotes the last source entry in complete tx to explicitly mark the final step of tx creation bool is_multisig() const { return ms_sigs_count > 0; } + + BEGIN_SERIALIZE_OBJECT() + FIELD(outputs) + FIELD(real_output) + FIELD(real_out_tx_key) + FIELD(real_output_in_tx_index) + FIELD(amount) + FIELD(transfer_index) + FIELD(multisig_id) + FIELD(ms_sigs_count) + FIELD(ms_keys_count) + FIELD(separately_signed_tx_complete) + END_SERIALIZE() }; struct tx_destination_entry @@ -86,6 +100,13 @@ namespace currency tx_destination_entry() : amount(0), minimum_sigs(0), amount_to_provide(0){} tx_destination_entry(uint64_t a, const account_public_address& ad) : amount(a), addr(1, ad), minimum_sigs(0), amount_to_provide(0){} tx_destination_entry(uint64_t a, const std::list& addr) : amount(a), addr(addr), minimum_sigs(addr.size()), amount_to_provide(0){} + + BEGIN_SERIALIZE_OBJECT() + FIELD(amount) + FIELD(addr) + FIELD(minimum_sigs) + FIELD(amount_to_provide) + END_SERIALIZE() }; struct tx_extra_info @@ -383,11 +404,12 @@ namespace currency size_t get_max_tx_size(); bool get_block_reward(bool is_pos, size_t median_size, size_t current_block_size, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t &reward, uint64_t height); uint64_t get_base_block_reward(bool is_pos, const boost::multiprecision::uint128_t& already_generated_coins, uint64_t height); - bool is_payment_id_size_ok(const std::string& payment_id); + bool is_payment_id_size_ok(const payment_id_t& payment_id); std::string get_account_address_as_str(const account_public_address& addr); - std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const std::string& payment_id); + std::string get_account_address_and_payment_id_as_str(const account_public_address& addr, const payment_id_t& payment_id); bool get_account_address_from_str(account_public_address& addr, const std::string& str); - bool get_account_address_and_payment_id_from_str(account_public_address& addr, std::string& payment_id, const std::string& str); + bool get_account_address_and_payment_id_from_str(account_public_address& addr, payment_id_t& payment_id, const std::string& str); + bool parse_payment_id_from_hex_str(const std::string& payment_id_str, payment_id_t& payment_id); bool is_coinbase(const transaction& tx); bool is_coinbase(const transaction& tx, bool& pos_coinbase); bool have_attachment_service_in_container(const std::vector& av, const std::string& service_id, const std::string& instruction); diff --git a/src/currency_protocol/currency_protocol_handler.inl b/src/currency_protocol/currency_protocol_handler.inl index 0485525f..b281e5c3 100644 --- a/src/currency_protocol/currency_protocol_handler.inl +++ b/src/currency_protocol/currency_protocol_handler.inl @@ -235,7 +235,7 @@ namespace currency if (it != m_blocks_id_que.end()) { //already have this block handler in que - LOG_PRINT("Block " << block_id << " already in processing que", LOG_LEVEL_2); + LOG_PRINT("Block " << block_id << " already in processing que", LOG_LEVEL_3); return 1; } else diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index b06714e1..dc168836 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -650,7 +650,7 @@ bool MainWindow::update_wallet_status(const view::wallet_status_info& wsi) TRY_ENTRY(); m_wallet_states->operator [](wsi.wallet_id) = wsi.wallet_state; std::string json_str; - epee::serialization::store_t_to_json(wsi, json_str); + epee::serialization::store_t_to_json(wsi, json_str, 0, epee::serialization::eol_lf); LOG_PRINT_L0(get_wallet_log_prefix(wsi.wallet_id) + "SENDING SIGNAL -> [update_wallet_status]:" << std::endl << json_str ); QMetaObject::invokeMethod(this, "update_wallet_status", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str())); return true; @@ -660,7 +660,7 @@ bool MainWindow::set_options(const view::gui_options& opt) { TRY_ENTRY(); std::string json_str; - epee::serialization::store_t_to_json(opt, json_str); + epee::serialization::store_t_to_json(opt, json_str, 0, epee::serialization::eol_lf); LOG_PRINT_L0("SENDING SIGNAL -> [set_options]:" << std::endl << json_str); QMetaObject::invokeMethod(this, "set_options", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str())); return true; @@ -688,7 +688,7 @@ bool MainWindow::update_wallets_info(const view::wallets_summary_info& wsi) { TRY_ENTRY(); std::string json_str; - epee::serialization::store_t_to_json(wsi, json_str); + epee::serialization::store_t_to_json(wsi, json_str, 0, epee::serialization::eol_lf); LOG_PRINT_L0("SENDING SIGNAL -> [update_wallets_info]"<< std::endl << json_str ); QMetaObject::invokeMethod(this, "update_wallets_info", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str())); @@ -700,7 +700,7 @@ bool MainWindow::money_transfer(const view::transfer_event_info& tei) { TRY_ENTRY(); std::string json_str; - epee::serialization::store_t_to_json(tei, json_str); + epee::serialization::store_t_to_json(tei, json_str, 0, epee::serialization::eol_lf); LOG_PRINT_L0(get_wallet_log_prefix(tei.wallet_id) + "SENDING SIGNAL -> [money_transfer]" << std::endl << json_str); //this->money_transfer(json_str.c_str()); @@ -745,7 +745,7 @@ bool MainWindow::money_transfer_cancel(const view::transfer_event_info& tei) { TRY_ENTRY(); std::string json_str; - epee::serialization::store_t_to_json(tei, json_str); + epee::serialization::store_t_to_json(tei, json_str, 0, epee::serialization::eol_lf); LOG_PRINT_L0(get_wallet_log_prefix(tei.wallet_id) + "SENDING SIGNAL -> [money_transfer_cancel]"); //this->money_transfer_cancel(json_str.c_str()); @@ -760,7 +760,7 @@ bool MainWindow::wallet_sync_progress(const view::wallet_sync_progres_param& p) TRY_ENTRY(); LOG_PRINT_L2(get_wallet_log_prefix(p.wallet_id) + "SENDING SIGNAL -> [wallet_sync_progress]" << " wallet_id: " << p.wallet_id << ": " << p.progress << "%"); //this->wallet_sync_progress(epee::serialization::store_t_to_json(p).c_str()); - QMetaObject::invokeMethod(this, "wallet_sync_progress", Qt::QueuedConnection, Q_ARG(QString, epee::serialization::store_t_to_json(p).c_str())); + QMetaObject::invokeMethod(this, "wallet_sync_progress", Qt::QueuedConnection, Q_ARG(QString, epee::serialization::store_t_to_json(p, 0, epee::serialization::eol_lf).c_str())); return true; CATCH_ENTRY2(false); } @@ -811,7 +811,7 @@ QString MainWindow::get_alias_coast(const QString& param) PREPARE_ARG_FROM_JSON(view::struct_with_one_t_type, lvl); view::get_alias_coast_response resp; resp.error_code = m_backend.get_alias_coast(lvl.v, resp.coast); - return epee::serialization::store_t_to_json(resp).c_str(); + return epee::serialization::store_t_to_json(resp, 0, epee::serialization::eol_lf).c_str(); CATCH_ENTRY_FAIL_API_RESPONCE(); } @@ -836,7 +836,7 @@ QString MainWindow::set_localization_strings(const QString param) resp.error_code = API_RETURN_CODE_OK; LOG_PRINT_L0("New localization set, language title: " << lr.language_title << ", strings " << lr.strings.size()); } - return epee::serialization::store_t_to_json(resp).c_str(); + return epee::serialization::store_t_to_json(resp, 0, epee::serialization::eol_lf).c_str(); CATCH_ENTRY_FAIL_API_RESPONCE(); } @@ -1292,7 +1292,7 @@ QString MainWindow::show_openfile_dialog(const QString& param) if (!epee::serialization::load_t_from_json(ofdr, param.toStdString())) { ofdres.error_code = API_RETURN_CODE_BAD_ARG; - return epee::serialization::store_t_to_json(ofdres).c_str(); + return epee::serialization::store_t_to_json(ofdres, 0, epee::serialization::eol_lf).c_str(); } QString path = QFileDialog::getOpenFileName(this, ofdr.caption.c_str(), @@ -1302,7 +1302,7 @@ QString MainWindow::show_openfile_dialog(const QString& param) if (!path.length()) { ofdres.error_code = API_RETURN_CODE_CANCELED; - return epee::serialization::store_t_to_json(ofdres).c_str(); + return epee::serialization::store_t_to_json(ofdres, 0, epee::serialization::eol_lf).c_str(); } ofdres.error_code = API_RETURN_CODE_OK; @@ -1325,7 +1325,7 @@ QString MainWindow::show_savefile_dialog(const QString& param) if (!path.length()) { ofdres.error_code = API_RETURN_CODE_CANCELED; - return epee::serialization::store_t_to_json(ofdres).c_str(); + return epee::serialization::store_t_to_json(ofdres, 0, epee::serialization::eol_lf).c_str(); } ofdres.error_code = API_RETURN_CODE_OK; diff --git a/src/serialization/stl_containers.h b/src/serialization/stl_containers.h index ae4d22ac..c3bb800e 100644 --- a/src/serialization/stl_containers.h +++ b/src/serialization/stl_containers.h @@ -9,28 +9,12 @@ #include #include -//#include "serialization.h" -template