use crate::ln::features::OfferFeatures;
use crate::ln::inbound_payment::{ExpandedKey, IV_LEN};
use crate::ln::msgs::{DecodeError, MAX_VALUE_MSAT};
-use crate::offers::merkle::{TaggedHash, TlvStream};
+use crate::offers::merkle::{TaggedHash, TlvRecord, TlvStream};
use crate::offers::nonce::Nonce;
use crate::offers::parse::{Bech32Encode, Bolt12ParseError, Bolt12SemanticError, ParsedMessage};
use crate::offers::signer::{Metadata, MetadataMaterial, self};
}
fn from_valid_invreq_tlv_stream(bytes: &[u8]) -> Self {
- let tlv_stream = TlvStream::new(bytes).range(OFFER_TYPES);
+ let tlv_stream = Offer::tlv_stream_iter(bytes);
let tagged_hash = TaggedHash::from_tlv_stream(Self::ID_TAG, tlv_stream);
Self(tagged_hash.to_bytes())
}
self.contents.expects_quantity()
}
+ pub(super) fn tlv_stream_iter<'a>(
+ bytes: &'a [u8]
+ ) -> impl core::iter::Iterator<Item = TlvRecord<'a>> {
+ TlvStream::new(bytes).range(OFFER_TYPES)
+ }
+
#[cfg(async_payments)]
pub(super) fn verify<T: secp256k1::Signing>(
&self, nonce: Nonce, key: &ExpandedKey, secp_ctx: &Secp256k1<T>
}
pub(crate) fn from_same_offer(&self, invreq: &InvoiceRequest) -> bool {
- let invoice_offer_tlv_stream = TlvStream::new(&self.bytes)
- .range(OFFER_TYPES)
- .map(|tlv_record| tlv_record.record_bytes);
- let invreq_offer_tlv_stream = TlvStream::new(invreq.bytes())
- .range(OFFER_TYPES)
- .map(|tlv_record| tlv_record.record_bytes);
+ let invoice_offer_tlv_stream =
+ Offer::tlv_stream_iter(&self.bytes).map(|tlv_record| tlv_record.record_bytes);
+ let invreq_offer_tlv_stream =
+ Offer::tlv_stream_iter(invreq.bytes()).map(|tlv_record| tlv_record.record_bytes);
invoice_offer_tlv_stream.eq(invreq_offer_tlv_stream)
}
}