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

Function handle_master_in

openingd/openingd.c:1360–1428  ·  view source on GitHub ↗

Standard lightningd-fd-is-ready-to-read demux code. Again, we could hang * here, but if we can't trust our parent, who can we trust? */

Source from the content-addressed store, hash-verified

1358/* Standard lightningd-fd-is-ready-to-read demux code. Again, we could hang
1359 * here, but if we can't trust our parent, who can we trust? */
1360static u8 *handle_master_in(struct state *state)
1361{
1362 u8 *msg = wire_sync_read(tmpctx, REQ_FD);
1363 enum openingd_wire t = fromwire_peektype(msg);
1364 u8 channel_flags;
1365 struct bitcoin_txid funding_txid;
1366 u16 funding_txout;
1367 u32 nonanchor_feerate, anchor_feerate;
1368 struct channel_type *ctype;
1369
1370 switch (t) {
1371 case WIRE_OPENINGD_FUNDER_START:
1372 if (!fromwire_openingd_funder_start(state, msg,
1373 &state->funding_sats,
1374 &state->push_msat,
1375 &state->upfront_shutdown_script[LOCAL],
1376 &state->local_upfront_shutdown_wallet_index,
1377 &nonanchor_feerate,
1378 &anchor_feerate,
1379 &state->channel_id,
1380 &channel_flags,
1381 &state->reserve,
1382 &ctype))
1383 master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
1384 msg = funder_channel_start(state, channel_flags, nonanchor_feerate, anchor_feerate, ctype);
1385 tal_free(ctype);
1386
1387 /* We want to keep openingd alive, since we're not done yet */
1388 if (msg)
1389 wire_sync_write(REQ_FD, take(msg));
1390 return NULL;
1391 case WIRE_OPENINGD_FUNDER_COMPLETE:
1392 if (!fromwire_openingd_funder_complete(state, msg,
1393 &funding_txid,
1394 &funding_txout,
1395 &state->channel_type))
1396 master_badmsg(WIRE_OPENINGD_FUNDER_COMPLETE, msg);
1397 state->funding.txid = funding_txid;
1398 state->funding.n = funding_txout;
1399 return funder_channel_complete(state);
1400 case WIRE_OPENINGD_FUNDER_CANCEL:
1401 /* We're aborting this, simple */
1402 if (!fromwire_openingd_funder_cancel(msg))
1403 master_badmsg(WIRE_OPENINGD_FUNDER_CANCEL, msg);
1404
1405 msg = towire_errorfmt(NULL, &state->channel_id, "Channel open canceled by us");
1406 peer_write(state->pps, take(msg));
1407 negotiation_aborted(state, "Channel open canceled by RPC");
1408 return NULL;
1409 case WIRE_OPENINGD_DEV_MEMLEAK:
1410 if (state->developer) {
1411 handle_dev_memleak(state, msg);
1412 return NULL;
1413 }
1414 /* fall thru */
1415 case WIRE_OPENINGD_DEV_MEMLEAK_REPLY:
1416 case WIRE_OPENINGD_INIT:
1417 case WIRE_OPENINGD_FUNDER_REPLY:

Callers 1

mainFunction · 0.70

Calls 13

fromwire_peektypeFunction · 0.85
funder_channel_startFunction · 0.85
tal_freeFunction · 0.85
funder_channel_completeFunction · 0.85
towire_errorfmtFunction · 0.85
peer_writeFunction · 0.85
tal_hexFunction · 0.85
negotiation_abortedFunction · 0.70
handle_dev_memleakFunction · 0.70
wire_sync_readFunction · 0.50
master_badmsgFunction · 0.50
wire_sync_writeFunction · 0.50

Tested by

no test coverage detected