diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 25e7d611..bdf36d6a 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -306,7 +306,10 @@ simple_wallet::simple_wallet() m_cmd_binder.set_handler("payments", boost::bind(&simple_wallet::show_payments, this, ph::_1), "payments [ ... ] - Show payments , ... "); m_cmd_binder.set_handler("bc_height", boost::bind(&simple_wallet::show_blockchain_height, this,ph::_1), "Show blockchain height"); m_cmd_binder.set_handler("wallet_bc_height", boost::bind(&simple_wallet::show_wallet_bcheight, this,ph::_1), "Show blockchain height"); + m_cmd_binder.set_handler("transfer", boost::bind(&simple_wallet::transfer, this,ph::_1), "transfer [asset_id_1:] [ [asset_id_2:] ... [asset_id_N:] ] [payment_id] - Transfer ,... to ,... , respectively. is the number of transactions yours is indistinguishable from (from 0 to maximum available), is an optional HEX-encoded string"); + m_cmd_binder.set_handler("transfer_so", boost::bind(&simple_wallet::transfer_so, this, ph::_1), "transfer_so [asset_id_1:] [ [asset_id_2:] ... [asset_id_N:] ] [payment_id] - Transfer funds spending only specified outputs (use list_outputs command to get outputs' indecies)"); + m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this,ph::_1), "set_log - Change current log detalisation level, is a number 0-4"); m_cmd_binder.set_handler("enable_console_logger", boost::bind(&simple_wallet::enable_console_logger, this,ph::_1), "Enables console logging"); m_cmd_binder.set_handler("resync", boost::bind(&simple_wallet::resync_wallet, this,ph::_1), "Causes wallet to reset all transfers and re-synchronize wallet"); @@ -1602,7 +1605,7 @@ bool preprocess_asset_id(std::string& address_arg, crypto::public_key& asset_id) return true; } //---------------------------------------------------------------------------------------------------- -bool simple_wallet::transfer(const std::vector &args_) +bool simple_wallet::transfer_impl(const std::vector &args_, uint64_t fee) { CONFIRM_WITH_PASSWORD(); SIMPLE_WALLET_BEGIN_TRY_ENTRY(); @@ -1734,7 +1737,7 @@ bool simple_wallet::transfer(const std::vector &args_) } currency::transaction tx; - m_wallet->transfer(dsts, fake_outs_count, 0, m_wallet->get_core_runtime_config().tx_default_fee, extra, attachments, tx); + m_wallet->transfer(dsts, fake_outs_count, 0, fee, extra, attachments, tx); if (!m_wallet->is_watch_only()) { @@ -1752,6 +1755,76 @@ bool simple_wallet::transfer(const std::vector &args_) return true; } //---------------------------------------------------------------------------------------------------- +bool simple_wallet::transfer(const std::vector &args) +{ + return transfer_impl(args, m_wallet->get_core_runtime_config().tx_default_fee); +} +//---------------------------------------------------------------------------------------------------- +bool simple_wallet::transfer_so(const std::vector &args) +{ + bool r = false; + + // 1st arg: outs + if (args.size() <= 0) + { + fail_msg_writer() << "invalid agruments, can't parse outputs index array, 'out_idx,out_idx,...' format is expected"; + return true; + } + + std::vector outs_idxs; + std::string outs_str = args[0]; + while (!outs_str.empty()) + { + size_t comma_pos = outs_str.find(','); + if (comma_pos != 0) + { + std::string out_idx_str = outs_str.substr(0, comma_pos); + int64_t out_idx = -1; + r = epee::string_tools::string_to_num_fast(out_idx_str, out_idx); + if (!r || out_idx < 0) + { + fail_msg_writer() << "invalid output index given: " << out_idx_str; + return true; + } + outs_idxs.push_back(out_idx); + if (comma_pos == std::string::npos) + break; + } + outs_str.erase(0, comma_pos + 1); + } + + std::stringstream ss; + for (auto i : outs_idxs) + ss << i << " "; + success_msg_writer() << "outputs' indicies allowed to spent: " << (outs_idxs.empty() ? std::string("all") : ss.str()); + + // 2nd arg: fee + if (args.size() <= 1) + { + fail_msg_writer() << "invalid agruments: can't parse fee"; + return true; + } + + uint64_t fee = 0; + r = currency::parse_amount(args[1], fee); + if (!r || fee < TX_MINIMUM_FEE) + { + fail_msg_writer() << "invalid agruments: given fee is invalid or too small: " << args[1] << ", minimum fee: " << print_money_brief(TX_MINIMUM_FEE); + return true; + } + + std::vector args_copy = args; + args_copy.erase(args_copy.begin(), args_copy.begin() + 2); // remove first two args + + m_wallet->set_tids_to_be_only_used_in_the_next_transfer(outs_idxs); + auto slh = epee::misc_utils::create_scope_leave_handler([&](){ + m_wallet->set_tids_to_be_only_used_in_the_next_transfer(std::vector()); // reset + }); + transfer_impl(args_copy, fee); + + return true; +} +//---------------------------------------------------------------------------------------------------- bool simple_wallet::run() { std::string addr_start = m_wallet->get_account().get_public_address_str().substr(0, 6); diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index d660e75c..60c5217b 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -73,7 +73,9 @@ namespace currency bool print_utxo_distribution(const std::vector &args); bool show_blockchain_height(const std::vector &args); bool show_wallet_bcheight(const std::vector &args); + bool transfer_impl(const std::vector &args, uint64_t fee); bool transfer(const std::vector &args); + bool transfer_so(const std::vector &args); bool resync_wallet(const std::vector &args); bool print_address(const std::vector &args = std::vector()); bool show_seed(const std::vector &args); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index e7cd8fca..258f1418 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -343,25 +343,11 @@ bool out_is_multisig(const currency::tx_out_v& out_t) return false; } -bool out_is_to_htlc(const currency::tx_out_v& out_t) -{ - if (out_t.type() == typeid(currency::tx_out_bare)) - { - return boost::get(out_t).target.type() == typeid(currency::txout_htlc); - } - return false; -} - bool out_is_zc(const currency::tx_out_v& out_t) { return out_t.type() == typeid(currency::tx_out_zarcanum); } -const currency::txout_htlc& out_get_htlc(const currency::tx_out_v& out_t) -{ - return boost::get(boost::get(out_t).target); -} - const crypto::public_key& wallet2::out_get_pub_key(const currency::tx_out_v& out_t, std::list& htlc_info_list) { if (out_t.type() == typeid(tx_out_bare)) @@ -635,32 +621,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t } VARIANT_CASE_CONST(currency::txin_htlc, in_htlc) { - if (in_htlc.key_offsets.size() != 1) - { - LOG_ERROR("in_htlc.key_offsets.size() != 1, skip inout"); - continue; - } - - if (in_htlc.key_offsets[0].type() != typeid(uint64_t)) - { - LOG_ERROR("HTLC with ref_by_id is not supported by wallet yet"); - continue; - } - - auto it = m_active_htlcs.find(std::make_pair(in_htlc.amount, boost::get(in_htlc.key_offsets[0]))); - if (it != m_active_htlcs.end()) - { - transfer_details& td = m_transfers.at(it->second); - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(td.m_ptx_wallet_info->m_tx.vout.size() > td.m_internal_output_index, "Internal error: wrong td.m_internal_output_index: " << td.m_internal_output_index); - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type() == typeid(tx_out_bare), "Internal error: wrong output type: " << td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type().name()); - const boost::typeindex::type_info& ti = boost::get(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]).target.type(); - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(ti == typeid(txout_htlc), "Internal error: wrong type of output's target: " << ti.name()); - //input spend active htlc - m_transfers.at(it->second).m_spent_height = height; - transfer_details_extra_option_htlc_info& tdeohi = get_or_add_field_to_variant_vector(td.varian_options); - tdeohi.origin = in_htlc.hltc_origin; - tdeohi.redeem_tx_id = ptc.tx_hash(); - } + WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(false, "txin_htlc is not supported"); } VARIANT_SWITCH_END(); ptc.i++; @@ -725,10 +686,9 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t const currency::tx_out_v& out_v = tx.vout[o]; bool out_type_zc = out_is_zc(out_v); bool out_type_to_key = out_is_to_key(out_v); - bool out_type_htlc = out_is_to_htlc(out_v); bool out_type_multisig = out_is_multisig(out_v); - if (out_type_zc || out_type_to_key || out_type_htlc) + if (out_type_zc || out_type_to_key) { crypto::public_key out_key = out_get_pub_key(out_v, htlc_info_list); // htlc_info_list contains information about which one, redeem or refund key is ours for an htlc output @@ -860,50 +820,8 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t } size_t transfer_index = new_index; - if (out_type_htlc) - { - const currency::txout_htlc& hltc = out_get_htlc(out_v); - //mark this as spent - td.m_flags |= WALLET_TRANSFER_DETAIL_FLAG_SPENT|WALLET_TRANSFER_DETAIL_CONCISE_MODE_PRESERVE; - //create entry for htlc input - htlc_expiration_trigger het = AUTO_VAL_INIT(het); - het.is_wallet_owns_redeem = (out_key == hltc.pkey_redeem) ? true : false; - het.transfer_index = transfer_index; - uint64_t expired_if_more_then = td.m_ptx_wallet_info->m_block_height + hltc.expiration; - m_htlcs.insert(std::make_pair(expired_if_more_then, het)); - - if (het.is_wallet_owns_redeem) - { - td.m_flags |= WALLET_TRANSFER_DETAIL_FLAG_HTLC_REDEEM; - } - - //active htlc - auto amount_gindex_pair = std::make_pair(td.m_amount, td.m_global_output_index); - m_active_htlcs[amount_gindex_pair] = transfer_index; - m_active_htlcs_txid[ptc.tx_hash()] = transfer_index; - //add payer to extra options - currency::tx_payer payer = AUTO_VAL_INIT(payer); - if (het.is_wallet_owns_redeem) - { - if (currency::get_type_in_variant_container(tx.extra, payer)) - { - crypto::chacha_crypt(payer.acc_addr, derivation); - td.varian_options.push_back(payer); - } - } - else - { - //since this is refund-mode htlc out, then sender is this wallet itself - payer.acc_addr = m_account.get_public_address(); - td.varian_options.push_back(payer); - } - - } - else - { - ptc.total_balance_change[td.get_asset_id()] += td.amount(); - add_transfer_to_transfers_cache(td.m_amount, transfer_index, td.get_asset_id()); - } + ptc.total_balance_change[td.get_asset_id()] += td.amount(); + add_transfer_to_transfers_cache(td.m_amount, transfer_index, td.get_asset_id()); if (td.m_key_image != currency::null_ki) m_key_images[td.m_key_image] = transfer_index; @@ -931,10 +849,6 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t WLT_LOG_L0("Received asset " << print16(td.get_asset_id()) << ", transfer #" << transfer_index << ", amount: " << print_money_brief(td.amount()) << (out_type_zc ? " (hidden)" : "") << ", with tx: " << ptc.tx_hash() << ", at height " << height); } } - else if (out_type_htlc) - { - WLT_LOG_L0("Detected HTLC[" << (td.m_flags & WALLET_TRANSFER_DETAIL_FLAG_HTLC_REDEEM ? "REDEEM" : "REFUND") << "], transfer #" << transfer_index << ", amount: " << print_money(td.amount()) << ", with tx: " << ptc.tx_hash() << ", at height " << height); - } } else if (out_type_multisig) { @@ -6277,108 +6191,6 @@ void wallet2::send_escrow_proposal(const bc_services::contract_private_details& print_tx_sent_message(tx, "from multisig", true, fee); } //---------------------------------------------------------------------------------------------------- -void wallet2::create_htlc_proposal(uint64_t amount, const currency::account_public_address& addr, uint64_t lock_blocks_count, currency::transaction& tx, const crypto::hash& htlc_hash, std::string& origin) -{ - construct_tx_param ctp = get_default_construct_tx_param(); - ctp.fee = TX_DEFAULT_FEE; - ctp.dsts.resize(1); - ctp.dsts.back().addr.push_back(addr); - ctp.dsts.back().amount = amount; - destination_option_htlc_out& htlc_option = ctp.dsts.back().htlc_options; - htlc_option.expiration = lock_blocks_count; //about 12 hours - htlc_option.htlc_hash = htlc_hash; - - currency::create_and_add_tx_payer_to_container_from_address(ctp.extra, - get_account().get_keys().account_address, get_top_block_height(), get_core_runtime_config()); - - finalized_tx ft = AUTO_VAL_INIT(ft); - this->transfer(ctp, ft, true, nullptr); - origin = ft.htlc_origin; - tx = ft.tx; -} -//---------------------------------------------------------------------------------------------------- -void wallet2::get_list_of_active_htlc(std::list& htlcs, bool only_redeem_txs) -{ - for (auto htlc_entry : m_active_htlcs_txid) - { - //auto it = m_transfers.find(htlc_entry.second); - //if (it == m_transfers.end()) - // continue; - //const transfer_details& td = it->second; - const transfer_details& td = m_transfers.at(htlc_entry.second); - if (only_redeem_txs && !(td.m_flags & WALLET_TRANSFER_DETAIL_FLAG_HTLC_REDEEM)) - { - continue; - } - wallet_public::htlc_entry_info entry = AUTO_VAL_INIT(entry); - entry.tx_id = htlc_entry.first; - if (td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type() != typeid(tx_out_bare)) - { - //@#@ - LOG_ERROR("Unexpected output type in get_list_of_active_htlc:" << td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type().name()); - continue; - } - const tx_out_bare out_b = boost::get(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]); - entry.amount = out_b.amount; - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(out_b.target.type() == typeid(txout_htlc), - "[get_list_of_active_htlc]Internal error: unexpected type of out"); - const txout_htlc& htlc = boost::get(out_b.target); - entry.sha256_hash = htlc.htlc_hash; - - currency::tx_payer payer = AUTO_VAL_INIT(payer); - if (currency::get_type_in_variant_container(td.varian_options, payer)) - entry.counterparty_address = payer.acc_addr; - - entry.is_redeem = td.m_flags & WALLET_TRANSFER_DETAIL_FLAG_HTLC_REDEEM ? true : false; - htlcs.push_back(entry); - } -} -//---------------------------------------------------------------------------------------------------- -void wallet2::redeem_htlc(const crypto::hash& htlc_tx_id, const std::string& origin) -{ - currency::transaction result_tx = AUTO_VAL_INIT(result_tx); - return redeem_htlc(htlc_tx_id, origin, result_tx); -} -//---------------------------------------------------------------------------------------------------- -void wallet2::redeem_htlc(const crypto::hash& htlc_tx_id, const std::string& origin, currency::transaction& result_tx) -{ - - construct_tx_param ctp = get_default_construct_tx_param(); - ctp.fee = TX_DEFAULT_FEE; - ctp.htlc_tx_id = htlc_tx_id; - ctp.htlc_origin = origin; - ctp.dsts.resize(1); - ctp.dsts.back().addr.push_back(m_account.get_keys().account_address); - - auto it = m_active_htlcs_txid.find(htlc_tx_id); - WLT_THROW_IF_FALSE_WITH_CODE(it != m_active_htlcs_txid.end(), - "htlc not found with tx_id = " << htlc_tx_id, API_RETURN_CODE_NOT_FOUND); - - ctp.dsts.back().amount = m_transfers.at(it->second).amount() - ctp.fee; - this->transfer(ctp, result_tx, true, nullptr); -} -//---------------------------------------------------------------------------------------------------- -bool wallet2::check_htlc_redeemed(const crypto::hash& htlc_tx_id, std::string& origin, crypto::hash& redeem_tx_id) -{ - auto it = m_active_htlcs_txid.find(htlc_tx_id); - - WLT_THROW_IF_FALSE_WITH_CODE(it != m_active_htlcs_txid.end(), - "htlc not found with tx_id = " << htlc_tx_id, API_RETURN_CODE_NOT_FOUND); - - transfer_details_extra_option_htlc_info htlc_options = AUTO_VAL_INIT(htlc_options); - if (!currency::get_type_in_variant_container(m_transfers.at(it->second).varian_options, htlc_options)) - { - return false; - } - if (htlc_options.origin.size()) - { - origin = htlc_options.origin; - redeem_tx_id = htlc_options.redeem_tx_id; - return true; - } - return false; -} -//---------------------------------------------------------------------------------------------------- bool wallet2::create_ionic_swap_proposal(const wallet_public::ionic_swap_proposal_info& proposal_details, const currency::account_public_address& destination_addr, wallet_public::ionic_swap_proposal& proposal) { std::vector selected_transfers_for_template; @@ -6957,8 +6769,6 @@ bool wallet2::prepare_tx_sources(size_t fake_outputs_count_, bool use_all_decoys VARIANT_SWITCH_BEGIN(o.target); VARIANT_CASE_CONST(txout_to_key, o) real_oe.stealth_address = o.key; - VARIANT_CASE_CONST(txout_htlc, htlc) - real_oe.stealth_address = htlc.pkey_refund; VARIANT_CASE_OTHER() { WLT_THROW_IF_FALSE_WITH_CODE(false, @@ -7606,15 +7416,6 @@ bool wallet2::is_transfer_able_to_go(const transfer_details& td, uint64_t fake_o return false; } - VARIANT_SWITCH_BEGIN(out_v); - VARIANT_CASE_CONST(tx_out_bare, o); - if (o.target.type() == typeid(txout_htlc)) - { - if (fake_outputs_count != 0) - return false; - } - VARIANT_SWITCH_END(); - return true; } //---------------------------------------------------------------------------------------------------- @@ -7981,21 +7782,6 @@ bool wallet2::prepare_transaction(construct_tx_param& ctp, currency::finalize_tx } catch (const error::not_enough_outs_to_mix&) { return false; } // if there's not enough decoys, return false to indicate minor non-fatal error } - else if (ctp.htlc_tx_id != currency::null_hash) - { - //htlc - //@#@ need to do refactoring over this part to support hidden amounts and asset_id - prepare_tx_sources_htlc(ctp.htlc_tx_id, ctp.htlc_origin, ftp.sources, needed_money_map[currency::native_coin_asset_id].found_amount); - WLT_THROW_IF_FALSE_WITH_CODE(ctp.dsts.size() == 1, - "htlc: unexpected ctp.dsts.size() =" << ctp.dsts.size(), API_RETURN_CODE_INTERNAL_ERROR); - - WLT_THROW_IF_FALSE_WITH_CODE(needed_money_map[currency::native_coin_asset_id].found_amount > ctp.fee, - "htlc: found money less then fee", API_RETURN_CODE_INTERNAL_ERROR); - - //fill amount - ctp.dsts.begin()->amount = needed_money_map[currency::native_coin_asset_id].found_amount - ctp.fee; - - } else if (ctp.multisig_id != currency::null_hash) { //multisig @@ -8448,8 +8234,6 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public VARIANT_SWITCH_BEGIN(o.target); VARIANT_CASE_CONST(txout_to_key, o) interted_it = src.outputs.emplace(it_to_insert, out_reference, o.key); - VARIANT_CASE_CONST(txout_htlc, htlc) - interted_it = src.outputs.emplace(it_to_insert, out_reference, htlc.pkey_refund); VARIANT_CASE_OTHER() { WLT_THROW_IF_FALSE_WITH_CODE(false, diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index ed2e50cb..717adf7d 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -586,6 +586,13 @@ namespace tools bool truncate_transfers_and_history(const std::list& items_to_remove); bool truncate_wallet(); + void set_tids_to_be_only_used_in_the_next_transfer(const std::vector& tids) + { + WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(std::all_of(tids.cbegin(), tids.cend(), [&](size_t i){ return i < m_transfers.size(); }), "some transfers IDs are out of range"); + m_found_free_amounts.clear(); + add_transfers_to_transfers_cache(tids); + } + // PoS mining void do_pos_mining_prepare_entry(mining_context& cxt, const transfer_details& td); bool do_pos_mining_iteration(mining_context& cxt, uint64_t ts); @@ -730,17 +737,6 @@ namespace tools void set_connectivity_options(unsigned int timeout); - /* - create_htlc_proposal: if htlc_hash == null_hash, then this wallet is originator of the atomic process, and - we use deterministic origin, if given some particular htlc_hash, then we use this hash, and this means that - opener-hash will be given by other side - */ - void create_htlc_proposal(uint64_t amount, const currency::account_public_address& addr, uint64_t lock_blocks_count, currency::transaction &tx, const crypto::hash& htlc_hash, std::string &origin); - void get_list_of_active_htlc(std::list& htlcs, bool only_redeem_txs); - void redeem_htlc(const crypto::hash& htlc_tx_id, const std::string& origin, currency::transaction& result_tx); - void redeem_htlc(const crypto::hash& htlc_tx_id, const std::string& origin); - bool check_htlc_redeemed(const crypto::hash& htlc_tx_id, std::string& origin, crypto::hash& redeem_tx_id); - void set_votes_config_path(const std::string& path_to_config_file); const tools::wallet_public::wallet_vote_config& get_current_votes() { return m_votes_config; } diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index d3a4e5b9..fe1383db 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -521,12 +521,11 @@ namespace tools return false; } - if (!req.comment.empty()) + if (!req.comment.empty() && payment_id.empty()) { - // tx_comment is temporary disabled -- sowle - //currency::tx_comment comment = AUTO_VAL_INIT(comment); - //comment.comment = req.comment; - //attachments.push_back(comment); + currency::tx_comment comment = AUTO_VAL_INIT(comment); + comment.comment = req.comment; + extra.push_back(comment); } if (req.push_payer && !wrap) @@ -1143,44 +1142,6 @@ namespace tools WALLET_RPC_CATCH_TRY_ENTRY(); } //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_create_htlc_proposal(const wallet_public::COMMAND_CREATE_HTLC_PROPOSAL::request& req, wallet_public::COMMAND_CREATE_HTLC_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx) - { - WALLET_RPC_BEGIN_TRY_ENTRY(); - currency::transaction tx = AUTO_VAL_INIT(tx); - w.get_wallet()->create_htlc_proposal(req.amount, req.counterparty_address, req.lock_blocks_count, tx, req.htlc_hash, res.derived_origin_secret); - res.result_tx_blob = currency::tx_to_blob(tx); - res.result_tx_id = get_transaction_hash(tx); - WALLET_RPC_CATCH_TRY_ENTRY(); - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_get_list_of_active_htlc(const wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC::request& req, wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC::response& res, epee::json_rpc::error& er, connection_context& cntx) - { - WALLET_RPC_BEGIN_TRY_ENTRY(); - w.get_wallet()->get_list_of_active_htlc(res.htlcs, req.income_redeem_only); - WALLET_RPC_CATCH_TRY_ENTRY(); - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_redeem_htlc(const wallet_public::COMMAND_REDEEM_HTLC::request& req, wallet_public::COMMAND_REDEEM_HTLC::response& res, epee::json_rpc::error& er, connection_context& cntx) - { - WALLET_RPC_BEGIN_TRY_ENTRY(); - currency::transaction tx = AUTO_VAL_INIT(tx); - w.get_wallet()->redeem_htlc(req.tx_id, req.origin_secret, tx); - res.result_tx_blob = currency::tx_to_blob(tx); - res.result_tx_id = get_transaction_hash(tx); - WALLET_RPC_CATCH_TRY_ENTRY(); - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ - bool wallet_rpc_server::on_check_htlc_redeemed(const wallet_public::COMMAND_CHECK_HTLC_REDEEMED::request& req, wallet_public::COMMAND_CHECK_HTLC_REDEEMED::response& res, epee::json_rpc::error& er, connection_context& cntx) - { - WALLET_RPC_BEGIN_TRY_ENTRY(); - w.get_wallet()->check_htlc_redeemed(req.htlc_tx_id, res.origin_secrete, res.redeem_tx_id); - WALLET_RPC_CATCH_TRY_ENTRY(); - return true; - } - //------------------------------------------------------------------------------------------------------------------------------ bool wallet_rpc_server::on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::request& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx) { WALLET_RPC_BEGIN_TRY_ENTRY(); diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h index 6962ed83..2a3cbc63 100644 --- a/src/wallet/wallet_rpc_server.h +++ b/src/wallet/wallet_rpc_server.h @@ -144,11 +144,6 @@ namespace tools MAP_JON_RPC_WE("marketplace_push_offer", on_marketplace_push_offer, wallet_public::COMMAND_MARKETPLACE_PUSH_OFFER) MAP_JON_RPC_WE("marketplace_push_update_offer", on_marketplace_push_update_offer, wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER) MAP_JON_RPC_WE("marketplace_cancel_offer", on_marketplace_cancel_offer, wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER) - //HTLC API - //MAP_JON_RPC_WE("atomics_create_htlc_proposal", on_create_htlc_proposal, wallet_public::COMMAND_CREATE_HTLC_PROPOSAL) - //MAP_JON_RPC_WE("atomics_get_list_of_active_htlc", on_get_list_of_active_htlc, wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC) - //MAP_JON_RPC_WE("atomics_redeem_htlc", on_redeem_htlc, wallet_public::COMMAND_REDEEM_HTLC) - //MAP_JON_RPC_WE("atomics_check_htlc_redeemed", on_check_htlc_redeemed, wallet_public::COMMAND_CHECK_HTLC_REDEEMED) //IONIC_SWAPS API MAP_JON_RPC_WE("ionic_swap_generate_proposal", on_ionic_swap_generate_proposal, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL) @@ -222,11 +217,6 @@ namespace tools bool on_marketplace_push_update_offer(const wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_PUSH_UPDATE_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_marketplace_cancel_offer(const wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER::request& req, wallet_public::COMMAND_MARKETPLACE_CANCEL_OFFER::response& res, epee::json_rpc::error& er, connection_context& cntx); - bool on_create_htlc_proposal(const wallet_public::COMMAND_CREATE_HTLC_PROPOSAL::request& req, wallet_public::COMMAND_CREATE_HTLC_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx); - bool on_get_list_of_active_htlc(const wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC::request& req, wallet_public::COMMAND_GET_LIST_OF_ACTIVE_HTLC::response& res, epee::json_rpc::error& er, connection_context& cntx); - bool on_redeem_htlc(const wallet_public::COMMAND_REDEEM_HTLC::request& req, wallet_public::COMMAND_REDEEM_HTLC::response& res, epee::json_rpc::error& er, connection_context& cntx); - bool on_check_htlc_redeemed(const wallet_public::COMMAND_CHECK_HTLC_REDEEMED::request& req, wallet_public::COMMAND_CHECK_HTLC_REDEEMED::response& res, epee::json_rpc::error& er, connection_context& cntx); - bool on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::request& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_ionic_swap_get_proposal_info(const wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::request& req, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx); bool on_ionic_swap_accept_proposal(const wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::request& req, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx); diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 4043708c..ad2b03f3 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1613,12 +1613,11 @@ std::string wallets_manager::transfer(uint64_t wallet_id, const view::transfer_p //process attachments - if (tp.comment.size()) + if (tp.comment.size() && payment_id.empty()) { - // tx_comment is temporary disabled -- sowle - //currency::tx_comment tc = AUTO_VAL_INIT(tc); - //tc.comment = tp.comment; - //extra.push_back(tc); + currency::tx_comment tc = AUTO_VAL_INIT(tc); + tc.comment = tp.comment; + extra.push_back(tc); } if (tp.push_payer && !wrap) { diff --git a/tests/core_tests/atomic_tests.cpp b/tests/core_tests/atomic_tests.cpp index bff1c87a..ec09c56a 100644 --- a/tests/core_tests/atomic_tests.cpp +++ b/tests/core_tests/atomic_tests.cpp @@ -1,8 +1,11 @@ // Copyright (c) 2014-2021 Zano Project // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. - #include "chaingen.h" + +// htlc clean up, WIP -- sowle +#if 0 + #include "escrow_wallet_tests.h" #include "random_helper.h" #include "chaingen_helpers.h" @@ -671,3 +674,5 @@ bool atomic_test_check_hardfork_rules::c1(currency::core& c, size_t ev_index, co return true; } + +#endif diff --git a/tests/core_tests/atomic_tests.h b/tests/core_tests/atomic_tests.h index 0476ddcb..f217deaf 100644 --- a/tests/core_tests/atomic_tests.h +++ b/tests/core_tests/atomic_tests.h @@ -1,8 +1,10 @@ // Copyright (c) 2014-2021 Zano Project // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. - #pragma once + +#if 0 + #include "chaingen.h" #include "wallet_tests_basic.h" @@ -44,3 +46,5 @@ struct atomic_test_check_hardfork_rules : public atomic_base_test bool c1(currency::core& c, size_t ev_index, const std::vector& events) override; private: }; + +#endif diff --git a/tests/core_tests/chaingen_main.cpp b/tests/core_tests/chaingen_main.cpp index f20f03c0..f8d46c10 100644 --- a/tests/core_tests/chaingen_main.cpp +++ b/tests/core_tests/chaingen_main.cpp @@ -1282,10 +1282,10 @@ int main(int argc, char* argv[]) GENERATE_AND_PLAY_HF(hard_fork_5_tx_version, "5-*"); // atomics - GENERATE_AND_PLAY(atomic_simple_test); - GENERATE_AND_PLAY(atomic_test_wrong_redeem_wrong_refund); - GENERATE_AND_PLAY(atomic_test_altchain_simple); - GENERATE_AND_PLAY(atomic_test_check_hardfork_rules); + //GENERATE_AND_PLAY(atomic_simple_test); + //GENERATE_AND_PLAY(atomic_test_wrong_redeem_wrong_refund); + //GENERATE_AND_PLAY(atomic_test_altchain_simple); + //GENERATE_AND_PLAY(atomic_test_check_hardfork_rules); GENERATE_AND_PLAY_HF(isolate_auditable_and_proof, "2-*");