What is capacity of peer attached to chan #n? */
| 530 | |
| 531 | /* What is capacity of peer attached to chan #n? */ |
| 532 | static struct amount_msat peer_capacity(const struct gossmap *gossmap, |
| 533 | const struct gossmap_node *me, |
| 534 | const struct gossmap_node *peer, |
| 535 | const struct gossmap_chan *ourchan) |
| 536 | { |
| 537 | struct amount_msat capacity = AMOUNT_MSAT(0); |
| 538 | |
| 539 | for (size_t i = 0; i < peer->num_chans; i++) { |
| 540 | int dir; |
| 541 | struct gossmap_chan *c; |
| 542 | c = gossmap_nth_chan(gossmap, peer, i, &dir); |
| 543 | if (c == ourchan) |
| 544 | continue; |
| 545 | if (!c->half[!dir].enabled) |
| 546 | continue; |
| 547 | if (!amount_msat_add( |
| 548 | &capacity, capacity, |
| 549 | amount_msat(fp16_to_u64(c->half[!dir].htlc_max)))) |
| 550 | continue; |
| 551 | } |
| 552 | return capacity; |
| 553 | } |
| 554 | |
| 555 | static struct command_result *json_listincoming(struct command *cmd, |
| 556 | const char *buffer, |
no test coverage detected