Skip to content

Commit b9c1e95

Browse files
committed
Minor review comments
1 parent 8833d7c commit b9c1e95

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lightning-invoice/src/de.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<const N: usize> FromBase32 for [u8; N] {
5454
Bolt11ParseError::InvalidSliceLength(
5555
data.len(),
5656
(N * 8 + 4) / 5,
57-
"<[u8; N]>::from_base32()".into(),
57+
"<[u8; N]>",
5858
)
5959
})
6060
}
@@ -68,7 +68,7 @@ impl FromBase32 for PaymentSecret {
6868
return Err(Bolt11ParseError::InvalidSliceLength(
6969
field_data.len(),
7070
52,
71-
"PaymentSecret::from_base32()".into(),
71+
"payment secret",
7272
));
7373
}
7474
let data_bytes = <[u8; 32]>::from_base32(field_data)?;
@@ -456,7 +456,7 @@ impl FromBase32 for PositiveTimestamp {
456456
return Err(Bolt11ParseError::InvalidSliceLength(
457457
b32.len(),
458458
7,
459-
"PositiveTimestamp::from_base32()".into(),
459+
"timestamp",
460460
));
461461
}
462462
let timestamp: u64 = parse_u64_be(b32)
@@ -475,7 +475,7 @@ impl FromBase32 for Bolt11InvoiceSignature {
475475
return Err(Bolt11ParseError::InvalidSliceLength(
476476
signature.len(),
477477
104,
478-
"Bolt11InvoiceSignature::from_base32()".into(),
478+
"signature",
479479
));
480480
}
481481
let recoverable_signature_bytes = <[u8; 65]>::from_base32(signature)?;
@@ -745,11 +745,11 @@ impl Display for Bolt11ParseError {
745745
Bolt11ParseError::DescriptionDecodeError(ref e) => {
746746
write!(f, "Description is not a valid utf-8 string: {}", e)
747747
}
748-
Bolt11ParseError::InvalidSliceLength(ref len, ref expected, ref function) => {
748+
Bolt11ParseError::InvalidSliceLength(ref len, ref expected, ref elemen) => {
749749
write!(
750750
f,
751-
"Slice had length {} instead of {} in function {}",
752-
len, expected, function
751+
"Slice had length {} instead of {} for element {}",
752+
len, expected, elemen
753753
)
754754
},
755755
Bolt11ParseError::BadPrefix => f.write_str("did not begin with 'ln'"),

lightning-invoice/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ pub enum Bolt11ParseError {
105105
InvalidPubKeyHashLength,
106106
InvalidScriptHashLength,
107107
InvalidRecoveryId,
108-
// Invalid length, with actual length, expected length, and function info
109-
InvalidSliceLength(usize, usize, String),
108+
// Invalid length, with actual length, expected length, and name of the element
109+
InvalidSliceLength(usize, usize, &'static str),
110110

111111
/// Not an error, but used internally to signal that a part of the invoice should be ignored
112112
/// according to BOLT11
@@ -312,7 +312,7 @@ impl RawHrp {
312312
/// Convert to bech32::Hrp
313313
pub fn to_hrp(&self) -> bech32::Hrp {
314314
let hrp_str = self.to_string();
315-
let s = core::str::from_utf8(&hrp_str.as_bytes()).expect("asserted to be ASCII");
315+
let s = core::str::from_utf8(&hrp_str.as_bytes()).expect("HRP bytes should be ASCII");
316316
bech32::Hrp::parse_unchecked(s)
317317
}
318318
}

lightning-invoice/src/test_ser_de.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn array_u8_error_invalid_length() {
6666
.err()
6767
.unwrap()
6868
.to_string(),
69-
"Slice had length 4 instead of 5 in function <[u8; N]>::from_base32()"
69+
"Slice had length 4 instead of 5 for element <[u8; N]>"
7070
);
7171
}
7272

0 commit comments

Comments
 (0)