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

Function json_add_invoices

lightningd/invoice.c:1281–1320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1279AUTODATA(json_command, &invoice_command);
1280
1281static void json_add_invoices(struct json_stream *response,
1282 struct wallet *wallet,
1283 const struct json_escape *label,
1284 const struct sha256 *payment_hash,
1285 const struct sha256 *local_offer_id)
1286{
1287 struct invoice_iterator it;
1288 const struct invoice_details *details;
1289 struct invoice invoice;
1290
1291 /* Don't iterate entire db if we're just after one. */
1292 if (label) {
1293 if (wallet_invoice_find_by_label(wallet, &invoice, label)) {
1294 details =
1295 wallet_invoice_details(tmpctx, wallet, invoice);
1296 json_add_invoice(response, NULL, details);
1297 }
1298 } else if (payment_hash != NULL) {
1299 if (wallet_invoice_find_by_rhash(wallet, &invoice,
1300 payment_hash)) {
1301 details =
1302 wallet_invoice_details(tmpctx, wallet, invoice);
1303 json_add_invoice(response, NULL, details);
1304 }
1305 } else {
1306 memset(&it, 0, sizeof(it));
1307 while (wallet_invoice_iterate(wallet, &it)) {
1308 details = wallet_invoice_iterator_deref(response,
1309 wallet, &it);
1310 /* FIXME: db can filter this better! */
1311 if (local_offer_id) {
1312 if (!details->local_offer_id
1313 || !sha256_eq(local_offer_id,
1314 details->local_offer_id))
1315 continue;
1316 }
1317 json_add_invoice(response, NULL, details);
1318 }
1319 }
1320}
1321
1322static struct command_result *json_listinvoices(struct command *cmd,
1323 const char *buffer,

Callers 1

json_listinvoicesFunction · 0.85

Calls 6

json_add_invoiceFunction · 0.85
wallet_invoice_detailsFunction · 0.50
wallet_invoice_iterateFunction · 0.50

Tested by

no test coverage detected