Class ExchangeRate

java.lang.Object
org.bitcoinj.utils.ExchangeRate
All Implemented Interfaces:
Serializable

public class ExchangeRate extends Object implements Serializable
An exchange rate is expressed as a ratio of a Coin and a Fiat amount.
See Also:
  • Field Details

    • coin

      public final Coin coin
    • fiat

      public final Fiat fiat
  • Constructor Details

    • ExchangeRate

      public ExchangeRate(Coin coin, Fiat fiat)
      Construct exchange rate. This amount of coin is worth that amount of fiat.
    • ExchangeRate

      public ExchangeRate(Fiat fiat)
      Construct exchange rate. One coin is worth this amount of fiat.
  • Method Details

    • coinToFiat

      public Fiat coinToFiat(Coin convertCoin)
      Convert a coin amount to a fiat amount using this exchange rate.
      Throws:
      ArithmeticException - if the converted fiat amount is too high or too low.
    • fiatToCoin

      public Coin fiatToCoin(Fiat convertFiat)
      Convert a fiat amount to a coin amount using this exchange rate.
      Throws:
      ArithmeticException - if the converted coin amount is too high or too low.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object