Merge pull request #2799 from benthecarman/tx-sync-wasm
authorElias Rohrer <dev@tnull.de>
Mon, 8 Jan 2024 17:55:07 +0000 (18:55 +0100)
committerGitHub <noreply@github.com>
Mon, 8 Jan 2024 17:55:07 +0000 (18:55 +0100)
Don't call system time in no-std

18 files changed:
.github/workflows/build.yml
ci/ci-tests.sh
lightning-background-processor/src/lib.rs
lightning-block-sync/src/convert.rs
lightning-invoice/src/lib.rs
lightning-invoice/src/payment.rs
lightning-invoice/src/sync.rs [deleted file]
lightning-invoice/src/utils.rs
lightning-persister/src/fs_store.rs
lightning/src/ln/channelmanager.rs
lightning/src/ln/payment_tests.rs
lightning/src/ln/peer_handler.rs
lightning/src/ln/reload_tests.rs
lightning/src/onion_message/messenger.rs
lightning/src/onion_message/offers.rs
lightning/src/routing/scoring.rs
lightning/src/sync/nostd_sync.rs
lightning/src/util/crypto.rs

index 65be3faef8b5578e0e44b84a6e3651be360af01f..ad5e1fc517bf4e5a706cbc90070ef407407e9cb5 100644 (file)
@@ -39,6 +39,9 @@ jobs:
         run: |
           sudo apt-get -y install shellcheck
           shellcheck ci/ci-tests.sh
+      - name: Set RUSTFLAGS to deny warnings
+        if: "matrix.toolchain == '1.63.0'"
+        run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
       - name: Run CI script
         shell: bash # Default on Winblows is powershell
         run: CI_MINIMIZE_DISK_USAGE=1 ./ci/ci-tests.sh
index ca8e20f07885b2ccd84c7967b5eb89fedd68f46a..3eccc48798dc6e4b5f3fccd0b0c29003be23b0c8 100755 (executable)
@@ -94,14 +94,14 @@ if [[ "$HOST_PLATFORM" != *windows* ]]; then
 
        DOWNLOAD_ELECTRS_AND_BITCOIND
 
-       RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-blocking
-       RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-blocking
-       RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-async
-       RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-async
-       RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-async-https
-       RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-async-https
-       RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features electrum
-       RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features electrum
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-blocking
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-blocking
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-async
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-async
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-async-https
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-async-https
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features electrum
+       RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features electrum
 
        popd
 fi
@@ -125,7 +125,7 @@ popd
 echo -e "\n\nBuilding with all Log-Limiting features"
 pushd lightning
 grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
-       cargo check --verbose --color always --features "$FEATURE"
+       RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check --verbose --color always --features "$FEATURE"
 done
 popd
 
@@ -138,9 +138,9 @@ done
 
 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
        # check if there is a conflict between no-std and the c_bindings cfg
-       RUSTFLAGS="--cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
+       RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
 done
-RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always
+RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
 
 # Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
 pushd lightning
@@ -174,5 +174,5 @@ if [ -f "$(which arm-none-eabi-gcc)" ]; then
 fi
 
 echo -e "\n\nTest cfg-flag builds"
-RUSTFLAGS="$RUSTFLAGS --cfg=taproot" cargo test --verbose --color always -p lightning
-RUSTFLAGS="$RUSTFLAGS --cfg=async_signing" cargo test --verbose --color always -p lightning
+RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
+RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
index a12ec9c0f3b8b85a868e9f2e3fa05f0abc460b3d..0f2c67538d65de59acb37da608ca0f48da78f227 100644 (file)
@@ -27,7 +27,10 @@ use lightning::chain::chainmonitor::{ChainMonitor, Persist};
 use lightning::sign::{EntropySource, NodeSigner, SignerProvider};
 use lightning::events::{Event, PathFailure};
 #[cfg(feature = "std")]
-use lightning::events::{EventHandler, EventsProvider};
+use lightning::events::EventHandler;
+#[cfg(any(feature = "std", feature = "futures"))]
+use lightning::events::EventsProvider;
+
 use lightning::ln::channelmanager::ChannelManager;
 use lightning::ln::msgs::OnionMessageHandler;
 use lightning::ln::peer_handler::APeerManager;
