diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 06f834e9c07..18bc7733212 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -5594,7 +5594,10 @@ void simple_wallet::on_new_block(uint64_t height, const cryptonote::block& block m_refresh_progress_reporter.update(height, false); } //---------------------------------------------------------------------------------------------------- -void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time) +void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid, + const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, + const cryptonote::subaddress_index& subaddr_index, const crypto::hash &payment_id, bool is_change, + uint64_t unlock_time) { if (m_locked) return; @@ -5609,31 +5612,12 @@ void simple_wallet::on_money_received(uint64_t height, const crypto::hash &txid, tr("idx ") << subaddr_index; const uint64_t warn_height = m_wallet->nettype() == TESTNET ? 1000000 : m_wallet->nettype() == STAGENET ? 50000 : 1650000; - if (height >= warn_height && !is_change) + if (height >= warn_height && !is_change && payment_id != crypto::null_hash) { - std::vector tx_extra_fields; - parse_tx_extra(tx.extra, tx_extra_fields); // failure ok - tx_extra_nonce extra_nonce; - tx_extra_pub_key extra_pub_key; - crypto::hash8 payment_id8 = crypto::null_hash8; - if (find_tx_extra_field_by_type(tx_extra_fields, extra_pub_key)) - { - const crypto::public_key &tx_pub_key = extra_pub_key.pub_key; - if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) - { - if (get_encrypted_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id8)) - { - m_wallet->get_account().get_device().decrypt_payment_id(payment_id8, tx_pub_key, m_wallet->get_account().get_keys().m_view_secret_key); - } - } - } - - if (payment_id8 != crypto::null_hash8) + if (!tools::wallet::is_long_payment_id(payment_id)) message_writer() << tr("NOTE: this transaction uses an encrypted payment ID: consider using subaddresses instead"); - - crypto::hash payment_id = crypto::null_hash; - if (get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, payment_id)) + else message_writer(console_color_red, false) << tr("WARNING: this transaction uses an unencrypted payment ID: these are obsolete and ignored. Use subaddresses instead."); } diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 76ece1b3893..651a7a0ca47 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -338,7 +338,7 @@ namespace cryptonote //----------------- i_wallet2_callback --------------------- virtual void on_new_block(uint64_t height, const cryptonote::block& block); - virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time); + virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, const crypto::hash &payment_id, bool is_change, uint64_t unlock_time); virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index); virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx, uint64_t amount, const cryptonote::transaction& spend_tx, const cryptonote::subaddress_index& subaddr_index); virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx); diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 92f5d66d896..51dd050e4dd 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -194,7 +194,10 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback } } - virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time) + virtual void on_money_received(uint64_t height, const crypto::hash &txid, + const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, + const cryptonote::subaddress_index& subaddr_index, const crypto::hash &payment_id, + bool is_change, uint64_t unlock_time) { std::string tx_hash = epee::string_tools::pod_to_hex(txid); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 68ac1d6c896..421f81188ee 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2566,7 +2566,7 @@ void wallet2::process_new_scanned_transaction( // money received callbacks LOG_PRINT_L0("Received money: " << print_money(td.amount()) << ", with tx: " << txid); if (!ignore_callbacks && 0 != m_callback && td.m_amount > 0) - m_callback->on_money_received(height, txid, tx, td.m_amount, 0, td.m_subaddr_index, spends_one_of_ours(tx), td.m_tx.unlock_time); + m_callback->on_money_received(height, txid, tx, td.m_amount, 0, td.m_subaddr_index, payment_id, spends_one_of_ours(tx), td.m_tx.unlock_time); } THROW_WALLET_EXCEPTION_IF(tx_money_got_in_outs.size() != tx_amounts_individual_outs.size(), error::wallet_internal_error, "Inconsistent size of output arrays"); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 521061ee470..975ff728b39 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -136,7 +136,7 @@ namespace tools // Full wallet callbacks virtual void on_new_block(uint64_t height, const cryptonote::block& block) {} virtual void on_reorg(uint64_t height, uint64_t blocks_detached, size_t transfers_detached) {} - virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time) {} + virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, const crypto::hash &payment_id, bool is_change, uint64_t unlock_time) {} virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index) {} virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx, uint64_t amount, const cryptonote::transaction& spend_tx, const cryptonote::subaddress_index& subaddr_index) {} virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}