| 353 | } |
| 354 | |
| 355 | static struct command_result *listincoming_done(struct command *cmd, |
| 356 | const char *method, |
| 357 | const char *buf, |
| 358 | const jsmntok_t *result, |
| 359 | struct find_best_peer_data *data) |
| 360 | { |
| 361 | const jsmntok_t *arr, *t; |
| 362 | size_t i; |
| 363 | struct chaninfo *best = NULL; |
| 364 | |
| 365 | arr = json_get_member(buf, result, "incoming"); |
| 366 | json_for_each_arr(i, t, arr) { |
| 367 | struct chaninfo ci; |
| 368 | const jsmntok_t *pftok; |
| 369 | u8 *features; |
| 370 | u64 feature_bits; |
| 371 | const char *err; |
| 372 | struct amount_msat feebase; |
| 373 | bool enabled; |
| 374 | |
| 375 | err = json_scan(tmpctx, buf, t, |
| 376 | "{id:%," |
| 377 | "incoming_capacity_msat:%," |
| 378 | "htlc_min_msat:%," |
| 379 | "htlc_max_msat:%," |
| 380 | "fee_base_msat:%," |
| 381 | "fee_proportional_millionths:%," |
| 382 | "cltv_expiry_delta:%," |
| 383 | "enabled:%}", |
| 384 | JSON_SCAN(json_to_pubkey, &ci.id), |
| 385 | JSON_SCAN(json_to_msat, &ci.capacity), |
| 386 | JSON_SCAN(json_to_msat, &ci.htlc_min), |
| 387 | JSON_SCAN(json_to_msat, &ci.htlc_max), |
| 388 | JSON_SCAN(json_to_msat, &feebase), |
| 389 | JSON_SCAN(json_to_u32, &ci.feeppm), |
| 390 | JSON_SCAN(json_to_u32, &ci.cltv), |
| 391 | JSON_SCAN(json_to_bool, &enabled)); |
| 392 | if (err) { |
| 393 | plugin_log(cmd->plugin, LOG_BROKEN, |
| 394 | "Could not parse listincoming: %s", |
| 395 | err); |
| 396 | continue; |
| 397 | } |
| 398 | ci.feebase = feebase.millisatoshis; /* Raw: feebase */ |
| 399 | |
| 400 | if (data->fronting_nodes) { |
| 401 | if (!is_in_pubkeys(data->fronting_nodes, &ci.id)) |
| 402 | continue; |
| 403 | |
| 404 | /* If disconnected, don't eliminate, simply |
| 405 | * consider it last. */ |
| 406 | if (!enabled) { |
| 407 | ci.capacity = AMOUNT_MSAT(0); |
| 408 | enabled = true; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | /* Don't pick a peer which is disconnected */ |
nothing calls this directly
no test coverage detected