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

Function main

openingd/openingd.c:1433–1545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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
fromwire_peektypeFunction · 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

Tested by

no test coverage detected