show number of non-ringct inputs

This commit is contained in:
kenshi84 2017-02-17 11:47:35 +09:00
parent 7d28eecfcb
commit 881b87b0de
5 changed files with 67 additions and 4 deletions

View file

@ -108,6 +108,7 @@ struct tx_details
crypto::public_key pk;
uint64_t xmr_inputs;
uint64_t xmr_outputs;
uint64_t num_nonrct_inputs;
uint64_t fee;
uint64_t mixin_no;
uint64_t size;
@ -171,6 +172,7 @@ struct tx_details
{"sum_outputs_short" , xmr_amount_to_str(xmr_outputs, "{:0.3f}")},
{"no_inputs" , static_cast<uint64_t>(input_key_imgs.size())},
{"no_outputs" , static_cast<uint64_t>(output_pub_keys.size())},
{"no_nonrct_inputs" , num_nonrct_inputs},
{"mixin" , mixin_str},
{"blk_height" , blk_height},
{"version" , std::to_string(version)},
@ -513,6 +515,7 @@ public:
// sum xmr in inputs and ouputs in the given tx
pair<uint64_t, uint64_t> sum_inputs = xmreg::sum_money_in_inputs(_tx_info.tx_json);
pair<uint64_t, uint64_t> sum_outputs = xmreg::sum_money_in_outputs(_tx_info.tx_json);
uint64_t num_nonrct_inputs = xmreg::count_nonrct_inputs(_tx_info.tx_json);
sum_money_in_outputs(_tx_info.tx_json);
@ -560,6 +563,7 @@ public:
{"xmr_outputs" , xmreg::xmr_amount_to_str(sum_outputs.first, "{:0.3f}")},
{"no_inputs" , sum_inputs.second},
{"no_outputs" , sum_outputs.second},
{"no_nonrct_inputs", num_nonrct_inputs},
{"is_ringct" , is_ringct_str},
{"rct_type" , rct_type_str},
{"mixin" , fmt::format("{:d}", mixin_no)},
@ -4282,6 +4286,7 @@ private:
// sum xmr in inputs and ouputs in the given tx
txd.xmr_inputs = sum_money_in_inputs(tx);
txd.xmr_outputs = sum_money_in_outputs(tx);
txd.num_nonrct_inputs = count_nonrct_inputs(tx);
// get mixin number
txd.mixin_no = get_mixin_no(tx);

View file

@ -44,7 +44,7 @@
<td>tx hash</td>
<td>fees</td>
<td>outputs</td>
<td>in/out</td>
<td>in(nonrct)/out</td>
<td>rct/type</td>
<td>mixin</td>
<td>tx size [kB]</td>
@ -57,7 +57,7 @@
<td><a href="/tx/{{hash}}">{{hash}}</a></td>
<td>{{tx_fee_short}}</td>
<td>{{sum_outputs_short}}</td>
<td>{{no_inputs}}/{{no_outputs}}</td>
<td>{{no_inputs}}({{no_nonrct_inputs}})/{{no_outputs}}</td>
<td>
{{#is_ringct}}yes/{{rct_type}}{{/is_ringct}}
{{^is_ringct}}no{{/is_ringct}}

View file

@ -10,7 +10,7 @@
<td>transaction hash</td>
<td>fee</td>
<td>outputs</td>
<td>in/out</td>
<td>in(nonrct)/out</td>
<td>rct/type</td>
<td>mixin</td>
<td>tx size [kB]</td>
@ -21,7 +21,7 @@
<td><a href="/tx/{{hash}}">{{hash}}</a></td>
<td>{{fee}}</td>
<td>{{xmr_outputs}}</td>
<td>{{no_inputs}}/{{no_outputs}}</td>
<td>{{no_inputs}}({{no_nonrct_inputs}})/{{no_outputs}}</td>
<td>{{is_ringct}}{{rct_type}}</td>
<td>{{mixin}}</td>
<td>{{txsize}}</td>

View file

@ -395,6 +395,58 @@ sum_money_in_inputs(const string& json_str)
return sum_xmr;
};
uint64_t
count_nonrct_inputs(const transaction& tx)
{
uint64_t num {0};
size_t input_no = tx.vin.size();
for (size_t i = 0; i < input_no; ++i)
{
if(tx.vin[i].type() != typeid(cryptonote::txin_to_key))
{
continue;
}
// get tx input key
const cryptonote::txin_to_key& tx_in_to_key
= boost::get<cryptonote::txin_to_key>(tx.vin[i]);
if (tx_in_to_key.amount != 0)
++num;
}
return num;
}
uint64_t
count_nonrct_inputs(const string& json_str)
{
uint64_t num {0};
json j;
try
{
j = json::parse( json_str);
}
catch (std::invalid_argument& e)
{
cerr << "count_nonrct_inputs: " << e.what() << endl;
return num;
}
for (json& vin: j["vin"])
{
uint64_t amount = vin["key"]["amount"].get<uint64_t>();
if (amount != 0)
++num;
}
return num;
};
array<uint64_t, 2>
sum_money_in_tx(const transaction& tx)
{

View file

@ -139,6 +139,12 @@ sum_money_in_inputs(const transaction& tx);
pair<uint64_t, uint64_t>
sum_money_in_inputs(const string& json_str);
uint64_t
count_nonrct_inputs(const transaction& tx);
uint64_t
count_nonrct_inputs(const string& json_str);
array<uint64_t, 2>
sum_money_in_tx(const transaction& tx);