show "?" instead of 0.000 amounts.

This commit is contained in:
moneroexamples 2017-01-15 10:18:03 +08:00
parent 5ee3ce6735
commit f17ec69d2b
2 changed files with 12 additions and 5 deletions

View file

@ -165,10 +165,10 @@ struct tx_details
{"pub_key" , tx_pk_str}, {"pub_key" , tx_pk_str},
{"tx_fee" , fee_str}, {"tx_fee" , fee_str},
{"tx_fee_short" , fee_short_str}, {"tx_fee_short" , fee_short_str},
{"sum_inputs" , fmt::format("{:0.6f}", XMR_AMOUNT(xmr_inputs))}, {"sum_inputs" , xmr_amount_to_str(xmr_inputs , "{:0.6f}")},
{"sum_outputs" , fmt::format("{:0.6f}", XMR_AMOUNT(xmr_outputs))}, {"sum_outputs" , xmr_amount_to_str(xmr_outputs, "{:0.6f}")},
{"sum_inputs_short" , fmt::format("{:0.3f}", XMR_AMOUNT(xmr_inputs))}, {"sum_inputs_short" , xmr_amount_to_str(xmr_inputs , "{:0.3f}")},
{"sum_outputs_short" , fmt::format("{:0.3f}", XMR_AMOUNT(xmr_outputs))}, {"sum_outputs_short" , xmr_amount_to_str(xmr_outputs, "{:0.3f}")},
{"no_inputs" , static_cast<uint64_t>(input_key_imgs.size())}, {"no_inputs" , static_cast<uint64_t>(input_key_imgs.size())},
{"no_outputs" , static_cast<uint64_t>(output_pub_keys.size())}, {"no_outputs" , static_cast<uint64_t>(output_pub_keys.size())},
{"mixin" , mixin_str}, {"mixin" , mixin_str},

View file

@ -253,7 +253,14 @@ static
string string
xmr_amount_to_str(const uint64_t& xmr_amount, string _format="{:0.12f}") xmr_amount_to_str(const uint64_t& xmr_amount, string _format="{:0.12f}")
{ {
return fmt::format(_format, XMR_AMOUNT(xmr_amount)); string amount_str = "?";
if (xmr_amount > 0)
{
amount_str = fmt::format(_format, XMR_AMOUNT(xmr_amount));
}
return amount_str;
} }
bool bool