Skip to content

Commit 50dfb9f

Browse files
committed
Add trampoline_hops field to Path
1 parent 278cc83 commit 50dfb9f

File tree

13 files changed

+56
-40
lines changed

13 files changed

+56
-40
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ fn send_payment(
565565
maybe_announced_channel: true,
566566
}],
567567
blinded_tail: None,
568+
trampoline_hops: vec![],
568569
}],
569570
route_params: None,
570571
});
@@ -647,6 +648,7 @@ fn send_hop_payment(
647648
},
648649
],
649650
blinded_tail: None,
651+
trampoline_hops: vec![],
650652
}],
651653
route_params: None,
652654
});

lightning-background-processor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ mod tests {
25402540
fee_msat: 0,
25412541
cltv_expiry_delta: MIN_CLTV_EXPIRY_DELTA as u32,
25422542
maybe_announced_channel: true,
2543-
}], blinded_tail: None };
2543+
}], trampoline_hops: vec![], blinded_tail: None };
25442544

25452545
$nodes[0].scorer.write_lock().expect(TestResult::PaymentFailure { path: path.clone(), short_channel_id: scored_scid });
25462546
$nodes[0].node.push_pending_event(Event::PaymentPathFailed {

lightning/src/events/mod.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::types::payment::{PaymentPreimage, PaymentHash, PaymentSecret};
3030
use crate::offers::invoice::Bolt12Invoice;
3131
use crate::onion_message::messenger::Responder;
3232
use crate::routing::gossip::NetworkUpdate;
33-
use crate::routing::router::{BlindedTail, Path, RouteHop, RouteParameters};
33+
use crate::routing::router::{BlindedTail, Path, RouteHop, RouteParameters, TrampolineHop};
3434
use crate::sign::SpendableOutputDescriptor;
3535
use crate::util::errors::APIError;
3636
use crate::util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, RequiredWrapper, UpgradableRequired, WithoutLength};
@@ -1185,12 +1185,12 @@ pub enum Event {
11851185
/// events generated or serialized by versions prior to 0.0.122.
11861186
next_user_channel_id: Option<u128>,
11871187
/// The node id of the previous node.
1188-
///
1188+
///
11891189
/// This is only `None` for HTLCs received prior to 0.1 or for events serialized by
11901190
/// versions prior to 0.1
11911191
prev_node_id: Option<PublicKey>,
11921192
/// The node id of the next node.
1193-
///
1193+
///
11941194
/// This is only `None` for HTLCs received prior to 0.1 or for events serialized by
11951195
/// versions prior to 0.1
11961196
next_node_id: Option<PublicKey>,
@@ -1584,6 +1584,7 @@ impl Writeable for Event {
15841584
(9, None::<RouteParameters>, option), // retry in LDK versions prior to 0.0.115
15851585
(11, payment_id, option),
15861586
(13, failure, required),
1587+
(15, path.trampoline_hops, optional_vec),
15871588
});
15881589
},
15891590
&Event::PendingHTLCsForwardable { time_forwardable: _ } => {
@@ -1670,6 +1671,7 @@ impl Writeable for Event {
16701671
(2, payment_hash, option),
16711672
(4, path.hops, required_vec),
16721673
(6, path.blinded_tail, option),
1674+
(8, path.trampoline_hops, optional_vec),
16731675
})
16741676
},
16751677
&Event::PaymentFailed { ref payment_id, ref payment_hash, ref reason } => {
@@ -1919,6 +1921,7 @@ impl MaybeReadable for Event {
19191921
let mut network_update = None;
19201922
let mut blinded_tail: Option<BlindedTail> = None;
19211923
let mut path: Option<Vec<RouteHop>> = Some(vec![]);
1924+
let mut trampoline_path: Option<Vec<TrampolineHop>> = Some(vec![]);
19221925
let mut short_channel_id = None;
19231926
let mut payment_id = None;
19241927
let mut failure_opt = None;
@@ -1933,14 +1936,15 @@ impl MaybeReadable for Event {
19331936
(7, short_channel_id, option),
19341937
(11, payment_id, option),
19351938
(13, failure_opt, upgradable_option),
1939+
(15, trampoline_path, optional_vec),
19361940
});
19371941
let failure = failure_opt.unwrap_or_else(|| PathFailure::OnPath { network_update });
19381942
Ok(Some(Event::PaymentPathFailed {
19391943
payment_id,
19401944
payment_hash,
19411945
payment_failed_permanently,
19421946
failure,
1943-
path: Path { hops: path.unwrap(), blinded_tail },
1947+
path: Path { hops: path.unwrap(), trampoline_hops: trampoline_path.unwrap_or(vec![]), blinded_tail },
19441948
short_channel_id,
19451949
#[cfg(test)]
19461950
error_code,
@@ -2081,11 +2085,12 @@ impl MaybeReadable for Event {
20812085
(2, payment_hash, option),
20822086
(4, path, required_vec),
20832087
(6, blinded_tail, option),
2088+
(8, trampoline_path, optional_vec),
20842089
});
20852090
Ok(Some(Event::PaymentPathSuccessful {
20862091
payment_id: payment_id.0.unwrap(),
20872092
payment_hash,
2088-
path: Path { hops: path, blinded_tail },
2093+
path: Path { hops: path, trampoline_hops: trampoline_path.unwrap_or(vec![]), blinded_tail },
20892094
}))
20902095
};
20912096
f()
@@ -2165,7 +2170,7 @@ impl MaybeReadable for Event {
21652170
Ok(Some(Event::ProbeSuccessful {
21662171
payment_id: payment_id.0.unwrap(),
21672172
payment_hash: payment_hash.0.unwrap(),
2168-
path: Path { hops: path, blinded_tail },
2173+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
21692174
}))
21702175
};
21712176
f()
@@ -2182,7 +2187,7 @@ impl MaybeReadable for Event {
21822187
Ok(Some(Event::ProbeFailed {
21832188
payment_id: payment_id.0.unwrap(),
21842189
payment_hash: payment_hash.0.unwrap(),
2185-
path: Path { hops: path, blinded_tail },
2190+
path: Path { hops: path, trampoline_hops: vec![], blinded_tail },
21862191
short_channel_id,
21872192
}))
21882193
};

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,7 @@ fn route_blinding_spec_test_vector() {
16071607
cltv_expiry_delta: 42,
16081608
maybe_announced_channel: false,
16091609
}],
1610+
trampoline_hops: vec![],
16101611
blinded_tail: Some(BlindedTail {
16111612
hops: blinded_hops,
16121613
blinding_point: bob_blinding_point,

lightning/src/ln/channel.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10386,7 +10386,7 @@ mod tests {
1038610386
cltv_expiry: 200000000,
1038710387
state: OutboundHTLCState::Committed,
1038810388
source: HTLCSource::OutboundRoute {
10389-
path: Path { hops: Vec::new(), blinded_tail: None },
10389+
path: Path { hops: Vec::new(), trampoline_hops: vec![], blinded_tail: None },
1039010390
session_priv: SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
1039110391
first_hop_htlc_msat: 548,
1039210392
payment_id: PaymentId([42; 32]),
@@ -10762,6 +10762,7 @@ mod tests {
1076210762
node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
1076310763
cltv_expiry_delta: 0, maybe_announced_channel: false,
1076410764
}],
10765+
trampoline_hops: vec![],
1076510766
blinded_tail: None
1076610767
},
1076710768
session_priv: test_utils::privkey(42),

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl HTLCSource {
668668
pub fn dummy() -> Self {
669669
assert!(cfg!(not(feature = "grind_signatures")));
670670
HTLCSource::OutboundRoute {
671-
path: Path { hops: Vec::new(), blinded_tail: None },
671+
path: Path { hops: Vec::new(), trampoline_hops: Vec::new(), blinded_tail: None },
672672
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),
673673
first_hop_htlc_msat: 0,
674674
payment_id: PaymentId([2; 32]),
@@ -12594,7 +12594,7 @@ impl Readable for HTLCSource {
1259412594
// instead.
1259512595
payment_id = Some(PaymentId(*session_priv.0.unwrap().as_ref()));
1259612596
}
12597-
let path = Path { hops: path_hops, blinded_tail };
12597+
let path = Path { hops: path_hops, trampoline_hops: vec![], blinded_tail };
1259812598
if path.hops.len() == 0 {
1259912599
return Err(DecodeError::InvalidValue);
1260012600
}

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ fn fake_network_test() {
10971097
).with_bolt11_features(nodes[1].node.bolt11_invoice_features()).unwrap();
10981098
let route_params = RouteParameters::from_payment_params_and_value(payment_params, 1000000);
10991099
let payment_preimage_1 = send_along_route(&nodes[1],
1100-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: Some(route_params.clone()) },
1100+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: Some(route_params.clone()) },
11011101
&vec!(&nodes[2], &nodes[3], &nodes[1])[..], 1000000).0;
11021102

11031103
let mut hops = Vec::with_capacity(3);
@@ -1131,7 +1131,7 @@ fn fake_network_test() {
11311131
hops[1].fee_msat = chan_2.1.contents.fee_base_msat as u64 + chan_2.1.contents.fee_proportional_millionths as u64 * hops[2].fee_msat as u64 / 1000000;
11321132
hops[0].fee_msat = chan_3.1.contents.fee_base_msat as u64 + chan_3.1.contents.fee_proportional_millionths as u64 * hops[1].fee_msat as u64 / 1000000;
11331133
let payment_hash_2 = send_along_route(&nodes[1],
1134-
Route { paths: vec![Path { hops, blinded_tail: None }], route_params: Some(route_params) },
1134+
Route { paths: vec![Path { hops, trampoline_hops: vec![], blinded_tail: None }], route_params: Some(route_params) },
11351135
&vec!(&nodes[3], &nodes[2], &nodes[1])[..], 1000000).1;
11361136

11371137
// Claim the rebalances...

lightning/src/ln/onion_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ mod tests {
532532
// Ensure the onion will not fit all the payloads by adding a large custom TLV.
533533
recipient_onion.custom_tlvs.push((13377331, vec![0; 1156]));
534534

535-
let path = Path { hops, blinded_tail: None, };
535+
let path = Path { hops, trampoline_hops: vec![], blinded_tail: None, };
536536
let onion_keys = super::onion_utils::construct_onion_keys(&secp_ctx, &path, &session_priv).unwrap();
537537
let (onion_payloads, ..) = super::onion_utils::build_onion_payloads(
538538
&path, total_amt_msat, &recipient_onion, cur_height + 1, &Some(keysend_preimage), None
@@ -558,6 +558,7 @@ mod tests {
558558

559559
let path = Path {
560560
hops: hops,
561+
trampoline_hops: vec![],
561562
blinded_tail: None,
562563
};
563564

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ mod tests {
13421342
channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(),
13431343
short_channel_id: 0, fee_msat: 0, cltv_expiry_delta: 0, maybe_announced_channel: true, // We fill in the payloads manually instead of generating them from RouteHops.
13441344
},
1345-
], blinded_tail: None }],
1345+
], trampoline_hops: vec![], blinded_tail: None }],
13461346
route_params: None,
13471347
};
13481348

