@@ -835,7 +835,7 @@ impl Bolt12Invoice {
835
835
( & refund. payer . 0 , REFUND_IV_BYTES_WITH_METADATA )
836
836
} ,
837
837
} ;
838
- self . contents . verify ( TlvStream :: new ( & self . bytes ) , metadata, key, iv_bytes, secp_ctx)
838
+ self . contents . verify ( & self . bytes , metadata, key, iv_bytes, secp_ctx)
839
839
}
840
840
841
841
/// Verifies that the invoice was for a request or refund created using the given key by
@@ -849,7 +849,8 @@ impl Bolt12Invoice {
849
849
InvoiceContents :: ForOffer { .. } => INVOICE_REQUEST_IV_BYTES ,
850
850
InvoiceContents :: ForRefund { .. } => REFUND_IV_BYTES_WITHOUT_METADATA ,
851
851
} ;
852
- self . contents . verify ( TlvStream :: new ( & self . bytes ) , & metadata, key, iv_bytes, secp_ctx)
852
+ self . contents
853
+ . verify ( & self . bytes , & metadata, key, iv_bytes, secp_ctx)
853
854
. and_then ( |extracted_payment_id| ( payment_id == extracted_payment_id)
854
855
. then ( || payment_id)
855
856
. ok_or ( ( ) )
@@ -1093,11 +1094,11 @@ impl InvoiceContents {
1093
1094
}
1094
1095
1095
1096
fn verify < T : secp256k1:: Signing > (
1096
- & self , tlv_stream : TlvStream < ' _ > , metadata : & Metadata , key : & ExpandedKey ,
1097
- iv_bytes : & [ u8 ; IV_LEN ] , secp_ctx : & Secp256k1 < T >
1097
+ & self , bytes : & [ u8 ] , metadata : & Metadata , key : & ExpandedKey , iv_bytes : & [ u8 ; IV_LEN ] ,
1098
+ secp_ctx : & Secp256k1 < T >
1098
1099
) -> Result < PaymentId , ( ) > {
1099
- let offer_records = tlv_stream . clone ( ) . range ( OFFER_TYPES ) ;
1100
- let invreq_records = tlv_stream . range ( INVOICE_REQUEST_TYPES ) . filter ( |record| {
1100
+ let offer_records = TlvStream :: new ( bytes ) . range ( OFFER_TYPES ) ;
1101
+ let invreq_records = TlvStream :: new ( bytes ) . range ( INVOICE_REQUEST_TYPES ) . filter ( |record| {
1101
1102
match record. r#type {
1102
1103
PAYER_METADATA_TYPE => false , // Should be outside range
1103
1104
INVOICE_REQUEST_PAYER_ID_TYPE => !metadata. derives_payer_keys ( ) ,
0 commit comments