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

Function listinvoice_done

plugins/bkpr/bookkeeper.c:1208–1251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1206}
1207
1208static struct command_result *
1209listinvoice_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
1253static struct command_result *
1254listsendpays_done(struct command *cmd, const char *buf,

Callers

nothing calls this directly

Calls 8

fetch_out_desc_invstrFunction · 0.85
add_payment_hash_descFunction · 0.85
json_escape_unescapeFunction · 0.85
notification_handledFunction · 0.85
json_get_memberFunction · 0.50
json_scanFunction · 0.50
plugin_logFunction · 0.50
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected