Skip to content

Commit f02d149

Browse files
Support decoding invreqs in inbound onion payloads.
1 parent a46b685 commit f02d149

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lightning/src/ln/msgs.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use crate::blinded_path::payment::{BlindedPaymentTlvs, ForwardTlvs, ReceiveTlvs}
3535
use crate::ln::types::{ChannelId, PaymentPreimage, PaymentHash, PaymentSecret};
3636
use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
3737
use crate::ln::onion_utils;
38+
use crate::offers::invoice_request::InvoiceRequest;
3839
use crate::onion_message;
3940
use crate::sign::{NodeSigner, Recipient};
4041

@@ -1740,6 +1741,7 @@ mod fuzzy_internal_msgs {
17401741
payment_context: PaymentContext,
17411742
intro_node_blinding_point: Option<PublicKey>,
17421743
keysend_preimage: Option<PaymentPreimage>,
1744+
invoice_request: Option<InvoiceRequest>,
17431745
custom_tlvs: Vec<(u64, Vec<u8>)>,
17441746
}
17451747
}
@@ -2724,6 +2726,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, &NS)> for InboundOnionPayload w
27242726
let mut payment_metadata: Option<WithoutLength<Vec<u8>>> = None;
27252727
let mut total_msat = None;
27262728
let mut keysend_preimage: Option<PaymentPreimage> = None;
2729+
let mut invoice_request: Option<InvoiceRequest> = None;
27272730
let mut custom_tlvs = Vec::new();
27282731

27292732
let tlv_len = BigSize::read(r)?;
@@ -2737,6 +2740,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, &NS)> for InboundOnionPayload w
27372740
(12, intro_node_blinding_point, option),
27382741
(16, payment_metadata, option),
27392742
(18, total_msat, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
2743+
(77_777, invoice_request, option),
27402744
// See https://github.com/lightning/blips/blob/master/blip-0003.md
27412745
(5482373484, keysend_preimage, option)
27422746
}, |msg_type: u64, msg_reader: &mut FixedLengthReader<_>| -> Result<bool, DecodeError> {
@@ -2767,7 +2771,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, &NS)> for InboundOnionPayload w
27672771
short_channel_id, payment_relay, payment_constraints, features
27682772
})} => {
27692773
if amt.is_some() || cltv_value.is_some() || total_msat.is_some() ||
2770-
keysend_preimage.is_some()
2774+
keysend_preimage.is_some() || invoice_request.is_some()
27712775
{
27722776
return Err(DecodeError::InvalidValue)
27732777
}
@@ -2792,21 +2796,22 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, &NS)> for InboundOnionPayload w
27922796
payment_context,
27932797
intro_node_blinding_point,
27942798
keysend_preimage,
2799+
invoice_request,
27952800
custom_tlvs,
27962801
})
27972802
},
27982803
}
27992804
} else if let Some(short_channel_id) = short_id {
28002805
if payment_data.is_some() || payment_metadata.is_some() || encrypted_tlvs_opt.is_some() ||
2801-
total_msat.is_some()
2806+
total_msat.is_some() || invoice_request.is_some()
28022807
{ return Err(DecodeError::InvalidValue) }
28032808
Ok(Self::Forward {
28042809
short_channel_id,
28052810
amt_to_forward: amt.ok_or(DecodeError::InvalidValue)?,
28062811
outgoing_cltv_value: cltv_value.ok_or(DecodeError::InvalidValue)?,
28072812
})
28082813
} else {
2809-
if encrypted_tlvs_opt.is_some() || total_msat.is_some() {
2814+
if encrypted_tlvs_opt.is_some() || total_msat.is_some() || invoice_request.is_some() {
28102815
return Err(DecodeError::InvalidValue)
28112816
}
28122817
if let Some(data) = &payment_data {

lightning/src/ln/onion_payment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub(super) fn create_recv_pending_htlc_info(
142142
msgs::InboundOnionPayload::BlindedReceive {
143143
sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, payment_secret,
144144
intro_node_blinding_point, payment_constraints, payment_context, keysend_preimage,
145-
custom_tlvs
145+
custom_tlvs, invoice_request: _
146146
} => {
147147
check_blinded_payment_constraints(
148148
sender_intended_htlc_amt_msat, cltv_expiry, &payment_constraints

0 commit comments

Comments
 (0)