@@ -344,9 +344,6 @@ pub struct PaymentConstraints {
344344/// [`PaymentPurpose`]: crate::events::PaymentPurpose
345345#[ derive( Clone , Debug , Eq , PartialEq ) ]
346346pub enum PaymentContext {
347- /// The payment context was unknown.
348- Unknown ( UnknownPaymentContext ) ,
349-
350347 /// The payment was made for an invoice requested from a BOLT 12 [`Offer`].
351348 ///
352349 /// [`Offer`]: crate::offers::offer::Offer
@@ -364,10 +361,6 @@ pub(crate) enum PaymentContextRef<'a> {
364361 Bolt12Refund ( & ' a Bolt12RefundContext ) ,
365362}
366363
367- /// An unknown payment context.
368- #[ derive( Clone , Debug , Eq , PartialEq ) ]
369- pub struct UnknownPaymentContext ( ( ) ) ;
370-
371364/// The context of a payment made for an invoice requested from a BOLT 12 [`Offer`].
372365///
373366/// [`Offer`]: crate::offers::offer::Offer
@@ -391,12 +384,6 @@ pub struct Bolt12OfferContext {
391384#[ derive( Clone , Debug , Eq , PartialEq ) ]
392385pub struct Bolt12RefundContext { }
393386
394- impl PaymentContext {
395- pub ( crate ) fn unknown ( ) -> Self {
396- PaymentContext :: Unknown ( UnknownPaymentContext ( ( ) ) )
397- }
398- }
399-
400387impl TryFrom < CounterpartyForwardingInfo > for PaymentRelay {
401388 type Error = ( ) ;
402389
@@ -477,7 +464,7 @@ impl Readable for BlindedPaymentTlvs {
477464 ( 12 , payment_constraints, required) ,
478465 ( 14 , features, ( option, encoding: ( BlindedHopFeatures , WithoutLength ) ) ) ,
479466 ( 65536 , payment_secret, option) ,
480- ( 65537 , payment_context, ( default_value , PaymentContext :: unknown ( ) ) ) ,
467+ ( 65537 , payment_context, option ) ,
481468 ( 65539 , authentication, option) ,
482469 } ) ;
483470 let _padding: Option < utils:: Padding > = _padding;
@@ -499,7 +486,7 @@ impl Readable for BlindedPaymentTlvs {
499486 tlvs : UnauthenticatedReceiveTlvs {
500487 payment_secret : payment_secret. ok_or ( DecodeError :: InvalidValue ) ?,
501488 payment_constraints : payment_constraints. 0 . unwrap ( ) ,
502- payment_context : payment_context. 0 . unwrap ( ) ,
489+ payment_context : payment_context. ok_or ( DecodeError :: InvalidValue ) ? ,
503490 } ,
504491 authentication : authentication. ok_or ( DecodeError :: InvalidValue ) ?,
505492 } ) )
@@ -637,7 +624,7 @@ impl Readable for PaymentConstraints {
637624
638625impl_writeable_tlv_based_enum_legacy ! ( PaymentContext ,
639626 ;
640- ( 0 , Unknown ) ,
627+ // 0 for Unknown removed in version 0.1.
641628 ( 1 , Bolt12Offer ) ,
642629 ( 2 , Bolt12Refund ) ,
643630) ;
@@ -659,18 +646,6 @@ impl<'a> Writeable for PaymentContextRef<'a> {
659646 }
660647}
661648
662- impl Writeable for UnknownPaymentContext {
663- fn write < W : Writer > ( & self , _w : & mut W ) -> Result < ( ) , io:: Error > {
664- Ok ( ( ) )
665- }
666- }
667-
668- impl Readable for UnknownPaymentContext {
669- fn read < R : io:: Read > ( _r : & mut R ) -> Result < Self , DecodeError > {
670- Ok ( UnknownPaymentContext ( ( ) ) )
671- }
672- }
673-
674649impl_writeable_tlv_based ! ( Bolt12OfferContext , {
675650 ( 0 , offer_id, required) ,
676651 ( 2 , invoice_request, required) ,
@@ -681,7 +656,7 @@ impl_writeable_tlv_based!(Bolt12RefundContext, {});
681656#[ cfg( test) ]
682657mod tests {
683658 use bitcoin:: secp256k1:: PublicKey ;
684- use crate :: blinded_path:: payment:: { PaymentForwardNode , ForwardTlvs , PaymentConstraints , PaymentContext , PaymentRelay , UnauthenticatedReceiveTlvs } ;
659+ use crate :: blinded_path:: payment:: { Bolt12RefundContext , PaymentForwardNode , ForwardTlvs , PaymentConstraints , PaymentContext , PaymentRelay , UnauthenticatedReceiveTlvs } ;
685660 use crate :: types:: payment:: PaymentSecret ;
686661 use crate :: types:: features:: BlindedHopFeatures ;
687662 use crate :: ln:: functional_test_utils:: TEST_FINAL_CLTV ;
@@ -732,7 +707,7 @@ mod tests {
732707 max_cltv_expiry : 0 ,
733708 htlc_minimum_msat : 1 ,
734709 } ,
735- payment_context : PaymentContext :: unknown ( ) ,
710+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
736711 } ;
737712 let htlc_maximum_msat = 100_000 ;
738713 let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat, 12 ) . unwrap ( ) ;
@@ -751,7 +726,7 @@ mod tests {
751726 max_cltv_expiry : 0 ,
752727 htlc_minimum_msat : 1 ,
753728 } ,
754- payment_context : PaymentContext :: unknown ( ) ,
729+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
755730 } ;
756731 let blinded_payinfo = super :: compute_payinfo ( & [ ] , & recv_tlvs, 4242 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
757732 assert_eq ! ( blinded_payinfo. fee_base_msat, 0 ) ;
@@ -807,7 +782,7 @@ mod tests {
807782 max_cltv_expiry : 0 ,
808783 htlc_minimum_msat : 3 ,
809784 } ,
810- payment_context : PaymentContext :: unknown ( ) ,
785+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
811786 } ;
812787 let htlc_maximum_msat = 100_000 ;
813788 let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat, TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
@@ -860,7 +835,7 @@ mod tests {
860835 max_cltv_expiry : 0 ,
861836 htlc_minimum_msat : 1 ,
862837 } ,
863- payment_context : PaymentContext :: unknown ( ) ,
838+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
864839 } ;
865840 let htlc_minimum_msat = 3798 ;
866841 assert ! ( super :: compute_payinfo( & intermediate_nodes[ ..] , & recv_tlvs, htlc_minimum_msat - 1 , TEST_FINAL_CLTV as u16 ) . is_err( ) ) ;
@@ -917,7 +892,7 @@ mod tests {
917892 max_cltv_expiry : 0 ,
918893 htlc_minimum_msat : 1 ,
919894 } ,
920- payment_context : PaymentContext :: unknown ( ) ,
895+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
921896 } ;
922897
923898 let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, 10_000 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
0 commit comments