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

Function harmony_entry

plugins/bkpr/incomestmt.c:681–752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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