| 337 | } |
| 338 | |
| 339 | static void gossmod_cb(struct gossmap_localmods *mods, |
| 340 | const struct node_id *self, |
| 341 | const struct node_id *peer, |
| 342 | const struct short_channel_id_dir *scidd, |
| 343 | struct amount_msat capacity_msat, |
| 344 | struct amount_msat htlcmin, |
| 345 | struct amount_msat htlcmax, |
| 346 | struct amount_msat spendable, |
| 347 | struct amount_msat max_total_htlc, |
| 348 | struct amount_msat fee_base, |
| 349 | u32 fee_proportional, |
| 350 | u16 cltv_delta, |
| 351 | bool enabled, |
| 352 | const char *buf, |
| 353 | const jsmntok_t *chantok, |
| 354 | struct payment *payment) |
| 355 | { |
| 356 | struct amount_msat min, max; |
| 357 | |
| 358 | if (scidd->dir == node_id_idx(self, peer)) { |
| 359 | /* local channels can send up to what's spendable but there is a |
| 360 | * limit also the total amount in-flight */ |
| 361 | min = AMOUNT_MSAT(0); |
| 362 | max = amount_msat_min(spendable, max_total_htlc); |
| 363 | } else { |
| 364 | /* remote channels can send up no more than spendable */ |
| 365 | min = htlcmin; |
| 366 | max = amount_msat_min(spendable, htlcmax); |
| 367 | } |
| 368 | |
| 369 | /* FIXME: features? */ |
| 370 | gossmap_local_addchan(mods, self, peer, scidd->scid, capacity_msat, |
| 371 | NULL); |
| 372 | gossmap_local_updatechan(mods, scidd, |
| 373 | &enabled, |
| 374 | &min, &max, |
| 375 | &fee_base, &fee_proportional, &cltv_delta); |
| 376 | |
| 377 | /* Is it disabled? */ |
| 378 | if (!enabled) |
| 379 | payment_disable_chan(payment, *scidd, LOG_DBG, |
| 380 | "listpeerchannels says not enabled"); |
| 381 | |
| 382 | /* Also update the uncertainty network by fixing the liquidity of the |
| 383 | * outgoing channel. If we try to set the liquidity of the incoming |
| 384 | * channel as well we would have conflicting information because our |
| 385 | * knowledge model does not take into account channel reserves. */ |
| 386 | if (scidd->dir == node_id_idx(self, peer)) |
| 387 | uncertainty_update_from_listpeerchannels( |
| 388 | pay_plugin->uncertainty, scidd, max, enabled, buf, chantok); |
| 389 | } |
| 390 | |
| 391 | static struct command_result *getmychannels_done(struct command *cmd, |
| 392 | const char *method UNUSED, |
nothing calls this directly
no test coverage detected