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

Function koinly_entry

plugins/bkpr/incomestmt.c:577–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575}
576
577static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
578{
579 /* Date */
580 time_t tv;
581 tv = ev->timestamp;
582 /* 2018-01-01 14:25 UTC */
583 char timebuf[sizeof("yyyy-mm-dd HH:MM UTC")];
584
585 /* Koinly counts invoice fee events inline */
586 if (streq(ev->tag, account_entry_tag_str(INVOICEFEE)))
587 return;
588
589 fprintf(csvf, "\n");
590
591 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M UTC", gmtime(&tv));
592 fprintf(csvf, "%s", timebuf);
593 fprintf(csvf, ",");
594
595 /* "Sent Amount,Sent Currency," */
596 if (!amount_msat_zero(ev->debit)) {
597 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
598 fprintf(csvf, ",");
599 fprintf(csvf, "%s", convert_asset_type(ev));
600 } else
601 fprintf(csvf, ",");
602
603 fprintf(csvf, ",");
604
605 /* Received Amount, Received Currency */
606 if (!amount_msat_zero(ev->credit)) {
607 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
608 fprintf(csvf, ",");
609 fprintf(csvf, "%s", convert_asset_type(ev));
610 } else
611 fprintf(csvf, ",");
612
613 fprintf(csvf, ",");
614
615
616 /* "Fee Amount,Fee Currency," */
617 if (!amount_msat_zero(ev->fees)
618 && streq(ev->tag, mvt_tag_str(INVOICE))) {
619 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
620 fprintf(csvf, ",");
621 fprintf(csvf, "%s", convert_asset_type(ev));
622 } else
623 fprintf(csvf, ",");
624
625 fprintf(csvf, ",");
626
627 /* Label */
628 fprintf(csvf, "%s", ev->tag);
629 fprintf(csvf, ",");
630
631 /* Description */
632 if (ev->desc)
633 fprintf(csvf, "%s", csv_safe_str(ev, ev->desc));
634 fprintf(csvf, ",");

Callers

nothing calls this directly

Calls 7

amount_msat_zeroFunction · 0.85
fmt_amount_msat_btcFunction · 0.85
convert_asset_typeFunction · 0.85
csv_safe_strFunction · 0.85
account_entry_tag_strFunction · 0.70
mvt_tag_strFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected