From e85ee60d35c5b42f8656f84de348de04ccc751d0 Mon Sep 17 00:00:00 2001 From: wowario Date: Sun, 16 Oct 2022 21:10:55 +0300 Subject: [PATCH] broadcast donation sub-address --- src/cryptonote_core/cryptonote_core.cpp | 24 ++++++++++++++++++++++++ src/cryptonote_core/cryptonote_core.h | 7 +++++++ src/rpc/core_rpc_server.cpp | 1 + src/rpc/core_rpc_server_commands_defs.h | 2 ++ 4 files changed, 34 insertions(+) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 7cc348431..7e5e9c8cc 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -56,6 +56,9 @@ using namespace epee; #include "common/notify.h" #include "hardforks/hardforks.h" #include "version.h" +#include +#include +#include #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "cn" @@ -1764,6 +1767,27 @@ namespace cryptonote return m_blockchain_storage.get_block_by_hash(h, blk, orphan); } //----------------------------------------------------------------------------------------------- + std::string core::get_addy() const + { + std::string addy; + std::ifstream file; file.open("address.txt"); + if (file.is_open()) + { + file >> addy; + if (addy.length() == 97 && addy.rfind("WW", 0) == 0) + { + return addy; + } else { + addy = "0"; + } + } + if (file.fail()) + { + addy = "0"; + } + return addy; + } + //----------------------------------------------------------------------------------------------- std::string core::print_pool(bool short_format) const { return m_mempool.print_pool(short_format); diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index a6cce8617..a4d02ece1 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -633,6 +633,13 @@ namespace cryptonote */ const Blockchain& get_blockchain_storage()const{return m_blockchain_storage;} + /** + * @brief gets addy + * + * @note get addy + */ + std::string get_addy() const; + /** * @copydoc tx_memory_pool::print_pool * diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 6c4a0712f..c2ab95293 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -503,6 +503,7 @@ namespace cryptonote res.synchronized = check_core_ready(); res.status = CORE_RPC_STATUS_OK; + res.donation_address = m_core.get_addy(); return true; } //------------------------------------------------------------------------------------------------------------------------------ diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index d71925df9..c4ece4b54 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -687,6 +687,7 @@ namespace cryptonote bool busy_syncing; std::string version; bool synchronized; + std::string donation_address; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_PARENT(rpc_access_response_base) @@ -728,6 +729,7 @@ namespace cryptonote KV_SERIALIZE(busy_syncing) KV_SERIALIZE(version) KV_SERIALIZE(synchronized) + KV_SERIALIZE(donation_address) END_KV_SERIALIZE_MAP() }; typedef epee::misc_utils::struct_init response;