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

Function koinly_entry

plugins/bkpr/incomestmt.c:554–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554static void koinly_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
555{
556 /* Date */
557 time_t tv;
558 tv = ev->timestamp;
559 /* 2018-01-01 14:25 UTC */
560 char timebuf[sizeof("yyyy-mm-dd HH:MM UTC")];
561
562 /* Koinly counts invoice fee events inline */
563 if (streq(ev->tag, account_entry_tag_str(INVOICEFEE)))
564 return;
565
566 fprintf(csvf, "\n");
567
568 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M UTC", gmtime(&tv));
569 fprintf(csvf, "%s", timebuf);
570 fprintf(csvf, ",");
571
572 /* "Sent Amount,Sent Currency," */
573 if (!amount_msat_is_zero(ev->debit)) {
574 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
575 fprintf(csvf, ",");
576 fprintf(csvf, "%s", asset_type_name());
577 } else
578 fprintf(csvf, ",");
579
580 fprintf(csvf, ",");
581
582 /* Received Amount, Received Currency */
583 if (!amount_msat_is_zero(ev->credit)) {
584 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
585 fprintf(csvf, ",");
586 fprintf(csvf, "%s", asset_type_name());
587 } else
588 fprintf(csvf, ",");
589
590 fprintf(csvf, ",");
591
592
593 /* "Fee Amount,Fee Currency," */
594 if (!amount_msat_is_zero(ev->fees)
595 && streq(ev->tag, mvt_tag_str(MVT_INVOICE))) {
596 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
597 fprintf(csvf, ",");
598 fprintf(csvf, "%s", asset_type_name());
599 } else
600 fprintf(csvf, ",");
601
602 fprintf(csvf, ",");
603
604 /* Label */
605 fprintf(csvf, "%s", ev->tag);
606 fprintf(csvf, ",");
607
608 /* Description */
609 if (ev->desc)
610 fprintf(csvf, "%s", csv_safe_str(ev, ev->desc));
611 fprintf(csvf, ",");

Callers

nothing calls this directly

Calls 9

account_entry_tag_strFunction · 0.85
amount_msat_is_zeroFunction · 0.85
fmt_amount_msat_btcFunction · 0.85
asset_type_nameFunction · 0.85
mvt_tag_strFunction · 0.85
csv_safe_strFunction · 0.85
fmt_bitcoin_txidFunction · 0.85
fmt_sha256Function · 0.85
fmt_bitcoin_outpointFunction · 0.85

Tested by

no test coverage detected