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

Function koinly_entry

plugins/bkpr/incomestmt.c:557–626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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