lightning/src/ln/outbound_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2553,7 +2553,7 @@ mod tests {
25532553
fee_msat: 0,
25542554
cltv_expiry_delta: 0,
25552555
maybe_announced_channel: true,
2556-
}], blinded_tail: None }],
2556+
}], trampoline_hops: vec![], blinded_tail: None }],
25572557
route_params: Some(route_params.clone()),
25582558
};
25592559
router.expect_find_route(route_params.clone(), Ok(route.clone()));
@@ -2909,6 +2909,7 @@ mod tests {
29092909
maybe_announced_channel: true,
29102910
}
29112911
],
2912+
trampoline_hops: vec![],
29122913
blinded_tail: None,
29132914
}
29142915
],

lightning/src/ln/payment_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ fn auto_retry_partial_failure() {
24412441
fee_msat: amt_msat / 2,
24422442
cltv_expiry_delta: 100,
24432443
maybe_announced_channel: true,
2444-
}], blinded_tail: None },
2444+
}], trampoline_hops: vec![], blinded_tail: None },
24452445
Path { hops: vec![RouteHop {
24462446
pubkey: nodes[1].node.get_our_node_id(),
24472447
node_features: nodes[1].node.node_features(),
@@ -2450,7 +2450,7 @@ fn auto_retry_partial_failure() {
24502450
fee_msat: amt_msat / 2,
24512451
cltv_expiry_delta: 100,
24522452
maybe_announced_channel: true,
2453-
}], blinded_tail: None },
2453+
}], trampoline_hops: vec![], blinded_tail: None },
24542454
],
24552455
route_params: Some(route_params.clone()),
24562456
};
@@ -2472,7 +2472,7 @@ fn auto_retry_partial_failure() {
24722472
fee_msat: amt_msat / 4,
24732473
cltv_expiry_delta: 100,
24742474
maybe_announced_channel: true,
2475-
}], blinded_tail: None },
2475+
}], trampoline_hops: vec![], blinded_tail: None },
24762476
Path { hops: vec![RouteHop {
24772477
pubkey: nodes[1].node.get_our_node_id(),
24782478
node_features: nodes[1].node.node_features(),
@@ -2481,7 +2481,7 @@ fn auto_retry_partial_failure() {
24812481
fee_msat: amt_msat / 4,
24822482
cltv_expiry_delta: 100,
24832483
maybe_announced_channel: true,
2484-
}], blinded_tail: None },
2484+
}], trampoline_hops: vec![], blinded_tail: None },
24852485
],
24862486
route_params: Some(retry_1_params.clone()),
24872487
};
@@ -2503,7 +2503,7 @@ fn auto_retry_partial_failure() {
25032503
fee_msat: amt_msat / 4,
25042504
cltv_expiry_delta: 100,
25052505
maybe_announced_channel: true,
2506-
}], blinded_tail: None },
2506+
}], trampoline_hops: vec![], blinded_tail: None },
25072507
],
25082508
route_params: Some(retry_2_params.clone()),
25092509
};
@@ -2648,7 +2648,7 @@ fn auto_retry_zero_attempts_send_error() {
26482648
fee_msat: amt_msat,
26492649
cltv_expiry_delta: 100,
26502650
maybe_announced_channel: true,
2651-
}], blinded_tail: None },
2651+
}], trampoline_hops: vec![], blinded_tail: None },
26522652
],
26532653
route_params: Some(route_params.clone()),
26542654
};
@@ -2746,7 +2746,7 @@ fn retry_multi_path_single_failed_payment() {
27462746
fee_msat: 10_000,
27472747
cltv_expiry_delta: 100,
27482748
maybe_announced_channel: true,
2749-
}], blinded_tail: None },
2749+
}], trampoline_hops: vec![], blinded_tail: None },
27502750
Path { hops: vec![RouteHop {
27512751
pubkey: nodes[1].node.get_our_node_id(),
27522752
node_features: nodes[1].node.node_features(),
@@ -2755,7 +2755,7 @@ fn retry_multi_path_single_failed_payment() {
27552755
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
27562756
cltv_expiry_delta: 100,
27572757
maybe_announced_channel: true,
2758-
}], blinded_tail: None },
2758+
}], trampoline_hops: vec![], blinded_tail: None },
27592759
],
27602760
route_params: Some(route_params.clone()),
27612761
};
@@ -2837,7 +2837,7 @@ fn immediate_retry_on_failure() {
28372837
fee_msat: 100_000_001, // Our default max-HTLC-value is 10% of the channel value, which this is one more than
28382838
cltv_expiry_delta: 100,
28392839
maybe_announced_channel: true,
2840-
}], blinded_tail: None },
2840+
}], trampoline_hops: vec![], blinded_tail: None },
28412841
],
28422842
route_params: Some(route_params.clone()),
28432843
};
@@ -2931,7 +2931,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29312931
fee_msat: 100_000_000,
29322932
cltv_expiry_delta: 100,
29332933
maybe_announced_channel: true,
2934-
}], blinded_tail: None },
2934+
}], trampoline_hops: vec![], blinded_tail: None },
29352935
Path { hops: vec![RouteHop {
29362936
pubkey: nodes[1].node.get_our_node_id(),
29372937
node_features: nodes[1].node.node_features(),
@@ -2948,7 +2948,7 @@ fn no_extra_retries_on_back_to_back_fail() {
29482948
fee_msat: 100_000_000,
29492949
cltv_expiry_delta: 100,
29502950
maybe_announced_channel: true,
2951-
}], blinded_tail: None }
2951+
}], trampoline_hops: vec![], blinded_tail: None }
29522952
],
29532953
route_params: Some(route_params.clone()),
29542954
};
@@ -3136,7 +3136,7 @@ fn test_simple_partial_retry() {
31363136
fee_msat: 100_000_000,
31373137
cltv_expiry_delta: 100,
31383138
maybe_announced_channel: true,
3139-
}], blinded_tail: None },
3139+
}], trampoline_hops: vec![], blinded_tail: None },
31403140
Path { hops: vec![RouteHop {
31413141
pubkey: nodes[1].node.get_our_node_id(),
31423142
node_features: nodes[1].node.node_features(),
@@ -3153,7 +3153,7 @@ fn test_simple_partial_retry() {
31533153
fee_msat: 100_000_000,
31543154
cltv_expiry_delta: 100,
31553155
maybe_announced_channel: true,
3156-
}], blinded_tail: None }
3156+
}], trampoline_hops: vec![], blinded_tail: None }
31573157
],
31583158
route_params: Some(route_params.clone()),
31593159
};
@@ -3307,7 +3307,7 @@ fn test_threaded_payment_retries() {
33073307
fee_msat: amt_msat / 1000,
33083308
cltv_expiry_delta: 100,
33093309
maybe_announced_channel: true,
3310-
}], blinded_tail: None },
3310+
}], trampoline_hops: vec![], blinded_tail: None },
33113311
Path { hops: vec![RouteHop {
33123312
pubkey: nodes[2].node.get_our_node_id(),
33133313
node_features: nodes[2].node.node_features(),
@@ -3324,7 +3324,7 @@ fn test_threaded_payment_retries() {
33243324
fee_msat: amt_msat - amt_msat / 1000,
33253325
cltv_expiry_delta: 100,
33263326
maybe_announced_channel: true,
3327-
}], blinded_tail: None }
3327+
}], trampoline_hops: vec![], blinded_tail: None }
33283328
],
33293329
route_params: Some(route_params.clone()),
33303330
};

0 commit comments

Comments
 (0)