use crate::offers::invoice_macros::{invoice_accessors_common, invoice_builder_methods_common};
#[cfg(test)]
use crate::offers::invoice_macros::invoice_builder_methods_test;
-use crate::offers::invoice_request::{EXPERIMENTAL_INVOICE_REQUEST_TYPES, INVOICE_REQUEST_PAYER_ID_TYPE, INVOICE_REQUEST_TYPES, IV_BYTES as INVOICE_REQUEST_IV_BYTES, InvoiceRequest, InvoiceRequestContents, InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef};
+use crate::offers::invoice_request::{EXPERIMENTAL_INVOICE_REQUEST_TYPES, ExperimentalInvoiceRequestTlvStream, ExperimentalInvoiceRequestTlvStreamRef, INVOICE_REQUEST_PAYER_ID_TYPE, INVOICE_REQUEST_TYPES, IV_BYTES as INVOICE_REQUEST_IV_BYTES, InvoiceRequest, InvoiceRequestContents, InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef};
use crate::offers::merkle::{SignError, SignFn, SignatureTlvStream, SignatureTlvStreamRef, TaggedHash, TlvStream, self, SIGNATURE_TLV_RECORD_SIZE};
use crate::offers::nonce::Nonce;
use crate::offers::offer::{Amount, EXPERIMENTAL_OFFER_TYPES, ExperimentalOfferTlvStream, ExperimentalOfferTlvStreamRef, OFFER_TYPES, OfferTlvStream, OfferTlvStreamRef, Quantity};
const EXPERIMENTAL_TYPES: core::ops::Range<u64> =
EXPERIMENTAL_OFFER_TYPES.start..EXPERIMENTAL_INVOICE_REQUEST_TYPES.end;
- let (_, _, _, invoice_tlv_stream, _) = contents.as_tlv_stream();
+ let (_, _, _, invoice_tlv_stream, _, _) = contents.as_tlv_stream();
// Allocate enough space for the invoice, which will include:
// - all TLV records from `invreq_bytes` except signatures,
pub(crate) fn as_tlv_stream(&self) -> FullInvoiceTlvStreamRef {
let (
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
- experimental_offer_tlv_stream,
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
) = self.contents.as_tlv_stream();
let signature_tlv_stream = SignatureTlvStreamRef {
signature: Some(&self.signature),
(
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
signature_tlv_stream, experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
)
}
}
fn as_tlv_stream(&self) -> PartialInvoiceTlvStreamRef {
- let (payer, offer, invoice_request, experimental_offer) = match self {
+ let (
+ payer, offer, invoice_request, experimental_offer, experimental_invoice_request,
+ ) = match self {
InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.as_tlv_stream(),
InvoiceContents::ForRefund { refund, .. } => refund.as_tlv_stream(),
};
let invoice = self.fields().as_tlv_stream();
- (payer, offer, invoice_request, invoice, experimental_offer)
+ (payer, offer, invoice_request, invoice, experimental_offer, experimental_invoice_request)
}
}
type FullInvoiceTlvStream =(
PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, InvoiceTlvStream, SignatureTlvStream,
- ExperimentalOfferTlvStream,
+ ExperimentalOfferTlvStream, ExperimentalInvoiceRequestTlvStream,
);
type FullInvoiceTlvStreamRef<'a> = (
InvoiceTlvStreamRef<'a>,
SignatureTlvStreamRef<'a>,
ExperimentalOfferTlvStreamRef,
+ ExperimentalInvoiceRequestTlvStreamRef,
);
impl CursorReadable for FullInvoiceTlvStream {
let invoice = CursorReadable::read(r)?;
let signature = CursorReadable::read(r)?;
let experimental_offer = CursorReadable::read(r)?;
+ let experimental_invoice_request = CursorReadable::read(r)?;
- Ok((payer, offer, invoice_request, invoice, signature, experimental_offer))
+ Ok(
+ (
+ payer, offer, invoice_request, invoice, signature, experimental_offer,
+ experimental_invoice_request,
+ )
+ )
}
}
type PartialInvoiceTlvStream = (
PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, InvoiceTlvStream,
- ExperimentalOfferTlvStream,
+ ExperimentalOfferTlvStream, ExperimentalInvoiceRequestTlvStream,
);
type PartialInvoiceTlvStreamRef<'a> = (
InvoiceRequestTlvStreamRef<'a>,
InvoiceTlvStreamRef<'a>,
ExperimentalOfferTlvStreamRef,
+ ExperimentalInvoiceRequestTlvStreamRef,
);
impl CursorReadable for PartialInvoiceTlvStream {
let invoice_request = CursorReadable::read(r)?;
let invoice = CursorReadable::read(r)?;
let experimental_offer = CursorReadable::read(r)?;
+ let experimental_invoice_request = CursorReadable::read(r)?;
- Ok((payer, offer, invoice_request, invoice, experimental_offer))
+ Ok(
+ (
+ payer, offer, invoice_request, invoice, experimental_offer,
+ experimental_invoice_request,
+ )
+ )
}
}
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
SignatureTlvStream { signature },
experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
) = tlv_stream;
let contents = InvoiceContents::try_from(
(
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
- experimental_offer_tlv_stream,
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
)
)?;
features, node_id, message_paths,
},
experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
) = tlv_stream;
if message_paths.is_some() { return Err(Bolt12SemanticError::UnexpectedPaths) }
let refund = RefundContents::try_from(
(
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
- experimental_offer_tlv_stream,
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
)
)?;
Ok(InvoiceContents::ForRefund { refund, fields })
let invoice_request = InvoiceRequestContents::try_from(
(
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
- experimental_offer_tlv_stream,
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
)
)?;
Ok(InvoiceContents::ForOffer { invoice_request, fields })
use crate::ln::features::{Bolt12InvoiceFeatures, InvoiceRequestFeatures, OfferFeatures};
use crate::ln::inbound_payment::ExpandedKey;
use crate::ln::msgs::DecodeError;
- use crate::offers::invoice_request::InvoiceRequestTlvStreamRef;
+ use crate::offers::invoice_request::{ExperimentalInvoiceRequestTlvStreamRef, InvoiceRequestTlvStreamRef};
use crate::offers::merkle::{SignError, SignatureTlvStreamRef, TaggedHash, self};
use crate::offers::nonce::Nonce;
use crate::offers::offer::{Amount, ExperimentalOfferTlvStreamRef, OfferTlvStreamRef, Quantity};
ExperimentalOfferTlvStreamRef {
experimental_foo: None,
},
+ ExperimentalInvoiceRequestTlvStreamRef {},
),
);
ExperimentalOfferTlvStreamRef {
experimental_foo: None,
},
+ ExperimentalInvoiceRequestTlvStreamRef {},
),
);
.relative_expiry(one_hour.as_secs() as u32)
.build().unwrap()
.sign(recipient_sign).unwrap();
- let (_, _, _, tlv_stream, _, _) = invoice.as_tlv_stream();
+ let (_, _, _, tlv_stream, _, _, _) = invoice.as_tlv_stream();
#[cfg(feature = "std")]
assert!(!invoice.is_expired());
assert_eq!(invoice.relative_expiry(), one_hour);
.relative_expiry(one_hour.as_secs() as u32 - 1)
.build().unwrap()
.sign(recipient_sign).unwrap();
- let (_, _, _, tlv_stream, _, _) = invoice.as_tlv_stream();
+ let (_, _, _, tlv_stream, _, _, _) = invoice.as_tlv_stream();
#[cfg(feature = "std")]
assert!(invoice.is_expired());
assert_eq!(invoice.relative_expiry(), one_hour - Duration::from_secs(1));
.respond_with_no_std(payment_paths(), payment_hash(), now()).unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- let (_, _, _, tlv_stream, _, _) = invoice.as_tlv_stream();
+ let (_, _, _, tlv_stream, _, _, _) = invoice.as_tlv_stream();
assert_eq!(invoice.amount_msats(), 1001);
assert_eq!(tlv_stream.amount, Some(1001));
}
.respond_with_no_std(payment_paths(), payment_hash(), now()).unwrap()
.build().unwrap()
.sign(recipient_sign).unwrap();
- let (_, _, _, tlv_stream, _, _) = invoice.as_tlv_stream();
+ let (_, _, _, tlv_stream, _, _, _) = invoice.as_tlv_stream();
assert_eq!(invoice.amount_msats(), 2000);
assert_eq!(tlv_stream.amount, Some(2000));
.fallback_v1_p2tr_tweaked(&tweaked_pubkey)
.build().unwrap()
.sign(recipient_sign).unwrap();
- let (_, _, _, tlv_stream, _, _) = invoice.as_tlv_stream();
+ let (_, _, _, tlv_stream, _, _, _) = invoice.as_tlv_stream();
assert_eq!(
invoice.fallbacks(),
vec![
.allow_mpp()
.build().unwrap()
.sign(recipient_sign).unwrap();
- let (_, _, _, tlv_stream, _, _) = invoice.as_tlv_stream();
+ let (_, _, _, tlv_stream, _, _, _) = invoice.as_tlv_stream();
assert_eq!(invoice.invoice_features(), &features);
assert_eq!(tlv_stream.features, Some(&features));
}
// unknown TLV records, which are not stored in `OfferContents`.
let (
payer_tlv_stream, _offer_tlv_stream, invoice_request_tlv_stream,
- _experimental_offer_tlv_stream,
+ _experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
) = contents.as_tlv_stream();
// Allocate enough space for the invoice_request, which will include:
+ payer_tlv_stream.serialized_length()
+ invoice_request_tlv_stream.serialized_length()
+ SIGNATURE_TLV_RECORD_SIZE
+ + experimental_invoice_request_tlv_stream.serialized_length(),
);
payer_tlv_stream.write(&mut bytes).unwrap();
- experimental_tlv_stream
.peek()
.map_or(remaining_bytes.len(), |first_record| first_record.start)
+ + experimental_invoice_request_tlv_stream.serialized_length(),
);
for record in experimental_tlv_stream {
record.write(&mut experimental_bytes).unwrap();
}
+ experimental_invoice_request_tlv_stream.write(&mut experimental_bytes).unwrap();
debug_assert_eq!(experimental_bytes.len(), experimental_bytes.capacity());
let tlv_stream = TlvStream::new(&bytes).chain(TlvStream::new(&experimental_bytes));
pub(crate) fn as_tlv_stream(&self) -> FullInvoiceRequestTlvStreamRef {
let (
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
- experimental_offer_tlv_stream,
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
) = self.contents.as_tlv_stream();
let signature_tlv_stream = SignatureTlvStreamRef {
signature: Some(&self.signature),
(
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
signature_tlv_stream, experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
)
}
}
}
pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef {
- let (payer, offer, mut invoice_request, experimental_offer) = self.inner.as_tlv_stream();
+ let (payer, offer, mut invoice_request, experimental_offer, experimental_invoice_request) =
+ self.inner.as_tlv_stream();
invoice_request.payer_id = Some(&self.payer_signing_pubkey);
- (payer, offer, invoice_request, experimental_offer)
+ (payer, offer, invoice_request, experimental_offer, experimental_invoice_request)
}
}
paths: None,
};
- (payer, offer, invoice_request, experimental_offer)
+ let experimental_invoice_request = ExperimentalInvoiceRequestTlvStreamRef {};
+
+ (payer, offer, invoice_request, experimental_offer, experimental_invoice_request)
}
}
pub(super) const EXPERIMENTAL_INVOICE_REQUEST_TYPES: core::ops::Range<u64> =
2_000_000_000..3_000_000_000;
+tlv_stream!(
+ ExperimentalInvoiceRequestTlvStream, ExperimentalInvoiceRequestTlvStreamRef,
+ EXPERIMENTAL_INVOICE_REQUEST_TYPES, {}
+);
+
type FullInvoiceRequestTlvStream = (
PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, SignatureTlvStream,
- ExperimentalOfferTlvStream,
+ ExperimentalOfferTlvStream, ExperimentalInvoiceRequestTlvStream,
);
type FullInvoiceRequestTlvStreamRef<'a> = (
InvoiceRequestTlvStreamRef<'a>,
SignatureTlvStreamRef<'a>,
ExperimentalOfferTlvStreamRef,
+ ExperimentalInvoiceRequestTlvStreamRef,
);
impl CursorReadable for FullInvoiceRequestTlvStream {
let invoice_request = CursorReadable::read(r)?;
let signature = CursorReadable::read(r)?;
let experimental_offer = CursorReadable::read(r)?;
+ let experimental_invoice_request = CursorReadable::read(r)?;
- Ok((payer, offer, invoice_request, signature, experimental_offer))
+ Ok(
+ (
+ payer, offer, invoice_request, signature, experimental_offer,
+ experimental_invoice_request,
+ )
+ )
}
}
type PartialInvoiceRequestTlvStream = (
PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, ExperimentalOfferTlvStream,
+ ExperimentalInvoiceRequestTlvStream,
);
type PartialInvoiceRequestTlvStreamRef<'a> = (
OfferTlvStreamRef<'a>,
InvoiceRequestTlvStreamRef<'a>,
ExperimentalOfferTlvStreamRef,
+ ExperimentalInvoiceRequestTlvStreamRef,
);
impl TryFrom<Vec<u8>> for UnsignedInvoiceRequest {
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
SignatureTlvStream { signature },
experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
) = tlv_stream;
let contents = InvoiceRequestContents::try_from(
(
payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream,
- experimental_offer_tlv_stream,
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
)
)?;
chain, amount, features, quantity, payer_id, payer_note, paths,
},
experimental_offer_tlv_stream,
+ ExperimentalInvoiceRequestTlvStream {},
) = tlv_stream;
let payer = match metadata {
#[cfg(test)]
mod tests {
- use super::{INVOICE_REQUEST_TYPES, InvoiceRequest, InvoiceRequestFields, InvoiceRequestTlvStreamRef, PAYER_NOTE_LIMIT, SIGNATURE_TAG, UnsignedInvoiceRequest};
+ use super::{ExperimentalInvoiceRequestTlvStreamRef, INVOICE_REQUEST_TYPES, InvoiceRequest, InvoiceRequestFields, InvoiceRequestTlvStreamRef, PAYER_NOTE_LIMIT, SIGNATURE_TAG, UnsignedInvoiceRequest};
use bitcoin::constants::ChainHash;
use bitcoin::network::Network;
ExperimentalOfferTlvStreamRef {
experimental_foo: None,
},
+ ExperimentalInvoiceRequestTlvStreamRef {},
),
);
let (
payer_tlv_stream, offer_tlv_stream, mut invoice_request_tlv_stream,
mut invoice_tlv_stream, mut signature_tlv_stream, experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
) = invoice.as_tlv_stream();
invoice_request_tlv_stream.amount = Some(2000);
invoice_tlv_stream.amount = Some(2000);
let tlv_stream =
(payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream);
+ let experimental_tlv_stream = (
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
+ );
let mut bytes = Vec::new();
- tlv_stream.write(&mut bytes).unwrap();
- experimental_offer_tlv_stream.write(&mut bytes).unwrap();
+ (&tlv_stream, &experimental_tlv_stream).write(&mut bytes).unwrap();
let message = TaggedHash::from_valid_tlv_stream_bytes(INVOICE_SIGNATURE_TAG, &bytes);
let signature = merkle::sign_message(recipient_sign, &message, recipient_pubkey()).unwrap();
signature_tlv_stream.signature = Some(&signature);
let mut encoded_invoice = Vec::new();
- tlv_stream.write(&mut encoded_invoice).unwrap();
- signature_tlv_stream.write(&mut encoded_invoice).unwrap();
- experimental_offer_tlv_stream.write(&mut encoded_invoice).unwrap();
+ (tlv_stream, signature_tlv_stream, experimental_tlv_stream)
+ .write(&mut encoded_invoice)
+ .unwrap();
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
let (
mut payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream,
mut signature_tlv_stream, experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
) = invoice.as_tlv_stream();
let metadata = payer_tlv_stream.metadata.unwrap().iter().copied().rev().collect();
payer_tlv_stream.metadata = Some(&metadata);
let tlv_stream =
(payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream);
+ let experimental_tlv_stream = (
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
+ );
let mut bytes = Vec::new();
- tlv_stream.write(&mut bytes).unwrap();
- experimental_offer_tlv_stream.write(&mut bytes).unwrap();
+ (&tlv_stream, &experimental_tlv_stream).write(&mut bytes).unwrap();
let message = TaggedHash::from_valid_tlv_stream_bytes(INVOICE_SIGNATURE_TAG, &bytes);
let signature = merkle::sign_message(recipient_sign, &message, recipient_pubkey()).unwrap();
signature_tlv_stream.signature = Some(&signature);
let mut encoded_invoice = Vec::new();
- tlv_stream.write(&mut encoded_invoice).unwrap();
- signature_tlv_stream.write(&mut encoded_invoice).unwrap();
- experimental_offer_tlv_stream.write(&mut encoded_invoice).unwrap();
+ (tlv_stream, signature_tlv_stream, experimental_tlv_stream)
+ .write(&mut encoded_invoice)
+ .unwrap();
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
assert!(invoice.verify_using_metadata(&expanded_key, &secp_ctx).is_err());
let (
payer_tlv_stream, offer_tlv_stream, mut invoice_request_tlv_stream,
mut invoice_tlv_stream, mut signature_tlv_stream, experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
) = invoice.as_tlv_stream();
invoice_request_tlv_stream.amount = Some(2000);
invoice_tlv_stream.amount = Some(2000);
let tlv_stream =
(payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream);
+ let experimental_tlv_stream = (
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
+ );
let mut bytes = Vec::new();
- tlv_stream.write(&mut bytes).unwrap();
- experimental_offer_tlv_stream.write(&mut bytes).unwrap();
+ (&tlv_stream, &experimental_tlv_stream).write(&mut bytes).unwrap();
let message = TaggedHash::from_valid_tlv_stream_bytes(INVOICE_SIGNATURE_TAG, &bytes);
let signature = merkle::sign_message(recipient_sign, &message, recipient_pubkey()).unwrap();
signature_tlv_stream.signature = Some(&signature);
let mut encoded_invoice = Vec::new();
- tlv_stream.write(&mut encoded_invoice).unwrap();
- signature_tlv_stream.write(&mut encoded_invoice).unwrap();
- experimental_offer_tlv_stream.write(&mut encoded_invoice).unwrap();
+ (tlv_stream, signature_tlv_stream, experimental_tlv_stream)
+ .write(&mut encoded_invoice)
+ .unwrap();
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
assert!(
let (
payer_tlv_stream, offer_tlv_stream, mut invoice_request_tlv_stream, invoice_tlv_stream,
mut signature_tlv_stream, experimental_offer_tlv_stream,
+ experimental_invoice_request_tlv_stream,
) = invoice.as_tlv_stream();
let payer_id = pubkey(1);
invoice_request_tlv_stream.payer_id = Some(&payer_id);
let tlv_stream =
(payer_tlv_stream, offer_tlv_stream, invoice_request_tlv_stream, invoice_tlv_stream);
+ let experimental_tlv_stream = (
+ experimental_offer_tlv_stream, experimental_invoice_request_tlv_stream,
+ );
let mut bytes = Vec::new();
- tlv_stream.write(&mut bytes).unwrap();
- experimental_offer_tlv_stream.write(&mut bytes).unwrap();
+ (&tlv_stream, &experimental_tlv_stream).write(&mut bytes).unwrap();
let message = TaggedHash::from_valid_tlv_stream_bytes(INVOICE_SIGNATURE_TAG, &bytes);
let signature = merkle::sign_message(recipient_sign, &message, recipient_pubkey()).unwrap();
signature_tlv_stream.signature = Some(&signature);
let mut encoded_invoice = Vec::new();
- tlv_stream.write(&mut encoded_invoice).unwrap();
- signature_tlv_stream.write(&mut encoded_invoice).unwrap();
- experimental_offer_tlv_stream.write(&mut encoded_invoice).unwrap();
+ (tlv_stream, signature_tlv_stream, experimental_tlv_stream)
+ .write(&mut encoded_invoice)
+ .unwrap();
let invoice = Bolt12Invoice::try_from(encoded_invoice).unwrap();
assert!(
.chain(Network::Bitcoin).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.chain(), mainnet);
assert_eq!(tlv_stream.chain, None);
.chain(Network::Testnet).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.chain(), testnet);
assert_eq!(tlv_stream.chain, Some(&testnet));
.chain(Network::Bitcoin).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.chain(), mainnet);
assert_eq!(tlv_stream.chain, None);
.chain(Network::Testnet).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.chain(), testnet);
assert_eq!(tlv_stream.chain, Some(&testnet));
.amount_msats(1000).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.amount_msats(), Some(1000));
assert_eq!(tlv_stream.amount, Some(1000));
.amount_msats(1000).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.amount_msats(), Some(1000));
assert_eq!(tlv_stream.amount, Some(1000));
.amount_msats(1001).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.amount_msats(), Some(1001));
assert_eq!(tlv_stream.amount, Some(1001));
.features_unchecked(InvoiceRequestFeatures::unknown())
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.invoice_request_features(), &InvoiceRequestFeatures::unknown());
assert_eq!(tlv_stream.features, Some(&InvoiceRequestFeatures::unknown()));
.features_unchecked(InvoiceRequestFeatures::empty())
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.invoice_request_features(), &InvoiceRequestFeatures::empty());
assert_eq!(tlv_stream.features, None);
}
.request_invoice(vec![1; 32], payer_pubkey()).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.quantity(), None);
assert_eq!(tlv_stream.quantity, None);
.quantity(10).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.amount_msats(), Some(10_000));
assert_eq!(tlv_stream.amount, Some(10_000));
.quantity(2).unwrap()
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.amount_msats(), Some(2_000));
assert_eq!(tlv_stream.amount, Some(2_000));
.payer_note("bar".into())
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.payer_note(), Some(PrintableString("bar")));
assert_eq!(tlv_stream.payer_note, Some(&String::from("bar")));
.payer_note("baz".into())
.build().unwrap()
.sign(payer_sign).unwrap();
- let (_, _, tlv_stream, _, _) = invoice_request.as_tlv_stream();
+ let (_, _, tlv_stream, _, _, _) = invoice_request.as_tlv_stream();
assert_eq!(invoice_request.payer_note(), Some(PrintableString("baz")));
assert_eq!(tlv_stream.payer_note, Some(&String::from("baz")));
}
use crate::ln::features::InvoiceRequestFeatures;
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
use crate::ln::msgs::{DecodeError, MAX_VALUE_MSAT};
-use crate::offers::invoice_request::{InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef};
+use crate::offers::invoice_request::{ExperimentalInvoiceRequestTlvStream, ExperimentalInvoiceRequestTlvStreamRef, InvoiceRequestTlvStream, InvoiceRequestTlvStreamRef};
use crate::offers::nonce::Nonce;
use crate::offers::offer::{ExperimentalOfferTlvStream, ExperimentalOfferTlvStreamRef, OfferTlvStream, OfferTlvStreamRef};
use crate::offers::parse::{Bech32Encode, Bolt12ParseError, Bolt12SemanticError, ParsedMessage};
experimental_foo: self.experimental_foo,
};
- (payer, offer, invoice_request, experimental_offer)
+ let experimental_invoice_request = ExperimentalInvoiceRequestTlvStreamRef {};
+
+ (payer, offer, invoice_request, experimental_offer, experimental_invoice_request)
}
}
type RefundTlvStream = (
PayerTlvStream, OfferTlvStream, InvoiceRequestTlvStream, ExperimentalOfferTlvStream,
+ ExperimentalInvoiceRequestTlvStream,
);
type RefundTlvStreamRef<'a> = (
OfferTlvStreamRef<'a>,
InvoiceRequestTlvStreamRef<'a>,
ExperimentalOfferTlvStreamRef,
+ ExperimentalInvoiceRequestTlvStreamRef,
);
impl CursorReadable for RefundTlvStream {
let offer = CursorReadable::read(r)?;
let invoice_request = CursorReadable::read(r)?;
let experimental_offer = CursorReadable::read(r)?;
+ let experimental_invoice_request = CursorReadable::read(r)?;
- Ok((payer, offer, invoice_request, experimental_offer))
+ Ok((payer, offer, invoice_request, experimental_offer, experimental_invoice_request))
}
}
#[cfg(test)]
experimental_foo,
},
+ ExperimentalInvoiceRequestTlvStream {},
) = tlv_stream;
let payer = match payer_metadata {
use crate::ln::features::{InvoiceRequestFeatures, OfferFeatures};
use crate::ln::inbound_payment::ExpandedKey;
use crate::ln::msgs::{DecodeError, MAX_VALUE_MSAT};
- use crate::offers::invoice_request::{INVOICE_REQUEST_TYPES, InvoiceRequestTlvStreamRef};
+ use crate::offers::invoice_request::{ExperimentalInvoiceRequestTlvStreamRef, INVOICE_REQUEST_TYPES, InvoiceRequestTlvStreamRef};
use crate::offers::nonce::Nonce;
use crate::offers::offer::{ExperimentalOfferTlvStreamRef, OfferTlvStreamRef};
use crate::offers::parse::{Bolt12ParseError, Bolt12SemanticError};
ExperimentalOfferTlvStreamRef {
experimental_foo: None,
},
+ ExperimentalInvoiceRequestTlvStreamRef {},
),
);
.absolute_expiry(future_expiry)
.build()
.unwrap();
- let (_, tlv_stream, _, _) = refund.as_tlv_stream();
+ let (_, tlv_stream, _, _, _) = refund.as_tlv_stream();
#[cfg(feature = "std")]
assert!(!refund.is_expired());
assert!(!refund.is_expired_no_std(now));
.absolute_expiry(past_expiry)
.build()
.unwrap();
- let (_, tlv_stream, _, _) = refund.as_tlv_stream();
+ let (_, tlv_stream, _, _, _) = refund.as_tlv_stream();
#[cfg(feature = "std")]
assert!(refund.is_expired());
assert!(refund.is_expired_no_std(now));
.path(paths[1].clone())
.build()
.unwrap();
- let (_, _, invoice_request_tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, invoice_request_tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.payer_signing_pubkey(), pubkey(42));
assert_eq!(refund.paths(), paths.as_slice());
assert_ne!(pubkey(42), pubkey(44));
.issuer("bar".into())
.build()
.unwrap();
- let (_, tlv_stream, _, _) = refund.as_tlv_stream();
+ let (_, tlv_stream, _, _, _) = refund.as_tlv_stream();
assert_eq!(refund.issuer(), Some(PrintableString("bar")));
assert_eq!(tlv_stream.issuer, Some(&String::from("bar")));
.issuer("baz".into())
.build()
.unwrap();
- let (_, tlv_stream, _, _) = refund.as_tlv_stream();
+ let (_, tlv_stream, _, _, _) = refund.as_tlv_stream();
assert_eq!(refund.issuer(), Some(PrintableString("baz")));
assert_eq!(tlv_stream.issuer, Some(&String::from("baz")));
}
let refund = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000).unwrap()
.chain(Network::Bitcoin)
.build().unwrap();
- let (_, _, tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.chain(), mainnet);
assert_eq!(tlv_stream.chain, None);
let refund = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000).unwrap()
.chain(Network::Testnet)
.build().unwrap();
- let (_, _, tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.chain(), testnet);
assert_eq!(tlv_stream.chain, Some(&testnet));
.chain(Network::Regtest)
.chain(Network::Testnet)
.build().unwrap();
- let (_, _, tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.chain(), testnet);
assert_eq!(tlv_stream.chain, Some(&testnet));
}
let refund = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000).unwrap()
.quantity(10)
.build().unwrap();
- let (_, _, tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.quantity(), Some(10));
assert_eq!(tlv_stream.quantity, Some(10));
.quantity(10)
.quantity(1)
.build().unwrap();
- let (_, _, tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.quantity(), Some(1));
assert_eq!(tlv_stream.quantity, Some(1));
}
let refund = RefundBuilder::new(vec![1; 32], payer_pubkey(), 1000).unwrap()
.payer_note("bar".into())
.build().unwrap();
- let (_, _, tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.payer_note(), Some(PrintableString("bar")));
assert_eq!(tlv_stream.payer_note, Some(&String::from("bar")));
.payer_note("bar".into())
.payer_note("baz".into())
.build().unwrap();
- let (_, _, tlv_stream, _) = refund.as_tlv_stream();
+ let (_, _, tlv_stream, _, _) = refund.as_tlv_stream();
assert_eq!(refund.payer_note(), Some(PrintableString("baz")));
assert_eq!(tlv_stream.payer_note, Some(&String::from("baz")));
}
}
}
+impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable> Readable for (A, B, C, D, E, F) {
+ fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let a: A = Readable::read(r)?;
+ let b: B = Readable::read(r)?;
+ let c: C = Readable::read(r)?;
+ let d: D = Readable::read(r)?;
+ let e: E = Readable::read(r)?;
+ let f: F = Readable::read(r)?;
+ Ok((a, b, c, d, e, f))
+ }
+}
+impl<A: Writeable, B: Writeable, C: Writeable, D: Writeable, E: Writeable, F: Writeable> Writeable for (A, B, C, D, E, F) {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
+ self.0.write(w)?;
+ self.1.write(w)?;
+ self.2.write(w)?;
+ self.3.write(w)?;
+ self.4.write(w)?;
+ self.5.write(w)
+ }
+}
+
impl Writeable for () {
fn write<W: Writer>(&self, _: &mut W) -> Result<(), io::Error> {
Ok(())