| 3832 | #define ASSUMED_MAX_HTLCS_PER_CHANNEL 15 |
| 3833 | |
| 3834 | static struct command_result * |
| 3835 | payee_incoming_limit_count(struct command *cmd, |
| 3836 | const char *method, |
| 3837 | const char *buf, |
| 3838 | const jsmntok_t *result, |
| 3839 | struct payment *p) |
| 3840 | { |
| 3841 | const jsmntok_t *channelstok; |
| 3842 | size_t num_channels = 0; |
| 3843 | |
| 3844 | channelstok = json_get_member(buf, result, "channels"); |
| 3845 | assert(channelstok); |
| 3846 | |
| 3847 | /* Count channels. |
| 3848 | * `listchannels` returns half-channels, i.e. it normally |
| 3849 | * gives two objects per channel, one for each direction. |
| 3850 | * However, `listchannels <source>` returns only half-channel |
| 3851 | * objects whose `source` is the given channel. |
| 3852 | * Thus, the length of `channels` is accurately the number |
| 3853 | * of channels. |
| 3854 | */ |
| 3855 | num_channels = channelstok->size; |
| 3856 | |
| 3857 | /* If num_channels is 0, check if there is an invoice. */ |
| 3858 | if (num_channels == 0) |
| 3859 | num_channels = tal_count(p->routes); |
| 3860 | |
| 3861 | /* If we got a decent number of channels, limit! */ |
| 3862 | if (num_channels != 0) { |
| 3863 | const char *why; |
| 3864 | u32 lim; |
| 3865 | why = tal_fmt(tmpctx, |
| 3866 | "Destination %s has %zd channels, " |
| 3867 | "assuming %d HTLCs per channel", |
| 3868 | fmt_node_id(tmpctx, |
| 3869 | p->route_destination), |
| 3870 | num_channels, |
| 3871 | ASSUMED_MAX_HTLCS_PER_CHANNEL); |
| 3872 | lim = num_channels * ASSUMED_MAX_HTLCS_PER_CHANNEL; |
| 3873 | payment_lower_max_htlcs(p, lim, why); |
| 3874 | } |
| 3875 | |
| 3876 | return payment_continue(p); |
| 3877 | } |
| 3878 | |
| 3879 | static struct command_result *payee_incoming_limit_step_cb(void *d UNUSED, struct payment *p) |
| 3880 | { |
nothing calls this directly
no test coverage detected