show which key images were spend for ran signed tx

master
moneroexamples 8 years ago
parent 34e9aa72d7
commit 24dc2502fd

@ -1520,6 +1520,8 @@ namespace xmreg {
for (mstch::node& input_node: inputs) for (mstch::node& input_node: inputs)
{ {
mstch::map& input_map = boost::get<mstch::map>(input_node);
// show input amount // show input amount
string& amount = boost::get<string>( string& amount = boost::get<string>(
boost::get<mstch::map>(input_node)["amount"] boost::get<mstch::map>(input_node)["amount"]
@ -1527,6 +1529,22 @@ namespace xmreg {
amount = fmt::format("{:0.12f}", XMR_AMOUNT(real_amounts.at(input_idx))); amount = fmt::format("{:0.12f}", XMR_AMOUNT(real_amounts.at(input_idx)));
// check if key images are spend or not
string& in_key_img_str = boost::get<string>(
boost::get<mstch::map>(input_node)["in_key_img"]
);
key_image key_imgage;
if (epee::string_tools::hex_to_pod(in_key_img_str, key_imgage))
{
input_map["already_spent"] = core_storage->get_db().has_key_image(key_imgage);
}
// mark real mixings
mstch::array& mixins = boost::get<mstch::array>( mstch::array& mixins = boost::get<mstch::array>(
boost::get<mstch::map>(input_node)["mixins"] boost::get<mstch::map>(input_node)["mixins"]
); );
@ -1573,7 +1591,6 @@ namespace xmreg {
++idx; ++idx;
} }
boost::get<mstch::array>(context["txs"]).push_back(tx_context); boost::get<mstch::array>(context["txs"]).push_back(tx_context);
} }
@ -2324,7 +2341,8 @@ namespace xmreg {
{"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))}, {"amount" , fmt::format("{:0.12f}", XMR_AMOUNT(in_key.amount))},
{"input_idx" , fmt::format("{:02d}", input_idx)}, {"input_idx" , fmt::format("{:02d}", input_idx)},
{"mixins" , mstch::array{}}, {"mixins" , mstch::array{}},
{"ring_sigs" , txd.get_ring_sig_for_input(input_idx)} {"ring_sigs" , txd.get_ring_sig_for_input(input_idx)},
{"already_spent", false} // placeholder for later
}); });
inputs_xmr_sum += in_key.amount; inputs_xmr_sum += in_key.amount;

@ -125,7 +125,19 @@
<table class="center"> <table class="center">
{{#inputs}} {{#inputs}}
<tr> <tr>
<td style="text-align: left;">key image {{input_idx}}: {{in_key_img}}</td> <td style="text-align: left;">
key image {{input_idx}}: {{in_key_img}}
{{#have_raw_tx}}
Already spent:
{{#already_spent}}
<span style="color: red; font-weight: bold;">True</span>
{{/already_spent}}
{{^already_spent}}
False
{{/already_spent}}
{{/#have_raw_tx}}
</td>
<td>amount: {{amount}}</td> <td>amount: {{amount}}</td>
</tr> </tr>
<tr> <tr>

Loading…
Cancel
Save