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

Function harmony_entry

plugins/bkpr/incomestmt.c:684–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682}
683
684static void harmony_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
685{
686 time_t tv;
687 tv = ev->timestamp;
688 /* datefmt: ISO-8601 */
689 char timebuf[sizeof("yyyy-mm-ddTHH:MM:SSZ")];
690 strftime(timebuf, sizeof(timebuf), "%Y-%m-%dT%TZ", gmtime(&tv));
691
692 /* New line! */
693 fprintf(csvf, "\n");
694
695 fprintf(csvf, "%s", timebuf);
696 fprintf(csvf, ",");
697
698 /* ",Venue" */
699 /* FIXME: use node_id ? */
700 fprintf(csvf, "cln");
701 fprintf(csvf, ",");
702
703 /* ",Type" */
704 fprintf(csvf, "%s", income_event_harmony_type(ev));
705 fprintf(csvf, ",");
706
707 /* ",Amount" */
708 if (!amount_msat_is_zero(ev->debit)) {
709 /* Debits are negative */
710 fprintf(csvf, "-");
711 fprintf(csvf, "%s",
712 fmt_amount_msat_btc(ctx, ev->debit, false));
713 } else
714 fprintf(csvf, "%s",
715 fmt_amount_msat_btc(ctx, ev->credit, false));
716
717 fprintf(csvf, ",");
718
719 /* ",Asset" */
720 fprintf(csvf, "%s", asset_type_name());
721 fprintf(csvf, ",");
722
723 /* ",Transaction ID" */
724 /* Some of this data is duplicated in other fields.
725 * We don't have a standard 'txid' for every event though */
726 if (ev->txid)
727 fprintf(csvf, "%s",
728 fmt_bitcoin_txid(ctx, ev->txid));
729 else if (ev->payment_id)
730 fprintf(csvf, "%s",
731 fmt_sha256(ctx, ev->payment_id));
732 else if (ev->outpoint)
733 fprintf(csvf, "%s",
734 fmt_bitcoin_outpoint(ctx, ev->outpoint));
735 fprintf(csvf, ",");
736
737 /* ",Order ID" payment hash, if any */
738 if (ev->payment_id)
739 fprintf(csvf, "%s",
740 fmt_sha256(ctx, ev->payment_id));
741 fprintf(csvf, ",");

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected