-
Notifications
You must be signed in to change notification settings - Fork 411
Invoice features #876
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
Invoice features #876
Conversation
bb13620
to
a4a44fd
Compare
Codecov Report
@@ Coverage Diff @@
## main #876 +/- ##
==========================================
+ Coverage 90.26% 90.77% +0.51%
==========================================
Files 57 57
Lines 29226 30371 +1145
==========================================
+ Hits 26380 27570 +1190
+ Misses 2846 2801 -45
Continue to review full report at Codecov.
|
a4a44fd
to
8333b33
Compare
lightning/src/ln/features.rs
Outdated
@@ -387,6 +391,17 @@ impl InitFeatures { | |||
} | |||
} | |||
|
|||
/// Calculates the base32 encoded size of a byte slice | |||
fn bytes_size_to_base32_size(byte_size: usize) -> usize { |
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.
Can we use the provided implementation for [u8]
instead of copying this function https://docs.rs/bech32/0.8.0/bech32/trait.Base32Len.html#impl-Base32Len
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.
That didn't work sadly... Neither did the original copied&pasted function. I did something super inefficient 😬 still need to think through a better way
923fce5
to
001c996
Compare
001c996
to
a9a1442
Compare
@@ -395,6 +399,68 @@ impl InvoiceFeatures { | |||
} | |||
} | |||
|
|||
impl ToBase32 for InvoiceFeatures { | |||
fn write_base32<W: WriteBase32>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err> { |
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.
Could you add some tests for these conversions?
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.
There is test_payment_secret_and_features_de_and_ser
which uses those methods, and invoice fuzzing. Added more unit tests though.
1fb1cd6
to
e1e5918
Compare
e1e5918
to
0eeaedf
Compare
Useful for constructing features objects from raw feature bytes.
0eeaedf
to
f281ddd
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.
Looks good, trivial comments and one doc comment.
lightning/src/ln/features.rs
Outdated
@@ -427,8 +493,8 @@ impl<T: sealed::Context> Features<T> { | |||
Features::<C> { flags, mark: PhantomData, } | |||
} | |||
|
|||
#[cfg(test)] | |||
/// Create a Features given a set of flags, in LE. | |||
/// Create a Features given a set of flags, in little-endian. This is in reverse bit order from |
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.
byte order, not bit order. We don't reverse the bits :).
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.
Maybe dumb q, but the bits are literally in reverse order from what they were, right? Rephrased tho :)
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.
I don't believe so? The highest bit in the last position is ultimately the highest bit - not the lowest bit in the last position (which would be true if we swapped the bits as well).
f281ddd
to
9e82f39
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.
utACK 9e82f39
9e82f39
to
b24d02c
Compare
Test locally, CI is just hella broken right now. See #895. |
Tested w/ sample