Skip to content

Commit 903d8f0

Browse files
Support decoding invreqs in inbound onion payloads.
1 parent 7cf9147 commit 903d8f0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lightning/src/ln/msgs.rs

Lines changed: 8 additions & 3 deletions
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

@@ -1790,6 +1791,7 @@ mod fuzzy_internal_msgs {
17901791
payment_context: PaymentContext,
17911792
intro_node_blinding_point: Option<PublicKey>,
17921793
keysend_preimage: Option<PaymentPreimage>,
1794+
invoice_request: Option<InvoiceRequest>,
17931795
custom_tlvs: Vec<(u64, Vec<u8>)>,
17941796
}
17951797
}
@@ -2792,6 +2794,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
27922794
let mut payment_metadata: Option<WithoutLength<Vec<u8>>> = None;
27932795
let mut total_msat = None;
27942796
let mut keysend_preimage: Option<PaymentPreimage> = None;
2797+
let mut invoice_request: Option<InvoiceRequest> = None;
27952798
let mut custom_tlvs = Vec::new();
27962799

27972800
let tlv_len = BigSize::read(r)?;
@@ -2805,6 +2808,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
28052808
(12, intro_node_blinding_point, option),
28062809
(16, payment_metadata, option),
28072810
(18, total_msat, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
2811+
(ONION_INVREQ_TLV_TYPE, invoice_request, option),
28082812
// See https://github.com/lightning/blips/blob/master/blip-0003.md
28092813
(5482373484, keysend_preimage, option)
28102814
}, |msg_type: u64, msg_reader: &mut FixedLengthReader<_>| -> Result<bool, DecodeError> {
@@ -2835,7 +2839,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
28352839
short_channel_id, payment_relay, payment_constraints, features, next_blinding_override
28362840
})} => {
28372841
if amt.is_some() || cltv_value.is_some() || total_msat.is_some() ||
2838-
keysend_preimage.is_some()
2842+
keysend_preimage.is_some() || invoice_request.is_some()
28392843
{
28402844
return Err(DecodeError::InvalidValue)
28412845
}
@@ -2861,21 +2865,22 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
28612865
payment_context,
28622866
intro_node_blinding_point,
28632867
keysend_preimage,
2868+
invoice_request,
28642869
custom_tlvs,
28652870
})
28662871
},
28672872
}
28682873
} else if let Some(short_channel_id) = short_id {
28692874
if payment_data.is_some() || payment_metadata.is_some() || encrypted_tlvs_opt.is_some() ||
2870-
total_msat.is_some()
2875+
total_msat.is_some() || invoice_request.is_some()
28712876
{ return Err(DecodeError::InvalidValue) }
28722877
Ok(Self::Forward {
28732878
short_channel_id,
28742879
amt_to_forward: amt.ok_or(DecodeError::InvalidValue)?,
28752880
outgoing_cltv_value: cltv_value.ok_or(DecodeError::InvalidValue)?,
28762881
})
28772882
} else {
2878-
if encrypted_tlvs_opt.is_some() || total_msat.is_some() {
2883+
if encrypted_tlvs_opt.is_some() || total_msat.is_some() || invoice_request.is_some() {
28792884
return Err(DecodeError::InvalidValue)
28802885
}
28812886
if let Some(data) = &payment_data {

lightning/src/ln/onion_payment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub(super) fn create_recv_pending_htlc_info(
146146
msgs::InboundOnionPayload::BlindedReceive {
147147
sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, payment_secret,
148148
intro_node_blinding_point, payment_constraints, payment_context, keysend_preimage,
149-
custom_tlvs
149+
custom_tlvs, invoice_request: _
150150
} => {
151151
check_blinded_payment_constraints(
152152
sender_intended_htlc_amt_msat, cltv_expiry, &payment_constraints

0 commit comments

Comments
 (0)