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

Function handle_master_in

openingd/openingd.c:1385–1447  ·  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

1383/* Standard lightningd-fd-is-ready-to-read demux code. Again, we could hang
1384 * here, but if we can't trust our parent, who can we trust? */
1385static u8 *handle_master_in(struct state *state)
1386{
1387 u8 *msg = wire_sync_read(tmpctx, REQ_FD);
1388 enum openingd_wire t = fromwire_peektype(msg);
1389 u8 channel_flags;
1390 struct bitcoin_txid funding_txid;
1391 u16 funding_txout;
1392
1393 switch (t) {
1394 case WIRE_OPENINGD_FUNDER_START:
1395 if (!fromwire_openingd_funder_start(state, msg,
1396 &state->funding_sats,
1397 &state->push_msat,
1398 &state->upfront_shutdown_script[LOCAL],
1399 &state->local_upfront_shutdown_wallet_index,
1400 &state->feerate_per_kw,
1401 &state->channel_id,
1402 &channel_flags,
1403 &state->reserve))
1404 master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
1405 msg = funder_channel_start(state, channel_flags);
1406
1407 /* We want to keep openingd alive, since we're not done yet */
1408 if (msg)
1409 wire_sync_write(REQ_FD, take(msg));
1410 return NULL;
1411 case WIRE_OPENINGD_FUNDER_COMPLETE:
1412 if (!fromwire_openingd_funder_complete(state, msg,
1413 &funding_txid,
1414 &funding_txout,
1415 &state->channel_type))
1416 master_badmsg(WIRE_OPENINGD_FUNDER_COMPLETE, msg);
1417 state->funding.txid = funding_txid;
1418 state->funding.n = funding_txout;
1419 return funder_channel_complete(state);
1420 case WIRE_OPENINGD_FUNDER_CANCEL:
1421 /* We're aborting this, simple */
1422 if (!fromwire_openingd_funder_cancel(msg))
1423 master_badmsg(WIRE_OPENINGD_FUNDER_CANCEL, msg);
1424
1425 msg = towire_errorfmt(NULL, &state->channel_id, "Channel open canceled by us");
1426 peer_write(state->pps, take(msg));
1427 negotiation_aborted(state, "Channel open canceled by RPC");
1428 return NULL;
1429 case WIRE_OPENINGD_DEV_MEMLEAK:
1430#if DEVELOPER
1431 handle_dev_memleak(state, msg);
1432 return NULL;
1433#endif
1434 case WIRE_OPENINGD_DEV_MEMLEAK_REPLY:
1435 case WIRE_OPENINGD_INIT:
1436 case WIRE_OPENINGD_FUNDER_REPLY:
1437 case WIRE_OPENINGD_FUNDER_START_REPLY:
1438 case WIRE_OPENINGD_FUNDEE:
1439 case WIRE_OPENINGD_FAILED:
1440 case WIRE_OPENINGD_GOT_OFFER:
1441 case WIRE_OPENINGD_GOT_OFFER_REPLY:
1442 break;

Callers 1

mainFunction · 0.70

Calls 12

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

Tested by

no test coverage detected