| 78 | } |
| 79 | |
| 80 | static void json_add_index(struct command *cmd, |
| 81 | struct json_stream *response, |
| 82 | enum wait_subsystem subsystem, |
| 83 | enum wait_index index, |
| 84 | u64 val, |
| 85 | va_list *ap) |
| 86 | { |
| 87 | const char *name, *value; |
| 88 | va_list ap2; |
| 89 | json_add_string(response, "subsystem", wait_subsystem_name(subsystem)); |
| 90 | json_add_u64(response, wait_index_name(index), val); |
| 91 | |
| 92 | if (!ap) |
| 93 | return; |
| 94 | |
| 95 | va_copy(ap2, *ap); |
| 96 | /* "htlcs" etc never had details field: they came after! */ |
| 97 | if (subsystem < WAIT_SUBSYSTEM_HTLCS |
| 98 | && command_deprecated_out_ok(cmd, "details", "v25.05", "v26.06")) { |
| 99 | json_object_start(response, "details"); |
| 100 | while ((name = va_arg(*ap, const char *)) != NULL) { |
| 101 | value = va_arg(*ap, const char *); |
| 102 | if (!value) |
| 103 | continue; |
| 104 | |
| 105 | /* This is a hack! */ |
| 106 | if (name[0] == '=') { |
| 107 | /* Copy in literallty! */ |
| 108 | json_add_jsonstr(response, name + 1, value, strlen(value)); |
| 109 | } else { |
| 110 | json_add_string(response, name, value); |
| 111 | } |
| 112 | } |
| 113 | json_object_end(response); |
| 114 | } |
| 115 | |
| 116 | json_object_start(response, wait_subsystem_name(subsystem)); |
| 117 | while ((name = va_arg(ap2, const char *)) != NULL) { |
| 118 | value = va_arg(ap2, const char *); |
| 119 | if (!value) |
| 120 | continue; |
| 121 | |
| 122 | /* This is a hack! Means "copy in literally". */ |
| 123 | if (name[0] == '=') { |
| 124 | /* This is also a hack! Means "current value"*/ |
| 125 | if (streq(value, "")) |
| 126 | json_add_u64(response, name + 1, val); |
| 127 | else |
| 128 | json_add_jsonstr(response, name + 1, value, strlen(value)); |
| 129 | } else { |
| 130 | json_add_string(response, name, value); |
| 131 | } |
| 132 | } |
| 133 | json_object_end(response); |
| 134 | } |
| 135 | |
| 136 | static u64 wait_index_bump(struct lightningd *ld, |
| 137 | struct db *db, |
no test coverage detected