use std::ops::Deref;
/// A hop in a route
-#[derive(Clone, PartialEq)]
+#[derive(Clone, Debug, PartialEq)]
pub struct RouteHop {
/// The node_id of the node at this hop.
pub pubkey: PublicKey,
}
/// A channel descriptor which provides a last-hop route to get_route
-#[derive(Clone)]
+#[derive(Clone, Debug, PartialEq)]
pub struct RouteHint {
/// The node_id of the non-target end of the route
pub src_node_id: PublicKey,
/// so that we can choose cheaper paths (as per Dijkstra's algorithm).
/// Fee values should be updated only in the context of the whole path, see update_value_and_recompute_fees.
/// These fee values are useful to choose hops as we traverse the graph "payee-to-payer".
-#[derive(Clone)]
+#[derive(Clone, Debug)]
struct PathBuildingHop {
/// Hop-specific details unrelated to the path during the routing phase,
/// but rather relevant to the LN graph.
// Instantiated with a list of hops with correct data in them collected during path finding,
// an instance of this struct should be further modified only via given methods.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
struct PaymentPath {
hops: Vec<PathBuildingHop>,
}
};
let over_path_minimum_msat = amount_to_transfer_over_msat >= $directional_info.htlc_minimum_msat &&
amount_to_transfer_over_msat >= $incl_fee_next_hops_htlc_minimum_msat;
+log_trace!(logger, "{} adding entry {} contributing up to {} (must be at least {}) -> {} ie {} with min {:?} and {} path min", if over_path_minimum_msat { "Adding" } else { "Not adding" },
+ $chan_id, available_value_contribution_msat, minimal_value_contribution_msat, $next_hops_value_contribution, amount_to_transfer_over_msat, $directional_info.htlc_minimum_msat, $incl_fee_next_hops_htlc_minimum_msat);
// If HTLC minimum is larger than the amount we're going to transfer, we shouldn't
// bother considering this channel.
}
}
+log_trace!(logger, "NEW GRAPH NODE! VC: {}", value_contribution_msat);
let new_graph_node = RouteGraphNode {
pubkey: $src_node_id,
lowest_fee_to_peer_through_node: total_fee_msat,
// We "propagate" the fees one hop backward (topologically) here,
// so that fees paid for a HTLC forwarding on the current channel are
// associated with the previous channel (where they will be subtracted).
+log_trace!(logger, "hvc {}", new_entry.hop_use_fee_msat);
ordered_hops.last_mut().unwrap().route_hop.fee_msat = new_entry.hop_use_fee_msat;
ordered_hops.last_mut().unwrap().route_hop.cltv_expiry_delta = new_entry.route_hop.cltv_expiry_delta;
ordered_hops.push(new_entry.clone());
}
+log_trace!(logger, "vc {}", value_contribution_msat);
ordered_hops.last_mut().unwrap().route_hop.fee_msat = value_contribution_msat;
ordered_hops.last_mut().unwrap().hop_use_fee_msat = 0;
ordered_hops.last_mut().unwrap().route_hop.cltv_expiry_delta = final_cltv;
return Err(LightningError{err: "Failed to find a path to the given destination".to_owned(), action: ErrorAction::IgnoreError});
}
+log_trace!(logger, "Potential paths {:?}", payment_paths);
+
if already_collected_value_msat < final_value_msat {
return Err(LightningError{err: "Failed to find a sufficient route to the given destination".to_owned(), action: ErrorAction::IgnoreError});
}