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

Function coin_movement_notification_serialize

lightningd/notification.c:479–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477}
478
479static void coin_movement_notification_serialize(struct json_stream *stream,
480 struct coin_mvt *mvt)
481{
482 json_object_start(stream, "coin_movement");
483 json_add_num(stream, "version", mvt->version);
484 json_add_node_id(stream, "node_id", mvt->node_id);
485 if (mvt->peer_id)
486 json_add_node_id(stream, "peer_id", mvt->peer_id);
487 json_add_string(stream, "type", mvt_type_str(mvt->type));
488 json_add_string(stream, "account_id", mvt->account_id);
489 if (mvt->originating_acct)
490 json_add_string(stream, "originating_account",
491 mvt->originating_acct);
492 json_mvt_id(stream, mvt->type, &mvt->id);
493 if (deprecated_apis) {
494 json_add_amount_msat_only(stream, "credit", mvt->credit);
495 json_add_amount_msat_only(stream, "debit", mvt->debit);
496 }
497 json_add_amount_msat_only(stream, "credit_msat", mvt->credit);
498 json_add_amount_msat_only(stream, "debit_msat", mvt->debit);
499
500 /* Only chain movements */
501 if (mvt->output_val)
502 json_add_amount_sats_deprecated(stream, "output_value",
503 "output_msat",
504 *mvt->output_val);
505 if (mvt->output_count > 0)
506 json_add_num(stream, "output_count",
507 mvt->output_count);
508
509 if (mvt->fees) {
510 if (deprecated_apis)
511 json_add_amount_msat_only(stream, "fees",
512 *mvt->fees);
513 json_add_amount_msat_only(stream, "fees_msat",
514 *mvt->fees);
515 }
516
517 json_array_start(stream, "tags");
518 for (size_t i = 0; i < tal_count(mvt->tags); i++)
519 json_add_string(stream, NULL, mvt_tag_str(mvt->tags[i]));
520 json_array_end(stream);
521
522 if (mvt->type == CHAIN_MVT)
523 json_add_u32(stream, "blockheight", mvt->blockheight);
524
525 json_add_u32(stream, "timestamp", mvt->timestamp);
526 json_add_string(stream, "coin_type", mvt->hrp_name);
527
528 json_object_end(stream);
529}
530
531REGISTER_NOTIFICATION(coin_movement,
532 coin_movement_notification_serialize);

Callers

nothing calls this directly

Calls 13

mvt_type_strFunction · 0.85
json_mvt_idFunction · 0.85
json_object_startFunction · 0.50
json_add_numFunction · 0.50
json_add_node_idFunction · 0.50
json_add_stringFunction · 0.50
json_array_startFunction · 0.50
mvt_tag_strFunction · 0.50
json_array_endFunction · 0.50
json_add_u32Function · 0.50

Tested by

no test coverage detected