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