Skip to content

Commit 67f3d49

Browse files
committed
Merge rust-bitcoin#3943: Add µBTC as a recognized str form of a MicroBitcoin Denomination
4dcdf73 Add `µBTC` and `µbtc` to tests (Jamil Lambert, PhD) afba28e Change `uBTC` to `µBTC` in rustdocs (Jamil Lambert, PhD) 2ca24f0 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 rust-bitcoin#3941 ACKs for top commit: apoelstra: ACK 4dcdf73; successfully ran local tests storopoli: ACK 4dcdf73 tcharding: ACK 4dcdf73 Tree-SHA512: 0f6e8b8b9c04f1a4dc6536c0420b2ded568ab96d2301b7d488807cb26003b91a787a6cf9023705c731682580f73ae5247f3f3b1e8646e4eb720c5a65da582933
2 parents 97f8610 + 4dcdf73 commit 67f3d49

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

units/src/amount/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub use self::{
4242
///
4343
/// # Accepted Denominations
4444
///
45-
/// All upper or lower case, excluding SI prefix (c, m, u) which must be lower case.
45+
/// All upper or lower case, excluding SI prefixes c, m and u (or µ) which must be lower case.
4646
/// - Singular: BTC, cBTC, mBTC, uBTC
4747
/// - Plural or singular: sat, satoshi, bit
4848
///
@@ -67,16 +67,17 @@ pub use self::{
6767
/// ```
6868
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
6969
#[non_exhaustive]
70+
#[allow(clippy::doc_markdown)]
7071
pub enum Denomination {
7172
/// BTC (1 BTC = 100,000,000 satoshi).
7273
Bitcoin,
7374
/// cBTC (1 cBTC = 1,000,000 satoshi).
7475
CentiBitcoin,
7576
/// mBTC (1 mBTC = 100,000 satoshi).
7677
MilliBitcoin,
77-
/// uBTC (1 uBTC = 100 satoshi).
78+
/// µBTC (1 µBTC = 100 satoshi).
7879
MicroBitcoin,
79-
/// bits (bits = uBTC).
80+
/// bits (bits = µBTC).
8081
Bit,
8182
/// satoshi (1 BTC = 100,000,000 satoshi).
8283
Satoshi,
@@ -119,7 +120,7 @@ impl Denomination {
119120
"BTC" | "btc" => Some(Denomination::Bitcoin),
120121
"cBTC" | "cbtc" => Some(Denomination::CentiBitcoin),
121122
"mBTC" | "mbtc" => Some(Denomination::MilliBitcoin),
122-
"uBTC" | "ubtc" => Some(Denomination::MicroBitcoin),
123+
"uBTC" | "ubtc" | "µBTC" | "µbtc" => Some(Denomination::MicroBitcoin),
123124
"bit" | "bits" | "BIT" | "BITS" => Some(Denomination::Bit),
124125
"SATOSHI" | "satoshi" | "SATOSHIS" | "satoshis" | "SAT" | "sat" | "SATS" | "sats" =>
125126
Some(Denomination::Satoshi),

units/src/amount/tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,9 @@ fn checked_sum_amounts() {
10571057
fn denomination_string_acceptable_forms() {
10581058
// Exhaustive list of valid forms.
10591059
let valid = [
1060-
"BTC", "btc", "cBTC", "cbtc", "mBTC", "mbtc", "uBTC", "ubtc", "bit", "bits", "BIT", "BITS",
1061-
"SATOSHI", "satoshi", "SATOSHIS", "satoshis", "SAT", "sat", "SATS", "sats",
1060+
"BTC", "btc", "cBTC", "cbtc", "mBTC", "mbtc", "uBTC", "ubtc", "µBTC", "µbtc", "bit",
1061+
"bits", "BIT", "BITS", "SATOSHI", "satoshi", "SATOSHIS", "satoshis", "SAT", "sat", "SATS",
1062+
"sats",
10621063
];
10631064
for denom in valid {
10641065
assert!(denom.parse::<Denomination>().is_ok());

0 commit comments

Comments
 (0)