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

Function cointrack_entry

plugins/bkpr/incomestmt.c:483–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
484{
485 /* Date mm/dd/yyyy HH:MM:SS UTC */
486 time_t tv;
487 tv = ev->timestamp;
488 char timebuf[sizeof("mm/dd/yyyy HH:MM:SS")];
489
490 /* Cointrack counts invoice fee events inline */
491 if (streq(ev->tag, account_entry_tag_str(INVOICEFEE)))
492 return;
493
494 fprintf(csvf, "\n");
495
496 strftime(timebuf, sizeof(timebuf), "%m/%d/%Y %T", gmtime(&tv));
497 fprintf(csvf, "%s", timebuf);
498 fprintf(csvf, ",");
499
500 /* Received Quantity + Received Currency */
501 if (!amount_msat_is_zero(ev->credit)) {
502 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false));
503 fprintf(csvf, ",");
504 fprintf(csvf, "%s", asset_type_name());
505 } else
506 fprintf(csvf, ",");
507
508 fprintf(csvf, ",");
509
510 /* "Sent Quantity,Sent Currency," */
511 if (!amount_msat_is_zero(ev->debit)) {
512 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false));
513 fprintf(csvf, ",");
514 fprintf(csvf, "%s", asset_type_name());
515 } else
516 fprintf(csvf, ",");
517
518 fprintf(csvf, ",");
519
520 /* "Fee Amount,Fee Currency," */
521 if (!amount_msat_is_zero(ev->fees)
522 && streq(ev->tag, mvt_tag_str(MVT_INVOICE))) {
523 fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false));
524 fprintf(csvf, ",");
525 fprintf(csvf, "%s", asset_type_name());
526 } else
527 fprintf(csvf, ",");
528
529 fprintf(csvf, ",");
530
531 /* Tag */
532 fprintf(csvf, "%s", income_event_cointrack_type(ev));
533 fprintf(csvf, ",");
534
535 /* Account */
536 fprintf(csvf, "%s", ev->acct_name);
537}
538
539static void koinly_header(FILE *csvf)
540{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected