Skip to content

Commit c5658f6

Browse files
committed
Check that the HRPs generated in BOLT 11 RawHrp are always valid
...in `debug_assertions`.
1 parent 0abf068 commit c5658f6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lightning-invoice/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ impl RawHrp {
313313
pub fn to_hrp(&self) -> bech32::Hrp {
314314
let hrp_str = self.to_string();
315315
let s = core::str::from_utf8(&hrp_str.as_bytes()).expect("HRP bytes should be ASCII");
316+
debug_assert!(bech32::Hrp::parse(s).is_ok(), "We should always build BIP 173-valid HRPs");
316317
bech32::Hrp::parse_unchecked(s)
317318
}
318319
}

0 commit comments

Comments
 (0)