File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -119,9 +119,16 @@ impl SpontaneousPayment {
119119 } ;
120120
121121 let recipient_fields = match custom_tlv {
122- Some ( ( tlv_type, tlv_value) ) => RecipientOnionFields :: spontaneous_empty ( )
123- . with_custom_tlvs ( vec ! [ ( tlv_type, tlv_value) ] )
124- . map_err ( |_| Error :: PaymentSendingFailed ) ?,
122+ Some ( ( tlv_type, tlv_value) ) => {
123+ if tlv_value. len ( ) > 1300 {
124+ // The real limit is lower, but we can't know without the full route.
125+ // This is just an early check to avoid trying a payment that will fail.
126+ return Err ( Error :: PaymentSendingFailed ) ;
127+ }
128+ RecipientOnionFields :: spontaneous_empty ( )
129+ . with_custom_tlvs ( vec ! [ ( tlv_type, tlv_value) ] )
130+ . map_err ( |_| Error :: PaymentSendingFailed ) ?
131+ } ,
125132 None => RecipientOnionFields :: spontaneous_empty ( ) ,
126133 } ;
127134
You can’t perform that action at this time.
0 commit comments