pass
elif cfg == "splicing":
pass
+ elif cfg == "async_payments":
+ pass
else:
print("Bad cfg tag: " + cfg)
assert False
RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning
+[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
+RUSTFLAGS="--cfg=async_payments" cargo test --verbose --color always -p lightning
},
}
},
+ #[cfg(async_payments)]
OffersMessage::StaticInvoice(_invoice) => {
match responder {
Some(responder) => {
ParsedOnionMessageContents::Offers(offers_message) => match offers_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),
},
+ #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(message) => panic!("Unexpected async payments message: {:?}", message),
ParsedOnionMessageContents::Custom(message) => panic!("Unexpected custom message: {:?}", message),
},
ParsedOnionMessageContents::Offers(offers_message) => match offers_message {
OffersMessage::InvoiceRequest(invoice_request) => panic!("Unexpected invoice_request: {:?}", invoice_request),
OffersMessage::Invoice(invoice) => invoice,
+ #[cfg(async_payments)]
OffersMessage::StaticInvoice(invoice) => panic!("Unexpected static invoice: {:?}", invoice),
OffersMessage::InvoiceError(error) => panic!("Unexpected invoice_error: {:?}", error),
},
+ #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(message) => panic!("Unexpected async payments message: {:?}", message),
ParsedOnionMessageContents::Custom(message) => panic!("Unexpected custom message: {:?}", message),
},
ParsedOnionMessageContents::Offers(offers_message) => match offers_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,
},
+ #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(message) => panic!("Unexpected async payments message: {:?}", message),
ParsedOnionMessageContents::Custom(message) => panic!("Unexpected custom message: {:?}", message),
},
mod payer;
pub mod refund;
pub(crate) mod signer;
-#[allow(unused)]
-pub(crate) mod static_invoice;
+#[cfg(async_payments)]
+pub mod static_invoice;
#[cfg(test)]
pub(crate) mod test_utils;
self.contents.expects_quantity()
}
+ #[cfg(async_payments)]
pub(super) fn verify<T: secp256k1::Signing>(
&self, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
) -> Result<(OfferId, Option<Keypair>), ()> {
use crate::ln::msgs::{self, OnionMessage, OnionMessageHandler, SocketAddress};
use crate::ln::onion_utils;
use crate::routing::gossip::{NetworkGraph, NodeId, ReadOnlyNetworkGraph};
-use super::async_payments::{AsyncPaymentsMessage, AsyncPaymentsMessageHandler};
+use super::async_payments::AsyncPaymentsMessageHandler;
+#[cfg(async_payments)]
+use super::async_payments::AsyncPaymentsMessage;
use super::packet::OnionMessageContents;
use super::packet::ParsedOnionMessageContents;
use super::offers::OffersMessageHandler;
node_id_lookup: NL,
message_router: MR,
offers_handler: OMH,
+ #[allow(unused)]
async_payments_handler: APH,
custom_handler: CMH,
intercept_messages_for_offline_peers: bool,
let response_instructions = self.offers_handler.handle_message(msg, responder);
let _ = self.handle_onion_message_response(response_instructions);
},
+ #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(AsyncPaymentsMessage::HeldHtlcAvailable(msg)) => {
let response_instructions = self.async_payments_handler.held_htlc_available(
msg, responder
);
let _ = self.handle_onion_message_response(response_instructions);
},
+ #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(AsyncPaymentsMessage::ReleaseHeldHtlc(msg)) => {
self.async_payments_handler.release_held_htlc(msg);
},
use crate::offers::invoice_request::InvoiceRequest;
use crate::offers::invoice::Bolt12Invoice;
use crate::offers::parse::Bolt12ParseError;
+#[cfg(async_payments)]
use crate::offers::static_invoice::StaticInvoice;
use crate::onion_message::packet::OnionMessageContents;
use crate::util::logger::Logger;
const INVOICE_REQUEST_TLV_TYPE: u64 = 64;
const INVOICE_TLV_TYPE: u64 = 66;
const INVOICE_ERROR_TLV_TYPE: u64 = 68;
+#[cfg(async_payments)]
const STATIC_INVOICE_TLV_TYPE: u64 = 70;
/// A handler for an [`OnionMessage`] containing a BOLT 12 Offers message as its payload.
/// [`Refund`]: crate::offers::refund::Refund
Invoice(Bolt12Invoice),
- /// A `StaticInvoice` sent in response to an [`InvoiceRequest`].
+ #[cfg(async_payments)]
+ /// A [`StaticInvoice`] sent in response to an [`InvoiceRequest`].
StaticInvoice(StaticInvoice),
/// An error from handling an [`OffersMessage`].
match tlv_type {
INVOICE_REQUEST_TLV_TYPE
| INVOICE_TLV_TYPE
- | STATIC_INVOICE_TLV_TYPE
| INVOICE_ERROR_TLV_TYPE => true,
+ #[cfg(async_payments)]
+ STATIC_INVOICE_TLV_TYPE => true,
_ => false,
}
}
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)),
}
OffersMessage::Invoice(message) => {
write!(f, "{:?}", message.as_tlv_stream())
}
+ #[cfg(async_payments)]
OffersMessage::StaticInvoice(message) => {
write!(f, "{:?}", message)
}
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,
}
match &self {
OffersMessage::InvoiceRequest(_) => "Invoice Request",
OffersMessage::Invoice(_) => "Invoice",
+ #[cfg(async_payments)]
OffersMessage::StaticInvoice(_) => "Static Invoice",
OffersMessage::InvoiceError(_) => "Invoice Error",
}
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),
}
use crate::blinded_path::utils::Padding;
use crate::ln::msgs::DecodeError;
use crate::ln::onion_utils;
+#[cfg(async_payments)]
use super::async_payments::AsyncPaymentsMessage;
use super::messenger::CustomOnionMessageHandler;
use super::offers::OffersMessage;
/// A message related to BOLT 12 Offers.
Offers(OffersMessage),
/// A message related to async payments.
+ #[cfg(async_payments)]
AsyncPayments(AsyncPaymentsMessage),
/// A custom onion message specified by the user.
Custom(T),
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::Custom(ref msg) => msg.tlv_type(),
}
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::Custom(ref msg) => msg.msg_type(),
}
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
match self {
ParsedOnionMessageContents::Offers(msg) => Ok(msg.write(w)?),
+ #[cfg(async_payments)]
ParsedOnionMessageContents::AsyncPayments(msg) => Ok(msg.write(w)?),
ParsedOnionMessageContents::Custom(msg) => Ok(msg.write(w)?),
}
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));