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

Function json_add_uncommitted_channel

lightningd/opening_control.c:34–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32#include <wally_psbt.h>
33
34void json_add_uncommitted_channel(struct json_stream *response,
35 const struct uncommitted_channel *uc)
36{
37 struct amount_msat total, ours;
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_string(response, "state", "OPENINGD");
47 json_add_string(response, "owner", "lightning_openingd");
48 json_add_string(response, "opener", "local");
49 if (uc->transient_billboard) {
50 json_array_start(response, "status");
51 json_add_string(response, NULL, uc->transient_billboard);
52 json_array_end(response);
53 }
54
55 /* These should never fail. */
56 if (amount_sat_to_msat(&total, uc->fc->funding_sats)
57 && amount_msat_sub(&ours, total, uc->fc->push)) {
58 json_add_amount_msat_compat(response, ours,
59 "msatoshi_to_us", "to_us_msat");
60 json_add_amount_msat_compat(response, total,
61 "msatoshi_total", "total_msat");
62 }
63
64 json_array_start(response, "features");
65 if (feature_negotiated(uc->peer->ld->our_features,
66 uc->peer->their_features,
67 OPT_STATIC_REMOTEKEY))
68 json_add_string(response, NULL, "option_static_remotekey");
69
70 if (feature_negotiated(uc->peer->ld->our_features,
71 uc->peer->their_features,
72 OPT_ANCHOR_OUTPUTS))
73 json_add_string(response, NULL, "option_anchor_outputs");
74 json_array_end(response);
75 json_object_end(response);
76}
77
78/* Steals fields from uncommitted_channel: returns NULL if can't generate a
79 * key for this channel (shouldn't happen!). */

Callers 1

json_add_peerFunction · 0.70

Calls 9

amount_msat_subFunction · 0.85
json_object_startFunction · 0.50
json_add_stringFunction · 0.50
json_array_startFunction · 0.50
json_array_endFunction · 0.50
amount_sat_to_msatFunction · 0.50
feature_negotiatedFunction · 0.50
json_object_endFunction · 0.50

Tested by

no test coverage detected