@@ -31,6 +31,8 @@ use crate::ln::outbound_payment::RecipientOnionFields;
3131use crate :: ln:: types:: ChannelId ;
3232use crate :: offers:: invoice:: Bolt12Invoice ;
3333use crate :: offers:: invoice_request:: InvoiceRequest ;
34+ use crate :: offers:: nonce:: Nonce ;
35+ use crate :: offers:: payer_proof:: { Bolt12InvoiceType , PaidBolt12Invoice } ;
3436use crate :: offers:: static_invoice:: StaticInvoice ;
3537use crate :: onion_message:: messenger:: Responder ;
3638use crate :: routing:: gossip:: NetworkUpdate ;
@@ -1089,17 +1091,13 @@ pub enum Event {
10891091 ///
10901092 /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees
10911093 fee_paid_msat : Option < u64 > ,
1092- /// The BOLT 12 invoice that was paid. `None` if the payment was a non BOLT 12 payment.
1094+ /// The paid BOLT 12 invoice bundled with the data needed to construct a
1095+ /// [`PayerProof`], which selectively discloses invoice fields to prove payment to a
1096+ /// third party.
10931097 ///
1094- /// The BOLT 12 invoice is useful for proof of payment because it contains the
1095- /// payment hash. A third party can verify that the payment was made by
1096- /// showing the invoice and confirming that the payment hash matches
1097- /// the hash of the payment preimage.
1098+ /// `None` for non-BOLT 12 payments.
10981099 ///
1099- /// However, the [`PaidBolt12Invoice`] can also be of type [`StaticInvoice`], which
1100- /// is a special [`Bolt12Invoice`] where proof of payment is not possible.
1101- ///
1102- /// [`StaticInvoice`]: crate::offers::static_invoice::StaticInvoice
1100+ /// [`PayerProof`]: crate::offers::payer_proof::PayerProof
11031101 bolt12_invoice : Option < PaidBolt12Invoice > ,
11041102 } ,
11051103 /// Indicates an outbound payment failed. Individual [`Event::PaymentPathFailed`] events
@@ -1975,13 +1973,16 @@ impl Writeable for Event {
19751973 ref bolt12_invoice,
19761974 } => {
19771975 2u8 . write ( writer) ?;
1976+ let invoice_type = bolt12_invoice. as_ref ( ) . map ( |paid| paid. invoice_type ( ) ) ;
1977+ let payment_nonce = bolt12_invoice. as_ref ( ) . and_then ( |paid| paid. nonce ( ) ) ;
19781978 write_tlv_fields ! ( writer, {
19791979 ( 0 , payment_preimage, required) ,
19801980 ( 1 , payment_hash, required) ,
19811981 ( 3 , payment_id, option) ,
19821982 ( 5 , fee_paid_msat, option) ,
19831983 ( 7 , amount_msat, option) ,
1984- ( 9 , bolt12_invoice, option) ,
1984+ ( 9 , invoice_type, option) ,
1985+ ( 11 , payment_nonce, option) ,
19851986 } ) ;
19861987 } ,
19871988 & Event :: PaymentPathFailed {
@@ -2473,20 +2474,25 @@ impl MaybeReadable for Event {
24732474 let mut payment_id = None ;
24742475 let mut amount_msat = None ;
24752476 let mut fee_paid_msat = None ;
2476- let mut bolt12_invoice = None ;
2477+ let mut invoice_type: Option < Bolt12InvoiceType > = None ;
2478+ let mut payment_nonce: Option < Nonce > = None ;
24772479 read_tlv_fields ! ( reader, {
24782480 ( 0 , payment_preimage, required) ,
24792481 ( 1 , payment_hash, option) ,
24802482 ( 3 , payment_id, option) ,
24812483 ( 5 , fee_paid_msat, option) ,
24822484 ( 7 , amount_msat, option) ,
2483- ( 9 , bolt12_invoice, option) ,
2485+ ( 9 , invoice_type, option) ,
2486+ ( 11 , payment_nonce, option) ,
24842487 } ) ;
24852488 if payment_hash. is_none ( ) {
24862489 payment_hash = Some ( PaymentHash (
24872490 Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . to_byte_array ( ) ,
24882491 ) ) ;
24892492 }
2493+ let bolt12_invoice = invoice_type. map ( |invoice| {
2494+ PaidBolt12Invoice :: new ( invoice, payment_preimage, payment_nonce)
2495+ } ) ;
24902496 Ok ( Some ( Event :: PaymentSent {
24912497 payment_id,
24922498 payment_preimage,
@@ -3146,19 +3152,3 @@ impl<T: EventHandler> EventHandler for Arc<T> {
31463152 self . deref ( ) . handle_event ( event)
31473153 }
31483154}
3149-
3150- /// The BOLT 12 invoice that was paid, surfaced in [`Event::PaymentSent::bolt12_invoice`].
3151- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
3152- pub enum PaidBolt12Invoice {
3153- /// The BOLT 12 invoice specified by the BOLT 12 specification,
3154- /// allowing the user to perform proof of payment.
3155- Bolt12Invoice ( Bolt12Invoice ) ,
3156- /// The Static invoice, used in the async payment specification update proposal,
3157- /// where the user cannot perform proof of payment.
3158- StaticInvoice ( StaticInvoice ) ,
3159- }
3160-
3161- impl_writeable_tlv_based_enum ! ( PaidBolt12Invoice ,
3162- { 0 , Bolt12Invoice } => ( ) ,
3163- { 2 , StaticInvoice } => ( ) ,
3164- ) ;
0 commit comments