X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fonion_message%2Foffers.rs;h=de373bda1bce81b104f1cd616be1ea4fb3e0b756;hb=aeaed62894737b3de18a425cbf7b673764d46e4f;hp=98276d1bfb74d1fb617a3b8c71892a0280d2593b;hpb=f521e4cceb022768a459285e7ab3922f0f59f9d5;p=rust-lightning diff --git a/lightning/src/onion_message/offers.rs b/lightning/src/onion_message/offers.rs index 98276d1b..de373bda 100644 --- a/lightning/src/onion_message/offers.rs +++ b/lightning/src/onion_message/offers.rs @@ -14,8 +14,8 @@ use crate::io::{self, Read}; use crate::ln::msgs::DecodeError; use crate::offers::invoice_error::InvoiceError; use crate::offers::invoice_request::InvoiceRequest; -use crate::offers::invoice::Invoice; -use crate::offers::parse::ParseError; +use crate::offers::invoice::Bolt12Invoice; +use crate::offers::parse::Bolt12ParseError; use crate::util::logger::Logger; use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer}; @@ -30,25 +30,25 @@ const INVOICE_ERROR_TLV_TYPE: u64 = 68; /// /// [`OnionMessage`]: crate::ln::msgs::OnionMessage pub trait OffersMessageHandler { - /// Handles the given message by either responding with an [`Invoice`], sending a payment, or - /// replying with an error. - fn handle_message(&self, message: OffersMessage); + /// Handles the given message by either responding with an [`Bolt12Invoice`], sending a payment, + /// or replying with an error. + fn handle_message(&self, message: OffersMessage) -> Option; } /// Possible BOLT 12 Offers messages sent and received via an [`OnionMessage`]. /// /// [`OnionMessage`]: crate::ln::msgs::OnionMessage -#[derive(Debug)] +#[derive(Clone, Debug)] pub enum OffersMessage { - /// A request for an [`Invoice`] for a particular [`Offer`]. + /// A request for a [`Bolt12Invoice`] for a particular [`Offer`]. /// /// [`Offer`]: crate::offers::offer::Offer InvoiceRequest(InvoiceRequest), - /// An [`Invoice`] sent in response to an [`InvoiceRequest`] or a [`Refund`]. + /// A [`Bolt12Invoice`] sent in response to an [`InvoiceRequest`] or a [`Refund`]. /// /// [`Refund`]: crate::offers::refund::Refund - Invoice(Invoice), + Invoice(Bolt12Invoice), /// An error from handling an [`OffersMessage`]. InvoiceError(InvoiceError), @@ -72,11 +72,11 @@ impl OffersMessage { } } - fn parse(tlv_type: u64, bytes: Vec) -> Result { + fn parse(tlv_type: u64, bytes: Vec) -> Result { match tlv_type { INVOICE_REQUEST_TLV_TYPE => Ok(Self::InvoiceRequest(InvoiceRequest::try_from(bytes)?)), - INVOICE_TLV_TYPE => Ok(Self::Invoice(Invoice::try_from(bytes)?)), - _ => Err(ParseError::Decode(DecodeError::InvalidValue)), + INVOICE_TLV_TYPE => Ok(Self::Invoice(Bolt12Invoice::try_from(bytes)?)), + _ => Err(Bolt12ParseError::Decode(DecodeError::InvalidValue)), } } } @@ -103,12 +103,12 @@ impl ReadableArgs<(u64, &L)> for OffersMessage { match Self::parse(tlv_type, bytes) { Ok(message) => Ok(message), - Err(ParseError::Decode(e)) => Err(e), - Err(ParseError::InvalidSemantics(e)) => { + Err(Bolt12ParseError::Decode(e)) => Err(e), + Err(Bolt12ParseError::InvalidSemantics(e)) => { log_trace!(logger, "Invalid semantics for TLV type {}: {:?}", tlv_type, e); Err(DecodeError::InvalidValue) }, - Err(ParseError::InvalidSignature(e)) => { + Err(Bolt12ParseError::InvalidSignature(e)) => { log_trace!(logger, "Invalid signature for TLV type {}: {:?}", tlv_type, e); Err(DecodeError::InvalidValue) },