From 7a3bfa655a26bc062053218ab9dfb0f63801b8d6 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 30 May 2023 14:47:17 +0200 Subject: [PATCH 1/2] Changed text in simplewallet by pecial request from @ravaga --- src/simplewallet/simplewallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 74e74b59..972b8589 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1468,9 +1468,9 @@ bool simple_wallet::transfer(const std::vector &args_) if (!m_wallet->is_watch_only()) { if(wrapped_transaction) - success_msg_writer(true) << "Money successfully sent to wZano custody wallet, transaction " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; + success_msg_writer(true) << "Transaction successfully sent to wZano custody wallet, id: " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; else - success_msg_writer(true) << "Money successfully sent, transaction " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; + success_msg_writer(true) << "Transaction successfully sent, id: " << get_transaction_hash(tx) << ", " << get_object_blobsize(tx) << " bytes"; } else { From 6263975c039b79fd8792131ae5f389410741b318 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 2 Jun 2023 20:09:13 +0200 Subject: [PATCH 2/2] Fixed bug with cloudflare ssl handshake --- contrib/epee/include/net/net_helper.h | 38 ++++++++++++++++++++++++++- src/currency_core/currency_config.h | 4 +-- src/simplewallet/simplewallet.cpp | 2 ++ src/wallet/wallet2.cpp | 16 ++++++----- src/wallet/wallet2.h | 2 ++ src/wallet/wallets_manager.cpp | 1 + 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/contrib/epee/include/net/net_helper.h b/contrib/epee/include/net/net_helper.h index 5765c162..4a42e679 100644 --- a/contrib/epee/include/net/net_helper.h +++ b/contrib/epee/include/net/net_helper.h @@ -71,6 +71,37 @@ namespace epee // Create a context that uses the default paths for // finding CA certificates. m_ssl_context.set_default_verify_paths(); + /*m_socket.set_verify_mode(boost::asio::ssl::verify_peer); + m_socket.set_verify_callback( + boost::bind(&socket_backend::verify_certificate, this, _1, _2));*/ + + } + + /* + bool verify_certificate(bool preverified, + boost::asio::ssl::verify_context& ctx) + { + std::cout << "verify_certificate (preverified " << preverified << " ) ...\n"; + // The verify callback can be used to check whether the certificate that is + // being presented is valid for the peer. For example, RFC 2818 describes + // the steps involved in doing this for HTTPS. Consult the OpenSSL + // documentation for more details. Note that the callback is called once + // for each certificate in the certificate chain, starting from the root + // certificate authority. + + // In this example we will simply print the certificate's subject name. + char subject_name[256]; + X509* cert = X509_STORE_CTX_get_current_cert(ctx.native_handle()); + X509_NAME_oneline(X509_get_subject_name(cert), subject_name, 256); + std::cout << "Verifying " << subject_name << "\n"; + + // dummy verification + return true; + }*/ + + void set_domain(const std::string& domain_name) + { + SSL_set_tlsext_host_name(m_socket.native_handle(), domain_name.c_str()); } boost::asio::ip::tcp::socket& get_socket() @@ -104,6 +135,11 @@ namespace epee return m_socket; } + void set_domain(const std::string& domain_name) + { + + } + boost::asio::ip::tcp::socket& get_stream() { return m_socket; @@ -216,7 +252,7 @@ namespace epee } ////////////////////////////////////////////////////////////////////////// - + m_sct_back.set_domain(addr); //boost::asio::ip::tcp::endpoint remote_endpoint(boost::asio::ip::address::from_string(addr.c_str()), port); boost::asio::ip::tcp::endpoint remote_endpoint(*iterator); diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 2ece02f4..0ec3f381 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -276,9 +276,9 @@ static_assert(PREMINE_AMOUNT / WALLET_MAX_ALLOWED_OUTPUT_AMOUNT < CURRENCY_MINER #define CURRENCY_RELAY_TXS_MAX_COUNT 5 #ifndef TESTNET - #define WALLET_ASSETS_WHITELIST_URL "https://zano.org/assets_whitelist.json" + #define WALLET_ASSETS_WHITELIST_URL "https://api.zano.org/assets_whitelist.json" #else - #define WALLET_ASSETS_WHITELIST_URL "https://zano.org/assets_whitelist_testnet.json" + #define WALLET_ASSETS_WHITELIST_URL "https://api.zano.org/assets_whitelist_testnet.json" #endif diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 972b8589..a42a81da 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2394,6 +2394,8 @@ int main(int argc, char* argv[]) if (command_line::get_arg(vm, arg_generate_new_wallet).size() || command_line::get_arg(vm, arg_generate_new_auditable_wallet).size()) return EXIT_FAILURE; + wal.m_use_assets_whitelisting(true); + if (!offline_mode) wal.refresh(); LOG_PRINT_GREEN("Loaded ok", LOG_LEVEL_0); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 5d0317da..05fe16f5 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3102,6 +3102,12 @@ void wallet2::set_use_deffered_global_outputs(bool use) m_use_deffered_global_outputs = use; } //---------------------------------------------------------------------------------------------------- +void wallet2::set_use_assets_whitelisting(bool use) +{ + LOG_PRINT_L0("[ASSET_WHITELISTING_MODE]: " << use); + m_use_assets_whitelisting = use; +} +//---------------------------------------------------------------------------------------------------- void wallet2::store_watch_only(const std::wstring& path_to_save, const std::string& password) const { WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(path_to_save != m_wallet_file, "trying to save watch-only wallet to the same wallet file!"); @@ -3325,13 +3331,10 @@ bool wallet2::delete_custom_asset_id(const crypto::public_key& asset_id) //---------------------------------------------------------------------------------------------------- bool wallet2::load_whitelisted_tokens() const { - // Temporary disable by sowle: - // 1. seems to be not working due to cloudflare issues - // 2. this should not access web when the tests are running + if(!m_use_assets_whitelisting) + return true; - return true; - - /* + m_whitelisted_assets.clear(); std::string body; @@ -3344,7 +3347,6 @@ bool wallet2::load_whitelisted_tokens() const } } return true; - */ } //---------------------------------------------------------------------------------------------------- bool wallet2::load_whitelisted_tokens_if_not_loaded() const diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 8818c7bc..6e834fba 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -944,6 +944,7 @@ namespace tools uint64_t get_sync_progress(); uint64_t get_wallet_file_size()const; void set_use_deffered_global_outputs(bool use); + void set_use_assets_whitelisting(bool use); construct_tx_param get_default_construct_tx_param_inital(); void set_disable_tor_relay(bool disable); uint64_t get_default_fee() {return TX_DEFAULT_FEE;} @@ -1189,6 +1190,7 @@ private: mutable uint64_t m_current_wallet_file_size; bool m_use_deffered_global_outputs; bool m_disable_tor_relay; + bool m_use_assets_whitelisting = false; mutable current_operation_context m_current_context; //this needed to access wallets state in coretests, for creating abnormal blocks and tranmsactions diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 3b14ebf5..e66f55e2 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1021,6 +1021,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st std::shared_ptr w(new tools::wallet2()); w->set_use_deffered_global_outputs(m_use_deffered_global_outputs); + w->set_use_assets_whitelisting(true); owr.wallet_id = m_wallet_id_counter++; w->callback(std::shared_ptr(new i_wallet_to_i_backend_adapter(this, owr.wallet_id)));