-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow uppercase bech32 HRP #3505
Conversation
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tests would be useful, to make behavior more explicit (lowercase/uppercase/mixedcase).
Note: doesn't help much, but might be related to / caused by #3270 |
Yup, already on it, will push in a sec :) |
Now pushed some test coverage. |
273357b
to
c1c86f3
Compare
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
24b99a2
to
afc9a56
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please squash.
afc9a56
to
b8dabf5
Compare
Squashed and included the following minor changes to align exactly with the BOLT12 test vectors: > git diff-tree -U2 afc9a5674 b8dabf51c
diff --git a/lightning/src/offers/parse.rs b/lightning/src/offers/parse.rs
index afd79b2a8..f3c481a9f 100644
--- a/lightning/src/offers/parse.rs
+++ b/lightning/src/offers/parse.rs
@@ -252,6 +252,6 @@ mod bolt12_tests {
"lno1pqps7sjqpgtyzm3qv4uxzmtsd3jjqer9wd3hy6tsw35k7msjzfpy7nz5yqcnygrfdej82um5wf5k2uckyypwa3eyt44h6txtxquqh7lz5djge4afgfjn7k4rgrkuag0jsd5xvxg",
- // An all-uppercase string is valid
- &"lno1pqps7sjqpgtyzm3qv4uxzmtsd3jjqer9wd3hy6tsw35k7msjzfpy7nz5yqcnygrfdej82um5wf5k2uckyypwa3eyt44h6txtxquqh7lz5djge4afgfjn7k4rgrkuag0jsd5xvxg".to_uppercase(),
+ // Uppercase is valid
+ "LNO1PQPS7SJQPGTYZM3QV4UXZMTSD3JJQER9WD3HY6TSW35K7MSJZFPY7NZ5YQCNYGRFDEJ82UM5WF5K2UCKYYPWA3EYT44H6TXTXQUQH7LZ5DJGE4AFGFJN7K4RGRKUAG0JSD5XVXG",
// + can join anywhere
@@ -292,5 +292,5 @@ mod bolt12_tests {
fn fails_parsing_bech32_encoded_offers_with_mixed_casing() {
// We assert that mixed-case encoding fails to parse.
- let mixed_case_offer = "lno1pqpS7sjqpgtyzm3qv4uxzmtsd3jjqer9wd3hy6tsw35k7msjzfpy7nz5yqcnygrfdej82um5wf5k2uckyypwa3eyt44h6txtxquqh7lz5djge4afgfjn7k4rgrkuag0jsd5xvxg";
+ let mixed_case_offer = "LnO1PqPs7sJqPgTyZm3qV4UxZmTsD3JjQeR9Wd3hY6TsW35k7mSjZfPy7nZ5YqCnYgRfDeJ82uM5Wf5k2uCkYyPwA3EyT44h6tXtXqUqH7Lz5dJgE4AfGfJn7k4rGrKuAg0jSd5xVxG";
match mixed_case_offer.parse::<Offer>() {
Ok(_) => panic!("Valid offer: {}", mixed_case_offer), |
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.
.. to ensure we're able to decode all-uppercase HRPs and reject mixed-case encodings.
b8dabf5
to
7272969
Compare
Rebased on |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 0.1 #3505 +/- ##
==========================================
+ Coverage 88.26% 88.32% +0.05%
==========================================
Files 149 149
Lines 112915 112926 +11
Branches 112915 112926 +11
==========================================
+ Hits 99666 99740 +74
+ Misses 10754 10697 -57
+ Partials 2495 2489 -6 ☔ View full report in Codecov by Sentry. |
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
We should drop this commit once lightningdevkit/rust-lightning#3505 got in.
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.Discovered while upgrading LDK Node to 0.1.0-beta1, as we failed to parse uppercase offers (which used to work).
Related: rust-bitcoin/rust-bech32#208