Skip to content

Commit

Permalink
f adjust blinded path spec compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Jun 20, 2024
1 parent f5e5c89 commit 4c785b5
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,9 +1677,10 @@ pub struct FinalOnionHopData {

mod fuzzy_internal_msgs {
use bitcoin::secp256k1::PublicKey;
use crate::blinded_path::BlindedPath;
use crate::blinded_path::payment::{PaymentConstraints, PaymentContext, PaymentRelay};
use crate::ln::types::{PaymentPreimage, PaymentSecret};
use crate::ln::features::BlindedHopFeatures;
use crate::ln::features::{BlindedHopFeatures, Bolt12InvoiceFeatures};
use super::{FinalOnionHopData, TrampolineOnionPacket};

#[allow(unused_imports)]
Expand Down Expand Up @@ -1771,19 +1772,13 @@ mod fuzzy_internal_msgs {
},
#[allow(unused)]
BlindedForward {
encrypted_tlvs: Vec<u8>,
intro_node_blinding_point: Option<PublicKey>,
amt_to_forward: u64,
outgoing_cltv_value: u32,
// experimental TLV: 66102
payment_paths: Vec<BlindedPath>,
// experimental TLV: 66097
invoice_features: Option<Bolt12InvoiceFeatures>
},
#[allow(unused)]
BlindedReceive {
sender_intended_htlc_amt_msat: u64,
total_msat: u64,
cltv_expiry_height: u32,
encrypted_tlvs: Vec<u8>,
intro_node_blinding_point: Option<PublicKey>, // Set if the introduction node of the blinded path is the final node
keysend_preimage: Option<PaymentPreimage>,
custom_tlvs: Vec<(u64, Vec<u8>)>,
}
}

pub struct DecodedOnionErrorPacket {
Expand Down Expand Up @@ -2681,30 +2676,14 @@ impl Writeable for OutboundTrampolinePayload {
(14, outgoing_node_id, required)
});
},
Self::BlindedForward { encrypted_tlvs, intro_node_blinding_point } => {
Self::BlindedForward { amt_to_forward, outgoing_cltv_value, payment_paths, invoice_features } => {
_encode_varint_length_prefixed_tlv!(w, {
(10, *encrypted_tlvs, required_vec),
(12, intro_node_blinding_point, option)
(2, HighZeroBytesDroppedBigSize(*amt_to_forward), required),
(4, HighZeroBytesDroppedBigSize(*outgoing_cltv_value), required),
(66097, invoice_features, option),
(66102, *payment_paths, required_vec)
});
},
Self::BlindedReceive {
sender_intended_htlc_amt_msat, total_msat, cltv_expiry_height, encrypted_tlvs,
intro_node_blinding_point, keysend_preimage, ref custom_tlvs,
} => {
// We need to update [`ln::outbound_payment::RecipientOnionFields::with_custom_tlvs`]
// to reject any reserved types in the experimental range if new ones are ever
// standardized.
let keysend_tlv = keysend_preimage.map(|preimage| (5482373484, preimage.encode()));
let mut custom_tlvs: Vec<&(u64, Vec<u8>)> = custom_tlvs.iter().chain(keysend_tlv.iter()).collect();
custom_tlvs.sort_unstable_by_key(|(typ, _)| *typ);
_encode_varint_length_prefixed_tlv!(w, {
(2, HighZeroBytesDroppedBigSize(*sender_intended_htlc_amt_msat), required),
(4, HighZeroBytesDroppedBigSize(*cltv_expiry_height), required),
(10, *encrypted_tlvs, required_vec),
(12, intro_node_blinding_point, option),
(18, HighZeroBytesDroppedBigSize(*total_msat), required)
}, custom_tlvs.iter());
},
}
Ok(())
}
Expand Down

0 comments on commit 4c785b5

Please sign in to comment.