@@ -315,9 +315,6 @@ pub struct PaymentConstraints {
315315/// [`PaymentPurpose`]: crate::events::PaymentPurpose
316316#[ derive( Clone , Debug , Eq , PartialEq ) ]
317317pub enum PaymentContext {
318- /// The payment context was unknown.
319- Unknown ( UnknownPaymentContext ) ,
320-
321318 /// The payment was made for an invoice requested from a BOLT 12 [`Offer`].
322319 ///
323320 /// [`Offer`]: crate::offers::offer::Offer
@@ -335,10 +332,6 @@ pub(crate) enum PaymentContextRef<'a> {
335332 Bolt12Refund ( & ' a Bolt12RefundContext ) ,
336333}
337334
338- /// An unknown payment context.
339- #[ derive( Clone , Debug , Eq , PartialEq ) ]
340- pub struct UnknownPaymentContext ( ( ) ) ;
341-
342335/// The context of a payment made for an invoice requested from a BOLT 12 [`Offer`].
343336///
344337/// [`Offer`]: crate::offers::offer::Offer
@@ -362,12 +355,6 @@ pub struct Bolt12OfferContext {
362355#[ derive( Clone , Debug , Eq , PartialEq ) ]
363356pub struct Bolt12RefundContext { }
364357
365- impl PaymentContext {
366- pub ( crate ) fn unknown ( ) -> Self {
367- PaymentContext :: Unknown ( UnknownPaymentContext ( ( ) ) )
368- }
369- }
370-
371358impl TryFrom < CounterpartyForwardingInfo > for PaymentRelay {
372359 type Error = ( ) ;
373360
@@ -437,7 +424,7 @@ impl Readable for BlindedPaymentTlvs {
437424 ( 12 , payment_constraints, required) ,
438425 ( 14 , features, ( option, encoding: ( BlindedHopFeatures , WithoutLength ) ) ) ,
439426 ( 65536 , payment_secret, option) ,
440- ( 65537 , payment_context, ( default_value , PaymentContext :: unknown ( ) ) ) ,
427+ ( 65537 , payment_context, option ) ,
441428 ( 65539 , authentication, option) ,
442429 } ) ;
443430 let _padding: Option < utils:: Padding > = _padding;
@@ -458,7 +445,7 @@ impl Readable for BlindedPaymentTlvs {
458445 Ok ( BlindedPaymentTlvs :: Receive ( ReceiveTlvs {
459446 payment_secret : payment_secret. ok_or ( DecodeError :: InvalidValue ) ?,
460447 payment_constraints : payment_constraints. 0 . unwrap ( ) ,
461- payment_context : payment_context. 0 . unwrap ( ) ,
448+ payment_context : payment_context. ok_or ( DecodeError :: InvalidValue ) ? ,
462449 authentication,
463450 } ) )
464451 }
@@ -595,7 +582,6 @@ impl Readable for PaymentConstraints {
595582
596583impl_writeable_tlv_based_enum_legacy ! ( PaymentContext ,
597584 ;
598- ( 0 , Unknown ) ,
599585 ( 1 , Bolt12Offer ) ,
600586 ( 2 , Bolt12Refund ) ,
601587) ;
@@ -617,18 +603,6 @@ impl<'a> Writeable for PaymentContextRef<'a> {
617603 }
618604}
619605
620- impl Writeable for UnknownPaymentContext {
621- fn write < W : Writer > ( & self , _w : & mut W ) -> Result < ( ) , io:: Error > {
622- Ok ( ( ) )
623- }
624- }
625-
626- impl Readable for UnknownPaymentContext {
627- fn read < R : io:: Read > ( _r : & mut R ) -> Result < Self , DecodeError > {
628- Ok ( UnknownPaymentContext ( ( ) ) )
629- }
630- }
631-
632606impl_writeable_tlv_based ! ( Bolt12OfferContext , {
633607 ( 0 , offer_id, required) ,
634608 ( 2 , invoice_request, required) ,
@@ -639,7 +613,7 @@ impl_writeable_tlv_based!(Bolt12RefundContext, {});
639613#[ cfg( test) ]
640614mod tests {
641615 use bitcoin:: secp256k1:: PublicKey ;
642- use crate :: blinded_path:: payment:: { PaymentForwardNode , ForwardTlvs , ReceiveTlvs , PaymentConstraints , PaymentContext , PaymentRelay } ;
616+ use crate :: blinded_path:: payment:: { Bolt12RefundContext , PaymentForwardNode , ForwardTlvs , ReceiveTlvs , PaymentConstraints , PaymentContext , PaymentRelay } ;
643617 use crate :: types:: payment:: PaymentSecret ;
644618 use crate :: types:: features:: BlindedHopFeatures ;
645619 use crate :: ln:: functional_test_utils:: TEST_FINAL_CLTV ;
@@ -690,7 +664,7 @@ mod tests {
690664 max_cltv_expiry : 0 ,
691665 htlc_minimum_msat : 1 ,
692666 } ,
693- payment_context : PaymentContext :: unknown ( ) ,
667+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
694668 authentication : None ,
695669 } ;
696670 let htlc_maximum_msat = 100_000 ;
@@ -710,7 +684,7 @@ mod tests {
710684 max_cltv_expiry : 0 ,
711685 htlc_minimum_msat : 1 ,
712686 } ,
713- payment_context : PaymentContext :: unknown ( ) ,
687+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
714688 authentication : None ,
715689 } ;
716690 let blinded_payinfo = super :: compute_payinfo ( & [ ] , & recv_tlvs, 4242 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
@@ -767,7 +741,7 @@ mod tests {
767741 max_cltv_expiry : 0 ,
768742 htlc_minimum_msat : 3 ,
769743 } ,
770- payment_context : PaymentContext :: unknown ( ) ,
744+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
771745 authentication : None ,
772746 } ;
773747 let htlc_maximum_msat = 100_000 ;
@@ -821,7 +795,7 @@ mod tests {
821795 max_cltv_expiry : 0 ,
822796 htlc_minimum_msat : 1 ,
823797 } ,
824- payment_context : PaymentContext :: unknown ( ) ,
798+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
825799 authentication : None ,
826800 } ;
827801 let htlc_minimum_msat = 3798 ;
@@ -879,7 +853,7 @@ mod tests {
879853 max_cltv_expiry : 0 ,
880854 htlc_minimum_msat : 1 ,
881855 } ,
882- payment_context : PaymentContext :: unknown ( ) ,
856+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
883857 authentication : None ,
884858 } ;
885859
0 commit comments