From 23756691b7de94e256a7b7157c60ba4e09235853 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Sun, 2 Mar 2025 22:15:50 +0000 Subject: [PATCH] Hotfix release to address 2 wallet issues: 1. new wallet "set" parameter "send-change-back-to-subaddress [1|0]" The change for a transaction can now be sent back to the main address for the wallet (default) or to the sending subaddress (* please note that for AUDIT TX type, it will ALWAYS be sent back to the subaddress) 2. fixed erroneous code setting "source_asset" in wallet2::process_new_transaction() This bug caused change entries to appear in all TXs when querying using "get_transfer_by_txid" RPC method as "in" output types. Whilst this is fully conformant to the Monero Docs that describe the method in question, it did not conform to the experience of the RPC method users or to traditional Monero RPC output. --- src/simplewallet/simplewallet.cpp | 25 ++++++++++++++++++++++++- src/simplewallet/simplewallet.h | 1 + src/version.cpp.in | 2 +- src/wallet/wallet2.cpp | 27 +++++++++++++++++++++------ src/wallet/wallet2.h | 3 +++ 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 0affc25ad..097353a98 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -3200,6 +3200,25 @@ bool simple_wallet::set_freeze_incoming_payments(const std::vector return true; } +bool simple_wallet::set_send_change_back_to_subaddress(const std::vector &args/* = std::vector()*/) +{ + if (args.size() < 2) + { + fail_msg_writer() << tr("Value not specified"); + return true; + } + + const auto pwd_container = get_and_verify_password(); + if (pwd_container) + { + parse_bool_and_use(args[1], [&](bool r) { + m_wallet->send_change_back_to_subaddress(r); + m_wallet->rewrite(m_wallet_file, pwd_container->password()); + }); + } + return true; +} + bool simple_wallet::help(const std::vector &args/* = std::vector()*/) { if(args.empty()) @@ -3562,7 +3581,9 @@ simple_wallet::simple_wallet() "inactivity-lock-timeout \n " " How many seconds to wait before locking the wallet (0 to disable).\n" "freeze-incoming-payments <1|0>\n " - " Whether to have incoming payments automatically frozen, so they cannot be spent erroneously.")); + " Whether to have incoming payments automatically frozen, so they cannot be spent erroneously.\n" + "send-change-back-to-subaddress <1|0>\n " + " Whether to have change from transactions sent back subaddresses (1) or to main address (0) (ignored for AUDIT commands).")); m_cmd_binder.set_handler("encrypted_seed", boost::bind(&simple_wallet::on_command, this, &simple_wallet::encrypted_seed, _1), tr("Display the encrypted Electrum-style mnemonic seed.")); @@ -3979,6 +4000,7 @@ bool simple_wallet::set_variable(const std::vector &args) success_msg_writer() << "load-deprecated-formats = " << m_wallet->load_deprecated_formats(); success_msg_writer() << "enable-multisig-experimental = " << m_wallet->is_multisig_enabled(); success_msg_writer() << "freeze-incoming-payments = " << m_wallet->is_freeze_incoming_payments_enabled(); + success_msg_writer() << "send-change-back-to-subaddress = " << m_wallet->is_send_change_back_to_subaddress_enabled(); return true; } else @@ -4047,6 +4069,7 @@ bool simple_wallet::set_variable(const std::vector &args) CHECK_SIMPLE_VARIABLE("credits-target", set_credits_target, tr("unsigned integer")); CHECK_SIMPLE_VARIABLE("enable-multisig-experimental", set_enable_multisig, tr("0 or 1")); CHECK_SIMPLE_VARIABLE("freeze-incoming-payments", set_freeze_incoming_payments, tr("0 or 1")); + CHECK_SIMPLE_VARIABLE("send-change-back-to-subaddress", set_send_change_back_to_subaddress, tr("0 or 1")); } fail_msg_writer() << tr("set: unrecognized argument(s)"); return true; diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index afe811505..75e54acb7 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -156,6 +156,7 @@ namespace cryptonote bool set_load_deprecated_formats(const std::vector &args = std::vector()); bool set_enable_multisig(const std::vector &args = std::vector()); bool set_freeze_incoming_payments(const std::vector &args = std::vector()); + bool set_send_change_back_to_subaddress(const std::vector &args = std::vector()); bool set_persistent_rpc_client_id(const std::vector &args = std::vector()); bool set_auto_mine_for_rpc_payment_threshold(const std::vector &args = std::vector()); bool set_credits_target(const std::vector &args = std::vector()); diff --git a/src/version.cpp.in b/src/version.cpp.in index 35d942a24..f328b00cd 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -1,5 +1,5 @@ #define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@" -#define DEF_SALVIUM_VERSION "0.9.5" +#define DEF_SALVIUM_VERSION "0.9.5a" #define DEF_MONERO_VERSION_TAG "release" #define DEF_MONERO_VERSION "0.18.3.3" #define DEF_MONERO_RELEASE_NAME "Zero" diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index f3f824e01..5f8bae7a7 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1252,6 +1252,7 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std m_credits_target(0), m_enable_multisig(false), m_freeze_incoming_payments(false), + m_send_change_back_to_subaddress(false), m_pool_info_query_time(0), m_has_ever_refreshed_from_node(false), m_allow_mismatched_daemon_version(false) @@ -2574,12 +2575,12 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote process_unconfirmed(txid, tx, height); std::string source_asset; - if (use_fork_rules(get_salvium_one_proofs_fork(), 0)) { - if (tx.type == cryptonote::transaction_type::MINER && tx.type == cryptonote::transaction_type::PROTOCOL) { + if (tx.type == cryptonote::transaction_type::MINER || tx.type == cryptonote::transaction_type::PROTOCOL) { + if (use_fork_rules(get_salvium_one_proofs_fork(), 0)) { source_asset = "SAL1"; + } else { + source_asset = "SAL"; } - } else if (tx.type == cryptonote::transaction_type::MINER && tx.type == cryptonote::transaction_type::PROTOCOL) { - source_asset = "SAL"; } else { source_asset = tx.source_asset_type; } @@ -5144,6 +5145,9 @@ boost::optional wallet2::get_keys_file_data(const epee: value2.SetInt(m_freeze_incoming_payments ? 1 : 0); json.AddMember("freeze_incoming_payments", value2, json.GetAllocator()); + value2.SetInt(m_send_change_back_to_subaddress ? 1 : 0); + json.AddMember("send_change_back_to_subaddress", value2, json.GetAllocator()); + // Serialize the JSON object rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); @@ -5291,6 +5295,7 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st m_credits_target = 0; m_enable_multisig = false; m_freeze_incoming_payments = false; + m_send_change_back_to_subaddress = false; m_allow_mismatched_daemon_version = false; } else if(json.IsObject()) @@ -5530,6 +5535,8 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st m_enable_multisig = field_enable_multisig; GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, freeze_incoming_payments, int, Int, false, false); m_freeze_incoming_payments = field_freeze_incoming_payments; + GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, send_change_back_to_subaddress, int, Int, false, false); + m_send_change_back_to_subaddress = field_send_change_back_to_subaddress; } else { @@ -10244,8 +10251,16 @@ void wallet2::transfer_selected_rct(std::vector