| 3230 | } |
| 3231 | |
| 3232 | static struct command_result *json_listhtlcs(struct command *cmd, |
| 3233 | const char *buffer, |
| 3234 | const jsmntok_t *obj UNNEEDED, |
| 3235 | const jsmntok_t *params) |
| 3236 | { |
| 3237 | struct json_stream *response; |
| 3238 | struct channel *chan; |
| 3239 | struct wallet_htlc_iter *i; |
| 3240 | struct short_channel_id scid; |
| 3241 | u64 htlc_id, created_index, updated_index; |
| 3242 | int cltv_expiry; |
| 3243 | enum side owner; |
| 3244 | struct amount_msat msat; |
| 3245 | struct sha256 payment_hash; |
| 3246 | enum htlc_state hstate; |
| 3247 | enum wait_index *listindex; |
| 3248 | u64 *liststart; |
| 3249 | u32 *listlimit; |
| 3250 | |
| 3251 | if (!param(cmd, buffer, params, |
| 3252 | p_opt("id", param_channel, &chan), |
| 3253 | p_opt("index", param_index, &listindex), |
| 3254 | p_opt_def("start", param_u64, &liststart, 0), |
| 3255 | p_opt("limit", param_u32, &listlimit), |
| 3256 | NULL)) |
| 3257 | return command_param_failed(); |
| 3258 | |
| 3259 | response = json_stream_success(cmd); |
| 3260 | json_array_start(response, "htlcs"); |
| 3261 | for (i = wallet_htlcs_first(cmd, cmd->ld->wallet, chan, |
| 3262 | listindex, *liststart, listlimit, |
| 3263 | &scid, &htlc_id, &cltv_expiry, &owner, &msat, |
| 3264 | &payment_hash, &hstate, |
| 3265 | &created_index, &updated_index); |
| 3266 | i; |
| 3267 | i = wallet_htlcs_next(cmd->ld->wallet, i, |
| 3268 | &scid, &htlc_id, &cltv_expiry, &owner, &msat, |
| 3269 | &payment_hash, &hstate, |
| 3270 | &created_index, &updated_index)) { |
| 3271 | json_object_start(response, NULL); |
| 3272 | json_add_u64(response, "created_index", created_index); |
| 3273 | if (updated_index != 0) |
| 3274 | json_add_u64(response, "updated_index", updated_index); |
| 3275 | json_add_short_channel_id(response, "short_channel_id", scid); |
| 3276 | json_add_u64(response, "id", htlc_id); |
| 3277 | json_add_u32(response, "expiry", cltv_expiry); |
| 3278 | json_add_string(response, "direction", |
| 3279 | owner == LOCAL ? "out": "in"); |
| 3280 | json_add_amount_msat(response, "amount_msat", msat); |
| 3281 | json_add_sha256(response, "payment_hash", &payment_hash); |
| 3282 | json_add_string(response, "state", htlc_state_name(hstate)); |
| 3283 | json_object_end(response); |
| 3284 | } |
| 3285 | json_array_end(response); |
| 3286 | |
| 3287 | return command_success(cmd, response); |
| 3288 | } |
| 3289 |
nothing calls this directly
no test coverage detected