Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Sep 12, 2024
1 parent 1a69ccc commit ad6f5f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lightning-invoice/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl FromBase32 for PaymentSecret {
return Err(Bolt11ParseError::InvalidSliceLength(
field_data.len(),
52,
"payment secret",
"PaymentSecret",
));
}
let data_bytes = <[u8; 32]>::from_base32(field_data)?;
Expand Down Expand Up @@ -383,10 +383,11 @@ impl FromStr for SignedRawBolt11Invoice {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let parsed = CheckedHrpstring::new::<Bech32>(s)?;
let hrp = parsed.hrp();
// Access original non-packed 32 byte values (as Fe32s) (iterator type is needed for API hack)
let data: Vec<_> = parsed.fe32_iter::<alloc::boxed::Box<dyn Iterator<Item = u8>>>().collect();
// Access original non-packed 32 byte values (as Fe32s)
// Note: the type argument is needed due to the API peculiarities, but it's not used
let data: Vec<_> = parsed.fe32_iter::<&mut dyn Iterator<Item = u8>>().collect();

const SIGNATURE_LEN5: usize = 104; // 32-bit values, 65 bytes
const SIGNATURE_LEN5: usize = 104; // number of the 5-bit values (equals to 65 bytes)
if data.len() < SIGNATURE_LEN5 {
return Err(Bolt11ParseError::TooShortDataPart);
}
Expand Down Expand Up @@ -467,7 +468,7 @@ impl FromBase32 for PositiveTimestamp {
return Err(Bolt11ParseError::InvalidSliceLength(
b32.len(),
7,
"timestamp",
"PositiveTimestamp",
));
}
let timestamp: u64 = parse_u64_be(b32)
Expand All @@ -486,7 +487,7 @@ impl FromBase32 for Bolt11InvoiceSignature {
return Err(Bolt11ParseError::InvalidSliceLength(
signature.len(),
104,
"signature",
"Bolt11InvoiceSignature",
));
}
let recoverable_signature_bytes = <[u8; 65]>::from_base32(signature)?;
Expand Down
1 change: 0 additions & 1 deletion lightning-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ _test_utils = []

[dependencies]
bitcoin = { version = "0.32.2", default-features = false }
bech32 = { version = "0.11.0", default-features = false }

[lints]
workspace = true

0 comments on commit ad6f5f1

Please sign in to comment.