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? */
| 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? */ |
| 1385 | static 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; |
no test coverage detected