- let payment_secret = match invoice.payment_secret() {
- Some(secret) => {
- let mut payment_secret = PaymentSecret([0; 32]);
- payment_secret.0.copy_from_slice(&secret.0);
- Some(payment_secret)
- }
- None => None,
- };
-
- // rust-lightning-invoice doesn't currently support features, so we parse features
- // manually from the invoice.
- let mut invoice_features = InvoiceFeatures::empty();
- for field in &invoice.into_signed_raw().raw_invoice().data.tagged_fields {
- match field {
- lightning_invoice::RawTaggedField::UnknownSemantics(vec) => {
- if vec[0] == bech32::u5::try_from_u8(5).unwrap() {
- if vec.len() >= 6 && vec[5].to_u8() & 0b10000 != 0 {
- invoice_features =
- invoice_features.set_variable_length_onion_optional();
- }
- if vec.len() >= 6 && vec[5].to_u8() & 0b01000 != 0 {
- invoice_features =
- invoice_features.set_variable_length_onion_required();
- }
- if vec.len() >= 4 && vec[3].to_u8() & 0b00001 != 0 {
- invoice_features =
- invoice_features.set_payment_secret_optional();
- }
- if vec.len() >= 5 && vec[4].to_u8() & 0b10000 != 0 {
- invoice_features =
- invoice_features.set_payment_secret_required();
- }
- if vec.len() >= 4 && vec[3].to_u8() & 0b00100 != 0 {
- invoice_features =
- invoice_features.set_basic_mpp_optional();
- }
- if vec.len() >= 4 && vec[3].to_u8() & 0b00010 != 0 {
- invoice_features =
- invoice_features.set_basic_mpp_required();
- }
- }
- }
- _ => {}
- }
- }
- let invoice_features_opt = match invoice_features == InvoiceFeatures::empty() {
- true => None,
- false => Some(invoice_features),
- };