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