Skip to content

Commit 6c56443

Browse files
Support decoding invreqs in inbound onion payloads.
1 parent bace469 commit 6c56443

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

@@ -1776,6 +1777,7 @@ mod fuzzy_internal_msgs {
17761777
payment_context: PaymentContext,
17771778
intro_node_blinding_point: Option<PublicKey>,
17781779
keysend_preimage: Option<PaymentPreimage>,
1780+
invoice_request: Option<InvoiceRequest>,
17791781
custom_tlvs: Vec<(u64, Vec<u8>)>,
17801782
}
17811783
}
@@ -2775,6 +2777,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
27752777
let mut payment_metadata: Option<WithoutLength<Vec<u8>>> = None;
27762778
let mut total_msat = None;
27772779
let mut keysend_preimage: Option<PaymentPreimage> = None;
2780+
let mut invoice_request: Option<InvoiceRequest> = None;
27782781
let mut custom_tlvs = Vec::new();
27792782

27802783
let tlv_len = BigSize::read(r)?;
@@ -2788,6 +2791,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
27882791
(12, intro_node_blinding_point, option),
27892792
(16, payment_metadata, option),
27902793
(18, total_msat, (option, encoding: (u64, HighZeroBytesDroppedBigSize))),
2794+
(77_777, invoice_request, option),
27912795
// See https://github.com/lightning/blips/blob/master/blip-0003.md
27922796
(5482373484, keysend_preimage, option)
27932797
}, |msg_type: u64, msg_reader: &mut FixedLengthReader<_>| -> Result<bool, DecodeError> {
@@ -2818,7 +2822,7 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
28182822
short_channel_id, payment_relay, payment_constraints, features, next_blinding_override
28192823
})} => {
28202824
if amt.is_some() || cltv_value.is_some() || total_msat.is_some() ||
2821-
keysend_preimage.is_some()
2825+
keysend_preimage.is_some() || invoice_request.is_some()
28222826
{
28232827
return Err(DecodeError::InvalidValue)
28242828
}
@@ -2844,21 +2848,22 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, NS)> for InboundOnionPayload wh
28442848
payment_context,
28452849
intro_node_blinding_point,
28462850
keysend_preimage,
2851+
invoice_request,
28472852
custom_tlvs,
28482853
})
28492854
},
28502855
}
28512856
} else if let Some(short_channel_id) = short_id {
28522857
if payment_data.is_some() || payment_metadata.is_some() || encrypted_tlvs_opt.is_some() ||
2853-
total_msat.is_some()
2858+
total_msat.is_some() || invoice_request.is_some()
28542859
{ return Err(DecodeError::InvalidValue) }
28552860
Ok(Self::Forward {
28562861
short_channel_id,
28572862
amt_to_forward: amt.ok_or(DecodeError::InvalidValue)?,
28582863
outgoing_cltv_value: cltv_value.ok_or(DecodeError::InvalidValue)?,
28592864
})
28602865
} else {
2861-
if encrypted_tlvs_opt.is_some() || total_msat.is_some() {
2866+
if encrypted_tlvs_opt.is_some() || total_msat.is_some() || invoice_request.is_some() {
28622867
return Err(DecodeError::InvalidValue)
28632868
}
28642869
if let Some(data) = &payment_data {

lightning/src/ln/onion_payment.rs

+1-1
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)