few amendments to spending estimation

add_selenium_testing
moneroexamples 7 years ago
parent 87e113d2b6
commit 8d018ecfdf

@ -1372,8 +1372,14 @@ public:
vector<txin_to_key> input_key_imgs = xmreg::get_key_images(tx);
// to hold sum of xmr in matched mixins, those that
// perfectly match mixin public key with outputs in mixn_tx.
uint64_t sum_mixin_xmr {0};
// this is used for the final check. we assument that number of
// parefct matches must be equal to number of inputs in a tx.
uint64_t no_of_matched_mixins {0};
for (const txin_to_key& in_key: input_key_imgs)
{
@ -1589,10 +1595,6 @@ public:
if (mine_output)
{
// cout << " - " << pod_to_hex(txout_k.key)
// <<": " << mine_output << " amount: "
// << xmreg::xmr_amount_to_str(amount)
// << endl;
found_something = true;
show_key_images = true;
@ -1605,10 +1607,14 @@ public:
continue;
}
no_of_matched_mixins++;
// for regular txs, just concentrated on outputs
// which have same amount as the key image.
// for ringct its not possible to know for sure amount
// in key image without spend key, so we just use all
// for regular/old txs there must be also a match
// in amounts, not only in output public keys
if (mixin_tx.version < 2 && amount == in_key.amount)
{
sum_mixin_xmr += amount;
@ -1644,21 +1650,29 @@ public:
context["show_inputs"] = show_key_images;
context["inputs_no"] = static_cast<uint64_t>(inputs.size());
context["sum_mixin_xmr"] = xmreg::xmr_amount_to_str(sum_mixin_xmr);
context["sum_mixin_xmr"] = xmreg::xmr_amount_to_str(
sum_mixin_xmr, "{:0.12f}", false);
uint64_t possible_spending {0};
if (sum_mixin_xmr > (sum_xmr + txd.fee))
// show spending only if sum of mixins is more than
// what we get + fee, and number of perferctly matched
// mixis is equal to number of inputs
if (sum_mixin_xmr > (sum_xmr + txd.fee)
&& no_of_matched_mixins == inputs.size())
{
// (outcoming - incoming) - fee
possible_spending = (sum_mixin_xmr - sum_xmr) - txd.fee;
}
context["possible_spending"] = xmreg::xmr_amount_to_str(
possible_spending, "{:0.12f}", false);
//cout << "no_of_matched_mixins: " << no_of_matched_mixins << endl;
// read my_outputs.html
string my_outputs_html = xmreg::read(TMPL_MY_OUTPUTS);

@ -132,7 +132,7 @@
</div>
<h3>
Sum XMR from matched mixin's outputs: {{sum_mixin_xmr}}
Sum XMR from matched and marked by * mixin's outputs: {{sum_mixin_xmr}}
<br/>
<span style="font-size: 16px"> Possible spending is:
{{possible_spending}} (tx fee included)

Loading…
Cancel
Save