Now that we have the listpeers result for the root payment, let's search * for a direct channel that is a) connected and b) in state normal. We will * check the capacity based on the channel_hints in the override. */
| 3243 | * for a direct channel that is a) connected and b) in state normal. We will |
| 3244 | * check the capacity based on the channel_hints in the override. */ |
| 3245 | static struct command_result *direct_pay_listpeers(struct command *cmd, |
| 3246 | const char *buffer, |
| 3247 | const jsmntok_t *toks, |
| 3248 | struct payment *p) |
| 3249 | { |
| 3250 | struct listpeers_result *r = |
| 3251 | json_to_listpeers_result(tmpctx, buffer, toks); |
| 3252 | struct direct_pay_data *d = payment_mod_directpay_get_data(p); |
| 3253 | |
| 3254 | if (r && tal_count(r->peers) == 1) { |
| 3255 | struct listpeers_peer *peer = r->peers[0]; |
| 3256 | if (!peer->connected) |
| 3257 | goto cont; |
| 3258 | |
| 3259 | for (size_t i=0; i<tal_count(peer->channels); i++) { |
| 3260 | struct listpeers_channel *chan = r->peers[0]->channels[i]; |
| 3261 | if (!streq(chan->state, "CHANNELD_NORMAL")) |
| 3262 | continue; |
| 3263 | |
| 3264 | /* Must have either a local alias for zeroconf |
| 3265 | * channels or a final scid. */ |
| 3266 | assert(chan->alias[LOCAL] || chan->scid); |
| 3267 | d->chan = tal(d, struct short_channel_id_dir); |
| 3268 | if (chan->scid) { |
| 3269 | d->chan->scid = *chan->scid; |
| 3270 | d->chan->dir = *chan->direction; |
| 3271 | } else { |
| 3272 | d->chan->scid = *chan->alias[LOCAL]; |
| 3273 | d->chan->dir = 0; /* Don't care. */ |
| 3274 | } |
| 3275 | } |
| 3276 | } |
| 3277 | cont: |
| 3278 | direct_pay_override(p); |
| 3279 | return command_still_pending(cmd); |
| 3280 | |
| 3281 | } |
| 3282 | |
| 3283 | static void direct_pay_cb(struct direct_pay_data *d, struct payment *p) |
| 3284 | { |
nothing calls this directly
no test coverage detected