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

Function json_add_htlcs

lightningd/peer_control.c:679–739  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677}
678
679static void json_add_htlcs(struct lightningd *ld,
680 struct json_stream *response,
681 const struct channel *channel)
682{
683 /* FIXME: make per-channel htlc maps! */
684 const struct htlc_in *hin;
685 struct htlc_in_map_iter ini;
686 const struct htlc_out *hout;
687 struct htlc_out_map_iter outi;
688 u32 local_feerate = get_feerate(channel->fee_states,
689 channel->opener, LOCAL);
690
691 /* FIXME: Add more fields. */
692 json_array_start(response, "htlcs");
693 for (hin = htlc_in_map_first(ld->htlcs_in, &ini);
694 hin;
695 hin = htlc_in_map_next(ld->htlcs_in, &ini)) {
696 if (hin->key.channel != channel)
697 continue;
698
699 json_object_start(response, NULL);
700 json_add_string(response, "direction", "in");
701 json_add_u64(response, "id", hin->key.id);
702 json_add_amount_msat(response, "amount_msat", hin->msat);
703 json_add_u32(response, "expiry", hin->cltv_expiry);
704 json_add_sha256(response, "payment_hash", &hin->payment_hash);
705 json_add_string(response, "state",
706 htlc_state_name(hin->hstate));
707 if (htlc_is_trimmed(REMOTE, hin->msat, local_feerate,
708 channel->our_config.dust_limit, LOCAL,
709 channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
710 channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX)))
711 json_add_bool(response, "local_trimmed", true);
712 if (hin->status != NULL)
713 json_add_string(response, "status", hin->status);
714 json_object_end(response);
715 }
716
717 for (hout = htlc_out_map_first(ld->htlcs_out, &outi);
718 hout;
719 hout = htlc_out_map_next(ld->htlcs_out, &outi)) {
720 if (hout->key.channel != channel)
721 continue;
722
723 json_object_start(response, NULL);
724 json_add_string(response, "direction", "out");
725 json_add_u64(response, "id", hout->key.id);
726 json_add_amount_msat(response, "amount_msat", hout->msat);
727 json_add_u64(response, "expiry", hout->cltv_expiry);
728 json_add_sha256(response, "payment_hash", &hout->payment_hash);
729 json_add_string(response, "state",
730 htlc_state_name(hout->hstate));
731 if (htlc_is_trimmed(LOCAL, hout->msat, local_feerate,
732 channel->our_config.dust_limit, LOCAL,
733 channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED),
734 channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX)))
735 json_add_bool(response, "local_trimmed", true);
736 json_object_end(response);

Callers 1

peer_control.cFile · 0.85

Calls 14

json_array_startFunction · 0.85
json_object_startFunction · 0.85
json_add_u64Function · 0.85
json_add_amount_msatFunction · 0.85
json_add_u32Function · 0.85
json_add_sha256Function · 0.85
htlc_is_trimmedFunction · 0.85
json_add_boolFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
channel_hasFunction · 0.70
get_feerateFunction · 0.50

Tested by

no test coverage detected