refactor return-by-reference

This commit is contained in:
Thomas Winget 2022-04-26 12:35:00 -04:00
parent f3a3399723
commit 1ce7a92ea8
3 changed files with 11 additions and 12 deletions

View File

@ -114,14 +114,15 @@ namespace wallet
}
// TODO: replace later when removing wallet2½ layer
uint64_t
Keyring::output_amount(
std::pair<uint64_t, rct::key>
Keyring::output_amount_and_mask(
const rct::rctSig& rv,
const crypto::key_derivation& derivation,
unsigned int i,
rct::key& mask)
unsigned int i)
{
return wallet25::output_amount(rv, derivation, i, mask, key_device);
rct::key mask{};
auto amount = wallet25::output_amount(rv, derivation, i, mask, key_device);
return {amount, std::move(mask)};
}
// This gets called for every output in the transaction, there is some complication for how the

View File

@ -68,12 +68,11 @@ namespace wallet
uint64_t output_index,
const cryptonote::subaddress_index& sub_index);
virtual uint64_t
output_amount(
virtual std::pair<uint64_t, rct::key>
output_amount_and_mask(
const rct::rctSig& rv,
const crypto::key_derivation& derivation,
unsigned int i,
rct::key& mask);
unsigned int i);
virtual crypto::public_key
generate_output_ephemeral_keys(

View File

@ -66,10 +66,9 @@ namespace wallet
Output o;
// TODO: ringct mask returned by reference. ugh.
auto amount = wallet_keys->output_amount(
tx.tx.rct_signatures, derivations[derivation_index], output_index, o.rct_mask);
std::tie(o.amount, o.rct_mask) = wallet_keys->output_amount_and_mask(
tx.tx.rct_signatures, derivations[derivation_index], output_index);
o.amount = amount;
o.key_image = key_image;
o.subaddress_index = *sub_index;
o.output_index = output_index;