diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index ab0bde122..32547e335 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -856,7 +856,7 @@ namespace cryptonote uint64_t summary_outs_money = 0; //fill outputs size_t output_index = 0; - size_t change_index = 0; + uint8_t change_index = 0; for(const tx_destination_entry& dst_entr: destinations) { CHECK_AND_ASSERT_MES(dst_entr.amount > 0 || tx.version > 1, false, "Destination with wrong amount: " << dst_entr.amount); diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h index a34262753..f7bf7dac4 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.h +++ b/src/cryptonote_core/cryptonote_tx_utils.h @@ -150,6 +150,7 @@ namespace cryptonote FIELD(original) VARINT_FIELD(amount) FIELD(addr) + FIELD(asset_type) FIELD(is_subaddress) FIELD(is_integrated) FIELD(is_change) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 8b03f8369..cd41aa763 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -11391,7 +11391,7 @@ std::vector wallet2::create_transactions_return(std::vector // Get P_change from the TX crypto::public_key P_change = crypto::null_pkey; - size_t change_index; + uint8_t change_index; uint32_t hf_version = get_current_hard_fork(); if (hf_version >= HF_VERSION_ENABLE_N_OUTS && td_origin.m_tx.version >= TRANSACTION_VERSION_N_OUTS) { @@ -11452,6 +11452,11 @@ std::vector wallet2::create_transactions_return(std::vector return_address = td_origin.m_tx.return_address; } + + // Sanity check that we aren't attempting to return our own TX change output to ourselves + THROW_WALLET_EXCEPTION_IF(change_index == td_origin.m_internal_output_index, error::wallet_internal_error, tr("Attempting to return change to ourself")); + + // Sanity check that we can obtain the change output from the origin TX THROW_WALLET_EXCEPTION_IF(!cryptonote::get_output_public_key(td_origin.m_tx.vout[change_index], P_change), error::wallet_internal_error, tr("Failed to identify change output")); @@ -11461,10 +11466,6 @@ std::vector wallet2::create_transactions_return(std::vector rct::key key_F = (rct::key&)(return_address); rct::key key_yF = rct::scalarmultKey(key_F, key_y); - // Sanity check that we aren't attempting to return our own TX output to ourselves - rct::key key_yF_check = rct::scalarmultKey(rct::sk2rct(m_account.get_keys().m_view_secret_key), rct::pk2rct(P_change)); - THROW_WALLET_EXCEPTION_IF(key_yF_check == key_yF, error::wallet_internal_error, tr("Attempting to return a payment to ourself")); - // Build the subaddress to send the return to cryptonote::account_public_address address; address.m_spend_public_key = P_change; diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 44f1415fc..22df641c1 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -392,6 +392,7 @@ namespace tools td.address = d.address(m_wallet->nettype(), pd.m_payment_id); } + entry.asset_type = pd.m_tx.source_asset_type; entry.type = "out"; entry.subaddr_index = { pd.m_subaddr_account, 0 }; for (uint32_t i: pd.m_subaddr_indices) @@ -424,6 +425,7 @@ namespace tools } entry.type = is_failed ? "failed" : "pending"; + entry.asset_type = pd.m_tx.source_asset_type; entry.subaddr_index = { pd.m_subaddr_account, 0 }; for (uint32_t i: pd.m_subaddr_indices) entry.subaddr_indices.push_back({pd.m_subaddr_account, i});