Function format_signed_zats_as_zec

Source
pub fn format_signed_zats_as_zec(amount: impl Into<i64>) -> String
Expand description

Formats a signed zatoshi amount as a human-readable ZEC value with appropriate sign.

This function extends format_zats_as_zec to handle negative values, which can occur in certain contexts like transaction fee calculations or balance changes.

§Arguments

  • amount - A signed zatoshi amount that can be converted to i64

§Returns

A string with the formatted ZEC amount, including sign if negative

§Examples

// Positive values work the same as format_zats_as_zec
assert_eq!(format_signed_zats_as_zec(100_000_000), "ZEC 1.0");
 
// Negative values include a minus sign
assert_eq!(format_signed_zats_as_zec(-50_000_000), "-ZEC 0.5");
assert_eq!(format_signed_zats_as_zec(-1), "-ZEC 0.00000001");