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

Function opening_negotiate_msg

openingd/openingd.c:178–223  ·  view source on GitHub ↗

~ Handle random messages we might get during opening negotiation, (eg. gossip) * returning the first non-handled one, or NULL if we aborted negotiation. */

Source from the content-addressed store, hash-verified

176/*~ Handle random messages we might get during opening negotiation, (eg. gossip)
177 * returning the first non-handled one, or NULL if we aborted negotiation. */
178static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state,
179 const struct channel_id *alternate)
180{
181 /* This is an event loop of its own. That's generally considered poor
182 * form, but we use it in a very limited way. */
183 for (;;) {
184 u8 *msg;
185 const char *err;
186
187 /* The event loop is responsible for freeing tmpctx, so our
188 * temporary allocations don't grow unbounded. */
189 clean_tmpctx();
190
191 /* This helper routine polls both the peer and gossipd. */
192 msg = peer_read(ctx, state->pps);
193
194 /* BOLT #1:
195 *
196 * A receiving node:
197 * - upon receiving a message of _odd_, unknown type:
198 * - MUST ignore the received message.
199 */
200 if (is_unknown_msg_discardable(msg))
201 continue;
202
203 /* A helper which decodes an error. */
204 err = is_peer_error(tmpctx, msg);
205 if (err) {
206 negotiation_aborted(state,
207 tal_fmt(tmpctx, "They sent %s",
208 err));
209 /* Return NULL so caller knows to stop negotiating. */
210 return tal_free(msg);
211 }
212
213 err = is_peer_warning(tmpctx, msg);
214 if (err) {
215 status_info("They sent %s", err);
216 tal_free(msg);
217 continue;
218 }
219
220 /* If we get here, it's an interesting message. */
221 return msg;
222 }
223}
224
225static bool setup_channel_funder(struct state *state)
226{

Callers 3

funder_channel_startFunction · 0.70
fundee_channelFunction · 0.70

Calls 7

clean_tmpctxFunction · 0.85
peer_readFunction · 0.85
is_peer_errorFunction · 0.85
tal_freeFunction · 0.85
is_peer_warningFunction · 0.85
negotiation_abortedFunction · 0.70

Tested by

no test coverage detected