Skip to content

non-uniform usage of plural in Denomination #729

@tcharding

Description

@tcharding

The Amount related Denomination struct parses to and from strings. Currently it uses the plural for Denomination::Bit and the singular for Denomination::Satoshi.

We should be uniform, either we support singular, plural, or both for all the abbreviation denominations (bits and sats).

  1. let a = Amount::from_str("100 bits") and let a = Amount::from_str("100 sats")
  2. let a = Amount::from_str("100 bit") and let a = Amount::from_str("100 sat")
  3. Both 1 and 2

For reference, here is the from_str implementation.

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "BTC" => Ok(Denomination::Bitcoin),
            "mBTC" => Ok(Denomination::MilliBitcoin),
            "uBTC" => Ok(Denomination::MicroBitcoin),
            "bits" => Ok(Denomination::Bit),
            "satoshi" => Ok(Denomination::Satoshi),
            "sat" => Ok(Denomination::Satoshi),
            "msat" => Ok(Denomination::MilliSatoshi),
            d => Err(ParseAmountError::UnknownDenomination(d.to_owned())),
        }
    }

Found while testing #509

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions