An upcoming rust-bitcoin release will remove the "no-std" feature.
Replace "no-std" in feature checks with "std", negating as needed. Using
a single feature flag makes the checks more consistent across modules.
let payment_paths = self.create_blinded_payment_paths(amount_msats, payment_secret)
.map_err(|_| Bolt12SemanticError::MissingPaths)?;
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
let builder = refund.respond_using_derived_keys(
payment_paths, payment_hash, expanded_key, entropy
)?;
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
let created_at = Duration::from_secs(
self.highest_seen_timestamp.load(Ordering::Acquire) as u64
);
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
let builder = refund.respond_using_derived_keys_no_std(
payment_paths, payment_hash, created_at, expanded_key, entropy
)?;
},
};
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
let created_at = Duration::from_secs(
self.highest_seen_timestamp.load(Ordering::Acquire) as u64
);
if invoice_request.keys.is_some() {
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
let builder = invoice_request.respond_using_derived_keys(
payment_paths, payment_hash
);
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
let builder = invoice_request.respond_using_derived_keys_no_std(
payment_paths, payment_hash, created_at
);
Err(error) => Some(OffersMessage::InvoiceError(error.into())),
}
} else {
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
let builder = invoice_request.respond_with(payment_paths, payment_hash);
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
let builder = invoice_request.respond_with_no_std(
payment_paths, payment_hash, created_at
);
use crate::util::errors::APIError;
use crate::util::logger::Logger;
use crate::util::time::Time;
-#[cfg(all(not(feature = "no-std"), test))]
+#[cfg(all(feature = "std", test))]
use crate::util::time::tests::SinceEpoch;
use crate::util::ser::ReadableArgs;
/// retry, and may retry multiple failed HTLCs at once if they failed around the same time and
/// were retried along a route from a single call to [`Router::find_route_with_id`].
Attempts(u32),
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
/// Time elapsed before abandoning retries for a payment. At least one attempt at payment is made;
/// see [`PaymentParameters::expiry_time`] to avoid any attempt at payment after a specific time.
///
Timeout(core::time::Duration),
}
-#[cfg(feature = "no-std")]
+#[cfg(not(feature = "std"))]
impl_writeable_tlv_based_enum!(Retry,
;
(0, Attempts)
);
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
impl_writeable_tlv_based_enum!(Retry,
;
(0, Attempts),
(Retry::Attempts(max_retry_count), PaymentAttempts { count, .. }) => {
max_retry_count > count
},
- #[cfg(all(not(feature = "no-std"), not(test)))]
+ #[cfg(all(feature = "std", not(test)))]
(Retry::Timeout(max_duration), PaymentAttempts { first_attempted_at, .. }) =>
*max_duration >= crate::util::time::MonotonicTime::now().duration_since(*first_attempted_at),
- #[cfg(all(not(feature = "no-std"), test))]
+ #[cfg(all(feature = "std", test))]
(Retry::Timeout(max_duration), PaymentAttempts { first_attempted_at, .. }) =>
*max_duration >= SinceEpoch::now().duration_since(*first_attempted_at),
}
/// it means the result of the first attempt is not known yet.
pub(crate) count: u32,
/// This field is only used when retry is `Retry::Timeout` which is only build with feature std
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
first_attempted_at: T,
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
phantom: core::marker::PhantomData<T>,
}
-#[cfg(not(any(feature = "no-std", test)))]
+#[cfg(not(any(not(feature = "std"), test)))]
type ConfiguredTime = crate::util::time::MonotonicTime;
-#[cfg(feature = "no-std")]
+#[cfg(not(feature = "std"))]
type ConfiguredTime = crate::util::time::Eternity;
-#[cfg(all(not(feature = "no-std"), test))]
+#[cfg(all(feature = "std", test))]
type ConfiguredTime = SinceEpoch;
impl<T: Time> PaymentAttemptsUsingTime<T> {
pub(crate) fn new() -> Self {
PaymentAttemptsUsingTime {
count: 0,
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
first_attempted_at: T::now(),
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
phantom: core::marker::PhantomData,
}
}
impl<T: Time> Display for PaymentAttemptsUsingTime<T> {
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
return write!(f, "attempts: {}", self.count);
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
return write!(
f,
"attempts: {}, duration: {}s",
use crate::routing::gossip::NodeId;
#[cfg(feature = "std")]
use std::time::{SystemTime, Instant, Duration};
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
use crate::util::time::tests::SinceEpoch;
#[test]
let mut msg_events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 0);
} else if test == AutoRetry::FailTimeout {
- #[cfg(not(feature = "no-std"))] {
+ #[cfg(feature = "std")] {
// Ensure ChannelManager will not retry a payment if it times out due to Retry::Timeout.
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::secret_only(payment_secret),
PaymentId(payment_hash.0), route_params, Retry::Timeout(Duration::from_secs(60))).unwrap();
// NOTE: In the case of no-std, we won't have access to the current UNIX time at the time of removal,
// so we'll just set the removal time here to the current UNIX time on the very next invocation
// of this function.
- #[cfg(feature = "no-std")]
+ #[cfg(not(feature = "std"))]
{
let mut tracked_time = Some(current_time_unix);
core::mem::swap(time, &mut tracked_time);
(route.paths[1].hops[1].short_channel_id == 4 && route.paths[0].hops[1].short_channel_id == 13));
}
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
pub(super) fn random_init_seed() -> u64 {
// Because the default HashMap in std pulls OS randomness, we can use it as a (bad) RNG.
use core::hash::{BuildHasher, Hasher};
}
#[test]
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
fn generate_routes() {
use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
}
#[test]
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
fn generate_routes_mpp() {
use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
}
#[test]
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
fn generate_large_mpp_routes() {
use crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters};
}
}
-#[cfg(all(any(test, ldk_bench), not(feature = "no-std")))]
+#[cfg(all(any(test, ldk_bench), feature = "std"))]
pub(crate) mod bench_utils {
use super::*;
use std::fs::File;
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
pub struct MonotonicTime(std::time::Instant);
/// The amount of time to shift `Instant` forward to prevent overflow when subtracting a `Duration`
/// from `Instant::now` on some operating systems (e.g., iOS representing `Instance` as `u64`).
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
const SHIFT: Duration = Duration::from_secs(10 * 365 * 24 * 60 * 60); // 10 years.
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
impl Time for MonotonicTime {
fn now() -> Self {
let instant = std::time::Instant::now().checked_add(SHIFT).expect("Overflow on MonotonicTime instantiation");
}
}
-#[cfg(not(feature = "no-std"))]
+#[cfg(feature = "std")]
impl Sub<Duration> for MonotonicTime {
type Output = Self;
}
#[test]
- #[cfg(not(feature = "no-std"))]
+ #[cfg(feature = "std")]
fn monotonic_time_subtracts() {
let now = super::MonotonicTime::now();
assert!(now.elapsed() < Duration::from_secs(10));