Repository: rust-bitcoin/rust-bitcoin (language: rust)

Issue:
Consider using µBTC in rustdocs
We parse micro-bitcoin as `uBTC` but perhaps we should use the more fancy µ in docs?

Originally suggested here: https://github.com/rust-bitcoin/rust-bitcoin/pull/3933#issuecomment-2605443499


Discussion / hints:
We already accept multiple versions of denominations, e.g. `"sat" | "SATS" | "sats"`. We could add `µBTC` as an accepted str form and explain that it is parsed and displayed as `uBTC`.
Yeah, maybe also add more knobs to `DisplayAmount` to allow people to change these things.

Fix patch:
diff --git a/units/src/amount/mod.rs b/units/src/amount/mod.rs
index 8e3a92515..1980a8c54 100644
--- a/units/src/amount/mod.rs
+++ b/units/src/amount/mod.rs
@@ -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),


Test patch:
diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs
index 42a9e3d3c..192b1552b 100644
--- a/units/src/amount/tests.rs
+++ b/units/src/amount/tests.rs
@@ -1013,8 +1013,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());