@@ -315,9 +315,6 @@ pub struct PaymentConstraints {
315
315
/// [`PaymentPurpose`]: crate::events::PaymentPurpose
316
316
#[ derive( Clone , Debug , Eq , PartialEq ) ]
317
317
pub enum PaymentContext {
318
- /// The payment context was unknown.
319
- Unknown ( UnknownPaymentContext ) ,
320
-
321
318
/// The payment was made for an invoice requested from a BOLT 12 [`Offer`].
322
319
///
323
320
/// [`Offer`]: crate::offers::offer::Offer
@@ -335,10 +332,6 @@ pub(crate) enum PaymentContextRef<'a> {
335
332
Bolt12Refund ( & ' a Bolt12RefundContext ) ,
336
333
}
337
334
338
- /// An unknown payment context.
339
- #[ derive( Clone , Debug , Eq , PartialEq ) ]
340
- pub struct UnknownPaymentContext ( ( ) ) ;
341
-
342
335
/// The context of a payment made for an invoice requested from a BOLT 12 [`Offer`].
343
336
///
344
337
/// [`Offer`]: crate::offers::offer::Offer
@@ -362,12 +355,6 @@ pub struct Bolt12OfferContext {
362
355
#[ derive( Clone , Debug , Eq , PartialEq ) ]
363
356
pub struct Bolt12RefundContext { }
364
357
365
- impl PaymentContext {
366
- pub ( crate ) fn unknown ( ) -> Self {
367
- PaymentContext :: Unknown ( UnknownPaymentContext ( ( ) ) )
368
- }
369
- }
370
-
371
358
impl TryFrom < CounterpartyForwardingInfo > for PaymentRelay {
372
359
type Error = ( ) ;
373
360
@@ -437,7 +424,7 @@ impl Readable for BlindedPaymentTlvs {
437
424
( 12 , payment_constraints, required) ,
438
425
( 14 , features, ( option, encoding: ( BlindedHopFeatures , WithoutLength ) ) ) ,
439
426
( 65536 , payment_secret, option) ,
440
- ( 65537 , payment_context, ( default_value , PaymentContext :: unknown ( ) ) ) ,
427
+ ( 65537 , payment_context, option ) ,
441
428
( 65539 , authentication, option) ,
442
429
} ) ;
443
430
let _padding: Option < utils:: Padding > = _padding;
@@ -458,7 +445,7 @@ impl Readable for BlindedPaymentTlvs {
458
445
Ok ( BlindedPaymentTlvs :: Receive ( ReceiveTlvs {
459
446
payment_secret : payment_secret. ok_or ( DecodeError :: InvalidValue ) ?,
460
447
payment_constraints : payment_constraints. 0 . unwrap ( ) ,
461
- payment_context : payment_context. 0 . unwrap ( ) ,
448
+ payment_context : payment_context. ok_or ( DecodeError :: InvalidValue ) ? ,
462
449
authentication,
463
450
} ) )
464
451
}
@@ -595,7 +582,6 @@ impl Readable for PaymentConstraints {
595
582
596
583
impl_writeable_tlv_based_enum_legacy ! ( PaymentContext ,
597
584
;
598
- ( 0 , Unknown ) ,
599
585
( 1 , Bolt12Offer ) ,
600
586
( 2 , Bolt12Refund ) ,
601
587
) ;
@@ -617,18 +603,6 @@ impl<'a> Writeable for PaymentContextRef<'a> {
617
603
}
618
604
}
619
605
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
-
632
606
impl_writeable_tlv_based ! ( Bolt12OfferContext , {
633
607
( 0 , offer_id, required) ,
634
608
( 2 , invoice_request, required) ,
@@ -639,7 +613,7 @@ impl_writeable_tlv_based!(Bolt12RefundContext, {});
639
613
#[ cfg( test) ]
640
614
mod tests {
641
615
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 } ;
643
617
use crate :: types:: payment:: PaymentSecret ;
644
618
use crate :: types:: features:: BlindedHopFeatures ;
645
619
use crate :: ln:: functional_test_utils:: TEST_FINAL_CLTV ;
@@ -690,7 +664,7 @@ mod tests {
690
664
max_cltv_expiry : 0 ,
691
665
htlc_minimum_msat : 1 ,
692
666
} ,
693
- payment_context : PaymentContext :: unknown ( ) ,
667
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
694
668
authentication : None ,
695
669
} ;
696
670
let htlc_maximum_msat = 100_000 ;
@@ -710,7 +684,7 @@ mod tests {
710
684
max_cltv_expiry : 0 ,
711
685
htlc_minimum_msat : 1 ,
712
686
} ,
713
- payment_context : PaymentContext :: unknown ( ) ,
687
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
714
688
authentication : None ,
715
689
} ;
716
690
let blinded_payinfo = super :: compute_payinfo ( & [ ] , & recv_tlvs, 4242 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
@@ -767,7 +741,7 @@ mod tests {
767
741
max_cltv_expiry : 0 ,
768
742
htlc_minimum_msat : 3 ,
769
743
} ,
770
- payment_context : PaymentContext :: unknown ( ) ,
744
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
771
745
authentication : None ,
772
746
} ;
773
747
let htlc_maximum_msat = 100_000 ;
@@ -821,7 +795,7 @@ mod tests {
821
795
max_cltv_expiry : 0 ,
822
796
htlc_minimum_msat : 1 ,
823
797
} ,
824
- payment_context : PaymentContext :: unknown ( ) ,
798
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
825
799
authentication : None ,
826
800
} ;
827
801
let htlc_minimum_msat = 3798 ;
@@ -879,7 +853,7 @@ mod tests {
879
853
max_cltv_expiry : 0 ,
880
854
htlc_minimum_msat : 1 ,
881
855
} ,
882
- payment_context : PaymentContext :: unknown ( ) ,
856
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
883
857
authentication : None ,
884
858
} ;
885
859
0 commit comments