Remove async payments cfg flag
What changed, and why it matters
This commit removes a compile-time feature flag called `async_payments` so that the new async-receive Lightning functionality is always included. It is a feature-enablement/refactoring change, not a patch for a known vulnerability. The code being exposed was already present but hidden behind the flag. There is no direct evidence in the commit of a security bug being fixed; rather, the change makes an experimental API public now that it is considered usable.
Treat as a routine feature-enablement commit. Reviewers should verify that the ungated async payment paths have adequate input validation and fuzz coverage now that they are compiled by default, but no immediate security response is indicated by the diff.
Security signals we found
Feature flag removal exposes previously gated async payment code to all builds
No changes to cryptographic verification, HTLC release, or signature checks observed
Fuzz corpus updated to reflect new message traffic from async receive cache refresh
Commit message explicitly states API readiness, not a security fix
Evidence from the diff
The commit deletes cfg(async_payments) guards across the rust-lightning crate, exposing async payment receive paths (static invoices, offer caches, blinded paths for async recipients, etc.) unconditionally. It also removes the flag from Cargo.toml check-cfg list and updates a fuzz test seed to account for an extra feerate request triggered by the async receive offer cache refresh. The diff shows no logic changes to security-critical algorithms such as signature verification, HTLC handling, or cryptographic checks; it is purely feature ungating and minor import reorganization.
Changed components
lightning/src/ln/channelmanager.rslightning/src/offers/flow.rslightning/src/offers/async_receive_offer_cache.rslightning/src/onion_message/messenger.rslightning/src/onion_message/offers.rslightning/src/onion_message/packet.rslightning/src/events/mod.rsCargo.tomlInspect captured patch +120 / −238
diff --git a/Cargo.toml b/Cargo.toml
index 3891b11..340e1f2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -66,6 +66,5 @@ check-cfg = [
"cfg(taproot)",
"cfg(require_route_graph_test)",
"cfg(splicing)",
- "cfg(async_payments)",
"cfg(simple_close)",
]
diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs
index eb9d51d..ae9e385 100644
--- a/fuzz/src/full_stack.rs
+++ b/fuzz/src/full_stack.rs
@@ -1171,6 +1171,9 @@ fn two_peer_forwarding_seed() -> Vec<u8> {
ext_from_hex("030120", &mut test);
// init message (type 16) with static_remotekey required, no anchors/taproot, and other bits optional and mac
ext_from_hex("0010 00021aaa 0008aaa210aa2a0a9aaa 01000000000000000000000000000000", &mut test);
+ // One feerate request on peer connection due to a list_channels call when seeing if the async
+ // receive offer cache needs updating
+ ext_from_hex("00fd", &mut test);
// create outbound channel to peer 1 for 50k sat
ext_from_hex(
diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs
index 2b71207..70a6ba2 100644
--- a/lightning/src/events/mod.rs
+++ b/lightning/src/events/mod.rs
@@ -1628,7 +1628,6 @@ pub enum Event {
///
/// [`ChannelManager::blinded_paths_for_async_recipient`]: crate::ln::channelmanager::ChannelManager::blinded_paths_for_async_recipient
/// [`ChannelManager::set_paths_to_static_invoice_server`]: crate::ln::channelmanager::ChannelManager::set_paths_to_static_invoice_server
- #[cfg(async_payments)]
PersistStaticInvoice {
/// The invoice that should be persisted and later provided to payers when handling a future
/// [`Event::StaticInvoiceRequested`].
@@ -1645,6 +1644,8 @@ pub enum Event {
///
/// When an [`Event::StaticInvoiceRequested`] comes in for the invoice, this id will be surfaced
/// and can be used alongside the `invoice_id` to retrieve the invoice from the database.
+ ///
+ ///[`ChannelManager::blinded_paths_for_async_recipient`]: crate::ln::channelmanager::ChannelManager::blinded_paths_for_async_recipient
recipient_id: Vec<u8>,
/// A random identifier for the invoice. When an [`Event::StaticInvoiceRequested`] comes in for
/// the invoice, this id will be surfaced and can be used alongside the `recipient_id` to
@@ -1676,7 +1677,6 @@ pub enum Event {
/// [`ChannelManager::set_paths_to_static_invoice_server`]: crate::ln::channelmanager::ChannelManager::set_paths_to_static_invoice_server
/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
/// [`ChannelManager::send_static_invoice`]: crate::ln::channelmanager::ChannelManager::send_static_invoice
- #[cfg(async_payments)]
StaticInvoiceRequested {
/// An identifier for the recipient previously surfaced in
/// [`Event::PersistStaticInvoice::recipient_id`]. Useful when paired with the `invoice_id` to
@@ -2123,13 +2123,11 @@ impl Writeable for Event {
(8, former_temporary_channel_id, required),
});
},
- #[cfg(async_payments)]
&Event::PersistStaticInvoice { .. } => {
45u8.write(writer)?;
// No need to write these events because we can just restart the static invoice negotiation
// on startup.
},
- #[cfg(async_payments)]
&Event::StaticInvoiceRequested { .. } => {
47u8.write(writer)?;
// Never write StaticInvoiceRequested events as buffered onion messages aren't serialized.
@@ -2711,10 +2709,8 @@ impl MaybeReadable for Event {
}))
},
// Note that we do not write a length-prefixed TLV for PersistStaticInvoice events.
- #[cfg(async_payments)]
45u8 => Ok(None),
// Note that we do not write a length-prefixed TLV for StaticInvoiceRequested events.
- #[cfg(async_payments)]
47u8 => Ok(None),
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index b2ee350..00e05aa 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -34,8 +34,9 @@ use bitcoin::{secp256k1, Sequence};
#[cfg(splicing)]
use bitcoin::{ScriptBuf, TxIn, Weight};
-use crate::blinded_path::message::MessageForwardNode;
-use crate::blinded_path::message::{AsyncPaymentsContext, OffersContext};
+use crate::blinded_path::message::{
+ AsyncPaymentsContext, BlindedMessagePath, MessageForwardNode, OffersContext,
+};
use crate::blinded_path::payment::{
AsyncBolt12OfferContext, Bolt12OfferContext, PaymentContext, UnauthenticatedReceiveTlvs,
};
@@ -102,6 +103,7 @@ use crate::offers::offer::Offer;
use crate::offers::parse::Bolt12SemanticError;
use crate::offers::refund::Refund;
use crate::offers::signer;
+use crate::offers::static_invoice::StaticInvoice;
use crate::onion_message::async_payments::{
AsyncPaymentsMessage, AsyncPaymentsMessageHandler, HeldHtlcAvailable, OfferPaths,
OfferPathsRequest, ReleaseHeldHtlc, ServeStaticInvoice, StaticInvoicePersisted,
@@ -134,12 +136,8 @@ use crate::util::ser::{
};
use crate::util::wakers::{Future, Notifier};
-#[cfg(all(test, async_payments))]
+#[cfg(test)]
use crate::blinded_path::payment::BlindedPaymentPath;
-#[cfg(async_payments)]
-use {
- crate::blinded_path::message::BlindedMessagePath, crate::offers::static_invoice::StaticInvoice,
-};
#[cfg(feature = "dnssec")]
use {
@@ -5094,7 +5092,7 @@ where
)
}
- #[cfg(all(test, async_payments))]
+ #[cfg(test)]
pub(crate) fn test_modify_pending_payment<Fn>(&self, payment_id: &PaymentId, mut callback: Fn)
where
Fn: FnMut(&mut PendingOutboundPayment),
@@ -5224,7 +5222,6 @@ where
)
}
- #[cfg(async_payments)]
fn check_refresh_async_receive_offer_cache(&self, timer_tick_occurred: bool) {
let peers = self.get_peers_for_blinded_path();
let channels = self.list_usable_channels();
@@ -5248,27 +5245,24 @@ where
}
}
- #[cfg(all(test, async_payments))]
+ #[cfg(test)]
pub(crate) fn test_check_refresh_async_receive_offers(&self) {
self.check_refresh_async_receive_offer_cache(false);
}
/// Should be called after handling an [`Event::PersistStaticInvoice`], where the `Responder`
/// comes from [`Event::PersistStaticInvoice::invoice_persisted_path`].
- #[cfg(async_payments)]
pub fn static_invoice_persisted(&self, invoice_persisted_path: Responder) {
self.flow.static_invoice_persisted(invoice_persisted_path);
}
/// Forwards a [`StaticInvoice`] in response to an [`Event::StaticInvoiceRequested`].
- #[cfg(async_payments)]
pub fn send_static_invoice(
&self, invoice: StaticInvoice, responder: Responder,
) -> Result<(), Bolt12SemanticError> {
self.flow.enqueue_static_invoice(invoice, responder)
}
- #[cfg(async_payments)]
fn initiate_async_payment(
&self, invoice: &StaticInvoice, payment_id: PaymentId,
) -> Result<(), Bolt12PaymentError> {
@@ -5318,7 +5312,6 @@ where
res
}
- #[cfg(async_payments)]
fn send_payment_for_static_invoice(
&self, payment_id: PaymentId,
) -> Result<(), Bolt12PaymentError> {
@@ -7671,7 +7664,6 @@ where
self.pending_outbound_payments
.remove_stale_payments(duration_since_epoch, &self.pending_events);
- #[cfg(async_payments)]
self.check_refresh_async_receive_offer_cache(true);
// Technically we don't need to do this here, but if we have holding cell entries in a
@@ -11884,7 +11876,6 @@ where
/// interactively building a [`StaticInvoice`] with the static invoice server.
///
/// Useful for posting offers to receive payments later, such as posting an offer on a website.
- #[cfg(async_payments)]
pub fn get_async_receive_offer(&self) -> Result<Offer, ()> {
let (offer, needs_persist) = self.flow.get_async_receive_offer()?;
if needs_persist {
@@ -11901,7 +11892,6 @@ where
///
/// This method only needs to be called once when the server first takes on the recipient as a
/// client, or when the paths change, e.g. if the paths are set to expire at a particular time.
- #[cfg(async_payments)]
pub fn set_paths_to_static_invoice_server(
&self, paths_to_static_invoice_server: Vec<BlindedMessagePath>,
) -> Result<(), ()> {
@@ -12307,7 +12297,6 @@ where
/// The provided `recipient_id` must uniquely identify the recipient, and will be surfaced later
/// when the recipient provides us with a static invoice to persist and serve to payers on their
/// behalf.
- #[cfg(async_payments)]
pub fn blinded_paths_for_async_recipient(
&self, recipient_id: Vec<u8>, relative_expiry: Option<Duration>,
) -> Result<Vec<BlindedMessagePath>, ()> {
@@ -12315,7 +12304,6 @@ where
self.flow.blinded_paths_for_async_recipient(recipient_id, relative_expiry, peers)
}
- #[cfg(any(test, async_payments))]
pub(super) fn duration_since_epoch(&self) -> Duration {
#[cfg(not(feature = "std"))]
let now = Duration::from_secs(self.highest_seen_timestamp.load(Ordering::Acquire) as u64);
@@ -12347,12 +12335,12 @@ where
.collect::<Vec<_>>()
}
- #[cfg(all(test, async_payments))]
+ #[cfg(test)]
pub(super) fn test_get_peers_for_blinded_path(&self) -> Vec<MessageForwardNode> {
self.get_peers_for_blinded_path()
}
- #[cfg(all(test, async_payments))]
+ #[cfg(test)]
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
/// [`Router::create_blinded_payment_paths`].
pub(super) fn test_create_blinded_payment_paths(
@@ -12856,7 +12844,6 @@ where
// interactively building offers as soon as we can after startup. We can't start building offers
// until we have some peer connection(s) to receive onion messages over, so as a minor optimization
// refresh the cache when a peer connects.
- #[cfg(async_payments)]
self.check_refresh_async_receive_offer_cache(false);
res
}
@@ -14128,7 +14115,6 @@ where
log_trace!($logger, "Failed paying invoice: {:?}", e);
InvoiceError::from_string(format!("{:?}", e))
},
- #[cfg(async_payments)]
Err(Bolt12PaymentError::BlindedPathCreationFailed) => {
let err_msg = "Failed to create a blinded path back to ourselves";
log_trace!($logger, "{}", err_msg);
@@ -14161,7 +14147,6 @@ where
Ok(InvreqResponseInstructions::SendStaticInvoice {
recipient_id: _recipient_id, invoice_id: _invoice_id
}) => {
- #[cfg(async_payments)]
self.pending_events.lock().unwrap().push_back((Event::StaticInvoiceRequested {
recipient_id: _recipient_id, invoice_id: _invoice_id, reply_path: responder
}, None));
@@ -14226,7 +14211,6 @@ where
let res = self.send_payment_for_verified_bolt12_invoice(&invoice, payment_id);
handle_pay_invoice_res!(res, invoice, logger);
},
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(invoice) => {
let payment_id = match context {
Some(OffersContext::OutboundPayment { payment_id, .. }) => payment_id,
@@ -14289,95 +14273,77 @@ where
&self, _message: OfferPathsRequest, _context: AsyncPaymentsContext,
_responder: Option<Responder>,
) -> Option<(OfferPaths, ResponseInstruction)> {
- #[cfg(async_payments)]
- {
- let peers = self.get_peers_for_blinded_path();
- let entropy = &*self.entropy_source;
- let (message, reply_path_context) =
- match self.flow.handle_offer_paths_request(_context, peers, entropy) {
- Some(msg) => msg,
- None => return None,
- };
- _responder.map(|resp| (message, resp.respond_with_reply_path(reply_path_context)))
- }
-
- #[cfg(not(async_payments))]
- None
+ let peers = self.get_peers_for_blinded_path();
+ let entropy = &*self.entropy_source;
+ let (message, reply_path_context) =
+ match self.flow.handle_offer_paths_request(_context, peers, entropy) {
+ Some(msg) => msg,
+ None => return None,
+ };
+ _responder.map(|resp| (message, resp.respond_with_reply_path(reply_path_context)))
}
fn handle_offer_paths(
&self, _message: OfferPaths, _context: AsyncPaymentsContext, _responder: Option<Responder>,
) -> Option<(ServeStaticInvoice, ResponseInstruction)> {
- #[cfg(async_payments)]
- {
- let responder = match _responder {
- Some(responder) => responder,
- None => return None,
- };
- let (serve_static_invoice, reply_context) = match self.flow.handle_offer_paths(
- _message,
- _context,
- responder.clone(),
- self.get_peers_for_blinded_path(),
- self.list_usable_channels(),
- &*self.entropy_source,
- &*self.router,
- ) {
- Some((msg, ctx)) => (msg, ctx),
- None => return None,
- };
-
- // We cached a new pending offer, so persist the cache.
- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
+ let responder = match _responder {
+ Some(responder) => responder,
+ None => return None,
+ };
+ let (serve_static_invoice, reply_context) = match self.flow.handle_offer_paths(
+ _message,
+ _context,
+ responder.clone(),
+ self.get_peers_for_blinded_path(),
+ self.list_usable_channels(),
+ &*self.entropy_source,
+ &*self.router,
+ ) {
+ Some((msg, ctx)) => (msg, ctx),
+ None => return None,
+ };
- let response_instructions = responder.respond_with_reply_path(reply_context);
- return Some((serve_static_invoice, response_instructions));
- }
+ // We cached a new pending offer, so persist the cache.
+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- #[cfg(not(async_payments))]
- return None;
+ let response_instructions = responder.respond_with_reply_path(reply_context);
+ return Some((serve_static_invoice, response_instructions));
}
fn handle_serve_static_invoice(
&self, _message: ServeStaticInvoice, _context: AsyncPaymentsContext,
_responder: Option<Responder>,
) {
- #[cfg(async_payments)]
- {
- let responder = match _responder {
- Some(resp) => resp,
- None => return,
- };
+ let responder = match _responder {
+ Some(resp) => resp,
+ None => return,
+ };
- let (recipient_id, invoice_id) =
- match self.flow.verify_serve_static_invoice_message(&_message, _context) {
- Ok((recipient_id, inv_id)) => (recipient_id, inv_id),
- Err(()) => return,
- };
+ let (recipient_id, invoice_id) =
+ match self.flow.verify_serve_static_invoice_message(&_message, _context) {
+ Ok((recipient_id, inv_id)) => (recipient_id, inv_id),
+ Err(()) => return,
+ };
- let mut pending_events = self.pending_events.lock().unwrap();
- pending_events.push_back((
- Event::PersistStaticInvoice {
- invoice: _message.invoice,
- invoice_slot: _message.invoice_slot,
- recipient_id,
- invoice_id,
- invoice_persisted_path: responder,
- },
- None,
- ));
- }
+ let mut pending_events = self.pending_events.lock().unwrap();
+ pending_events.push_back((
+ Event::PersistStaticInvoice {
+ invoice: _message.invoice,
+ invoice_slot: _message.invoice_slot,
+ recipient_id,
+ invoice_id,
+ invoice_persisted_path: responder,
+ },
+ None,
+ ));
}
fn handle_static_invoice_persisted(
&self, _message: StaticInvoicePersisted, _context: AsyncPaymentsContext,
) {
- #[cfg(async_payments)]
- {
- let should_persist = self.flow.handle_static_invoice_persisted(_context);
- if should_persist {
- let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
- }
+ let should_persist = self.flow.handle_static_invoice_persisted(_context);
+ if should_persist {
+ let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
}
}
@@ -14385,31 +14351,23 @@ where
&self, _message: HeldHtlcAvailable, _context: AsyncPaymentsContext,
_responder: Option<Responder>,
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
- #[cfg(async_payments)]
- {
- self.flow.verify_inbound_async_payment_context(_context).ok()?;
- return _responder.map(|responder| (ReleaseHeldHtlc {}, responder.respond()));
- }
- #[cfg(not(async_payments))]
- return None;
+ self.flow.verify_inbound_async_payment_context(_context).ok()?;
+ return _responder.map(|responder| (ReleaseHeldHtlc {}, responder.respond()));
}
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
- #[cfg(async_payments)]
- {
- let payment_id = match _context {
- AsyncPaymentsContext::OutboundPayment { payment_id } => payment_id,
- _ => return,
- };
+ let payment_id = match _context {
+ AsyncPaymentsContext::OutboundPayment { payment_id } => payment_id,
+ _ => return,
+ };
- if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
- log_trace!(
- self.logger,
- "Failed to release held HTLC with payment id {}: {:?}",
- payment_id,
- e
- );
- }
+ if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
+ log_trace!(
+ self.logger,
+ "Failed to release held HTLC with payment id {}: {:?}",
+ payment_id,
+ e
+ );
}
}
diff --git a/lightning/src/ln/inbound_payment.rs b/lightning/src/ln/inbound_payment.rs
index a7d45b8..f7b2a4a 100644
--- a/lightning/src/ln/inbound_payment.rs
+++ b/lightning/src/ln/inbound_payment.rs
@@ -213,7 +213,6 @@ pub fn create_from_hash(
Ok(construct_payment_secret(&iv_bytes, &metadata_bytes, &keys.metadata_key))
}
-#[cfg(async_payments)]
pub(crate) fn create_for_spontaneous_payment(
keys: &ExpandedKey, min_value_msat: Option<u64>, invoice_expiry_delta_secs: u32,
current_time: u64, min_final_cltv_expiry_delta: Option<u16>,
diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs
index a513582..3ca3b76 100644
--- a/lightning/src/ln/mod.rs
+++ b/lightning/src/ln/mod.rs
@@ -60,7 +60,7 @@ pub use onion_utils::process_onion_failure;
#[cfg(fuzzing)]
pub use onion_utils::AttributionData;
-#[cfg(all(test, async_payments))]
+#[cfg(test)]
#[allow(unused_mut)]
mod async_payments_tests;
#[cfg(test)]
diff --git a/lightning/src/ln/offers_tests.rs b/lightning/src/ln/offers_tests.rs
index ba9858b..6c56ecc 100644
--- a/lightning/src/ln/offers_tests.rs
+++ b/lightning/src/ln/offers_tests.rs
@@ -227,7 +227,6 @@ pub(super) fn extract_invoice_request<'a, 'b, 'c>(
Ok(PeeledOnion::Offers(message, _, reply_path)) => match message {
OffersMessage::InvoiceRequest(invoice_request) => (invoice_request, reply_path.unwrap()),
OffersMessage::Invoice(invoice) => panic!("Unexpected invoice: {:?}", invoice),
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(invoice) => panic!("Unexpected static invoice: {:?}", invoice),
OffersMessage::InvoiceError(error) => panic!("Unexpected invoice_error: {:?}", error),
},
@@ -242,7 +241,6 @@ fn extract_invoice<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, message: &OnionMessage)
Ok(PeeledOnion::Offers(message, _, reply_path)) => match message {
OffersMessage::InvoiceRequest(invoice_request) => panic!("Unexpected invoice_request: {:?}", invoice_request),
OffersMessage::Invoice(invoice) => (invoice, reply_path.unwrap()),
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(invoice) => panic!("Unexpected static invoice: {:?}", invoice),
OffersMessage::InvoiceError(error) => panic!("Unexpected invoice_error: {:?}", error),
},
@@ -259,7 +257,6 @@ fn extract_invoice_error<'a, 'b, 'c>(
Ok(PeeledOnion::Offers(message, _, _)) => match message {
OffersMessage::InvoiceRequest(invoice_request) => panic!("Unexpected invoice_request: {:?}", invoice_request),
OffersMessage::Invoice(invoice) => panic!("Unexpected invoice: {:?}", invoice),
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(invoice) => panic!("Unexpected invoice: {:?}", invoice),
OffersMessage::InvoiceError(error) => error,
},
@@ -1235,7 +1232,7 @@ fn pays_bolt12_invoice_asynchronously() {
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
- // Re-process the same onion message to ensure idempotency —
+ // Re-process the same onion message to ensure idempotency —
// we should not generate a duplicate `InvoiceReceived` event.
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs
index ffc3ee4..476964d 100644
--- a/lightning/src/ln/outbound_payment.rs
+++ b/lightning/src/ln/outbound_payment.rs
@@ -20,7 +20,7 @@ use crate::ln::channel_state::ChannelDetails;
use crate::ln::channelmanager::{EventCompletionAction, HTLCSource, PaymentId};
use crate::ln::onion_utils;
use crate::ln::onion_utils::{DecodedOnionFailure, HTLCFailReason};
-use crate::offers::invoice::Bolt12Invoice;
+use crate::offers::invoice::{Bolt12Invoice, DerivedSigningPubkey, InvoiceBuilder};
use crate::offers::invoice_request::InvoiceRequest;
use crate::offers::nonce::Nonce;
use crate::offers::static_invoice::StaticInvoice;
@@ -37,9 +37,6 @@ use crate::util::ser::ReadableArgs;
#[cfg(feature = "std")]
use crate::util::time::Instant;
-#[cfg(async_payments)]
-use crate::offers::invoice::{DerivedSigningPubkey, InvoiceBuilder};
-
use core::fmt::{self, Display, Formatter};
use core::ops::Deref;
use core::sync::atomic::{AtomicBool, Ordering};
@@ -54,12 +51,11 @@ use crate::sync::Mutex;
/// [`ChannelManager::timer_tick_occurred`]: crate::ln::channelmanager::ChannelManager::timer_tick_occurred
pub(crate) const IDEMPOTENCY_TIMEOUT_TICKS: u8 = 7;
-#[cfg(async_payments)]
/// The default relative expiration to wait for a pending outbound HTLC to a often-offline
/// payee to fulfill.
const ASYNC_PAYMENT_TIMEOUT_RELATIVE_EXPIRY: Duration = Duration::from_secs(60 * 60 * 24 * 7);
-#[cfg(all(async_payments, test))]
+#[cfg(test)]
pub(crate) const TEST_ASYNC_PAYMENT_TIMEOUT_RELATIVE_EXPIRY: Duration =
ASYNC_PAYMENT_TIMEOUT_RELATIVE_EXPIRY;
@@ -637,7 +633,6 @@ pub enum Bolt12PaymentError {
UnknownRequiredFeatures,
/// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed.
SendingFailed(RetryableSendFailure),
- #[cfg(async_payments)]
/// Failed to create a blinded path back to ourselves.
///
/// We attempted to initiate payment to a [`StaticInvoice`] but failed to create a reply path for
@@ -1111,7 +1106,6 @@ impl OutboundPayments {
Ok(())
}
- #[cfg(async_payments)]
#[rustfmt::skip]
pub(super) fn static_invoice_received<ES: Deref>(
&self, invoice: &StaticInvoice, payment_id: PaymentId, features: Bolt12InvoiceFeatures,
@@ -1201,7 +1195,6 @@ impl OutboundPayments {
};
}
- #[cfg(async_payments)]
#[rustfmt::skip]
pub(super) fn send_payment_for_static_invoice<
R: Deref, ES: Deref, NS: Deref, NL: Deref, IH, SP, L: Deref
diff --git a/lightning/src/offers/async_receive_offer_cache.rs b/lightning/src/offers/async_receive_offer_cache.rs
index 346c7a8..1b1078d 100644
--- a/lightning/src/offers/async_receive_offer_cache.rs
+++ b/lightning/src/offers/async_receive_offer_cache.rs
@@ -11,7 +11,7 @@
//! server as an async recipient. The static invoice server will serve the resulting invoices to
//! payers on our behalf when we're offline.
-use crate::blinded_path::message::BlindedMessagePath;
+use crate::blinded_path::message::{AsyncPaymentsContext, BlindedMessagePath};
use crate::io;
use crate::io::Read;
use crate::ln::msgs::DecodeError;
@@ -22,9 +22,6 @@ use crate::prelude::*;
use crate::util::ser::{Readable, Writeable, Writer};
use core::time::Duration;
-#[cfg(async_payments)]
-use crate::blinded_path::message::AsyncPaymentsContext;
-
/// The status of this offer in the cache.
#[derive(Clone, PartialEq)]
enum OfferStatus {
@@ -161,7 +158,6 @@ impl AsyncReceiveOfferCache {
/// on our behalf when we're offline.
///
/// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
- #[cfg(async_payments)]
pub(crate) fn set_paths_to_static_invoice_server(
&mut self, paths_to_static_invoice_server: Vec<BlindedMessagePath>,
) -> Result<(), ()> {
@@ -181,11 +177,9 @@ impl AsyncReceiveOfferCache {
// The target number of offers we want to have cached at any given time, to mitigate too much
// reuse of the same offer while also limiting the amount of space our offers take up on the
// server's end.
-#[cfg(async_payments)]
const MAX_CACHED_OFFERS_TARGET: usize = 10;
// The max number of times we'll attempt to request offer paths per timer tick.
-#[cfg(async_payments)]
const MAX_UPDATE_ATTEMPTS: u8 = 3;
// If we have an offer that is replaceable and is more than 2 hours old, we can go ahead and refresh
@@ -196,7 +190,6 @@ const MAX_UPDATE_ATTEMPTS: u8 = 3;
// invoices from different offers competing for the same slot to the server, messages are received
// delayed or out-of-order, and we end up providing an offer to the user that the server just
// deleted and replaced.
-#[cfg(async_payments)]
const OFFER_REFRESH_THRESHOLD: Duration = Duration::from_secs(2 * 60 * 60);
/// Invoices stored with the static invoice server may become stale due to outdated channel and fee
@@ -204,22 +197,20 @@ const OFFER_REFRESH_THRESHOLD: Duration = Duration::from_secs(2 * 60 * 60);
const INVOICE_REFRESH_THRESHOLD: Duration = Duration::from_secs(2 * 60 * 60);
// Require offer paths that we receive to last at least 3 months.
-#[cfg(async_payments)]
const MIN_OFFER_PATHS_RELATIVE_EXPIRY_SECS: u64 = 3 * 30 * 24 * 60 * 60;
-#[cfg(all(test, async_payments))]
+#[cfg(test)]
pub(crate) const TEST_MAX_CACHED_OFFERS_TARGET: usize = MAX_CACHED_OFFERS_TARGET;
-#[cfg(all(test, async_payments))]
+#[cfg(test)]
pub(crate) const TEST_MAX_UPDATE_ATTEMPTS: u8 = MAX_UPDATE_ATTEMPTS;
-#[cfg(all(test, async_payments))]
+#[cfg(test)]
pub(crate) const TEST_OFFER_REFRESH_THRESHOLD: Duration = OFFER_REFRESH_THRESHOLD;
-#[cfg(all(test, async_payments))]
+#[cfg(test)]
pub(crate) const TEST_INVOICE_REFRESH_THRESHOLD: Duration = INVOICE_REFRESH_THRESHOLD;
-#[cfg(all(test, async_payments))]
+#[cfg(test)]
pub(crate) const TEST_MIN_OFFER_PATHS_RELATIVE_EXPIRY_SECS: u64 =
MIN_OFFER_PATHS_RELATIVE_EXPIRY_SECS;
-#[cfg(async_payments)]
impl AsyncReceiveOfferCache {
/// Retrieve a cached [`Offer`] for receiving async payments as an often-offline recipient, as
/// well as returning a bool indicating whether the cache needs to be re-persisted.
diff --git a/lightning/src/offers/flow.rs b/lightning/src/offers/flow.rs
index 107c720..91c506e 100644
--- a/lightning/src/offers/flow.rs
+++ b/lightning/src/offers/flow.rs
@@ -19,11 +19,11 @@ use bitcoin::constants::ChainHash;
use bitcoin::secp256k1::{self, PublicKey, Secp256k1};
use crate::blinded_path::message::{
- BlindedMessagePath, MessageContext, MessageForwardNode, OffersContext,
+ AsyncPaymentsContext, BlindedMessagePath, MessageContext, MessageForwardNode, OffersContext,
};
use crate::blinded_path::payment::{
- BlindedPaymentPath, Bolt12OfferContext, Bolt12RefundContext, PaymentConstraints,
- PaymentContext, UnauthenticatedReceiveTlvs,
+ AsyncBolt12OfferContext, BlindedPaymentPath, Bolt12OfferContext, Bolt12RefundContext,
+ PaymentConstraints, PaymentContext, UnauthenticatedReceiveTlvs,
};
use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
@@ -44,32 +44,26 @@ use crate::offers::invoice_request::{
InvoiceRequest, InvoiceRequestBuilder, VerifiedInvoiceRequest,
};
use crate::offers::nonce::Nonce;
-use crate::offers::offer::{DerivedMetadata, Offer, OfferBuilder};
+use crate::offers::offer::{Amount, DerivedMetadata, Offer, OfferBuilder};
use crate::offers::parse::Bolt12SemanticError;
use crate::offers::refund::{Refund, RefundBuilder};
-use crate::onion_message::async_payments::AsyncPaymentsMessage;
-use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions};
+use crate::onion_message::async_payments::{
+ AsyncPaymentsMessage, HeldHtlcAvailable, OfferPaths, OfferPathsRequest, ServeStaticInvoice,
+ StaticInvoicePersisted,
+};
+use crate::onion_message::messenger::{
+ Destination, MessageRouter, MessageSendInstructions, Responder,
+};
use crate::onion_message::offers::OffersMessage;
use crate::onion_message::packet::OnionMessageContents;
use crate::routing::router::Router;
use crate::sign::{EntropySource, NodeSigner, ReceiveAuthKey};
+
+use crate::offers::static_invoice::{StaticInvoice, StaticInvoiceBuilder};
use crate::sync::{Mutex, RwLock};
use crate::types::payment::{PaymentHash, PaymentSecret};
use crate::util::ser::Writeable;
-#[cfg(async_payments)]
-use {
- crate::blinded_path::message::AsyncPaymentsContext,
- crate::blinded_path::payment::AsyncBolt12OfferContext,
- crate::offers::offer::Amount,
- crate::offers::static_invoice::{StaticInvoice, StaticInvoiceBuilder},
- crate::onion_message::async_payments::{
- HeldHtlcAvailable, OfferPaths, OfferPathsRequest, ServeStaticInvoice,
- StaticInvoicePersisted,
- },
- crate::onion_message::messenger::Responder,
-};
-
#[cfg(feature = "dnssec")]
use {
crate::blinded_path::message::DNSResolverContext,
@@ -167,7 +161,6 @@ where
///
/// This method only needs to be called once when the server first takes on the recipient as a
/// client, or when the paths change, e.g. if the paths are set to expire at a particular time.
- #[cfg(async_payments)]
pub fn set_paths_to_static_invoice_server(
&self, paths_to_static_invoice_server: Vec<BlindedMessagePath>,
peers: Vec<MessageForwardNode>,
@@ -192,7 +185,6 @@ where
self.receive_auth_key
}
- #[cfg(async_payments)]
fn duration_since_epoch(&self) -> Duration {
#[cfg(not(feature = "std"))]
let now = Duration::from_secs(self.highest_seen_timestamp.load(Ordering::Acquire) as u64);
@@ -242,7 +234,6 @@ where
/// The maximum size of a received [`StaticInvoice`] before we'll fail verification in
/// [`OffersMessageFlow::verify_serve_static_invoice_message].
-#[cfg(async_payments)]
pub const MAX_STATIC_INVOICE_SIZE_BYTES: usize = 5 * 1024;
/// Defines the maximum number of [`OffersMessage`] including different reply paths to be sent
@@ -252,22 +243,20 @@ pub const MAX_STATIC_INVOICE_SIZE_BYTES: usize = 5 * 1024;
/// even if multiple invoices are received.
const OFFERS_MESSAGE_REQUEST_LIMIT: usize = 10;
-#[cfg(all(async_payments, test))]
+#[cfg(test)]
pub(crate) const TEST_OFFERS_MESSAGE_REQUEST_LIMIT: usize = OFFERS_MESSAGE_REQUEST_LIMIT;
/// The default relative expiry for reply paths where a quick response is expected and the reply
/// path is single-use.
-#[cfg(async_payments)]
const TEMP_REPLY_PATH_RELATIVE_EXPIRY: Duration = Duration::from_secs(2 * 60 * 60);
-#[cfg(all(async_payments, test))]
+#[cfg(test)]
pub(crate) const TEST_TEMP_REPLY_PATH_RELATIVE_EXPIRY: Duration = TEMP_REPLY_PATH_RELATIVE_EXPIRY;
// Default to async receive offers and the paths used to update them lasting one year.
-#[cfg(async_payments)]
const DEFAULT_ASYNC_RECEIVE_OFFER_EXPIRY: Duration = Duration::from_secs(365 * 24 * 60 * 60);
-#[cfg(all(async_payments, test))]
+#[cfg(test)]
pub(crate) const TEST_DEFAULT_ASYNC_RECEIVE_OFFER_EXPIRY: Duration =
DEFAULT_ASYNC_RECEIVE_OFFER_EXPIRY;
@@ -284,7 +273,6 @@ where
/// [`Self::set_paths_to_static_invoice_server`].
///
/// Errors if blinded path creation fails or the provided `recipient_id` is larger than 1KiB.
- #[cfg(async_payments)]
pub fn blinded_paths_for_async_recipient(
&self, recipient_id: Vec<u8>, relative_expiry: Option<Duration>,
peers: Vec<MessageForwardNode>,
@@ -360,7 +348,7 @@ where
)
}
- #[cfg(all(test, async_payments))]
+ #[cfg(test)]
/// Creates multi-hop blinded payment paths for the given `amount_msats` by delegating to
/// [`Router::create_blinded_payment_paths`].
pub(crate) fn test_create_blinded_payment_paths<ES: Deref, R: Deref>(
@@ -445,7 +433,6 @@ where
let nonce = match context {
None if invoice_request.metadata().is_some() => None,
Some(OffersContext::InvoiceRequest { nonce }) => Some(nonce),
- #[cfg(async_payments)]
Some(OffersContext::StaticInvoiceRequested {
recipient_id,
invoice_id,
@@ -507,7 +494,6 @@ where
///
/// Returns `Err(())` if:
/// - The inbound payment context has expired.
- #[cfg(async_payments)]
pub fn verify_inbound_async_payment_context(
&self, context: AsyncPaymentsContext,
) -> Result<(), ()> {
@@ -623,7 +609,6 @@ where
/// 2. Use [`Self::create_static_invoice_builder`] to create a [`StaticInvoice`] from this
/// [`Offer`] plus the returned [`Nonce`], and provide the static invoice to the
/// aforementioned always-online node.
- #[cfg(async_payments)]
pub fn create_async_receive_offer_builder<ES: Deref>(
&self, entropy_source: ES, message_paths_to_always_online_node: Vec<BlindedMessagePath>,
) -> Result<(OfferBuilder<DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError>
@@ -792,7 +777,6 @@ where
/// Creates a [`StaticInvoiceBuilder`] from the corresponding [`Offer`] and [`Nonce`] that were
/// created via [`Self::create_async_receive_offer_builder`].
- #[cfg(async_payments)]
pub fn create_static_invoice_builder<'a, ES: Deref, R: Deref>(
&self, router: &R, entropy_source: ES, offer: &'a Offer, offer_nonce: Nonce,
payment_secret: PaymentSecret, relative_expiry_secs: u32,
@@ -1115,7 +1099,6 @@ where
/// Forwards a [`StaticInvoice`] over the provided [`Responder`] in response to an
/// [`InvoiceRequest`] that we as a static invoice server received on behalf of an often-offline
/// recipient.
- #[cfg(async_payments)]
pub fn enqueue_static_invoice(
&self, invoice: StaticInvoice, responder: Responder,
) -> Result<(), Bolt12SemanticError> {
@@ -1144,7 +1127,6 @@ where
///
/// [`ReleaseHeldHtlc`]: crate::onion_message::async_payments::ReleaseHeldHtlc
/// [`supports_onion_messages`]: crate::types::features::Features::supports_onion_messages
- #[cfg(async_payments)]
pub fn enqueue_held_htlc_available(
&self, invoice: &StaticInvoice, payment_id: PaymentId, peers: Vec<MessageForwardNode>,
) -> Result<(), Bolt12SemanticError> {
@@ -1230,13 +1212,12 @@ where
///
/// Returns the requested offer as well as a bool indicating whether the cache needs to be
/// persisted using [`Self::writeable_async_receive_offer_cache`].
- #[cfg(async_payments)]
pub fn get_async_receive_offer(&self) -> Result<(Offer, bool), ()> {
let mut cache = self.async_receive_offer_cache.lock().unwrap();
cache.get_async_receive_offer(self.duration_since_epoch())
}
- #[cfg(all(test, async_payments))]
+ #[cfg(test)]
pub(crate) fn test_get_async_receive_offers(&self) -> Vec<Offer> {
self.async_receive_offer_cache.lock().unwrap().test_get_payable_offers()
}
@@ -1252,7 +1233,6 @@ where
/// the cache can self-regulate the number of messages sent out.
///
/// Errors if we failed to create blinded reply paths when sending an [`OfferPathsRequest`] message.
- #[cfg(async_payments)]
pub fn check_refresh_async_receive_offer_cache<ES: Deref, R: Deref>(
&self, peers: Vec<MessageForwardNode>, usable_channels: Vec<ChannelDetails>, entropy: ES,
router: R, timer_tick_occurred: bool,
@@ -1278,7 +1258,6 @@ where
Ok(())
}
- #[cfg(async_payments)]
fn check_refresh_async_offers(
&self, peers: Vec<MessageForwardNode>, timer_tick_occurred: bool,
) -> Result<(), ()> {
@@ -1323,7 +1302,6 @@ where
/// Enqueue onion messages that will used to request invoice refresh from the static invoice
/// server, based on the offers provided by the cache.
- #[cfg(async_payments)]
fn check_refresh_static_invoices<ES: Deref, R: Deref>(
&self, peers: Vec<MessageForwardNode>, usable_channels: Vec<ChannelDetails>, entropy: ES,
router: R,
@@ -1392,7 +1370,6 @@ where
/// Handles an incoming [`OfferPathsRequest`] onion message from an often-offline recipient who
/// wants us (the static invoice server) to serve [`StaticInvoice`]s to payers on their behalf.
/// Sends out [`OfferPaths`] onion messages in response.
- #[cfg(async_payments)]
pub fn handle_offer_paths_request<ES: Deref>(
&self, context: AsyncPaymentsContext, peers: Vec<MessageForwardNode>, entropy_source: ES,
) -> Option<(OfferPaths, MessageContext)>
@@ -1455,7 +1432,6 @@ where
///
/// Returns `None` if we have enough offers cached already, verification of `message` fails, or we
/// fail to create blinded paths.
- #[cfg(async_payments)]
pub fn handle_offer_paths<ES: Deref, R: Deref>(
&self, message: OfferPaths, context: AsyncPaymentsContext, responder: Responder,
peers: Vec<MessageForwardNode>, usable_channels: Vec<ChannelDetails>, entropy: ES,
@@ -1544,7 +1520,6 @@ where
/// Creates a [`StaticInvoice`] and a blinded path for the server to forward invoice requests from
/// payers to our node.
- #[cfg(async_payments)]
fn create_static_invoice_for_server<ES: Deref, R: Deref>(
&self, offer: &Offer, offer_nonce: Nonce, peers: Vec<MessageForwardNode>,
usable_channels: Vec<ChannelDetails>, entropy: ES, router: R,
@@ -1608,7 +1583,6 @@ where
/// [`MAX_STATIC_INVOICE_SIZE_BYTES`].
///
/// [`ServeStaticInvoice::invoice`]: crate::onion_message::async_payments::ServeStaticInvoice::invoice
- #[cfg(async_payments)]
pub fn verify_serve_static_invoice_message(
&self, message: &ServeStaticInvoice, context: AsyncPaymentsContext,
) -> Result<(Vec<u8>, u128), ()> {
@@ -1638,7 +1612,6 @@ where
/// to payers on behalf of an often-offline recipient. This method must be called after persisting
/// a [`StaticInvoice`] to confirm to the recipient that their corresponding [`Offer`] is ready to
/// receive async payments.
- #[cfg(async_payments)]
pub fn static_invoice_persisted(&self, responder: Responder) {
let mut pending_async_payments_messages =
self.pending_async_payments_messages.lock().unwrap();
@@ -1651,7 +1624,6 @@ where
/// [`Self::writeable_async_receive_offer_cache`].
///
/// [`StaticInvoicePersisted`]: crate::onion_message::async_payments::StaticInvoicePersisted
- #[cfg(async_payments)]
pub fn handle_static_invoice_persisted(&self, context: AsyncPaymentsContext) -> bool {
let mut cache = self.async_receive_offer_cache.lock().unwrap();
cache.static_invoice_persisted(context)
diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs
index 38c8cd3..553977d 100644
--- a/lightning/src/onion_message/messenger.rs
+++ b/lightning/src/onion_message/messenger.rs
@@ -15,9 +15,7 @@ use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::hashes::{Hash, HashEngine};
use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey};
-#[cfg(async_payments)]
-use super::async_payments::AsyncPaymentsMessage;
-use super::async_payments::AsyncPaymentsMessageHandler;
+use super::async_payments::{AsyncPaymentsMessage, AsyncPaymentsMessageHandler};
use super::dns_resolution::{DNSResolverMessage, DNSResolverMessageHandler};
use super::offers::{OffersMessage, OffersMessageHandler};
use super::packet::OnionMessageContents;
@@ -26,11 +24,9 @@ use super::packet::{
ForwardControlTlvs, Packet, Payload, ReceiveControlTlvs, BIG_PACKET_HOP_DATA_LEN,
SMALL_PACKET_HOP_DATA_LEN,
};
-#[cfg(async_payments)]
-use crate::blinded_path::message::AsyncPaymentsContext;
use crate::blinded_path::message::{
- BlindedMessagePath, DNSResolverContext, ForwardTlvs, MessageContext, MessageForwardNode,
- NextMessageHop, OffersContext, ReceiveTlvs,
+ AsyncPaymentsContext, BlindedMessagePath, DNSResolverContext, ForwardTlvs, MessageContext,
+ MessageForwardNode, NextMessageHop, OffersContext, ReceiveTlvs,
};
use crate::blinded_path::utils;
use crate::blinded_path::{IntroductionNode, NodeIdLookUp};
@@ -440,7 +436,6 @@ impl Responder {
}
/// Converts a [`Responder`] into its inner [`BlindedMessagePath`].
- #[cfg(async_payments)]
pub(crate) fn into_blinded_path(self) -> BlindedMessagePath {
self.reply_path
}
@@ -977,7 +972,6 @@ pub enum PeeledOnion<T: OnionMessageContents> {
/// Received offers onion message, with decrypted contents, context, and reply path
Offers(OffersMessage, Option<OffersContext>, Option<BlindedMessagePath>),
/// Received async payments onion message, with decrypted contents, context, and reply path
- #[cfg(async_payments)]
AsyncPayments(AsyncPaymentsMessage, AsyncPaymentsContext, Option<BlindedMessagePath>),
/// Received DNS resolver onion message, with decrypted contents, context, and reply path
DNSResolver(DNSResolverMessage, Option<DNSResolverContext>, Option<BlindedMessagePath>),
@@ -1181,7 +1175,6 @@ where
(ParsedOnionMessageContents::Offers(msg), None) => {
Ok(PeeledOnion::Offers(msg, None, reply_path))
},
- #[cfg(async_payments)]
(
ParsedOnionMessageContents::AsyncPayments(msg),
Some(MessageContext::AsyncPayments(ctx)),
@@ -1678,15 +1671,12 @@ where
);
}
- #[cfg(async_payments)]
- {
- for (message, instructions) in self.async_payments_handler.release_pending_messages() {
- let _ = self.send_onion_message_internal(
- message,
- instructions,
- format_args!("when sending AsyncPaymentsMessage"),
- );
- }
+ for (message, instructions) in self.async_payments_handler.release_pending_messages() {
+ let _ = self.send_onion_message_internal(
+ message,
+ instructions,
+ format_args!("when sending AsyncPaymentsMessage"),
+ );
}
// Enqueue any initiating `DNSResolverMessage`s to send.
@@ -2098,7 +2088,6 @@ where
let _ = self.handle_onion_message_response(msg, instructions);
}
},
- #[cfg(async_payments)]
Ok(PeeledOnion::AsyncPayments(message, context, reply_path)) => {
log_receive!(message, reply_path.is_some());
let responder = reply_path.map(Responder::new);
diff --git a/lightning/src/onion_message/offers.rs b/lightning/src/onion_message/offers.rs
index c4c7774..06988d4 100644
--- a/lightning/src/onion_message/offers.rs
+++ b/lightning/src/onion_message/offers.rs
@@ -16,7 +16,6 @@ use crate::offers::invoice::Bolt12Invoice;
use crate::offers::invoice_error::InvoiceError;
use crate::offers::invoice_request::InvoiceRequest;
use crate::offers::parse::Bolt12ParseError;
-#[cfg(async_payments)]
use crate::offers::static_invoice::StaticInvoice;
use crate::onion_message::messenger::{MessageSendInstructions, Responder, ResponseInstruction};
use crate::onion_message::packet::OnionMessageContents;
@@ -30,7 +29,7 @@ use crate::prelude::*;
const INVOICE_REQUEST_TLV_TYPE: u64 = 64;
const INVOICE_TLV_TYPE: u64 = 66;
const INVOICE_ERROR_TLV_TYPE: u64 = 68;
-#[cfg(async_payments)]
+// Spec'd in https://github.com/lightning/bolts/pull/1149.
const STATIC_INVOICE_TLV_TYPE: u64 = 70;
/// A handler for an [`OnionMessage`] containing a BOLT 12 Offers message as its payload.
@@ -79,7 +78,6 @@ pub enum OffersMessage {
/// [`Refund`]: crate::offers::refund::Refund
Invoice(Bolt12Invoice),
- #[cfg(async_payments)]
/// A [`StaticInvoice`] sent in response to an [`InvoiceRequest`].
StaticInvoice(StaticInvoice),
@@ -91,9 +89,10 @@ impl OffersMessage {
/// Returns whether `tlv_type` corresponds to a TLV record for Offers.
pub fn is_known_type(tlv_type: u64) -> bool {
match tlv_type {
- INVOICE_REQUEST_TLV_TYPE | INVOICE_TLV_TYPE | INVOICE_ERROR_TLV_TYPE => true,
- #[cfg(async_payments)]
- STATIC_INVOICE_TLV_TYPE => true,
+ INVOICE_REQUEST_TLV_TYPE
+ | INVOICE_TLV_TYPE
+ | INVOICE_ERROR_TLV_TYPE
+ | STATIC_INVOICE_TLV_TYPE => true,
_ => false,
}
}
@@ -102,7 +101,6 @@ impl OffersMessage {
match tlv_type {
INVOICE_REQUEST_TLV_TYPE => Ok(Self::InvoiceRequest(InvoiceRequest::try_from(bytes)?)),
INVOICE_TLV_TYPE => Ok(Self::Invoice(Bolt12Invoice::try_from(bytes)?)),
- #[cfg(async_payments)]
STATIC_INVOICE_TLV_TYPE => Ok(Self::StaticInvoice(StaticInvoice::try_from(bytes)?)),
_ => Err(Bolt12ParseError::Decode(DecodeError::InvalidValue)),
}
@@ -112,7 +110,6 @@ impl OffersMessage {
match &self {
OffersMessage::InvoiceRequest(_) => "Invoice Request",
OffersMessage::Invoice(_) => "Invoice",
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(_) => "Static Invoice",
OffersMessage::InvoiceError(_) => "Invoice Error",
}
@@ -128,7 +125,6 @@ impl fmt::Debug for OffersMessage {
OffersMessage::Invoice(message) => {
write!(f, "{:?}", message.as_tlv_stream())
},
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(message) => {
write!(f, "{:?}", message)
},
@@ -144,7 +140,6 @@ impl OnionMessageContents for OffersMessage {
match self {
OffersMessage::InvoiceRequest(_) => INVOICE_REQUEST_TLV_TYPE,
OffersMessage::Invoice(_) => INVOICE_TLV_TYPE,
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(_) => STATIC_INVOICE_TLV_TYPE,
OffersMessage::InvoiceError(_) => INVOICE_ERROR_TLV_TYPE,
}
@@ -164,7 +159,6 @@ impl Writeable for OffersMessage {
match self {
OffersMessage::InvoiceRequest(message) => message.write(w),
OffersMessage::Invoice(message) => message.write(w),
- #[cfg(async_payments)]
OffersMessage::StaticInvoice(message) => message.write(w),
OffersMessage::InvoiceError(message) => message.write(w),
}
diff --git a/lightning/src/onion_message/packet.rs b/lightning/src/onion_message/packet.rs
index 301473f..ee41ee9 100644
--- a/lightning/src/onion_message/packet.rs
+++ b/lightning/src/onion_message/packet.rs
@@ -12,7 +12,6 @@
use bitcoin::secp256k1::ecdh::SharedSecret;
use bitcoin::secp256k1::PublicKey;
-#[cfg(async_payments)]
use super::async_payments::AsyncPaymentsMessage;
use super::dns_resolution::DNSResolverMessage;
use super::messenger::CustomOnionMessageHandler;
@@ -131,7 +130,6 @@ pub enum ParsedOnionMessageContents<T: OnionMessageContents> {
/// A message related to BOLT 12 Offers.
Offers(OffersMessage),
/// A message related to async payments.
- #[cfg(async_payments)]
AsyncPayments(AsyncPaymentsMessage),
/// A message requesting or providing a DNSSEC proof
DNSResolver(DNSResolverMessage),
@@ -146,7 +144,6 @@ impl<T: OnionMessageContents> OnionMessageContents for ParsedOnionMessageContent
fn tlv_type(&self) -> u64 {
match self {
&ParsedOnionMessageContents::Offers(ref msg) => msg.tlv_type(),
- #[cfg(async_payments)]
&ParsedOnionMessageContents::AsyncPayments(ref msg) => msg.tlv_type(),
&ParsedOnionMessageContents::DNSResolver(ref msg) => msg.tlv_type(),
&ParsedOnionMessageContents::Custom(ref msg) => msg.tlv_type(),
@@ -156,7 +153,6 @@ impl<T: OnionMessageContents> OnionMessageContents for ParsedOnionMessageContent
fn msg_type(&self) -> String {
match self {
ParsedOnionMessageContents::Offers(ref msg) => msg.msg_type(),
- #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(ref msg) => msg.msg_type(),
ParsedOnionMessageContents::DNSResolver(ref msg) => msg.msg_type(),
ParsedOnionMessageContents::Custom(ref msg) => msg.msg_type(),
@@ -166,7 +162,6 @@ impl<T: OnionMessageContents> OnionMessageContents for ParsedOnionMessageContent
fn msg_type(&self) -> &'static str {
match self {
ParsedOnionMessageContents::Offers(ref msg) => msg.msg_type(),
- #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(ref msg) => msg.msg_type(),
ParsedOnionMessageContents::DNSResolver(ref msg) => msg.msg_type(),
ParsedOnionMessageContents::Custom(ref msg) => msg.msg_type(),
@@ -178,7 +173,6 @@ impl<T: OnionMessageContents> Writeable for ParsedOnionMessageContents<T> {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
match self {
ParsedOnionMessageContents::Offers(msg) => msg.write(w),
- #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(msg) => msg.write(w),
ParsedOnionMessageContents::DNSResolver(msg) => msg.write(w),
ParsedOnionMessageContents::Custom(msg) => msg.write(w),
@@ -293,7 +287,6 @@ impl<H: CustomOnionMessageHandler + ?Sized, L: Logger + ?Sized>
message = Some(ParsedOnionMessageContents::Offers(msg));
Ok(true)
},
- #[cfg(async_payments)]
tlv_type if AsyncPaymentsMessage::is_known_type(tlv_type) => {
let msg = AsyncPaymentsMessage::read(msg_reader, tlv_type)?;
message = Some(ParsedOnionMessageContents::AsyncPayments(msg));
diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs
index d56d574..77f2e20 100644
--- a/lightning/src/routing/router.rs
+++ b/lightning/src/routing/router.rs
@@ -23,7 +23,6 @@ use crate::ln::channelmanager::{PaymentId, RecipientOnionFields, MIN_FINAL_CLTV_
use crate::ln::msgs::{DecodeError, MAX_VALUE_MSAT};
use crate::ln::onion_utils;
use crate::offers::invoice::Bolt12Invoice;
-#[cfg(async_payments)]
use crate::offers::static_invoice::StaticInvoice;
use crate::routing::gossip::{
DirectedChannelInfo, EffectiveCapacity, NetworkGraph, NodeId, ReadOnlyNetworkGraph,
@@ -1010,7 +1009,6 @@ impl PaymentParameters {
/// Creates parameters for paying to a blinded payee from the provided invoice. Sets
/// [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and
/// [`PaymentParameters::expiry_time`].
- #[cfg(async_payments)]
#[rustfmt::skip]
pub fn from_static_invoice(invoice: &StaticInvoice) -> Self {
Self::blinded(invoice.payment_paths().to_vec())
Why this scored 24/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.