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