@@ -344,9 +344,6 @@ pub struct PaymentConstraints {
344
344
/// [`PaymentPurpose`]: crate::events::PaymentPurpose
345
345
#[ derive( Clone , Debug , Eq , PartialEq ) ]
346
346
pub enum PaymentContext {
347
- /// The payment context was unknown.
348
- Unknown ( UnknownPaymentContext ) ,
349
-
350
347
/// The payment was made for an invoice requested from a BOLT 12 [`Offer`].
351
348
///
352
349
/// [`Offer`]: crate::offers::offer::Offer
@@ -364,10 +361,6 @@ pub(crate) enum PaymentContextRef<'a> {
364
361
Bolt12Refund ( & ' a Bolt12RefundContext ) ,
365
362
}
366
363
367
- /// An unknown payment context.
368
- #[ derive( Clone , Debug , Eq , PartialEq ) ]
369
- pub struct UnknownPaymentContext ( ( ) ) ;
370
-
371
364
/// The context of a payment made for an invoice requested from a BOLT 12 [`Offer`].
372
365
///
373
366
/// [`Offer`]: crate::offers::offer::Offer
@@ -391,12 +384,6 @@ pub struct Bolt12OfferContext {
391
384
#[ derive( Clone , Debug , Eq , PartialEq ) ]
392
385
pub struct Bolt12RefundContext { }
393
386
394
- impl PaymentContext {
395
- pub ( crate ) fn unknown ( ) -> Self {
396
- PaymentContext :: Unknown ( UnknownPaymentContext ( ( ) ) )
397
- }
398
- }
399
-
400
387
impl TryFrom < CounterpartyForwardingInfo > for PaymentRelay {
401
388
type Error = ( ) ;
402
389
@@ -477,7 +464,7 @@ impl Readable for BlindedPaymentTlvs {
477
464
( 12 , payment_constraints, required) ,
478
465
( 14 , features, ( option, encoding: ( BlindedHopFeatures , WithoutLength ) ) ) ,
479
466
( 65536 , payment_secret, option) ,
480
- ( 65537 , payment_context, ( default_value , PaymentContext :: unknown ( ) ) ) ,
467
+ ( 65537 , payment_context, option ) ,
481
468
( 65539 , authentication, option) ,
482
469
} ) ;
483
470
let _padding: Option < utils:: Padding > = _padding;
@@ -499,7 +486,7 @@ impl Readable for BlindedPaymentTlvs {
499
486
tlvs : UnauthenticatedReceiveTlvs {
500
487
payment_secret : payment_secret. ok_or ( DecodeError :: InvalidValue ) ?,
501
488
payment_constraints : payment_constraints. 0 . unwrap ( ) ,
502
- payment_context : payment_context. 0 . unwrap ( ) ,
489
+ payment_context : payment_context. ok_or ( DecodeError :: InvalidValue ) ? ,
503
490
} ,
504
491
authentication : authentication. ok_or ( DecodeError :: InvalidValue ) ?,
505
492
} ) )
@@ -637,7 +624,7 @@ impl Readable for PaymentConstraints {
637
624
638
625
impl_writeable_tlv_based_enum_legacy ! ( PaymentContext ,
639
626
;
640
- ( 0 , Unknown ) ,
627
+ // 0 for Unknown removed in version 0.1.
641
628
( 1 , Bolt12Offer ) ,
642
629
( 2 , Bolt12Refund ) ,
643
630
) ;
@@ -659,18 +646,6 @@ impl<'a> Writeable for PaymentContextRef<'a> {
659
646
}
660
647
}
661
648
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
-
674
649
impl_writeable_tlv_based ! ( Bolt12OfferContext , {
675
650
( 0 , offer_id, required) ,
676
651
( 2 , invoice_request, required) ,
@@ -681,7 +656,7 @@ impl_writeable_tlv_based!(Bolt12RefundContext, {});
681
656
#[ cfg( test) ]
682
657
mod tests {
683
658
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 } ;
685
660
use crate :: types:: payment:: PaymentSecret ;
686
661
use crate :: types:: features:: BlindedHopFeatures ;
687
662
use crate :: ln:: functional_test_utils:: TEST_FINAL_CLTV ;
@@ -732,7 +707,7 @@ mod tests {
732
707
max_cltv_expiry : 0 ,
733
708
htlc_minimum_msat : 1 ,
734
709
} ,
735
- payment_context : PaymentContext :: unknown ( ) ,
710
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
736
711
} ;
737
712
let htlc_maximum_msat = 100_000 ;
738
713
let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, htlc_maximum_msat, 12 ) . unwrap ( ) ;
@@ -751,7 +726,7 @@ mod tests {
751
726
max_cltv_expiry : 0 ,
752
727
htlc_minimum_msat : 1 ,
753
728
} ,
754
- payment_context : PaymentContext :: unknown ( ) ,
729
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
755
730
} ;
756
731
let blinded_payinfo = super :: compute_payinfo ( & [ ] , & recv_tlvs, 4242 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
757
732
assert_eq ! ( blinded_payinfo. fee_base_msat, 0 ) ;
@@ -807,7 +782,7 @@ mod tests {
807
782
max_cltv_expiry : 0 ,
808
783
htlc_minimum_msat : 3 ,
809
784
} ,
810
- payment_context : PaymentContext :: unknown ( ) ,
785
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
811
786
} ;
812
787
let htlc_maximum_msat = 100_000 ;
813
788
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 {
860
835
max_cltv_expiry : 0 ,
861
836
htlc_minimum_msat : 1 ,
862
837
} ,
863
- payment_context : PaymentContext :: unknown ( ) ,
838
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
864
839
} ;
865
840
let htlc_minimum_msat = 3798 ;
866
841
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 {
917
892
max_cltv_expiry : 0 ,
918
893
htlc_minimum_msat : 1 ,
919
894
} ,
920
- payment_context : PaymentContext :: unknown ( ) ,
895
+ payment_context : PaymentContext :: Bolt12Refund ( Bolt12RefundContext { } ) ,
921
896
} ;
922
897
923
898
let blinded_payinfo = super :: compute_payinfo ( & intermediate_nodes[ ..] , & recv_tlvs, 10_000 , TEST_FINAL_CLTV as u16 ) . unwrap ( ) ;
0 commit comments