This route is pending, ie. locked in HTLCs. * Called either: * - after a sendpay is accepted, * - or after listsendpays reveals some pending route that we didn't * previously know about. */
| 149 | * - or after listsendpays reveals some pending route that we didn't |
| 150 | * previously know about. */ |
| 151 | static void route_pending_register(struct routetracker *routetracker, |
| 152 | struct route *route TAKES) |
| 153 | { |
| 154 | assert(route); |
| 155 | assert(routetracker); |
| 156 | struct payment *payment = route_get_payment_verify(route); |
| 157 | assert(payment); |
| 158 | assert(payment->groupid == route->key.groupid); |
| 159 | |
| 160 | /* we already keep track of this route */ |
| 161 | if (route_map_get(pay_plugin->pending_routes, &route->key)) |
| 162 | plugin_err(pay_plugin->plugin, |
| 163 | "%s: tracking a route (%s) duplicate?", |
| 164 | __func__, |
| 165 | fmt_routekey(tmpctx, &route->key)); |
| 166 | |
| 167 | uncertainty_commit_htlcs(pay_plugin->uncertainty, route); |
| 168 | |
| 169 | if (taken(route)) |
| 170 | tal_steal(pay_plugin->pending_routes, route); |
| 171 | |
| 172 | if (!route_map_add(pay_plugin->pending_routes, route) || |
| 173 | !tal_add_destructor2(route, remove_route, |
| 174 | pay_plugin->pending_routes)) |
| 175 | plugin_err(pay_plugin->plugin, "%s: failed to register route.", |
| 176 | __func__); |
| 177 | |
| 178 | if (!amount_msat_add(&payment->total_sent, payment->total_sent, |
| 179 | route_sends(route)) || |
| 180 | !amount_msat_add(&payment->total_delivering, |
| 181 | payment->total_delivering, |
| 182 | route_delivers(route))) { |
| 183 | plugin_err(pay_plugin->plugin, |
| 184 | "%s: amount_msat arithmetic overflow.", |
| 185 | __func__); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void payment_collect_results(struct payment *payment, |
| 190 | struct preimage **payment_preimage, |
no test coverage detected