+ loop {
+ if let Some(&(_, ref features)) = first_hop_targets.get(&res.last().unwrap().pubkey) {
+ res.last_mut().unwrap().node_features = NodeFeatures::with_known_relevant_init_flags(&features);
+ } else if let Some(node) = network.nodes.get(&res.last().unwrap().pubkey) {
+ res.last_mut().unwrap().node_features = node.features.clone();
+ } else {
+ // We should be able to fill in features for everything except the last
+ // hop, if the last hop was provided via a BOLT 11 invoice (though we
+ // should be able to extend it further as BOLT 11 does have feature
+ // flags for the last hop node itself).
+ assert!(res.last().unwrap().pubkey == *target);
+ }
+ if res.last().unwrap().pubkey == *target {
+ break;
+ }
+