Skip to content

Commit 60333c8

Browse files
committed
fixup! Add new payment type and metadata bytes
move msat value check
1 parent 4211577 commit 60333c8

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

lightning/src/ln/inbound_payment.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,15 @@ fn construct_metadata_bytes(min_value_msat: Option<u64>, payment_type: Method,
179179
let expiry_timestamp = highest_seen_timestamp + invoice_expiry_delta_secs as u64 + 7200;
180180
let mut expiry_bytes = expiry_timestamp.to_be_bytes();
181181

182-
if min_final_cltv_expiry_delta.is_some() {
183-
if {
184-
// `min_value_msat` should fit in (64 bits - 3 payment type bits =) 61 bits as an unsigned integer.
185-
// This should leave us with a maximum value greater than the 21M BTC supply cap anyway.
186-
min_value_msat.is_some() && min_value_msat.unwrap() > ((1u64 << 61) - 1) ||
187-
// `expiry_timestamp` should fit in (64 bits - 2 delta bytes =) 48 bits as an unsigned integer.
188-
// Bitcoin's block header timestamps are actually `u32`s, so we're technically already limited to
189-
// the much smaller maximum timestamp of `u32::MAX` for now, but we check the u64 `expiry_timestamp`
190-
// for future-proofing.
191-
expiry_timestamp > ((1u64 << 48) - 1)
192-
} { return Err(()); }
193-
}
182+
// `min_value_msat` should fit in (64 bits - 3 payment type bits =) 61 bits as an unsigned integer.
183+
// This should leave us with a maximum value greater than the 21M BTC supply cap anyway.
184+
if min_value_msat.is_some() && min_value_msat.unwrap() > ((1u64 << 61) - 1) { return Err(()); }
185+
186+
// `expiry_timestamp` should fit in (64 bits - 2 delta bytes =) 48 bits as an unsigned integer.
187+
// Bitcoin's block header timestamps are actually `u32`s, so we're technically already limited to
188+
// the much smaller maximum timestamp of `u32::MAX` for now, but we check the u64 `expiry_timestamp`
189+
// for future-proofing.
190+
if min_final_cltv_expiry_delta.is_some() && expiry_timestamp > ((1u64 << 48) - 1) { return Err(()); }
194191

195192
if let Some(min_final_cltv_expiry_delta) = min_final_cltv_expiry_delta {
196193
let bytes = min_final_cltv_expiry_delta.to_be_bytes();

0 commit comments

Comments
 (0)