Skip to content

Serialize blinded Trampoline hops #3007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test blinded Trampoline payload serialization.
  • Loading branch information
arik-so committed Oct 23, 2024
commit f6b3004659ff50e644fbf1e77d1e8f9031e4172e
34 changes: 33 additions & 1 deletion lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3333,7 +3333,7 @@ mod tests {
use crate::ln::types::ChannelId;
use crate::types::payment::{PaymentPreimage, PaymentHash, PaymentSecret};
use crate::types::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
use crate::ln::msgs::{self, FinalOnionHopData, OnionErrorPacket, CommonOpenChannelFields, CommonAcceptChannelFields, TrampolineOnionPacket};
use crate::ln::msgs::{self, FinalOnionHopData, OnionErrorPacket, CommonOpenChannelFields, CommonAcceptChannelFields, OutboundTrampolinePayload, TrampolineOnionPacket};
use crate::ln::msgs::SocketAddress;
use crate::routing::gossip::{NodeAlias, NodeId};
use crate::util::ser::{BigSize, FixedLengthReader, Hostname, LengthReadable, Readable, ReadableArgs, TransactionU16LenLimited, Writeable};
Expand All @@ -3359,6 +3359,8 @@ mod tests {

#[cfg(feature = "std")]
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
use types::features::{BlindedHopFeatures, Bolt12InvoiceFeatures};
use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath};
#[cfg(feature = "std")]
use crate::ln::msgs::SocketAddressParseError;

Expand Down Expand Up @@ -4706,6 +4708,36 @@ mod tests {
assert_eq!(encoded_trampoline_packet, expected_eclair_trampoline_packet);
}

#[test]
fn encoding_outbound_trampoline_payload() {
let mut trampoline_features = Bolt12InvoiceFeatures::empty();
trampoline_features.set_basic_mpp_optional();
let introduction_node = PublicKey::from_slice(&<Vec<u8>>::from_hex("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991").unwrap()).unwrap();
let blinding_point = PublicKey::from_slice(&<Vec<u8>>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()).unwrap();
let trampoline_payload = OutboundTrampolinePayload::LegacyBlindedPathEntry {
amt_to_forward: 150_000_000,
outgoing_cltv_value: 800_000,
payment_paths: vec![
BlindedPaymentPath::from_raw(
introduction_node,
blinding_point,
vec![],
BlindedPayInfo{
fee_base_msat: 500,
fee_proportional_millionths: 1_000,
cltv_expiry_delta: 36,
htlc_minimum_msat: 1,
htlc_maximum_msat: 500_000_000,
features: BlindedHopFeatures::empty(),
}
)
],
invoice_features: Some(trampoline_features),
};
let serialized_payload = trampoline_payload.encode().to_lower_hex_string();
assert_eq!(serialized_payload, "71020408f0d18004030c35001503020000165f032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e66868099102eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f28368661900000001f4000003e800240000000000000001000000001dcd65000000");
}

#[test]
fn query_channel_range_end_blocknum() {
let tests: Vec<(u32, u32, u32)> = vec![
Expand Down