Merge pull request #26 from moneroexamples/change_zero_amount_str

show "?" instead of 0.000 amounts.
master
moneroexamples 8 years ago committed by GitHub
commit 91698a02ee

@ -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},

@ -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

Loading…
Cancel
Save