Fixed pre-scanning for STAKE TXs
This commit is contained in:
@@ -110,7 +110,7 @@ CarrotDestinationV1 carrot_and_legacy_account::subaddress(const subaddress_index
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> carrot_and_legacy_account::get_subaddress_map() const
|
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> carrot_and_legacy_account::get_subaddress_map_cn() const
|
||||||
{
|
{
|
||||||
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> res;
|
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> res;
|
||||||
for (const auto &p : subaddress_map)
|
for (const auto &p : subaddress_map)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace carrot
|
|||||||
|
|
||||||
CarrotDestinationV1 subaddress(const subaddress_index_extended &subaddress_index) const;
|
CarrotDestinationV1 subaddress(const subaddress_index_extended &subaddress_index) const;
|
||||||
|
|
||||||
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> get_subaddress_map() const;
|
std::unordered_map<crypto::public_key, cryptonote::subaddress_index> get_subaddress_map_cn() const;
|
||||||
|
|
||||||
// brief: opening_for_subaddress - return (k^g_a, k^t_a) for j s.t. K^j_s = (k^g_a * G + k^t_a * T)
|
// brief: opening_for_subaddress - return (k^g_a, k^t_a) for j s.t. K^j_s = (k^g_a * G + k^t_a * T)
|
||||||
void opening_for_subaddress(const subaddress_index_extended &subaddress_index,
|
void opening_for_subaddress(const subaddress_index_extended &subaddress_index,
|
||||||
|
|||||||
@@ -142,9 +142,11 @@ static std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_pre_car
|
|||||||
const std::optional<carrot::encrypted_payment_id_t> &encrypted_payment_id,
|
const std::optional<carrot::encrypted_payment_id_t> &encrypted_payment_id,
|
||||||
const epee::span<const crypto::key_derivation> main_derivations,
|
const epee::span<const crypto::key_derivation> main_derivations,
|
||||||
const epee::span<const crypto::key_derivation> additional_derivations,
|
const epee::span<const crypto::key_derivation> additional_derivations,
|
||||||
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map,
|
carrot::carrot_and_legacy_account &account,
|
||||||
hw::device &hwdev)
|
hw::device &hwdev)
|
||||||
{
|
{
|
||||||
|
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map = account.get_subaddress_map_cn();
|
||||||
|
|
||||||
boost::optional<cryptonote::subaddress_receive_info> receive_info;
|
boost::optional<cryptonote::subaddress_receive_info> receive_info;
|
||||||
size_t main_deriv_idx;
|
size_t main_deriv_idx;
|
||||||
for (main_deriv_idx = 0; main_deriv_idx < std::max<size_t>(1, main_derivations.size()); ++main_deriv_idx)
|
for (main_deriv_idx = 0; main_deriv_idx < std::max<size_t>(1, main_derivations.size()); ++main_deriv_idx)
|
||||||
@@ -236,6 +238,12 @@ static std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_pre_car
|
|||||||
.derive_type = carrot::AddressDeriveType::PreCarrot
|
.derive_type = carrot::AddressDeriveType::PreCarrot
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// HERE BE DRAGONS!!!
|
||||||
|
// SRCG: whilst the following code will work, it'd be better being moved to the TX_BUILDER code
|
||||||
|
// add the entry to our subaddress map in case it's a change payment (false positives won't hurt us)
|
||||||
|
account.subaddress_map.insert({enote.onetime_address, subaddr_index});
|
||||||
|
// LAND AHOY!!!
|
||||||
|
|
||||||
return enote_view_incoming_scan_info_t{
|
return enote_view_incoming_scan_info_t{
|
||||||
.sender_extension_g = sender_extension_g,
|
.sender_extension_g = sender_extension_g,
|
||||||
.sender_extension_t = crypto::null_skey,
|
.sender_extension_t = crypto::null_skey,
|
||||||
@@ -331,7 +339,7 @@ static std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_carrot_
|
|||||||
const mx25519_pubkey &s_sender_receiver_unctx,
|
const mx25519_pubkey &s_sender_receiver_unctx,
|
||||||
const crypto::public_key &main_address_spend_pubkey,
|
const crypto::public_key &main_address_spend_pubkey,
|
||||||
const carrot::view_incoming_key_device &k_view_dev,
|
const carrot::view_incoming_key_device &k_view_dev,
|
||||||
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map)
|
carrot::carrot_and_legacy_account &account)
|
||||||
{
|
{
|
||||||
enote_view_incoming_scan_info_t res;
|
enote_view_incoming_scan_info_t res;
|
||||||
|
|
||||||
@@ -352,13 +360,13 @@ static std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_carrot_
|
|||||||
dummy_enote_type))
|
dummy_enote_type))
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
const auto subaddr_it = subaddress_map.find(res.address_spend_pubkey);
|
const auto subaddr_it = account.subaddress_map.find(res.address_spend_pubkey);
|
||||||
CHECK_AND_ASSERT_MES(subaddr_it != subaddress_map.cend(),
|
CHECK_AND_ASSERT_MES(subaddr_it != account.subaddress_map.cend(),
|
||||||
std::nullopt,
|
std::nullopt,
|
||||||
"view_incoming_scan_carrot_enote: carrot enote scanned successfully, "
|
"view_incoming_scan_carrot_enote: carrot enote scanned successfully, "
|
||||||
"but the recovered address spend pubkey was not found in the subaddress map");
|
"but the recovered address spend pubkey was not found in the subaddress map");
|
||||||
|
|
||||||
const carrot::subaddress_index_extended subaddr_index = {{subaddr_it->second.major, subaddr_it->second.minor}};
|
const carrot::subaddress_index_extended subaddr_index = subaddr_it->second;
|
||||||
|
|
||||||
memset(&res.payment_id, 0, sizeof(res.payment_id));
|
memset(&res.payment_id, 0, sizeof(res.payment_id));
|
||||||
memcpy(&res.payment_id, &payment_id, sizeof(carrot::payment_id_t));
|
memcpy(&res.payment_id, &payment_id, sizeof(carrot::payment_id_t));
|
||||||
@@ -461,7 +469,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote(
|
|||||||
const epee::span<const crypto::key_derivation> additional_derivations,
|
const epee::span<const crypto::key_derivation> additional_derivations,
|
||||||
const cryptonote::account_public_address &address,
|
const cryptonote::account_public_address &address,
|
||||||
const carrot::view_incoming_key_device *k_view_dev,
|
const carrot::view_incoming_key_device *k_view_dev,
|
||||||
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map,
|
carrot::carrot_and_legacy_account &account,
|
||||||
hw::device &hwdev)
|
hw::device &hwdev)
|
||||||
{
|
{
|
||||||
CHECK_AND_ASSERT_MES(!main_derivations.empty() || !additional_derivations.empty(),
|
CHECK_AND_ASSERT_MES(!main_derivations.empty() || !additional_derivations.empty(),
|
||||||
@@ -487,7 +495,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote(
|
|||||||
encrypted_payment_id,
|
encrypted_payment_id,
|
||||||
main_derivations,
|
main_derivations,
|
||||||
additional_derivations,
|
additional_derivations,
|
||||||
subaddress_map,
|
account,
|
||||||
hwdev);
|
hwdev);
|
||||||
|
|
||||||
// copy long plaintext payment ID, if applicable
|
// copy long plaintext payment ID, if applicable
|
||||||
@@ -532,7 +540,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote(
|
|||||||
s_sender_receiver_unctx,
|
s_sender_receiver_unctx,
|
||||||
address.m_spend_public_key,
|
address.m_spend_public_key,
|
||||||
*k_view_dev,
|
*k_view_dev,
|
||||||
subaddress_map);
|
account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +551,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote(
|
|||||||
const epee::span<const crypto::key_derivation> additional_derivations;
|
const epee::span<const crypto::key_derivation> additional_derivations;
|
||||||
const cryptonote::account_public_address &address;
|
const cryptonote::account_public_address &address;
|
||||||
const carrot::view_incoming_key_device *k_view_dev;
|
const carrot::view_incoming_key_device *k_view_dev;
|
||||||
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map;
|
carrot::carrot_and_legacy_account &account;
|
||||||
hw::device &hwdev;
|
hw::device &hwdev;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -555,7 +563,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote(
|
|||||||
additional_derivations,
|
additional_derivations,
|
||||||
address,
|
address,
|
||||||
k_view_dev,
|
k_view_dev,
|
||||||
subaddress_map,
|
account,
|
||||||
hwdev
|
hwdev
|
||||||
},
|
},
|
||||||
enote);
|
enote);
|
||||||
@@ -571,7 +579,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote(
|
|||||||
const epee::span<const crypto::key_derivation> additional_derivations,
|
const epee::span<const crypto::key_derivation> additional_derivations,
|
||||||
const cryptonote::account_public_address &address,
|
const cryptonote::account_public_address &address,
|
||||||
const carrot::view_incoming_key_device *k_view_dev,
|
const carrot::view_incoming_key_device *k_view_dev,
|
||||||
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map,
|
carrot::carrot_and_legacy_account &account,
|
||||||
hw::device &hwdev)
|
hw::device &hwdev)
|
||||||
{
|
{
|
||||||
MoneroEnoteVariant enote;
|
MoneroEnoteVariant enote;
|
||||||
@@ -628,7 +636,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote(
|
|||||||
additional_derivations,
|
additional_derivations,
|
||||||
address,
|
address,
|
||||||
k_view_dev,
|
k_view_dev,
|
||||||
subaddress_map,
|
account,
|
||||||
hwdev);
|
hwdev);
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -639,7 +647,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote_from_pre
|
|||||||
const std::size_t local_output_index,
|
const std::size_t local_output_index,
|
||||||
const cryptonote::account_public_address &address,
|
const cryptonote::account_public_address &address,
|
||||||
const crypto::secret_key &k_view_incoming,
|
const crypto::secret_key &k_view_incoming,
|
||||||
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map,
|
carrot::carrot_and_legacy_account &account,
|
||||||
hw::device &hwdev)
|
hw::device &hwdev)
|
||||||
{
|
{
|
||||||
const bool is_carrot = carrot::is_carrot_transaction_v1(tx_prefix);
|
const bool is_carrot = carrot::is_carrot_transaction_v1(tx_prefix);
|
||||||
@@ -692,7 +700,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote_from_pre
|
|||||||
epee::to_span(additional_derivations),
|
epee::to_span(additional_derivations),
|
||||||
address,
|
address,
|
||||||
&k_view_dev,
|
&k_view_dev,
|
||||||
subaddress_map,
|
account,
|
||||||
hwdev);
|
hwdev);
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -733,7 +741,7 @@ void view_incoming_scan_transaction(
|
|||||||
additional_derivations,
|
additional_derivations,
|
||||||
address,
|
address,
|
||||||
&k_view_dev,
|
&k_view_dev,
|
||||||
account.get_subaddress_map(),
|
account,
|
||||||
account.get_keys().get_device());
|
account.get_keys().get_device());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -817,6 +825,8 @@ std::vector<std::optional<enote_view_incoming_scan_info_t>> view_incoming_scan_t
|
|||||||
|
|
||||||
// 3. do view-incoming scan for each output enotes
|
// 3. do view-incoming scan for each output enotes
|
||||||
hw::device &hwdev = hw::get_device("default");
|
hw::device &hwdev = hw::get_device("default");
|
||||||
|
carrot::carrot_and_legacy_account dummy_account;
|
||||||
|
dummy_account.subaddress_map[address.m_spend_public_key] = {{}};
|
||||||
for (size_t local_output_index = 0; local_output_index < n_outputs; ++local_output_index)
|
for (size_t local_output_index = 0; local_output_index < n_outputs; ++local_output_index)
|
||||||
{
|
{
|
||||||
auto &enote_scan_info = res[local_output_index];
|
auto &enote_scan_info = res[local_output_index];
|
||||||
@@ -830,7 +840,7 @@ std::vector<std::optional<enote_view_incoming_scan_info_t>> view_incoming_scan_t
|
|||||||
custom_additional_derivations,
|
custom_additional_derivations,
|
||||||
address,
|
address,
|
||||||
/*k_view_dev=*/nullptr,
|
/*k_view_dev=*/nullptr,
|
||||||
{{address.m_spend_public_key, {}}},
|
dummy_account,
|
||||||
hwdev);
|
hwdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ std::optional<enote_view_incoming_scan_info_t> view_incoming_scan_enote_from_pre
|
|||||||
const std::size_t local_output_index,
|
const std::size_t local_output_index,
|
||||||
const cryptonote::account_public_address &address,
|
const cryptonote::account_public_address &address,
|
||||||
const crypto::secret_key &k_view_incoming,
|
const crypto::secret_key &k_view_incoming,
|
||||||
const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddress_map,
|
carrot::carrot_and_legacy_account &account,
|
||||||
hw::device &hwdev);
|
hw::device &hwdev);
|
||||||
|
|
||||||
void view_incoming_scan_transaction(
|
void view_incoming_scan_transaction(
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ std::vector<carrot::CarrotTransactionProposalV1> make_carrot_transaction_proposa
|
|||||||
const bool is_selfsend_dest = build_payment_proposals(normal_payment_proposals,
|
const bool is_selfsend_dest = build_payment_proposals(normal_payment_proposals,
|
||||||
selfsend_payment_proposals,
|
selfsend_payment_proposals,
|
||||||
de,
|
de,
|
||||||
w.get_account().get_subaddress_map());
|
w.get_account().get_subaddress_map_cn());
|
||||||
CHECK_AND_ASSERT_THROW_MES((is_selfsend_dest && selfsend_payment_proposals.size() == i+1)
|
CHECK_AND_ASSERT_THROW_MES((is_selfsend_dest && selfsend_payment_proposals.size() == i+1)
|
||||||
|| (!is_selfsend_dest && normal_payment_proposals.size() == i+1),
|
|| (!is_selfsend_dest && normal_payment_proposals.size() == i+1),
|
||||||
__func__ << ": BUG in build_payment_proposals: incorrect count for payment proposal lists");
|
__func__ << ": BUG in build_payment_proposals: incorrect count for payment proposal lists");
|
||||||
|
|||||||
@@ -2664,7 +2664,7 @@ void wallet2::process_new_scanned_transaction(
|
|||||||
origin_tx_data.tx_type = td_origin.m_tx.type;
|
origin_tx_data.tx_type = td_origin.m_tx.type;
|
||||||
rct::salvium_input_data_t sid;
|
rct::salvium_input_data_t sid;
|
||||||
THROW_WALLET_EXCEPTION_IF(!cryptonote::generate_key_image_helper(m_account.get_keys(),
|
THROW_WALLET_EXCEPTION_IF(!cryptonote::generate_key_image_helper(m_account.get_keys(),
|
||||||
m_account.get_subaddress_map(),
|
m_account.get_subaddress_map_cn(),
|
||||||
onetime_address,
|
onetime_address,
|
||||||
tx_public_key,
|
tx_public_key,
|
||||||
additional_tx_public_keys,
|
additional_tx_public_keys,
|
||||||
@@ -10414,7 +10414,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
|
|||||||
std::vector<std::pair<std::string, std::string>> circ_amounts;
|
std::vector<std::pair<std::string, std::string>> circ_amounts;
|
||||||
THROW_WALLET_EXCEPTION_IF(!get_circulating_supply(circ_amounts), error::wallet_internal_error, "Failed to get circulating supply");
|
THROW_WALLET_EXCEPTION_IF(!get_circulating_supply(circ_amounts), error::wallet_internal_error, "Failed to get circulating supply");
|
||||||
// make a normal tx
|
// make a normal tx
|
||||||
bool r = cryptonote::construct_tx_and_get_tx_key(a_keys/*m_account.get_keys()*/, m_account.get_subaddress_map(), sources, splitted_dsts, hf_version, source_asset, dest_asset, tx_type, change_dts.addr, extra, tx, unlock_time, tx_key, additional_tx_keys, true, rct_config, use_view_tags);
|
bool r = cryptonote::construct_tx_and_get_tx_key(a_keys/*m_account.get_keys()*/, m_account.get_subaddress_map_cn(), sources, splitted_dsts, hf_version, source_asset, dest_asset, tx_type, change_dts.addr, extra, tx, unlock_time, tx_key, additional_tx_keys, true, rct_config, use_view_tags);
|
||||||
LOG_PRINT_L2("constructed tx, r="<<r);
|
LOG_PRINT_L2("constructed tx, r="<<r);
|
||||||
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, dsts, unlock_time, m_nettype);
|
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, dsts, unlock_time, m_nettype);
|
||||||
}
|
}
|
||||||
@@ -13881,7 +13881,7 @@ crypto::public_key wallet2::get_tx_pub_key_from_received_outs(const tools::walle
|
|||||||
td.m_internal_output_index,
|
td.m_internal_output_index,
|
||||||
m_account_public_address,
|
m_account_public_address,
|
||||||
m_account.get_keys().m_view_secret_key,
|
m_account.get_keys().m_view_secret_key,
|
||||||
m_account.get_subaddress_map(),
|
m_account,
|
||||||
m_account.get_device());
|
m_account.get_device());
|
||||||
|
|
||||||
const size_t main_tx_pubkey_index = enote_scan_info ? enote_scan_info->main_tx_pubkey_index : 0;
|
const size_t main_tx_pubkey_index = enote_scan_info ? enote_scan_info->main_tx_pubkey_index : 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user