| 1206 | } |
| 1207 | |
| 1208 | static struct command_result * |
| 1209 | listinvoice_done(struct command *cmd, const char *buf, |
| 1210 | const jsmntok_t *result, struct sha256 *payment_hash) |
| 1211 | { |
| 1212 | size_t i; |
| 1213 | const jsmntok_t *inv_arr_tok, *inv_tok; |
| 1214 | const char *desc; |
| 1215 | inv_arr_tok = json_get_member(buf, result, "invoices"); |
| 1216 | assert(inv_arr_tok->type == JSMN_ARRAY); |
| 1217 | |
| 1218 | desc = NULL; |
| 1219 | json_for_each_arr(i, inv_tok, inv_arr_tok) { |
| 1220 | char *err; |
| 1221 | |
| 1222 | /* Found desc in "description" */ |
| 1223 | if (!json_scan(cmd, buf, inv_tok, "{description:%}", |
| 1224 | JSON_SCAN_TAL(cmd, json_strdup, &desc))) |
| 1225 | break; |
| 1226 | |
| 1227 | /* if 'description' doesn't exist, try bolt11/bolt12 */ |
| 1228 | desc = fetch_out_desc_invstr(cmd, buf, inv_tok, &err); |
| 1229 | if (desc || err) { |
| 1230 | if (err) |
| 1231 | plugin_log(cmd->plugin, |
| 1232 | LOG_BROKEN, "%s", err); |
| 1233 | break; |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | if (desc) { |
| 1238 | db_begin_transaction(db); |
| 1239 | add_payment_hash_desc(db, payment_hash, |
| 1240 | json_escape_unescape(cmd, |
| 1241 | (struct json_escape *)desc)); |
| 1242 | db_commit_transaction(db); |
| 1243 | } else |
| 1244 | plugin_log(cmd->plugin, LOG_DBG, |
| 1245 | "listinvoices:" |
| 1246 | " description/bolt11/bolt12" |
| 1247 | " not found (%.*s)", |
| 1248 | result->end - result->start, buf); |
| 1249 | |
| 1250 | return notification_handled(cmd); |
| 1251 | } |
| 1252 | |
| 1253 | static struct command_result * |
| 1254 | listsendpays_done(struct command *cmd, const char *buf, |
nothing calls this directly
no test coverage detected