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

Function main

openingd/openingd.c:1430–1543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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