Merge rust-bitcoin/rust-bitcoin#3943: Add `µBTC` as a recognized `str` form of a MicroBitcoin Denomination
4dcdf73cfa
Add `µBTC` and `µbtc` to tests (Jamil Lambert, PhD)afba28e188
Change `uBTC` to `µBTC` in rustdocs (Jamil Lambert, PhD)2ca24f00f2
Add `µBTC` as a recognized `str` form of `uBTC` (Jamil Lambert, PhD) Pull request description: `µ` is the correct letter for the SI unit micro but is not on most standard keyboards. `u` was used instead because it looks similar. Add `µBTC` to the list of recognized strings for MicroBitcoin. This is an addition only, `uBTC` still works as normal. Change `uBTC` to `µBTC` in the rustdocs. The examples have been left as `uBTC` since this is easier for most people to use. Add `µBTC` and `µbtc` to the tests. Close #3941 ACKs for top commit: apoelstra: ACK 4dcdf73cfa896b2c095cda9064c6e0a0e9aeec2b; successfully ran local tests storopoli: ACK4dcdf73cfa
tcharding: ACK4dcdf73cfa
Tree-SHA512: 0f6e8b8b9c04f1a4dc6536c0420b2ded568ab96d2301b7d488807cb26003b91a787a6cf9023705c731682580f73ae5247f3f3b1e8646e4eb720c5a65da582933
This commit is contained in:
commit
67f3d498af
|
@ -42,7 +42,7 @@ pub use self::{
|
|||
///
|
||||
/// # Accepted Denominations
|
||||
///
|
||||
/// All upper or lower case, excluding SI prefix (c, m, u) which must be lower case.
|
||||
/// All upper or lower case, excluding SI prefixes c, m and u (or µ) which must be lower case.
|
||||
/// - Singular: BTC, cBTC, mBTC, uBTC
|
||||
/// - Plural or singular: sat, satoshi, bit
|
||||
///
|
||||
|
@ -67,6 +67,7 @@ pub use self::{
|
|||
/// ```
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
||||
#[non_exhaustive]
|
||||
#[allow(clippy::doc_markdown)]
|
||||
pub enum Denomination {
|
||||
/// BTC (1 BTC = 100,000,000 satoshi).
|
||||
Bitcoin,
|
||||
|
@ -74,9 +75,9 @@ pub enum Denomination {
|
|||
CentiBitcoin,
|
||||
/// mBTC (1 mBTC = 100,000 satoshi).
|
||||
MilliBitcoin,
|
||||
/// uBTC (1 uBTC = 100 satoshi).
|
||||
/// µBTC (1 µBTC = 100 satoshi).
|
||||
MicroBitcoin,
|
||||
/// bits (bits = uBTC).
|
||||
/// bits (bits = µBTC).
|
||||
Bit,
|
||||
/// satoshi (1 BTC = 100,000,000 satoshi).
|
||||
Satoshi,
|
||||
|
@ -119,7 +120,7 @@ impl Denomination {
|
|||
"BTC" | "btc" => Some(Denomination::Bitcoin),
|
||||
"cBTC" | "cbtc" => Some(Denomination::CentiBitcoin),
|
||||
"mBTC" | "mbtc" => Some(Denomination::MilliBitcoin),
|
||||
"uBTC" | "ubtc" => Some(Denomination::MicroBitcoin),
|
||||
"uBTC" | "ubtc" | "µBTC" | "µbtc" => Some(Denomination::MicroBitcoin),
|
||||
"bit" | "bits" | "BIT" | "BITS" => Some(Denomination::Bit),
|
||||
"SATOSHI" | "satoshi" | "SATOSHIS" | "satoshis" | "SAT" | "sat" | "SATS" | "sats" =>
|
||||
Some(Denomination::Satoshi),
|
||||
|
|
|
@ -1057,8 +1057,9 @@ fn checked_sum_amounts() {
|
|||
fn denomination_string_acceptable_forms() {
|
||||
// Exhaustive list of valid forms.
|
||||
let valid = [
|
||||
"BTC", "btc", "cBTC", "cbtc", "mBTC", "mbtc", "uBTC", "ubtc", "bit", "bits", "BIT", "BITS",
|
||||
"SATOSHI", "satoshi", "SATOSHIS", "satoshis", "SAT", "sat", "SATS", "sats",
|
||||
"BTC", "btc", "cBTC", "cbtc", "mBTC", "mbtc", "uBTC", "ubtc", "µBTC", "µbtc", "bit",
|
||||
"bits", "BIT", "BITS", "SATOSHI", "satoshi", "SATOSHIS", "satoshis", "SAT", "sat", "SATS",
|
||||
"sats",
|
||||
];
|
||||
for denom in valid {
|
||||
assert!(denom.parse::<Denomination>().is_ok());
|
||||
|
|
Loading…
Reference in New Issue