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

Function cointrack_entry

plugins/bkpr/incomestmt.c:506–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

504}
505
506static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
507{
508 /* Date mm/dd/yyyy HH:MM:SS UTC */
509 time_t tv;
510 tv = ev->timestamp;
511 char timebuf[sizeof("mm/dd/yyyy HH:MM:SS")];
512
513 /* Cointrack counts invoice fee events inline */
514 if (streq(ev->tag, account_entry_tag_str(INVOICEFEE)))
515 return;
516
517 fprintf(csvf, "\n");
518
519 strftime(timebuf, sizeof(timebuf), "%m/%d/%Y %T", gmtime(&tv));
520 fprintf(csvf, "%s", timebuf);
521 fprintf(csvf, ",");
522
523 /* Received Quantity + Received Currency */
524 if (!amount_msat_zero(ev->credit)) {
525 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
526 fprintf(csvf, ",");
527 fprintf(csvf, "%s", convert_asset_type(ev));
528 } else
529 fprintf(csvf, ",");
530
531 fprintf(csvf, ",");
532
533 /* "Sent Quantity,Sent Currency," */
534 if (!amount_msat_zero(ev->debit)) {
535 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
536 fprintf(csvf, ",");
537 fprintf(csvf, "%s", convert_asset_type(ev));
538 } else
539 fprintf(csvf, ",");
540
541 fprintf(csvf, ",");
542
543 /* "Fee Amount,Fee Currency," */
544 if (!amount_msat_zero(ev->fees)
545 && streq(ev->tag, mvt_tag_str(INVOICE))) {
546 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
547 fprintf(csvf, ",");
548 fprintf(csvf, "%s", convert_asset_type(ev));
549 } else
550 fprintf(csvf, ",");
551
552 fprintf(csvf, ",");
553
554 /* Tag */
555 fprintf(csvf, "%s", income_event_cointrack_type(ev));
556 fprintf(csvf, ",");
557
558 /* Account */
559 fprintf(csvf, "%s", ev->acct_name);
560}
561
562static void koinly_header(FILE *csvf)
563{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected