Skip to content

Commit 540bcf7

Browse files
committed
Allow uppercase bech32 HRP
Previously, we would fail parsing `Offer`s if the HRP didn't match our expected (lowercase) HRP. Here, we relax this check in accordance with the spec to also allow all-uppercase HRPs.
1 parent 85d1e5f commit 540bcf7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lightning/src/offers/parse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ mod sealed {
5858

5959
let parsed = CheckedHrpstring::new::<NoChecksum>(encoded.as_ref())?;
6060
let hrp = parsed.hrp();
61-
if hrp.as_str() != Self::BECH32_HRP {
61+
// Compare the lowercase'd iter to allow for all-uppercase HRPs
62+
if hrp.lowercase_char_iter().ne(Self::BECH32_HRP.chars()) {
6263
return Err(Bolt12ParseError::InvalidBech32Hrp);
6364
}
6465

0 commit comments

Comments
 (0)