projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2b14cc4
)
Fix overflow in lightning-invoice amount_pico_btc.
author
Valentine Wallace
<vwallace@protonmail.com>
Tue, 30 Apr 2024 14:05:35 +0000
(10:05 -0400)
committer
Valentine Wallace
<vwallace@protonmail.com>
Tue, 30 Apr 2024 14:05:35 +0000
(10:05 -0400)
lightning-invoice/src/lib.rs
patch
|
blob
|
history
diff --git
a/lightning-invoice/src/lib.rs
b/lightning-invoice/src/lib.rs
index 20eaf7a82d27a7970872883536f7edce1da55c69..f06eeaa1744bfcf16e5c74d6e61423d8fc44d082 100644
(file)
--- a/
lightning-invoice/src/lib.rs
+++ b/
lightning-invoice/src/lib.rs
@@
-1068,9
+1068,10
@@
impl RawBolt11Invoice {
find_all_extract!(self.known_tagged_fields(), TaggedField::PrivateRoute(ref x), x).collect()
}
+ /// Returns `None` if no amount is set or on overflow.
pub fn amount_pico_btc(&self) -> Option<u64> {
- self.hrp.raw_amount.
map
(|v| {
- v
* self.hrp.si_prefix.as_ref().map_or(1_000_000_000_000, |si| { si.multiplier() }
)
+ self.hrp.raw_amount.
and_then
(|v| {
+ v
.checked_mul(self.hrp.si_prefix.as_ref().map_or(1_000_000_000_000, |si| { si.multiplier() })
)
})
}