Truncate trailing zeroes in coin amounts (#1366)

* truncate coin amounts
* truncate datetimes
* fixed formatting
This commit is contained in:
Mike Dallas
2018-08-17 18:05:35 +01:00
committed by Ignotus Peverell
parent f7161a9afb
commit adeaea4622
5 changed files with 39 additions and 24 deletions
+13 -13
View File
@@ -54,7 +54,7 @@ pub fn outputs(
let status = format!("{:?}", out.status);
let is_coinbase = format!("{}", out.is_coinbase);
let num_confirmations = format!("{}", out.num_confirmations(cur_height));
let value = format!("{}", core::amount_to_hr_string(out.value));
let value = format!("{}", core::amount_to_hr_string(out.value, false));
let tx = match out.tx_log_entry {
None => "".to_owned(),
Some(t) => t.to_string(),
@@ -123,26 +123,26 @@ pub fn txs(
None => "None".to_owned(),
};
let entry_type = format!("{}", t.tx_type);
let creation_ts = format!("{}", t.creation_ts);
let creation_ts = format!("{}", t.creation_ts.format("%Y-%m-%d %H:%M:%S"));
let confirmation_ts = match t.confirmation_ts {
Some(m) => format!("{}", m),
Some(m) => format!("{}", m.format("%Y-%m-%d %H:%M:%S")),
None => "None".to_owned(),
};
let confirmed = format!("{}", t.confirmed);
let num_inputs = format!("{}", t.num_inputs);
let num_outputs = format!("{}", t.num_outputs);
let amount_debited_str = core::amount_to_hr_string(t.amount_debited);
let amount_credited_str = core::amount_to_hr_string(t.amount_credited);
let amount_debited_str = core::amount_to_hr_string(t.amount_debited, true);
let amount_credited_str = core::amount_to_hr_string(t.amount_credited, true);
let fee = match t.fee {
Some(f) => format!("{}", core::amount_to_hr_string(f)),
Some(f) => format!("{}", core::amount_to_hr_string(f, true)),
None => "None".to_owned(),
};
let net_diff = if t.amount_credited >= t.amount_debited {
core::amount_to_hr_string(t.amount_credited - t.amount_debited)
core::amount_to_hr_string(t.amount_credited - t.amount_debited, true)
} else {
format!(
"-{}",
core::amount_to_hr_string(t.amount_debited - t.amount_credited)
core::amount_to_hr_string(t.amount_debited - t.amount_credited, true)
)
};
table.add_row(row![
@@ -181,12 +181,12 @@ pub fn info(wallet_info: &WalletInfo, validated: bool) {
wallet_info.last_confirmed_height
);
let mut table = table!(
[bFG->"Total", FG->amount_to_hr_string(wallet_info.total)],
[bFY->"Awaiting Confirmation", FY->amount_to_hr_string(wallet_info.amount_awaiting_confirmation)],
[bFY->"Immature Coinbase", FY->amount_to_hr_string(wallet_info.amount_immature)],
[bFG->"Currently Spendable", FG->amount_to_hr_string(wallet_info.amount_currently_spendable)],
[bFG->"Total", FG->amount_to_hr_string(wallet_info.total, false)],
[bFY->"Awaiting Confirmation", FY->amount_to_hr_string(wallet_info.amount_awaiting_confirmation, false)],
[bFY->"Immature Coinbase", FY->amount_to_hr_string(wallet_info.amount_immature, false)],
[bFG->"Currently Spendable", FG->amount_to_hr_string(wallet_info.amount_currently_spendable, false)],
[Fw->"---------", Fw->"---------"],
[Fr->"(Locked by previous transaction)", Fr->amount_to_hr_string(wallet_info.amount_locked)]
[Fr->"(Locked by previous transaction)", Fr->amount_to_hr_string(wallet_info.amount_locked, false)]
);
table.set_format(*prettytable::format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR);
table.printstd();
+2 -2
View File
@@ -276,8 +276,8 @@ impl Slate {
if fee > self.amount + self.fee {
let reason = format!(
"Rejected the transfer because transaction fee ({}) exceeds received amount ({}).",
amount_to_hr_string(fee),
amount_to_hr_string(self.amount + self.fee)
amount_to_hr_string(fee, false),
amount_to_hr_string(self.amount + self.fee, false)
);
info!(LOGGER, "{}", reason);
return Err(ErrorKind::Fee(reason.to_string()))?;