diff --git a/src/carrot_core/account.h b/src/carrot_core/account.h index b4e2ffc0e..1a0e78deb 100644 --- a/src/carrot_core/account.h +++ b/src/carrot_core/account.h @@ -49,8 +49,8 @@ namespace carrot crypto::public_key K_o; // output onetime address crypto::public_key K_change; // change output onetime address crypto::key_image key_image; - crypto::secret_key x; - crypto::secret_key y; + crypto::secret_key sum_g; + crypto::secret_key sender_extension_t; return_output_info_t() { // Default constructor for serialization @@ -58,8 +58,8 @@ namespace carrot K_o = crypto::public_key(); K_change = crypto::public_key(); key_image = crypto::key_image(); - x = crypto::secret_key(); - y = crypto::secret_key(); + sum_g = crypto::secret_key(); + sender_extension_t = crypto::secret_key(); } return_output_info_t( @@ -67,22 +67,22 @@ namespace carrot const crypto::public_key &K_o, const crypto::public_key &K_change, const crypto::key_image &key_image, - const crypto::secret_key &x, - const crypto::secret_key &y): + const crypto::secret_key &sum_g, + const crypto::secret_key &sender_extension_t): input_context(input_context), K_o(K_o), K_change(K_change), key_image(key_image), - x(x), - y(y) {} + sum_g(sum_g), + sender_extension_t(sender_extension_t) {} BEGIN_SERIALIZE_OBJECT() FIELD(input_context) FIELD(K_o) FIELD(K_change) FIELD(key_image) - FIELD(x) - FIELD(y) + FIELD(sum_g) + FIELD(sender_extension_t) END_SERIALIZE() }; @@ -189,8 +189,8 @@ namespace boost x.K_o = crypto::public_key(); x.K_change = crypto::public_key(); x.key_image = crypto::key_image(); - x.x = crypto::secret_key(); - x.y = crypto::secret_key(); + x.sum_g = crypto::secret_key(); + x.sender_extension_t = crypto::secret_key(); } template @@ -200,8 +200,8 @@ namespace boost a & x.K_o; a & x.K_change; a & x.key_image; - a & x.x; - a & x.y; + a & x.sum_g; + a & x.sender_extension_t; } } } diff --git a/src/carrot_core/scan.cpp b/src/carrot_core/scan.cpp index c2fc762dc..d205cbb67 100644 --- a/src/carrot_core/scan.cpp +++ b/src/carrot_core/scan.cpp @@ -477,7 +477,6 @@ bool try_scan_carrot_enote_internal_receiver(const CarrotEnoteV1 &enote, { // Determine whether this is a full wallet or a watch-only wallet const cryptonote::account_keys &keys = account.get_keys(); - bool watch_only = (keys.m_spend_secret_key == crypto::null_skey && keys.m_view_secret_key == crypto::null_skey); // input_context const input_context_t input_context = make_carrot_input_context(enote.tx_first_key_image); @@ -524,45 +523,19 @@ bool try_scan_carrot_enote_internal_receiver(const CarrotEnoteV1 &enote, // compute K_r = K_return + K_o crypto::public_key K_r = rct::rct2pk(rct::addKeys(rct::pk2rct(K_return), rct::pk2rct(enote.onetime_address))); - // Is this a watch-only wallet? - if (watch_only) { + // calculate the key image for the return output + crypto::secret_key sum_g; + sc_add(to_bytes(sum_g), to_bytes(sender_extension_g_out), to_bytes(k_return)); + crypto::key_image key_image = account.derive_key_image_view_only(address_spend_pubkey_out, + sum_g, + sender_extension_t_out, + K_r + ); - // calculate the key image for the return output - crypto::secret_key sum_g; - sc_add(to_bytes(sum_g), to_bytes(sender_extension_g_out), to_bytes(k_return)); - crypto::key_image key_image = account.derive_key_image_view_only(address_spend_pubkey_out, - sum_g, - sender_extension_t_out, - K_r - ); - - // HERE BE DRAGONS!!! - // SRCG: test whether this will even work for return_payment detection - account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, key_image, crypto::null_skey, crypto::null_skey}}}); - // LAND AHOY!!! - - } else { - - // calculate the key image for the return output - crypto::secret_key sum_g; - sc_add(to_bytes(sum_g), to_bytes(sender_extension_g_out), to_bytes(k_return)); - crypto::key_image key_image = account.derive_key_image(address_spend_pubkey_out, - sum_g, - sender_extension_t_out, - K_r - ); - - crypto::secret_key x, y; - account.try_searching_for_opening_for_onetime_address(address_spend_pubkey_out, - sum_g, - sender_extension_t_out, - x, - y - ); - - // save the input context & change output key - account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, key_image, x, y}}}); - } + // HERE BE DRAGONS!!! + // SRCG: test whether this will even work for return_payment detection + account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, key_image, sum_g, sender_extension_t_out}}}); + // LAND AHOY!!! } // janus protection checks are not needed for internal scans diff --git a/src/wallet/tx_builder.cpp b/src/wallet/tx_builder.cpp index 33446cec7..bfe9e6b8d 100644 --- a/src/wallet/tx_builder.cpp +++ b/src/wallet/tx_builder.cpp @@ -818,8 +818,13 @@ bool get_address_openings_x_y( if (return_output_map.find(rct::rct2pk(src.outputs[src.real_output].second.dest)) != return_output_map.end()) { const auto &return_output = return_output_map.at(rct::rct2pk(src.outputs[src.real_output].second.dest)); - x_out = return_output.x; - y_out = return_output.y; + w.get_account().try_searching_for_opening_for_onetime_address( + return_output.K_change, + return_output.sum_g, + return_output.sender_extension_t, + x_out, + y_out + ); return true; }