diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 1f0fb86722d..1beab011933 100755 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -11622,12 +11622,13 @@ std::vector wallet2::create_transactions_burn(const std::ve std::swap(burn_fixed, beldex_tx_params.burn_fixed); std::swap(burn_percent, beldex_tx_params.burn_percent); THROW_WALLET_EXCEPTION_IF(beldex_tx_params.hf_version < HF_VERSION_FEE_BURNING, error::wallet_internal_error, "cannot construct transaction: cannot burn amounts under the current hard fork"); - std::vector extra_plus; // Copy and modified from input if modification needed - extra_plus = extra_base; - add_burned_amount_to_tx_extra(extra_plus, 0); - fixed_fee += burn_fixed; - THROW_WALLET_EXCEPTION_IF(burn_percent > fee_percent, error::wallet_internal_error, "invalid burn fees: cannot burn more than the tx fee"); - + { + std::vector extra_plus; // Copy and modified from input if modification needed + extra_plus = extra_base; + add_burned_amount_to_tx_extra(extra_plus, 0); + fixed_fee += burn_fixed; + THROW_WALLET_EXCEPTION_IF(burn_percent > fee_percent, error::wallet_internal_error, "invalid burn fees: cannot burn more than the tx fee"); + } LOG_PRINT_L2("Starting with " << unused_transfers_indices.size() << " non-dust outputs and " << unused_dust_indices.size() << " dust outputs"); if (unused_dust_indices.empty() && unused_transfers_indices.empty()) @@ -11715,7 +11716,7 @@ std::vector wallet2::create_transactions_burn(const std::ve { dt.amount = dt_amount; } - beldex_tx_params = tools::wallet2::construct_params(*hf_version, tx_type, priority,amount_burned); + beldex_tx_params.burn_fixed = amount_burned; transfer_selected_rct(tx.dsts, tx.selected_transfers, fake_outs_count, outs, unlock_time, needed_fee, extra_base, test_tx, test_ptx, rct_config, beldex_tx_params); txBlob = t_serializable_object_to_blob(test_ptx.tx); diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index b87c7bc581a..f66eedfb4ec 100755 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -1076,30 +1076,26 @@ namespace tools std::vector ptx_vector; std::vector extra; - uint64_t burn_amount = req.amount; - std::cout << "burn_amount : " << burn_amount << std::endl; - std::string tx_id = req.tx_id; - std::cout << "req.txid : " << req.tx_id << std::endl; - - if(burn_amount == 0 && tx_id.empty()) + + if(req.amount == 0 && req.tx_id.empty()) throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Amount/Txid is required"}; - if(!burn_amount == 0 && !tx_id.empty()) + if(req.amount != 0 && !req.tx_id.empty()) throw wallet_rpc_error{error_code::TX_NOT_POSSIBLE, "Only one field needed either Amount or Txid"}; LOG_PRINT_L3("on_burn_transfer starts"); - if(!burn_amount == 0) + if(req.amount) { std::optional hf_version = m_wallet->get_hard_fork_version(); if (!hf_version) throw wallet_rpc_error{error_code::HF_QUERY_FAILED, tools::ERR_MSG_NETWORK_VERSION_QUERY_FAILED}; - cryptonote::beldex_construct_tx_params tx_params = tools::wallet2::construct_params(*hf_version, cryptonote::txtype::coin_burn, req.priority, burn_amount); + cryptonote::beldex_construct_tx_params tx_params = tools::wallet2::construct_params(*hf_version, cryptonote::txtype::coin_burn, req.priority, req.amount); ptx_vector = m_wallet->create_transactions_2({}, CRYPTONOTE_DEFAULT_TX_MIXIN, 0, req.priority, extra, req.account_index, req.subaddr_indices, tx_params); } - else if (!tx_id.empty()) + else { crypto::hash tx_hash; - if (!tools::hex_to_type(tx_id, tx_hash)) + if (!tools::hex_to_type(req.tx_id, tx_hash)) throw wallet_rpc_error{error_code::WRONG_TXID, "failed to parse txid"}; size_t outputs = 1; tools::wallet2::transfer_container transfers;