Add CentiBitcoin to denominations
This commit is contained in:
parent
2f404f9b5c
commit
39e528fdfc
|
@ -21,6 +21,7 @@ use crate::prelude::*;
|
||||||
/// # use bitcoin::Amount;
|
/// # use bitcoin::Amount;
|
||||||
///
|
///
|
||||||
/// assert_eq!(Amount::from_str("1 BTC").unwrap(), Amount::from_sat(100_000_000));
|
/// assert_eq!(Amount::from_str("1 BTC").unwrap(), Amount::from_sat(100_000_000));
|
||||||
|
/// assert_eq!(Amount::from_str("1 cBTC").unwrap(), Amount::from_sat(1_000_000));
|
||||||
/// assert_eq!(Amount::from_str("1 mBTC").unwrap(), Amount::from_sat(100_000));
|
/// assert_eq!(Amount::from_str("1 mBTC").unwrap(), Amount::from_sat(100_000));
|
||||||
/// assert_eq!(Amount::from_str("1 uBTC").unwrap(), Amount::from_sat(100));
|
/// assert_eq!(Amount::from_str("1 uBTC").unwrap(), Amount::from_sat(100));
|
||||||
/// assert_eq!(Amount::from_str("10 nBTC").unwrap(), Amount::from_sat(1));
|
/// assert_eq!(Amount::from_str("10 nBTC").unwrap(), Amount::from_sat(1));
|
||||||
|
@ -33,6 +34,8 @@ use crate::prelude::*;
|
||||||
pub enum Denomination {
|
pub enum Denomination {
|
||||||
/// BTC
|
/// BTC
|
||||||
Bitcoin,
|
Bitcoin,
|
||||||
|
/// cBTC
|
||||||
|
CentiBitcoin,
|
||||||
/// mBTC
|
/// mBTC
|
||||||
MilliBitcoin,
|
MilliBitcoin,
|
||||||
/// uBTC
|
/// uBTC
|
||||||
|
@ -54,6 +57,7 @@ impl Denomination {
|
||||||
fn precision(self) -> i8 {
|
fn precision(self) -> i8 {
|
||||||
match self {
|
match self {
|
||||||
Denomination::Bitcoin => -8,
|
Denomination::Bitcoin => -8,
|
||||||
|
Denomination::CentiBitcoin => -6,
|
||||||
Denomination::MilliBitcoin => -5,
|
Denomination::MilliBitcoin => -5,
|
||||||
Denomination::MicroBitcoin => -2,
|
Denomination::MicroBitcoin => -2,
|
||||||
Denomination::NanoBitcoin => 1,
|
Denomination::NanoBitcoin => 1,
|
||||||
|
@ -68,6 +72,7 @@ impl Denomination {
|
||||||
fn as_str(self) -> &'static str {
|
fn as_str(self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
Denomination::Bitcoin => "BTC",
|
Denomination::Bitcoin => "BTC",
|
||||||
|
Denomination::CentiBitcoin => "cBTC",
|
||||||
Denomination::MilliBitcoin => "mBTC",
|
Denomination::MilliBitcoin => "mBTC",
|
||||||
Denomination::MicroBitcoin => "uBTC",
|
Denomination::MicroBitcoin => "uBTC",
|
||||||
Denomination::NanoBitcoin => "nBTC",
|
Denomination::NanoBitcoin => "nBTC",
|
||||||
|
@ -115,6 +120,10 @@ fn denomination_from_str(mut s: &str) -> Option<Denomination> {
|
||||||
return Some(Denomination::Bitcoin);
|
return Some(Denomination::Bitcoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.eq_ignore_ascii_case("cBTC") {
|
||||||
|
return Some(Denomination::CentiBitcoin);
|
||||||
|
}
|
||||||
|
|
||||||
if s.eq_ignore_ascii_case("mBTC") {
|
if s.eq_ignore_ascii_case("mBTC") {
|
||||||
return Some(Denomination::MilliBitcoin);
|
return Some(Denomination::MilliBitcoin);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue