| 553 | } |
| 554 | |
| 555 | static struct command_result *json_listincoming(struct command *cmd, |
| 556 | const char *buffer, |
| 557 | const jsmntok_t *params) |
| 558 | { |
| 559 | struct json_stream *js; |
| 560 | struct gossmap_node *me; |
| 561 | struct gossmap *gossmap; |
| 562 | |
| 563 | if (!param(cmd, buffer, params, NULL)) |
| 564 | return command_param_failed(); |
| 565 | |
| 566 | gossmap = get_gossmap(); |
| 567 | |
| 568 | js = jsonrpc_stream_success(cmd); |
| 569 | json_array_start(js, "incoming"); |
| 570 | me = gossmap_find_node(gossmap, &local_id); |
| 571 | if (!me) |
| 572 | goto done; |
| 573 | |
| 574 | for (size_t i = 0; i < me->num_chans; i++) { |
| 575 | struct node_id peer_id; |
| 576 | int dir; |
| 577 | struct gossmap_chan *ourchan; |
| 578 | struct gossmap_node *peer; |
| 579 | struct short_channel_id scid; |
| 580 | |
| 581 | ourchan = gossmap_nth_chan(gossmap, me, i, &dir); |
| 582 | /* If its half is disabled, ignore. */ |
| 583 | if (!ourchan->half[!dir].enabled) |
| 584 | continue; |
| 585 | |
| 586 | peer = gossmap_nth_node(gossmap, ourchan, !dir); |
| 587 | scid = gossmap_chan_scid(gossmap, ourchan); |
| 588 | |
| 589 | json_object_start(js, NULL); |
| 590 | gossmap_node_get_id(gossmap, peer, &peer_id); |
| 591 | json_add_node_id(js, "id", &peer_id); |
| 592 | json_add_short_channel_id(js, "short_channel_id", &scid); |
| 593 | json_add_amount_msat_only(js, "fee_base_msat", |
| 594 | amount_msat(ourchan->half[!dir] |
| 595 | .base_fee)); |
| 596 | json_add_amount_msat_only(js, "htlc_max_msat", |
| 597 | amount_msat(fp16_to_u64(ourchan->half[!dir] |
| 598 | .htlc_max))); |
| 599 | json_add_u32(js, "fee_proportional_millionths", |
| 600 | ourchan->half[!dir].proportional_fee); |
| 601 | json_add_u32(js, "cltv_expiry_delta", ourchan->half[!dir].delay); |
| 602 | json_add_amount_msat_only(js, "incoming_capacity_msat", |
| 603 | peer_capacity(gossmap, |
| 604 | me, peer, ourchan)); |
| 605 | json_object_end(js); |
| 606 | } |
| 607 | done: |
| 608 | json_array_end(js); |
| 609 | |
| 610 | return command_finished(cmd, js); |
| 611 | } |
| 612 |
nothing calls this directly
no test coverage detected