| 3036 | } |
| 3037 | |
| 3038 | static struct command_result *json_listhtlcs(struct command *cmd, |
| 3039 | const char *buffer, |
| 3040 | const jsmntok_t *obj UNNEEDED, |
| 3041 | const jsmntok_t *params) |
| 3042 | { |
| 3043 | struct json_stream *response; |
| 3044 | struct channel *chan; |
| 3045 | struct wallet_htlc_iter *i; |
| 3046 | struct short_channel_id scid; |
| 3047 | u64 htlc_id; |
| 3048 | int cltv_expiry; |
| 3049 | enum side owner; |
| 3050 | struct amount_msat msat; |
| 3051 | struct sha256 payment_hash; |
| 3052 | enum htlc_state hstate; |
| 3053 | |
| 3054 | if (!param(cmd, buffer, params, |
| 3055 | p_opt("id", param_channel, &chan), |
| 3056 | NULL)) |
| 3057 | return command_param_failed(); |
| 3058 | |
| 3059 | response = json_stream_success(cmd); |
| 3060 | json_array_start(response, "htlcs"); |
| 3061 | for (i = wallet_htlcs_first(cmd, cmd->ld->wallet, chan, |
| 3062 | &scid, &htlc_id, &cltv_expiry, &owner, &msat, |
| 3063 | &payment_hash, &hstate); |
| 3064 | i; |
| 3065 | i = wallet_htlcs_next(cmd->ld->wallet, i, |
| 3066 | &scid, &htlc_id, &cltv_expiry, &owner, &msat, |
| 3067 | &payment_hash, &hstate)) { |
| 3068 | json_object_start(response, NULL); |
| 3069 | json_add_short_channel_id(response, "short_channel_id", &scid); |
| 3070 | json_add_u64(response, "id", htlc_id); |
| 3071 | json_add_u32(response, "expiry", cltv_expiry); |
| 3072 | json_add_string(response, "direction", |
| 3073 | owner == LOCAL ? "out": "in"); |
| 3074 | json_add_amount_msat_only(response, "amount_msat", msat); |
| 3075 | json_add_sha256(response, "payment_hash", &payment_hash); |
| 3076 | json_add_string(response, "state", htlc_state_name(hstate)); |
| 3077 | json_object_end(response); |
| 3078 | } |
| 3079 | json_array_end(response); |
| 3080 | |
| 3081 | return command_success(cmd, response); |
| 3082 | } |
| 3083 | |
| 3084 | static const struct json_command listhtlcs_command = { |
| 3085 | "listhtlcs", |
nothing calls this directly
no test coverage detected