From 03f443cf4c8b53cbf07bdd5c1b9cb9ec57e987b6 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Tue, 11 Apr 2023 17:23:06 +0200 Subject: [PATCH] Fixed few complilation issues --- src/gui/qt-daemon/application/mainwindow.cpp | 12 ++++++------ src/wallet/view_iface.h | 2 +- src/wallet/wallet2.cpp | 12 ++++++------ src/wallet/wallet_public_structs_defs.h | 4 ++-- src/wallet/wallets_manager.cpp | 5 +++-- src/wallet/wallets_manager.h | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index 03261af2..b61b4cce 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -2162,35 +2162,35 @@ QString MainWindow::get_wallet_info(const QString& param) return MAKE_RESPONSE(ar); CATCH_ENTRY_FAIL_API_RESPONCE(); } -QString create_ionic_swap_proposal(const QString& param) +QString MainWindow::create_ionic_swap_proposal(const QString& param) { TRY_ENTRY(); LOG_API_TIMING(); PREPARE_ARG_FROM_JSON(view::create_ionic_swap_proposal_request, cispr); - PREPARE_RESPONSE(view::api_response_t, ar); + PREPARE_RESPONSE(std::string, ar); ar.error_code = m_backend.create_ionic_swap_proposal(cispr.wallet_id, cispr, ar.response_data); return MAKE_RESPONSE(ar); CATCH_ENTRY_FAIL_API_RESPONCE(); } -QString get_ionic_swap_proposal_info(const QString& param) +QString MainWindow::get_ionic_swap_proposal_info(const QString& param) { TRY_ENTRY(); LOG_API_TIMING(); PREPARE_ARG_FROM_JSON(view::api_request_t, tx_raw_hex); - PREPARE_RESPONSE(view::api_response_t, ar); + PREPARE_RESPONSE(tools::wallet_public::ionic_swap_proposal_info, ar); ar.error_code = m_backend.get_ionic_swap_proposal_info(tx_raw_hex.wallet_id, tx_raw_hex.req_data, ar.response_data); return MAKE_RESPONSE(ar); CATCH_ENTRY_FAIL_API_RESPONCE(); } -QString accept_ionic_swap_proposal(const QString& param) +QString MainWindow::accept_ionic_swap_proposal(const QString& param) { TRY_ENTRY(); LOG_API_TIMING(); PREPARE_ARG_FROM_JSON(view::api_request_t, tx_raw_hex); - PREPARE_RESPONSE(view::api_response_t, ar); + PREPARE_RESPONSE(std::string, ar); ar.error_code = m_backend.accept_ionic_swap_proposal(tx_raw_hex.wallet_id, tx_raw_hex.req_data, ar.response_data); return MAKE_RESPONSE(ar); CATCH_ENTRY_FAIL_API_RESPONCE(); diff --git a/src/wallet/view_iface.h b/src/wallet/view_iface.h index de98cdfe..ebce8c5e 100644 --- a/src/wallet/view_iface.h +++ b/src/wallet/view_iface.h @@ -409,7 +409,7 @@ public: struct wallet_and_asset_id { uint64_t wallet_id = 0; - crypto::hash asset_id = currency::null_hash; + crypto::public_key asset_id = currency::null_pkey; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(wallet_id) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index dfbf9951..bb6f98bd 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -5040,8 +5040,8 @@ bool wallet2::get_ionic_swap_proposal_info(const currency::transaction tx, walle bool r = lookup_acc_outs(m_account.get_keys(), tx, outs, tx_money_got_in_outs, derivation); THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "Failed to lookup_acc_outs for tx: " << get_transaction_hash(tx)); - std::unordered_map ammounts_to; - std::unordered_map ammounts_from; + std::unordered_map ammounts_to; + std::unordered_map ammounts_from; std::vector third_party_outs; size_t i = 0; for (const auto& o : outs) @@ -5060,7 +5060,7 @@ bool wallet2::get_ionic_swap_proposal_info(const currency::transaction tx, walle uint64_t amount = 0; //TODO decode output info //get_amout_and_asset_id() - ammounts_from[asset_id] += amount; + //ammounts_from[asset_id] += amount; } for (const auto& a : ammounts_to) @@ -5110,7 +5110,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat bool r = get_ionic_swap_proposal_info(tx_template, msc.proposal); THROW_IF_TRUE_WALLET_EX(!r, error::wallet_internal_error, "Failed to get info from proposal"); - std::unordered_map balances; + std::unordered_map balances; uint64_t mined = 0; this->balance(balances, mined); //validate balances needed @@ -5121,7 +5121,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat { return false; } - if (item.asset_id == currency::null_hash) + if (item.asset_id == currency::native_coin_asset_id) { native_amount_required = item.amount; } @@ -5132,7 +5132,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat if (msc.proposal.fee < m_core_runtime_config.tx_default_fee) { additional_fee = m_core_runtime_config.tx_default_fee - msc.proposal.fee; - if (balances[currency::null_hash].unlocked < additional_fee + native_amount_required) + if (balances[currency::native_coin_asset_id].unlocked < additional_fee + native_amount_required) { return false; } diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 485c2117..515fe5a4 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -1183,11 +1183,11 @@ namespace wallet_public struct asset_funds { - crypto::hash asset_id; + crypto::public_key asset_id; uint64_t amount; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(asset_id) + KV_SERIALIZE_POD_AS_HEX_STRING(asset_id) KV_SERIALIZE(amount) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 53f20b24..5c2f7f1b 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -927,7 +927,7 @@ std::string wallets_manager::get_ionic_swap_proposal_info(uint64_t wallet_id, st return API_RETURN_CODE_OK; } -std::string wallets_manager::accept_ionic_swap_proposal(uint64_t wallet_id, std::string&raw_tx_template_hex, currency::transaction& result_tx) +std::string wallets_manager::accept_ionic_swap_proposal(uint64_t wallet_id, std::string&raw_tx_template_hex, std::string& result_raw_tx_hex) { GET_WALLET_OPT_BY_ID(wallet_id, wo); try { @@ -937,11 +937,12 @@ std::string wallets_manager::accept_ionic_swap_proposal(uint64_t wallet_id, std: { return API_RETURN_CODE_BAD_ARG; } - + currency::transaction result_tx = AUTO_VAL_INIT(result_tx); if (!wo.w->get()->accept_ionic_swap_proposal(raw_tx_template, result_tx)) { return API_RETURN_CODE_FAIL; } + result_raw_tx_hex = epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(result_tx)); } catch (...) { diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index c2fac77f..b9542b2a 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -138,7 +138,7 @@ public: std::string is_wallet_password_valid(uint64_t wallet_id, const std::string& pass); std::string create_ionic_swap_proposal(uint64_t wallet_id, const tools::wallet_public::create_ionic_swap_proposal_request& proposal, std::string& result_proposal_hex); std::string get_ionic_swap_proposal_info(uint64_t wallet_id, std::string&raw_tx_template_hex, tools::wallet_public::ionic_swap_proposal_info& proposal); - std::string accept_ionic_swap_proposal(uint64_t wallet_id, std::string&raw_tx_template_hex, currency::transaction& result_tx); + std::string accept_ionic_swap_proposal(uint64_t wallet_id, std::string&raw_tx_template_hex, std::string& result_raw_tx); std::string get_my_offers(const bc_services::core_offers_filter& filter, std::list& offers); std::string get_fav_offers(const std::list& hashes, const bc_services::core_offers_filter& filter, std::list& offers); std::string get_tx_pool_info(currency::COMMAND_RPC_GET_POOL_INFO::response& res);