Skip to content

Commit ea208f9

Browse files
committed
Introduce Padding for Blinded Payment Paths
1 parent 05cec0e commit ea208f9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lightning/src/blinded_path/payment.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
1313

1414
use crate::blinded_path::{BlindedHop, BlindedPath, IntroductionNode, NodeIdLookUp};
15-
use crate::blinded_path::utils;
15+
use crate::blinded_path::utils::{self, WithPadding};
1616
use crate::crypto::streams::ChaChaPolyReadAdapter;
1717
use crate::io;
1818
use crate::io::Cursor;
@@ -412,7 +412,6 @@ impl Writeable for ReceiveTlvs {
412412

413413
impl<'a> Writeable for BlindedPaymentTlvsRef<'a> {
414414
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
415-
// TODO: write padding
416415
match self {
417416
Self::Forward(tlvs) => tlvs.write(w)?,
418417
Self::Receive(tlvs) => tlvs.write(w)?,
@@ -467,7 +466,7 @@ pub(super) fn blinded_hops<T: secp256k1::Signing + secp256k1::Verification>(
467466
let tlvs = intermediate_nodes.iter().map(|node| BlindedPaymentTlvsRef::Forward(&node.tlvs))
468467
.chain(core::iter::once(BlindedPaymentTlvsRef::Receive(&payee_tlvs)));
469468

470-
let path = pks.zip(tlvs);
469+
let path = pks.zip(tlvs.map(|tlv| WithPadding { tlvs: tlv }));
471470

472471
utils::construct_blinded_hops(secp_ctx, path, session_priv)
473472
}

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
298298
let mut route_params = get_blinded_route_parameters(amt_msat, payment_secret, 1, 1_0000_0000,
299299
nodes.iter().skip(1).map(|n| n.node.get_our_node_id()).collect(),
300300
&[&chan_upd_1_2, &chan_upd_2_3], &chanmon_cfgs[3].keys_manager);
301-
route_params.payment_params.max_path_length = 18;
301+
route_params.payment_params.max_path_length = 16;
302302

303303
let route = get_route(&nodes[0], &route_params).unwrap();
304304
node_cfgs[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
@@ -822,6 +822,8 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
822822
nodes.iter().skip(1).map(|n| n.node.get_our_node_id()).collect(), &[&chan_upd_1_2],
823823
&chanmon_cfgs[2].keys_manager);
824824

825+
route_params.payment_params.max_path_length = 17;
826+
825827
let route = if check == ReceiveCheckFail::ProcessPendingHTLCsCheck {
826828
let mut route = get_route(&nodes[0], &route_params).unwrap();
827829
// Set the final CLTV expiry too low to trigger the failure in process_pending_htlc_forwards.

0 commit comments

Comments
 (0)