Merge pull request #2998 from tnull/2024-04-fix-potential-lock-race-in-CM-write
[rust-lightning] / lightning-invoice / src / payment.rs
index 7306d12f5e6c0061825ebf1d2fde3c2decafde79..8196fa9eb89a81d7df74300484ee96cddee5588f 100644 (file)
@@ -10,7 +10,7 @@
 //! Convenient utilities for paying Lightning invoices.
 
 use crate::Bolt11Invoice;
-use crate::bitcoin_hashes::Hash;
+use bitcoin::hashes::Hash;
 
 use lightning::ln::PaymentHash;
 use lightning::ln::channelmanager::RecipientOnionFields;
@@ -84,15 +84,13 @@ fn params_from_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
 mod tests {
        use super::*;
        use crate::{InvoiceBuilder, Currency};
-       use bitcoin_hashes::sha256::Hash as Sha256;
-       use lightning::events::Event;
-       use lightning::ln::channelmanager::{Retry, PaymentId};
-       use lightning::ln::msgs::ChannelMessageHandler;
+       use bitcoin::hashes::sha256::Hash as Sha256;
        use lightning::ln::PaymentSecret;
-       use lightning::ln::functional_test_utils::*;
        use lightning::routing::router::Payee;
        use secp256k1::{SecretKey, PublicKey, Secp256k1};
-       use std::time::{SystemTime, Duration};
+       use core::time::Duration;
+       #[cfg(feature = "std")]
+       use std::time::SystemTime;
 
        fn duration_since_epoch() -> Duration {
                #[cfg(feature = "std")]
@@ -171,6 +169,10 @@ mod tests {
        #[test]
        #[cfg(feature = "std")]
        fn payment_metadata_end_to_end() {
+               use lightning::events::Event;
+               use lightning::ln::channelmanager::{Retry, PaymentId};
+               use lightning::ln::msgs::ChannelMessageHandler;
+               use lightning::ln::functional_test_utils::*;
                // Test that a payment metadata read from an invoice passed to `pay_invoice` makes it all
                // the way out through the `PaymentClaimable` event.
                let chanmon_cfgs = create_chanmon_cfgs(2);