projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #2957 from G8XSU/pause-events
[rust-lightning]
/
lightning-invoice
/
src
/
lib.rs
diff --git
a/lightning-invoice/src/lib.rs
b/lightning-invoice/src/lib.rs
index 457896633f63bf18af3f6345dfd9c66666e4d256..920d44b1561dbf12f8afdc1e3e5105eb8a5aefef 100644
(file)
--- a/
lightning-invoice/src/lib.rs
+++ b/
lightning-invoice/src/lib.rs
@@
-31,7
+31,6
@@
pub mod utils;
extern crate bech32;
#[macro_use] extern crate lightning;
extern crate bech32;
#[macro_use] extern crate lightning;
-extern crate num_traits;
extern crate secp256k1;
extern crate alloc;
#[cfg(any(test, feature = "std"))]
extern crate secp256k1;
extern crate alloc;
#[cfg(any(test, feature = "std"))]
@@
-66,7
+65,7
@@
use core::str;
use serde::{Deserialize, Deserializer,Serialize, Serializer, de::Error};
#[doc(no_inline)]
use serde::{Deserialize, Deserializer,Serialize, Serializer, de::Error};
#[doc(no_inline)]
-pub use lightning::ln::PaymentSecret;
+pub use lightning::ln::
types::
PaymentSecret;
#[doc(no_inline)]
pub use lightning::routing::router::{RouteHint, RouteHintHop};
#[doc(no_inline)]
#[doc(no_inline)]
pub use lightning::routing::router::{RouteHint, RouteHintHop};
#[doc(no_inline)]
@@
-79,14
+78,7
@@
mod tb;
#[allow(unused_imports)]
mod prelude {
#[allow(unused_imports)]
mod prelude {
- #[cfg(feature = "hashbrown")]
- extern crate hashbrown;
-
pub use alloc::{vec, vec::Vec, string::String};
pub use alloc::{vec, vec::Vec, string::String};
- #[cfg(not(feature = "hashbrown"))]
- pub use std::collections::{HashMap, hash_map};
- #[cfg(feature = "hashbrown")]
- pub use self::hashbrown::{HashMap, HashSet, hash_map};
pub use alloc::string::ToString;
}
pub use alloc::string::ToString;
}
@@
-170,7
+162,7
@@
pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = 18;
/// use secp256k1::Secp256k1;
/// use secp256k1::SecretKey;
///
/// use secp256k1::Secp256k1;
/// use secp256k1::SecretKey;
///
-/// use lightning::ln::PaymentSecret;
+/// use lightning::ln::
types::
PaymentSecret;
///
/// use lightning_invoice::{Currency, InvoiceBuilder};
///
///
/// use lightning_invoice::{Currency, InvoiceBuilder};
///
@@
-1076,9
+1068,10
@@
impl RawBolt11Invoice {
find_all_extract!(self.known_tagged_fields(), TaggedField::PrivateRoute(ref x), x).collect()
}
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> {
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() })
)
})
}
})
}
@@
-1884,7
+1877,7
@@
mod test {
Bolt11SemanticError};
let private_key = SecretKey::from_slice(&[42; 32]).unwrap();
Bolt11SemanticError};
let private_key = SecretKey::from_slice(&[42; 32]).unwrap();
- let payment_secret = lightning::ln::PaymentSecret([21; 32]);
+ let payment_secret = lightning::ln::
types::
PaymentSecret([21; 32]);
let invoice_template = RawBolt11Invoice {
hrp: RawHrp {
currency: Currency::Bitcoin,
let invoice_template = RawBolt11Invoice {
hrp: RawHrp {
currency: Currency::Bitcoin,
@@
-2071,7
+2064,7
@@
mod test {
let route_1 = RouteHint(vec![
RouteHintHop {
src_node_id: public_key,
let route_1 = RouteHint(vec![
RouteHintHop {
src_node_id: public_key,
- short_channel_id:
de::parse_int_be(&[123; 8], 256).expect("short chan ID slice too big?"
),
+ short_channel_id:
u64::from_be_bytes([123; 8]
),
fees: RoutingFees {
base_msat: 2,
proportional_millionths: 1,
fees: RoutingFees {
base_msat: 2,
proportional_millionths: 1,
@@
-2082,7
+2075,7
@@
mod test {
},
RouteHintHop {
src_node_id: public_key,
},
RouteHintHop {
src_node_id: public_key,
- short_channel_id:
de::parse_int_be(&[42; 8], 256).expect("short chan ID slice too big?"
),
+ short_channel_id:
u64::from_be_bytes([42; 8]
),
fees: RoutingFees {
base_msat: 3,
proportional_millionths: 2,
fees: RoutingFees {
base_msat: 3,
proportional_millionths: 2,
@@
-2107,7
+2100,7
@@
mod test {
},
RouteHintHop {
src_node_id: public_key,
},
RouteHintHop {
src_node_id: public_key,
- short_channel_id:
de::parse_int_be(&[1; 8], 256).expect("short chan ID slice too big?"
),
+ short_channel_id:
u64::from_be_bytes([1; 8]
),
fees: RoutingFees {
base_msat: 5,
proportional_millionths: 4,
fees: RoutingFees {
base_msat: 5,
proportional_millionths: 4,