Merge rust-bitcoin/rust-bitcoin#2268: Add convenience constants to `Denomination`
22747149a9
Add convenience constants to `Denomination` (Martin Habovstiak) Pull request description: `Denomination::Bitcoin` and `Denomination::Satoshi` are often used, especially in test code so this change adds `BTC` and `SAT` - short, readable constants. Notably this doesn't add the other constants as that would lead to either unidiomatic names or confusing casing (MSAT meaning millisat not megasat) and they are not used that much anyway. ACKs for top commit: apoelstra: ACK22747149a9
tcharding: ACK22747149a9
Tree-SHA512: fb49e61c28f5df14d5432a81ec946a367696fe36e96798d35831cd5cb88b813fe3aa1e7be201997956b4d4f6e5431e4da20d0d24e4d6c036aa199fc9b9c87da1
This commit is contained in:
commit
ce1704a6e7
|
@ -59,6 +59,12 @@ pub enum Denomination {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Denomination {
|
impl Denomination {
|
||||||
|
/// Convenience alias for `Denomination::Bitcoin`.
|
||||||
|
pub const BTC: Self = Denomination::Bitcoin;
|
||||||
|
|
||||||
|
/// Convenience alias for `Denomination::Satoshi`.
|
||||||
|
pub const SAT: Self = Denomination::Satoshi;
|
||||||
|
|
||||||
/// The number of decimal places more than a satoshi.
|
/// The number of decimal places more than a satoshi.
|
||||||
fn precision(self) -> i8 {
|
fn precision(self) -> i8 {
|
||||||
match self {
|
match self {
|
||||||
|
|
Loading…
Reference in New Issue