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

Function billboard_message

common/billboard.c:6–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <common/utils.h>
5
6char *billboard_message(const tal_t *ctx,
7 const bool channel_ready[NUM_SIDES],
8 const bool have_sigs[NUM_SIDES],
9 const bool shutdown_sent[NUM_SIDES],
10 u32 depth_togo,
11 size_t num_htlcs)
12{
13 const char *funding_status, *announce_status,
14 *shutdown_status COMPILER_WANTS_INIT("gcc 8.3.0");
15
16 if (channel_ready[LOCAL] && channel_ready[REMOTE])
17 funding_status = "Channel ready for use.";
18 else if (!channel_ready[LOCAL] && !channel_ready[REMOTE])
19 funding_status = tal_fmt(ctx,
20 "Funding needs %d more"
21 " confirmations to be ready.",
22 depth_togo);
23 else if (channel_ready[LOCAL] && !channel_ready[REMOTE])
24 funding_status = "We've confirmed channel ready, they haven't yet.";
25 else {
26 assert(!channel_ready[LOCAL] && channel_ready[REMOTE]);
27 funding_status = "They've confirmed channel ready, we haven't yet.";
28 }
29
30 if (have_sigs) {
31 if (have_sigs[LOCAL] && have_sigs[REMOTE])
32 announce_status = " Channel announced.";
33 else if (have_sigs[LOCAL] && !have_sigs[REMOTE])
34 announce_status = " Waiting for their"
35 " announcement signatures.";
36 else if (!have_sigs[LOCAL] && have_sigs[REMOTE])
37 announce_status = " They need our announcement"
38 " signatures.";
39 else {
40 assert(!have_sigs[LOCAL] && !have_sigs[REMOTE]);
41 announce_status = "";
42 }
43 } else
44 announce_status = "";
45
46 if (!shutdown_sent[LOCAL] && !shutdown_sent[REMOTE])
47 shutdown_status = "";
48 else if (!shutdown_sent[LOCAL] && shutdown_sent[REMOTE])
49 shutdown_status = " They've sent shutdown, waiting for ours";
50 else if (shutdown_sent[LOCAL] && !shutdown_sent[REMOTE])
51 shutdown_status = " We've send shutdown, waiting for theirs";
52 else if (shutdown_sent[LOCAL] && shutdown_sent[REMOTE]) {
53 if (num_htlcs)
54 shutdown_status = tal_fmt(ctx,
55 " Shutdown messages"
56 " exchanged, waiting for"
57 " %zu HTLCs to complete.",
58 num_htlcs);
59 else
60 shutdown_status = tal_fmt(ctx,
61 " Shutdown messages"
62 " exchanged.");
63 }

Callers 2

billboard_updateFunction · 0.85
billboard_updateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected