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

Function main

openingd/openingd.c:1438–1551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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