@@ -727,8 +730,6 @@ async fn process_onion_message_handler_events_async<
 where
        PM::Target: APeerManager + Send + Sync,
 {
-       use lightning::events::EventsProvider;
-
        let events = core::cell::RefCell::new(Vec::new());
        peer_manager.onion_message_handler().process_pending_events(&|e| events.borrow_mut().push(e));
 
index 62b0d6e47cbbd303e19fde760b57d22339423009..ed811d2cc0c3f629e16a450937c58d8287f35689 100644 (file)
@@ -247,10 +247,12 @@ impl TryInto<BlockHash> for JsonResponse {
 /// The REST `getutxos` endpoint retuns a whole pile of data we don't care about and one bit we do
 /// - whether the `hit bitmap` field had any entries. Thus we condense the result down into only
 /// that.
+#[cfg(feature = "rest-client")]
 pub(crate) struct GetUtxosResponse {
        pub(crate) hit_bitmap_nonempty: bool
 }
 
+#[cfg(feature = "rest-client")]
 impl TryInto<GetUtxosResponse> for JsonResponse {
        type Error = std::io::Error;
 
index 690bf57640862daae0adb55019ab48d90a2384a0..df0412bfc5d3e0d3876b177200527e01fd272678 100644 (file)
@@ -77,6 +77,7 @@ mod de;
 mod ser;
 mod tb;
 
+#[allow(unused_imports)]
 mod prelude {
        #[cfg(feature = "hashbrown")]
        extern crate hashbrown;
@@ -92,10 +93,6 @@ mod prelude {
 
 use crate::prelude::*;
 
-/// Sync compat for std/no_std
-#[cfg(not(feature = "std"))]
-mod sync;
-
 /// Errors that indicate what is wrong with the invoice. They have some granularity for debug
 /// reasons, but should generally result in an "invalid BOLT11 invoice" message for the user.
 #[allow(missing_docs)]
@@ -2049,7 +2046,7 @@ mod test {
                use lightning::routing::router::RouteHintHop;
                use secp256k1::Secp256k1;
                use secp256k1::{SecretKey, PublicKey};
-               use std::time::{UNIX_EPOCH, Duration};
+               use std::time::Duration;
 
                let secp_ctx = Secp256k1::new();
 
@@ -2138,7 +2135,7 @@ mod test {
                assert_eq!(invoice.currency(), Currency::BitcoinTestnet);
                #[cfg(feature = "std")]
                assert_eq!(
-                       invoice.timestamp().duration_since(UNIX_EPOCH).unwrap().as_secs(),
+                       invoice.timestamp().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(),
                        1234567
                );
                assert_eq!(invoice.payee_pub_key(), Some(&public_key));
index b8f564ef573bf9b37dba86350bf73df745f42b0a..8196fa9eb89a81d7df74300484ee96cddee5588f 100644 (file)
@@ -85,14 +85,12 @@ 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 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);
diff --git a/lightning-invoice/src/sync.rs b/lightning-invoice/src/sync.rs
deleted file mode 100644 (file)
index fae923f..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-use core::cell::{RefCell, RefMut};
-use core::ops::{Deref, DerefMut};
-
-pub type LockResult<Guard> = Result<Guard, ()>;
-
-pub struct Mutex<T: ?Sized> {
-       inner: RefCell<T>
-}
-
-#[must_use = "if unused the Mutex will immediately unlock"]
-pub struct MutexGuard<'a, T: ?Sized + 'a> {
-       lock: RefMut<'a, T>,
-}
-
-impl<T: ?Sized> Deref for MutexGuard<'_, T> {
-       type Target = T;
-
-       fn deref(&self) -> &T {
-               &self.lock.deref()
-       }
-}
-
-impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
-       fn deref_mut(&mut self) -> &mut T {
-               self.lock.deref_mut()
-       }
-}
-
-impl<T> Mutex<T> {
-       pub fn new(inner: T) -> Mutex<T> {
-               Mutex { inner: RefCell::new(inner) }
-       }
-
-       pub fn lock<'a>(&'a self) -> LockResult<MutexGuard<'a, T>> {
-               Ok(MutexGuard { lock: self.inner.borrow_mut() })
-       }
-}
index 3a337a9a4b964dea101ee04ea5f6346b4b68fe27..5e8b72467e5da655cd9f77876ac692b948498833 100644 (file)
@@ -816,14 +816,15 @@ impl<'a, 'b, L: Deref> WithChannelDetails<'a, 'b, L> where L::Target: Logger {
 
 #[cfg(test)]
 mod test {
-       use core::cell::RefCell;
        use core::time::Duration;
        use crate::{Currency, Description, Bolt11InvoiceDescription, SignOrCreationError, CreationError};
        use bitcoin::hashes::{Hash, sha256};
        use bitcoin::hashes::sha256::Hash as Sha256;
        use lightning::sign::PhantomKeysManager;
-       use lightning::events::{MessageSendEvent, MessageSendEventsProvider, Event, EventsProvider};
-       use lightning::ln::{PaymentPreimage, PaymentHash};
+       use lightning::events::{MessageSendEvent, MessageSendEventsProvider};
+       use lightning::ln::PaymentHash;
+       #[cfg(feature = "std")]
+       use lightning::ln::PaymentPreimage;
        use lightning::ln::channelmanager::{PhantomRouteHints, MIN_FINAL_CLTV_EXPIRY_DELTA, PaymentId, RecipientOnionFields, Retry};
        use lightning::ln::functional_test_utils::*;
        use lightning::ln::msgs::ChannelMessageHandler;
@@ -1294,6 +1295,9 @@ mod test {
 
        #[cfg(feature = "std")]
        fn do_test_multi_node_receive(user_generated_pmt_hash: bool) {
+               use lightning::events::{Event, EventsProvider};
+               use core::cell::RefCell;
+
                let mut chanmon_cfgs = create_chanmon_cfgs(3);
                let seed_1 = [42u8; 32];
                let seed_2 = [43u8; 32];
index 118cf9af7ba0e9554ca23514534007ca8c824e0a..b5c6526207df007f10f33df3deac57629015323e 100644 (file)
@@ -381,11 +381,6 @@ mod tests {
        use lightning::util::persist::read_channel_monitors;
        use std::fs;
        use std::str::FromStr;
-       #[cfg(target_os = "windows")]
-       use {
-               lightning::get_event_msg,
-               lightning::ln::msgs::ChannelMessageHandler,
-       };
 
        impl Drop for FilesystemStore {
                fn drop(&mut self) {
index b2b28cdf365cce7ed07eda808089525c039ad015..75cd72b8f6897416fd482362263af139201fd459 100644 (file)
@@ -47,9 +47,7 @@ use crate::ln::channel::{Channel, ChannelPhase, ChannelContext, ChannelError, Ch
 use crate::ln::features::{Bolt12InvoiceFeatures, ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
 #[cfg(any(feature = "_test_utils", test))]
 use crate::ln::features::Bolt11InvoiceFeatures;
-use crate::routing::gossip::NetworkGraph;
-use crate::routing::router::{BlindedTail, DefaultRouter, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
-use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
+use crate::routing::router::{BlindedTail, InFlightHtlcs, Path, Payee, PaymentParameters, Route, RouteParameters, Router};
 use crate::ln::onion_payment::{check_incoming_htlc_cltv, create_recv_pending_htlc_info, create_fwd_pending_htlc_info, decode_incoming_update_add_htlc_onion, InboundOnionErr, NextPacketDetails};
 use crate::ln::msgs;
 use crate::ln::onion_utils;
@@ -66,7 +64,7 @@ use crate::offers::offer::{DerivedMetadata, Offer, OfferBuilder};
 use crate::offers::parse::Bolt12SemanticError;
 use crate::offers::refund::{Refund, RefundBuilder};
 use crate::onion_message::{Destination, MessageRouter, OffersMessage, OffersMessageHandler, PendingOnionMessage, new_pending_onion_message};
-use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient, SignerProvider};
+use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
 use crate::sign::ecdsa::WriteableEcdsaChannelSigner;
 use crate::util::config::{UserConfig, ChannelConfig, ChannelConfigUpdate};
 use crate::util::wakers::{Future, Notifier};
@@ -75,6 +73,13 @@ use crate::util::string::UntrustedString;
 use crate::util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
 use crate::util::logger::{Level, Logger, WithContext};
 use crate::util::errors::APIError;
+#[cfg(not(c_bindings))]
+use {
+       crate::routing::router::DefaultRouter,
+       crate::routing::gossip::NetworkGraph,
+       crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters},
+       crate::sign::KeysManager,
+};
 
 use alloc::collections::{btree_map, BTreeMap};
 
index 6af0e63c98bf421bade346f89f1fff303f48e764..73cdf59bbb699fb6966ad964ac99d6f00f3efeb9 100644 (file)
@@ -43,10 +43,9 @@ use crate::ln::functional_test_utils;
 use crate::ln::functional_test_utils::*;
 use crate::routing::gossip::NodeId;
 #[cfg(feature = "std")]
-use {
-       crate::util::time::tests::SinceEpoch,
-       std::time::{SystemTime, Instant, Duration}
-};
+use std::time::{SystemTime, Instant, Duration};
+#[cfg(not(feature = "no-std"))]
+use crate::util::time::tests::SinceEpoch;
 
 #[test]
 fn mpp_failure() {
index a4e0042414f8996f95c08deb72d7a578322fff97..9f49b67932bc02c5972f5b7b1351a933df15eacb 100644 (file)
@@ -18,7 +18,7 @@
 use bitcoin::blockdata::constants::ChainHash;
 use bitcoin::secp256k1::{self, Secp256k1, SecretKey, PublicKey};
 
-use crate::sign::{KeysManager, NodeSigner, Recipient};
+use crate::sign::{NodeSigner, Recipient};
 use crate::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider};
 use crate::ln::ChannelId;
 use crate::ln::features::{InitFeatures, NodeFeatures};
@@ -33,7 +33,7 @@ use crate::ln::wire::{Encode, Type};
 #[cfg(not(c_bindings))]
 use crate::onion_message::{SimpleArcOnionMessenger, SimpleRefOnionMessenger};
 use crate::onion_message::{CustomOnionMessageHandler, OffersMessage, OffersMessageHandler, OnionMessageContents, PendingOnionMessage};
-use crate::routing::gossip::{NetworkGraph, P2PGossipSync, NodeId, NodeAlias};
+use crate::routing::gossip::{NodeId, NodeAlias};
 use crate::util::atomic_counter::AtomicCounter;
 use crate::util::logger::{Logger, WithContext};
 use crate::util::string::PrintableString;
@@ -41,12 +41,19 @@ use crate::util::string::PrintableString;
 use crate::prelude::*;
 use crate::io;
 use alloc::collections::VecDeque;
-use crate::sync::{Arc, Mutex, MutexGuard, FairRwLock};
+use crate::sync::{Mutex, MutexGuard, FairRwLock};
 use core::sync::atomic::{AtomicBool, AtomicU32, AtomicI32, Ordering};
 use core::{cmp, hash, fmt, mem};
 use core::ops::Deref;
 use core::convert::Infallible;
-#[cfg(feature = "std")] use std::error;
+#[cfg(feature = "std")]
+use std::error;
+#[cfg(not(c_bindings))]
+use {
+       crate::routing::gossip::{NetworkGraph, P2PGossipSync},
+       crate::sign::KeysManager,
+       crate::sync::Arc,
+};
 
 use bitcoin::hashes::sha256::Hash as Sha256;
 use bitcoin::hashes::sha256::HashEngine as Sha256Engine;
index b3d52b78f2b5a5a3921c66873325fde418601b2b..1ac290383a48761fa1e892bbc01fc73685aad983 100644 (file)
@@ -15,16 +15,14 @@ use crate::chain::channelmonitor::{CLOSED_CHANNEL_UPDATE_ID, ChannelMonitor};
 use crate::sign::EntropySource;
 use crate::chain::transaction::OutPoint;
 use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider};
-use crate::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, PaymentId, Retry, RecipientOnionFields};
+use crate::ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, PaymentId, RecipientOnionFields};
 use crate::ln::msgs;
 use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ErrorAction};
-use crate::routing::router::{RouteParameters, PaymentParameters};
 use crate::util::test_channel_signer::TestChannelSigner;
 use crate::util::test_utils;
 use crate::util::errors::APIError;
 use crate::util::ser::{Writeable, ReadableArgs};
 use crate::util::config::UserConfig;
-use crate::util::string::UntrustedString;
 
 use bitcoin::hash_types::BlockHash;
 
@@ -496,6 +494,9 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
 
 #[cfg(feature = "std")]
 fn do_test_data_loss_protect(reconnect_panicing: bool, substantially_old: bool, not_stale: bool) {
+       use crate::routing::router::{RouteParameters, PaymentParameters};
+       use crate::ln::channelmanager::Retry;
+       use crate::util::string::UntrustedString;
        // When we get a data_loss_protect proving we're behind, we immediately panic as the
        // chain::Watch API requirements have been violated (e.g. the user restored from a backup). The
        // panic message informs the user they should force-close without broadcasting, which is tested
index 7743270e257b039301b4eaa9cdab681e242590b3..a8ffcc02466f5afa918bf299e7a41572d24b72fc 100644 (file)
@@ -19,13 +19,12 @@ use crate::blinded_path::BlindedPath;
 use crate::blinded_path::message::{advance_path_by_one, ForwardTlvs, ReceiveTlvs};
 use crate::blinded_path::utils;
 use crate::events::{Event, EventHandler, EventsProvider};
-use crate::sign::{EntropySource, KeysManager, NodeSigner, Recipient};
+use crate::sign::{EntropySource, NodeSigner, Recipient};
 #[cfg(not(c_bindings))]
 use crate::ln::channelmanager::{SimpleArcChannelManager, SimpleRefChannelManager};
 use crate::ln::features::{InitFeatures, NodeFeatures};
 use crate::ln::msgs::{self, OnionMessage, OnionMessageHandler, SocketAddress};
 use crate::ln::onion_utils;
-use crate::ln::peer_handler::IgnoringMessageHandler;
 use crate::routing::gossip::{NetworkGraph, NodeId};
 pub use super::packet::OnionMessageContents;
 use super::packet::ParsedOnionMessageContents;
@@ -37,9 +36,16 @@ use crate::util::ser::Writeable;
 use core::fmt;
 use core::ops::Deref;
 use crate::io;
-use crate::sync::{Arc, Mutex};
+use crate::sync::Mutex;
 use crate::prelude::*;
 
+#[cfg(not(c_bindings))]
+use {
+       crate::sign::KeysManager,
+       crate::ln::peer_handler::IgnoringMessageHandler,
+       crate::sync::Arc,
+};
+
 pub(super) const MAX_TIMER_TICKS: usize = 2;
 
 /// A sender, receiver and forwarder of [`OnionMessage`]s.
@@ -258,7 +264,7 @@ pub struct PendingOnionMessage<T: OnionMessageContents> {
 ///
 /// These are obtained when released from [`OnionMessenger`]'s handlers after which they are
 /// enqueued for sending.
-pub type PendingOnionMessage<T: OnionMessageContents> = (T, Destination, Option<BlindedPath>);
+pub type PendingOnionMessage<T> = (T, Destination, Option<BlindedPath>);
 
 pub(crate) fn new_pending_onion_message<T: OnionMessageContents>(
        contents: T, destination: Destination, reply_path: Option<BlindedPath>
index fb6ff746717ed1daeb731032ee2fd0145428b53f..a65c0393a1e922042482cd3d16dca877cf110ea2 100644 (file)
@@ -18,9 +18,10 @@ use crate::offers::invoice_request::InvoiceRequest;
 use crate::offers::invoice::Bolt12Invoice;
 use crate::offers::parse::Bolt12ParseError;
 use crate::onion_message::OnionMessageContents;
-use crate::onion_message::messenger::PendingOnionMessage;
 use crate::util::logger::Logger;
 use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer};
+#[cfg(not(c_bindings))]
+use crate::onion_message::messenger::PendingOnionMessage;
 
 use crate::prelude::*;
 
index 6ace8681ac025a08423bff54c4dae67b829fab5f..858de610399c5b3e779ff4d5305992c3d80a0428 100644 (file)
@@ -64,12 +64,16 @@ use crate::util::logger::Logger;
 
 use crate::prelude::*;
 use core::{cmp, fmt};
-use core::cell::{RefCell, RefMut, Ref};
 use core::convert::TryInto;
 use core::ops::{Deref, DerefMut};
 use core::time::Duration;
 use crate::io::{self, Read};
-use crate::sync::{Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
+use crate::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
+#[cfg(not(c_bindings))]
+use {
+       core::cell::{RefCell, RefMut, Ref},
+       crate::sync::{Mutex, MutexGuard},
+};
 
 /// We define Score ever-so-slightly differently based on whether we are being built for C bindings
 /// or not. For users, `LockableScore` must somehow be writeable to disk. For Rust users, this is
index 27cfb9b8f782c4bafabecd5180a5d0d2256105c3..0f92bd6caa3ad7c914b304db24d5fa69a8456b85 100644 (file)
@@ -37,10 +37,6 @@ impl<T> Mutex<T> {
                Ok(MutexGuard { lock: self.inner.borrow_mut() })
        }
 
-       pub fn try_lock<'a>(&'a self) -> LockResult<MutexGuard<'a, T>> {
-               Ok(MutexGuard { lock: self.inner.borrow_mut() })
-       }
-
        pub fn into_inner(self) -> LockResult<T> {
                Ok(self.inner.into_inner())
        }
index bb5903b2c8d166783c8b6a275441282e9e7d1b27..98963c7c2bd4fd823c614e25b50dd1785d8dbab2 100644 (file)
@@ -64,6 +64,7 @@ pub fn sign<C: Signing>(ctx: &Secp256k1<C>, msg: &Message, sk: &SecretKey) -> Si
 }
 
 #[inline]
+#[allow(unused_variables)]
 pub fn sign_with_aux_rand<C: Signing, ES: Deref>(
        ctx: &Secp256k1<C>, msg: &Message, sk: &SecretKey, entropy_source: &ES
 ) -> Signature where ES::Target: EntropySource {