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

Function main

openingd/openingd.c:1449–1565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1447}
1448
1449int main(int argc, char *argv[])
1450{
1451 setup_locale();
1452
1453 u8 *msg;
1454 struct pollfd pollfd[2];
1455 struct state *state = tal(NULL, struct state);
1456 struct secret *none;
1457 struct channel_id *force_tmp_channel_id;
1458
1459 subdaemon_setup(argc, argv);
1460
1461 /*~ This makes status_failed, status_debug etc work synchronously by
1462 * writing to REQ_FD */
1463 status_setup_sync(REQ_FD);
1464
1465 /*~ The very first thing we read from lightningd is our init msg */
1466 msg = wire_sync_read(tmpctx, REQ_FD);
1467 if (!fromwire_openingd_init(state, msg,
1468 &chainparams,
1469 &state->our_features,
1470 &state->their_features,
1471 &state->localconf,
1472 &state->max_to_self_delay,
1473 &state->min_effective_htlc_capacity,
1474 &state->our_points,
1475 &state->our_funding_pubkey,
1476 &state->minimum_depth,
1477 &state->min_feerate, &state->max_feerate,
1478 &force_tmp_channel_id,
1479 &state->allowdustreserve))
1480 master_badmsg(WIRE_OPENINGD_INIT, msg);
1481
1482#if DEVELOPER
1483 dev_force_tmp_channel_id = force_tmp_channel_id;
1484#endif
1485
1486 /* 3 == peer, 4 = hsmd */
1487 state->pps = new_per_peer_state(state);
1488 per_peer_state_set_fd(state->pps, 3);
1489
1490 /*~ Initially we're not associated with a channel, but
1491 * handle_peer_gossip_or_error compares this. */
1492 memset(&state->channel_id, 0, sizeof(state->channel_id));
1493 state->channel = NULL;
1494
1495 /* Default this to zero, we only ever look at the local */
1496 state->remoteconf.max_dust_htlc_exposure_msat = AMOUNT_MSAT(0);
1497
1498 /*~ We set these to NULL, meaning no requirements on shutdown */
1499 state->upfront_shutdown_script[LOCAL]
1500 = state->upfront_shutdown_script[REMOTE]
1501 = NULL;
1502
1503 /*~ We need an initial per-commitment point whether we're funding or
1504 * they are, and lightningd has reserved a unique dbid for us already,
1505 * so we might as well get the hsm daemon to generate it now. */
1506 wire_sync_write(HSM_FD,

Callers

nothing calls this directly

Calls 15

setup_localeFunction · 0.85
new_per_peer_stateFunction · 0.85
per_peer_state_set_fdFunction · 0.85
tal_hexFunction · 0.85
clean_tmpctxFunction · 0.85
tal_freeFunction · 0.85
handle_master_inFunction · 0.70
handle_peer_inFunction · 0.70
subdaemon_setupFunction · 0.50
status_setup_syncFunction · 0.50
wire_sync_readFunction · 0.50

Tested by

no test coverage detected