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

Function opening_negotiate_msg

openingd/openingd.c:181–226  ·  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

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

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