MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_listhtlcs

Function json_listhtlcs

lightningd/peer_htlcs.c:3334–3390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3332}
3333
3334static struct command_result *json_listhtlcs(struct command *cmd,
3335 const char *buffer,
3336 const jsmntok_t *obj UNNEEDED,
3337 const jsmntok_t *params)
3338{
3339 struct json_stream *response;
3340 struct channel *chan;
3341 struct wallet_htlc_iter *i;
3342 struct short_channel_id scid;
3343 u64 htlc_id, created_index, updated_index;
3344 int cltv_expiry;
3345 enum side owner;
3346 struct amount_msat msat;
3347 struct sha256 payment_hash;
3348 enum htlc_state hstate;
3349 enum wait_index *listindex;
3350 u64 *liststart;
3351 u32 *listlimit;
3352
3353 if (!param(cmd, buffer, params,
3354 p_opt("id", param_channel, &chan),
3355 p_opt("index", param_index, &listindex),
3356 p_opt_def("start", param_u64, &liststart, 0),
3357 p_opt("limit", param_u32, &listlimit),
3358 NULL))
3359 return command_param_failed();
3360
3361 response = json_stream_success(cmd);
3362 json_array_start(response, "htlcs");
3363 for (i = wallet_htlcs_first(cmd, cmd->ld->wallet, chan,
3364 listindex, *liststart, listlimit,
3365 &scid, &htlc_id, &cltv_expiry, &owner, &msat,
3366 &payment_hash, &hstate,
3367 &created_index, &updated_index);
3368 i;
3369 i = wallet_htlcs_next(cmd->ld->wallet, i,
3370 &scid, &htlc_id, &cltv_expiry, &owner, &msat,
3371 &payment_hash, &hstate,
3372 &created_index, &updated_index)) {
3373 json_object_start(response, NULL);
3374 json_add_u64(response, "created_index", created_index);
3375 if (updated_index != 0)
3376 json_add_u64(response, "updated_index", updated_index);
3377 json_add_short_channel_id(response, "short_channel_id", scid);
3378 json_add_u64(response, "id", htlc_id);
3379 json_add_u32(response, "expiry", cltv_expiry);
3380 json_add_string(response, "direction",
3381 owner == LOCAL ? "out": "in");
3382 json_add_amount_msat(response, "amount_msat", msat);
3383 json_add_sha256(response, "payment_hash", &payment_hash);
3384 json_add_string(response, "state", htlc_state_name(hstate));
3385 json_object_end(response);
3386 }
3387 json_array_end(response);
3388
3389 return command_success(cmd, response);
3390}
3391

Callers

nothing calls this directly

Calls 15

json_array_startFunction · 0.85
wallet_htlcs_firstFunction · 0.85
wallet_htlcs_nextFunction · 0.85
json_object_startFunction · 0.85
json_add_u64Function · 0.85
json_add_u32Function · 0.85
json_add_amount_msatFunction · 0.85
json_add_sha256Function · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
command_param_failedFunction · 0.70

Tested by

no test coverage detected