@@ -880,11 +880,10 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool>
880880{
881881 /// Sets the payment metadata.
882882 ///
883- /// By default features are set to *optionally* allow the sender to include the payment metadata.
884- /// If you wish to require that the sender include the metadata (and fail to parse the invoice if
885- /// they don't support payment metadata fields), you need to call
886- /// [`InvoiceBuilder::require_payment_metadata`] after this.
887- pub fn payment_metadata (
883+ /// This marks the payment metadata as optional, allowing a legacy sender that doesn't
884+ /// understand payment metadata to ignore it. Note that LDK by default commits to the payment
885+ /// metadata in its payment secret, implicitly making it required.
886+ pub fn optional_payment_metadata (
888887 mut self , payment_metadata : Vec < u8 > ,
889888 ) -> InvoiceBuilder < D , H , T , C , S , tb:: True > {
890889 self . tagged_fields . push ( TaggedField :: PaymentMetadata ( payment_metadata) ) ;
@@ -902,20 +901,23 @@ impl<D: tb::Bool, H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool>
902901 }
903902 self . set_flags ( )
904903 }
905- }
906904
907- impl < D : tb:: Bool , H : tb:: Bool , T : tb:: Bool , C : tb:: Bool , S : tb:: Bool >
908- InvoiceBuilder < D , H , T , C , S , tb:: True >
909- {
910- /// Sets forwarding of payment metadata as required. A reader of the invoice which does not
911- /// support sending payment metadata will fail to read the invoice.
912- pub fn require_payment_metadata ( mut self ) -> InvoiceBuilder < D , H , T , C , S , tb:: True > {
913- for field in self . tagged_fields . iter_mut ( ) {
905+ /// Sets the payment metadata.
906+ ///
907+ /// By default features are set to *require* the sender to include the payment metadata.
908+ /// If you wish to support legacy senders that ignore the metadata, you can call
909+ /// [`InvoiceBuilder::optional_payment_metadata`] instead. Note that LDK by default commits to
910+ /// the payment metadata in its payment secret, implicitly making it required.
911+ pub fn payment_metadata (
912+ self , payment_metadata : Vec < u8 > ,
913+ ) -> InvoiceBuilder < D , H , T , C , S , tb:: True > {
914+ let mut res = self . optional_payment_metadata ( payment_metadata) ;
915+ for field in res. tagged_fields . iter_mut ( ) {
914916 if let TaggedField :: Features ( f) = field {
915917 f. set_payment_metadata_required ( ) ;
916918 }
917919 }
918- self
920+ res
919921 }
920922}
921923
0 commit comments