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

Function harmony_entry

plugins/bkpr/incomestmt.c:705–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

703}
704
705static void harmony_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev)
706{
707 time_t tv;
708 tv = ev->timestamp;
709 /* datefmt: ISO-8601 */
710 char timebuf[sizeof("yyyy-mm-ddTHH:MM:SSZ")];
711 strftime(timebuf, sizeof(timebuf), "%Y-%m-%dT%TZ", gmtime(&tv));
712
713 /* New line! */
714 fprintf(csvf, "\n");
715
716 fprintf(csvf, "%s", timebuf);
717 fprintf(csvf, ",");
718
719 /* ",Venue" */
720 /* FIXME: use node_id ? */
721 fprintf(csvf, "cln");
722 fprintf(csvf, ",");
723
724 /* ",Type" */
725 fprintf(csvf, "%s", income_event_harmony_type(ev));
726 fprintf(csvf, ",");
727
728 /* ",Amount" */
729 if (!amount_msat_zero(ev->debit)) {
730 /* Debits are negative */
731 fprintf(csvf, "-");
732 fprintf(csvf, "%s",
733 fmt_amount_msat_btc(ctx, ev->debit, false));
734 } else
735 fprintf(csvf, "%s",
736 fmt_amount_msat_btc(ctx, ev->credit, false));
737
738 fprintf(csvf, ",");
739
740 /* ",Asset" */
741 fprintf(csvf, "%s", convert_asset_type(ev));
742 fprintf(csvf, ",");
743
744 /* ",Transaction ID" */
745 /* Some of this data is duplicated in other fields.
746 * We don't have a standard 'txid' for every event though */
747 if (ev->txid)
748 fprintf(csvf, "%s",
749 type_to_string(ctx, struct bitcoin_txid, ev->txid));
750 else if (ev->payment_id)
751 fprintf(csvf, "%s",
752 type_to_string(ctx, struct sha256, ev->payment_id));
753 else if (ev->outpoint)
754 fprintf(csvf, "%s",
755 type_to_string(ctx, struct bitcoin_outpoint,
756 ev->outpoint));
757 fprintf(csvf, ",");
758
759 /* ",Order ID" payment hash, if any */
760 if (ev->payment_id)
761 fprintf(csvf, "%s",
762 type_to_string(ctx, struct sha256, ev->payment_id));

Callers

nothing calls this directly

Calls 6

amount_msat_zeroFunction · 0.85
fmt_amount_msat_btcFunction · 0.85
convert_asset_typeFunction · 0.85
csv_safe_strFunction · 0.85
type_to_stringClass · 0.50

Tested by

no test coverage detected