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

Function format_event

plugins/bkpr/report.c:432–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432static char *format_event(const tal_t *ctx,
433 const struct report_format *fmt,
434 enum escape_format esc,
435 const struct bkpr *bkpr,
436 const struct income_event *e)
437{
438 char *out = tal_strdup(ctx, "");
439
440 for (size_t i = 0; i < tal_count(fmt->fmt); i++) {
441 const char *v;
442
443 if (fmt->fmt[i] == NULL) {
444 assert(fmt->str[i] != NULL);
445 out = tal_strcat(ctx, take(out), fmt->str[i]);
446 continue;
447 }
448
449 v = fmt->fmt[i](tmpctx, bkpr, e);
450 /* Treat ZERO_AMOUNT as absent when there are conditionals. */
451 if (v == ZERO_AMOUNT && (fmt->ifset[i] || fmt->ifnotset[i]))
452 v = NULL;
453
454 if (v) {
455 if (fmt->ifset[i]) {
456 out = tal_strcat(ctx, take(out),
457 format_event(tmpctx, fmt->ifset[i], esc, bkpr, e));
458 } else {
459 out = tal_strcat(ctx, take(out),
460 escape_value(tmpctx, v, esc));
461 }
462 continue;
463 }
464
465 if (fmt->ifnotset[i]) {
466 out = tal_strcat(ctx, take(out),
467 format_event(tmpctx, fmt->ifnotset[i], esc, bkpr, e));
468 }
469 }
470
471 return out;
472}
473
474struct command_result *do_bkpr_report(struct command *cmd,
475 struct report_info *info)

Calls 1

escape_valueFunction · 0.85