mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 06:57:53 +01:00
Fix overflow in lightning-invoice amount_pico_btc.
This commit is contained in:
parent
2b14cc40a6
commit
c6ae9288b9
1 changed files with 3 additions and 2 deletions
|
@ -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() }))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue