Routes are computed and saved in the payment for later use. */
| 130 | |
| 131 | /* Routes are computed and saved in the payment for later use. */ |
| 132 | struct route **get_routes(const tal_t *ctx, |
| 133 | struct payment_info *payment_info, |
| 134 | |
| 135 | const struct node_id *source, |
| 136 | const struct node_id *destination, |
| 137 | struct gossmap *gossmap, |
| 138 | struct uncertainty *uncertainty, |
| 139 | struct disabledmap *disabledmap, |
| 140 | |
| 141 | struct amount_msat amount_to_deliver, |
| 142 | struct amount_msat feebudget, |
| 143 | |
| 144 | u64 *next_partid, |
| 145 | u64 groupid, |
| 146 | bool blinded_destination, |
| 147 | |
| 148 | enum jsonrpc_errcode *ecode, |
| 149 | const char **fail) |
| 150 | { |
| 151 | assert(gossmap); |
| 152 | assert(uncertainty); |
| 153 | |
| 154 | const tal_t *this_ctx = tal(ctx, tal_t); |
| 155 | struct route **routes = tal_arr(ctx, struct route *, 0); |
| 156 | |
| 157 | double probability_budget = payment_info->min_prob_success; |
| 158 | const double base_probability = payment_info->base_prob_success; |
| 159 | double delay_feefactor = payment_info->delay_feefactor; |
| 160 | const double base_fee_penalty = payment_info->base_fee_penalty; |
| 161 | const double prob_cost_factor = payment_info->prob_cost_factor; |
| 162 | const unsigned int maxdelay = payment_info->maxdelay; |
| 163 | bool delay_feefactor_updated = true; |
| 164 | |
| 165 | bitmap *disabled_bitmap = |
| 166 | tal_disabledmap_get_bitmap(this_ctx, disabledmap, gossmap); |
| 167 | |
| 168 | if (!disabled_bitmap) { |
| 169 | tal_report_error(ctx, ecode, fail, PLUGIN_ERROR, |
| 170 | "Failed to build disabled_bitmap."); |
| 171 | goto function_fail; |
| 172 | } |
| 173 | if (amount_msat_is_zero(amount_to_deliver)) { |
| 174 | tal_report_error(ctx, ecode, fail, PLUGIN_ERROR, |
| 175 | "amount to deliver is zero"); |
| 176 | goto function_fail; |
| 177 | } |
| 178 | |
| 179 | /* Also disable every channel that we don't have in the chan_extra_map. |
| 180 | * We might have channels in the gossmap that are not usable for |
| 181 | * probability computations for example if we don't know their capacity. |
| 182 | * We can tell the solver to ignore those channels by disabling them |
| 183 | * here. |
| 184 | */ |
| 185 | for (struct gossmap_chan *chan = gossmap_first_chan(gossmap); chan; |
| 186 | chan = gossmap_next_chan(gossmap, chan)) { |
| 187 | const u32 chan_id = gossmap_chan_idx(gossmap, chan); |
| 188 | struct short_channel_id scid = gossmap_chan_scid(gossmap, chan); |
| 189 | struct chan_extra *ce = |