//! # use lightning::offers::invoice::BlindedPayInfo;
//! # use lightning::blinded_path::BlindedPath;
//! #
-//! # fn create_payment_paths() -> Vec<(BlindedPath, BlindedPayInfo)> { unimplemented!() }
+//! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() }
//! # fn create_payment_hash() -> PaymentHash { unimplemented!() }
//! #
//! # fn parse_invoice_request(bytes: Vec<u8>) -> Result<(), lightning::offers::parse::ParseError> {
impl<'a> InvoiceBuilder<'a, ExplicitSigningPubkey> {
pub(super) fn for_offer(
- invoice_request: &'a InvoiceRequest, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>,
+ invoice_request: &'a InvoiceRequest, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>,
created_at: Duration, payment_hash: PaymentHash
) -> Result<Self, SemanticError> {
let amount_msats = Self::check_amount_msats(invoice_request)?;
}
pub(super) fn for_refund(
- refund: &'a Refund, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, created_at: Duration,
+ refund: &'a Refund, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, created_at: Duration,
payment_hash: PaymentHash, signing_pubkey: PublicKey
) -> Result<Self, SemanticError> {
let amount_msats = refund.amount_msats();
impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
pub(super) fn for_offer_using_keys(
- invoice_request: &'a InvoiceRequest, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>,
+ invoice_request: &'a InvoiceRequest, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>,
created_at: Duration, payment_hash: PaymentHash, keys: KeyPair
) -> Result<Self, SemanticError> {
let amount_msats = Self::check_amount_msats(invoice_request)?;
}
pub(super) fn for_refund_using_keys(
- refund: &'a Refund, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, created_at: Duration,
+ refund: &'a Refund, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, created_at: Duration,
payment_hash: PaymentHash, keys: KeyPair,
) -> Result<Self, SemanticError> {
let amount_msats = refund.amount_msats();
}
fn fields(
- payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, created_at: Duration,
+ payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, created_at: Duration,
payment_hash: PaymentHash, amount_msats: u64, signing_pubkey: PublicKey
) -> InvoiceFields {
InvoiceFields {
/// Invoice-specific fields for an `invoice` message.
#[derive(Clone, Debug, PartialEq)]
struct InvoiceFields {
- payment_paths: Vec<(BlindedPath, BlindedPayInfo)>,
+ payment_paths: Vec<(BlindedPayInfo, BlindedPath)>,
created_at: Duration,
relative_expiry: Option<Duration>,
payment_hash: PaymentHash,
///
/// Blinded paths provide recipient privacy by obfuscating its node id. Note, however, that this
/// privacy is lost if a public node id is used for [`Invoice::signing_pubkey`].
- pub fn payment_paths(&self) -> &[(BlindedPath, BlindedPayInfo)] {
+ pub fn payment_paths(&self) -> &[(BlindedPayInfo, BlindedPath)] {
&self.contents.fields().payment_paths[..]
}
};
InvoiceTlvStreamRef {
- paths: Some(Iterable(self.payment_paths.iter().map(|(path, _)| path))),
- blindedpay: Some(Iterable(self.payment_paths.iter().map(|(_, payinfo)| payinfo))),
+ paths: Some(Iterable(self.payment_paths.iter().map(|(_, path)| path))),
+ blindedpay: Some(Iterable(self.payment_paths.iter().map(|(payinfo, _)| payinfo))),
created_at: Some(self.created_at.as_secs()),
relative_expiry: self.relative_expiry.map(|duration| duration.as_secs() as u32),
payment_hash: Some(&self.payment_hash),
});
type BlindedPathIter<'a> = core::iter::Map<
- core::slice::Iter<'a, (BlindedPath, BlindedPayInfo)>,
- for<'r> fn(&'r (BlindedPath, BlindedPayInfo)) -> &'r BlindedPath,
+ core::slice::Iter<'a, (BlindedPayInfo, BlindedPath)>,
+ for<'r> fn(&'r (BlindedPayInfo, BlindedPath)) -> &'r BlindedPath,
>;
type BlindedPayInfoIter<'a> = core::iter::Map<
- core::slice::Iter<'a, (BlindedPath, BlindedPayInfo)>,
- for<'r> fn(&'r (BlindedPath, BlindedPayInfo)) -> &'r BlindedPayInfo,
+ core::slice::Iter<'a, (BlindedPayInfo, BlindedPath)>,
+ for<'r> fn(&'r (BlindedPayInfo, BlindedPath)) -> &'r BlindedPayInfo,
>;
/// Information needed to route a payment across a [`BlindedPath`].
},
) = tlv_stream;
- let payment_paths = match (paths, blindedpay) {
- (None, _) => return Err(SemanticError::MissingPaths),
- (_, None) => return Err(SemanticError::InvalidPayInfo),
- (Some(paths), _) if paths.is_empty() => return Err(SemanticError::MissingPaths),
- (Some(paths), Some(blindedpay)) if paths.len() != blindedpay.len() => {
+ let payment_paths = match (blindedpay, paths) {
+ (_, None) => return Err(SemanticError::MissingPaths),
+ (None, _) => return Err(SemanticError::InvalidPayInfo),
+ (_, Some(paths)) if paths.is_empty() => return Err(SemanticError::MissingPaths),
+ (Some(blindedpay), Some(paths)) if paths.len() != blindedpay.len() => {
return Err(SemanticError::InvalidPayInfo);
},
- (Some(paths), Some(blindedpay)) => {
- paths.into_iter().zip(blindedpay.into_iter()).collect::<Vec<_>>()
+ (Some(blindedpay), Some(paths)) => {
+ blindedpay.into_iter().zip(paths.into_iter()).collect::<Vec<_>>()
},
};
payer_note: None,
},
InvoiceTlvStreamRef {
- paths: Some(Iterable(payment_paths.iter().map(|(path, _)| path))),
- blindedpay: Some(Iterable(payment_paths.iter().map(|(_, payinfo)| payinfo))),
+ paths: Some(Iterable(payment_paths.iter().map(|(_, path)| path))),
+ blindedpay: Some(Iterable(payment_paths.iter().map(|(payinfo, _)| payinfo))),
created_at: Some(now.as_secs()),
relative_expiry: None,
payment_hash: Some(&payment_hash),
payer_note: None,
},
InvoiceTlvStreamRef {
- paths: Some(Iterable(payment_paths.iter().map(|(path, _)| path))),
- blindedpay: Some(Iterable(payment_paths.iter().map(|(_, payinfo)| payinfo))),
+ paths: Some(Iterable(payment_paths.iter().map(|(_, path)| path))),
+ blindedpay: Some(Iterable(payment_paths.iter().map(|(payinfo, _)| payinfo))),
created_at: Some(now.as_secs()),
relative_expiry: None,
payment_hash: Some(&payment_hash),
let empty_payment_paths = vec![];
let mut tlv_stream = invoice.as_tlv_stream();
- tlv_stream.3.paths = Some(Iterable(empty_payment_paths.iter().map(|(path, _)| path)));
+ tlv_stream.3.paths = Some(Iterable(empty_payment_paths.iter().map(|(_, path)| path)));
match Invoice::try_from(tlv_stream.to_bytes()) {
Ok(_) => panic!("expected error"),
let mut payment_paths = payment_paths();
payment_paths.pop();
let mut tlv_stream = invoice.as_tlv_stream();
- tlv_stream.3.blindedpay = Some(Iterable(payment_paths.iter().map(|(_, payinfo)| payinfo)));
+ tlv_stream.3.blindedpay = Some(Iterable(payment_paths.iter().map(|(payinfo, _)| payinfo)));
match Invoice::try_from(tlv_stream.to_bytes()) {
Ok(_) => panic!("expected error"),
/// [`Duration`]: core::time::Duration
#[cfg(feature = "std")]
pub fn respond_with(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash
) -> Result<InvoiceBuilder<ExplicitSigningPubkey>, SemanticError> {
let created_at = std::time::SystemTime::now()
.duration_since(std::time::SystemTime::UNIX_EPOCH)
///
/// [`Invoice::created_at`]: crate::offers::invoice::Invoice::created_at
pub fn respond_with_no_std(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash,
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
created_at: core::time::Duration
) -> Result<InvoiceBuilder<ExplicitSigningPubkey>, SemanticError> {
if self.features().requires_unknown_bits() {
/// [`Invoice`]: crate::offers::invoice::Invoice
#[cfg(feature = "std")]
pub fn verify_and_respond_using_derived_keys<T: secp256k1::Signing>(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash,
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
expanded_key: &ExpandedKey, secp_ctx: &Secp256k1<T>
) -> Result<InvoiceBuilder<DerivedSigningPubkey>, SemanticError> {
let created_at = std::time::SystemTime::now()
///
/// [`Invoice`]: crate::offers::invoice::Invoice
pub fn verify_and_respond_using_derived_keys_no_std<T: secp256k1::Signing>(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash,
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
created_at: core::time::Duration, expanded_key: &ExpandedKey, secp_ctx: &Secp256k1<T>
) -> Result<InvoiceBuilder<DerivedSigningPubkey>, SemanticError> {
if self.features().requires_unknown_bits() {
/// [`Duration`]: core::time::Duration
#[cfg(feature = "std")]
pub fn respond_with(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash,
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
signing_pubkey: PublicKey,
) -> Result<InvoiceBuilder<ExplicitSigningPubkey>, SemanticError> {
let created_at = std::time::SystemTime::now()
///
/// [`Invoice::created_at`]: crate::offers::invoice::Invoice::created_at
pub fn respond_with_no_std(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash,
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
signing_pubkey: PublicKey, created_at: Duration
) -> Result<InvoiceBuilder<ExplicitSigningPubkey>, SemanticError> {
if self.features().requires_unknown_bits() {
/// [`Invoice`]: crate::offers::invoice::Invoice
#[cfg(feature = "std")]
pub fn respond_using_derived_keys<ES: Deref>(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash,
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
expanded_key: &ExpandedKey, entropy_source: ES
) -> Result<InvoiceBuilder<DerivedSigningPubkey>, SemanticError>
where
///
/// [`Invoice`]: crate::offers::invoice::Invoice
pub fn respond_using_derived_keys_no_std<ES: Deref>(
- &self, payment_paths: Vec<(BlindedPath, BlindedPayInfo)>, payment_hash: PaymentHash,
+ &self, payment_paths: Vec<(BlindedPayInfo, BlindedPath)>, payment_hash: PaymentHash,
created_at: core::time::Duration, expanded_key: &ExpandedKey, entropy_source: ES
) -> Result<InvoiceBuilder<DerivedSigningPubkey>, SemanticError>
where