diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index 76e20a74..8cf48c4a 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -2168,14 +2168,20 @@ QString create_ionic_swap_proposal(const QString& param) LOG_API_TIMING(); PREPARE_ARG_FROM_JSON(view::create_ionic_swap_proposal_request, cispr); PREPARE_RESPONSE(view::api_response_t, ar); - ar.error_code = m_backend.create_ionic_swap_proposal(waid.wallet_id, cispr, ar.response_data); + 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) { - + TRY_ENTRY(); + LOG_API_TIMING(); + PREPARE_ARG_FROM_JSON(view::api_request_t, tx_raw_hex); + PREPARE_RESPONSE(view::api_response_t, 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(); } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 71b62bd5..4bfed2ba 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4927,6 +4927,25 @@ bool wallet2::build_ionic_swap_template(const view::ionic_swap_proposal_info& pr return true; } //---------------------------------------------------------------------------------------------------- +bool wallet2::get_ionic_swap_proposal_info(std::string&raw_tx_template, ionic_swap_proposal_info& proposal) +{ + + currency::transaction tx; + bool r = parse_and_validate_tx_from_blob(tx_blob, tx); + THROW_IF_TRUE_WALLET_EX(!r, error::tx_parse_error, tx_blob); + + crypto::key_derivation derivation = AUTO_VAL_INIT(derivation); + std::vector outs; + uint64_t tx_money_got_in_outs = 0; + 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)); + for (const auto& o : outs) + { + + } + + +} //---------------------------------------------------------------------------------------------------- bool wallet2::prepare_tx_sources_for_packing(uint64_t items_to_pack, size_t fake_outputs_count, std::vector& sources, std::vector& selected_indicies, uint64_t& found_money) { diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 6ed688fd..bec4cdea 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -865,6 +865,14 @@ std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, cons } bool r = wo.w->get()->create_ionic_swap_proposal(proposal, dest_account); + if (!r) + { + return API_RETURN_CODE_FAIL; + } + else + { + return API_RETURN_CODE_OK; + } } catch (...) { @@ -875,6 +883,28 @@ std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, cons return true; } +std::string get_ionic_swap_proposal_info(uint64_t wallet_id, std::string&raw_tx_template_hex, ionic_swap_proposal_info& proposal) +{ + GET_WALLET_OPT_BY_ID(wallet_id, wo); + try { + std::string raw_tx_template; + bool r = epee::string_tools::parse_hexstr_to_binbuff(raw_tx_template_hex, raw_tx_template); + if (!r) + { + return API_RETURN_CODE_BAD_ARG; + } + + if (!wo.w->get()->get_ionic_swap_proposal_info(raw_tx_template, proposal)) + { + return API_RETURN_CODE_FAIL; + } + } + catch (...) + { + return API_RETURN_CODE_FAIL; + } + return API_RETURN_CODE_OK; +} std::string wallets_manager::get_my_offers(const bc_services::core_offers_filter& filter, std::list& offers) { diff --git a/src/wallet/wallets_manager.h b/src/wallet/wallets_manager.h index f88b024f..e465f3cf 100644 --- a/src/wallet/wallets_manager.h +++ b/src/wallet/wallets_manager.h @@ -137,6 +137,7 @@ public: std::string reset_wallet_password(uint64_t wallet_id, const std::string& pass); 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 view::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, ionic_swap_proposal_info& proposal); 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);