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

Function json_add_uncommitted_channel

lightningd/opening_control.c:31–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#include <wally_psbt.h>
30
31void json_add_uncommitted_channel(struct command *cmd,
32 struct json_stream *response,
33 const struct uncommitted_channel *uc,
34 const struct peer *peer)
35{
36 struct amount_msat total, ours;
37
38 if (!uc)
39 return;
40
41 /* If we're chatting but no channel, that's shown by connected: True */
42 if (!uc->fc)
43 return;
44
45 json_object_start(response, NULL);
46 json_add_node_id(response, "peer_id", &peer->id);
47 json_add_bool(response, "peer_connected", peer->connected == PEER_CONNECTED);
48 json_add_channel_type(response, "channel_type", uc->fc->channel_type);
49 json_add_string(response, "state", "OPENINGD");
50 json_add_string(response, "owner", "lightning_openingd");
51 json_add_string(response, "opener", "local");
52 if (uc->transient_billboard) {
53 json_array_start(response, "status");
54 json_add_string(response, NULL, uc->transient_billboard);
55 json_array_end(response);
56 }
57
58 /* These should never fail. */
59 if (amount_sat_to_msat(&total, uc->fc->funding_sats)
60 && amount_msat_sub(&ours, total, uc->fc->push)) {
61 json_add_amount_msat(response, "to_us_msat", ours);
62 json_add_amount_msat(response, "total_msat", total);
63 }
64
65 json_array_start(response, "features");
66 if (feature_negotiated(uc->peer->ld->our_features,
67 uc->peer->their_features,
68 OPT_STATIC_REMOTEKEY))
69 json_add_string(response, NULL, "option_static_remotekey");
70
71 if (feature_negotiated(uc->peer->ld->our_features,
72 uc->peer->their_features,
73 OPT_ANCHORS_ZERO_FEE_HTLC_TX))
74 json_add_string(response, NULL, "option_anchors");
75
76 json_array_end(response);
77 json_object_end(response);
78}
79
80/* Steals fields from uncommitted_channel: returns NULL if can't generate a
81 * key for this channel (shouldn't happen!). */

Callers 1

json_add_peerchannelsFunction · 0.70

Calls 12

json_object_startFunction · 0.85
json_add_node_idFunction · 0.85
json_add_boolFunction · 0.85
json_add_channel_typeFunction · 0.85
json_array_startFunction · 0.85
json_array_endFunction · 0.85
amount_msat_subFunction · 0.85
json_add_amount_msatFunction · 0.85
feature_negotiatedFunction · 0.85
json_object_endFunction · 0.85
json_add_stringFunction · 0.50
amount_sat_to_msatFunction · 0.50

Tested by

no test coverage detected